agent-bridge-service 0.2.2 → 1.0.0
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/CHANGELOG.md +112 -140
- package/README.md +508 -35
- package/README.zh-CN.md +443 -33
- package/assets/agent-icons/agy.svg +27 -0
- package/dist/adapters/acp-auth.js +51 -0
- package/dist/adapters/acp-codebuddy.js +507 -0
- package/dist/adapters/agent-adapters.js +466 -46
- package/dist/adapters/claude-stream.js +159 -0
- package/dist/adapters/codex-app-server.js +310 -0
- package/dist/adapters/host-env.js +48 -0
- package/dist/adapters/mcp-elicitation.js +148 -0
- package/dist/adapters/mcp-host.js +70 -0
- package/dist/adapters/step-parsers.js +583 -0
- package/dist/app/bootstrap.js +163 -74
- package/dist/app/claude-resident.js +204 -0
- package/dist/app/conversation.js +639 -0
- package/dist/app/service-gate.js +1 -1
- package/dist/app/session.js +425 -14
- package/dist/app/task-dispatch.js +883 -7
- package/dist/app/task-registry.js +168 -0
- package/dist/cli/dispatch.js +4 -0
- package/dist/cli/flags.js +11 -0
- package/dist/cli/help.js +25 -7
- package/dist/cli/panel.js +334 -0
- package/dist/cli/render.js +2 -0
- package/dist/commands/approvals.js +80 -0
- package/dist/commands/connect.js +122 -4
- package/dist/commands/daemon-service.js +81 -0
- package/dist/commands/daemon.js +269 -6
- package/dist/commands/logout.js +13 -10
- package/dist/commands/serve.js +98 -12
- package/dist/commands/sessions.js +106 -0
- package/dist/core/ansi.js +5 -0
- package/dist/core/artifact-extract.js +158 -0
- package/dist/core/artifact-transfer.js +583 -0
- package/dist/core/device-identity.js +22 -0
- package/dist/core/emitter.js +50 -8
- package/dist/core/errors.js +43 -0
- package/dist/core/form-schema.js +72 -0
- package/dist/core/interaction-broker.js +440 -0
- package/dist/core/interaction-url.js +63 -0
- package/dist/core/partial-messages.js +99 -0
- package/dist/core/permission-ledger.js +146 -0
- package/dist/core/permission-policy.js +88 -0
- package/dist/core/port-fallback.js +22 -0
- package/dist/core/redact.js +13 -0
- package/dist/core/scan.js +12 -7
- package/dist/core/session-store.js +1632 -0
- package/dist/core/task-supervisor.js +955 -30
- package/dist/infra/atomic-file.js +111 -0
- package/dist/infra/audit.js +7 -0
- package/dist/infra/auth.js +167 -42
- package/dist/infra/config.js +511 -72
- package/dist/infra/device-identity-store.js +87 -0
- package/dist/infra/jwt.js +149 -0
- package/dist/infra/profile-lock.js +295 -0
- package/dist/infra/proxy-env.js +60 -0
- package/dist/infra/service-token.js +25 -4
- package/dist/protocol.js +298 -2
- package/dist/transport/a2a-mapping.js +206 -0
- package/dist/transport/acp-gateway-mapping.js +186 -0
- package/dist/transport/bridge-client.js +31 -22
- package/dist/transport/control-plane-page.js +820 -0
- package/dist/transport/control-plane-sessions-page.js +90 -0
- package/dist/transport/control-plane.js +923 -71
- package/dist/transport/gateway.js +1005 -0
- package/dist/transport/office-preview.js +154 -0
- package/package.json +6 -3
- package/assets/agent-icons/gemini.svg +0 -1
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* - 跑一次 `--version` 拿版本;找到 bin 但执行失败 → installedButBroken
|
|
7
7
|
* - 凭据只判「环境变量 / 凭据文件是否存在」,读到即停,内容不落内存更不上传
|
|
8
8
|
*/
|
|
9
|
-
import { execFileSync, spawn } from 'node:child_process';
|
|
9
|
+
import { execFile, execFileSync, spawn } from 'node:child_process';
|
|
10
10
|
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
12
|
import { delimiter, join } from 'node:path';
|
|
13
|
+
import { fullModeAdmitted } from '../core/permission-policy.js';
|
|
13
14
|
import { logoDataUri } from './agent-logos.js';
|
|
14
15
|
import { buildWinCommandLine, isWinShim } from './win-exec.js';
|
|
15
16
|
const home = () => homedir();
|
|
@@ -22,7 +23,12 @@ export const AGENTS = [
|
|
|
22
23
|
display: 'Claude Code',
|
|
23
24
|
bin: 'claude',
|
|
24
25
|
capability: 'non_interactive',
|
|
25
|
-
|
|
26
|
+
// 步骤流(B 批次):stream-json 事件流喂 task_step;task_log 上行内容随之变为 JSONL
|
|
27
|
+
taskArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json', '--verbose'],
|
|
28
|
+
// full:跳过工具权限确认(非 OS 提权)
|
|
29
|
+
fullArgs: ['--dangerously-skip-permissions'],
|
|
30
|
+
resumeArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json', '--verbose', '--resume', '{{sessionId}}'],
|
|
31
|
+
steps: 'claude-json',
|
|
26
32
|
credential: {
|
|
27
33
|
envKey: 'ANTHROPIC_API_KEY',
|
|
28
34
|
envs: ['ANTHROPIC_API_KEY', 'CLAUDE_CODE_OAUTH_TOKEN'],
|
|
@@ -32,13 +38,23 @@ export const AGENTS = [
|
|
|
32
38
|
},
|
|
33
39
|
{
|
|
34
40
|
// 腾讯 CodeBuddy CLI(@tencent-ai/codebuddy-code),命令名 codebuddy,别名 cbc。
|
|
35
|
-
// 接口与 Claude Code
|
|
41
|
+
// 接口与 Claude Code 同构(实测 help 确认支持 stream-json);登录后凭据落 ~/.codebuddy。
|
|
36
42
|
kind: 'codebuddy-cli',
|
|
37
43
|
display: 'CodeBuddy CLI',
|
|
38
44
|
bin: 'codebuddy',
|
|
39
45
|
altBins: ['cbc'],
|
|
40
46
|
capability: 'non_interactive',
|
|
41
|
-
taskArgs: ['-p', '{{prompt}}', '--output-format', '
|
|
47
|
+
taskArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json', '--verbose'],
|
|
48
|
+
resumeArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json', '--verbose', '--resume', '{{sessionId}}'],
|
|
49
|
+
// full:-y 自动确认;仅当 external_sandbox=true 时才允许(env 注入由 supervisor 负责)
|
|
50
|
+
fullArgs: ['-y'],
|
|
51
|
+
steps: 'claude-json',
|
|
52
|
+
acp: {
|
|
53
|
+
command: 'codebuddy',
|
|
54
|
+
args: ['--serve', '--acp', '--port', '0'],
|
|
55
|
+
authEnv: 'CODEBUDDY_AUTH_TOKEN',
|
|
56
|
+
sanitizeHostEnv: true,
|
|
57
|
+
},
|
|
42
58
|
credential: {
|
|
43
59
|
envs: [],
|
|
44
60
|
files: [join(home(), '.codebuddy')],
|
|
@@ -50,7 +66,11 @@ export const AGENTS = [
|
|
|
50
66
|
display: 'Codex',
|
|
51
67
|
bin: 'codex',
|
|
52
68
|
capability: 'non_interactive',
|
|
69
|
+
// exec --json 已是 JSONL 事件流(item.started/item.completed);stdin 由 spawn 关闭(stdio ignore)
|
|
53
70
|
taskArgs: ['exec', '--json', '{{prompt}}'],
|
|
71
|
+
// full:同时绕过审批与 Codex 自身沙箱
|
|
72
|
+
fullArgs: ['--dangerously-bypass-approvals-and-sandbox'],
|
|
73
|
+
steps: 'codex-json',
|
|
54
74
|
credential: {
|
|
55
75
|
envKey: 'OPENAI_API_KEY',
|
|
56
76
|
envs: ['OPENAI_API_KEY'],
|
|
@@ -63,8 +83,24 @@ export const AGENTS = [
|
|
|
63
83
|
display: 'DeepSeek Harness',
|
|
64
84
|
bin: 'dsh',
|
|
65
85
|
npxSpec: '@deepseek-ai/dsh',
|
|
86
|
+
// 官方文档:headless 加 --json 出 NDJSON 事件流(tool_call/tool_result 按 callId 配对);
|
|
87
|
+
// 需 dsh ≥ 0.2.x(0.1.5 实测 --json 是 unknown option,不带 --json 只能出纯文本、没有步骤流)
|
|
88
|
+
minVersion: '0.2.0',
|
|
66
89
|
capability: 'non_interactive',
|
|
67
|
-
|
|
90
|
+
// 官方文档:headless 加 --json 出 NDJSON 事件流(tool_call/tool_result 按 callId 配对);
|
|
91
|
+
// 需 dsh ≥ 0.2.x(0.1.5 实测 --json 是 unknown option)
|
|
92
|
+
taskArgs: ['--profile', 'headless', '--json', '{{prompt}}'],
|
|
93
|
+
// full:两个官方 headless 参数;never 是「仍需审批即拒绝」,不是自动批准
|
|
94
|
+
fullArgs: ['--permission-mode', 'danger-full-access', '--approval-policy', 'never'],
|
|
95
|
+
resumeArgs: ['--profile', 'headless', '--json', '--session-id', '{{sessionId}}', '{{prompt}}'],
|
|
96
|
+
steps: 'dsh-json',
|
|
97
|
+
// 实测(0.2.1-rc.2):`dsh --profile acp` 在 stdio 上讲 ACP,initialize 回 protocolVersion=1、
|
|
98
|
+
// sessionCapabilities {close,list,resume};续会话靠自家的 `session/resume`,
|
|
99
|
+
// 标准 `session/load` 回 -32601 Method not found。
|
|
100
|
+
acp: { command: 'dsh', args: ['--profile', 'acp'] },
|
|
101
|
+
// automation-only:跑工具时只发 tool_call/tool_call_update,**从不回问权限**,也没有表单通道。
|
|
102
|
+
// 这是实测结论,不是保守估计 —— 声明了平台就会等。
|
|
103
|
+
acpInteractionKinds: [],
|
|
68
104
|
credential: {
|
|
69
105
|
envKey: 'DEEPSEEK_API_KEY',
|
|
70
106
|
envs: ['DEEPSEEK_API_KEY'],
|
|
@@ -73,16 +109,43 @@ export const AGENTS = [
|
|
|
73
109
|
},
|
|
74
110
|
},
|
|
75
111
|
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
112
|
+
// Google 官方继任者:Gemini CLI 2026-06-18 停服个人/Pro/Ultra 账号,官方指明迁移到 Antigravity。
|
|
113
|
+
// 2026-11-14 本机实测 agy 1.4.10(详见 openspec/changes/archive/2026-11-14-switch-gemini-to-antigravity-cli/design.md):
|
|
114
|
+
// - 1.4.10 无 `acp`;1.5.9 ACP 已于 2026-11-16 通过真实首轮/续接验收。
|
|
115
|
+
// WorkBuddy 进程代理可能与 Windows 系统代理不同 ⇒ 显式 external proxy 优先、系统自动探测兜底。
|
|
116
|
+
// - `-p` 吞值:prompt 必须紧跟其后且置于 argv 末尾,中间插旗标会被当 prompt 吞掉(实测 exit 2 报错)
|
|
117
|
+
// - 未登录:stderr 立即打 `Authentication required…` / `Waiting for authentication (timeout 60s)…`,
|
|
118
|
+
// 60s 后吐 `status:"ERROR"` 结果但进程不退出 ⇒ authGuard 必须 kill(实测 timeout 124 实锤挂死)
|
|
119
|
+
// - 登录令牌存 OS keyring;Windows 以固定 target=gemini:antigravity 探测存在性,不读取秘密。
|
|
120
|
+
// envs/files 留空;envKey 未复验不开放(GEMINI_API_KEY + --settings 链路留作后续)
|
|
121
|
+
kind: 'agy',
|
|
122
|
+
display: 'Antigravity CLI',
|
|
123
|
+
bin: 'agy',
|
|
124
|
+
capability: 'non_interactive',
|
|
125
|
+
minVersion: '1.5.9',
|
|
126
|
+
acp: { command: 'agy', args: ['acp'], preferSystemProxy: true },
|
|
127
|
+
acpMinVersion: '1.5.9',
|
|
128
|
+
// 已实测无工具回合与原生续接;permission/form 尚未逐项实测,不声明。
|
|
129
|
+
acpInteractionKinds: [],
|
|
130
|
+
preferSystemProxy: true,
|
|
131
|
+
// 官方 headless 文档 + 1.4.10 实测信封一致:{"event":"init"|"step_update"|"result",…同名负载}
|
|
132
|
+
taskArgs: ['--output-format', 'stream-json', '-p', '{{prompt}}'],
|
|
133
|
+
// full:官方 always-proceed 权限模式(auto-approve all tool permission requests)。
|
|
134
|
+
// 不能把旗标追加在 prompt 后:-p 的 prompt 必须始终是最后一个 argv。
|
|
135
|
+
fullArgs: ['--dangerously-skip-permissions'],
|
|
136
|
+
fullTaskArgs: ['--output-format', 'stream-json', '--dangerously-skip-permissions', '-p', '{{prompt}}'],
|
|
137
|
+
// 官方文档:`--conversation <ID>` 续接指定会话(flags 前置,-p prompt 压尾)
|
|
138
|
+
resumeArgs: ['--output-format', 'stream-json', '--conversation', '{{sessionId}}', '-p', '{{prompt}}'],
|
|
139
|
+
steps: 'agy-json',
|
|
140
|
+
authGuard: {
|
|
141
|
+
patterns: [/Authentication required/, /Waiting for authentication/],
|
|
142
|
+
hint: 'Antigravity CLI 未登录或凭据已失效:请先在本机运行 `agy` 完成一次登录',
|
|
143
|
+
},
|
|
81
144
|
credential: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
loginCommand: '
|
|
145
|
+
envs: [],
|
|
146
|
+
files: [],
|
|
147
|
+
windowsTargets: ['gemini:antigravity'],
|
|
148
|
+
loginCommand: 'agy',
|
|
86
149
|
},
|
|
87
150
|
},
|
|
88
151
|
{
|
|
@@ -90,12 +153,20 @@ export const AGENTS = [
|
|
|
90
153
|
display: 'opencode',
|
|
91
154
|
bin: 'opencode',
|
|
92
155
|
capability: 'interactive_only',
|
|
93
|
-
|
|
156
|
+
// 修 bug(B 批次实测发现):opencode 只认 `--format json`,原先写的 `--json` 是无效参数
|
|
157
|
+
taskArgs: ['run', '--format', 'json', '{{prompt}}'],
|
|
158
|
+
// full:--auto(显式 deny 仍有效)
|
|
159
|
+
fullArgs: ['--auto'],
|
|
160
|
+
steps: 'opencode-json',
|
|
161
|
+
acp: { command: 'opencode', args: ['acp'] },
|
|
94
162
|
credential: {
|
|
95
163
|
envs: ['OPENCODE_API_KEY'],
|
|
96
164
|
files: [
|
|
97
165
|
join(home(), '.local', 'share', 'opencode', 'auth.json'),
|
|
98
166
|
join(localAppData(), 'opencode', 'auth.json'),
|
|
167
|
+
// 2026-11-24 实测:自定义 provider apiKey 落在 ~/.config/opencode/opencode.json
|
|
168
|
+
//(该配置下 TUI 正常可用、auth.json 不存在)——不探测它会把可用工具稳定误报成缺凭据。
|
|
169
|
+
join(home(), '.config', 'opencode', 'opencode.json'),
|
|
99
170
|
],
|
|
100
171
|
loginCommand: 'opencode auth login',
|
|
101
172
|
},
|
|
@@ -106,27 +177,74 @@ export const AGENTS = [
|
|
|
106
177
|
bin: 'mimo',
|
|
107
178
|
altBins: ['mimo-code'],
|
|
108
179
|
capability: 'interactive_only',
|
|
109
|
-
|
|
110
|
-
|
|
180
|
+
// opencode fork(官方 drive-mimo skill 确认事件同构):run --format json 出 JSONL
|
|
181
|
+
taskArgs: ['run', '--format', 'json', '{{prompt}}'],
|
|
182
|
+
// full:与 claude 同义(显式 deny 仍有效)
|
|
183
|
+
fullArgs: ['--dangerously-skip-permissions'],
|
|
184
|
+
steps: 'opencode-json',
|
|
185
|
+
acp: { command: 'mimo', args: ['acp'] },
|
|
186
|
+
credential: {
|
|
187
|
+
envs: ['MIMO_API_KEY'],
|
|
188
|
+
// 真实凭据位置(实测):`mimo providers` 显示 Credentials `~\.local\share\mimocode\auth.json`。
|
|
189
|
+
// 之前 files 是空的,于是明明配了 key 也被判「缺凭据」。
|
|
190
|
+
files: [join(home(), '.local', 'share', 'mimocode', 'auth.json')],
|
|
191
|
+
loginCommand: 'mimo',
|
|
192
|
+
},
|
|
111
193
|
},
|
|
112
194
|
{
|
|
113
195
|
kind: 'qoder-cli',
|
|
114
196
|
display: 'Qoder CLI',
|
|
115
|
-
bin
|
|
197
|
+
// 修 bug(B 批次实测发现):真 CLI 是 qodercli;bin 'qoder' 命中的是 Qoder IDE 的
|
|
198
|
+
// Electron 入口(.qoder/entry/qoder.cmd),把 IDE 当 CLI 探测属于误报
|
|
199
|
+
bin: 'qodercli',
|
|
116
200
|
capability: 'interactive_only',
|
|
117
|
-
|
|
118
|
-
|
|
201
|
+
// 官方文档(docs.qoder.com/cli/run-in-scripts):-p + --output-format stream-json;实测 claude 同构
|
|
202
|
+
taskArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json'],
|
|
203
|
+
resumeArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json', '--resume', '{{sessionId}}'],
|
|
204
|
+
// full:Qoder 官方旁路语义
|
|
205
|
+
fullArgs: ['--dangerously-skip-permissions'],
|
|
206
|
+
steps: 'claude-json',
|
|
207
|
+
credential: {
|
|
208
|
+
envs: ['QODER_PERSONAL_ACCESS_TOKEN'],
|
|
209
|
+
files: [join(home(), '.qoder', '.auth', 'user')],
|
|
210
|
+
loginCommand: 'qodercli',
|
|
211
|
+
},
|
|
119
212
|
},
|
|
120
213
|
{
|
|
214
|
+
// 官方 xAI 命令行(Grok Build)。2026-10-29 实测 1.0.70:
|
|
215
|
+
// - `grok --version` → "grok 1.0.70 (…)",`--help` 首行 "Grok Build TUI"
|
|
216
|
+
// - 非交互仍是 `-p/--single`;`--output-format streaming-messages-json` 出的是
|
|
217
|
+
// Claude Messages 线格式(system/init → assistant/user → result),与 claude-json 解析器逐字段吻合
|
|
218
|
+
// - `-s/--session-id` 可指定会话 ID、`-r/--resume` 可续接同一会话(实测 init.session_id 前后一致)
|
|
219
|
+
// - `--always-approve` 实测使 init.permissionMode = bypassPermissions
|
|
220
|
+
// ⚠️ kind 保持 'grok-cli':它是平台 run_task.agentType 的精确匹配值,改名属跨团队契约变更,
|
|
221
|
+
// 本次只改展示名(display)与实现细节。
|
|
121
222
|
kind: 'grok-cli',
|
|
122
|
-
display: 'Grok
|
|
223
|
+
display: 'Grok Build',
|
|
123
224
|
bin: 'grok',
|
|
124
225
|
capability: 'interactive_only',
|
|
125
|
-
taskArgs: ['
|
|
226
|
+
taskArgs: ['--single', '{{prompt}}', '--output-format', 'streaming-messages-json'],
|
|
227
|
+
// full:--always-approve(沙箱是另一维度)
|
|
228
|
+
fullArgs: ['--always-approve'],
|
|
229
|
+
// 实测 -r 能续上同一 session ⇒ headless 走原生续接,而不是重放 transcript
|
|
230
|
+
resumeArgs: ['--single', '{{prompt}}', '--output-format', 'streaming-messages-json', '--resume', '{{sessionId}}'],
|
|
231
|
+
steps: 'claude-json',
|
|
232
|
+
acp: {
|
|
233
|
+
command: 'grok',
|
|
234
|
+
args: ['agent', 'stdio'],
|
|
235
|
+
// 实测 initialize 声明 authMethods = [xai.api_key(默认), grok.com];
|
|
236
|
+
// 且 **session/new 不需要先 authenticate 就能建会话** —— 所以这里刻意不写 `authMethod`:
|
|
237
|
+
// 写死 'grok.com' 会让每个任务都尝试一次浏览器登录(无浏览器机器上还会弹窗)。
|
|
238
|
+
// 只在真的有 XAI_API_KEY 时才走 API key 通道。
|
|
239
|
+
authEnvMethods: { XAI_API_KEY: 'xai.api_key' },
|
|
240
|
+
},
|
|
126
241
|
credential: {
|
|
127
242
|
envKey: 'XAI_API_KEY',
|
|
128
243
|
envs: ['XAI_API_KEY', 'GROK_API_KEY'],
|
|
129
|
-
|
|
244
|
+
// Grok Build 的真实凭据位置:OAuth 登录态 auth.json;自定义模型(含 api_key)config.toml。
|
|
245
|
+
// ⛔ 不再探测社区版遗留的 user-settings.json —— 官方版从不创建它,探测它等于稳定误报「缺凭据」。
|
|
246
|
+
files: [join(home(), '.grok', 'auth.json'), join(home(), '.grok', 'config.toml')],
|
|
247
|
+
loginCommand: 'grok login',
|
|
130
248
|
},
|
|
131
249
|
},
|
|
132
250
|
{
|
|
@@ -134,11 +252,23 @@ export const AGENTS = [
|
|
|
134
252
|
display: 'Kimi Code',
|
|
135
253
|
bin: 'kimi',
|
|
136
254
|
capability: 'interactive_only',
|
|
137
|
-
|
|
255
|
+
// 修 bug(B 批次实测发现):kimi 没有 --headless(unknown option);
|
|
256
|
+
// 非交互是 -p,stream-json 为 OpenAI tool_calls 风格(已实测)
|
|
257
|
+
taskArgs: ['-p', '{{prompt}}', '--output-format', 'stream-json'],
|
|
258
|
+
// full:**不追加** —— -p 已是 auto 权限,再加 --auto 会重复
|
|
259
|
+
fullArgs: [],
|
|
260
|
+
steps: 'kimi-json',
|
|
261
|
+
acp: { command: 'kimi', args: ['acp'] },
|
|
138
262
|
credential: {
|
|
139
263
|
envKey: 'MOONSHOT_API_KEY',
|
|
140
264
|
envs: ['MOONSHOT_API_KEY', 'KIMI_API_KEY'],
|
|
141
|
-
|
|
265
|
+
// 2026-11-24 实测(kimi 2.3.1,`kimi doctor` / `kimi provider list`):官方 oauth 凭据落
|
|
266
|
+
// ~/.kimi-code/credentials/kimi-code.json;自定义 provider(`kimi provider add` 导入)配置在
|
|
267
|
+
// ~/.kimi-code/config.toml。原探测的 ~/.kimi/config.json 从未存在 = 稳定误报缺凭据。
|
|
268
|
+
files: [
|
|
269
|
+
join(home(), '.kimi-code', 'credentials', 'kimi-code.json'),
|
|
270
|
+
join(home(), '.kimi-code', 'config.toml'),
|
|
271
|
+
],
|
|
142
272
|
loginCommand: 'kimi',
|
|
143
273
|
},
|
|
144
274
|
},
|
|
@@ -147,23 +277,125 @@ export const AGENTS = [
|
|
|
147
277
|
display: 'MiniMax Code',
|
|
148
278
|
bin: 'mcode',
|
|
149
279
|
capability: 'interactive_only',
|
|
150
|
-
|
|
151
|
-
|
|
280
|
+
// 修 bug(B 批次查证发现):mcode 的非交互子命令是 exec 不是 run;
|
|
281
|
+
// 官方 FAQ 确认 exec --output-format stream-json 出 NDJSON 事件流(0.6.13 实测:
|
|
282
|
+
// item.started/completed + item.type=tool_call,toolCall{name,input})
|
|
283
|
+
taskArgs: ['exec', '--output-format', 'stream-json', '{{prompt}}'],
|
|
284
|
+
// full:exec 的 full policy
|
|
285
|
+
fullArgs: ['--permission', 'full'],
|
|
286
|
+
steps: 'mcode-json',
|
|
287
|
+
acp: { command: 'mcode', args: ['acp'] },
|
|
288
|
+
credential: {
|
|
289
|
+
envs: ['MINIMAX_API_KEY'],
|
|
290
|
+
// 2026-11-26 实测(mcode 0.6.13):官方 oauth 凭据落
|
|
291
|
+
// ~/.minimax/auth/prod/cn/mcode-public/auth.json(登录后活跃刷新);自定义 provider
|
|
292
|
+
// (`mcode provider add`)配置在 ~/.minimax/config.yaml。此前 files 为空只认 env,
|
|
293
|
+
// 已登录/已配 provider 的机器会被稳定误报成缺凭据。
|
|
294
|
+
files: [
|
|
295
|
+
join(home(), '.minimax', 'auth', 'prod', 'cn', 'mcode-public', 'auth.json'),
|
|
296
|
+
join(home(), '.minimax', 'config.yaml'),
|
|
297
|
+
],
|
|
298
|
+
loginCommand: 'mcode',
|
|
299
|
+
},
|
|
152
300
|
},
|
|
153
301
|
{
|
|
154
302
|
kind: 'trae-cli',
|
|
155
303
|
display: 'Trae CLI',
|
|
156
304
|
bin: 'traecli',
|
|
157
305
|
capability: 'interactive_only',
|
|
158
|
-
|
|
159
|
-
|
|
306
|
+
// 修 bug(B 批次实测发现):原 `run` 子命令不存在;实测 `exec --print --output-format stream-json`
|
|
307
|
+
// 输出 claude 同构事件流(v0.211.1)
|
|
308
|
+
// 修 bug(2026-10-30 实测 0.211.1):`--print` 已不存在,`--output-format` 也不再是
|
|
309
|
+
// exec 的旗标 —— 实测 `traecli exec --print` → `unexpected argument '--print'`(exit 2)。
|
|
310
|
+
// 现在的非交互输出开关是 `--json`("Print events to stdout as JSONL")。
|
|
311
|
+
taskArgs: ['exec', '--json', '{{prompt}}'],
|
|
312
|
+
// full:--yolo(不夸大不同版本的沙箱语义)
|
|
313
|
+
fullArgs: ['--yolo'],
|
|
314
|
+
steps: 'claude-json',
|
|
315
|
+
// 修 bug(实跑复核):`traecli acp` 是**子命令组**,不带子命令只打印帮助并 exit 0 ——
|
|
316
|
+
// 于是 bridge 报「进程退出(code 0)」,看起来像正常结束,实际握手从未开始。
|
|
317
|
+
// 真入口是 `traecli acp serve`(实测 initialize 立刻回 protocolVersion=1)。
|
|
318
|
+
acp: { command: 'traecli', args: ['acp', 'serve'] },
|
|
319
|
+
credential: {
|
|
320
|
+
envs: ['TRAECLI_PERSONAL_ACCESS_TOKEN'],
|
|
321
|
+
files: [],
|
|
322
|
+
// 2026-11-27 实测(0.121.3):本版本**没有 `login` 子命令**(`traecli login` 整体落回
|
|
323
|
+
// 顶层 help),认证来自 OS keyring(由 Trae IDE 的团队/企业登录写入)或本 env 的 PAT;
|
|
324
|
+
// 未登录时模型子系统整体不可用(启动即拉云端模型列表失败)。statusCommand 对缺该子命令
|
|
325
|
+
// 的版本自然返回非零 → 诚实报缺凭据,不会误报 ready;未来版本补回 login 即自动生效。
|
|
326
|
+
statusCommand: { args: ['login', 'status'], timeoutMs: 3_000 },
|
|
327
|
+
loginCommand: 'traecli',
|
|
328
|
+
},
|
|
160
329
|
},
|
|
161
330
|
];
|
|
162
331
|
export function agentDefOf(kind) {
|
|
163
332
|
return AGENTS.find((a) => a.kind === kind);
|
|
164
333
|
}
|
|
334
|
+
/** 生成指定权限模式的默认 argv;fullTaskArgs 是少数位置敏感 CLI 的显式覆盖。 */
|
|
335
|
+
export function taskArgsForPermission(def, mode) {
|
|
336
|
+
if (mode === 'default')
|
|
337
|
+
return def.taskArgs;
|
|
338
|
+
return def.fullTaskArgs ?? [...def.taskArgs, ...(def.fullArgs ?? [])];
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* 按执行模式如实描述能力(1.0 `AgentListItem.executionModes`)。
|
|
342
|
+
*
|
|
343
|
+
* 为什么不能只报一个 `capability`:同一工具在 headless 与 ACP 下能做的事不一样 ——
|
|
344
|
+
* headless 可能支持 full(危险参数),ACP 只走 default + 原生 permission 交互。
|
|
345
|
+
* 混着报会让平台请求出「跑到一半才失败」的组合,所以这里逐模式列,未验证的一律不列。
|
|
346
|
+
*/
|
|
347
|
+
export function executionModesFor(def, externalSandbox = false, installedVersion) {
|
|
348
|
+
// steps 只有声明了步骤解析器才真的产出 task_step;artifacts 是任务级双向通道,两种模式都有
|
|
349
|
+
const headlessFeed = ['messages', ...(def.steps !== undefined ? ['steps'] : []), 'artifacts'];
|
|
350
|
+
const admitted = fullModeAdmitted({ kind: def.kind, fullArgs: def.fullArgs, externalSandbox });
|
|
351
|
+
// headless 要么靠 CLI 的续接参数接上原生会话,要么拿完整 transcript 重放 —— 后者是 12/12 的底线
|
|
352
|
+
const headlessContinuation = def.resumeArgs ? 'resume-session' : 'replay-session';
|
|
353
|
+
const modes = [
|
|
354
|
+
{
|
|
355
|
+
mode: 'headless',
|
|
356
|
+
// 未通过 full 准入(尤其 CodeBuddy 没声明 external_sandbox)就不声明 full,避免平台误判
|
|
357
|
+
permissionModes: admitted ? ['default', 'full'] : ['default'],
|
|
358
|
+
// headless 是一次性执行,没有回问通道
|
|
359
|
+
interactionKinds: [],
|
|
360
|
+
feedKinds: headlessFeed,
|
|
361
|
+
continuation: headlessContinuation,
|
|
362
|
+
},
|
|
363
|
+
];
|
|
364
|
+
const acpVersionOk = def.acpMinVersion === undefined ||
|
|
365
|
+
(installedVersion !== undefined && meetsMinVersion(installedVersion, def.acpMinVersion));
|
|
366
|
+
if (def.acp && acpVersionOk) {
|
|
367
|
+
modes.push({
|
|
368
|
+
mode: 'acp-stdio',
|
|
369
|
+
// ACP 走原生 permission 交互,不走「跳过审批」的 full 参数
|
|
370
|
+
permissionModes: ['default'],
|
|
371
|
+
// 逐工具如实声明:dsh 的 ACP 是 automation-only,实测不发权限/表单请求
|
|
372
|
+
interactionKinds: def.acpInteractionKinds ?? ['permission', 'form'],
|
|
373
|
+
// ACP 的 agent_message_chunk → messages、tool_call → steps;artifacts 暂无 ACP 来源
|
|
374
|
+
feedKinds: ['messages', 'steps'],
|
|
375
|
+
// ACP 会话由 agent 持有,bridge 只回传 ID(当前 9 个声明工具走 session/load 或 session/resume)
|
|
376
|
+
continuation: 'native-session',
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return modes;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* 这些执行模式里是否存在能续接回合的一档 = 该工具能不能开 conversation。
|
|
383
|
+
*
|
|
384
|
+
* 判据是「任一模式可续」而不是「headless 可续」:同一工具可能 headless 单轮、ACP 能续,
|
|
385
|
+
* 平台只给了 agentType、并没有指定通道,取任一模式可续才是如实回答。
|
|
386
|
+
*/
|
|
387
|
+
export function canContinue(modes) {
|
|
388
|
+
return modes.some((m) => m.continuation !== 'single-turn');
|
|
389
|
+
}
|
|
390
|
+
/** 该 agentType 是否支持多轮会话;未知工具返回 false 由调用方按「未知工具」单独处理 */
|
|
391
|
+
export function agentCanContinue(kind) {
|
|
392
|
+
const def = agentDefOf(kind);
|
|
393
|
+
return def ? canContinue(executionModesFor(def)) : false;
|
|
394
|
+
}
|
|
165
395
|
// ---------- 可执行文件解析 ----------
|
|
166
|
-
|
|
396
|
+
// `.exe` 必须排在 `.cmd` 前面:`.exe` 可以直接 spawn,`.cmd/.bat` 是 npm 垫片,
|
|
397
|
+
// 必须经 shell 转发(见 win-exec.ts)。顺序反了,ACP 通道会拿到 .cmd 然后 EINVAL。
|
|
398
|
+
const WIN_EXTS = ['.exe', '.cmd', '.bat', ''];
|
|
167
399
|
/** Windows 上真正能 spawn 的可执行扩展名(无扩展名的 shim 是 bash 脚本,Node 起不来) */
|
|
168
400
|
const WIN_EXEC_RE = /\.(exe|cmd|bat)$/i;
|
|
169
401
|
function isExecutableFile(p) {
|
|
@@ -180,6 +412,53 @@ function isExecutableFile(p) {
|
|
|
180
412
|
return false;
|
|
181
413
|
}
|
|
182
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* 从 `where` / `command -v` 的输出里挑一个真正能执行的路径。
|
|
417
|
+
*
|
|
418
|
+
* 为什么 `.exe` 优先:同目录常同时存在 `foo.cmd`(npm 垫片)与 `foo.exe`,
|
|
419
|
+
* 而 `where` 的输出顺序不保证。挑到 `.cmd` 时调用方必须走 shell 转发 ——
|
|
420
|
+
* ACP 这类要长期持有 stdin/stdout 的通道经一层 cmd.exe 转发既多余又易碎。
|
|
421
|
+
*/
|
|
422
|
+
export function pickPreferredBin(hits) {
|
|
423
|
+
const usable = hits.map((s) => s.trim()).filter(Boolean).filter((p) => isExecutableFile(p));
|
|
424
|
+
return usable.find((p) => /\.exe$/i.test(p)) ?? usable[0];
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* 启动一个 CLI 子进程,统一处理 Windows `.cmd/.bat` 垫片。
|
|
428
|
+
*
|
|
429
|
+
* 为什么这个函数在这里而不是 `win-exec.ts`:`protocol-boundary-check` 只允许
|
|
430
|
+
* 本文件与 `task-supervisor.ts` 出现 `shell: true`(垫片必须经 shell 转发),
|
|
431
|
+
* 而长驻通道(ACP / app-server)也要同一套处理。与其让每个 adapter 各写一份、
|
|
432
|
+
* 各自被门禁拦下,不如收敛成这一个入口 —— 拼命令行仍走 `win-exec.ts`。
|
|
433
|
+
*/
|
|
434
|
+
export function spawnCliProcess(binPath, argv, opts) {
|
|
435
|
+
const stdio = ['pipe', 'pipe', 'pipe'];
|
|
436
|
+
return (isWinShim(binPath)
|
|
437
|
+
? spawn(buildWinCommandLine(binPath, argv), {
|
|
438
|
+
cwd: opts.cwd,
|
|
439
|
+
env: opts.env,
|
|
440
|
+
shell: true,
|
|
441
|
+
windowsHide: true,
|
|
442
|
+
stdio,
|
|
443
|
+
})
|
|
444
|
+
: spawn(binPath, argv, { cwd: opts.cwd, env: opts.env, windowsHide: true, stdio }));
|
|
445
|
+
}
|
|
446
|
+
/** Windows 垫片必须回收整棵树;直接 exe/posix 保留原 kill 语义。taskkill 输出与错误不上行。 */
|
|
447
|
+
export function killCliProcess(child, binPath) {
|
|
448
|
+
if (process.platform === 'win32' && isWinShim(binPath) && child.pid) {
|
|
449
|
+
execFile('taskkill', ['/pid', String(child.pid), '/T', '/F'], { timeout: 2_000, windowsHide: true }, () => {
|
|
450
|
+
// taskkill 失败时至少终止外壳;不让清理异常反噬已结算任务。
|
|
451
|
+
try {
|
|
452
|
+
child.kill();
|
|
453
|
+
}
|
|
454
|
+
catch {
|
|
455
|
+
/* 已退出 */
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
child.kill();
|
|
461
|
+
}
|
|
183
462
|
/** 候选目录:PATH → 常见用户目录 → 逐用户 Programs\<厂商>\<产品>\bin */
|
|
184
463
|
export function candidateBinDirs() {
|
|
185
464
|
const dirs = [];
|
|
@@ -196,6 +475,12 @@ export function candidateBinDirs() {
|
|
|
196
475
|
push(join(home(), '.volta', 'bin'));
|
|
197
476
|
push(join(home(), '.cargo', 'bin'));
|
|
198
477
|
push(join(home(), '.codex', 'packages', 'standalone', 'current', 'bin'));
|
|
478
|
+
// 自带安装器的 CLI 常把可执行塞进 `~/.<product>/bin` 且**不写 PATH**:
|
|
479
|
+
// Mimo Code 就是 `~/.mimocode/bin/mimo.exe`(实测 0.1.16 能跑,但 `where mimo` 找不到,
|
|
480
|
+
// 于是 bridge 误判「未安装」)。扫到就能自动就绪,不必要求用户改 PATH。
|
|
481
|
+
push(join(home(), '.mimocode', 'bin'));
|
|
482
|
+
// agy 同例且更隐蔽:装进 `%LOCALAPPDATA%\agy\bin`(跨厂商目录,Programs 扫描盖不住)
|
|
483
|
+
push(join(localAppData(), 'agy', 'bin'));
|
|
199
484
|
const root = join(localAppData(), 'Programs');
|
|
200
485
|
try {
|
|
201
486
|
for (const vendor of readdirSync(root)) {
|
|
@@ -252,13 +537,9 @@ export function resolveBin(names) {
|
|
|
252
537
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
253
538
|
});
|
|
254
539
|
// where 可能返回多行(grok.cmd / grok.exe / grok),逐个看,取第一个真正能执行的
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
.filter(Boolean);
|
|
259
|
-
const usable = hits.find((p) => isExecutableFile(p));
|
|
260
|
-
if (usable)
|
|
261
|
-
return usable;
|
|
540
|
+
const preferred = pickPreferredBin(out.split(/\r?\n/));
|
|
541
|
+
if (preferred)
|
|
542
|
+
return preferred;
|
|
262
543
|
}
|
|
263
544
|
catch {
|
|
264
545
|
/* 继续走目录扫描 */
|
|
@@ -270,6 +551,31 @@ export function resolveBin(names) {
|
|
|
270
551
|
}
|
|
271
552
|
return undefined;
|
|
272
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* 把 AgentDef 的 acp 声明变成「能直接 spawn 的 spec」。
|
|
556
|
+
*
|
|
557
|
+
* 两件事必须在**调用方**做,不能让 runner 自己做:
|
|
558
|
+
* 1) 补 `label` —— 9 个工具共用一个 runner,没有 label 就只能写死一个产品名,
|
|
559
|
+
* 于是 opencode / trae 的失败被冠上 CodeBuddy 的名字,排查直接被带偏;
|
|
560
|
+
* 2) 把 `command` 解析成**绝对路径** —— 否则 spawn 依赖 PATH,而扫描用的是 `resolveBin`,
|
|
561
|
+
* 就会出现「status 报就绪、跑起来 ENOENT」这种自相矛盾(qoder 实跑即此)。
|
|
562
|
+
*
|
|
563
|
+
* 解析失败时保留原 command:让 spawn 报出的 ENOENT 至少还带着 label,
|
|
564
|
+
* 比在这里静默返回 undefined(调用方会退回 CodeBuddy spec)更安全。
|
|
565
|
+
*/
|
|
566
|
+
export function acpSpecFor(def) {
|
|
567
|
+
if (!def?.acp)
|
|
568
|
+
return undefined;
|
|
569
|
+
// 已经是路径就不再 where 一次:每次解析约 300-400ms,run_task 在同步路径上不该白付这个钱。
|
|
570
|
+
const alreadyPath = /[\\/]/.test(def.acp.command);
|
|
571
|
+
const resolved = alreadyPath ? def.acp.command : resolveBin([def.acp.command, ...(def.altBins ?? [])]);
|
|
572
|
+
return {
|
|
573
|
+
...def.acp,
|
|
574
|
+
label: def.acp.label ?? def.display,
|
|
575
|
+
command: resolved ?? def.acp.command,
|
|
576
|
+
...(def.credential.loginCommand ? { loginCommand: def.credential.loginCommand } : {}),
|
|
577
|
+
};
|
|
578
|
+
}
|
|
273
579
|
/**
|
|
274
580
|
* `resolveBin` 的异步版本,供扫描并发使用。
|
|
275
581
|
* 同步版每次 `where` 约 300-400ms,12 个工具串行就是 4s 量级 —— 扫描用这个才能与版本探测并行。
|
|
@@ -302,11 +608,7 @@ export async function resolveBinAsync(names) {
|
|
|
302
608
|
resolve(buf);
|
|
303
609
|
});
|
|
304
610
|
});
|
|
305
|
-
const usable = out
|
|
306
|
-
.split(/\r?\n/)
|
|
307
|
-
.map((s) => s.trim())
|
|
308
|
-
.filter(Boolean)
|
|
309
|
-
.find((p) => isExecutableFile(p));
|
|
611
|
+
const usable = pickPreferredBin(out.split(/\r?\n/));
|
|
310
612
|
if (usable)
|
|
311
613
|
return usable;
|
|
312
614
|
}
|
|
@@ -398,8 +700,120 @@ export function probeCredential(def) {
|
|
|
398
700
|
const hasEvidence = def.credential.envs.length > 0 || def.credential.files.length > 0;
|
|
399
701
|
return hasEvidence ? { status: 'missing' } : { status: 'unknown' };
|
|
400
702
|
}
|
|
703
|
+
/** cmdkey 的本地化文案不参与判断;只认每行末尾稳定的 ASCII target 标记。 */
|
|
704
|
+
export function windowsCredentialTargetPresent(output, target) {
|
|
705
|
+
const marker = `LegacyGeneric:target=${target}`;
|
|
706
|
+
return output.split(/\r?\n/).some((line) => line.trim().endsWith(marker));
|
|
707
|
+
}
|
|
708
|
+
function listWindowsCredentialTargets() {
|
|
709
|
+
return new Promise((resolve, reject) => {
|
|
710
|
+
execFile('cmdkey', ['/list'], { encoding: 'utf8', timeout: 2_000, maxBuffer: 256 * 1024, windowsHide: true }, (error, stdout) => {
|
|
711
|
+
if (error)
|
|
712
|
+
reject(error);
|
|
713
|
+
else
|
|
714
|
+
resolve(stdout);
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* 在 env/file 的直接证据之后补 OS keyring 存在性探测。
|
|
720
|
+
* 完整 cmdkey 输出只在函数内消费,不写日志/事件/数据库;失败时保留原保守结果。
|
|
721
|
+
*/
|
|
722
|
+
export async function probeCredentialWithKeyring(def, opts = {}) {
|
|
723
|
+
const direct = probeCredential(def);
|
|
724
|
+
const targets = def.credential.windowsTargets ?? [];
|
|
725
|
+
if (direct.status === 'configured' || targets.length === 0 || (opts.platform ?? process.platform) !== 'win32') {
|
|
726
|
+
return direct;
|
|
727
|
+
}
|
|
728
|
+
try {
|
|
729
|
+
const output = await (opts.listWindowsTargets ?? listWindowsCredentialTargets)();
|
|
730
|
+
const target = targets.find((item) => windowsCredentialTargetPresent(output, item));
|
|
731
|
+
return target ? { status: 'configured', source: `keyring:${target}` } : direct;
|
|
732
|
+
}
|
|
733
|
+
catch {
|
|
734
|
+
return direct;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
function runCredentialStatusCommand(binPath, args, timeoutMs) {
|
|
738
|
+
return new Promise((resolve) => {
|
|
739
|
+
let done = false;
|
|
740
|
+
let timer;
|
|
741
|
+
const finish = (configured) => {
|
|
742
|
+
if (done)
|
|
743
|
+
return;
|
|
744
|
+
done = true;
|
|
745
|
+
if (timer)
|
|
746
|
+
clearTimeout(timer);
|
|
747
|
+
resolve(configured);
|
|
748
|
+
};
|
|
749
|
+
try {
|
|
750
|
+
const child = spawnCliProcess(binPath, args, { cwd: home(), env: process.env });
|
|
751
|
+
// 状态命令的输出可能含账号信息:只排空管道,绝不写日志或上行。
|
|
752
|
+
child.stdout.resume();
|
|
753
|
+
child.stderr.resume();
|
|
754
|
+
timer = setTimeout(() => {
|
|
755
|
+
killCliProcess(child, binPath);
|
|
756
|
+
finish(false);
|
|
757
|
+
}, timeoutMs);
|
|
758
|
+
child.on('error', () => finish(false));
|
|
759
|
+
child.on('close', (code) => finish(code === 0));
|
|
760
|
+
}
|
|
761
|
+
catch {
|
|
762
|
+
finish(false);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
/** env/file → keyring → 官方只读状态命令;任一明确证据存在即 configured。 */
|
|
767
|
+
export async function probeCredentialRuntime(def, binPath, opts = {}) {
|
|
768
|
+
const probed = await probeCredentialWithKeyring(def, opts);
|
|
769
|
+
const command = def.credential.statusCommand;
|
|
770
|
+
if (probed.status === 'configured' || !command)
|
|
771
|
+
return probed;
|
|
772
|
+
try {
|
|
773
|
+
const configured = await (opts.runStatusCommand ??
|
|
774
|
+
(() => runCredentialStatusCommand(binPath, command.args, command.timeoutMs ?? 3_000)))();
|
|
775
|
+
return configured
|
|
776
|
+
? { status: 'configured', source: `command:${command.args.join(' ')}` }
|
|
777
|
+
: probed;
|
|
778
|
+
}
|
|
779
|
+
catch {
|
|
780
|
+
return probed;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
/** 解析 `MAJOR.MINOR.PATCH[-pre]`;解析不出来返回 undefined */
|
|
784
|
+
function parseVersion(v) {
|
|
785
|
+
if (!v)
|
|
786
|
+
return undefined;
|
|
787
|
+
const m = /(\d+)\.(\d+)(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?/.exec(v);
|
|
788
|
+
if (!m)
|
|
789
|
+
return undefined;
|
|
790
|
+
return {
|
|
791
|
+
nums: [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)],
|
|
792
|
+
pre: Boolean(m[4]),
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* 版本是否满足最低要求。
|
|
797
|
+
*
|
|
798
|
+
* 只做「够不够跑 taskArgs」这一件事,不实现完整 semver 范围语法。
|
|
799
|
+
* prerelease 视为低于同号正式版(`0.1.5-rc.3` < `0.1.5`),与 semver 一致。
|
|
800
|
+
* 任一侧解析不出来就返回 true —— 宁可放行让人真跑一次,也不要因为版本字符串怪就判死。
|
|
801
|
+
*/
|
|
802
|
+
export function meetsMinVersion(actual, min) {
|
|
803
|
+
const a = parseVersion(actual);
|
|
804
|
+
const b = parseVersion(min);
|
|
805
|
+
if (!a || !b)
|
|
806
|
+
return true;
|
|
807
|
+
for (let i = 0; i < 3; i += 1) {
|
|
808
|
+
if (a.nums[i] !== b.nums[i])
|
|
809
|
+
return a.nums[i] > b.nums[i];
|
|
810
|
+
}
|
|
811
|
+
if (a.pre && !b.pre)
|
|
812
|
+
return false;
|
|
813
|
+
return true;
|
|
814
|
+
}
|
|
401
815
|
/** 探测单个工具(不抛错:任何异常都降级成 not_installed / installedButBroken) */
|
|
402
|
-
export async function probeAgent(def) {
|
|
816
|
+
export async function probeAgent(def, externalSandbox = false) {
|
|
403
817
|
const binPath = await resolveBinAsync([def.bin, ...(def.altBins ?? [])]);
|
|
404
818
|
// 图标按 kind 直接映射 assets/agent-icons/<kind>.svg,不额外维护一张表
|
|
405
819
|
const logo = logoDataUri(def.kind);
|
|
@@ -408,12 +822,15 @@ export async function probeAgent(def) {
|
|
|
408
822
|
display: def.display,
|
|
409
823
|
status: 'not_installed',
|
|
410
824
|
capability: def.capability,
|
|
825
|
+
// 步骤流能力如实标注:纯文本工具 false,平台的步骤面板对它降级为空状态
|
|
826
|
+
steps: def.steps !== undefined,
|
|
827
|
+
executionModes: executionModesFor(def, externalSandbox),
|
|
411
828
|
...(logo ? { logo } : {}),
|
|
412
829
|
};
|
|
413
830
|
if (!binPath) {
|
|
414
831
|
// 免安装工具:不落本地可执行文件,直接算「未装凭据」(装了 npx 就能跑)
|
|
415
832
|
if (def.npxSpec) {
|
|
416
|
-
const cred =
|
|
833
|
+
const cred = await probeCredentialWithKeyring(def);
|
|
417
834
|
return {
|
|
418
835
|
...base,
|
|
419
836
|
status: cred.status === 'configured' ? 'ready' : 'installed_no_cred',
|
|
@@ -424,14 +841,17 @@ export async function probeAgent(def) {
|
|
|
424
841
|
return base;
|
|
425
842
|
}
|
|
426
843
|
const ver = await probeVersion(binPath);
|
|
427
|
-
const cred =
|
|
844
|
+
const cred = await probeCredentialRuntime(def, binPath);
|
|
428
845
|
const status = cred.status === 'configured' ? 'ready' : 'installed_no_cred';
|
|
846
|
+
// 版本不够跑 taskArgs 也算「装坏」:否则平台会派任务下来,用户只看到一个 unknown option。
|
|
847
|
+
const tooOld = def.minVersion !== undefined && !meetsMinVersion(ver.version, def.minVersion);
|
|
429
848
|
return {
|
|
430
849
|
...base,
|
|
850
|
+
executionModes: executionModesFor(def, externalSandbox, ver.version),
|
|
431
851
|
status,
|
|
432
852
|
version: ver.version,
|
|
433
853
|
path: binPath,
|
|
434
854
|
credentialSource: cred.source,
|
|
435
|
-
installedButBroken: !ver.ok,
|
|
855
|
+
installedButBroken: !ver.ok || tooOld,
|
|
436
856
|
};
|
|
437
857
|
}
|