@armadra/agent 0.5.0 → 0.6.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 (471) hide show
  1. package/CHANGELOG.md +177 -294
  2. package/CHANGELOG.zh-CN.md +442 -0
  3. package/README.md +408 -364
  4. package/README.zh-CN.md +705 -0
  5. package/dist/agent/session-plan.js +2 -2
  6. package/dist/agent/session-state.d.ts +3 -0
  7. package/dist/agent/session-state.js +20 -0
  8. package/dist/agent/session-subagent.d.ts +15 -1
  9. package/dist/agent/session-subagent.js +26 -3
  10. package/dist/agent/session-telemetry.d.ts +16 -2
  11. package/dist/agent/session-telemetry.js +29 -7
  12. package/dist/agent/session-tools.js +5 -2
  13. package/dist/agent/session-trace-writer.d.ts +27 -0
  14. package/dist/agent/session-trace-writer.js +253 -0
  15. package/dist/agent/session.d.ts +2 -0
  16. package/dist/agent/session.js +12 -0
  17. package/dist/agent/subagent-direct.d.ts +20 -0
  18. package/dist/agent/subagent-direct.js +76 -0
  19. package/dist/agent/subagent-registry.d.ts +8 -1
  20. package/dist/agent/subagent-registry.js +28 -1
  21. package/dist/agent/system-prompt.d.ts +3 -1
  22. package/dist/agent/system-prompt.js +3 -0
  23. package/dist/agent/tool-runner.d.ts +2 -1
  24. package/dist/agent/tool-runner.js +5 -4
  25. package/dist/agent/types-w6.d.ts +39 -0
  26. package/dist/agent/types-w6.js +4 -0
  27. package/dist/agent/types.d.ts +5 -2
  28. package/dist/agents/external.js +1 -1
  29. package/dist/agents/task-record.d.ts +74 -1
  30. package/dist/agents/task-record.js +100 -0
  31. package/dist/ai/apis/cache-params.js +2 -1
  32. package/dist/ai/apis/chatgpt-backend.d.ts +52 -0
  33. package/dist/ai/apis/chatgpt-backend.js +224 -0
  34. package/dist/ai/apis/chatgpt-rate-limits.d.ts +26 -0
  35. package/dist/ai/apis/chatgpt-rate-limits.js +91 -0
  36. package/dist/ai/apis/openai-responses-request.d.ts +2 -1
  37. package/dist/ai/apis/openai-responses-request.js +8 -2
  38. package/dist/ai/apis/openai-responses.d.ts +2 -0
  39. package/dist/ai/apis/openai-responses.js +51 -16
  40. package/dist/ai/overflow.d.ts +1 -1
  41. package/dist/ai/overflow.js +10 -7
  42. package/dist/ai/providers/auth.d.ts +15 -2
  43. package/dist/ai/providers/auth.js +69 -2
  44. package/dist/ai/providers/builtin.js +27 -0
  45. package/dist/ai/providers/catalog-data.js +1 -0
  46. package/dist/ai/providers/enrich.js +2 -7
  47. package/dist/ai/providers/models-dev-cache.js +15 -19
  48. package/dist/ai/providers/models-dev-snapshot.js +8 -7
  49. package/dist/ai/providers/models-dev.js +5 -15
  50. package/dist/ai/providers/suggest.js +2 -16
  51. package/dist/ai/types.d.ts +27 -1
  52. package/dist/auth/chatgpt/backend-client.d.ts +26 -0
  53. package/dist/auth/chatgpt/backend-client.js +74 -0
  54. package/dist/auth/chatgpt/claims.d.ts +17 -0
  55. package/dist/auth/chatgpt/claims.js +46 -0
  56. package/dist/auth/chatgpt/cli.d.ts +33 -0
  57. package/dist/auth/chatgpt/cli.js +252 -0
  58. package/dist/auth/chatgpt/doctor.d.ts +17 -0
  59. package/dist/auth/chatgpt/doctor.js +36 -0
  60. package/dist/auth/chatgpt/host-id.d.ts +7 -0
  61. package/dist/auth/chatgpt/host-id.js +26 -0
  62. package/dist/auth/chatgpt/login.d.ts +30 -0
  63. package/dist/auth/chatgpt/login.js +130 -0
  64. package/dist/auth/chatgpt/presets.d.ts +66 -0
  65. package/dist/auth/chatgpt/presets.js +120 -0
  66. package/dist/auth/chatgpt/quota-text.d.ts +13 -0
  67. package/dist/auth/chatgpt/quota-text.js +36 -0
  68. package/dist/auth/oauth/browser.d.ts +12 -0
  69. package/dist/auth/oauth/browser.js +27 -0
  70. package/dist/auth/oauth/callback-server.d.ts +47 -0
  71. package/dist/auth/oauth/callback-server.js +147 -0
  72. package/dist/auth/oauth/flows.d.ts +62 -0
  73. package/dist/auth/oauth/flows.js +113 -0
  74. package/dist/auth/oauth/jwt.d.ts +24 -0
  75. package/dist/auth/oauth/jwt.js +81 -0
  76. package/dist/auth/oauth/live.d.ts +21 -0
  77. package/dist/auth/oauth/live.js +25 -0
  78. package/dist/auth/oauth/oidc.d.ts +26 -0
  79. package/dist/auth/oauth/oidc.js +72 -0
  80. package/dist/auth/oauth/pkce.d.ts +15 -0
  81. package/dist/auth/oauth/pkce.js +20 -0
  82. package/dist/auth/oauth/refresh.d.ts +35 -0
  83. package/dist/auth/oauth/refresh.js +129 -0
  84. package/dist/auth/oauth/token-client.d.ts +33 -0
  85. package/dist/auth/oauth/token-client.js +121 -0
  86. package/dist/auth/oauth/token-store.d.ts +23 -0
  87. package/dist/auth/oauth/token-store.js +125 -0
  88. package/dist/auth/testing/fake-oauth.d.ts +73 -0
  89. package/dist/auth/testing/fake-oauth.js +271 -0
  90. package/dist/auth/testing/refresh-child.d.ts +5 -0
  91. package/dist/auth/testing/refresh-child.js +16 -0
  92. package/dist/bundle/ama.cjs +28307 -13241
  93. package/dist/checkpoints/backend.js +6 -5
  94. package/dist/checkpoints/restore.js +3 -2
  95. package/dist/checkpoints/settings.js +2 -1
  96. package/dist/checkpoints/shadow-git.js +7 -6
  97. package/dist/checkpoints/shadow-restore.js +3 -2
  98. package/dist/checkpoints/tracker.js +4 -3
  99. package/dist/cli/args.d.ts +9 -2
  100. package/dist/cli/args.js +74 -27
  101. package/dist/cli/bootstrap.js +53 -31
  102. package/dist/cli/choice-prompt.d.ts +58 -0
  103. package/dist/cli/choice-prompt.js +142 -0
  104. package/dist/cli/codemode-notice.js +2 -2
  105. package/dist/cli/compose-agents.js +2 -1
  106. package/dist/cli/compose-extensions.js +2 -0
  107. package/dist/cli/compose-memory.d.ts +53 -0
  108. package/dist/cli/compose-memory.js +127 -0
  109. package/dist/cli/compose-providers.d.ts +5 -0
  110. package/dist/cli/compose-providers.js +32 -2
  111. package/dist/cli/compose-session.d.ts +5 -0
  112. package/dist/cli/compose-session.js +27 -13
  113. package/dist/cli/compose-store.d.ts +2 -0
  114. package/dist/cli/compose-store.js +9 -5
  115. package/dist/cli/compose.d.ts +2 -0
  116. package/dist/cli/compose.js +13 -5
  117. package/dist/cli/default-model.d.ts +0 -2
  118. package/dist/cli/default-model.js +5 -8
  119. package/dist/cli/deps.d.ts +5 -1
  120. package/dist/cli/exit-codes.d.ts +1 -1
  121. package/dist/cli/exit-codes.js +7 -16
  122. package/dist/cli/from-prompt.js +3 -2
  123. package/dist/cli/help-text.d.ts +2 -1
  124. package/dist/cli/help-text.js +5 -99
  125. package/dist/cli/main.d.ts +5 -0
  126. package/dist/cli/main.js +21 -2
  127. package/dist/cli/proxy.js +14 -9
  128. package/dist/cli/runtime.d.ts +5 -0
  129. package/dist/cli/startup-screen.js +20 -27
  130. package/dist/cli/startup-steps.js +6 -8
  131. package/dist/cli/subcommands/auth.d.ts +6 -3
  132. package/dist/cli/subcommands/auth.js +52 -22
  133. package/dist/cli/subcommands/config-set.d.ts +21 -0
  134. package/dist/cli/subcommands/config-set.js +137 -0
  135. package/dist/cli/subcommands/config.d.ts +2 -1
  136. package/dist/cli/subcommands/config.js +51 -37
  137. package/dist/cli/subcommands/doctor.d.ts +2 -1
  138. package/dist/cli/subcommands/doctor.js +97 -58
  139. package/dist/cli/subcommands/init.d.ts +1 -1
  140. package/dist/cli/subcommands/init.js +8 -7
  141. package/dist/cli/subcommands/memory.d.ts +18 -0
  142. package/dist/cli/subcommands/memory.js +189 -0
  143. package/dist/cli/subcommands/model-meta.js +11 -9
  144. package/dist/cli/subcommands/models-cache-probe.d.ts +1 -1
  145. package/dist/cli/subcommands/models-cache-probe.js +26 -32
  146. package/dist/cli/subcommands/models-discover.d.ts +3 -0
  147. package/dist/cli/subcommands/models-discover.js +44 -21
  148. package/dist/cli/subcommands/models.d.ts +1 -1
  149. package/dist/cli/subcommands/models.js +29 -22
  150. package/dist/cli/subcommands/probe-runner.js +8 -7
  151. package/dist/cli/subcommands/providers-list.js +32 -21
  152. package/dist/cli/subcommands/providers-plan.js +24 -25
  153. package/dist/cli/subcommands/providers-probe.js +5 -6
  154. package/dist/cli/subcommands/providers.d.ts +2 -2
  155. package/dist/cli/subcommands/providers.js +48 -59
  156. package/dist/cli/subcommands/sessions-export.d.ts +1 -1
  157. package/dist/cli/subcommands/sessions-export.js +10 -9
  158. package/dist/cli/subcommands/sessions-search.d.ts +1 -1
  159. package/dist/cli/subcommands/sessions-search.js +11 -10
  160. package/dist/cli/subcommands/sessions-trace.d.ts +30 -0
  161. package/dist/cli/subcommands/sessions-trace.js +156 -0
  162. package/dist/cli/subcommands/sessions.d.ts +4 -3
  163. package/dist/cli/subcommands/sessions.js +40 -37
  164. package/dist/cli/subcommands/stats.d.ts +1 -1
  165. package/dist/cli/subcommands/stats.js +49 -30
  166. package/dist/cli/system-prompt-arg.js +3 -2
  167. package/dist/codemode/capability.js +3 -2
  168. package/dist/compaction/post-compact.d.ts +1 -0
  169. package/dist/compaction/post-compact.js +15 -1
  170. package/dist/compaction/prune-tier.d.ts +1 -1
  171. package/dist/compaction/prune-tier.js +3 -3
  172. package/dist/compaction/serialize.js +2 -1
  173. package/dist/config/auth-file.d.ts +12 -2
  174. package/dist/config/auth-file.js +32 -10
  175. package/dist/config/checker.js +12 -11
  176. package/dist/config/context-files.js +3 -2
  177. package/dist/config/edit.d.ts +106 -0
  178. package/dist/config/edit.js +350 -0
  179. package/dist/config/init.d.ts +4 -3
  180. package/dist/config/init.js +10 -18
  181. package/dist/config/json-schema.d.ts +2 -1
  182. package/dist/config/json-schema.js +101 -68
  183. package/dist/config/key-docs.d.ts +18 -7
  184. package/dist/config/key-docs.js +43 -128
  185. package/dist/config/load.js +7 -6
  186. package/dist/config/merge.d.ts +4 -1
  187. package/dist/config/merge.js +42 -22
  188. package/dist/config/paths.js +6 -5
  189. package/dist/config/profile.d.ts +5 -1
  190. package/dist/config/profile.js +7 -2
  191. package/dist/config/schema-w5.js +3 -2
  192. package/dist/config/schema-w6.d.ts +19 -0
  193. package/dist/config/schema-w6.js +115 -0
  194. package/dist/config/schema.js +34 -20
  195. package/dist/config/settings-registry.d.ts +78 -0
  196. package/dist/config/settings-registry.js +184 -0
  197. package/dist/config/types-w6.d.ts +109 -0
  198. package/dist/config/types-w6.js +19 -0
  199. package/dist/config/types.d.ts +11 -8
  200. package/dist/config/types.js +1 -0
  201. package/dist/drivers/acp/client.js +1 -1
  202. package/dist/drivers/acp/driver.js +13 -8
  203. package/dist/drivers/agents.js +4 -3
  204. package/dist/drivers/base.js +3 -2
  205. package/dist/drivers/host-runners.js +2 -1
  206. package/dist/drivers/native/claude-stream.js +12 -11
  207. package/dist/drivers/native/codex-app-server.js +17 -12
  208. package/dist/drivers/native/oneshot.js +8 -7
  209. package/dist/drivers/pool.js +1 -1
  210. package/dist/drivers/runner.d.ts +3 -1
  211. package/dist/drivers/runner.js +68 -20
  212. package/dist/drivers/turn.js +1 -1
  213. package/dist/hooks/config.js +3 -2
  214. package/dist/hooks/protocol.js +18 -12
  215. package/dist/host/api-impl.js +11 -10
  216. package/dist/host/loader.js +9 -8
  217. package/dist/host/types.d.ts +3 -0
  218. package/dist/i18n/catalog.d.ts +2169 -0
  219. package/dist/i18n/catalog.js +72 -0
  220. package/dist/i18n/format.d.ts +21 -0
  221. package/dist/i18n/format.js +58 -0
  222. package/dist/i18n/index.d.ts +58 -0
  223. package/dist/i18n/index.js +72 -0
  224. package/dist/i18n/messages/agents.d.ts +84 -0
  225. package/dist/i18n/messages/agents.js +85 -0
  226. package/dist/i18n/messages/approval.d.ts +99 -0
  227. package/dist/i18n/messages/approval.js +100 -0
  228. package/dist/i18n/messages/auth.d.ts +187 -0
  229. package/dist/i18n/messages/auth.js +189 -0
  230. package/dist/i18n/messages/cli-args.d.ts +46 -0
  231. package/dist/i18n/messages/cli-args.js +46 -0
  232. package/dist/i18n/messages/cli-help.d.ts +12 -0
  233. package/dist/i18n/messages/cli-help.js +244 -0
  234. package/dist/i18n/messages/cli.d.ts +336 -0
  235. package/dist/i18n/messages/cli.js +311 -0
  236. package/dist/i18n/messages/config-keys.d.ts +289 -0
  237. package/dist/i18n/messages/config-keys.js +292 -0
  238. package/dist/i18n/messages/config.d.ts +502 -0
  239. package/dist/i18n/messages/config.js +239 -0
  240. package/dist/i18n/messages/drivers.d.ts +123 -0
  241. package/dist/i18n/messages/drivers.js +124 -0
  242. package/dist/i18n/messages/errors.d.ts +83 -0
  243. package/dist/i18n/messages/errors.js +171 -0
  244. package/dist/i18n/messages/interactive-line.d.ts +61 -0
  245. package/dist/i18n/messages/interactive-line.js +69 -0
  246. package/dist/i18n/messages/interactive-startup.d.ts +103 -0
  247. package/dist/i18n/messages/interactive-startup.js +104 -0
  248. package/dist/i18n/messages/interactive-view.d.ts +140 -0
  249. package/dist/i18n/messages/interactive-view.js +141 -0
  250. package/dist/i18n/messages/interactive.d.ts +493 -0
  251. package/dist/i18n/messages/interactive.js +248 -0
  252. package/dist/i18n/messages/memory.d.ts +123 -0
  253. package/dist/i18n/messages/memory.js +128 -0
  254. package/dist/i18n/messages/panels.d.ts +190 -0
  255. package/dist/i18n/messages/panels.js +189 -0
  256. package/dist/i18n/messages/permissions.d.ts +126 -0
  257. package/dist/i18n/messages/permissions.js +151 -0
  258. package/dist/i18n/messages/plan.d.ts +123 -0
  259. package/dist/i18n/messages/plan.js +124 -0
  260. package/dist/i18n/messages/print.d.ts +86 -0
  261. package/dist/i18n/messages/print.js +91 -0
  262. package/dist/i18n/messages/report.d.ts +391 -0
  263. package/dist/i18n/messages/report.js +490 -0
  264. package/dist/i18n/messages/rewind.d.ts +198 -0
  265. package/dist/i18n/messages/rewind.js +217 -0
  266. package/dist/i18n/messages/session.d.ts +230 -0
  267. package/dist/i18n/messages/session.js +258 -0
  268. package/dist/i18n/messages/settings.d.ts +348 -0
  269. package/dist/i18n/messages/settings.js +336 -0
  270. package/dist/i18n/messages/subcommands-config.d.ts +111 -0
  271. package/dist/i18n/messages/subcommands-config.js +127 -0
  272. package/dist/i18n/messages/subcommands.d.ts +548 -0
  273. package/dist/i18n/messages/subcommands.js +474 -0
  274. package/dist/i18n/messages/trace.d.ts +243 -0
  275. package/dist/i18n/messages/trace.js +238 -0
  276. package/dist/i18n/types.d.ts +15 -0
  277. package/dist/i18n/types.js +7 -0
  278. package/dist/index.d.ts +6 -0
  279. package/dist/index.js +2 -0
  280. package/dist/memory/edit.d.ts +24 -0
  281. package/dist/memory/edit.js +63 -0
  282. package/dist/memory/frontmatter.d.ts +37 -0
  283. package/dist/memory/frontmatter.js +79 -0
  284. package/dist/memory/index.d.ts +28 -0
  285. package/dist/memory/index.js +126 -0
  286. package/dist/memory/lock.d.ts +17 -0
  287. package/dist/memory/lock.js +62 -0
  288. package/dist/memory/paths.d.ts +57 -0
  289. package/dist/memory/paths.js +175 -0
  290. package/dist/memory/report.d.ts +36 -0
  291. package/dist/memory/report.js +86 -0
  292. package/dist/memory/runtime.d.ts +42 -0
  293. package/dist/memory/runtime.js +36 -0
  294. package/dist/memory/secrets.d.ts +8 -0
  295. package/dist/memory/secrets.js +27 -0
  296. package/dist/memory/section.d.ts +28 -0
  297. package/dist/memory/section.js +59 -0
  298. package/dist/memory/store.d.ts +70 -0
  299. package/dist/memory/store.js +284 -0
  300. package/dist/memory/tool.d.ts +31 -0
  301. package/dist/memory/tool.js +94 -0
  302. package/dist/modes/acp/acp-events.js +2 -1
  303. package/dist/modes/acp/acp-server.js +13 -12
  304. package/dist/modes/commands-core.d.ts +17 -0
  305. package/dist/modes/commands-core.js +101 -61
  306. package/dist/modes/image-input.js +20 -6
  307. package/dist/modes/interactive/agent-bar.d.ts +95 -0
  308. package/dist/modes/interactive/agent-bar.js +248 -0
  309. package/dist/modes/interactive/agent-panels.js +27 -26
  310. package/dist/modes/interactive/agent-transcript.d.ts +47 -0
  311. package/dist/modes/interactive/agent-transcript.js +191 -0
  312. package/dist/modes/interactive/agent-ui.d.ts +36 -1
  313. package/dist/modes/interactive/agent-ui.js +180 -14
  314. package/dist/modes/interactive/agent-view.d.ts +72 -0
  315. package/dist/modes/interactive/agent-view.js +281 -0
  316. package/dist/modes/interactive/approval-dialog.js +46 -34
  317. package/dist/modes/interactive/clipboard-paste.d.ts +2 -2
  318. package/dist/modes/interactive/clipboard-paste.js +9 -4
  319. package/dist/modes/interactive/commands.d.ts +22 -1
  320. package/dist/modes/interactive/commands.js +93 -38
  321. package/dist/modes/interactive/completion.js +2 -1
  322. package/dist/modes/interactive/config-panel.d.ts +70 -0
  323. package/dist/modes/interactive/config-panel.js +319 -0
  324. package/dist/modes/interactive/config-ui.d.ts +96 -0
  325. package/dist/modes/interactive/config-ui.js +397 -0
  326. package/dist/modes/interactive/confirm-dialog.d.ts +49 -0
  327. package/dist/modes/interactive/confirm-dialog.js +120 -0
  328. package/dist/modes/interactive/event-notices.js +11 -9
  329. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  330. package/dist/modes/interactive/interactive-mode.js +25 -22
  331. package/dist/modes/interactive/key-dispatch.d.ts +18 -0
  332. package/dist/modes/interactive/key-dispatch.js +39 -13
  333. package/dist/modes/interactive/line/line-editor.js +2 -1
  334. package/dist/modes/interactive/line/line-mode.d.ts +2 -0
  335. package/dist/modes/interactive/line/line-mode.js +24 -4
  336. package/dist/modes/interactive/line/line-render.js +25 -24
  337. package/dist/modes/interactive/memory-panel.d.ts +64 -0
  338. package/dist/modes/interactive/memory-panel.js +221 -0
  339. package/dist/modes/interactive/message-view.d.ts +4 -2
  340. package/dist/modes/interactive/message-view.js +42 -33
  341. package/dist/modes/interactive/panels.js +39 -31
  342. package/dist/modes/interactive/pickers.d.ts +2 -1
  343. package/dist/modes/interactive/pickers.js +10 -6
  344. package/dist/modes/interactive/plan-command.d.ts +1 -1
  345. package/dist/modes/interactive/plan-command.js +24 -27
  346. package/dist/modes/interactive/plan-dialog.js +18 -17
  347. package/dist/modes/interactive/plan-flow.js +6 -5
  348. package/dist/modes/interactive/rewind-command.d.ts +1 -1
  349. package/dist/modes/interactive/rewind-command.js +18 -16
  350. package/dist/modes/interactive/rewind-flow.d.ts +0 -1
  351. package/dist/modes/interactive/rewind-flow.js +13 -14
  352. package/dist/modes/interactive/rewind-list.js +7 -6
  353. package/dist/modes/interactive/rewind-panel.js +40 -40
  354. package/dist/modes/interactive/rewind-text.d.ts +5 -3
  355. package/dist/modes/interactive/rewind-text.js +48 -38
  356. package/dist/modes/interactive/run-indicator.js +15 -12
  357. package/dist/modes/interactive/session-events.js +3 -2
  358. package/dist/modes/interactive/startup-header.js +22 -23
  359. package/dist/modes/interactive/startup-ui.js +41 -29
  360. package/dist/modes/interactive/status-area.d.ts +2 -0
  361. package/dist/modes/interactive/status-area.js +8 -2
  362. package/dist/modes/interactive/status-bar.js +4 -3
  363. package/dist/modes/interactive/subagent-view.js +9 -7
  364. package/dist/modes/interactive/tasks-report.d.ts +6 -0
  365. package/dist/modes/interactive/tasks-report.js +28 -31
  366. package/dist/modes/interactive/terminal-setup.d.ts +9 -0
  367. package/dist/modes/interactive/terminal-setup.js +23 -0
  368. package/dist/modes/interactive/tool-summary.js +19 -17
  369. package/dist/modes/interactive/tool-view.js +7 -4
  370. package/dist/modes/interactive/trace-view.d.ts +89 -0
  371. package/dist/modes/interactive/trace-view.js +332 -0
  372. package/dist/modes/print/print-mode.js +14 -15
  373. package/dist/modes/rpc/commands.js +7 -3
  374. package/dist/modes/rpc/rpc-mode.js +9 -3
  375. package/dist/modes/session-report.d.ts +2 -0
  376. package/dist/modes/session-report.js +101 -105
  377. package/dist/modes/startup-ui-text.js +11 -6
  378. package/dist/permissions/bypass.d.ts +30 -0
  379. package/dist/permissions/bypass.js +45 -0
  380. package/dist/permissions/memory-class.d.ts +23 -0
  381. package/dist/permissions/memory-class.js +54 -0
  382. package/dist/permissions/modes.d.ts +3 -3
  383. package/dist/permissions/modes.js +21 -16
  384. package/dist/permissions/pipeline.d.ts +1 -1
  385. package/dist/permissions/pipeline.js +9 -2
  386. package/dist/permissions/preview.js +49 -42
  387. package/dist/permissions/rules.js +5 -2
  388. package/dist/permissions/types.d.ts +4 -0
  389. package/dist/plan/store.js +2 -1
  390. package/dist/rpc.d.ts +39 -1
  391. package/dist/rpc.js +3 -0
  392. package/dist/sandbox/bash.js +11 -8
  393. package/dist/sandbox/detect.js +14 -11
  394. package/dist/sdk.d.ts +17 -1
  395. package/dist/sdk.js +29 -7
  396. package/dist/session/export.js +31 -30
  397. package/dist/session/manager.d.ts +1 -1
  398. package/dist/session/manager.js +5 -3
  399. package/dist/session/reuse.js +5 -4
  400. package/dist/session/scan.js +3 -2
  401. package/dist/session/stats-aggregate.d.ts +3 -1
  402. package/dist/session/stats-aggregate.js +5 -1
  403. package/dist/session/stats-index.js +2 -1
  404. package/dist/session/stats-scan.d.ts +4 -1
  405. package/dist/session/stats-scan.js +6 -2
  406. package/dist/session/store.d.ts +11 -0
  407. package/dist/session/store.js +48 -1
  408. package/dist/session/types.d.ts +2 -0
  409. package/dist/skills/builtin.js +2 -1
  410. package/dist/tools/image-file.d.ts +26 -1
  411. package/dist/tools/image-file.js +55 -13
  412. package/dist/tools/presets.d.ts +14 -1
  413. package/dist/tools/presets.js +3 -3
  414. package/dist/tools/registry.js +1 -1
  415. package/dist/tools/truncate.d.ts +1 -1
  416. package/dist/tools/truncate.js +2 -2
  417. package/dist/tools/types.d.ts +17 -1
  418. package/dist/trace/build-index.d.ts +91 -0
  419. package/dist/trace/build-index.js +127 -0
  420. package/dist/trace/build-nodes.d.ts +24 -0
  421. package/dist/trace/build-nodes.js +279 -0
  422. package/dist/trace/build-util.d.ts +43 -0
  423. package/dist/trace/build-util.js +120 -0
  424. package/dist/trace/build.d.ts +82 -0
  425. package/dist/trace/build.js +382 -0
  426. package/dist/trace/detail.d.ts +35 -0
  427. package/dist/trace/detail.js +205 -0
  428. package/dist/trace/flatten.d.ts +69 -0
  429. package/dist/trace/flatten.js +173 -0
  430. package/dist/trace/format.d.ts +47 -0
  431. package/dist/trace/format.js +329 -0
  432. package/dist/trace/html-template.d.ts +19 -0
  433. package/dist/trace/html-template.js +150 -0
  434. package/dist/trace/html.d.ts +104 -0
  435. package/dist/trace/html.js +292 -0
  436. package/dist/trace/preview.d.ts +29 -0
  437. package/dist/trace/preview.js +59 -0
  438. package/dist/trace/query-session.d.ts +14 -0
  439. package/dist/trace/query-session.js +38 -0
  440. package/dist/trace/query.d.ts +55 -0
  441. package/dist/trace/query.js +188 -0
  442. package/dist/trace/session.d.ts +40 -0
  443. package/dist/trace/session.js +168 -0
  444. package/dist/trace/types.d.ts +243 -0
  445. package/dist/trace/types.js +13 -0
  446. package/dist/tui/components/editor-paste.d.ts +2 -0
  447. package/dist/tui/components/editor-paste.js +6 -3
  448. package/dist/tui/components/editor.js +2 -2
  449. package/dist/tui/components/loader.d.ts +3 -0
  450. package/dist/tui/components/loader.js +14 -0
  451. package/dist/tui/components/settings-list.d.ts +61 -0
  452. package/dist/tui/components/settings-list.js +135 -0
  453. package/dist/tui/keybindings.d.ts +6 -1
  454. package/dist/tui/keybindings.js +18 -6
  455. package/dist/tui.d.ts +1 -0
  456. package/dist/tui.js +2 -0
  457. package/docs/en/host-api.md +167 -0
  458. package/docs/en/permissions.md +214 -0
  459. package/docs/en/providers.md +625 -0
  460. package/docs/en/rpc.md +361 -0
  461. package/docs/en/sessions.md +219 -0
  462. package/docs/en/tui.md +527 -0
  463. package/docs/host-api.md +18 -17
  464. package/docs/memory.md +172 -0
  465. package/docs/permissions.md +3 -2
  466. package/docs/providers.md +67 -1
  467. package/docs/rpc.md +31 -3
  468. package/docs/session-format.md +8 -2
  469. package/docs/sessions.md +29 -1
  470. package/docs/tui.md +189 -21
  471. package/package.json +8 -3
@@ -0,0 +1,490 @@
1
+ /**
2
+ * 消息目录:report(键名规范见 docs/i18n.md)。[W6-C0 建空壳,W6-I3 迁入]
3
+ *
4
+ * 范围:斜杠命令语义层(`modes/commands-core.ts` 的命令说明与回执)、`/session` `/cache` 报告与缓存提示
5
+ * (`modes/session-report.ts`)、启动期文本问答(`modes/startup-ui-text.ts`)、`ama doctor`。
6
+ *
7
+ * en 是形状源;zh 用 `satisfies Messages<typeof en>`,缺键 / 多键 / 参数不符在 tsc 期报错。
8
+ * 整句一个键、禁止片段拼接;插值写成函数,条件分支写进函数体。
9
+ * `formatTokens` / `formatUsd` / `formatPercent` 的结果、`streaming` / `idle` 之类的枚举值不译。
10
+ */
11
+ import { plural } from "../format.js";
12
+ export const en = {
13
+ /** 内置斜杠命令:`args` 只写需要翻译的占位,说明整句。 */
14
+ commands: {
15
+ help: "List commands",
16
+ new: "Start a new session",
17
+ resume: "Resume a session (pick one when no id)",
18
+ forkArgs: "[entry id]",
19
+ fork: "Fork a new session from an entry",
20
+ compactArgs: "[instructions]",
21
+ compact: "Compact the context",
22
+ rewind: "Rewind the conversation and code to before a message",
23
+ model: "Switch model",
24
+ thinkingArgs: "[level]",
25
+ thinking: "Thinking level off | minimal | low | medium | high | xhigh",
26
+ permissionArgs: "[mode]",
27
+ permission: "Permission mode plan | default | auto-edit | full-auto",
28
+ toolsArgs: "[names…]",
29
+ tools: "List / set active tools",
30
+ hooks: "List loaded hooks",
31
+ session: "Session info, usage and cache",
32
+ cache: "Cache stats; switch warming for this session; print the prefix fingerprint",
33
+ statusline: "Footer info two lines / one line (Ctrl+G)",
34
+ planArgs: "[goal] | approve [mode|fresh] | reject",
35
+ plan: "Show the plan and status; with a goal, enter Plan mode; approve / discard a pending plan",
36
+ tasks: "Sub-agent tasks: status, output, stop",
37
+ agents: "Sub-agent types and external agents (installed, version)",
38
+ paste: "Paste an image from the clipboard (Ctrl+V)",
39
+ exit: "Exit",
40
+ config: "Settings panel; key=value sets one item directly (user level)",
41
+ traceArgs: "[task id]",
42
+ trace: "Trace: timing and usage of turns, requests and tools",
43
+ memoryArgs: "[show|edit|rm <name> | on|off | reload]",
44
+ memory: "Cross-session memory (needs memory.enabled)",
45
+ skillLine: "/skill:<name> [args] Use a skill",
46
+ templateLine: "/<template> [args] Expand a prompt template",
47
+ },
48
+ /** 斜杠命令的回执与用法错误。 */
49
+ command: {
50
+ warmingUnsupported: "this session cannot switch cache warming",
51
+ warming: (mode) => `Warming: ${mode}`,
52
+ warmingInvalid: (modes) => `warming mode must be ${modes.join(" | ")}`,
53
+ warmingSet: (mode) => `Warming: ${mode} (this session)`,
54
+ cacheUsage: "usage: /cache [warm off|streaming|idle | fingerprint]",
55
+ taskStopped: (id) => `Stopped ${id}`,
56
+ tasksUsage: "usage: /tasks [id] | /tasks stop <id>",
57
+ newSession: (id) => `New session ${id}`,
58
+ resumed: (id, messages) => `Resumed session ${id} (${plural(messages, "message")})`,
59
+ forked: (id) => `Forked to new session ${id}`,
60
+ compacted: (before, after) => `Compacted: ${before}${after !== undefined ? ` → ${after}` : ""} tokens`,
61
+ model: (ref) => `Model: ${ref}`,
62
+ thinkingInvalid: (levels) => `thinking level must be ${levels.join(" | ")}`,
63
+ thinking: (level) => `Thinking level: ${level}`,
64
+ permissionInvalid: (modes) => `permission mode must be ${modes.join(" | ")} (display names work too, e.g. "Accept edits")`,
65
+ permissionCancelled: (mode) => `Cancelled; permission mode is still ${mode}`,
66
+ permission: (mode) => `Permission mode: ${mode}`,
67
+ tools: (active, inactive) => `Active: ${active.join(", ") || "(none)"}${inactive.length > 0 ? `\nAvailable: ${inactive.join(", ")}` : ""}`,
68
+ noHooks: "No hooks loaded",
69
+ pasted: (path) => `Pasted image: ${path}`,
70
+ statuslineOnly: "/statusline is only available in the interactive UI",
71
+ },
72
+ /** 启动期文本问答(`--no-tui`、非 TTY)。 */
73
+ startup: {
74
+ more: (count) => ` …${count} more`,
75
+ trustQuestion: (cwd) => `Trust this directory's project resources? ${cwd}`,
76
+ trustChoices: "[y this time / a trust and remember / N don't trust] ",
77
+ resumeQuestion: "Resume which session?",
78
+ resumeAnswer: "Number or id: ",
79
+ pickModel: "Choose a model:",
80
+ pickModelAnswer: "Number or provider/id: ",
81
+ cwdMissing: (path) => `The session's working directory does not exist: ${path}`,
82
+ cwdAnswer: "Replacement directory (empty line cancels): ",
83
+ notDirectory: (path) => `Not a directory: ${path}\n`,
84
+ },
85
+ /** `/session`、`/cache` 报告与缓存提示行。 */
86
+ cache: {
87
+ unreported: "not reported",
88
+ unknown: "unknown",
89
+ reason: (reason) => {
90
+ switch (reason) {
91
+ case "prefix_changed":
92
+ return "prefix changed";
93
+ case "model_changed":
94
+ return "model switched";
95
+ case "idle":
96
+ return "idle timeout";
97
+ case "subtask":
98
+ return "subtask";
99
+ case "evicted":
100
+ return "evicted by server";
101
+ }
102
+ },
103
+ missIdle: (minutes) => `after ${plural(minutes, "minute")} idle`,
104
+ missSubtask: (minutes) => `after a ${plural(minutes, "minute")} subtask`,
105
+ missModel: "after switching model",
106
+ missTools: "tool list changed",
107
+ missSystem: "system prompt changed",
108
+ missPrefix: "prefix changed",
109
+ missEvicted: "evicted by the server",
110
+ missNotice: (reason, tokens, cost) => `Cache miss (${reason}): re-billed ${tokens} tokens${cost === undefined ? "" : ` (about ${cost})`}`,
111
+ pressure: (percent) => `Context ${percent}% used`,
112
+ pressureTurns: (percent, turns) => `Context ${percent}% used, about ${plural(turns, "turn")} left (average of the last 5 turns)`,
113
+ pressureTokens: (percent, tokens) => `Context ${percent}% used, ${tokens} tokens left`,
114
+ warmSent: (read, cost) => {
115
+ const parts = [
116
+ ...(read !== undefined ? [`read ${read} tokens`] : []),
117
+ ...(cost !== undefined ? [cost] : []),
118
+ ];
119
+ return `Cache warming refreshed${parts.length > 0 ? ` (${parts.join(", ")})` : ""}`;
120
+ },
121
+ stopReason: (reason) => ({
122
+ retention_none: "cache retention is none",
123
+ payload_replaced: "request body replaced by onPayload",
124
+ thinking_budget: "thinking budget follows max_tokens, cannot replay",
125
+ reporting_unknown: "endpoint has not reported cache yet",
126
+ reporting_silent: "endpoint does not report cache",
127
+ no_ttl: "model catalog has no cache TTL",
128
+ ttl_too_short: "cache TTL too short",
129
+ max_duration: "warming duration limit reached",
130
+ late: "timer fired late",
131
+ off: "off",
132
+ stale: "context changed",
133
+ declined: "declined by host",
134
+ error: "warming request failed",
135
+ no_cache_hits: "consecutive warmings with zero hits",
136
+ no_price: "no price, cannot compute economics",
137
+ below_min_savings: "expected savings below threshold",
138
+ })[reason] ?? reason,
139
+ stopped: "stopped",
140
+ stoppedWith: (reason) => `stopped: ${reason}`,
141
+ next: (duration) => `next in ${duration}`,
142
+ savings: (amount, floor) => `expected savings ${amount}${floor === undefined ? "" : ` ≥ ${floor}`}`,
143
+ pending: "waiting for the next request",
144
+ sent: (count, cost) => `sent ${count}× ${cost}`,
145
+ missesNone: "0",
146
+ misses: (count, tokens, cost, by) => `${count}, re-billed ${tokens} tokens ≈ ${cost}${by !== "" ? ` (${by})` : ""}`,
147
+ keyInput: "Input",
148
+ input: (prompt, read, share, uncached, write) => `${prompt} = cache read ${read}${share !== undefined ? ` (${share})` : ""} + uncached ${uncached}${write !== undefined ? ` (of which written ${write})` : ""}`,
149
+ keyHitRate: "Hit rate",
150
+ sessionRate: (rate) => `session ${rate}`,
151
+ rates: (last, session) => `last ${last} · session ${session}`,
152
+ keyReporting: "Reporting",
153
+ keyMisses: "Misses",
154
+ keyWarming: "Warming",
155
+ keyContext: "Context",
156
+ context: (percent, remaining, turns) => `${percent}%${remaining !== undefined ? `, ≈ ${remaining} tokens left` : ""}${turns !== undefined ? ` ≈ ${plural(turns, "turn")}` : ""}`,
157
+ keySubtasks: "Subtasks",
158
+ subtasks: (count, rate, rebilled) => `${plural(count, "session")}, hit rate ${rate}${rebilled !== undefined ? `, re-billed ${rebilled} tokens` : ""}`,
159
+ title: "Cache",
160
+ },
161
+ /** `/session` 的其余段。 */
162
+ session: {
163
+ externalTokens: (tokens) => `${tokens} tokens`,
164
+ externalRequests: (count) => plural(count, "request"),
165
+ external: (runs, amount, tokens) => `${plural(runs, "run")} · ${amount}${tokens !== undefined ? ` · ${tokens} tokens` : ""}`,
166
+ tasks: (total) => plural(total, "task"),
167
+ running: (count) => `running ${count}`,
168
+ status: (status, count) => {
169
+ const labels = {
170
+ completed: "completed",
171
+ failed: "failed",
172
+ aborted: "stopped",
173
+ max_turns: "out of turns",
174
+ interrupted: "interrupted",
175
+ };
176
+ return `${labels[status] ?? status} ${count}`;
177
+ },
178
+ tasksLine: (parts) => `${parts.join(" · ")} (/tasks)`,
179
+ keySession: "Session",
180
+ session: (id, file) => `${id}${file !== undefined ? ` (${file})` : " (not saved)"}`,
181
+ keyModel: "Model",
182
+ model: (model, thinking, permission) => `${model} · thinking ${thinking} · permission ${permission}`,
183
+ keyMessages: "Messages",
184
+ messages: (user, assistant, tools) => `user ${user} · assistant ${assistant} · tool calls ${tools}`,
185
+ keyUsage: "Usage",
186
+ usage: (input, output, cacheRead, cacheWrite, cost) => `input ${input} · output ${output} · cache read ${cacheRead} · cache write ${cacheWrite} · ${cost}`,
187
+ keyContext: "Context",
188
+ context: (tokens, window, percent) => `${tokens} / ${window} (${percent}%)`,
189
+ keyAgents: "Sub-agents",
190
+ externalTitle: "External agents",
191
+ noFingerprint: "This session does not provide a prefix fingerprint",
192
+ noRequestYet: "No real request yet (the fingerprint is recorded after the first request)",
193
+ fingerprintTitle: "Prefix fingerprint (last request)",
194
+ },
195
+ /** `ama doctor`。 */
196
+ doctor: {
197
+ usage: "Usage: ama doctor [--profile <file>] [--auth-file <file>] [--trust | --no-trust]\n",
198
+ missing: (label, path) => `${label}: ${path} (does not exist)`,
199
+ labeled: (label, text) => `${label}: ${text}`,
200
+ keySource: (source, origin) => `${source}${origin !== undefined ? ` (${origin})` : ""}`,
201
+ hookCommand: (command, ms) => `${command} (${ms} ms)`,
202
+ codemode: (mode, reason) => `codemode: ${mode} (${reason})`,
203
+ warning: (text) => `warning: ${text}`,
204
+ trustTitle: "Trust",
205
+ fromCli: "command line",
206
+ noRecord: "default: no record, interactive mode will ask",
207
+ trustInvalid: "trust.json is invalid",
208
+ trust: (cwd, trusted, from) => `${cwd}: ${trusted ? "trusted" : "not trusted"} (${from})`,
209
+ gated: (trusted) => `Resources that need trust${trusted ? "" : " (not loaded now)"}:`,
210
+ keysTitle: "Key sources (sources only, never values)",
211
+ authMode: (mode, path) => `auth.json mode ${mode}, should be 600: ${path}`,
212
+ none: "none",
213
+ notNeeded: "not needed",
214
+ baseUrlEnv: (env, url) => `baseUrl from environment variable ${env}: ${url} (compat uses conservative defaults)`,
215
+ model: (ref, reason) => `Model to use: ${ref ?? "(none)"} (${reason})`,
216
+ registry: (error) => `provider registry: ${error}`,
217
+ envVars: (names) => `Environment variables: ${names.length > 0 ? names.join(", ") : "(none)"}`,
218
+ empty: "(none)",
219
+ hookSkipped: (path) => `not trusted, skipped: ${path}`,
220
+ terminalTitle: "Terminal",
221
+ tty: (stdin, stdout) => `stdin TTY: ${stdin ? "yes" : "no"} · stdout TTY: ${stdout ? "yes" : "no"}`,
222
+ term: (term, colorterm) => `TERM=${term ?? "(unset)"} · COLORTERM=${colorterm ?? "(unset)"}`,
223
+ noColor: "NO_COLOR is set: no colors",
224
+ tmux: "running inside tmux",
225
+ size: (columns, rows) => `Size: ${columns}×${rows}`,
226
+ defaultUi: (tui) => `Default UI: ${tui ? "terminal UI" : "line mode (same as --no-tui)"}`,
227
+ language: (locale, source) => `UI language: ${locale} (source ${source})`,
228
+ languageSource: (kind, name, value) => kind === "cli"
229
+ ? "--lang"
230
+ : kind === "config"
231
+ ? "ui.language"
232
+ : kind === "default"
233
+ ? "default"
234
+ : `${name}=${value}`,
235
+ proxyTitle: "Proxy",
236
+ fileHistory: (blobs, size, shadow, dir) => `file-history: ${plural(blobs, "backup")}, ${size}${shadow !== undefined ? `; ${shadow}` : ""} (${dir}; ama sessions prune cleans up)`,
237
+ shadowRepos: (repos, size) => `${plural(repos, "shadow repo")}, ${size}`,
238
+ fileHistoryFailed: (error) => `file-history: failed to read (${error})`,
239
+ dirsTitle: "Directories",
240
+ configDir: (path) => `Config directory: ${path}`,
241
+ dataDir: (path, exists) => `Data directory: ${path}${exists ? "" : " (not created yet)"}`,
242
+ layersTitle: "Config layers (defaults ← user ← profile ← project (tighten only) ← command line)",
243
+ builtinDefaults: "defaults: built in",
244
+ userLevel: "user",
245
+ projectLevel: "project",
246
+ tightened: (text) => ` tightened: ${text}`,
247
+ permissionMode: (mode) => `Effective permission mode: ${mode}`,
248
+ osSandbox: (kind, detail, networkOnly) => `OS sandbox: ${kind === "none" ? "none" : kind} (${detail}${networkOnly ? "; network only" : ""})`,
249
+ bashSandbox: (detail) => `bash sandbox: ${detail}`,
250
+ contextTitle: "Context files (AGENTS.md, outer first)",
251
+ contextUser: "user",
252
+ contextProject: "project",
253
+ userHooks: (path) => `User hooks.json: ${path}`,
254
+ },
255
+ };
256
+ export const zh = {
257
+ commands: {
258
+ help: "列出命令",
259
+ new: "新建会话",
260
+ resume: "恢复会话(无 id 时选择)",
261
+ forkArgs: "[条目 id]",
262
+ fork: "从某条目分叉出新会话",
263
+ compactArgs: "[说明]",
264
+ compact: "压缩上下文",
265
+ rewind: "回滚对话与代码到某条消息之前",
266
+ model: "切换模型",
267
+ thinkingArgs: "[级别]",
268
+ thinking: "思考级别 off | minimal | low | medium | high | xhigh",
269
+ permissionArgs: "[模式]",
270
+ permission: "权限模式 plan | default | auto-edit | full-auto",
271
+ toolsArgs: "[名字…]",
272
+ tools: "列出 / 设置活动工具",
273
+ hooks: "列出已加载的 Hook",
274
+ session: "会话信息、用量与缓存",
275
+ cache: "缓存统计;切换本会话保温;打印前缀指纹",
276
+ statusline: "底部信息行两行 / 一行(Ctrl+G)",
277
+ planArgs: "[目标] | approve [模式|fresh] | reject",
278
+ plan: "查看计划与状态;带目标进入 Plan 模式;批准 / 放弃待审批的计划",
279
+ tasks: "子 Agent 任务:状态、输出、停止",
280
+ agents: "子 Agent 类型与外部 Agent(安装状态、版本)",
281
+ paste: "粘贴剪贴板里的图片(Ctrl+V)",
282
+ exit: "退出",
283
+ config: "设置面板;key=value 直接设一项(用户级)",
284
+ traceArgs: "[任务 id]",
285
+ trace: "轨迹:回合、请求与工具的耗时和用量",
286
+ memoryArgs: "[show|edit|rm <名字> | on|off | reload]",
287
+ memory: "跨会话记忆(需开启 memory.enabled)",
288
+ skillLine: "/skill:<名字> [参数] 使用 Skill",
289
+ templateLine: "/<模板名> [参数] 展开提示模板",
290
+ },
291
+ command: {
292
+ warmingUnsupported: "当前会话不支持切换保温",
293
+ warming: (mode) => `保温:${mode}`,
294
+ warmingInvalid: (modes) => `保温模式应为 ${modes.join(" | ")}`,
295
+ warmingSet: (mode) => `保温:${mode}(本会话)`,
296
+ cacheUsage: "用法:/cache [warm off|streaming|idle | fingerprint]",
297
+ taskStopped: (id) => `已停止 ${id}`,
298
+ tasksUsage: "用法:/tasks [id] | /tasks stop <id>",
299
+ newSession: (id) => `已新建会话 ${id}`,
300
+ resumed: (id, messages) => `已恢复会话 ${id}(${messages} 条消息)`,
301
+ forked: (id) => `已分叉到新会话 ${id}`,
302
+ compacted: (before, after) => `已压缩:${before}${after !== undefined ? ` → ${after}` : ""} token`,
303
+ model: (ref) => `模型:${ref}`,
304
+ thinkingInvalid: (levels) => `思考级别应为 ${levels.join(" | ")}`,
305
+ thinking: (level) => `思考级别:${level}`,
306
+ permissionInvalid: (modes) => `权限模式应为 ${modes.join(" | ")}(也可写显示名,如 "Accept edits")`,
307
+ permissionCancelled: (mode) => `已取消,权限模式仍为 ${mode}`,
308
+ permission: (mode) => `权限模式:${mode}`,
309
+ tools: (active, inactive) => `活动:${active.join(", ") || "(无)"}${inactive.length > 0 ? `\n可用:${inactive.join(", ")}` : ""}`,
310
+ noHooks: "没有已加载的 Hook",
311
+ pasted: (path) => `已粘贴图片:${path}`,
312
+ statuslineOnly: "/statusline 只在交互界面可用",
313
+ },
314
+ startup: {
315
+ more: (count) => ` …另有 ${count} 项`,
316
+ trustQuestion: (cwd) => `信任这个目录的项目资源?${cwd}`,
317
+ trustChoices: "[y 仅本次 / a 信任并记住 / N 不信任] ",
318
+ resumeQuestion: "恢复哪个会话?",
319
+ resumeAnswer: "编号或 id:",
320
+ pickModel: "选择模型:",
321
+ pickModelAnswer: "编号或 provider/id:",
322
+ cwdMissing: (path) => `会话的工作目录不存在:${path}`,
323
+ cwdAnswer: "替代目录(空行取消):",
324
+ notDirectory: (path) => `不是目录:${path}\n`,
325
+ },
326
+ cache: {
327
+ unreported: "未报告",
328
+ unknown: "未知",
329
+ reason: (reason) => {
330
+ switch (reason) {
331
+ case "prefix_changed":
332
+ return "前缀变化";
333
+ case "model_changed":
334
+ return "切换模型";
335
+ case "idle":
336
+ return "空闲超时";
337
+ case "subtask":
338
+ return "子任务";
339
+ case "evicted":
340
+ return "服务端淘汰";
341
+ }
342
+ },
343
+ missIdle: (minutes) => `空闲 ${minutes} 分钟后`,
344
+ missSubtask: (minutes) => `子任务运行 ${minutes} 分钟后`,
345
+ missModel: "切换模型后",
346
+ missTools: "工具表变化",
347
+ missSystem: "系统提示变化",
348
+ missPrefix: "前缀变化",
349
+ missEvicted: "服务端已淘汰",
350
+ missNotice: (reason, tokens, cost) => `缓存未命中(${reason}):重计费 ${tokens} token${cost === undefined ? "" : `(约 ${cost})`}`,
351
+ pressure: (percent) => `上下文已用 ${percent}%`,
352
+ pressureTurns: (percent, turns) => `上下文已用 ${percent}%,约剩 ${turns} 回合(按最近 5 回合均值)`,
353
+ pressureTokens: (percent, tokens) => `上下文已用 ${percent}%,余量 ${tokens} token`,
354
+ warmSent: (read, cost) => {
355
+ const text = `${read !== undefined ? `读 ${read} token` : ""}${cost !== undefined ? `${read !== undefined ? "," : ""}${cost}` : ""}`;
356
+ return `缓存保温已刷新${text !== "" ? `(${text})` : ""}`;
357
+ },
358
+ stopReason: (reason) => ({
359
+ retention_none: "缓存保留为 none",
360
+ payload_replaced: "请求体被 onPayload 替换",
361
+ thinking_budget: "思考预算随 max_tokens,不可重放",
362
+ reporting_unknown: "端点还没报过缓存",
363
+ reporting_silent: "端点不报缓存",
364
+ no_ttl: "模型目录没有缓存 TTL",
365
+ ttl_too_short: "缓存 TTL 太短",
366
+ max_duration: "已达保温时长上限",
367
+ late: "计时器迟到",
368
+ off: "已关闭",
369
+ stale: "上下文已变",
370
+ declined: "宿主否决",
371
+ error: "保温请求失败",
372
+ no_cache_hits: "连续保温零命中",
373
+ no_price: "缺价格,经济性不可算",
374
+ below_min_savings: "期望节省低于门槛",
375
+ })[reason] ?? reason,
376
+ stopped: "已停止",
377
+ stoppedWith: (reason) => `已停止:${reason}`,
378
+ next: (duration) => `下次 ${duration}`,
379
+ savings: (amount, floor) => `期望节省 ${amount}${floor === undefined ? "" : ` ≥ ${floor}`}`,
380
+ pending: "待下一次请求",
381
+ sent: (count, cost) => `已发 ${count} 次 ${cost}`,
382
+ missesNone: "0 次",
383
+ misses: (count, tokens, cost, by) => `${count} 次,重计费 ${tokens} token ≈ ${cost}${by !== "" ? `(${by})` : ""}`,
384
+ keyInput: "输入",
385
+ input: (prompt, read, share, uncached, write) => `${prompt} = 缓存读 ${read}${share !== undefined ? `(${share})` : " "}+ 未缓存 ${uncached}${write !== undefined ? `(其中写入 ${write})` : ""}`,
386
+ keyHitRate: "命中率",
387
+ sessionRate: (rate) => `会话 ${rate}`,
388
+ rates: (last, session) => `最近 ${last} · 会话 ${session}`,
389
+ keyReporting: "报告状态",
390
+ keyMisses: "未命中",
391
+ keyWarming: "保温",
392
+ keyContext: "上下文",
393
+ context: (percent, remaining, turns) => `${percent}%${remaining !== undefined ? `,余量 ≈ ${remaining} token` : ""}${turns !== undefined ? ` ≈ ${turns} 回合` : ""}`,
394
+ keySubtasks: "子任务",
395
+ subtasks: (count, rate, rebilled) => `${count} 个会话,命中率 ${rate}${rebilled !== undefined ? `,重计费 ${rebilled} token` : ""}`,
396
+ title: "缓存",
397
+ },
398
+ session: {
399
+ externalTokens: (tokens) => `${tokens} token`,
400
+ externalRequests: (count) => `${count} 次请求`,
401
+ external: (runs, amount, tokens) => `${runs} 次运行 · ${amount}${tokens !== undefined ? ` · ${tokens} token` : ""}`,
402
+ tasks: (total) => `${total} 个任务`,
403
+ running: (count) => `运行中 ${count}`,
404
+ status: (status, count) => {
405
+ const labels = {
406
+ completed: "完成",
407
+ failed: "失败",
408
+ aborted: "已停止",
409
+ max_turns: "轮数耗尽",
410
+ interrupted: "已中断",
411
+ };
412
+ return `${labels[status] ?? status} ${count}`;
413
+ },
414
+ tasksLine: (parts) => `${parts.join(" · ")}(/tasks)`,
415
+ keySession: "会话",
416
+ session: (id, file) => `${id}${file !== undefined ? `(${file})` : "(未落盘)"}`,
417
+ keyModel: "模型",
418
+ model: (model, thinking, permission) => `${model} · 思考 ${thinking} · 权限 ${permission}`,
419
+ keyMessages: "消息",
420
+ messages: (user, assistant, tools) => `用户 ${user} · 助手 ${assistant} · 工具调用 ${tools}`,
421
+ keyUsage: "用量",
422
+ usage: (input, output, cacheRead, cacheWrite, cost) => `输入 ${input} · 输出 ${output} · 缓存读 ${cacheRead} · 缓存写 ${cacheWrite} · ${cost}`,
423
+ keyContext: "上下文",
424
+ context: (tokens, window, percent) => `${tokens} / ${window}(${percent}%)`,
425
+ keyAgents: "子 Agent",
426
+ externalTitle: "外部 Agent",
427
+ noFingerprint: "当前会话不提供前缀指纹",
428
+ noRequestYet: "还没有真实请求(指纹在第一次请求后记录)",
429
+ fingerprintTitle: "前缀指纹(最近一次请求)",
430
+ },
431
+ doctor: {
432
+ usage: "用法:ama doctor [--profile <文件>] [--auth-file <文件>] [--trust | --no-trust]\n",
433
+ missing: (label, path) => `${label}:${path}(不存在)`,
434
+ labeled: (label, text) => `${label}:${text}`,
435
+ keySource: (source, origin) => `${source}${origin !== undefined ? `(${origin})` : ""}`,
436
+ hookCommand: (command, ms) => `${command}(${ms} ms)`,
437
+ codemode: (mode, reason) => `codemode:${mode}(${reason})`,
438
+ warning: (text) => `警告:${text}`,
439
+ trustTitle: "信任",
440
+ fromCli: "命令行",
441
+ noRecord: "缺省:无记录,交互模式会询问",
442
+ trustInvalid: "trust.json 无效",
443
+ trust: (cwd, trusted, from) => `${cwd}:${trusted ? "已信任" : "未信任"}(${from})`,
444
+ gated: (trusted) => `需要信任的资源${trusted ? "" : "(当前不加载)"}:`,
445
+ keysTitle: "Key 来源(只显示来源,不显示值)",
446
+ authMode: (mode, path) => `auth.json 权限 ${mode},应为 600:${path}`,
447
+ none: "无",
448
+ notNeeded: "无需",
449
+ baseUrlEnv: (env, url) => `baseUrl 来自环境变量 ${env}:${url}(compat 按保守缺省)`,
450
+ model: (ref, reason) => `将使用的模型:${ref ?? "(无)"}(${reason})`,
451
+ registry: (error) => `供应商注册表:${error}`,
452
+ envVars: (names) => `环境变量:${names.length > 0 ? names.join(", ") : "(无)"}`,
453
+ empty: "(无)",
454
+ hookSkipped: (path) => `未信任,跳过:${path}`,
455
+ terminalTitle: "终端",
456
+ tty: (stdin, stdout) => `stdin TTY:${stdin ? "是" : "否"} · stdout TTY:${stdout ? "是" : "否"}`,
457
+ term: (term, colorterm) => `TERM=${term ?? "(未设置)"} · COLORTERM=${colorterm ?? "(未设置)"}`,
458
+ noColor: "NO_COLOR 已设置:不输出颜色",
459
+ tmux: "在 tmux 中运行",
460
+ size: (columns, rows) => `尺寸:${columns}×${rows}`,
461
+ defaultUi: (tui) => `缺省界面:${tui ? "终端界面" : "行式(--no-tui 等价)"}`,
462
+ language: (locale, source) => `界面语言:${locale}(来源 ${source})`,
463
+ languageSource: (kind, name, value) => kind === "cli"
464
+ ? "--lang"
465
+ : kind === "config"
466
+ ? "ui.language"
467
+ : kind === "default"
468
+ ? "缺省"
469
+ : `${name}=${value}`,
470
+ proxyTitle: "代理",
471
+ fileHistory: (blobs, size, shadow, dir) => `file-history:${blobs} 个备份,${size}${shadow !== undefined ? `;${shadow}` : ""}(${dir};ama sessions prune 清理)`,
472
+ shadowRepos: (repos, size) => `影子仓库 ${repos} 个,${size}`,
473
+ fileHistoryFailed: (error) => `file-history:读取失败(${error})`,
474
+ dirsTitle: "目录",
475
+ configDir: (path) => `配置目录:${path}`,
476
+ dataDir: (path, exists) => `数据目录:${path}${exists ? "" : "(尚未创建)"}`,
477
+ layersTitle: "配置层级(缺省 ← 用户级 ← profile ← 项目级(只能收紧)← 命令行)",
478
+ builtinDefaults: "缺省:内置",
479
+ userLevel: "用户级",
480
+ projectLevel: "项目级",
481
+ tightened: (text) => ` 收紧:${text}`,
482
+ permissionMode: (mode) => `有效权限模式:${mode}`,
483
+ osSandbox: (kind, detail, networkOnly) => `操作系统沙箱:${kind === "none" ? "无" : kind}(${detail}${networkOnly ? ";只隔离网络" : ""})`,
484
+ bashSandbox: (detail) => `bash 沙箱:${detail}`,
485
+ contextTitle: "上下文文件(AGENTS.md,外层在前)",
486
+ contextUser: "用户级",
487
+ contextProject: "项目",
488
+ userHooks: (path) => `用户级 hooks.json:${path}`,
489
+ },
490
+ };