Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ jobs:
src/tools/__tests__/background-full-page.browser.test.ts
src/session-manager/__tests__/incognito.browser.test.ts
src/transport/__tests__/remote-connection.browser.test.ts
src/entrypoints/__tests__/runtime-injection.browser.test.ts
- name: Run headed background execution, screenshot and window-routing regressions
run: |
sudo apt-get update
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ determines which versions can connect.

### Changed

- **Zero-tax Chrome MV3 `registration: "runtime"` dual-tier content script injection, SW-startup orphan Agent Window reaping, and shared `content/dom-primitives.ts`**: Migrated all four MV3 content-script entrypoints (`content`, `cooperation.content`, `record-frame.content`, and `long-screenshot-page.content`) out of static `manifest.json` `content_scripts` into idempotent runtime injection (`claimIdempotentContentScript`) with `noScriptStartedPostMessage: true` so ordinary browsing incurs zero content-script, `window.postMessage`, or React 19 overhead; injected Tier A (`content.js` and `long-screenshot-page.js`) per `tabId`/`documentId` via idempotent `ensureOverlayInjected` across controlled task tabs, `webNavigation.onCommitted` (including Speculation Rules prerender outermost frames, sequenced strictly after Tier B `cooperation.js` arming/repair), pre-confirmation `tab_borrow` candidate user tabs, `request_help`, `record`, and active `video` overlays while skipping uninjected tabs on `hidden` / `CAPTURE_SUPPRESS` / `INPUT_PASSTHROUGH`; dynamically registered/unregistered pure-TypeScript Tier B (`cooperation.js` and `record-frame.js`) with `persistAcrossSessions: false` when active sessions or recordings transition between `0` and `>= 1`, loading silently at `document_start` with 0 DOM listeners and 0 startup IPC until armed by Background (`COOPERATION_ARM_FRAME` / `RECORD_FRAME_START` plus 50ms per-tab subframe coalescing, `cooperation.js` co-injection in `injectRecordFrameAllFrames`, and non-destructive per-frame `injectCooperationAllFrames` repair across `tab_borrow`, `ack === undefined` frames, and dynamically inserted light-DOM or open/closed `ShadowRoot` `about:blank` / `srcdoc` subframes); tracked dedicated Agent Window `ownedTabIds` in `chrome.storage.session` (`bsk.orphan_agent_windows`) to reap orphaned pure Agent Windows on Service Worker restart without ever closing windows containing user, borrowed, or human-preserved tabs; and extracted `apps/extension/src/content/dom-primitives.ts`.
- **Single daemon `tool_pipeline`, 4-module `daemon/ipc` decomposition, non-blocking persistence, and shared `cli::orchestration` kernel**: Decomposed 3,489-line `daemon/ipc.rs` into `daemon/tool_pipeline.rs` (single unified `tool.*` pipeline with RAII `AuditTicketGuard`, `SessionActivityGuard`, `ToolInflightRegistry`, `IntentWal`, and post-settlement scope/run-log reconciliation), `daemon/ipc_sessions.rs`, `daemon/ipc_transport.rs`, and a slim `daemon/ipc.rs` router; promoted exhaustive `OutcomeKind` (`bsk-protocol`) / `Outcome` (`daemon/tool_policy.rs`) routing in `daemon/queue.rs`; moved `TransferRegistry` staging/import/session-teardown I/O, `AuditStore` JSONL `sync_data()` writes (including `session.user_interrupt` markers), and monotonic-sequence `IntentWal` flushes/atomic `sync_data()` compactions out of global state `Mutex`es and Tokio worker threads via `spawn_blocking`; and extracted `cli/orchestration.rs` to share Canvas screenshot point-click validation, `open`/`sync`/action/positive timeout bounds, explicit `--session` + `--browser` conflict checks, cached VOM hydration, and 2-second `CANCEL_RESPONSE_GRACE` settlement across `bsk` CLI and `bsk mcp`.
- **100% strongly typed `bsk-protocol` contracts, typed `EventFrame` payloads, out-of-band WS correlation, and native `ActionMetadata` SSOT**: Replaced all 19 remaining `serde_json::Value` RPC contracts in `Method::contract_meta` (`ToolCooperate`, `LocalAuth*`, `AuditRequest`, `LedgerRequest`, `Session*`, `BrowserList`, `ToolOperationAwait`, and `Transfer*`) with strict Rust/JSON Schema structs, replaced untyped `EventFrame.payload: Value` across Rust and TypeScript with an exhaustive 10-variant `EventFrame` discriminated union, moved `_audit_id` and `_operation_id` out of business `params` into top-level `RequestFrame` envelope fields (deleting in-place `params` mutation and `stripEnvelopeParams`), embedded `ActionMetadata` / passive `context_id` natively with `#[serde(deny_unknown_fields)]` across all 23 `Full` and 9 passive-read `*Params` structs (eliminating post-hoc `catalog.rs` JSON Schema surgery and manual 4-key copy/re-insertion in `daemon/ipc.rs`), and unified `MethodSpec.action_metadata` (`Full` / `ContextOnly` / `TabBindingContext` / `Dynamic` / `None`) as the single source of truth across `bsk-protocol` and `bsk-cli`.
- **Unified daemon session teardown, strongly typed `IpcEnvelope`, and MCP host-scope lifecycle**: Converged all 6 session teardown paths across `state.rs`, `ws.rs`, `ipc.rs`, `start.rs`, `session_requests.rs`, and `sessions.rs` into `DaemonState::teardown_session(session_id, reason)` covering all 12 session-associated state tables, promoted `HOST_AGENT_ENV_KEYS` ahead of transient `mcp:<pid>:<nonce>` scopes so `bsk mcp` and `bsk` CLI within the same host agent thread share one implicit session (while immediately stopping orphan sessions on `stdio` EOF or disconnect read errors only for exclusive transient `mcp:` scopes), added 256-entry LRU eviction for inactive scope tombstones and idle `start_locks`, and replaced private `_`-prefixed IPC JSON fields with strongly typed `IpcEnvelope` metadata (`IpcRequestMeta` / `IpcResponseMeta`) negotiated via `StatusResult.ipc_envelope` and `DaemonInfo.ipc_envelope` (preserving bidirectional rolling-upgrade compatibility with pre-envelope `"2.0"` `bsk mcp`, CLI, and daemon processes) plus explicit extension-WS `WsCorrelation`.
Expand All @@ -41,6 +42,7 @@ determines which versions can connect.

### Fixed

- Ignored internal `data-bsk-*` attributes and `<browser-skill-overlay>` (`[data-bsk-overlay]`) ShadowHost mutations in `cooperation-capture.ts` so active recording and sensitive-field markers no longer advance `FrameState.structure`, excluded extension ShadowRoot UI controls (`HelpRequestOverlay`, `RecordOverlay`, `BorrowConfirmationOverlay`) across `record-capture.ts`, `record-hover-surface.ts`, and `cooperation-capture.ts` so overlay interactions and hover surfaces are never mis-recorded as webpage steps, and re-evaluated tab control ownership after awaiting `ensureOverlayInjected` so mid-injection tab detachments never flash stale `control` state.
- VOM token estimation now handles unpaired UTF-16 surrogates without combining them with the following symbol or throwing a `RangeError`; valid emoji pairs retain their existing estimates.

- Fixed non-`start` `tool.video` (`status`/`stop`/`list`/`get`/`delete`), `tool.operation_await`, and scope-bound `tool.wait_ms` bypassing `ToolInflightRegistry` cancellation (and scope-bound `tool.wait_ms` omitting `SessionActivityGuard` idle leases or `ToolDialogAccept`/`ToolDialogDismiss` `decision_lock` waits masking `UserAborted`/`SessionEnded` reasons) on `session.user_interrupt` and `DaemonState::teardown_session` (`session.window_closed` / idle reap / disconnect), fixed `IntentWal` `flush_pending_async` returning before concurrently drained `DISPATCHED` records hit disk and `on_session_ended` leaving un-reconciled `dispatched`/`unknown` records on disk across daemon restarts, fixed `queue.rs` misattributing deadline cancel-cleanup timeouts on non-transfer tools (`navigate`, `screenshot_full_page`, `window_resize`, etc.) as `"file transfer timed out"` (`transfer_outcome_unknown`) and stripping extension `effect_state` / `cancelled_before_dispatch` metadata on cancelled file transfers (including when terminal session teardown reasons are present), fixed Canvas screenshot point-click and zero-timeout validation drift across `bsk` CLI and MCP (`bsk_interact`, `bsk_page`, `bsk_inspect`, `bsk_tabs`, `bsk_assist`, `bsk sync --wait-for/--wait-not --timeout-ms` up to `120000`ms, and structured `scope_browser_conflict` errors on MCP `bsk_session(open)`), and fixed MCP `notifications/cancelled` dropping in-flight IPC futures at `0`ms without awaiting `CANCEL_RESPONSE_GRACE` (recovering real `effect_state` receipts and releasing staged upload files on `cancelled_before_dispatch`).
Expand Down Expand Up @@ -100,6 +102,7 @@ determines which versions can connect.

### Removed

- Removed dead write-only `apps/extension/src/lib/sessions-live-flag.ts` (`bh.sessions_live` / `SESSIONS_LIVE_FLAG_KEY`) and ineffective Isolated World `history.pushState` / `history.replaceState` monkey-patching in `apps/extension/src/content/record-capture.ts`.
- Removed `reattachIfSoftDetached`, `reconcileSoftDetachedFrames`, and `resolveTarget` compensation hooks from `CdpRunner`, `RefStore.remapChildFrameSessions`, partial hand-written `CdpRunner` wrapper object literals (replaced with full `delegateCdpRunner` delegation), and isolated default `new ChromiumCdp()` fallback instances outside `background.ts`.
- Removed deprecated `TraceV2` recording types/converters (retaining `TraceV3` only), all 9 legacy `1.x` `Feature::*` compatibility gates, extension/daemon `"1.6"`/`LEGACY_MIN_COMPATIBLE_PEER` shims, duplicate `DragParams.observation_id` / legacy drag modes, and duplicate `wire_*` runtime validators from generated TypeScript artifacts.
- Retired and removed `packages/dsh-plugin-browserskill`, its standalone release
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CLI 和扩展可以分别发布,能否连接由协议兼容性决定。更新

### 变更

- **Chrome MV3 `registration: "runtime"` 零税双层按需内容脚本注入、SW 启动期孤儿 Agent 窗口兜底回收与共享 `content/dom-primitives.ts`**:将全部 4 个 MV3 内容脚本入口(`content`、`cooperation.content`、`record-frame.content` 与 `long-screenshot-page.content`)以 `noScriptStartedPostMessage: true` 与 `claimIdempotentContentScript` 幂等守卫迁出静态 `manifest.json` `content_scripts`,彻底消除日常浏览普通网页时的全局 `<all_urls>` 内容脚本、`window.postMessage` 广播与 React 19 加载税;通过幂等 `ensureOverlayInjected` 对受控任务标签页、`webNavigation.onCommitted`(含 Speculation Rules 预渲染顶层帧,且严格排在 Tier B `cooperation.js` 激活/补注入之后)、确认前 `tab_borrow` 候选用户标签页、`request_help`、`record` 与活跃 `video` 浮层按 `tabId`/`documentId` 单点注入 Tier A(`content.js` 与 `long-screenshot-page.js`),并在 `hidden` / `CAPTURE_SUPPRESS` / `INPUT_PASSTHROUGH` 时跳过未注入标签页;在活跃会话或录制于 `0` 与 `>= 1` 间切换时以 `persistAcrossSessions: false` 动态启停纯 TS 轻量 Tier B(`cooperation.js` 与 `record-frame.js`),使其在 `document_start` 零 DOM 监听、零启动唤醒 IPC 静默加载并由后台按需点名激活(`COOPERATION_ARM_FRAME` / `RECORD_FRAME_START` 配合单标签页 50ms 子帧合并去抖、`injectRecordFrameAllFrames` 协同注入 `cooperation.js`,以及在 `tab_borrow`、`ack === undefined` 帧与动态插入的普通 DOM 或 open/closed `ShadowRoot` 内同源 `about:blank` / `srcdoc` 子帧上进行无损按帧探测补注入);通过 `chrome.storage.session`(`bsk.orphan_agent_windows`)追踪独占 Agent 窗口创建的标签页集合,在 Service Worker 重启后精准回收无活跃会话的纯孤儿 Agent 窗口(严格保留含用户、借用或人工接管标签页的窗口);并抽离共享 DOM 原语模块 `apps/extension/src/content/dom-primitives.ts`。
- **守护进程单一 `tool_pipeline` 工具管线、`daemon/ipc` 四模块拆解、无锁阻塞持久化与 `cli::orchestration` 客户端共享编排内核**:将 3,489 行的 `daemon/ipc.rs` 拆解为 `daemon/tool_pipeline.rs`(统一收口全部 `tool.*` 执行路径的 RAII `AuditTicketGuard`、`SessionActivityGuard`、`ToolInflightRegistry`、`IntentWal` 与作用域/运行日志结算)、`daemon/ipc_sessions.rs`、`daemon/ipc_transport.rs` 及精简路由层 `daemon/ipc.rs`;在 `bsk-protocol` 与 `daemon/tool_policy.rs` / `daemon/queue.rs` 中建立穷尽式 `OutcomeKind` / `Outcome` 结果与超时归因路由;通过局部状态分离与 `spawn_blocking` 将 `TransferRegistry` 大文件暂存/导入复制/会话销毁目录清理、`AuditStore` JSONL `sync_data()` 刷盘(含 `session.user_interrupt` 标记)与单调序号 `IntentWal` 刷盘及 `sync_data()` 原子压缩彻底移出全局状态 `Mutex` 与 Tokio 工作线程阻塞路径;并提取 `cli/orchestration.rs` 统一 `bsk` CLI 与 `bsk mcp` 的 Canvas 截图坐标点击校验、`open`/`sync`/动作/正数超时边界、显式 `--session` + `--browser` 冲突校验、缓存 VOM 回填以及 2 秒 `CANCEL_RESPONSE_GRACE` 优雅取消结算。
- **`bsk-protocol` 100% 强类型化、强类型 `EventFrame` 事件载荷、WS 信封相关性解耦与原生 `ActionMetadata` 单一事实源**:将 `Method::contract_meta` 中剩余全部 19 个 `serde_json::Value` RPC 契约(`ToolCooperate`、`LocalAuth*`、`AuditRequest`、`LedgerRequest`、`Session*`、`BrowserList`、`ToolOperationAwait` 与 `Transfer*`)收口为编译期强类型 Rust/JSON Schema 结构;将跨 Rust 与 TypeScript 的裸 `EventFrame.payload: Value` 升级为穷尽覆盖全部 10 类事件的强类型 `EventFrame` 判别联合;将扩展 WS 请求上的 `_audit_id` 与 `_operation_id` 迁出业务 `params` 并提升至 `RequestFrame` 顶层可选字段(彻底移除原地篡改 `params` 与扩展侧 `stripEnvelopeParams` 补偿剥离);在全部 23 个 `Full` 与 9 个被动只读 `*Params` 结构中原生内嵌 `ActionMetadata` / `context_id` 并统一启用 `#[serde(deny_unknown_fields)]`(净删 `catalog.rs` 事后 JSON Schema 拼接补丁与 `daemon/ipc.rs` 手工拷出再塞回 4 个元字段的胶水代码);并将 `MethodSpec.action_metadata`(`Full` / `ContextOnly` / `TabBindingContext` / `Dynamic` / `None`)打通为 `bsk-protocol` 与 `bsk-cli` 共享的唯一真源。
- **统一守护进程会话销毁入口、强类型 `IpcEnvelope` 与 MCP 宿主作用域生命周期**:将 `state.rs`、`ws.rs`、`ipc.rs`、`start.rs`、`session_requests.rs` 与 `sessions.rs` 中分散的 6 处会话清理路径统一收口至覆盖全部 12 张会话状态表的 `DaemonState::teardown_session(session_id, reason)`;在 `ImplicitScopeRegistry` 中将宿主子代理环境变量(`HOST_AGENT_ENV_KEYS`)优先级提升至瞬态 `mcp:<pid>:<nonce>` 之前,使同一宿主线程内的 `bsk mcp` 与 `bsk` CLI 自动共享隐式会话,同时仅对无宿主环境变量兜底的独占瞬态 `mcp:` 连接在 `stdio` EOF 或读取异常断开时立即停止并回收孤儿会话;为非活跃作用域墓碑与空闲 `start_locks` 增加 256 容量上限的 LRU 淘汰;并以通过 `StatusResult.ipc_envelope` 与 `DaemonInfo.ipc_envelope` 协商的强类型 `IpcEnvelope`(`IpcRequestMeta` / `IpcResponseMeta`,保留与升级期间未重启的 `"2.0"` 旧版 `bsk mcp`、CLI 及守护进程间的双向滚动升级兼容)及显式扩展 WS `WsCorrelation` 替代本地 IPC 载荷混装的私有 `_` 字段。
Expand All @@ -28,6 +29,7 @@ CLI 和扩展可以分别发布,能否连接由协议兼容性决定。更新

### 修复

- 在 `cooperation-capture.ts` 中忽略扩展内部私有 `data-bsk-*` 属性与 `<browser-skill-overlay>`(`[data-bsk-overlay]`)ShadowHost 变更以消除录制/敏感字段标记对 `FrameState.structure` 的自污染,在 `record-capture.ts`、`record-hover-surface.ts` 与 `cooperation-capture.ts` 中统一过滤扩展自身 ShadowRoot 浮层控件(`HelpRequestOverlay`、`RecordOverlay`、`BorrowConfirmationOverlay`)防止浮层内点击/输入或悬停面被误录为网页操作,并在 `ensureOverlayInjected` 异步注入完成后二次校验标签页受控归属以杜绝注入途中断开控制导致的陈旧浮层闪现。
- VOM Token 估算现在能处理未配对的 UTF-16 代理字符,不会再误合并后续符号或抛出 `RangeError`;有效 emoji 代理对的估算保持不变。

- 修复非 `start` 的 `tool.video`(`status`/`stop`/`list`/`get`/`delete`)、`tool.operation_await` 与作用域绑定的 `tool.wait_ms` 未接入 `ToolInflightRegistry` 而在 `session.user_interrupt` 及 `DaemonState::teardown_session`(`session.window_closed` / 空闲超时回收 / 断连)时无法立即唤醒取消与转发 WS `cancel` 的问题(同时补齐作用域绑定 `tool.wait_ms` 的 `SessionActivityGuard` 空闲租约,并修复 `ToolDialogAccept`/`ToolDialogDismiss` 等待 `decision_lock` 被中断或销毁时丢失 `UserAborted`/`SessionEnded` 错误原因的问题),修复 `IntentWal` `flush_pending_async` 在并发已被取出的 `DISPATCHED` 批次落盘前提前返回以及 `on_session_ended` 未将会话结束对账持久化导致 daemon 重启后误冻已关闭会话的竞态,修复 `queue.rs` 在非文件传输工具(`navigate`、`screenshot_full_page`、`window_resize` 等)发生超时取消清理挂起时被兜底分支误报为 `"file transfer timed out"`(`transfer_outcome_unknown`)以及在文件传输取消清理完成(含携带会话终止 `reason` 时)丢弃扩展侧 `effect_state` / `cancelled_before_dispatch` 元数据的缺陷,修复 `bsk` CLI 与 MCP(`bsk_interact`、`bsk_page`、`bsk_inspect`、`bsk_tabs`、`bsk_assist`)间的 Canvas 截图坐标点击与零值超时校验漂移(同时对齐 `bsk sync --wait-for/--wait-not --timeout-ms` `120000`ms 上限与 MCP `bsk_session(open)` 的结构化 `scope_browser_conflict` 错误),并修复 MCP `notifications/cancelled` 在 `0`ms 直接丢弃在途 IPC 请求而丢失真实 `effect_state` 及在 `cancelled_before_dispatch` 时泄漏已暂存上传文件的缺陷。
Expand All @@ -48,6 +50,7 @@ CLI 和扩展可以分别发布,能否连接由协议兼容性决定。更新

### 移除

- 移除已沦为只写不读死代码的 `apps/extension/src/lib/sessions-live-flag.ts`(`bh.sessions_live` / `SESSIONS_LIVE_FLAG_KEY`)以及 `apps/extension/src/content/record-capture.ts` 中在隔离世界无效的 `history.pushState` / `history.replaceState` 重写死代码。
- 从 `CdpRunner` 及上层调用栈净删 `reattachIfSoftDetached`、`reconcileSoftDetachedFrames` 与 `resolveTarget` 三大外泄补偿钩子,移除 `RefStore.remapChildFrameSessions`、手写残缺局部 `CdpRunner` 对象字面量(统一收口为 `delegateCdpRunner` 全量委托代理)以及 `background.ts` 以外所有孤立默认的 `new ChromiumCdp()` 野实例。
- 移除已废弃的 `TraceV2` 录制协议类型与转换器(仅保留 `TraceV3`)、全部 9 套 `1.x` `Feature::*` 历史版本协商门禁、扩展/守护进程 `"1.6"`/`LEGACY_MIN_COMPATIBLE_PEER` 兼容兜底、重复字段 `DragParams.observation_id` / 旧拖拽模式以及生成 TS 产物中重复导出的 `wire_*` 运行时校验器。
- 下线并整体移除 `packages/dsh-plugin-browserskill`、独立发版流水线及专属测试桩;DeepSeek Harness
Expand Down
Loading
Loading