Commit Graph
10 Commits
Author SHA1 Message Date
Menghuan1918 4ebd3e9bdd chore: adapt sidebar to DSH 0.2.1-alpha.5 2026-10-17 02:12:44 +08:00
Menghuan1918 57fe6e657d test: 临时目录清理统一走 removeTree(修 Windows 上的 ENOTEMPTY 竞态)
CI 在 windows lane 上红在**清理**而不是断言:
`rmSync(scratch, { recursive: true, force: true })` 抛
`ENOTEMPTY: rmdir …archives-pvpAWR`——刚被 kill 的 zip/tar 子进程(以及刚关闭的
fs.watch / 刚结束的 git 子进程)还没被系统释放句柄,删除于是失败在一个**已经通过**
的用例的 afterEach 里(那一次 2466 个用例全过,只有清理挂掉,整个 lane 变红)。

`maxRetries` + `retryDelay` 正是 Node 为这种场景提供的对策,因此新增
`tests/temp-tree.ts` 的 `removeTree()`,把 30 份 spec(175 处 `{ recursive, force }`
写法)统一换过去,并清掉随之不再使用的 `rmSync` 导入。POSIX 上首次即成功、不触发
重试,行为不变。

本地:typecheck / lint 干净,全量 210 文件 / 2524 通过。
2026-10-16 00:51:11 +08:00
Menghuan1918 62b797665f docs: 接入指南 / README / AGENTS / CHANGELOG 与设计文档同步
- 指南 §5.2 / §5.3 / §6:FileViewerProps 的 truncated → size + largeFile、
  新增 visible;fs.read 三态;新增 fs.readPage;fs.write 迁到 raw 路由
- 指南 §6.1:打包改原生命令的完整说明(工具探测顺序、-y 与符号链接环、
  公共祖先定位、临时文件 + 流式下发、unavailable 501),删掉已不存在的
  ZIP_MAX_ENTRIES / ZIP_MAX_BYTES 与 src/zip.ts 的说法
- README / README_EN:挂载示例的四个限额收缩为 listLimit,并说明三个键
  已删除、旧 profile 残留值会被静默忽略
- AGENTS §6 测试地图:6 tab + 4 viewer、新增的六个守护 spec
- CHANGELOG / CHANGELOG_EN:未发布段
- docs/plans/2026-10-11-streaming-transfer-jsonl-preview.md:设计过程、
  与 VS Code Web 的对照(含「VS Code 并不分页」的纠错)与实施偏差记录

另修一处 lint:jsonl.ts 的 truncate 助手在重写摘要后成了死代码
2026-10-11 22:43:30 +08:00
HuanLinOTO 356c3b1dbc Merge PR #682: fix(trust-fence): 允许 bfcache 恢复的图片带过期 cross-site 标记(PNG 预览空白修复)
# Conflicts:
#	tests/trusted-hosts.spec.ts
2026-10-01 17:18:31 +08:00
MXY e1c7ac3491 fix(ws): fence 接受桌面壳页面 origin,补全自定义协议下的 WebSocket 修复
上一个提交把 WebSocket 的 base 改到 `__DSH_TRANSPORT__.streamBaseUrl`,解决了
`ws://app` 解析不了的问题;但握手仍然失败。桌面壳页面位于 `dsh-app://app`,
它的 WebSocket 升级直连 Host 的 loopback 地址(壳的 `protocol.handle` 不承载
upgrade),Chromium 因此带上 `Origin: dsh-app://app`。fence 按 hostname 比较,
字面量 `app` 永远不等于 `127.0.0.1`,socket 在 `handleUpgrade` 之前就被销毁。

HTTP 路由不受影响,原因在壳自己:它转发前会删掉 origin 头,Host 侧看到的是
无 Origin 请求,fence 本就放行。所以同一个 fence 只在 WebSocket 路径上暴露。

改动:fence 在 Host 检查通过之后接受精确字符串 `dsh-app://app` —— 与壳自身
request forwarder 的信任集合(非 null 时只认这一个)逐字一致。同 scheme 的
其他 origin、跨站 origin 仍然拒绝;无 Origin 的请求本来就走放行分支,因此这
不是在既有信任面之外新增入口。

测试:`tests/trusted-hosts.spec.ts` 新增 4 例,其中两条是负向控制(Host 非
我方时仍拒、精确匹配而非前缀匹配)。两条新断言各做过一次变异验证:禁用该
分支只让「接受」一例变红,改成前缀匹配只让「精确」一例变红。
2026-10-01 02:30:26 +08:00
Pluto-Yt 32e8f56c4a fix(trust-fence): accept a bfcache-restored image with a stale cross-site marker
Chromium can restore a same-origin image subresource from bfcache while the
request still carries `Sec-Fetch-Site: cross-site`. The fence refused every
cross-site marker outright, so /sidebar/file answered 403 and the image
preview stayed blank until the tab was reloaded. Reproduced on a real
`dsh web` instance: the same URL returns 200 image/png normally and 403 once
the cross-site marker is present with no Origin.

The exception is deliberately narrow — GET /sidebar/file only, browser image
subresources only (`Sec-Fetch-Mode: no-cors` + `Sec-Fetch-Dest: image`), and
the unforgeable Referer must name the request's exact authority. `Sec-Fetch-*`
and `Referer` are forbidden request headers, so a foreign page cannot forge
them. API requests, non-GET media, non-image subresources, CORS image reads,
foreign/look-alike/malformed Referers and Referer-less requests stay refused,
and the existing Origin hostname check is unchanged.

tests/trusted-hosts.spec.ts covers the accepted loopback and trusted-remote
cases plus the refusal matrix over real GET /sidebar/file requests.
2026-09-15 10:47:30 +08:00
Menghuan1918 ba0114749f feat(dsh): adapt to DSH 0.1.5-alpha.1
Move the plugin onto the DSH 0.1.5-alpha.1 baseline (peer floor
^0.1.5-alpha.1, CI pinned to the alpha dist-tag) and fix the two host
contract changes that alpha line introduced.

Baseline:
- all @deepseek-ai/dsh-* peer/dev deps -> 0.1.5-alpha.1; optional peer
  @deepseek-ai/dsh-client-ui-sidebar-right (declared, unused until the
  native-surface phase); devDep @deepseek-ai/dsh-agent-loop (inbox fold)
- dsh.plugin.json engines >=0.1.5-alpha.1; version 0.19.0-alpha.0;
  SIDEBAR_SERVICE_VERSION follows

Live assistant stream (assistant/chunk is gone):
- 0.1.5 publishes in-flight model deltas as process-local
  agent/assistant-stream frames instead of durable assistant/chunk events
  and embeds the settled stream in assistant/message / assistant/attempt.
  src/assistant-live.ts folds the frames into a bounded per-session buffer;
  sidechat.events serves the current attempt as `live` rows (replaced every
  poll, never a delta) and the transcript renders them; the inherited
  in-progress snapshot reads message content / attempt stream / live frames.

Cold session reads (persistence.inspect is gone):
- 0.1.5 reads a stored session through an explicit read handle
  (open(id,'read') -> handle.read() -> close()). src/session-store.ts owns
  that protocol; every cold read (sidechat transcript, cold-resume preset,
  session.cwd, changes replay) goes through it.

Dead code and docs:
- drop the remote.session.openWorkspacePath interception: 0.1.5's chat opens
  files through ctx.sidebarRight.openResource instead, so the wrapper had no
  caller and would hijack the host's "open in app" gesture; the
  interceptOpenPath pref, its settings row and its locale keys go with it
- AGENTS.md §3 + external-plugin-guide.md describe the new baseline
- vitest setup bridges Node's localStorage accessor to jsdom's store (the
  pre-existing 26 failures on Node >= 22)
- desktop-layout e2e seeds through host RPC and types into the Lexical
  composer (0.1.5 replaced the textarea) instead of driving the directory
  picker

Verified: pnpm typecheck / lint / build / test (124 files, 1327 tests) /
check:consumer-types, plus pnpm test:mount against a real
@deepseek-ai/dsh@0.1.5-alpha.1 host (18/18).
2026-09-09 11:15:30 +08:00
MXY 8181e13b52 fix(trust-fence): Origin 校验改按 hostname 比较,对齐 DSH 网关栅栏(Edge 151 无端口 Origin 修复)
镜像栅栏此前按 host(含端口)比较 Origin,而部分 Chromium 构建(Edge 151)会把非默认端口 loopback 页面的 Origin 序列化为不带端口的形式,导致 /sidebar/* 在 Edge 151 下全部 403 forbidden。DSH 官方栅栏(api-request-trust.ts)已改为 hostname 比较,本提交同步该语义:端口不再重决信任,Host 栅栏与 sec-fetch-site 拒绝逻辑不变。

测试:tests/trusted-hosts.spec.ts 新增无端口 Origin 放行、不同 hostname 拒绝、null origin 拒绝三个回归用例;本地 scratch 挂载 + curl 实测通过。
2026-08-18 23:23:17 +08:00
Menghuan1918 c0aeefc936 fix: 回应审查保留意见 — 测试钉住跨站分支、删死接口、修正注释措辞
- tests/trusted-hosts.spec.ts:用例 4 改为受信 origin + cross-site marker
  以隔离拒绝分支(原同时踩 marker 与 origin 两条路径,删除 marker 检查
  测试依旧通过——变异验证现仅该用例失败);接受侧断言从 not.toBe(403)
  收紧为 toBe(200),请求体补 sessionId(session.cwd 的真实契约)
- src/context-types.ts:删除已无引用的 SidebarLoader/SidebarLoaderEntry
  死接口(loader 成员移除后残留)
- src/index.ts:修正 "same list / 无需重启" 过承诺注释,改为与 /api 网关
  同源的准确表述(boot 采样快照 + --trusted-host 权威,读 live 服务值)
2026-08-14 23:03:26 +08:00
Rookie_Zoe ea250c9e87 fix: /sidebar 信任栅栏改用 webRuntime.trustedHosts,修复远程访问全部 403
根因:trustedHostsOf 按 entry.options.name === 'connection' 查找 connection
行,但该行 name 是模块标识符(@deepseek-ai/dsh-client-connection,id 才是
connection),查找永远落空 → trustedHosts 为空 → 栅栏只放行回环 Host → 通过
域名或局域网 IP 访问时 /sidebar/bundle chunk 加载失败、资源管理器/代码管理器
全部 403 forbidden(/api 不受影响,它读的是 apply 时已求值的配置)。

修复(按 review 建议):host half 直接注入 webRuntime 服务,栅栏每请求实时
读取 ctx.webRuntime.trustedHosts —— 与 /api 网关同一信任列表(启动时采样的
LAN IP 字面量 + --trusted-host 权威),不再依赖 Loader entry / fiber /
!!js 节点求值;自定义信任域名由 dsh web --trusted-host 提供。

新增 tests/trusted-hosts.spec.ts 回归:域名/局域网放行、空列表仅回环、
跨站标记拒绝、每请求实时读取;plugin-shape 断言同步更新。
2026-08-14 23:03:26 +08:00