@armadra/agent 0.17.2 → 0.18.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CHANGELOG.zh-CN.md +36 -0
  3. package/THIRD_PARTY_NOTICES.md +6 -0
  4. package/assets/quickjs/LICENSE +57 -0
  5. package/assets/quickjs/README.md +14 -0
  6. package/assets/quickjs/quickjs.wasm +0 -0
  7. package/dist/agent/recovery-reminder.js +6 -1
  8. package/dist/agent/schema-coerce.d.ts +24 -0
  9. package/dist/agent/schema-coerce.js +157 -0
  10. package/dist/agent/schema.d.ts +1 -1
  11. package/dist/agent/schema.js +1 -1
  12. package/dist/agent/session-cache.js +12 -0
  13. package/dist/agent/tool-runner.js +57 -28
  14. package/dist/agent/types.d.ts +4 -0
  15. package/dist/ai/apis/anthropic-compat.d.ts +3 -1
  16. package/dist/ai/apis/anthropic-compat.js +8 -1
  17. package/dist/ai/apis/anthropic-messages.js +54 -2
  18. package/dist/ai/apis/anthropic-request.d.ts +3 -0
  19. package/dist/ai/apis/anthropic-request.js +7 -1
  20. package/dist/ai/apis/anthropic-threads.d.ts +64 -0
  21. package/dist/ai/apis/anthropic-threads.js +192 -0
  22. package/dist/ai/providers/catalog-data.js +5 -5
  23. package/dist/ai/providers/models-dev-data.js +22 -22
  24. package/dist/ai/types.d.ts +16 -0
  25. package/dist/bundle/ama-sandbox.cjs +96 -2
  26. package/dist/bundle/ama.cjs +2386 -890
  27. package/dist/cli/subcommands/config.d.ts +3 -0
  28. package/dist/cli/subcommands/config.js +22 -7
  29. package/dist/cli/subcommands/doctor.js +1 -0
  30. package/dist/cli/subcommands/models-discover.js +6 -2
  31. package/dist/codemode/capability.d.ts +14 -2
  32. package/dist/codemode/capability.js +19 -2
  33. package/dist/codemode/host-side.d.ts +14 -0
  34. package/dist/codemode/host-side.js +81 -10
  35. package/dist/codemode/inner-calls.d.ts +19 -0
  36. package/dist/codemode/inner-calls.js +24 -0
  37. package/dist/codemode/protocol.d.ts +14 -0
  38. package/dist/codemode/protocol.js +9 -1
  39. package/dist/codemode/quickjs/host.d.ts +15 -0
  40. package/dist/codemode/quickjs/host.js +243 -0
  41. package/dist/codemode/quickjs/wasm.d.ts +21 -0
  42. package/dist/codemode/quickjs/wasm.js +39 -0
  43. package/dist/codemode/quickjs/worker.d.ts +55 -0
  44. package/dist/codemode/quickjs/worker.js +457 -0
  45. package/dist/codemode/sandbox-entry.d.ts +4 -0
  46. package/dist/codemode/sandbox-entry.js +95 -3
  47. package/dist/codemode/script-images.d.ts +18 -0
  48. package/dist/codemode/script-images.js +38 -0
  49. package/dist/codemode/script-output.d.ts +19 -0
  50. package/dist/codemode/script-output.js +67 -0
  51. package/dist/codemode/search-tools.d.ts +27 -0
  52. package/dist/codemode/search-tools.js +83 -0
  53. package/dist/codemode/tool.d.ts +4 -0
  54. package/dist/codemode/tool.js +60 -9
  55. package/dist/codemode/worker-pool.d.ts +65 -0
  56. package/dist/codemode/worker-pool.js +131 -0
  57. package/dist/config/json-schema.js +3 -1
  58. package/dist/config/key-docs.js +7 -1
  59. package/dist/config/schema.js +4 -2
  60. package/dist/config/settings-registry.js +2 -0
  61. package/dist/config/types.d.ts +10 -0
  62. package/dist/config/types.js +1 -0
  63. package/dist/i18n/catalog.d.ts +8 -0
  64. package/dist/i18n/messages/config-keys.d.ts +4 -0
  65. package/dist/i18n/messages/config-keys.js +6 -2
  66. package/dist/i18n/messages/config.d.ts +4 -0
  67. package/dist/i18n/messages/interactive-view.d.ts +2 -0
  68. package/dist/i18n/messages/interactive-view.js +2 -0
  69. package/dist/i18n/messages/interactive.d.ts +2 -0
  70. package/dist/i18n/messages/report.d.ts +2 -0
  71. package/dist/i18n/messages/report.js +2 -0
  72. package/dist/i18n/messages/subcommands-config.d.ts +8 -0
  73. package/dist/i18n/messages/subcommands-config.js +8 -0
  74. package/dist/i18n/messages/subcommands.d.ts +8 -0
  75. package/dist/modes/interactive/tool-view.d.ts +8 -2
  76. package/dist/modes/interactive/tool-view.js +12 -5
  77. package/dist/session/unclean-end.d.ts +8 -0
  78. package/dist/session/unclean-end.js +39 -7
  79. package/docs/en/guides/providers.md +27 -7
  80. package/docs/en/guides/tui.md +1 -1
  81. package/docs/en/reference/rpc.md +3 -1
  82. package/docs/guides/codemode.md +52 -12
  83. package/docs/guides/providers.md +21 -1
  84. package/docs/guides/sandbox.md +2 -0
  85. package/docs/guides/tui.md +1 -1
  86. package/docs/reference/rpc.md +3 -1
  87. package/docs/reference/session-format.md +10 -9
  88. package/package.json +2 -1
@@ -39,6 +39,7 @@ export function canonicalPreset(name) {
39
39
  : name;
40
40
  }
41
41
  export const CODEMODE_MODES = ["off", "on", "only"];
42
+ export const CODEMODE_ENGINES = ["auto", "node", "quickjs"];
42
43
  export const CACHE_RETENTIONS = ["none", "short", "long"];
43
44
  export const DEFAULT_CACHE_CONFIG = Object.freeze({
44
45
  warming: "streaming",
@@ -427,6 +427,10 @@ declare const en: {
427
427
  sandboxIsolated: (node: number) => string;
428
428
  sandboxOs: (node: number, kind: string) => string;
429
429
  sandboxNone: (node: number) => string;
430
+ sandboxQuickjs: (node: number) => string;
431
+ engineExplicit: (engine: string) => string;
432
+ engineAutoNode: (sandbox: string) => string;
433
+ engineAutoQuickjs: (node: number) => string;
430
434
  codemodeExplicit: (sandbox: string) => string;
431
435
  codemodeFollowsPreset: (preset: string, sandbox: string) => string;
432
436
  presetAlias: (layer: string, label: string, preset: string, canonical: string) => string;
@@ -645,6 +649,7 @@ declare const en: {
645
649
  fetched: (title: string | undefined, size: string, format: string) => string;
646
650
  fetchRedirect: (url: string) => string;
647
651
  awaiting: (glyph: string) => string;
652
+ coerced: string;
648
653
  subagentRunning: (elapsed: string) => string;
649
654
  running: (elapsed: string) => string;
650
655
  moreLines: (ellipsis: string, n: number) => string;
@@ -1279,6 +1284,7 @@ declare const en: {
1279
1284
  keySource: (source: string, origin: string | undefined) => string;
1280
1285
  hookCommand: (command: string, ms: number) => string;
1281
1286
  codemode: (mode: string, reason: string) => string;
1287
+ codemodeEngine: (engine: string, reason: string) => string;
1282
1288
  warning: (text: string) => string;
1283
1289
  trustTitle: string;
1284
1290
  fromCli: string;
@@ -1392,7 +1398,9 @@ declare const en: {
1392
1398
  "codemode.mode": string;
1393
1399
  "codemode.inlineBudget": string;
1394
1400
  "codemode.requireStrict": string;
1401
+ "codemode.maxWorkers": string;
1395
1402
  "codemode.maxHeapMb": string;
1403
+ "codemode.engine": string;
1396
1404
  hooks: string;
1397
1405
  "hooks.timeoutMs": string;
1398
1406
  ui: string;
@@ -45,7 +45,9 @@ export declare const en: {
45
45
  "codemode.mode": string;
46
46
  "codemode.inlineBudget": string;
47
47
  "codemode.requireStrict": string;
48
+ "codemode.maxWorkers": string;
48
49
  "codemode.maxHeapMb": string;
50
+ "codemode.engine": string;
49
51
  hooks: string;
50
52
  "hooks.timeoutMs": string;
51
53
  ui: string;
@@ -204,7 +206,9 @@ export declare const zh: {
204
206
  "codemode.mode": string;
205
207
  "codemode.inlineBudget": string;
206
208
  "codemode.requireStrict": string;
209
+ "codemode.maxWorkers": string;
207
210
  "codemode.maxHeapMb": string;
211
+ "codemode.engine": string;
208
212
  hooks: string;
209
213
  "hooks.timeoutMs": string;
210
214
  ui: string;
@@ -96,7 +96,9 @@ const keysEn = {
96
96
  "codemode.mode": "off | on | only; when unset it follows the preset: default → on (Node ≥ 25; Node 22 / 24 → off), codemode-only → only, minimal / coordinator → off; project level only accepts off",
97
97
  "codemode.inlineBudget": "Budget (estimated tokens) for inlining tool declarations in the description in only mode; beyond it only names are listed",
98
98
  "codemode.requireStrict": "true: disable codemode when the runtime Node does not isolate the network (Node 22 / 24)",
99
- "codemode.maxHeapMb": "V8 heap limit (MB) for the script child process; a script that exceeds it ends with an error; 0 sets no limit",
99
+ "codemode.maxWorkers": "Most script child processes alive at once across all sessions in this process (default 2); the AMA_CODEMODE_MAX_WORKERS environment variable takes precedence",
100
+ "codemode.maxHeapMb": "Memory limit (MB) for the script engine (V8 heap of the node child process, QuickJS heap of the quickjs engine); a script that exceeds it ends with an error; 0 sets no limit",
101
+ "codemode.engine": "auto | node | quickjs; auto uses the Node child process when the network is isolated (Node ≥ 25 or an OS sandbox) and QuickJS in WebAssembly otherwise; quickjs makes codemode a read-class tool on every platform; user level only",
100
102
  hooks: "Hook settings (the hooks themselves live in hooks.json)",
101
103
  "hooks.timeoutMs": "Default timeout for a single hook command (ms)",
102
104
  ui: "Terminal interface",
@@ -228,7 +230,9 @@ const keysZh = {
228
230
  "codemode.mode": "off | on | only;不写时跟随预设:default → on(Node ≥ 25;Node 22 / 24 → off)、codemode-only → only、minimal / coordinator → off;项目级只接受 off",
229
231
  "codemode.inlineBudget": "only 模式在描述里内联工具声明的预算(估算 token),超出只列名字",
230
232
  "codemode.requireStrict": "true:运行时 Node 不隔离网络(Node 22 / 24)时直接禁用 codemode",
231
- "codemode.maxHeapMb": "脚本子进程的 V8 堆上限(MB),超出时脚本以错误结束;0 不设上限",
233
+ "codemode.maxWorkers": "本进程内所有会话同时存活的脚本子进程数上限(缺省 2);环境变量 AMA_CODEMODE_MAX_WORKERS 优先",
234
+ "codemode.maxHeapMb": "脚本引擎的内存上限(MB):node 引擎是子进程的 V8 堆,quickjs 引擎是 QuickJS 堆;超出时脚本以错误结束;0 不设上限",
235
+ "codemode.engine": "auto | node | quickjs;auto:网络已隔离(Node ≥ 25 或操作系统沙箱)时用 Node 子进程,否则用 WebAssembly 里的 QuickJS;quickjs 让 codemode 在所有平台都是 read 类;只认用户级",
232
236
  hooks: "Hook 设置(Hook 本身写在 hooks.json)",
233
237
  "hooks.timeoutMs": "单个 Hook 命令的缺省超时(毫秒)",
234
238
  ui: "终端界面",
@@ -45,7 +45,9 @@ export declare const en: {
45
45
  "codemode.mode": string;
46
46
  "codemode.inlineBudget": string;
47
47
  "codemode.requireStrict": string;
48
+ "codemode.maxWorkers": string;
48
49
  "codemode.maxHeapMb": string;
50
+ "codemode.engine": string;
49
51
  hooks: string;
50
52
  "hooks.timeoutMs": string;
51
53
  ui: string;
@@ -318,7 +320,9 @@ export declare const zh: {
318
320
  "codemode.mode": string;
319
321
  "codemode.inlineBudget": string;
320
322
  "codemode.requireStrict": string;
323
+ "codemode.maxWorkers": string;
321
324
  "codemode.maxHeapMb": string;
325
+ "codemode.engine": string;
322
326
  hooks: string;
323
327
  "hooks.timeoutMs": string;
324
328
  ui: string;
@@ -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;
@@ -449,6 +450,7 @@ export declare const zh: {
449
450
  fetched: (title: string | undefined, size: string, format: string) => string;
450
451
  fetchRedirect: (url: string) => string;
451
452
  awaiting: (glyph: string) => string;
453
+ coerced: string;
452
454
  subagentRunning: (elapsed: string) => string;
453
455
  running: (elapsed: string) => string;
454
456
  moreLines: (ellipsis: string, n: number) => string;
@@ -211,6 +211,7 @@ export declare const en: {
211
211
  keySource: (source: string, origin: string | undefined) => string;
212
212
  hookCommand: (command: string, ms: number) => string;
213
213
  codemode: (mode: string, reason: string) => string;
214
+ codemodeEngine: (engine: string, reason: string) => string;
214
215
  warning: (text: string) => string;
215
216
  trustTitle: string;
216
217
  fromCli: string;
@@ -452,6 +453,7 @@ export declare const zh: {
452
453
  keySource: (source: string, origin: string | undefined) => string;
453
454
  hookCommand: (command: string, ms: number) => string;
454
455
  codemode: (mode: string, reason: string) => string;
456
+ codemodeEngine: (engine: string, reason: string) => string;
455
457
  warning: (text: string) => string;
456
458
  trustTitle: string;
457
459
  fromCli: string;
@@ -212,6 +212,7 @@ export const en = {
212
212
  keySource: (source, origin) => `${source}${origin !== undefined ? ` (${origin})` : ""}`,
213
213
  hookCommand: (command, ms) => `${command} (${ms} ms)`,
214
214
  codemode: (mode, reason) => `codemode: ${mode} (${reason})`,
215
+ codemodeEngine: (engine, reason) => `codemode engine: ${engine} (${reason})`,
215
216
  warning: (text) => `warning: ${text}`,
216
217
  trustTitle: "Trust",
217
218
  fromCli: "command line",
@@ -456,6 +457,7 @@ export const zh = {
456
457
  keySource: (source, origin) => `${source}${origin !== undefined ? `(${origin})` : ""}`,
457
458
  hookCommand: (command, ms) => `${command}(${ms} ms)`,
458
459
  codemode: (mode, reason) => `codemode:${mode}(${reason})`,
460
+ codemodeEngine: (engine, reason) => `codemode 引擎:${engine}(${reason})`,
459
461
  warning: (text) => `警告:${text}`,
460
462
  trustTitle: "信任",
461
463
  fromCli: "命令行",
@@ -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;
@@ -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, args: unknown, options: ToolViewOptions);
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, args, options) {
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
- return truncateToWidth(summary === "" ? title : `${title} ${summary}`, width);
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;
@@ -25,6 +25,8 @@ export declare const UNCLEAN_ABORTED_TYPE = "ama.aborted";
25
25
  export declare const UNCLEAN_REMINDER_TYPE = "ama.reminder";
26
26
  /** 与 `trace/types.ts` 的 `TRACE_CUSTOM_TYPE` 相同。 */
27
27
  export declare const UNCLEAN_TRACE_TYPE = "ama.trace";
28
+ /** 与 `codemode/inner-calls.ts` 的 `INNER_CALL_CUSTOM_TYPE` 相同。 */
29
+ export declare const UNCLEAN_CODEMODE_CALL_TYPE = "ama.codemode-call";
28
30
  /** 工具清单的上限:条数与单项长度。 */
29
31
  export declare const UNCLEAN_TOOLS_MAX = 12;
30
32
  export declare const UNCLEAN_TARGET_MAX = 80;
@@ -35,6 +37,12 @@ export interface UncleanEnd {
35
37
  tools: string[];
36
38
  /** 封顶后没列出的条数。 */
37
39
  more: number;
40
+ /**
41
+ * 外层 codemode 调用没有结果(脚本被杀)时,它已经完成的内层调用(`name target: ok | failed`,按发生顺序,
42
+ * 已封顶);其余情况为空。
43
+ */
44
+ innerCalls?: string[];
45
+ innerMore?: number;
38
46
  /** T 里已有恢复提醒(第二次 resume 不再注入)。 */
39
47
  reminded: boolean;
40
48
  }
@@ -24,6 +24,8 @@ export const UNCLEAN_ABORTED_TYPE = "ama.aborted";
24
24
  export const UNCLEAN_REMINDER_TYPE = "ama.reminder";
25
25
  /** 与 `trace/types.ts` 的 `TRACE_CUSTOM_TYPE` 相同。 */
26
26
  export const UNCLEAN_TRACE_TYPE = "ama.trace";
27
+ /** 与 `codemode/inner-calls.ts` 的 `INNER_CALL_CUSTOM_TYPE` 相同。 */
28
+ export const UNCLEAN_CODEMODE_CALL_TYPE = "ama.codemode-call";
27
29
  /** 工具清单的上限:条数与单项长度。 */
28
30
  export const UNCLEAN_TOOLS_MAX = 12;
29
31
  export const UNCLEAN_TARGET_MAX = 80;
@@ -104,18 +106,40 @@ export function toolTarget(name, args) {
104
106
  }
105
107
  return undefined;
106
108
  }
107
- /** 上一轮 = 最后一条非 steer 的 user 消息之后;列出其中全部 assistant 的工具调用。 */
108
- function lastTurnTools(branch, results) {
109
- let start = 0;
109
+ /** 上一轮的起点:最后一条非 steer 的 user 消息之后。 */
110
+ function turnStart(branch) {
110
111
  for (let i = branch.length - 1; i >= 0; i--) {
111
112
  const entry = branch[i];
112
113
  if (entry?.type === "message" &&
113
114
  entry.message.role === "user" &&
114
115
  entry.message.origin !== "steer") {
115
- start = i + 1;
116
- break;
116
+ return i + 1;
117
117
  }
118
118
  }
119
+ return 0;
120
+ }
121
+ /** 上一轮里、外层 codemode 调用没有结果的那些脚本已经完成的内层调用。 */
122
+ function lastTurnInnerCalls(branch, results) {
123
+ const lines = [];
124
+ for (const entry of branch.slice(turnStart(branch))) {
125
+ if (entry.type !== "custom" || entry.customType !== UNCLEAN_CODEMODE_CALL_TYPE)
126
+ continue;
127
+ const data = entry.data;
128
+ if (typeof data !== "object" || data === null)
129
+ continue;
130
+ if (typeof data.parent !== "string" || results.has(data.parent))
131
+ continue;
132
+ if (typeof data.name !== "string")
133
+ continue;
134
+ const head = typeof data.target === "string" ? `${data.name} ${clip(data.target)}` : data.name;
135
+ lines.push(`${clip(head)}: ${data.ok === false ? "failed" : "ok"}`);
136
+ }
137
+ const shown = lines.slice(0, UNCLEAN_TOOLS_MAX);
138
+ return { innerCalls: shown, innerMore: lines.length - shown.length };
139
+ }
140
+ /** 上一轮 = 最后一条非 steer 的 user 消息之后;列出其中全部 assistant 的工具调用。 */
141
+ function lastTurnTools(branch, results) {
142
+ const start = turnStart(branch);
119
143
  const seen = new Set();
120
144
  const tools = [];
121
145
  for (const entry of branch.slice(start)) {
@@ -148,6 +172,14 @@ export function detectUncleanEnd(branch) {
148
172
  const reason = reasonOf(branch, at, entry.message, after);
149
173
  if (reason === undefined)
150
174
  return undefined;
151
- const { tools, more } = lastTurnTools(branch, resultIds(branch));
152
- return { reason, tools, more, reminded: after.some(isRecoveryReminder) };
175
+ const results = resultIds(branch);
176
+ const { tools, more } = lastTurnTools(branch, results);
177
+ const { innerCalls, innerMore } = lastTurnInnerCalls(branch, results);
178
+ return {
179
+ reason,
180
+ tools,
181
+ more,
182
+ ...(innerCalls.length > 0 ? { innerCalls, innerMore } : {}),
183
+ reminded: after.some(isRecoveryReminder),
184
+ };
153
185
  }
@@ -423,13 +423,14 @@ compat only records **verified** differences; please attach a docs link or a rea
423
423
 
424
424
  Defaults are inferred from the request host (`src/ai/apis/anthropic-compat.ts`); `providers.<id>.compat` and channel- or model-level `compat` override field by field:
425
425
 
426
- | Switch | Effect | Default |
427
- | ----------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
428
- | `sendInterleavedThinkingBeta` | Send the `interleaved-thinking` beta header for budgeted thinking + tools | On for `api.anthropic.com`; off for DeepSeek, Zhipu, Kimi, Qwen, MiniMax, StepFun, Tencent, Volcengine; other hosts only for `claude*` models |
429
- | `sendCacheControl` | Place `cache_control` breakpoints | On; off for DeepSeek (documented as ignored) |
430
- | `adaptiveThinking` | `{type:"adaptive"}` + `output_config.effort` | Off; enabled per entry in the catalog for new official models |
431
- | `supportsCacheControlOnTools` | Breakpoint on the last tool definition | On |
432
- | `maxCacheBreakpoints` | Maximum number of breakpoints | 4 |
426
+ | Switch | Effect | Default |
427
+ | ----------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
428
+ | `sendInterleavedThinkingBeta` | Send the `interleaved-thinking` beta header for budgeted thinking + tools | On for `api.anthropic.com`; off for DeepSeek, Zhipu, Kimi, Qwen, MiniMax, StepFun, Tencent, Volcengine; other hosts only for `claude*` models |
429
+ | `sendCacheControl` | Place `cache_control` breakpoints | On; off for DeepSeek (documented as ignored) |
430
+ | `adaptiveThinking` | `{type:"adaptive"}` + `output_config.effort` | Off; enabled per entry in the catalog for new official models |
431
+ | `supportsCacheControlOnTools` | Breakpoint on the last tool definition | On |
432
+ | `maxCacheBreakpoints` | Maximum number of breakpoints | 4 |
433
+ | `messageThreads` | Continue requests as message threads and send only new messages (see below) | On for `api.anthropic.com`; off for every other host (including Anthropic-compatible third parties and relays) |
433
434
 
434
435
  OpenRouter's Messages endpoint only gives cache usage in `message_delta`; parsing already merges non-empty fields, so no switch is needed.
435
436
 
@@ -524,6 +525,25 @@ Every real request records an in-memory entry: the prefix fingerprint (the first
524
525
 
525
526
  `task` sub-sessions have their own record chain and stats, summarized in the "Sub-tasks" line of `/session`; forked sessions keep using the root session id as `prompt_cache_key` (just a routing hint).
526
527
 
528
+ ### Message threads
529
+
530
+ Default behavior on the official endpoint (beta header `message-threads-2026-08-12`): when a request has a stable session id and `cacheRetention` is not `none`, the server keeps the conversation as a thread and the request carries only the messages after the previous reply instead of resending the whole history every turn. `system` and `tools` are omitted from a continuation; the thread keeps its own. Token usage and cache reads/writes are still reported for the whole conversation, and fingerprints and miss detection look only at the transcript, so a continuation is never reported as a miss.
531
+
532
+ | Item | Rule |
533
+ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
534
+ | First request | Full request with `thread: {type:"create"}` and the beta header; the reply's message id becomes the session's continuation point |
535
+ | Continuation | `system` / `tools` removed, `messages` only the new part, `thread: {type:"continue", previous_message_id}`; each reply can be continued once |
536
+ | Fallback to full | The earlier context no longer matches the request item by item (compaction, `/tree` rewind or branch switch, a change to model / system / tools / thinking level / `tool_choice` / betas); the message count does not exceed the continuation point; the previous turn failed or was aborted; the reply came from another endpoint. A new thread is started |
537
+ | Server rejection | `thread_not_found`, `thread_already_continued`, `thread_continue_in_flight`, `thread_fingerprint_mismatch` → resend the full request as a new thread once; `thread_unsupported_request`, or a 400 about the `thread` field without an error code → resend without `thread` **and without the threads beta header** (the endpoint may reject the header value itself), and stop using threads for that session and for that endpoint + model for the rest of the process, so no other session pays an extra 400 on its first request. The first four keep the header on resend. Other errors are not about the thread and surface as usual |
538
+ | Not participating | A request with `StreamOptions.disableContinuation: true` neither continues nor replaces the continuation point: warming replays and compaction / branch summary requests set it (they repeat the previous request's prefix, and continuing would use up the only continuation of that reply); so does a request whose body `onPayload` replaced with a non-object. The threads beta header is still sent so headers match real turns and the cache key stays the same (once an endpoint is switched off, no request carries it) |
539
+ | Switch | `compat.messageThreads: false` turns it off; Anthropic-compatible third parties and relays default to off (a gateway that drops unknown fields would turn a continuation into a request missing its history); set `true` once the gateway is known to forward the `thread` field |
540
+
541
+ Forked sessions share the root's prompt cache key but have their own thread key (`StreamOptions.threadKey`, default `sessionId`), so a fork and its root each continue their own thread.
542
+
543
+ Continuation points live in process memory only (up to 10 000 sessions, released when the session ends). After a restart, or once the thread has expired on the server (a few idle minutes), the first request is rejected and resent in full automatically, costing one extra round trip.
544
+
545
+ Manual live check (real key, not run in CI): `pnpm build:lib && ANTHROPIC_API_KEY=... node scripts/verify-anthropic-threads.mjs [model id]`, default `claude-haiku-5-5`. It uses temporary `AMA_DATA_DIR` / `AMA_CONFIG_DIR`, reads the key from the environment only and never prints it. It runs 3 turns and prints, per turn, the thread action (create / continue), the request body message count and input / cacheRead / cacheWrite / output; it exits 1 if turn 2 did not continue.
546
+
527
547
  ### Warming
528
548
 
529
549
  While a tool runs for a long time (long tests, `task` sub-tasks, codemode scripts), the prefix may expire before the next request. Warming replays the previous real request before the TTL expires (same model, same context, `maxTokens` at the smallest value the protocol accepts: 16 for `openai-responses`, 1 elsewhere), paying only one read to keep the cache alive.
@@ -50,7 +50,7 @@ Accept edits | shift+tab to cycle claude-opus-5-5 medium | Ctx 3.0% 8.2k/272k
50
50
  - **Notices**: `✗` errors, `↻ retry n/m`, `!` warnings (cache misses, remaining context), `⛔` hook blocks, host notifications, explanations of denied or timed-out approvals; compaction / branch summaries are left-bar cards (`▎ context compacted 128k → 24k tokens`).
51
51
  - **Running**: `⠋ verb · elapsed · …`, with the verb taken from the deepest current state: waiting for confirmation (approval open), `running bash` / `running 3 tools`, `retry 2/3 · in 2s`, compacting context, replying `· ↓≈1.2k` (estimated tokens of this output), thinking. While a foreground sub-agent task blocks the turn, `Ctrl+B to background` is appended; while the agent bar has tasks, `↓ Agent bar` is appended (`↓ handle approval` instead when an approval is docked): `⠏ running task · 4s · Esc to interrupt · Ctrl+B to background · ↓ Agent bar`; items are dropped whole from the end when the line does not fit. With text in the input box, `Enter queue · Ctrl+X interrupt & send` comes first (`Enter interrupt & send · Ctrl+X queue` with `ui.enterWhileRunning: "interrupt"`); with queued steers the queue's last line reads `Alt+↑ take back · Ctrl+X send now · Esc refill and interrupt`.
52
52
  - **Status bar**: the mode is always on the far left; `full` splits into two sides — the left column holds state and switches (permission mode, the `shift+tab` hint, codemode, sandbox, preset, fallback), the right column holds metrics and the model (tps, usage, model, Ctx, git, cost, duration, quota), right-aligned, and a line with nothing on the left sits flush right; the status bar is the last line except for the subscription quota line in the `full` layout (`compact` always keeps it last). In `compact` the separator is always `·` (embedding hosts parse it), in `full` it is `|`. The layout follows `ui.statusLine`: `full` (two lines) by default in a standalone terminal, `compact` (one line, same layout as before) by default in an embedding host with a profile; `Ctrl+G` or `/statusline [full|compact]` switches at runtime for this session only. With `full` the input box is the 4th line from the bottom (`compact` keeps it 3rd from the bottom).
53
- - **`full` top line (rate line)**: the left side holds switches: `codemode on|only` (with `net!` when the network is not isolated) · `sandbox` · `preset <name>` (when not default) · `→ <fallback model>` (during a fallback, yellow) · queue count · host status; it is empty when there are none. The right side is `tps: <rate> tok/s • <output tokens> tok / <elapsed> (avg <session average> · ttft <time to first token>) · Σ↑<input> ↓<output> R<cache read> W<cache write> · cache · re-billing · [-]`. While streaming the rate is the instantaneous value over the last 2 s (`tps:` in the accent color); afterwards it is the request's average; whole replies generated in under 0.25 s get no rate and show `—`; elapsed time starts at the first token; `Σ` marks the **session total** of billed tokens (not context usage), `↑` input includes cache reads and writes, which are also listed as `R` / `W` (hidden when 0; `Σ` is `sum ` in ASCII); in ASCII `•` becomes `*` and `→` becomes `->`; `[-]` at the end hints that it folds. Only chat requests count (compaction summaries, warming and the classifier do not). When narrow, the right-side metrics drop first (output / elapsed, tokens, cache, re-billing, avg, ttft), then the left-side switches (host status, queue count, preset, fallback, sandbox, codemode); `tps` and `[-]` never drop.
53
+ - **`full` top line (rate line)**: the left side holds switches: `codemode on|only` (with `net!` when the network is not isolated, only with `codemode.engine: "node"`) · `sandbox` · `preset <name>` (when not default) · `→ <fallback model>` (during a fallback, yellow) · queue count · host status; it is empty when there are none. The right side is `tps: <rate> tok/s • <output tokens> tok / <elapsed> (avg <session average> · ttft <time to first token>) · Σ↑<input> ↓<output> R<cache read> W<cache write> · cache · re-billing · [-]`. While streaming the rate is the instantaneous value over the last 2 s (`tps:` in the accent color); afterwards it is the request's average; whole replies generated in under 0.25 s get no rate and show `—`; elapsed time starts at the first token; `Σ` marks the **session total** of billed tokens (not context usage), `↑` input includes cache reads and writes, which are also listed as `R` / `W` (hidden when 0; `Σ` is `sum ` in ASCII); in ASCII `•` becomes `*` and `→` becomes `->`; `[-]` at the end hints that it folds. Only chat requests count (compaction summaries, warming and the classifier do not). When narrow, the right-side metrics drop first (output / elapsed, tokens, cache, re-billing, avg, ttft), then the left-side switches (host status, queue count, preset, fallback, sandbox, codemode); `tps` and `[-]` never drop.
54
54
  - **`full` bottom line**: on the left `permission mode | shift+tab to switch`, on the right `model thinking-level | Ctx 3.0% 8.2k/272k auto | <dir name> ⎇ <branch> <short commit> ↑N ↓N (+a,-d) | $cost | session duration` (Ctx with one decimal, no meter even when wide). The Ctx part is the current context: the percentage, used / window, and `auto` while auto-compaction is on (hidden when it is off, tripped after repeated failures, or the window is unknown); the numbers get a leading `≈` when they do not come from usage reported by the model (the baseline estimated from the system prompt and tool declarations before the first request, or the full estimate after a compaction until the next request); without a window it reads `Ctx ? 8.2k`. When narrow, these drop in order: `auto`, the switch hint, thinking level, `/window`, line changes, directory name, branch and commit, used tokens, duration, cost, the context percentage, model.
55
55
  - **Subscription quota line** (third `full` line, below the status bar): when the current model uses a ChatGPT subscription (the `chatgpt` provider) it shows `Session: <used %> | Reset: <time to reset> | Weekly: <used %> | Weekly Reset: <time to reset>` (Chinese labels in the Chinese interface), from the latest `quota_update` (the codex flavor's `x-codex-primary/secondary-*` response headers and `codex.rate_limits` events; siwc only has it after a 429). Reset times are relative (`2h 18m`, `6d 5h`) and refresh once a minute. Before the first request the codex flavor shows "Quota: shown after the first request" (the first request brings the quota back, so holding the line avoids the row count jumping); siwc without data takes no line (it only gets a quota when over the limit, so a placeholder would stay forever); non-subscription models show nothing. Below 80 columns it compresses to `5h 10% ↻2h18m · wk 31% ↻6d5h`, dropping the reset times first when narrower. The quota line is right-aligned. Labels follow the window length rather than the primary / secondary slot: 300 minutes is `Session`, 10080 minutes is `Weekly`, any other length shows the length itself (`1d: `); without a length, primary counts as Session and secondary as Weekly (or the other one if that name is taken); windows are ordered shortest first. A window with 0 % used, no length and no reset time is the server saying "no such window" and is not shown (some plans get a single weekly window from codex, sent as primary). `Ctrl+G` / `/statusline compact` folds the quota line together with the rate line (`compact` stays a single line; hosts anchor on "last line = status bar").
56
56
  - **Colors** (`full`): labels, units, separators and parentheses dim gray; the rate number purple, output / elapsed / avg blue, ttft purple; model and thinking level blue; Ctx by threshold green / yellow / red (yellow once past the tier-one pruning threshold — 0.7 × (window − reserve), a little under 70%; red at ≥ 90%; ≥ 70% yellow when there is no threshold), quota percentages yellow at ≥ 70% and red at ≥ 90%; directory and branch green, short commit dim, `↑N` ahead orange, `↓N` behind red, `(+a,-d)` green / red; cost yellow; duration and reset times purple. All come from theme semantic colors with dark / light and 16-color mappings; `NO_COLOR` and ASCII drop the colors and keep the structure. `compact` colors are unchanged.
@@ -204,7 +204,7 @@ Events are the in-process `SessionEvent` (`src/agent/types.ts`); only `message_u
204
204
  | `agent_settled` | `warning?` (the run has fully ended, retries and followUps included) |
205
205
  | `message_start` / `message_end` | `message` (`AgentMessage`) |
206
206
  | `message_update` | `assistantMessageEvent`, `usage?` (see below) |
207
- | `tool_execution_start` | `toolCallId`, `toolName`, `args`, `parentToolCallId?` |
207
+ | `tool_execution_start` | `toolCallId`, `toolName`, `args`, `coercedArguments?`, `parentToolCallId?` |
208
208
  | `tool_execution_update` | `toolCallId`, `toolName`, `partial` (output text while running), `parentToolCallId?` |
209
209
  | `tool_execution_end` | `toolCallId`, `toolName`, `result`, `isError`, `parentToolCallId?`, `autoDecision?` (auto mode: `{ layer: rule \| static \| classifier, decision, reason, cached? }`), `denied?` (`true`: not executed because permissions / a hook / approval denied it; the reason is in `result`) |
210
210
  | `queue_update` | `steering: string[]`, `followUp: string[]` |
@@ -225,6 +225,8 @@ Events are the in-process `SessionEvent` (`src/agent/types.ts`); only `message_u
225
225
 
226
226
  There is also the non-session event `{"type":"notification","level":"info"|"warn"|"error","message":…}`: the host's `ui.notify` and run failures after the response.
227
227
 
228
+ `coercedArguments` is an optional additive field: when the model's arguments failed strict validation but passed after lenient coercion, it holds the arguments the permission gate, hooks and the tool actually received (`args` stays as the model sent it, as does the session history); it is absent when the arguments were valid as sent. Older clients can ignore it; `RPC_PROTOCOL_VERSION` is unchanged.
229
+
228
230
  `parentToolCallId` appears only on inner calls made through `tools.*` inside codemode scripts; its value is the id of the outer `codemode` call, which clients use to fold the display. Inner calls do not enter the transcript.
229
231
 
230
232
  Assistant messages in `message_end`, `turn_end`, `done` / `error` and in replays (`get_messages`, `get_entries`) may carry two optional fields (model efficiency batch, docs/history/model-efficiency-plan.md §1.10, Chinese): `retryAfterMs` on failed messages (`Retry-After`, in ms) and `rawArguments` on tool-call blocks (the raw argument string the model produced). `subagent_*` events are unchanged; `TaskInfo` from `get_tasks` may carry `context?: "fork" | "fresh"` (the sub-session's actual context mode). All are new optional fields, `RPC_PROTOCOL_VERSION` is unchanged, and clients can ignore fields they do not know.