@ai-workbench/remote-agent 0.9.0-toolbridge.20 → 0.9.0-toolbridge.21

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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.20 · 插件 → 添加插件
1
+ # AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.21 · 插件 → 添加插件
2
2
 
3
3
  ## 含工具桥预发布线
4
4
 
5
- 本包为 `0.9.0-toolbridge.20`,从 `v0.9.0-toolbridge.14` 派生,使用 `host-toolbridge` 发布渠道。员工安装由连接组件提供的「AI 写作工作台(含工具桥)」总包 `@ai-workbench/workbench-toolbridge@0.1.17`,与不含工具桥的版本二选一。
5
+ 本包为 `0.9.0-toolbridge.21`,从 `v0.9.0-toolbridge.14` 派生,使用 `host-toolbridge` 发布渠道。员工安装由连接组件提供的「AI 写作工作台(含工具桥)」总包 `@ai-workbench/workbench-toolbridge@0.1.18`,与不含工具桥的版本二选一。
6
6
 
7
7
  本轮增加两家运行中插话(DSH 原生 nextStep),保留官方队列和原话;明确 followup 仍排下一轮。Codex 含桥组件需 `2.2.2-aw.12`,Claude 仍为官方 `0.94.0`。插件确定消息未发出时保留排队资格;送达未确认时明确报错且不重放。已注入旧正文不能撤回,编辑版下一步骤交付。
8
8
 
@@ -10,7 +10,7 @@ host `0.8.11` 的新 broker 支持同一客户端/SDK 在切网后按输出游
10
10
 
11
11
  原轮正常完成(或冷接回已交付原结果)后结束该轮主机 broker,原生线程写锁随之释放,同一 DSH 会话下一轮不再因旧轮保留 10 分钟而报“原会话仍被占用”;结果未定(插件退出、断开、失败)时仍保留原轮待接回。旧 X.14–.16 发出的结束请求在主机上始终不生效,只有升级本包才消除;只升主机不够。
12
12
 
13
- 本机文件夹下的主机 Claude 可以开自己的子代理(原生 Agent 与 TaskStop),子代理还能再开子代理,插件不加层数或次数限制。子代理继承同一工具表:原生 Read/Write/Edit/Glob/Grep/Bash 仍关闭,文件和命令只走员工本机工具并按原审批;工具桥的 DSH 工具同样可用。子代理的工具事件进技术详情,结论由主 Claude 在原回复里给出;取消本轮会一并结束子代理。Claude 原生的 SendMessage/ListAgents 不开放(DSH 同名的 send_message/list_agents 见下段),因为它们能触及主机账号的其他本地和云端会话;子代理完成后结果仍自动交回主 Claude。主机文件夹本就允许,行为不变。Codex 自身的多代理功能本线没有关闭(层数和线程数是 Codex 上游默认值,插件不改)。
13
+ 本机文件夹下的主机 Claude 可以开自己的子代理(原生 Agent 与 TaskStop),子代理还能再开子代理,插件不加层数或次数限制。子代理继承同一工具表:原生 Read/Write/Edit/Glob/Grep/Bash 仍关闭,文件和命令只走员工本机工具并按原审批;工具桥的 DSH 工具同样可用。子代理的工具事件进技术详情,结论由主 Claude 在原回复里给出;取消本轮会一并结束子代理。Claude 原生的 SendMessage/ListAgents 不开放(DSH 同名的 send_message/list_agents 见下段),因为它们能触及主机账号的其他本地和云端会话;子代理完成后结果仍自动交回主 Claude。主机文件夹本就允许,行为不变。Claude 的云端子代理(Agent 的 isolation:"remote",会在员工 Claude 账号的云端运行,碰不到员工电脑和主机)在本机文件夹和主机文件夹下都被拒绝(0.9.0-toolbridge.21 起,上游 PreToolUse 钩子:调用里写 remote,或所调子代理类型的定义文件写 `isolation: remote`,都拒;检查在主机跑一个固定脚本,只读钩子输入和子代理定义文件,不执行模型内容);本地子代理、worktree、套娃、Skill 和 DSH 子代理工具照常。Codex 自身的多代理功能本线没有关闭(层数和线程数是 Codex 上游默认值,插件不改)。
14
14
 
15
15
  任何 agent 都可以调用其他 agent:本机文件夹下的主机 Claude/Codex 经工具桥使用 DSH 自带的子代理工具(subagent、subagent_fork、list_subagent_models、send_message、interrupt_agent、list_agents、wait_agent、spawn_teammate、team_task_*、workflow 及后台任务 job_output/job_list/job_kill),由 DSH 执行、审批、显示子代理卡片和交回结果。被调方可以是主机 Claude 新会话、主机 Codex 新会话或员工在 DSH 配好的模型;跨品牌路由需员工在 DSH 子代理设置里允许。DSH 的子会话不是工作区成员,插件沿 live 的 parentSession 找到最近一个登记在工作区里的祖先会话,按它的工作区执行(子会话 cwd 仍须等于该工作区,本机/主机文件夹同样适用);子会话有自己的主机原生会话、broker、冷接回记录,文件和命令照常走员工本机或所选主机目录。层数、并发由 DSH 自己的用户设置决定,插件不加任何层数、并发、次数或预算限制,也不改 DSH 设置。主机文件夹不开放工具桥,所以主机文件夹下的主机 Claude/Codex 只能用自己的原生子代理,作为被调方时由 DSH 子代理派出。
16
16
 
package/dist/acp.d.ts CHANGED
@@ -44,6 +44,16 @@ export interface AcpStartContext {
44
44
  employeeRouting?: EmployeeRouting;
45
45
  }
46
46
  export type AcpStartMethod = 'session/new' | 'session/resume' | 'session/load';
47
+ /** Owner 2026-11-12: refuse only Claude's cloud subagent (Agent isolation:"remote"; it would run in the employee's Claude cloud, away from the employee
48
+ * computer and the host). CLI 2.1.285 applies `isolation ?? definition.isolation`, and agent definition files (user/managed/project, not plugins) accept
49
+ * `isolation: remote`. Upstream PreToolUse hook (programmatic settings tier) runs before any permission mode, at every depth; the fixed script only reads
50
+ * the hook JSON from stdin and agent definition files, never runs model content:
51
+ * - explicit "isolation":"remote" → deny (one sentence for the model); explicit "worktree" → pass;
52
+ * - otherwise, only if a definition in a directory the CLI loads from (symlinks followed, BOM/CRLF tolerated) has a frontmatter isolation key
53
+ * (block, flow, quoted or explicit `?` form) whose value is not plain worktree, or a `<<` merge line, deny unless the requested type (default general-purpose) provably differs from every such definition's plain name
54
+ * (ASCII, compared as the CLI does: lowercase, no space/-/_); names that cannot be compared count as a match;
55
+ * - no such definition → exit 0 with no output, native permission flow unchanged. A failed stdin read denies (exit 2). */
56
+ export declare const CLOUD_SUBAGENT_REFUSED = "\u4E91\u7AEF\u5B50\u4EE3\u7406\u78B0\u4E0D\u5230\u4F60\u7684\u7535\u8111\u548C\u4E3B\u673A\uFF0C\u5DF2\u62D2\u7EDD\uFF0C\u8BF7\u6539\u7528\u672C\u5730\u5B50\u4EE3\u7406\u3002";
47
57
  /** ACP v1 with explicitly negotiated SDK 2.0 lifecycle/context extensions. */
48
58
  export declare class AcpSession {
49
59
  private connection;
package/dist/acp.js CHANGED
@@ -10,7 +10,31 @@ import { ModelConfiguration, ModelConfigurationError } from "./model-configurati
10
10
  // Native subagents stay on (Agent/TaskStop): children inherit this tool pool, deny rules and the employee MCP aliases, so their files/commands also run on the employee device.
11
11
  // Skill stays on for the main session and subagents; a skill's `!` inline command needs native Bash, which stays disallowed, so it never runs on the host.
12
12
  // SendMessage/ListAgents stay off: they also reach other local and cloud sessions of the host account.
13
- function employeeClaudeOptions(routing) { return { tools: ['Agent', 'TaskStop', 'Skill'], disallowedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'], toolAliases: structuredClone(routing.toolAliases) }; }
13
+ /** Owner 2026-11-12: refuse only Claude's cloud subagent (Agent isolation:"remote"; it would run in the employee's Claude cloud, away from the employee
14
+ * computer and the host). CLI 2.1.285 applies `isolation ?? definition.isolation`, and agent definition files (user/managed/project, not plugins) accept
15
+ * `isolation: remote`. Upstream PreToolUse hook (programmatic settings tier) runs before any permission mode, at every depth; the fixed script only reads
16
+ * the hook JSON from stdin and agent definition files, never runs model content:
17
+ * - explicit "isolation":"remote" → deny (one sentence for the model); explicit "worktree" → pass;
18
+ * - otherwise, only if a definition in a directory the CLI loads from (symlinks followed, BOM/CRLF tolerated) has a frontmatter isolation key
19
+ * (block, flow, quoted or explicit `?` form) whose value is not plain worktree, or a `<<` merge line, deny unless the requested type (default general-purpose) provably differs from every such definition's plain name
20
+ * (ASCII, compared as the CLI does: lowercase, no space/-/_); names that cannot be compared count as a match;
21
+ * - no such definition → exit 0 with no output, native permission flow unchanged. A failed stdin read denies (exit 2). */
22
+ export const CLOUD_SUBAGENT_REFUSED = '云端子代理碰不到你的电脑和主机,已拒绝,请改用本地子代理。';
23
+ const cloudSubagentHook = `j=$(/bin/cat) || { echo '云端子代理检查失败,本次子代理没有启动。' >&2; exit 2; }
24
+ deny(){ printf '%s\\n' '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"${CLOUD_SUBAGENT_REFUSED}"}}'; exit 0; }
25
+ case $j in *'"isolation":"remote"'*) deny;; *'"isolation":"worktree"'*) exit 0;; esac
26
+ d=\${CLAUDE_PROJECT_DIR:-$PWD}; set -- "\${CLAUDE_CONFIG_DIR:-$HOME/.claude}/agents" "/Library/Application Support/ClaudeCode/.claude/agents"
27
+ while :; do set -- "$@" "$d/.claude/agents"; m=; [ -f "$d/.git" ] && m=$(/usr/bin/sed -n 's#^gitdir:[[:space:]]*\\(.*\\)/\\.git/worktrees/.*#\\1#p' "$d/.git"); case $m in '') ;; /*) set -- "$@" "$m/.claude/agents";; *) set -- "$@" "$d/$m/.claude/agents";; esac; [ "$d" = / ] && break; d=$(/usr/bin/dirname "$d"); done
28
+ c=$(for a; do [ -d "$a" ] && /usr/bin/find -L "$a" -type f -name '*.md' 2>/dev/null; done | while IFS= read -r f; do LC_ALL=C /usr/bin/awk 'NR==1{sub(/^\\357\\273\\277/,"");sub(/\\r$/,"");if($0!~/^---[ \\t]*$/)exit;next} {sub(/\\r$/,"")} /^---[ \\t]*$/{exit} {l=tolower($0)} match(l,/(^[ \\t]*|[{,][ \\t]*)["\\047]?isolation["\\047]?[ \\t]*:/){v=substr($0,RSTART+RLENGTH);sub(/^[ \\t]+/,"",v);sub(/[,}].*$/,"",v);sub(/[ \\t]+#.*$/,"",v);sub(/[ \\t]+$/,"",v);gsub(/^["\\047]|["\\047]$/,"",v);if(v!="worktree")c=1} l~/^[ \\t]*\\?[ \\t]*["\\047]?isolation/||index($0,"<<"){c=1} /^name[ \\t]*:/&&!h{h=1;n=$0;sub(/^name[ \\t]*:[ \\t]*/,"",n);sub(/[ \\t]+#.*$/,"",n);sub(/[ \\t]+$/,"",n);if(n~/^".*"$/||n~/^\\047.*\\047$/)n=substr(n,2,length(n)-2)} END{if(c)print "C" n}' "$f"; done)
29
+ [ -n "$c" ] || exit 0
30
+ z(){ /usr/bin/tr 'A-Z' 'a-z' | /usr/bin/tr -d ' \\t_-'; }
31
+ case $j in *'"subagent_type":'*) t=$(printf '%s' "$j" | /usr/bin/sed -n 's/.*"subagent_type":"\\([^"\\\\]*\\)".*/\\1/p');; *) t=general-purpose;; esac
32
+ case $t in ''|*[!\\ -~]*) deny;; esac
33
+ t=$(printf '%s' "$t" | z)
34
+ printf '%s\\n' "$c" | while IFS= read -r v; do v=\${v#C}; case $v in ''|*[!A-Za-z0-9._+@/\\ -]*) echo hit;; *) [ "$(printf '%s' "$v" | z)" = "$t" ] && echo hit;; esac; done | /usr/bin/grep -q hit && deny
35
+ exit 0`;
36
+ const claudeSettings = () => ({ hooks: { PreToolUse: [{ matcher: 'Agent', hooks: [{ type: 'command', command: cloudSubagentHook }] }] } });
37
+ function employeeClaudeOptions(routing) { return { tools: ['Agent', 'TaskStop', 'Skill'], disallowedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'], toolAliases: structuredClone(routing.toolAliases), settings: claudeSettings() }; }
14
38
  const permissionRanks = { claude: { plan: 0, default: 1, acceptEdits: 1, bypassPermissions: 2 }, codex: { 'read-only': 0, 'workspace-write': 1, agent: 1, 'agent-full-access': 2 } };
15
39
  /** ACP v1 with explicitly negotiated SDK 2.0 lifecycle/context extensions. */
16
40
  export class AcpSession {
@@ -555,7 +579,8 @@ export class AcpSession {
555
579
  this.validatePrompt(prompt);
556
580
  const routing = context?.employeeRouting ? structuredClone(context.employeeRouting) : undefined;
557
581
  this.employeeRouting = routing;
558
- 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 }] } } : {}) };
582
+ const claudeCode = routing ? { options: employeeClaudeOptions(routing) } : this.codexNewSessionOnly ? undefined : { options: { settings: claudeSettings() } };
583
+ const params = { cwd, mcpServers: context?.toolBridgeServers ? structuredClone(context.toolBridgeServers) : routing ? structuredClone(routing.mcpServers) : [], ...((claudeCode || this.employeeMeta) ? { _meta: { ...(this.employeeMeta ? { awEmployeeExecution: this.employeeMeta } : {}), ...(claudeCode ? { claudeCode } : {}) } } : {}), ...(systemPrompt && !(resumeId && this.codexNewSessionOnly) ? { systemPrompt: { mode: 'append', content: [{ type: 'text', text: systemPrompt }] } } : {}) };
559
584
  const configRevision = this.resetConfiguration();
560
585
  const restore = async (operation) => {
561
586
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-workbench/remote-agent",
3
- "version": "0.9.0-toolbridge.20",
3
+ "version": "0.9.0-toolbridge.21",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",