@ai-workbench/remote-agent 0.9.0-toolbridge.2 → 0.9.0-toolbridge.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/README.md +12 -3
  2. package/dist/acp.d.ts +10 -0
  3. package/dist/acp.js +71 -6
  4. package/dist/agents.d.ts +2 -0
  5. package/dist/agents.js +4 -3
  6. package/dist/claude-local.d.ts +1 -0
  7. package/dist/claude-local.js +2 -2
  8. package/dist/client.js +1 -1
  9. package/dist/cloud-failure.d.ts +11 -0
  10. package/dist/cloud-failure.js +54 -0
  11. package/dist/employee-mcp.d.ts +8 -24
  12. package/dist/employee-mcp.js +24 -188
  13. package/dist/employee-tools.d.ts +5 -22
  14. package/dist/employee-tools.js +4 -292
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.js +31 -15
  17. package/dist/model-catalog.d.ts +1 -1
  18. package/dist/model-catalog.js +4 -0
  19. package/dist/presentation.js +1 -0
  20. package/dist/provider.js +4 -2
  21. package/dist/toolbridge-loop.js +3 -0
  22. package/dist/toolbridge-table.js +4 -1
  23. package/dist/toolbridge.d.ts +1 -0
  24. package/dist/toolbridge.js +1 -0
  25. package/package.json +10 -6
  26. package/helpers/ripgrep/LICENSE-vscode +0 -13
  27. package/helpers/ripgrep/PROVENANCE.md +0 -9
  28. package/helpers/ripgrep/darwin-arm64/rg +0 -0
  29. package/helpers/ripgrep/darwin-x64/rg +0 -0
  30. package/helpers/ripgrep/manifest.json +0 -56
  31. package/helpers/ripgrep/notices/COPYING-ripgrep +0 -3
  32. package/helpers/ripgrep/notices/DEPENDENCIES.json +0 -946
  33. package/helpers/ripgrep/notices/LICENCE-PCRE2.md +0 -103
  34. package/helpers/ripgrep/notices/LICENSE-MIT-ripgrep +0 -21
  35. package/helpers/ripgrep/notices/UNLICENSE-ripgrep +0 -24
  36. package/helpers/ripgrep/notices/aho-corasick-1.1.3/COPYING +0 -3
  37. package/helpers/ripgrep/notices/aho-corasick-1.1.3/LICENSE-MIT +0 -21
  38. package/helpers/ripgrep/notices/aho-corasick-1.1.3/UNLICENSE +0 -24
  39. package/helpers/ripgrep/notices/anyhow-1.0.100/LICENSE-APACHE +0 -176
  40. package/helpers/ripgrep/notices/anyhow-1.0.100/LICENSE-MIT +0 -23
  41. package/helpers/ripgrep/notices/arbitrary-1.4.2/LICENSE-APACHE +0 -201
  42. package/helpers/ripgrep/notices/arbitrary-1.4.2/LICENSE-MIT +0 -27
  43. package/helpers/ripgrep/notices/bstr-1.12.0/COPYING +0 -8
  44. package/helpers/ripgrep/notices/bstr-1.12.0/LICENSE-APACHE +0 -201
  45. package/helpers/ripgrep/notices/bstr-1.12.0/LICENSE-MIT +0 -21
  46. package/helpers/ripgrep/notices/cc-1.2.41/LICENSE-APACHE +0 -201
  47. package/helpers/ripgrep/notices/cc-1.2.41/LICENSE-MIT +0 -25
  48. package/helpers/ripgrep/notices/cfg-if-1.0.4/LICENSE-APACHE +0 -201
  49. package/helpers/ripgrep/notices/cfg-if-1.0.4/LICENSE-MIT +0 -25
  50. package/helpers/ripgrep/notices/crossbeam-channel-0.5.15/LICENSE-APACHE +0 -201
  51. package/helpers/ripgrep/notices/crossbeam-channel-0.5.15/LICENSE-MIT +0 -27
  52. package/helpers/ripgrep/notices/crossbeam-channel-0.5.15/LICENSE-THIRD-PARTY +0 -593
  53. package/helpers/ripgrep/notices/crossbeam-deque-0.8.6/LICENSE-APACHE +0 -201
  54. package/helpers/ripgrep/notices/crossbeam-deque-0.8.6/LICENSE-MIT +0 -27
  55. package/helpers/ripgrep/notices/crossbeam-epoch-0.9.18/LICENSE-APACHE +0 -201
  56. package/helpers/ripgrep/notices/crossbeam-epoch-0.9.18/LICENSE-MIT +0 -27
  57. package/helpers/ripgrep/notices/crossbeam-utils-0.8.21/LICENSE-APACHE +0 -201
  58. package/helpers/ripgrep/notices/crossbeam-utils-0.8.21/LICENSE-MIT +0 -27
  59. package/helpers/ripgrep/notices/derive_arbitrary-1.4.2/LICENSE-APACHE +0 -201
  60. package/helpers/ripgrep/notices/derive_arbitrary-1.4.2/LICENSE-MIT +0 -27
  61. package/helpers/ripgrep/notices/encoding_rs-0.8.35/COPYRIGHT +0 -17
  62. package/helpers/ripgrep/notices/encoding_rs-0.8.35/LICENSE-APACHE +0 -202
  63. package/helpers/ripgrep/notices/encoding_rs-0.8.35/LICENSE-MIT +0 -25
  64. package/helpers/ripgrep/notices/encoding_rs-0.8.35/LICENSE-WHATWG +0 -26
  65. package/helpers/ripgrep/notices/encoding_rs_io-0.1.7/COPYING +0 -8
  66. package/helpers/ripgrep/notices/encoding_rs_io-0.1.7/LICENSE-APACHE +0 -201
  67. package/helpers/ripgrep/notices/encoding_rs_io-0.1.7/LICENSE-MIT +0 -21
  68. package/helpers/ripgrep/notices/find-msvc-tools-0.1.4/LICENSE-APACHE +0 -201
  69. package/helpers/ripgrep/notices/find-msvc-tools-0.1.4/LICENSE-MIT +0 -25
  70. package/helpers/ripgrep/notices/getrandom-0.3.4/LICENSE-APACHE +0 -201
  71. package/helpers/ripgrep/notices/getrandom-0.3.4/LICENSE-MIT +0 -26
  72. package/helpers/ripgrep/notices/glob-0.3.3/LICENSE-APACHE +0 -201
  73. package/helpers/ripgrep/notices/glob-0.3.3/LICENSE-MIT +0 -25
  74. package/helpers/ripgrep/notices/itoa-1.0.15/LICENSE-APACHE +0 -176
  75. package/helpers/ripgrep/notices/itoa-1.0.15/LICENSE-MIT +0 -23
  76. package/helpers/ripgrep/notices/jobserver-0.1.34/LICENSE-APACHE +0 -201
  77. package/helpers/ripgrep/notices/jobserver-0.1.34/LICENSE-MIT +0 -25
  78. package/helpers/ripgrep/notices/lexopt-0.3.1/LICENSE +0 -19
  79. package/helpers/ripgrep/notices/libc-0.2.177/LICENSE-APACHE +0 -176
  80. package/helpers/ripgrep/notices/libc-0.2.177/LICENSE-MIT +0 -25
  81. package/helpers/ripgrep/notices/log-0.4.28/LICENSE-APACHE +0 -201
  82. package/helpers/ripgrep/notices/log-0.4.28/LICENSE-MIT +0 -25
  83. package/helpers/ripgrep/notices/memchr-2.7.6/COPYING +0 -3
  84. package/helpers/ripgrep/notices/memchr-2.7.6/LICENSE-MIT +0 -21
  85. package/helpers/ripgrep/notices/memchr-2.7.6/UNLICENSE +0 -24
  86. package/helpers/ripgrep/notices/memmap2-0.9.8/LICENSE-APACHE +0 -201
  87. package/helpers/ripgrep/notices/memmap2-0.9.8/LICENSE-MIT +0 -26
  88. package/helpers/ripgrep/notices/msvc_spectre_libs-0.1.3/LICENSE +0 -21
  89. package/helpers/ripgrep/notices/pcre2-0.2.11/COPYING +0 -3
  90. package/helpers/ripgrep/notices/pcre2-0.2.11/LICENSE-MIT +0 -21
  91. package/helpers/ripgrep/notices/pcre2-0.2.11/UNLICENSE +0 -24
  92. package/helpers/ripgrep/notices/pcre2-sys-0.2.10/COPYING +0 -3
  93. package/helpers/ripgrep/notices/pcre2-sys-0.2.10/LICENSE-MIT +0 -21
  94. package/helpers/ripgrep/notices/pcre2-sys-0.2.10/UNLICENSE +0 -24
  95. package/helpers/ripgrep/notices/pkg-config-0.3.32/LICENSE-APACHE +0 -201
  96. package/helpers/ripgrep/notices/pkg-config-0.3.32/LICENSE-MIT +0 -25
  97. package/helpers/ripgrep/notices/proc-macro2-1.0.101/LICENSE-APACHE +0 -176
  98. package/helpers/ripgrep/notices/proc-macro2-1.0.101/LICENSE-MIT +0 -23
  99. package/helpers/ripgrep/notices/quote-1.0.41/LICENSE-APACHE +0 -176
  100. package/helpers/ripgrep/notices/quote-1.0.41/LICENSE-MIT +0 -23
  101. package/helpers/ripgrep/notices/r-efi-5.3.0/AUTHORS +0 -74
  102. package/helpers/ripgrep/notices/regex-1.12.2/LICENSE-APACHE +0 -201
  103. package/helpers/ripgrep/notices/regex-1.12.2/LICENSE-MIT +0 -25
  104. package/helpers/ripgrep/notices/regex-automata-0.4.13/LICENSE-APACHE +0 -201
  105. package/helpers/ripgrep/notices/regex-automata-0.4.13/LICENSE-MIT +0 -25
  106. package/helpers/ripgrep/notices/regex-syntax-0.8.8/LICENSE-APACHE +0 -201
  107. package/helpers/ripgrep/notices/regex-syntax-0.8.8/LICENSE-MIT +0 -25
  108. package/helpers/ripgrep/notices/regex-syntax-0.8.8/src/unicode_tables/LICENSE-UNICODE +0 -57
  109. package/helpers/ripgrep/notices/ryu-1.0.20/LICENSE-APACHE +0 -176
  110. package/helpers/ripgrep/notices/ryu-1.0.20/LICENSE-BOOST +0 -23
  111. package/helpers/ripgrep/notices/same-file-1.0.6/COPYING +0 -3
  112. package/helpers/ripgrep/notices/same-file-1.0.6/LICENSE-MIT +0 -21
  113. package/helpers/ripgrep/notices/same-file-1.0.6/UNLICENSE +0 -24
  114. package/helpers/ripgrep/notices/serde-1.0.228/LICENSE-APACHE +0 -176
  115. package/helpers/ripgrep/notices/serde-1.0.228/LICENSE-MIT +0 -23
  116. package/helpers/ripgrep/notices/serde_core-1.0.228/LICENSE-APACHE +0 -176
  117. package/helpers/ripgrep/notices/serde_core-1.0.228/LICENSE-MIT +0 -23
  118. package/helpers/ripgrep/notices/serde_derive-1.0.228/LICENSE-APACHE +0 -176
  119. package/helpers/ripgrep/notices/serde_derive-1.0.228/LICENSE-MIT +0 -23
  120. package/helpers/ripgrep/notices/serde_json-1.0.145/LICENSE-APACHE +0 -176
  121. package/helpers/ripgrep/notices/serde_json-1.0.145/LICENSE-MIT +0 -23
  122. package/helpers/ripgrep/notices/shlex-1.3.0/LICENSE-APACHE +0 -13
  123. package/helpers/ripgrep/notices/shlex-1.3.0/LICENSE-MIT +0 -21
  124. package/helpers/ripgrep/notices/syn-2.0.106/LICENSE-APACHE +0 -176
  125. package/helpers/ripgrep/notices/syn-2.0.106/LICENSE-MIT +0 -23
  126. package/helpers/ripgrep/notices/termcolor-1.4.1/COPYING +0 -3
  127. package/helpers/ripgrep/notices/termcolor-1.4.1/LICENSE-MIT +0 -21
  128. package/helpers/ripgrep/notices/termcolor-1.4.1/UNLICENSE +0 -24
  129. package/helpers/ripgrep/notices/textwrap-0.16.2/LICENSE +0 -21
  130. package/helpers/ripgrep/notices/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/LICENSE-APACHE +0 -201
  131. package/helpers/ripgrep/notices/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/LICENSE-MIT +0 -25
  132. package/helpers/ripgrep/notices/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc/COPYING +0 -27
  133. package/helpers/ripgrep/notices/tikv-jemallocator-0.6.0/LICENSE-APACHE +0 -201
  134. package/helpers/ripgrep/notices/tikv-jemallocator-0.6.0/LICENSE-MIT +0 -25
  135. package/helpers/ripgrep/notices/unicode-ident-1.0.19/LICENSE-APACHE +0 -176
  136. package/helpers/ripgrep/notices/unicode-ident-1.0.19/LICENSE-MIT +0 -23
  137. package/helpers/ripgrep/notices/unicode-ident-1.0.19/LICENSE-UNICODE +0 -39
  138. package/helpers/ripgrep/notices/walkdir-2.5.0/COPYING +0 -3
  139. package/helpers/ripgrep/notices/walkdir-2.5.0/LICENSE-MIT +0 -21
  140. package/helpers/ripgrep/notices/walkdir-2.5.0/UNLICENSE +0 -24
  141. package/helpers/ripgrep/notices/wasip2-1.0.1+wasi-0.2.4/LICENSE-APACHE +0 -201
  142. package/helpers/ripgrep/notices/wasip2-1.0.1+wasi-0.2.4/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  143. package/helpers/ripgrep/notices/wasip2-1.0.1+wasi-0.2.4/LICENSE-MIT +0 -23
  144. package/helpers/ripgrep/notices/winapi-util-0.1.11/COPYING +0 -3
  145. package/helpers/ripgrep/notices/winapi-util-0.1.11/LICENSE-MIT +0 -21
  146. package/helpers/ripgrep/notices/winapi-util-0.1.11/UNLICENSE +0 -24
  147. package/helpers/ripgrep/notices/windows-link-0.2.1/license-apache-2.0 +0 -201
  148. package/helpers/ripgrep/notices/windows-link-0.2.1/license-mit +0 -21
  149. package/helpers/ripgrep/notices/windows-sys-0.61.2/license-apache-2.0 +0 -201
  150. package/helpers/ripgrep/notices/windows-sys-0.61.2/license-mit +0 -21
  151. package/helpers/ripgrep/notices/wit-bindgen-0.46.0/LICENSE-APACHE +0 -201
  152. package/helpers/ripgrep/notices/wit-bindgen-0.46.0/LICENSE-Apache-2.0_WITH_LLVM-exception +0 -220
  153. package/helpers/ripgrep/notices/wit-bindgen-0.46.0/LICENSE-MIT +0 -23
package/README.md CHANGED
@@ -1,14 +1,22 @@
1
- # AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.2 · 插件 → 添加插件
1
+ # AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.7 · 插件 → 添加插件
2
2
 
3
3
  ## 含工具桥预发布线
4
4
 
5
- 本包为 `0.9.0-toolbridge.2`,在独立 `toolbridge` 分支开发;稳定 main/0.8.x 和原总包保持原样。员工安装由连接组件提供的「AI 写作工作台(含工具桥)」总包,与不含工具桥的版本二选一。预发布渠道为 `toolbridge`,本轮仅提供本地固定包,不发布 npm。
5
+ 本包为 `0.9.0-toolbridge.7`,在独立 `toolbridge` 分支开发;稳定 main/0.8.x 和原总包保持原样。员工安装由连接组件提供的「AI 写作工作台(含工具桥)」总包,与不含工具桥的版本二选一。预发布渠道为 `toolbridge`,本轮仅提供本地固定包,不发布 npm。
6
+
7
+ 含桥线新增模型菜单 **Codex(云)**(英文 Codex (Cloud)),只用于本机文件夹。它由主机 `aw-session` 启动 `/usr/local/aw-host/bin/aw-cloud-acp`,每轮新建云任务并带入可见历史;写入审批沿现有 DSH 入口。任务创建/中继失败会显示本轮已停止,取消只停止中继和员工调用,**云任务可能继续运行至结束**。不自动重提或切到主机 Codex。云端目前仅接受文本,图片输入会明确失败。
8
+
9
+ 云链路按 R2 ACP v1 合同返回结构化失败:失败为 `refusal`、取消为 `cancelled`;DSH 显示失败分类与“云任务可能继续运行至结束”或“本轮未提交云任务”,技术详情保留 `causeCode`。只读档只暴露实际存在的 Read/Glob/Grep,以及显式声明 `annotations.readOnlyHint === true` 的 D31 桥工具;未标记、false 或字符串标记不算只读。桥的原生许可由 X 单次应答,实际工具仍由 DSH 审批。没有从工具名称或说明猜测只读权限。只读工具声明不会扩大 DSH 权限。接线及离线证据见 `docs/evidence/2026-10-28-K4-cancel-timeout/REPORT.md`;真实云组合/界面验收仍由编排安排。
10
+
11
+ 云通道取消时最多等待 `cloudCancelReceiptWaitMs`(默认10000毫秒)消费 v1 结构化回执,保留 causeCode、run 和 taskMayContinue;超时或通道断开无法收到回执时,按“状态未知,云任务可能仍在运行”结束本轮;超时关闭该ACP通道,迟到回执不能改写结果。X 员工 MCP 还会按当前 DSH 只读档直接拒绝 Write/Edit/Bash,并拒绝这些写操作的原生审批请求,不创建审批卡。权限改变后按当前档位处理。
12
+
13
+ 升级验收须遵循 P1–P4:完全退出 DSH(⌘Q)后重开并新建会话;两个总包二选一(不新增第三包);DSH 版本保持不变,24h 内连续升级须由编排清理 `minimumReleaseAgeExclude` 中该包旧同名行或等满 24h;云路径直接走 aw-cloud-acp,不依赖主机 Codex 的 MCP 首轮发现修复。发布只由编排在中性目录使用 npmrc-publish 执行。
6
14
 
7
15
  选择本机文件夹后,Claude 和 Codex 可以把 DSH 已启用的 MCP、web、skill、ask_user、todo/present/goal 等工具交给 DSH 原生执行和审批。内置文件/命令、子代理/agent-team、run_code 不在桥接表;原有文件和命令执行方式保留。plan 不自动放行桥接权限;default 下 Claude 的桥接原生权限由插件单次应答,员工只在 DSH 审批实际工具。主机文件夹不开放工具桥。
8
16
 
9
17
  工具表按每次主机连接生成快照,新增/移除在下一次连接生效;不承诺 Codex 当前 MCP 会话热刷新。审批期间的插话等当前主机 prompt 结束后再发,停泊中切换助手会停止原轮次并明确提示。工具主动结束DSH轮次时,已提交结果仍交回原agent;确认原生工具收到后结束原prompt,下一条沿原线程继续,不在已关闭步骤追加模型回复。取消和主机结束等待后的结果不重放;工具已执行的副作用不能因取消而撤销,请按说明核对。图片结果由官方附件组件读取后交回。
10
18
 
11
- Codex 需要 S 后续安装的独立受保护命令 `/usr/local/aw-host/bin/codex-acp-toolbridge`(aw.7),不会替换原 codex-acp/aw.6;Claude命令不变。指定桥接 server 的等待为 owner 确认的 **1800 秒**、审批交 DSH;不改其他 server 或全局策略,不新增设置项。N0.4.9、L0.7.37沿既有公开合同;真实界面/员工验收由编排安排。完整合同和证据见 `docs/contracts/codex-toolbridge.md`、`docs/evidence/2026-10-26-toolbridge/REPORT.md`。
19
+ Codex 需要 S 后续安装的独立受保护命令 `/usr/local/aw-host/bin/codex-acp-toolbridge`(aw.8),不会替换原 codex-acp/aw.6;Claude命令不变。指定桥接 server 的等待为 owner 确认的 **1800 秒**、审批交 DSH;不改其他server的调用时限,不新增插件设置项。含桥的本机Codex会话按原生规则等各扩展现有启动时限结算后再捕获工具;启动失败会明确说明,文件和命令仍按原方式执行,本轮不自动重试。N0.4.9、L0.7.37沿既有公开合同;真实界面/员工验收由编排安排。完整合同和本轮启动修复证据见 `docs/contracts/codex-toolbridge.md`、`docs/evidence/2026-10-27-toolbridge-startup/REPORT.md`。
12
20
 
13
21
  通过官方 DSH 插件入口使用 Claude(远程主机)与 Codex(远程主机)。登录和工作区来源由“远程主机连接”组件提供;员工在原生工作区和模型菜单中选择文件夹与型号。
14
22
 
@@ -51,6 +59,7 @@ Codex 员工端只使用随包提供的原生组件,通道等待本次组件
51
59
  | brokerMaxFrameBytes | 2097152 | 主机回传单段容量 |
52
60
  | brokerControlMaxBytes | 1048576 | 主机会话管理回复容量 |
53
61
  | employeeShellKillGraceMs | 1000 | 本机命令连接取消后的清理宽限毫秒 |
62
+ | cloudCancelReceiptWaitMs | 10000 | 云取消回执最长等待毫秒;1~2147483647,超时以状态未知结束本轮 |
54
63
 
55
64
  容量超限明确失败,不截断成有效消息。参数范围、生效时机和调整后果由官方 schema 与参数页显示;以上四条执行不变量不可关闭。
56
65
 
package/dist/acp.d.ts CHANGED
@@ -9,6 +9,7 @@ import type { EmployeeRouting } from './employee-relay.ts';
9
9
  import type { SessionOwnership } from './broker-ownership.ts';
10
10
  export type ApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable';
11
11
  export interface AcpHooks {
12
+ cloudCancelReceiptWaitMs?: number;
12
13
  closeDiagnostics?: CloseDiagnostics;
13
14
  onUpdate?: (notification: acp.SessionNotification) => void;
14
15
  onResponse?: (response: acp.PromptResponse) => void;
@@ -37,6 +38,8 @@ export interface EmployeeExecutionMeta {
37
38
  acpMaxMessageBytes: number;
38
39
  }
39
40
  export interface AcpStartContext {
41
+ routing?: 'native-exec' | 'mcp';
42
+ loginProvider?: 'claude' | 'codex';
40
43
  toolBridgeServers?: EmployeeRouting['mcpServers'];
41
44
  systemPrompt?: string;
42
45
  codexNewSessionOnly?: true;
@@ -53,6 +56,7 @@ export declare class AcpSession {
53
56
  private turnSignal?;
54
57
  private turnToken?;
55
58
  private busy;
59
+ private cloudCancelReceiptExpired;
56
60
  private startAttempted;
57
61
  private negotiated;
58
62
  private method?;
@@ -96,6 +100,12 @@ export declare class AcpSession {
96
100
  private detail;
97
101
  private employeeNoticeNames;
98
102
  private employeeNoticeUnshown;
103
+ private employeeBridge;
104
+ private pendingBridgeStartupFailures;
105
+ private bridgeStartupFailed;
106
+ private bridgeStartupNoticeDelivered;
107
+ private confirmBridgeStartupFailure;
108
+ private flushBridgeStartupNotice;
99
109
  private employeeInfo;
100
110
  private need;
101
111
  constructor(transport: acp.Stream | acp.AgentApp | stable.AgentApp, hooks: AcpHooks);
package/dist/acp.js CHANGED
@@ -7,6 +7,7 @@ import { employeeFailure } from "./presentation.js";
7
7
  import { isolateRpcIds } from "./rpc-namespace.js";
8
8
  import { sanitizeObservation, sanitizeDisplayLabel } from "./conversation-details.js";
9
9
  import { ModelConfiguration, ModelConfigurationError } from "./model-configuration.js";
10
+ import { CloudTurnFailure, CLOUD_FAILURE_META_KEY, cloudTurnFailure, cloudCancelReceiptTimeout, DEFAULT_CLOUD_CANCEL_RECEIPT_WAIT_MS } from "./cloud-failure.js";
10
11
  function employeeClaudeOptions(routing) { return { tools: [], disallowedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash', 'Agent', 'Task', 'TaskOutput', 'TaskStop'], toolAliases: structuredClone(routing.toolAliases) }; }
11
12
  const permissionRanks = { claude: { plan: 0, default: 1, acceptEdits: 1, bypassPermissions: 2 }, codex: { 'read-only': 0, 'workspace-write': 1, agent: 1, 'agent-full-access': 2 } };
12
13
  /** ACP v1 with explicitly negotiated SDK 2.0 lifecycle/context extensions. */
@@ -18,6 +19,7 @@ export class AcpSession {
18
19
  turnSignal;
19
20
  turnToken;
20
21
  busy = false;
22
+ cloudCancelReceiptExpired = false;
21
23
  startAttempted = false;
22
24
  negotiated = {};
23
25
  method;
@@ -226,6 +228,27 @@ export class AcpSession {
226
228
  }
227
229
  employeeNoticeNames = new Set();
228
230
  employeeNoticeUnshown = false;
231
+ employeeBridge = false;
232
+ pendingBridgeStartupFailures = new Set();
233
+ bridgeStartupFailed = false;
234
+ bridgeStartupNoticeDelivered = false;
235
+ confirmBridgeStartupFailure() {
236
+ if (!this.sessionId)
237
+ return;
238
+ const failed = this.pendingBridgeStartupFailures.has(this.sessionId);
239
+ this.pendingBridgeStartupFailures.clear();
240
+ if (failed && !this.bridgeStartupFailed) {
241
+ this.bridgeStartupFailed = true;
242
+ this.detail({ kind: 'extension', severity: 'warning', code: 'TOOLBRIDGE_STARTUP_FAILED', summary: '本轮DSH扩展工具桥启动失败;文件和命令继续使用原生路径,没有自动重试。', method: 'session/update', payload: { server: 'employee', status: 'failed', source: 'codex-acp/mcp-startup-report', nativeSessionId: this.sessionId } });
243
+ }
244
+ this.flushBridgeStartupNotice();
245
+ }
246
+ flushBridgeStartupNotice() {
247
+ if (!this.bridgeStartupFailed || this.bridgeStartupNoticeDelivered || !this.busy || this.closeRequested || this.turnSignal?.aborted || !this.hooks.onEmployeeNotice)
248
+ return;
249
+ this.hooks.onEmployeeNotice('本轮DSH里的扩展工具未能连接到Codex,暂时不可用。文件和命令仍按原方式执行;具体原因见技术详情。本轮不会自动重试。');
250
+ this.bridgeStartupNoticeDelivered = true;
251
+ }
229
252
  employeeInfo(value) {
230
253
  const bridge = record(record(value)?.mcpBridge);
231
254
  if (bridge)
@@ -253,6 +276,8 @@ export class AcpSession {
253
276
  this.closeDiagnostics = hooks.closeDiagnostics ?? new CloseDiagnostics(event => this.detail(event));
254
277
  const app = acp.client({ name: '@ai-workbench/remote-agent' })
255
278
  .onNotification(acp.methods.client.session.update, ({ params: notification }) => {
279
+ if (this.cloudCancelReceiptExpired)
280
+ return;
256
281
  if (this.creatingReplacement) {
257
282
  if (notification.sessionId !== this.sessionId && notification.update.sessionUpdate === 'config_option_update')
258
283
  this.pendingConfiguration(notification.sessionId, notification.update.configOptions);
@@ -263,6 +288,11 @@ export class AcpSession {
263
288
  this.detail({ kind: 'session', severity: 'warning', code: 'ACP_FOREIGN_SESSION_UPDATE', summary: '收到不属于当前远端会话的通知,未作为正文处理', method: 'session/update', payload: notification });
264
289
  return;
265
290
  }
291
+ const update = notification.update;
292
+ if (this.employeeBridge && !this.closeRequested && (update.sessionUpdate === 'tool_call' || update.sessionUpdate === 'tool_call_update') && update.status === 'failed' && update.title === 'mcp__employee__startup' && update.toolCallId.startsWith('mcp_startup.employee.') && update.toolCallId.length > 'mcp_startup.employee.'.length) {
293
+ this.pendingBridgeStartupFailures.add(notification.sessionId);
294
+ this.confirmBridgeStartupFailure();
295
+ }
266
296
  const meta = record(notification._meta);
267
297
  if (notification.update.sessionUpdate === 'current_mode_update') {
268
298
  this.nativeModeId = notification.update.currentModeId;
@@ -482,12 +512,13 @@ export class AcpSession {
482
512
  throw new NeedError('SESSION_ALREADY_STARTED', '此连接已用于建立会话,不能转用工作区或身份', '新的独立远端连接');
483
513
  this.startAttempted = true;
484
514
  this.employeeMeta = context?.employeeExecution;
515
+ this.employeeBridge = !!this.employeeMeta && !!context?.toolBridgeServers;
485
516
  const abort = () => this.close({ layer: 'acp', initiator: 'acp.start-signal', reason: 'ABORTED', action: 'abort' }, new NeedError('ABORTED', '会话建立已取消', '重新连接主机'));
486
517
  signal?.throwIfAborted();
487
518
  signal?.addEventListener('abort', abort, { once: true });
488
519
  try {
489
520
  const hello = await this.stage('acp-initialize', () => this.connection.agent.request(acp.methods.agent.initialize, {
490
- protocolVersion: acp.PROTOCOL_VERSION, clientInfo: { name: '@ai-workbench/remote-agent', version: '0.9.0-toolbridge.2' },
521
+ protocolVersion: acp.PROTOCOL_VERSION, clientInfo: { name: '@ai-workbench/remote-agent', version: '0.9.0-toolbridge.7' },
491
522
  clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false, session: { notices: {} }, ...(this.employeeMeta ? { _meta: { awEmployeeExecution: { version: 1, closeReason: 1, ...(context?.toolBridgeServers ? { mcpBridge: 1 } : {}) } } } : {}) },
492
523
  }, { cancellationSignal: signal }));
493
524
  if (hello.protocolVersion !== acp.PROTOCOL_VERSION)
@@ -504,9 +535,9 @@ export class AcpSession {
504
535
  this.codexNewSessionOnly = !!context?.codexNewSessionOnly;
505
536
  if (prompt)
506
537
  this.validatePrompt(prompt);
507
- const routing = context?.employeeRouting ? structuredClone(context.employeeRouting) : undefined;
538
+ const routing = context?.routing !== 'native-exec' && context?.employeeRouting ? structuredClone(context.employeeRouting) : undefined;
508
539
  this.employeeRouting = routing;
509
- const params = { cwd, mcpServers: context?.toolBridgeServers ? structuredClone(context.toolBridgeServers) : routing ? structuredClone(routing.mcpServers) : [], ...((routing || this.employeeMeta) ? { _meta: { ...(this.employeeMeta ? { awEmployeeExecution: this.employeeMeta } : {}), ...(routing ? { claudeCode: { options: employeeClaudeOptions(routing) } } : {}) } } : {}), ...(systemPrompt && !(resumeId && this.codexNewSessionOnly) ? { systemPrompt: { mode: 'append', content: [{ type: 'text', text: systemPrompt }] } } : {}) };
540
+ const params = { cwd, mcpServers: context?.toolBridgeServers ? structuredClone(context.toolBridgeServers) : routing ? structuredClone(routing.mcpServers) : [], ...((routing || this.employeeMeta) ? { _meta: { ...(this.employeeMeta ? { awEmployeeExecution: this.employeeMeta } : {}), ...(routing && context?.loginProvider !== 'codex' ? { claudeCode: { options: employeeClaudeOptions(routing) } } : {}) } } : {}), ...(systemPrompt && !(resumeId && this.codexNewSessionOnly) ? { systemPrompt: { mode: 'append', content: [{ type: 'text', text: systemPrompt }] } } : {}) };
510
541
  const configRevision = this.resetConfiguration();
511
542
  const restore = async (operation) => {
512
543
  try {
@@ -555,6 +586,7 @@ export class AcpSession {
555
586
  this.lifecycleConfiguration(result, configRevision);
556
587
  this.method = acp.methods.agent.session.new;
557
588
  }
589
+ this.confirmBridgeStartupFailure();
558
590
  await this.hooks.sessionOwnership?.bind(this.sessionId, signal);
559
591
  this.ready = true;
560
592
  this.cwd = cwd;
@@ -592,35 +624,68 @@ export class AcpSession {
592
624
  } };
593
625
  const expectedPermission = this.selectedPermission, reportedModes = new Set();
594
626
  const native = () => this.validateNativePermission(expectedPermission, reportedModes);
627
+ const cloudContract = record(this.negotiated._meta?.aiWorkbenchCloudFailure);
628
+ const cloud = cloudContract?.schemaVersion === 1 && cloudContract.metaKey === CLOUD_FAILURE_META_KEY;
629
+ const receiptWaitMs = this.hooks.cloudCancelReceiptWaitMs ?? DEFAULT_CLOUD_CANCEL_RECEIPT_WAIT_MS;
630
+ if (cloud && (!Number.isSafeInteger(receiptWaitMs) || receiptWaitMs < 1 || receiptWaitMs > 2147483647))
631
+ throw new NeedError('SETTINGS_REQUIRED', '云取消回执等待设置无效,本轮未发送。', 'cloudCancelReceiptWaitMs:1~2147483647的整数毫秒');
595
632
  this.busy = true;
596
633
  this.turnSignal = signal;
597
634
  this.turnToken = Symbol('turn');
635
+ let receiptTimer;
636
+ let receiptTimeout;
598
637
  let rejectAbort;
599
638
  const interrupted = new Promise((_resolve, reject) => { rejectAbort = reject; });
600
639
  const cancel = () => {
601
640
  this.closeDiagnostics.record({ layer: 'acp', initiator: 'acp.prompt-cancel', reason: 'ABORTED', operation: 'session/prompt', action: 'abort' });
602
- rejectAbort?.(new NeedError('ABORTED', '已请求取消本轮,远端状态需确认', '确认主机取消状态'));
641
+ if (cloud) {
642
+ receiptTimer = setTimeout(() => {
643
+ this.cloudCancelReceiptExpired = true;
644
+ receiptTimeout = cloudCancelReceiptTimeout(receiptWaitMs);
645
+ this.detail({ kind: 'need', severity: 'action-required', code: receiptTimeout.code, summary: receiptTimeout.message, payload: receiptTimeout.info });
646
+ rejectAbort?.(receiptTimeout);
647
+ this.close({ layer: 'acp', initiator: 'acp.cloud-cancel-receipt-timeout', reason: receiptTimeout.code, action: 'close' });
648
+ }, receiptWaitMs);
649
+ }
650
+ else
651
+ rejectAbort?.(new NeedError('ABORTED', '已请求取消本轮,远端状态需确认', '确认主机取消状态'));
603
652
  void this.connection.agent.notify(acp.methods.agent.session.cancel, { sessionId: this.sessionId }).catch(() => {
604
- this.need({ code: 'CANCEL_UNCONFIRMED', message: '连接中断,无法确认主机已取消本轮', requires: '恢复连接以确认远端状态' });
653
+ this.need({ code: 'CANCEL_UNCONFIRMED', message: cloud ? '云通道已断开,无法确认云任务已结束。' : '连接中断,无法确认主机已取消本轮', requires: cloud ? '恢复云通道以核对任务状态' : '恢复连接以确认远端状态' });
605
654
  });
606
655
  };
607
656
  signal?.addEventListener('abort', cancel, { once: true });
608
657
  try {
658
+ this.flushBridgeStartupNotice();
609
659
  const result = await this.stage('acp-prompt', () => {
610
660
  this.promptPermissions.set(params, { current, native });
611
661
  const request = this.connection.agent.request(acp.methods.agent.session.prompt, params, { cancellationSignal: signal });
662
+ // Cloud cancellation keeps the receipt RPC only for the configured
663
+ // interval; host adapters retain their immediate cancellation path.
612
664
  return signal ? Promise.race([request, interrupted]) : request;
613
665
  });
614
- signal?.throwIfAborted();
615
666
  this.hooks.onResponse?.(result);
667
+ if (cloud) {
668
+ const failure = cloudTurnFailure(result);
669
+ if (failure)
670
+ throw failure;
671
+ }
672
+ signal?.throwIfAborted();
616
673
  return result.stopReason;
617
674
  }
618
675
  catch (error) {
676
+ if (receiptTimeout)
677
+ throw receiptTimeout;
678
+ if (error instanceof CloudTurnFailure)
679
+ throw error;
680
+ if (cloud && signal?.aborted)
681
+ throw cloudTurnFailure({ stopReason: 'cancelled' });
619
682
  if (signal?.aborted)
620
683
  throw new NeedError('ABORTED', '本轮已取消;已请求主机停止', '确认主机取消状态');
621
684
  throw acpNeed(error);
622
685
  }
623
686
  finally {
687
+ if (receiptTimer !== undefined)
688
+ clearTimeout(receiptTimer);
624
689
  signal?.removeEventListener('abort', cancel);
625
690
  this.turnSignal = undefined;
626
691
  this.busy = false;
package/dist/agents.d.ts CHANGED
@@ -7,8 +7,10 @@ export interface AgentDefinition {
7
7
  }>;
8
8
  readonly command: string;
9
9
  readonly loginProvider: 'claude' | 'codex';
10
+ readonly routing: 'native-exec' | 'mcp';
10
11
  }
11
12
  export declare const CODEX_AGENT: AgentDefinition;
12
13
  export declare const CLAUDE_AGENT: AgentDefinition;
14
+ export declare const CODEX_CLOUD_AGENT: AgentDefinition;
13
15
  export declare const AGENTS: readonly AgentDefinition[];
14
16
  export declare function agentForProvider(id: string): AgentDefinition | undefined;
package/dist/agents.js CHANGED
@@ -1,4 +1,5 @@
1
- export const CODEX_AGENT = Object.freeze({ id: 'codex-remote', name: Object.freeze({ zh: 'Codex(远程主机)', en: 'Codex (Remote Host)' }), command: '/usr/local/aw-host/bin/codex-acp-toolbridge', loginProvider: 'codex' });
2
- export const CLAUDE_AGENT = Object.freeze({ id: 'claude-code-workbench', name: Object.freeze({ zh: 'Claude(远程主机)', en: 'Claude (Remote Host)' }), command: '/usr/local/aw-host/bin/claude-agent-acp', loginProvider: 'claude' });
3
- export const AGENTS = Object.freeze([CODEX_AGENT, CLAUDE_AGENT]);
1
+ export const CODEX_AGENT = Object.freeze({ id: 'codex-remote', name: Object.freeze({ zh: 'Codex(远程主机)', en: 'Codex (Remote Host)' }), command: '/usr/local/aw-host/bin/codex-acp-toolbridge', loginProvider: 'codex', routing: 'native-exec' });
2
+ export const CLAUDE_AGENT = Object.freeze({ id: 'claude-code-workbench', name: Object.freeze({ zh: 'Claude(远程主机)', en: 'Claude (Remote Host)' }), command: '/usr/local/aw-host/bin/claude-agent-acp', loginProvider: 'claude', routing: 'mcp' });
3
+ export const CODEX_CLOUD_AGENT = Object.freeze({ id: 'codex-cloud', name: Object.freeze({ zh: 'Codex(云)', en: 'Codex (Cloud)' }), command: '/usr/local/aw-host/bin/aw-cloud-acp', loginProvider: 'codex', routing: 'mcp' });
4
+ export const AGENTS = Object.freeze([CODEX_AGENT, CLAUDE_AGENT, CODEX_CLOUD_AGENT]);
4
5
  export function agentForProvider(id) { return AGENTS.find(agent => agent.id === id); }
@@ -13,6 +13,7 @@ interface Configuration {
13
13
  employeeShellKillGraceMs?: number;
14
14
  }
15
15
  interface Options {
16
+ readOnly?: (sessionId: string) => boolean;
16
17
  getConnect: () => ConnectApi | undefined;
17
18
  getNetwork: () => EmployeeNetworkApi | undefined;
18
19
  readWorkspace: (sessionId: string) => Promise<EmployeeWorkspace>;
@@ -116,7 +116,7 @@ export function createClaudeLocalProvider(options) {
116
116
  lease = await (options.ports?.lease ?? openEmployeeLease)({ closeDiagnostics, getConnect: () => options.getConnect(), getNetwork: options.getNetwork, readWorkspace: () => options.readWorkspace(request.sessionId), host: target, sessionId: request.sessionId, control: async (_target, command, signal) => (await transport()).run(command, signal), detail: unscoped }, request.signal);
117
117
  const shell = (options.ports?.shell ?? createEmployeeShell)({ closeDiagnostics, target: lease.target, sshArgs: lease.sshArgs, maxBytes: maximum, killGraceMs: grace, attach: async (spec) => (await transport()).attach([spec.command, ...spec.args].map(shellQuote).join(' ')) });
118
118
  request.toolBridge?.enable(event => details.record(event));
119
- mcp = await (options.ports?.mcp ?? openEmployeeMcp)({ bridge: request.toolBridge, closeDiagnostics, lease, maxBytes: maximum, killGraceMs: grace, runShell: shell, activeSignal: () => entry?.active?.signal, captureDetail: () => { const sink = entry?.active?.details; if (!sink)
119
+ mcp = await (options.ports?.mcp ?? openEmployeeMcp)({ ...(options.readOnly ? { readOnly: () => options.readOnly(request.sessionId) } : {}), bridge: request.toolBridge, closeDiagnostics, lease, maxBytes: maximum, killGraceMs: grace, runShell: shell, activeSignal: () => entry?.active?.signal, captureDetail: () => { const sink = entry?.active?.details; if (!sink)
120
120
  throw failure('EMPLOYEE_NO_ACTIVE_TURN'); return observation => sink.record(observation); }, detail: unscoped });
121
121
  entry = { runtime: undefined, scope, lease, details, request };
122
122
  const row = entry;
@@ -144,7 +144,7 @@ export function createClaudeLocalProvider(options) {
144
144
  });
145
145
  };
146
146
  const executionSignal = AbortSignal.any([lease.signal, ...mcp.signal ? [mcp.signal] : []]);
147
- row.runtime = { ...underlying, closeDiagnostics, cwd: workspace.directory.path, details, connection: { ...connection }, binding: { bindingId: item.bindingId, workspaceId: workspace.workspaceId, revision: state.revision }, execution: { hostCwd: target.session.root, routing: mcp.routing, notice: NOTICE, signal: executionSignal, scope: { source: 'local', cwd: workspace.directory.path, hostCwd: target.session.root, uid: lease.target.endpoint.remoteUid, claudeAcpVersion: '0.94.0', sdkVersion: '0.3.303', unsupported: ['subagents', 'internal-direct-calls', 'binary-read', 'background-shell'] }, validate: async (signal) => { signal?.throwIfAborted(); executionSignal.throwIfAborted(); }, beginTurn: async (signal) => { signal?.throwIfAborted(); executionSignal.throwIfAborted(); if (row.closing || row.active)
147
+ row.runtime = { ...underlying, closeDiagnostics, cwd: workspace.directory.path, details, connection: { ...connection }, binding: { bindingId: item.bindingId, workspaceId: workspace.workspaceId, revision: state.revision }, execution: { hostCwd: target.session.root, routing: mcp.routing, notice: NOTICE, signal: executionSignal, scope: { source: 'local', cwd: workspace.directory.path, hostCwd: target.session.root, uid: lease.target.endpoint.remoteUid, ...(request.agent?.loginProvider === 'codex' ? { acpAgent: 'aw-cloud-acp', acpVersion: '0.1.2' } : { claudeAcpVersion: '0.94.0', sdkVersion: '0.3.303' }), unsupported: ['subagents', 'internal-direct-calls', 'binary-read', 'background-shell'] }, validate: async (signal) => { signal?.throwIfAborted(); executionSignal.throwIfAborted(); }, beginTurn: async (signal) => { signal?.throwIfAborted(); executionSignal.throwIfAborted(); if (row.closing || row.active)
148
148
  throw failure('TURN_BUSY'); row.active = { signal, details: row.details }; }, endTurn: () => { row.active = undefined; } }, dispose: cause => close(false, cause), detach: cause => close(true, cause) };
149
149
  entries.set(request.sessionId, row);
150
150
  lease.signal.addEventListener('abort', () => { void close(false, { layer: 'endpoint', initiator: 'claude.lease-abort', reason: closeCode(lease?.signal.reason, 'EMPLOYEE_CONTEXT_CHANGED'), action: 'abort' }).catch(() => console.warn('CLAUDE_CLEANUP_FAILED')); }, { once: true });
package/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  window.__ModuleLoader__.load({id:'@ai-workbench/remote-agent',factory(require){
2
2
  const messages={"en":{"administratorNote":"Settings → Built-in plugins → 远程助手参数. Eight named settings with defaults, scope and effects.","providerName":"Codex (Remote Host)"},"zh":{"administratorNote":"管理员:设置 → 内置插件 → 远程助手参数。八项设置含默认值、范围、生效和后果说明。","providerName":"Codex(远程主机)"}};
3
- const settingsFields=[{"key":"acpMaxMessageBytes","name":"完整消息与工具输出容量(字节)","kind":"number","min":1,"max":9007199254740991,"range":"1~9007199254740991 的整数;0不能关闭上限","scope":"两位远程助手的完整会话消息;也用于模型目录、本机 MCP、员工执行 RPC 和工具输出容量。","when":"当轮快照不变;下一次独立目录查询读取新值;已有会话需新建后使用。","consequence":"调大可接收更大消息、占用更多内存;调小更早拒绝超限。超限明确停止,不截断、不自动重试;不能用0取消完整消息保护。","defaultValue":4194304},{"key":"brokerMaxFrameBytes","name":"主机会话回传单段容量(字节)","kind":"number","min":1,"max":9007199254740991,"range":"1~9007199254740991 的整数;0不能关闭上限","scope":"本插件接收主机会话单段输出的容量;不会替主机修改它自己的输出策略。","when":"当轮快照不变;更改后已有会话需新建。","consequence":"调大允许更大回传段、占用更多内存;调小可能拒绝主机合法输出。超限停止,不截断;不能关闭协议帧核验。","defaultValue":2097152},{"key":"brokerControlMaxBytes","name":"主机会话管理回复容量(字节)","kind":"number","min":1,"max":9007199254740991,"range":"1~9007199254740991 的整数;0不能关闭上限","scope":"主机会话管理命令的标准输出、标准错误各自容量;也用于本机执行桥的管理回复。","when":"当轮快照不变;更改后已有会话需新建。","consequence":"调大允许更长管理回复、占用更多内存;调小可能无法核实状态。超限明确停止,不能把不完整回复当成功;0不表示无限。","defaultValue":1048576},{"key":"employeeShellKillGraceMs","name":"本机命令外层连接清理宽限(毫秒)","kind":"number","min":0,"max":2147483647,"range":"0~2147483647 的整数","scope":"仅 Claude 本机 Bash 取消后,本插件自己的外层 SSH 进程清理;不控制员工命令或 Codex 执行器。","when":"当轮快照不变;更改后已有会话需新建。","consequence":"大于0时先请求外层连接退出,再等待所设毫秒后强制清理;0表示不留宽限、立即强制清理外层连接,不是关闭取消。没有员工端退出确认时结果仍未知,不能据此自动重放或声称命令已停止。","defaultValue":1000}];
3
+ const settingsFields=[{"key":"acpMaxMessageBytes","name":"完整消息与工具输出容量(字节)","kind":"number","min":1,"max":9007199254740991,"range":"1~9007199254740991 的整数;0不能关闭上限","scope":"两位远程助手的完整会话消息;也用于模型目录、本机 MCP、员工执行 RPC 和工具输出容量。","when":"当轮快照不变;下一次独立目录查询读取新值;已有会话需新建后使用。","consequence":"调大可接收更大消息、占用更多内存;调小更早拒绝超限。超限明确停止,不截断、不自动重试;不能用0取消完整消息保护。","defaultValue":4194304},{"key":"brokerMaxFrameBytes","name":"主机会话回传单段容量(字节)","kind":"number","min":1,"max":9007199254740991,"range":"1~9007199254740991 的整数;0不能关闭上限","scope":"本插件接收主机会话单段输出的容量;不会替主机修改它自己的输出策略。","when":"当轮快照不变;更改后已有会话需新建。","consequence":"调大允许更大回传段、占用更多内存;调小可能拒绝主机合法输出。超限停止,不截断;不能关闭协议帧核验。","defaultValue":2097152},{"key":"brokerControlMaxBytes","name":"主机会话管理回复容量(字节)","kind":"number","min":1,"max":9007199254740991,"range":"1~9007199254740991 的整数;0不能关闭上限","scope":"主机会话管理命令的标准输出、标准错误各自容量;也用于本机执行桥的管理回复。","when":"当轮快照不变;更改后已有会话需新建。","consequence":"调大允许更长管理回复、占用更多内存;调小可能无法核实状态。超限明确停止,不能把不完整回复当成功;0不表示无限。","defaultValue":1048576},{"key":"employeeShellKillGraceMs","name":"本机命令外层连接清理宽限(毫秒)","kind":"number","min":0,"max":2147483647,"range":"0~2147483647 的整数","scope":"仅 Claude 本机 Bash 取消后,本插件自己的外层 SSH 进程清理;不控制员工命令或 Codex 执行器。","when":"当轮快照不变;更改后已有会话需新建。","consequence":"大于0时先请求外层连接退出,再等待所设毫秒后强制清理;0表示不留宽限、立即强制清理外层连接,不是关闭取消。没有员工端退出确认时结果仍未知,不能据此自动重放或声称命令已停止。","defaultValue":1000},{"key":"cloudCancelReceiptWaitMs","name":"云取消回执最长等待(毫秒)","kind":"number","min":1,"max":2147483647,"range":"1~2147483647 的整数;0不能设为无限等待","scope":"仅协商v1云失败合同的取消回执等待;不改变主机助手取消或云任务执行期限。","when":"每轮读取配置快照;取消时开始计时,改动用于下一轮。","consequence":"默认10000毫秒。到时未收到回执则以状态未知、云任务可能仍在运行结束本轮并关闭该ACP通道;迟到回执不能改写结果。调小会更早失去详细回执,调大增加取消等待;不重提任务。","defaultValue":10000}];
4
4
  /* Public settings.plugins.tab + shared ConfigForms. No private client services. */
5
5
  function mountRuntimeSettings(ctx,React,fields){
6
6
  const h=React.createElement;
@@ -0,0 +1,11 @@
1
+ import type { PromptResponse } from '@agentclientprotocol/sdk/unstable';
2
+ import { NeedError } from './remote.ts';
3
+ export declare const CLOUD_FAILURE_META_KEY = "ai-workbench/cloud-turn";
4
+ export declare const DEFAULT_CLOUD_CANCEL_RECEIPT_WAIT_MS = 10000;
5
+ export declare class CloudTurnFailure extends NeedError {
6
+ readonly info: Readonly<Record<string, unknown>>;
7
+ constructor(info: Readonly<Record<string, unknown>>, message: string);
8
+ }
9
+ export declare function cloudCancelReceiptTimeout(waitMs: number): CloudTurnFailure;
10
+ /** Read only the v1 contract. Never classify a cloud turn by its prose. */
11
+ export declare function cloudTurnFailure(response: PromptResponse): CloudTurnFailure | undefined;
@@ -0,0 +1,54 @@
1
+ import { NeedError } from "./remote.js";
2
+ export const CLOUD_FAILURE_META_KEY = 'ai-workbench/cloud-turn';
3
+ export const DEFAULT_CLOUD_CANCEL_RECEIPT_WAIT_MS = 10000;
4
+ const messages = {
5
+ CLOUD_TASK_CREATE_FAILED: '云任务创建失败或结果未知,本轮已停止。',
6
+ CLOUD_RELAY_DISCONNECTED: '云中继连接已断开,本轮已停止。',
7
+ CLOUD_CANCELLED: '云任务本轮已取消派发。',
8
+ CLOUD_DEADLINE_EXCEEDED: '云任务本轮已到截止时间。',
9
+ CLOUD_ENDPOINT_DISCONNECTED: '员工工具通道不可用,本轮已停止。',
10
+ CLOUD_TOOL_UNAVAILABLE: '本轮权限或工具表不包含此工具,未执行。',
11
+ CLOUD_PERMISSION_DENIED: '本次操作没有获得授权,未执行。',
12
+ CLOUD_TASK_FAILED: '云任务失败或状态无法确认,本轮已停止。',
13
+ CLOUD_REPORT_UNAVAILABLE: '云任务最终报告未能确认,本轮已停止。',
14
+ CLOUD_TURN_FAILED: '云任务本轮未完成。',
15
+ };
16
+ const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
17
+ const machineCode = (value) => typeof value === 'string' && /^[A-Z][A-Z0-9_]{0,79}$/.test(value) ? value : undefined;
18
+ export class CloudTurnFailure extends NeedError {
19
+ info;
20
+ constructor(info, message) {
21
+ super(String(info.code), message, JSON.stringify(info));
22
+ this.info = info;
23
+ }
24
+ }
25
+ export function cloudCancelReceiptTimeout(waitMs) {
26
+ return new CloudTurnFailure(Object.freeze({ schemaVersion: 1, status: 'unknown', code: 'CLOUD_CANCEL_RECEIPT_TIMEOUT', causeCode: 'CLOUD_CANCEL_RECEIPT_TIMEOUT', origin: 'client', stopReason: 'cancelled', taskMayContinue: true, retryable: false, waitMs }), '取消回执等待已到上限;状态未知,云任务可能仍在运行。不会自动重提或改用主机 Codex。');
27
+ }
28
+ /** Read only the v1 contract. Never classify a cloud turn by its prose. */
29
+ export function cloudTurnFailure(response) {
30
+ const meta = object(response._meta?.[CLOUD_FAILURE_META_KEY]);
31
+ if (!meta && response.stopReason !== 'refusal' && response.stopReason !== 'cancelled')
32
+ return;
33
+ if (meta?.status !== 'failed' && response.stopReason !== 'refusal' && response.stopReason !== 'cancelled')
34
+ return;
35
+ const supported = meta?.schemaVersion === 1 && meta.status === 'failed';
36
+ const reported = supported ? machineCode(meta.code) : undefined;
37
+ const code = reported && Object.hasOwn(messages, reported) ? reported : response.stopReason === 'cancelled' ? 'CLOUD_CANCELLED' : 'CLOUD_TURN_FAILED';
38
+ const taskMayContinue = supported && typeof meta.taskMayContinue === 'boolean' ? meta.taskMayContinue : true;
39
+ const info = { schemaVersion: 1, status: 'failed', code, stopReason: response.stopReason, taskMayContinue, retryable: false };
40
+ if (supported) {
41
+ const causeCode = machineCode(meta.causeCode);
42
+ if (causeCode)
43
+ info.causeCode = causeCode;
44
+ if (reported && reported !== code)
45
+ info.reportedCode = reported;
46
+ if (typeof meta.stage === 'string' && ['registration', 'relay', 'submission', 'task', 'endpoint', 'turn'].includes(meta.stage))
47
+ info.stage = meta.stage;
48
+ for (const field of ['run', 'taskId'])
49
+ if (typeof meta[field] === 'string' && /^[A-Za-z0-9_.:-]{1,128}$/.test(meta[field]))
50
+ info[field] = meta[field];
51
+ }
52
+ const message = messages[code] + (taskMayContinue ? ' 云任务可能继续运行至结束。' : ' 本轮未提交云任务。') + ' 不会自动重提或改用主机 Codex。';
53
+ return new CloudTurnFailure(Object.freeze(info), message);
54
+ }
@@ -1,35 +1,19 @@
1
- import type { ToolBridge } from './toolbridge.ts';
1
+ import { EmployeeSocketTransport as SocketTransport, EMPLOYEE_MCP_TOOLS } from '@ai-workbench/employee-tools';
2
+ import type { Socket } from 'node:net';
2
3
  import { type CloseCause, type CloseDiagnostics, type CloseObserver } from './close-diagnostics.ts';
3
- import { type Socket } from 'node:net';
4
- import { type JSONRPCMessage, type Tool } from '@modelcontextprotocol/sdk/types.js';
5
- import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
6
4
  import type { EmployeeLease } from './employee-endpoint.ts';
7
5
  import { employeeRouting } from './employee-relay.ts';
8
6
  import type { DetailObservation } from './conversation-details.ts';
9
7
  import type { EmployeeShell } from './employee-shell.ts';
10
- export declare const EMPLOYEE_MCP_TOOLS: Tool[];
11
- /** Same newline-delimited MCP messages as stdio, over an employee-only Unix stream. */
12
- export declare class EmployeeSocketTransport implements Transport {
13
- private socket;
14
- private maxBytes;
15
- private observeClose?;
16
- onclose?: () => void;
17
- onerror?: (error: Error) => void;
18
- onmessage?: (message: JSONRPCMessage) => void;
19
- private pending;
20
- private ended;
21
- private failure?;
22
- get error(): Error | undefined;
23
- private readonly lifetime;
24
- readonly signal: AbortSignal;
25
- constructor(socket: Socket, maxBytes: number, observeClose?: CloseObserver | undefined);
26
- private failed;
27
- start(): Promise<void>;
28
- send(message: JSONRPCMessage): Promise<void>;
29
- close(cause?: CloseCause): Promise<void>;
8
+ import type { ToolBridge } from './toolbridge.ts';
9
+ export { EMPLOYEE_MCP_TOOLS };
10
+ export declare class EmployeeSocketTransport extends SocketTransport {
11
+ constructor(socket: Socket, maxBytes: number, observeClose?: CloseObserver);
30
12
  }
31
13
  export interface EmployeeMcpOptions {
32
14
  bridge?: ToolBridge;
15
+ /** Current official sandbox mode; X's cloud caller supplies this live getter. */
16
+ readOnly?: () => boolean;
33
17
  closeDiagnostics?: CloseDiagnostics;
34
18
  lease: EmployeeLease;
35
19
  maxBytes: number;