@armadra/agent 0.17.3 → 0.19.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 +50 -0
- package/CHANGELOG.zh-CN.md +50 -0
- package/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/THIRD_PARTY_NOTICES.md +6 -0
- package/assets/quickjs/LICENSE +57 -0
- package/assets/quickjs/README.md +14 -0
- package/assets/quickjs/quickjs.wasm +0 -0
- package/dist/agent/recovery-reminder.js +6 -1
- package/dist/agent/schema-coerce.d.ts +24 -0
- package/dist/agent/schema-coerce.js +157 -0
- package/dist/agent/schema.d.ts +1 -1
- package/dist/agent/schema.js +1 -1
- package/dist/agent/session-cache.js +12 -0
- package/dist/agent/tool-runner.js +57 -28
- package/dist/agent/types.d.ts +4 -0
- package/dist/ai/apis/anthropic-compat.d.ts +3 -1
- package/dist/ai/apis/anthropic-compat.js +8 -1
- package/dist/ai/apis/anthropic-messages.js +54 -2
- package/dist/ai/apis/anthropic-request.d.ts +3 -0
- package/dist/ai/apis/anthropic-request.js +7 -1
- package/dist/ai/apis/anthropic-threads.d.ts +64 -0
- package/dist/ai/apis/anthropic-threads.js +192 -0
- package/dist/ai/providers/catalog-data.js +5 -5
- package/dist/ai/providers/models-dev-data.js +22 -22
- package/dist/ai/types.d.ts +16 -0
- package/dist/bundle/ama-sandbox.cjs +96 -2
- package/dist/bundle/ama.cjs +29964 -27673
- package/dist/cli/bootstrap.js +32 -6
- package/dist/cli/compose-agents.js +2 -1
- package/dist/cli/compose-extensions-load.d.ts +20 -0
- package/dist/cli/compose-extensions-load.js +38 -0
- package/dist/cli/compose.js +1 -0
- package/dist/cli/deps.d.ts +11 -0
- package/dist/cli/runtime.d.ts +7 -0
- package/dist/cli/subcommands/config.d.ts +3 -0
- package/dist/cli/subcommands/config.js +22 -7
- package/dist/cli/subcommands/doctor.js +34 -0
- package/dist/cli/subcommands/models-discover.js +6 -2
- package/dist/codemode/capability.d.ts +14 -2
- package/dist/codemode/capability.js +19 -2
- package/dist/codemode/host-side.d.ts +14 -0
- package/dist/codemode/host-side.js +81 -10
- package/dist/codemode/inner-calls.d.ts +19 -0
- package/dist/codemode/inner-calls.js +24 -0
- package/dist/codemode/protocol.d.ts +14 -0
- package/dist/codemode/protocol.js +9 -1
- package/dist/codemode/quickjs/host.d.ts +15 -0
- package/dist/codemode/quickjs/host.js +243 -0
- package/dist/codemode/quickjs/wasm.d.ts +21 -0
- package/dist/codemode/quickjs/wasm.js +39 -0
- package/dist/codemode/quickjs/worker.d.ts +55 -0
- package/dist/codemode/quickjs/worker.js +457 -0
- package/dist/codemode/sandbox-entry.d.ts +4 -0
- package/dist/codemode/sandbox-entry.js +95 -3
- package/dist/codemode/script-images.d.ts +18 -0
- package/dist/codemode/script-images.js +38 -0
- package/dist/codemode/script-output.d.ts +19 -0
- package/dist/codemode/script-output.js +67 -0
- package/dist/codemode/search-tools.d.ts +27 -0
- package/dist/codemode/search-tools.js +83 -0
- package/dist/codemode/tool.d.ts +4 -0
- package/dist/codemode/tool.js +60 -9
- package/dist/codemode/worker-pool.d.ts +65 -0
- package/dist/codemode/worker-pool.js +131 -0
- package/dist/config/extension-tree-hash.d.ts +31 -0
- package/dist/config/extension-tree-hash.js +88 -0
- package/dist/config/extension-trust.d.ts +70 -0
- package/dist/config/extension-trust.js +112 -0
- package/dist/config/json-schema.js +3 -1
- package/dist/config/key-docs.js +7 -1
- package/dist/config/profile.d.ts +2 -0
- package/dist/config/profile.js +1 -0
- package/dist/config/schema-trust.d.ts +7 -0
- package/dist/config/schema-trust.js +46 -0
- package/dist/config/schema.d.ts +4 -5
- package/dist/config/schema.js +7 -27
- package/dist/config/settings-registry.js +2 -0
- package/dist/config/trust.d.ts +2 -0
- package/dist/config/trust.js +5 -1
- package/dist/config/types.d.ts +23 -0
- package/dist/config/types.js +1 -0
- package/dist/drivers/host-runners.d.ts +15 -4
- package/dist/drivers/host-runners.js +31 -17
- package/dist/errors.d.ts +1 -1
- package/dist/host/api-impl.d.ts +47 -4
- package/dist/host/api-impl.js +181 -20
- package/dist/host/commands.d.ts +23 -0
- package/dist/host/commands.js +76 -0
- package/dist/host/extensions.d.ts +43 -0
- package/dist/host/extensions.js +117 -0
- package/dist/host/resources.d.ts +2 -0
- package/dist/host/resources.js +5 -0
- package/dist/host/types.d.ts +41 -2
- package/dist/host/types.js +4 -2
- package/dist/i18n/catalog.d.ts +39 -0
- package/dist/i18n/messages/cli.d.ts +24 -0
- package/dist/i18n/messages/cli.js +24 -0
- package/dist/i18n/messages/config-keys.d.ts +4 -0
- package/dist/i18n/messages/config-keys.js +6 -2
- package/dist/i18n/messages/config.d.ts +4 -0
- package/dist/i18n/messages/drivers.d.ts +22 -0
- package/dist/i18n/messages/drivers.js +22 -0
- package/dist/i18n/messages/errors.d.ts +1 -1
- package/dist/i18n/messages/interactive-startup.d.ts +4 -0
- package/dist/i18n/messages/interactive-startup.js +4 -0
- package/dist/i18n/messages/interactive-view.d.ts +2 -0
- package/dist/i18n/messages/interactive-view.js +2 -0
- package/dist/i18n/messages/interactive.d.ts +6 -0
- package/dist/i18n/messages/report.d.ts +14 -0
- package/dist/i18n/messages/report.js +14 -0
- package/dist/i18n/messages/subcommands-config.d.ts +8 -0
- package/dist/i18n/messages/subcommands-config.js +8 -0
- package/dist/i18n/messages/subcommands.d.ts +8 -0
- package/dist/modes/acp/acp-config.d.ts +4 -2
- package/dist/modes/acp/acp-config.js +17 -3
- package/dist/modes/acp/acp-events.d.ts +2 -0
- package/dist/modes/acp/acp-events.js +4 -0
- package/dist/modes/acp/acp-server.js +6 -2
- package/dist/modes/acp/acp-sessions.d.ts +8 -1
- package/dist/modes/acp/acp-sessions.js +18 -0
- package/dist/modes/commands-core.d.ts +14 -1
- package/dist/modes/commands-core.js +34 -2
- package/dist/modes/interactive/startup-ui.js +21 -0
- package/dist/modes/interactive/status-area.js +1 -1
- package/dist/modes/interactive/tool-view.d.ts +8 -2
- package/dist/modes/interactive/tool-view.js +12 -5
- package/dist/modes/print/print-mode.d.ts +3 -0
- package/dist/modes/print/print-mode.js +35 -8
- package/dist/modes/rpc/commands.d.ts +2 -0
- package/dist/modes/rpc/commands.js +22 -7
- package/dist/modes/rpc/rpc-mode.js +3 -0
- package/dist/modes/startup-ui-text.js +11 -0
- package/dist/rpc.d.ts +2 -1
- package/dist/session/unclean-end.d.ts +8 -0
- package/dist/session/unclean-end.js +39 -7
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/registry.js +13 -0
- package/dist/tools/types.d.ts +7 -0
- package/docs/README.md +1 -1
- package/docs/en/README.md +3 -3
- package/docs/en/guides/extensions.md +141 -0
- package/docs/en/guides/providers.md +27 -7
- package/docs/en/guides/tui.md +1 -1
- package/docs/en/reference/acp.md +1 -1
- package/docs/en/reference/host-api.md +55 -27
- package/docs/en/reference/rpc.md +12 -8
- package/docs/guides/codemode.md +52 -12
- package/docs/guides/extensions.md +136 -0
- package/docs/guides/providers.md +21 -1
- package/docs/guides/sandbox.md +2 -0
- package/docs/guides/tui.md +1 -1
- package/docs/reference/acp.md +1 -1
- package/docs/reference/host-api.md +55 -27
- package/docs/reference/rpc.md +12 -8
- package/docs/reference/session-format.md +10 -9
- package/package.json +5 -2
|
@@ -74,6 +74,7 @@ export declare const en: {
|
|
|
74
74
|
fetched: (title: string | undefined, size: string, format: string) => string;
|
|
75
75
|
fetchRedirect: (url: string) => string;
|
|
76
76
|
awaiting: (glyph: string) => string;
|
|
77
|
+
coerced: string;
|
|
77
78
|
subagentRunning: (elapsed: string) => string;
|
|
78
79
|
running: (elapsed: string) => string;
|
|
79
80
|
moreLines: (ellipsis: string, n: number) => string;
|
|
@@ -145,6 +146,7 @@ export declare const zh: {
|
|
|
145
146
|
fetched: (title: string | undefined, size: string, format: string) => string;
|
|
146
147
|
fetchRedirect: (url: string) => string;
|
|
147
148
|
awaiting: (glyph: string) => string;
|
|
149
|
+
coerced: string;
|
|
148
150
|
subagentRunning: (elapsed: string) => string;
|
|
149
151
|
running: (elapsed: string) => string;
|
|
150
152
|
moreLines: (ellipsis: string, n: number) => string;
|
|
@@ -77,6 +77,7 @@ export const en = {
|
|
|
77
77
|
fetched: (title, size, format) => [title, size, format].filter((p) => p !== undefined && p !== "").join(" · "),
|
|
78
78
|
fetchRedirect: (url) => `redirected to ${url} (not followed)`,
|
|
79
79
|
awaiting: (glyph) => `${glyph} awaiting approval`,
|
|
80
|
+
coerced: "(arguments adjusted)",
|
|
80
81
|
subagentRunning: (elapsed) => `subagent · running ${elapsed}`,
|
|
81
82
|
running: (elapsed) => `running · ${elapsed}`,
|
|
82
83
|
moreLines: (ellipsis, n) => `${ellipsis} ${plural(n, "more line")} (Ctrl+O to expand)`,
|
|
@@ -148,6 +149,7 @@ export const zh = {
|
|
|
148
149
|
fetched: (title, size, format) => [title, size, format].filter((p) => p !== undefined && p !== "").join(" · "),
|
|
149
150
|
fetchRedirect: (url) => `重定向到 ${url}(未跟随)`,
|
|
150
151
|
awaiting: (glyph) => `${glyph} 等待确认`,
|
|
152
|
+
coerced: "(参数已调整)",
|
|
151
153
|
subagentRunning: (elapsed) => `子 Agent · 运行中 ${elapsed}`,
|
|
152
154
|
running: (elapsed) => `运行中 · ${elapsed}`,
|
|
153
155
|
moreLines: (ellipsis, n) => `${ellipsis} 另 ${n} 行(Ctrl+O 展开)`,
|
|
@@ -199,6 +199,7 @@ export declare const en: {
|
|
|
199
199
|
fetched: (title: string | undefined, size: string, format: string) => string;
|
|
200
200
|
fetchRedirect: (url: string) => string;
|
|
201
201
|
awaiting: (glyph: string) => string;
|
|
202
|
+
coerced: string;
|
|
202
203
|
subagentRunning: (elapsed: string) => string;
|
|
203
204
|
running: (elapsed: string) => string;
|
|
204
205
|
moreLines: (ellipsis: string, n: number) => string;
|
|
@@ -233,6 +234,8 @@ export declare const en: {
|
|
|
233
234
|
trustNever: string;
|
|
234
235
|
moreResources: (n: number) => string;
|
|
235
236
|
trustTitle: string;
|
|
237
|
+
extensionsTitle: string;
|
|
238
|
+
extensionDirectory: string;
|
|
236
239
|
resumeTitle: string;
|
|
237
240
|
modelTitle: string;
|
|
238
241
|
cwdTitle: string;
|
|
@@ -449,6 +452,7 @@ export declare const zh: {
|
|
|
449
452
|
fetched: (title: string | undefined, size: string, format: string) => string;
|
|
450
453
|
fetchRedirect: (url: string) => string;
|
|
451
454
|
awaiting: (glyph: string) => string;
|
|
455
|
+
coerced: string;
|
|
452
456
|
subagentRunning: (elapsed: string) => string;
|
|
453
457
|
running: (elapsed: string) => string;
|
|
454
458
|
moreLines: (ellipsis: string, n: number) => string;
|
|
@@ -483,6 +487,8 @@ export declare const zh: {
|
|
|
483
487
|
trustNever: string;
|
|
484
488
|
moreResources: (n: number) => string;
|
|
485
489
|
trustTitle: string;
|
|
490
|
+
extensionsTitle: string;
|
|
491
|
+
extensionDirectory: string;
|
|
486
492
|
resumeTitle: string;
|
|
487
493
|
modelTitle: string;
|
|
488
494
|
cwdTitle: string;
|
|
@@ -79,6 +79,7 @@ export declare const en: {
|
|
|
79
79
|
more: (count: number) => string;
|
|
80
80
|
trustQuestion: (cwd: string) => string;
|
|
81
81
|
trustChoices: string;
|
|
82
|
+
extensionsQuestion: string;
|
|
82
83
|
resumeQuestion: string;
|
|
83
84
|
resumeAnswer: string;
|
|
84
85
|
pickModel: string;
|
|
@@ -211,6 +212,7 @@ export declare const en: {
|
|
|
211
212
|
keySource: (source: string, origin: string | undefined) => string;
|
|
212
213
|
hookCommand: (command: string, ms: number) => string;
|
|
213
214
|
codemode: (mode: string, reason: string) => string;
|
|
215
|
+
codemodeEngine: (engine: string, reason: string) => string;
|
|
214
216
|
warning: (text: string) => string;
|
|
215
217
|
trustTitle: string;
|
|
216
218
|
fromCli: string;
|
|
@@ -218,6 +220,11 @@ export declare const en: {
|
|
|
218
220
|
trustInvalid: string;
|
|
219
221
|
trust: (cwd: string, trusted: boolean, from: string) => string;
|
|
220
222
|
gated: (trusted: boolean) => string;
|
|
223
|
+
extensionsTitle: string;
|
|
224
|
+
extensionsNote: string;
|
|
225
|
+
extensionsNone: string;
|
|
226
|
+
extensionLine: (enabled: boolean, path: string, sha: string, reason: string | undefined, directory: boolean) => string;
|
|
227
|
+
extensionSha: (sha256: string | undefined) => string;
|
|
221
228
|
keysTitle: string;
|
|
222
229
|
authMode: (mode: string, path: string) => string;
|
|
223
230
|
none: string;
|
|
@@ -325,6 +332,7 @@ export declare const zh: {
|
|
|
325
332
|
more: (count: number) => string;
|
|
326
333
|
trustQuestion: (cwd: string) => string;
|
|
327
334
|
trustChoices: string;
|
|
335
|
+
extensionsQuestion: string;
|
|
328
336
|
resumeQuestion: string;
|
|
329
337
|
resumeAnswer: string;
|
|
330
338
|
pickModel: string;
|
|
@@ -452,6 +460,7 @@ export declare const zh: {
|
|
|
452
460
|
keySource: (source: string, origin: string | undefined) => string;
|
|
453
461
|
hookCommand: (command: string, ms: number) => string;
|
|
454
462
|
codemode: (mode: string, reason: string) => string;
|
|
463
|
+
codemodeEngine: (engine: string, reason: string) => string;
|
|
455
464
|
warning: (text: string) => string;
|
|
456
465
|
trustTitle: string;
|
|
457
466
|
fromCli: string;
|
|
@@ -459,6 +468,11 @@ export declare const zh: {
|
|
|
459
468
|
trustInvalid: string;
|
|
460
469
|
trust: (cwd: string, trusted: boolean, from: string) => string;
|
|
461
470
|
gated: (trusted: boolean) => string;
|
|
471
|
+
extensionsTitle: string;
|
|
472
|
+
extensionsNote: string;
|
|
473
|
+
extensionsNone: string;
|
|
474
|
+
extensionLine: (enabled: boolean, path: string, sha: string, reason: string | undefined, directory: boolean) => string;
|
|
475
|
+
extensionSha: (sha256: string | undefined) => string;
|
|
462
476
|
keysTitle: string;
|
|
463
477
|
authMode: (mode: string, path: string) => string;
|
|
464
478
|
none: string;
|
|
@@ -80,6 +80,7 @@ export const en = {
|
|
|
80
80
|
more: (count) => ` …${count} more`,
|
|
81
81
|
trustQuestion: (cwd) => `Trust this directory's project resources? ${cwd}`,
|
|
82
82
|
trustChoices: "[y this time / a trust and remember / N don't trust] ",
|
|
83
|
+
extensionsQuestion: "Enable these local extensions? They run code with your permissions",
|
|
83
84
|
resumeQuestion: "Resume which session?",
|
|
84
85
|
resumeAnswer: "Number or id: ",
|
|
85
86
|
pickModel: "Choose a model:",
|
|
@@ -212,6 +213,7 @@ export const en = {
|
|
|
212
213
|
keySource: (source, origin) => `${source}${origin !== undefined ? ` (${origin})` : ""}`,
|
|
213
214
|
hookCommand: (command, ms) => `${command} (${ms} ms)`,
|
|
214
215
|
codemode: (mode, reason) => `codemode: ${mode} (${reason})`,
|
|
216
|
+
codemodeEngine: (engine, reason) => `codemode engine: ${engine} (${reason})`,
|
|
215
217
|
warning: (text) => `warning: ${text}`,
|
|
216
218
|
trustTitle: "Trust",
|
|
217
219
|
fromCli: "command line",
|
|
@@ -219,6 +221,11 @@ export const en = {
|
|
|
219
221
|
trustInvalid: "trust.json is invalid",
|
|
220
222
|
trust: (cwd, trusted, from) => `${cwd}: ${trusted ? "trusted" : "not trusted"} (${from})`,
|
|
221
223
|
gated: (trusted) => `Resources that need trust${trusted ? "" : " (not loaded now)"}:`,
|
|
224
|
+
extensionsTitle: "Local extensions",
|
|
225
|
+
extensionsNote: "Listed from files and trust records only; doctor never runs extension code, so load failures show at startup",
|
|
226
|
+
extensionsNone: "none (user-level extensions/ and profile extensions are empty)",
|
|
227
|
+
extensionLine: (enabled, path, sha, reason, directory) => `${enabled ? "enabled" : "skipped"} ${directory ? "[directory] " : ""}${path} sha256 ${sha}${reason === undefined ? "" : ` (${reason})`}`,
|
|
228
|
+
extensionSha: (sha256) => sha256?.slice(0, 12) ?? "-",
|
|
222
229
|
keysTitle: "Key sources (sources only, never values)",
|
|
223
230
|
authMode: (mode, path) => `auth.json mode ${mode}, should be 600: ${path}`,
|
|
224
231
|
none: "none",
|
|
@@ -332,6 +339,7 @@ export const zh = {
|
|
|
332
339
|
more: (count) => ` …另有 ${count} 项`,
|
|
333
340
|
trustQuestion: (cwd) => `信任这个目录的项目资源?${cwd}`,
|
|
334
341
|
trustChoices: "[y 仅本次 / a 信任并记住 / N 不信任] ",
|
|
342
|
+
extensionsQuestion: "启用这些本地扩展?它们以你的权限运行代码",
|
|
335
343
|
resumeQuestion: "恢复哪个会话?",
|
|
336
344
|
resumeAnswer: "编号或 id:",
|
|
337
345
|
pickModel: "选择模型:",
|
|
@@ -456,6 +464,7 @@ export const zh = {
|
|
|
456
464
|
keySource: (source, origin) => `${source}${origin !== undefined ? `(${origin})` : ""}`,
|
|
457
465
|
hookCommand: (command, ms) => `${command}(${ms} ms)`,
|
|
458
466
|
codemode: (mode, reason) => `codemode:${mode}(${reason})`,
|
|
467
|
+
codemodeEngine: (engine, reason) => `codemode 引擎:${engine}(${reason})`,
|
|
459
468
|
warning: (text) => `警告:${text}`,
|
|
460
469
|
trustTitle: "信任",
|
|
461
470
|
fromCli: "命令行",
|
|
@@ -463,6 +472,11 @@ export const zh = {
|
|
|
463
472
|
trustInvalid: "trust.json 无效",
|
|
464
473
|
trust: (cwd, trusted, from) => `${cwd}:${trusted ? "已信任" : "未信任"}(${from})`,
|
|
465
474
|
gated: (trusted) => `需要信任的资源${trusted ? "" : "(当前不加载)"}:`,
|
|
475
|
+
extensionsTitle: "本地扩展",
|
|
476
|
+
extensionsNote: "只按文件与信任记录列出;doctor 不执行扩展代码,加载失败在启动时才会出现",
|
|
477
|
+
extensionsNone: "无(用户级 extensions/ 与 profile 的 extensions 都为空)",
|
|
478
|
+
extensionLine: (enabled, path, sha, reason, directory) => `${enabled ? "启用" : "跳过"} ${directory ? "[目录] " : ""}${path} sha256 ${sha}${reason === undefined ? "" : ` (${reason})`}`,
|
|
479
|
+
extensionSha: (sha256) => sha256?.slice(0, 12) ?? "-",
|
|
466
480
|
keysTitle: "Key 来源(只显示来源,不显示值)",
|
|
467
481
|
authMode: (mode, path) => `auth.json 权限 ${mode},应为 600:${path}`,
|
|
468
482
|
none: "无",
|
|
@@ -25,6 +25,10 @@ export declare const en: {
|
|
|
25
25
|
sandboxIsolated: (node: number) => string;
|
|
26
26
|
sandboxOs: (node: number, kind: string) => string;
|
|
27
27
|
sandboxNone: (node: number) => string;
|
|
28
|
+
sandboxQuickjs: (node: number) => string;
|
|
29
|
+
engineExplicit: (engine: string) => string;
|
|
30
|
+
engineAutoNode: (sandbox: string) => string;
|
|
31
|
+
engineAutoQuickjs: (node: number) => string;
|
|
28
32
|
codemodeExplicit: (sandbox: string) => string;
|
|
29
33
|
codemodeFollowsPreset: (preset: string, sandbox: string) => string;
|
|
30
34
|
presetAlias: (layer: string, label: string, preset: string, canonical: string) => string;
|
|
@@ -80,6 +84,10 @@ export declare const zh: {
|
|
|
80
84
|
sandboxIsolated: (node: number) => string;
|
|
81
85
|
sandboxOs: (node: number, kind: string) => string;
|
|
82
86
|
sandboxNone: (node: number) => string;
|
|
87
|
+
sandboxQuickjs: (node: number) => string;
|
|
88
|
+
engineExplicit: (engine: string) => string;
|
|
89
|
+
engineAutoNode: (sandbox: string) => string;
|
|
90
|
+
engineAutoQuickjs: (node: number) => string;
|
|
83
91
|
codemodeExplicit: (sandbox: string) => string;
|
|
84
92
|
codemodeFollowsPreset: (preset: string, sandbox: string) => string;
|
|
85
93
|
presetAlias: (layer: string, label: string, preset: string, canonical: string) => string;
|
|
@@ -30,6 +30,10 @@ export const en = {
|
|
|
30
30
|
sandboxIsolated: (node) => `Node ${node} isolates the network`,
|
|
31
31
|
sandboxOs: (node, kind) => `Node ${node}, network isolated by the OS sandbox ${kind}`,
|
|
32
32
|
sandboxNone: (node) => `Node ${node} < 25, network not isolated`,
|
|
33
|
+
sandboxQuickjs: (node) => `Node ${node}, scripts run in QuickJS (WebAssembly)`,
|
|
34
|
+
engineExplicit: (engine) => `codemode.engine is set to ${engine}`,
|
|
35
|
+
engineAutoNode: (sandbox) => `auto: ${sandbox}, so the Node child process`,
|
|
36
|
+
engineAutoQuickjs: (node) => `auto: Node ${node} cannot isolate the network and no OS sandbox is available, so QuickJS in WebAssembly`,
|
|
33
37
|
codemodeExplicit: (sandbox) => `codemode.mode set explicitly (${sandbox})`,
|
|
34
38
|
codemodeFollowsPreset: (preset, sandbox) => `follows preset ${preset} (${sandbox})`,
|
|
35
39
|
presetAlias: (layer, label, preset, canonical) => `${layer} (${label}) writes tools.preset with the old name ${preset}; the canonical name is ${canonical}`,
|
|
@@ -93,6 +97,10 @@ export const zh = {
|
|
|
93
97
|
sandboxIsolated: (node) => `Node ${node} 网络已隔离`,
|
|
94
98
|
sandboxOs: (node, kind) => `Node ${node} 网络由操作系统沙箱 ${kind} 隔离`,
|
|
95
99
|
sandboxNone: (node) => `Node ${node} < 25 网络未隔离`,
|
|
100
|
+
sandboxQuickjs: (node) => `Node ${node},脚本在 QuickJS(WebAssembly)里运行`,
|
|
101
|
+
engineExplicit: (engine) => `codemode.engine 显式设为 ${engine}`,
|
|
102
|
+
engineAutoNode: (sandbox) => `auto:${sandbox},用 Node 子进程`,
|
|
103
|
+
engineAutoQuickjs: (node) => `auto:Node ${node} 无法隔离网络且没有可用的操作系统沙箱,用 WebAssembly 里的 QuickJS`,
|
|
96
104
|
codemodeExplicit: (sandbox) => `codemode.mode 显式设置(${sandbox})`,
|
|
97
105
|
codemodeFollowsPreset: (preset, sandbox) => `跟随预设 ${preset}(${sandbox})`,
|
|
98
106
|
presetAlias: (layer, label, preset, canonical) => `${layer}(${label})的 tools.preset 写的是旧名 ${preset},规范名 ${canonical}`,
|
|
@@ -257,6 +257,10 @@ export declare const en: {
|
|
|
257
257
|
sandboxIsolated: (node: number) => string;
|
|
258
258
|
sandboxOs: (node: number, kind: string) => string;
|
|
259
259
|
sandboxNone: (node: number) => string;
|
|
260
|
+
sandboxQuickjs: (node: number) => string;
|
|
261
|
+
engineExplicit: (engine: string) => string;
|
|
262
|
+
engineAutoNode: (sandbox: string) => string;
|
|
263
|
+
engineAutoQuickjs: (node: number) => string;
|
|
260
264
|
codemodeExplicit: (sandbox: string) => string;
|
|
261
265
|
codemodeFollowsPreset: (preset: string, sandbox: string) => string;
|
|
262
266
|
presetAlias: (layer: string, label: string, preset: string, canonical: string) => string;
|
|
@@ -543,6 +547,10 @@ export declare const zh: {
|
|
|
543
547
|
sandboxIsolated: (node: number) => string;
|
|
544
548
|
sandboxOs: (node: number, kind: string) => string;
|
|
545
549
|
sandboxNone: (node: number) => string;
|
|
550
|
+
sandboxQuickjs: (node: number) => string;
|
|
551
|
+
engineExplicit: (engine: string) => string;
|
|
552
|
+
engineAutoNode: (sandbox: string) => string;
|
|
553
|
+
engineAutoQuickjs: (node: number) => string;
|
|
546
554
|
codemodeExplicit: (sandbox: string) => string;
|
|
547
555
|
codemodeFollowsPreset: (preset: string, sandbox: string) => string;
|
|
548
556
|
presetAlias: (layer: string, label: string, preset: string, canonical: string) => string;
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
* 之后 `buildConfigOptions` 同步取(映射器的 `extras()` 是同步的)。没准备过时只列本地供应商与当前模型。
|
|
13
13
|
* - `applyConfigOption`:`session/set_config_option` → `setModel()` / `setThinkingLevel()`;未知 id、
|
|
14
14
|
* 非字符串值、找不到的模型、不认识的级别回 invalid params。
|
|
15
|
-
* - `availableCommands`:skills → `skill:<name>`,提示模板 → `<name>`(`argumentHint` → `input.hint
|
|
15
|
+
* - `availableCommands`:skills → `skill:<name>`,提示模板 → `<name>`(`argumentHint` → `input.hint`);
|
|
16
|
+
* [#303] 宿主 / 扩展命令 → `<name>`(`args` → `input.hint`),遮住同名提示模板(与其它模式一致)。
|
|
16
17
|
* 内置斜杠命令(`/new`、`/compact`…)在 ACP 下不执行,不列。
|
|
17
18
|
*/
|
|
18
19
|
import type { AgentSession } from "../../agent/types.js";
|
|
19
20
|
import type { ProviderRegistryApi } from "../../ai/types.js";
|
|
20
21
|
import type { LoadedResources } from "../../cli/runtime.js";
|
|
22
|
+
import type { HostCommandSource } from "../../host/commands.js";
|
|
21
23
|
import { type AcpAvailableCommand, type AcpSessionConfigOption, type AcpSetConfigOptionParams } from "../../drivers/acp/types.js";
|
|
22
24
|
import type { PermissionMode } from "../../permissions/types.js";
|
|
23
25
|
/** 配置项 id(机器字段,不翻译)。 */
|
|
@@ -40,4 +42,4 @@ export interface ConfigOptionsExtras {
|
|
|
40
42
|
export declare function buildConfigOptions(session: AgentSession, providers: ProviderRegistryApi, env: NodeJS.ProcessEnv, extras?: ConfigOptionsExtras): AcpSessionConfigOption[];
|
|
41
43
|
/** 未知 id / value → RpcError invalidParams。 */
|
|
42
44
|
export declare function applyConfigOption(session: AgentSession, params: AcpSetConfigOptionParams): Promise<void>;
|
|
43
|
-
export declare function availableCommands(resources: LoadedResources): AcpAvailableCommand[];
|
|
45
|
+
export declare function availableCommands(resources: LoadedResources, hostCommands?: HostCommandSource): AcpAvailableCommand[];
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* 之后 `buildConfigOptions` 同步取(映射器的 `extras()` 是同步的)。没准备过时只列本地供应商与当前模型。
|
|
13
13
|
* - `applyConfigOption`:`session/set_config_option` → `setModel()` / `setThinkingLevel()`;未知 id、
|
|
14
14
|
* 非字符串值、找不到的模型、不认识的级别回 invalid params。
|
|
15
|
-
* - `availableCommands`:skills → `skill:<name>`,提示模板 → `<name>`(`argumentHint` → `input.hint
|
|
15
|
+
* - `availableCommands`:skills → `skill:<name>`,提示模板 → `<name>`(`argumentHint` → `input.hint`);
|
|
16
|
+
* [#303] 宿主 / 扩展命令 → `<name>`(`args` → `input.hint`),遮住同名提示模板(与其它模式一致)。
|
|
16
17
|
* 内置斜杠命令(`/new`、`/compact`…)在 ACP 下不执行,不列。
|
|
17
18
|
*/
|
|
18
19
|
import { formatModelRef } from "../../ai/providers/channels.js";
|
|
@@ -136,16 +137,29 @@ export async function applyConfigOption(session, params) {
|
|
|
136
137
|
throw new RpcError(RPC_ERRORS.invalidParams, msg().acp.core.unknownConfigOption(String(params.configId)));
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
export function availableCommands(resources) {
|
|
140
|
+
export function availableCommands(resources, hostCommands) {
|
|
141
|
+
const hosted = hostCommands?.list() ?? [];
|
|
142
|
+
const shadowed = new Set(hosted.map((c) => c.name));
|
|
140
143
|
const commands = resources.skills.map((skill) => ({
|
|
141
144
|
name: `skill:${skill.name}`,
|
|
142
145
|
description: skill.description,
|
|
143
146
|
}));
|
|
144
|
-
for (const prompt of resources.prompts)
|
|
147
|
+
for (const prompt of resources.prompts) {
|
|
148
|
+
if (shadowed.has(prompt.name))
|
|
149
|
+
continue;
|
|
145
150
|
commands.push({
|
|
146
151
|
name: prompt.name,
|
|
147
152
|
description: prompt.description ?? "",
|
|
148
153
|
...(prompt.argumentHint !== undefined ? { input: { hint: prompt.argumentHint } } : {}),
|
|
149
154
|
});
|
|
155
|
+
}
|
|
156
|
+
for (const command of hosted)
|
|
157
|
+
commands.push({
|
|
158
|
+
name: command.name,
|
|
159
|
+
description: command.description,
|
|
160
|
+
...(command.args !== undefined && command.args !== ""
|
|
161
|
+
? { input: { hint: command.args } }
|
|
162
|
+
: {}),
|
|
163
|
+
});
|
|
150
164
|
return commands;
|
|
151
165
|
}
|
|
@@ -75,6 +75,8 @@ export declare class AcpEventMapper {
|
|
|
75
75
|
* 与 `usage_update`(客户端可能刚重建线程,用量不去重,照发一次)。
|
|
76
76
|
*/
|
|
77
77
|
announce(): void;
|
|
78
|
+
/** [#303] 扩展命令 handled 的输出:一条 `agent_message_chunk`(不开模型回合)。 */
|
|
79
|
+
emitMessage(text: string): void;
|
|
78
80
|
/** 回合结束后由服务端调:`session_info_update`(标题与上次不同才带 title)。 */
|
|
79
81
|
emitSessionInfo(title: string | null, updatedAt: string): void;
|
|
80
82
|
/** 权限请求对应的工具调用 id(按工具名与参数匹配最近一个;有 `context.toolCallId` 时不需要)。 */
|
|
@@ -81,6 +81,10 @@ export class AcpEventMapper {
|
|
|
81
81
|
this.emit({ sessionUpdate: "config_option_update", configOptions });
|
|
82
82
|
this.emitUsage(true);
|
|
83
83
|
}
|
|
84
|
+
/** [#303] 扩展命令 handled 的输出:一条 `agent_message_chunk`(不开模型回合)。 */
|
|
85
|
+
emitMessage(text) {
|
|
86
|
+
this.emit({ sessionUpdate: "agent_message_chunk", content: { type: "text", text } });
|
|
87
|
+
}
|
|
84
88
|
/** 回合结束后由服务端调:`session_info_update`(标题与上次不同才带 title)。 */
|
|
85
89
|
emitSessionInfo(title, updatedAt) {
|
|
86
90
|
const changed = title !== this.lastTitle;
|
|
@@ -32,7 +32,7 @@ import { AcpEventMapper, permissionModes, toolKind, toolLocations, toolTitle, }
|
|
|
32
32
|
import { msg } from "../../i18n/index.js";
|
|
33
33
|
import { CONFIG_IDS, applyConfigOption, availableCommands, buildConfigOptions, prepareConfigOptions, } from "./acp-config.js";
|
|
34
34
|
import { clientCapabilitiesOf } from "./acp-connection.js";
|
|
35
|
-
import { PromptQueue, cancelledResult, disposeQuiet, pageSessions, promptWhenIdle, quiesce, sessionTitle, } from "./acp-sessions.js";
|
|
35
|
+
import { PromptQueue, ZERO_USAGE, dispatchHostSlash, cancelledResult, disposeQuiet, pageSessions, promptWhenIdle, quiesce, sessionTitle, } from "./acp-sessions.js";
|
|
36
36
|
export const ACP_AGENT_CAPABILITIES = {
|
|
37
37
|
loadSession: true,
|
|
38
38
|
promptCapabilities: { image: true, audio: false, embeddedContext: true },
|
|
@@ -123,7 +123,7 @@ export class AcpServer {
|
|
|
123
123
|
extras(session) {
|
|
124
124
|
return {
|
|
125
125
|
configOptions: this.configOptions(session),
|
|
126
|
-
commands: availableCommands(this.runtime.resources),
|
|
126
|
+
commands: availableCommands(this.runtime.resources, this.runtime.hostCommands),
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
configOptions(session) {
|
|
@@ -381,6 +381,10 @@ export class AcpServer {
|
|
|
381
381
|
let before = session.getStats().tokens;
|
|
382
382
|
let failure;
|
|
383
383
|
try {
|
|
384
|
+
if (await dispatchHostSlash(job, this.runtime, session, entry.mapper)) {
|
|
385
|
+
await this.peer.flush();
|
|
386
|
+
return { stopReason: "end_turn", usage: { ...ZERO_USAGE } };
|
|
387
|
+
}
|
|
384
388
|
// [#166] 起点取在真正发起时:等待期间结束的通知回合不计入本次 usage
|
|
385
389
|
await promptWhenIdle(session, job, () => void (before = session.getStats().tokens));
|
|
386
390
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ImageBlock } from "../../ai/types.js";
|
|
10
10
|
import type { AgentSessionImpl } from "../../agent/session.js";
|
|
11
|
+
import type { AgentSession } from "../../agent/types.js";
|
|
11
12
|
import type { TaskControl } from "../../agents/task-control.js";
|
|
12
13
|
import type { Runtime } from "../../cli/runtime.js";
|
|
13
14
|
import type { AgentMessage, SessionListItem } from "../../session/types.js";
|
|
@@ -30,7 +31,8 @@ export interface PooledSession {
|
|
|
30
31
|
/** 排队或在跑的一次 `session/prompt`。 */
|
|
31
32
|
export interface PromptJob {
|
|
32
33
|
readonly sessionId: string;
|
|
33
|
-
|
|
34
|
+
/** [#303] 扩展命令的 `prompt` 结果会改写它。 */
|
|
35
|
+
text: string;
|
|
34
36
|
readonly images: ImageBlock[];
|
|
35
37
|
/** `session/cancel` / `session/close` / `$/cancel_request` 要求中断。 */
|
|
36
38
|
cancelRequested: boolean;
|
|
@@ -100,3 +102,8 @@ export declare function quiesce(session: AgentSessionImpl, control: TaskControl
|
|
|
100
102
|
* dispose 之后若还有周期(与 dispose 同一时刻开出来的)再 abort 一次。
|
|
101
103
|
*/
|
|
102
104
|
export declare function disposeQuiet(runtime: Runtime, session: AgentSessionImpl, fallback: AgentSessionImpl, control?: TaskControl, retries?: number): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* [#303] `/<名> 参数` 命中宿主 / 扩展注册的命令:`handled` 发出 `message`(`agent_message_chunk`)并返回 true,
|
|
107
|
+
* 调用方不开模型回合;`prompt` 改写 `job.text` 并返回 false;没有同名命令返回 false。命令抛错原样上抛。
|
|
108
|
+
*/
|
|
109
|
+
export declare function dispatchHostSlash(job: PromptJob, runtime: Pick<Runtime, "hostCommands" | "mode">, session: Pick<AgentSession, "state">, mapper: Pick<AcpEventMapper, "emitMessage">): Promise<boolean>;
|
|
@@ -11,6 +11,7 @@ import { RPC_ERRORS, } from "../../drivers/acp/types.js";
|
|
|
11
11
|
import { RpcError } from "../../drivers/jsonrpc.js";
|
|
12
12
|
import { AmaError } from "../../errors.js";
|
|
13
13
|
import { msg } from "../../i18n/index.js";
|
|
14
|
+
import { parseSlash, runHostSlash } from "../commands-core.js";
|
|
14
15
|
/** `session/list` 每页条数。 */
|
|
15
16
|
export const LIST_PAGE_SIZE = 50;
|
|
16
17
|
/** 列表与 `session_info_update` 的标题上限(字符)。 */
|
|
@@ -223,3 +224,20 @@ export async function disposeQuiet(runtime, session, fallback, control, retries
|
|
|
223
224
|
}
|
|
224
225
|
await session.abort();
|
|
225
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* [#303] `/<名> 参数` 命中宿主 / 扩展注册的命令:`handled` 发出 `message`(`agent_message_chunk`)并返回 true,
|
|
229
|
+
* 调用方不开模型回合;`prompt` 改写 `job.text` 并返回 false;没有同名命令返回 false。命令抛错原样上抛。
|
|
230
|
+
*/
|
|
231
|
+
export async function dispatchHostSlash(job, runtime, session, mapper) {
|
|
232
|
+
const slash = parseSlash(job.text);
|
|
233
|
+
if (slash === undefined)
|
|
234
|
+
return false;
|
|
235
|
+
const hosted = await runHostSlash(slash.name, slash.args, runtime, session);
|
|
236
|
+
if (hosted?.kind === "prompt")
|
|
237
|
+
job.text = hosted.text;
|
|
238
|
+
if (hosted?.kind !== "handled")
|
|
239
|
+
return false;
|
|
240
|
+
if (hosted.message !== undefined && hosted.message !== "")
|
|
241
|
+
mapper.emitMessage(hosted.message);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
@@ -58,6 +58,8 @@ export interface CommandInfo {
|
|
|
58
58
|
name: string;
|
|
59
59
|
args?: string;
|
|
60
60
|
description: string;
|
|
61
|
+
/** [#301] 经 `commands.register` 注册的命令(宿主适配器 / 本地扩展);缺省为内置。 */
|
|
62
|
+
source?: "extension";
|
|
61
63
|
/** 只在该能力可用时列出(`/help`、补全、RPC `get_commands`);输入时照常分派。 */
|
|
62
64
|
requires?: "memory" | "task";
|
|
63
65
|
}
|
|
@@ -66,9 +68,20 @@ export declare const BUILTIN_COMMANDS: readonly CommandInfo[];
|
|
|
66
68
|
* 能力关闭的命令不列出(capability-off.test.ts 锁定):memory = 记忆工具已注册(`memory.enabled`);
|
|
67
69
|
* task = 模型能直接调 `task`,或能经 codemode 脚本调(`task` 已注册且 codemode 在活动集)。
|
|
68
70
|
*/
|
|
69
|
-
export declare function availableCommands(runtime: Pick<Runtime, "tools">, session: Pick<AgentSession, "getTools">, list?: readonly CommandInfo[]): CommandInfo[];
|
|
71
|
+
export declare function availableCommands(runtime: Pick<Runtime, "tools" | "hostCommands">, session: Pick<AgentSession, "getTools">, list?: readonly CommandInfo[]): CommandInfo[];
|
|
72
|
+
/** 交互界面自己处理的命令(interactive/commands.ts 的 INTERACTIVE_COMMANDS;测试锁定一致)。 */
|
|
73
|
+
export declare const INTERACTIVE_COMMAND_NAMES: readonly string[];
|
|
74
|
+
/** [#301] 保留的命令名:内置命令、别名与交互界面命令;`commands.register` 不得占用。 */
|
|
75
|
+
export declare function isReservedCommandName(name: string): boolean;
|
|
70
76
|
export declare function parseSlash(line: string): {
|
|
71
77
|
name: string;
|
|
72
78
|
args: string;
|
|
73
79
|
} | undefined;
|
|
74
80
|
export declare function runSlashCommand(line: string, ctx: CommandContext): Promise<CommandResult | undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* [#301] 只查宿主 / 扩展注册的命令(RPC 的 `prompt` 没有内置命令分派,只认它);`name` 已按 `parseSlash`
|
|
83
|
+
* 规整。没有同名命令返回 undefined。
|
|
84
|
+
*/
|
|
85
|
+
export declare function runHostSlash(name: string, args: string, runtime: Pick<Runtime, "hostCommands" | "mode">, session: Pick<AgentSession, "state">): Promise<Extract<CommandResult, {
|
|
86
|
+
kind: "handled" | "prompt";
|
|
87
|
+
}> | undefined>;
|
|
@@ -17,6 +17,7 @@ import { AgentSessionImpl } from "../agent/session.js";
|
|
|
17
17
|
import { WARMING_MODES } from "../ai/cache/types.js";
|
|
18
18
|
import { THINKING_LEVELS } from "../ai/thinking.js";
|
|
19
19
|
import { AmaError } from "../errors.js";
|
|
20
|
+
import { runHostCommand } from "../host/commands.js";
|
|
20
21
|
import { PERMISSION_MODE_ORDER, parsePermissionMode, permissionModeLabel, } from "../permissions/modes.js";
|
|
21
22
|
import { pasteImage } from "./interactive/clipboard-paste.js";
|
|
22
23
|
import { planCommand } from "./interactive/plan-command.js";
|
|
@@ -92,9 +93,23 @@ export function availableCommands(runtime, session, list = BUILTIN_COMMANDS) {
|
|
|
92
93
|
: requires === "task"
|
|
93
94
|
? active.has("task") || (active.has("codemode") && registered.has("task"))
|
|
94
95
|
: true;
|
|
95
|
-
|
|
96
|
+
const extension = (runtime.hostCommands?.list() ?? []).map((c) => ({
|
|
97
|
+
name: c.name,
|
|
98
|
+
description: c.description,
|
|
99
|
+
...(c.args !== undefined ? { args: c.args } : {}),
|
|
100
|
+
source: "extension",
|
|
101
|
+
}));
|
|
102
|
+
return [...list.filter((c) => has(c.requires)), ...extension];
|
|
96
103
|
}
|
|
97
104
|
const ALIASES = { quit: "exit", q: "exit", "?": "help" };
|
|
105
|
+
/** 交互界面自己处理的命令(interactive/commands.ts 的 INTERACTIVE_COMMANDS;测试锁定一致)。 */
|
|
106
|
+
export const INTERACTIVE_COMMAND_NAMES = ["tree", "permissions"];
|
|
107
|
+
/** [#301] 保留的命令名:内置命令、别名与交互界面命令;`commands.register` 不得占用。 */
|
|
108
|
+
export function isReservedCommandName(name) {
|
|
109
|
+
return (BUILTIN_COMMANDS.some((c) => c.name === name) ||
|
|
110
|
+
Object.hasOwn(ALIASES, name) ||
|
|
111
|
+
INTERACTIVE_COMMAND_NAMES.includes(name));
|
|
112
|
+
}
|
|
98
113
|
export function parseSlash(line) {
|
|
99
114
|
const m = /^\/([A-Za-z?][\w-]*)(?:\s+([\s\S]*))?$/.exec(line.trim());
|
|
100
115
|
if (m === null)
|
|
@@ -299,6 +314,23 @@ export async function runSlashCommand(line, ctx) {
|
|
|
299
314
|
case "memory":
|
|
300
315
|
return { kind: "handled", message: msg().interactive.commands.unavailable(name) };
|
|
301
316
|
default:
|
|
302
|
-
return
|
|
317
|
+
return extensionCommand(name, args, ctx);
|
|
303
318
|
}
|
|
304
319
|
}
|
|
320
|
+
/** [#301] 内置命令之后、提示模板之前:宿主适配器 / 扩展注册的命令;没有同名的返回 undefined。 */
|
|
321
|
+
async function extensionCommand(name, args, ctx) {
|
|
322
|
+
return runHostSlash(name, args, ctx.runtime, ctx.session());
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* [#301] 只查宿主 / 扩展注册的命令(RPC 的 `prompt` 没有内置命令分派,只认它);`name` 已按 `parseSlash`
|
|
326
|
+
* 规整。没有同名命令返回 undefined。
|
|
327
|
+
*/
|
|
328
|
+
export async function runHostSlash(name, args, runtime, session) {
|
|
329
|
+
const command = runtime.hostCommands?.get(name);
|
|
330
|
+
if (command === undefined)
|
|
331
|
+
return undefined;
|
|
332
|
+
return runHostCommand(command, args, {
|
|
333
|
+
mode: runtime.mode,
|
|
334
|
+
session: { id: () => session.state.sessionId, cwd: () => session.state.cwd },
|
|
335
|
+
});
|
|
336
|
+
}
|
|
@@ -181,6 +181,27 @@ export function createStartupUi(options = {}) {
|
|
|
181
181
|
const choice = choices.find((c) => c.value === picked?.value);
|
|
182
182
|
return choice?.answer ?? { trusted: false, remember: false };
|
|
183
183
|
},
|
|
184
|
+
async promptExtensions(files) {
|
|
185
|
+
const m = msg().interactive.startup.ui;
|
|
186
|
+
const choices = trustChoices();
|
|
187
|
+
const shown = files
|
|
188
|
+
.slice(0, 4)
|
|
189
|
+
.flatMap((f) => [
|
|
190
|
+
f.directory === true ? `${f.path} ${m.extensionDirectory}` : f.path,
|
|
191
|
+
` sha256 ${f.sha256}`,
|
|
192
|
+
]);
|
|
193
|
+
if (files.length > 4)
|
|
194
|
+
shown.push(m.moreResources(files.length - 4));
|
|
195
|
+
const picked = await askSelect(r, {
|
|
196
|
+
title: m.extensionsTitle,
|
|
197
|
+
lines: shown,
|
|
198
|
+
items: choices.map(({ value, label }) => ({ value, label })),
|
|
199
|
+
selected: "skip",
|
|
200
|
+
numberKeys: true,
|
|
201
|
+
});
|
|
202
|
+
const choice = choices.find((c) => c.value === picked?.value);
|
|
203
|
+
return choice?.answer ?? { trusted: false, remember: false };
|
|
204
|
+
},
|
|
184
205
|
async pickSession(items) {
|
|
185
206
|
if (items.length === 0)
|
|
186
207
|
return undefined;
|
|
@@ -65,7 +65,7 @@ export class StatusArea {
|
|
|
65
65
|
const source = {
|
|
66
66
|
session: () => deps.session(),
|
|
67
67
|
preset: () => runtime.config.tools?.preset ?? "default",
|
|
68
|
-
hostStatus: () => runtime.host?.status(),
|
|
68
|
+
hostStatus: () => runtime.hostStatus?.() ?? runtime.host?.status(),
|
|
69
69
|
codemode: () => {
|
|
70
70
|
const mode = effectiveCodemodeMode(runtime.config);
|
|
71
71
|
const active = deps
|
|
@@ -46,8 +46,9 @@ export interface ToolViewOptions {
|
|
|
46
46
|
export declare class ToolView implements Component {
|
|
47
47
|
readonly toolCallId: string;
|
|
48
48
|
readonly toolName: string;
|
|
49
|
-
private readonly args;
|
|
50
49
|
private readonly options;
|
|
50
|
+
/** 宽松强转改过模型参数时,实际执行的参数:显示以它为准,标题行带一个淡色标记。 */
|
|
51
|
+
private readonly coerced?;
|
|
51
52
|
private state;
|
|
52
53
|
private partial;
|
|
53
54
|
private result;
|
|
@@ -56,6 +57,8 @@ export declare class ToolView implements Component {
|
|
|
56
57
|
private cache;
|
|
57
58
|
private version;
|
|
58
59
|
private startedAt;
|
|
60
|
+
/** 显示用的参数:强转过取强转后的。 */
|
|
61
|
+
private readonly args;
|
|
59
62
|
/** 审批对话框打开时还没开始执行(摘要行显示「等待确认」,关闭后重新计时)。 */
|
|
60
63
|
private awaiting;
|
|
61
64
|
private elapsedMs;
|
|
@@ -63,7 +66,9 @@ export declare class ToolView implements Component {
|
|
|
63
66
|
replayed: boolean;
|
|
64
67
|
/** 外层调用(嵌套时):子视图变化要让外层缓存失效。 */
|
|
65
68
|
private parent;
|
|
66
|
-
constructor(toolCallId: string, toolName: string,
|
|
69
|
+
constructor(toolCallId: string, toolName: string, modelArgs: unknown, options: ToolViewOptions,
|
|
70
|
+
/** 宽松强转改过模型参数时,实际执行的参数:显示以它为准,标题行带一个淡色标记。 */
|
|
71
|
+
coerced?: Record<string, unknown> | undefined);
|
|
67
72
|
private now;
|
|
68
73
|
get isRunning(): boolean;
|
|
69
74
|
get isExpanded(): boolean;
|
|
@@ -125,6 +130,7 @@ export declare class ToolTracker {
|
|
|
125
130
|
toolCallId: string;
|
|
126
131
|
toolName: string;
|
|
127
132
|
args: unknown;
|
|
133
|
+
coercedArguments?: Record<string, unknown>;
|
|
128
134
|
parentToolCallId?: string;
|
|
129
135
|
}): {
|
|
130
136
|
view: ToolView;
|
|
@@ -39,8 +39,8 @@ const DIFF_NUMBERS_MIN_WIDTH = 60;
|
|
|
39
39
|
export class ToolView {
|
|
40
40
|
toolCallId;
|
|
41
41
|
toolName;
|
|
42
|
-
args;
|
|
43
42
|
options;
|
|
43
|
+
coerced;
|
|
44
44
|
state = "running";
|
|
45
45
|
partial = "";
|
|
46
46
|
result;
|
|
@@ -49,6 +49,8 @@ export class ToolView {
|
|
|
49
49
|
cache = null;
|
|
50
50
|
version = 0;
|
|
51
51
|
startedAt;
|
|
52
|
+
/** 显示用的参数:强转过取强转后的。 */
|
|
53
|
+
args;
|
|
52
54
|
/** 审批对话框打开时还没开始执行(摘要行显示「等待确认」,关闭后重新计时)。 */
|
|
53
55
|
awaiting = false;
|
|
54
56
|
elapsedMs = 0;
|
|
@@ -56,11 +58,14 @@ export class ToolView {
|
|
|
56
58
|
replayed = false;
|
|
57
59
|
/** 外层调用(嵌套时):子视图变化要让外层缓存失效。 */
|
|
58
60
|
parent;
|
|
59
|
-
constructor(toolCallId, toolName,
|
|
61
|
+
constructor(toolCallId, toolName, modelArgs, options,
|
|
62
|
+
/** 宽松强转改过模型参数时,实际执行的参数:显示以它为准,标题行带一个淡色标记。 */
|
|
63
|
+
coerced) {
|
|
60
64
|
this.toolCallId = toolCallId;
|
|
61
65
|
this.toolName = toolName;
|
|
62
|
-
this.args = args;
|
|
63
66
|
this.options = options;
|
|
67
|
+
this.coerced = coerced;
|
|
68
|
+
this.args = coerced ?? modelArgs;
|
|
64
69
|
this.startedAt = this.now();
|
|
65
70
|
}
|
|
66
71
|
now() {
|
|
@@ -153,7 +158,9 @@ export class ToolView {
|
|
|
153
158
|
const dot = theme.fg(color, theme.glyphs.tool);
|
|
154
159
|
const summary = this.customCall(width) ?? toolSummary(this.toolName, this.args, this.options.cwd);
|
|
155
160
|
const title = `${dot} ${theme.bold(theme.fg("tool", this.toolName))}`;
|
|
156
|
-
|
|
161
|
+
const mark = this.coerced === undefined ? "" : ` ${theme.fg("dim", msg().interactive.view.tool.coerced)}`;
|
|
162
|
+
const line = summary === "" ? title : `${title} ${summary}`;
|
|
163
|
+
return truncateToWidth(`${line}${mark}`, width);
|
|
157
164
|
}
|
|
158
165
|
/** ` ⎿ 摘要`:运行中带 spinner 与秒数,完成后是结果摘要。 */
|
|
159
166
|
summaryLine(width) {
|
|
@@ -411,7 +418,7 @@ export class ToolTracker {
|
|
|
411
418
|
// 同一调用的重复 start 复用;已结束的同名 id(有的供应商跨回合复用 id)另起一个视图
|
|
412
419
|
if (existing !== undefined && existing.isRunning)
|
|
413
420
|
return { view: existing, topLevel: false };
|
|
414
|
-
const view = new ToolView(event.toolCallId, event.toolName, event.args, this.options);
|
|
421
|
+
const view = new ToolView(event.toolCallId, event.toolName, event.args, this.options, event.coercedArguments);
|
|
415
422
|
view.setExpanded(this.expanded);
|
|
416
423
|
this.views.set(event.toolCallId, view);
|
|
417
424
|
const parent = event.parentToolCallId !== undefined ? this.views.get(event.parentToolCallId) : undefined;
|