@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
package/docs/en/tui.md ADDED
@@ -0,0 +1,527 @@
1
+ # Terminal UI
2
+
3
+ English · [简体中文](../tui.md)
4
+
5
+ > Translated from the Chinese [docs/tui.md](../tui.md) as of commit `6a7b5eb`. When the two differ, the Chinese version is
6
+ > authoritative. Screens below are illustrative; the exact interface wording follows the interface language
7
+ > (`ui.language`, `--lang`, `AMA_LANG`).
8
+
9
+ How to use interactive mode, plus the API of the terminal component library `@armadra/agent/tui`. The design rationale is in [design.md](../design.md) §12 (Chinese).
10
+
11
+ Running `ama` directly in a terminal (stdin / stdout both TTYs, `TERM` not `dumb`, no `--no-tui`) enters interactive mode. The interface uses the **main screen** only: the conversation history scrolls into the terminal scrollback without switching to the alternate screen, so `capture-pane` in tmux can read the whole conversation, and it stays on screen after exit.
12
+
13
+ ## Layout
14
+
15
+ The visual spec (colors, glyphs, screen-by-screen mockups) is in [tui-design.md](../tui-design.md) (Chinese). Hierarchy is expressed by indentation: column 0 holds the user `›`, the tool `⏺` and notice symbols, column 2 the result connector `⎿`, column 4 the tool output; the structure stays readable without colors (`NO_COLOR`, `capture-pane` without `-e`).
16
+
17
+ ```
18
+ ╭──────────────────────────────────────────────────────────────╮
19
+ │ ✻ ama 0.3.0 │ ← startup header (normal)
20
+ │ │
21
+ │ Model anthropic/claude-sonnet-4-5 · thinking medium │
22
+ │ Dir ~/Projects/demo · trusted (trust.json) │
23
+ │ Mode Accept edits · preset default │
24
+ │ Loaded AGENTS.md · 2 Skills │
25
+ │ │
26
+ │ /help commands · Shift+Tab mode · Ctrl+O expand tool output │
27
+ ╰──────────────────────────────────────────────────────────────╯
28
+
29
+ › read the README ← user message (continuation lines indented 2)
30
+
31
+ ✻ Thinking · 120 tokens ← thinking block (folded; Ctrl+O expands)
32
+
33
+ ⏺ read README.md ← tool call: ⏺ tool name summary
34
+ ⎿ Read 5 lines ← one-line result summary
35
+ 1 # Demo ← output body (indented 4)
36
+ … 2 more lines (Ctrl+O to expand)
37
+ ⏺ bash pnpm test ← no blank line between adjacent tool calls
38
+ ⎿ ⠋ running · 4s
39
+
40
+ ↳ after also update the docs ← queued message
41
+ Alt+↑ recall · Esc restore and interrupt
42
+ ⠋ running bash · 4s · Esc to interrupt ← running verb
43
+ ────────────────────────────────────────────────
44
+ › Type a message, / commands, @ files, Shift+Enter newline ← input box (placeholder)
45
+ ────────────────────────────────────────────────
46
+ tps: 100 tok/s • 546 tok / 5.5s (avg 100 · ttft 1.4s) ↑12k ↓1.2k · cache 80% ♨ · [-] ← rate line (full)
47
+ Accept edits claude-opus-5-5 medium | Ctx 3.0% | proj ⎇ main 5ae9e54 (+12,-3) | $0.26 | 2h24m
48
+ ```
49
+
50
+ - **User messages**: start with `›`, continuation lines indented 2 columns; steers while running are marked `↳ steer`, messages queued after this turn `↳ after`, and messages injected by the host (the Armadra canvas) `↳ host` (the `origin` in the session file stays steer / followUp / host).
51
+ - **Thinking blocks**: `ui.showThinking` = `collapsed` (default: "thinking…" → "thinking · 1.2k tokens", `Ctrl+O` expands it to an indented body of at most 60 lines) / `full` (always expanded) / `hidden`.
52
+ - **Tool calls**: titled `⏺ tool name summary`; `⏺` is the accent color while running, green on success, red on failure. The second line after `⎿` is the result summary: lines read, `N changes · +a −b`, `exit 0 · 2.1s · 48 lines`, matches and files, `N inner calls · M lines of script output`, `sub-agent · running 1m05s` / `done · 1m42s · ↑28k ↓4.1k`; while running the summary line carries a spinner in the same frame as the bottom and the seconds. Bodies show the first 3 lines folded; `edit` shows a diff (first 12 lines, with line numbers at ≥ 60 columns); running `bash` scrolls its last 8 lines. `Ctrl+O` expands / folds everything (thinking blocks included). Inner calls of a codemode script hang under the outer call (folded, only the titles and summaries of the latest 5 are listed).
53
+ - **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`).
54
+ - **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.
55
+ - **Status bar**: always the last line, with the mode always on the far left. 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).
56
+ - **`full` top line (rate line)**: `tps: <rate> tok/s • <output tokens> tok / <elapsed> (avg <session average> · ttft <time to first token>)`. 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; in ASCII `•` becomes `*`. The right side holds usage items: `↑` input (including cache reads and writes) `↓` output · cache · re-billing · queue count · codemode · tool preset (when not default) · host status, with `[-]` at the end hinting that it folds. Only chat requests count (compaction summaries, warming and the classifier do not). When narrow, these drop in order: output / elapsed, codemode, queue count, tokens, cache, re-billing, preset, host status, avg, ttft; `tps` and `[-]` never drop.
57
+ - **`full` bottom line**: on the left `permission mode | shift+tab to switch`, on the right `model thinking-level | Ctx 3.0% | <dir name> ⎇ <branch> <short commit> (+a,-d) | $cost | session duration` (Ctx with one decimal, no meter even when wide); when narrow, these drop in order: the switch hint, thinking level, line changes, directory name, branch and commit, duration, cost, context, model.
58
+ - **`compact`**: one line; on the right model · thinking level · `↑ ↓` · cache · cost · re-billing · context usage · dir ⎇ branch commit +a −b · session duration · queue count · codemode · preset · host status; when narrow, these drop in order: the switch hint, host status, preset, re-billing, cost, cache, tokens, thinking level, queue count, codemode, line changes, directory name, branch and commit, duration, context, model.
59
+ - **git**: branch and short commit are read directly from `.git/HEAD` (worktrees understood; detached shows only the short commit; outside git the whole part is omitted, leaving only the directory name). `+a −b` is the working tree (staged included) line diff against HEAD, computed in the background with `git diff --numstat HEAD` after a turn ends, a writing tool finishes, a rewind or `/tree`, at most once every 10 seconds; if it takes longer than 2 seconds or fails, line changes are hidden for the rest of the session; `AMA_STATUS_GIT=0` turns it off.
60
+ - **Cost** includes sub-tasks, warming, the classifier and external agent usage priced in USD (other units only in `/session`); **duration** counts from when this process opened the current session (`Ns` / `Nm` / `NhMm`).
61
+ - When bash commands run in the OS sandbox (`sandbox.bash: "auto"` and available on this machine, see [sandbox.md](../sandbox.md), Chinese), the usage items gain a sandbox marker, dropped first together with codemode when space runs out.
62
+ - During a model fallback (`fallbackModel`: when the main model is overloaded or retries are exhausted, one retry with the fallback model) the model item shows `main model → fallback model` (the fallback in yellow); it disappears once the fallback model replies and the main model is restored, and the message area gets an explanatory line.
63
+ - Model names abbreviate with width (provider dropped below 100 columns, channel below 60, version suffix below 48); `compact` at ≥ 110 columns shows context as a meter `ctx ▮▮▮▯▯▯▯▯▯▯ 34%`; changing numbers reserve their widest shape, so items never flicker in and out as values change. In ASCII mode `⎇` → `git`, `−` → `-`, `♨` → `~`.
64
+ - **Exit**: a session summary line and the resume command are appended at the end of the message area and stay in the terminal scrollback:
65
+
66
+ ```
67
+ ─ session 3f2a9c1e · 12 min · 7 turns · ↑128k ↓9.4k · cache 81% · $0.42 (re-billed $0.03)
68
+ resume: ama --resume 3f2a9c1e
69
+ ```
70
+
71
+ ## Cache and context
72
+
73
+ Status bar items:
74
+
75
+ | Item | Meaning |
76
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
+ | `cache 83%` | Hit rate of the **latest** request (cache read / (input + cache read + cache write)); the session total is in `/session` |
78
+ | `cache —` | The endpoint has not reported cache usage yet (`unknown`: no long enough comparable request so far) |
79
+ | `cache` "not reported" | The endpoint does not report cache usage (`silent`: reads and writes were 0 for 3 comparable requests in a row, or `compat.cacheReporting: "silent"`); such requests stay out of the hit-rate denominator |
80
+ | `♨` | Warming timer running (during long tool runs the prefix is replayed per TTL; `/cache warm` switches it) |
81
+ | `rebill $0.11` | Re-billing caused by cache misses in this session; token count for models without prices; hidden when 0 |
82
+ | `ctx 72%` | Context usage: green below 70%, yellow at ≥ 70%, red at ≥ 90%; `ctx ?` means the model has no window information |
83
+ | `codemode only` | codemode active (`on` / `only`); a red `net!` is appended when the network is not isolated (Node 22 / 24 without an OS sandbox, see sandbox.md) |
84
+
85
+ The message area (stderr with an `ama: ` prefix in line mode) shows one line in only two cases; `cache.missNotices: false` turns them off:
86
+
87
+ - One miss re-bills ≥ 20k tokens or ≥ $0.10, e.g. "cache miss (after 7 minutes idle): re-billed 38.2k tokens (about $0.11)". Causes are idle timeout, a sub-task running, a model switch, a system prompt / tool table change, server eviction; smaller misses only go into the stats.
88
+ - Context usage crosses 70% / 90% (once each), e.g. "context 72% used, about 9 turns left (average of the last 5 turns)"; when turns cannot be estimated, the remaining tokens are given.
89
+ - In line mode with `AMA_LOG=info`, successful warming is also written, e.g. "cache warmed (read 12k tokens, $0.001)".
90
+
91
+ `/session` draws a left-bar panel in the message area with a "Cache" section after the session information; `/cache` shows only that section (line mode and RPC get the same content as plain text):
92
+
93
+ ```
94
+ ▎ Session 3f2a9c1e ~/.local/share/ama/sessions/…/3f2a9c1e.jsonl
95
+ ▎ Model anthropic/claude-sonnet-4-5 · thinking medium · permission Accept edits
96
+ ▎ Messages user 7 · assistant 9 · tool calls 23
97
+ ▎ Usage input 3.4k · output 9.4k · cache read 118k · cache write 6.2k · $0.42
98
+ ▎ Context ▮▮▮▯▯▯▯▯▯▯ 34% · 68k / 200k
99
+ ▎
100
+ ▎ Cache
101
+ ▎ Input 3.4k = cache read 2.2k (65%) + uncached 1.2k
102
+ ▎ Reporting reported
103
+ ▎ Hit rate latest 84% · session 65%
104
+ ▎ Misses 0
105
+ ▎ Warming streaming · stopped: the model catalog has no cache TTL
106
+ ▎ Context 1%, remaining ≈ 127k tokens ≈ 2443 turns
107
+ ```
108
+
109
+ The misses line is broken down by cause (`3, re-billed 61k tokens ≈ $0.18 (idle timeout 2 · prefix change 1)`); while the warming timer runs, the warming line shows `streaming · next in 2m 10s · expected saving $0.18 ≥ $0.05`, and when stopped it gives the reason; with task sub-sessions there is an extra "Sub-tasks" line.
110
+
111
+ - `/cache warm off|streaming|idle`: switch warming for this session (the config is not written; `idle` also warms while idle, for expensive models).
112
+ - `/cache fingerprint`: the prefix fingerprint of the latest real request: one 16-character hash each for the system prompt and the tool table, plus the model name. If a hash changed between two requests, the host or a hook modified the system prompt / tool table mid-session.
113
+
114
+ Trade-offs: the status bar shows the latest hit rate (the session total lives in `/session`); `cache.missNotices` is on by default (the thresholds make it rare); the `Meter` component is not in the default status bar. The rules for hit rate, misses and warming are in [providers.md](providers.md) "Caching".
115
+
116
+ `ama models cache-probe <provider/model>` sends two minimal requests with a fixed prefix a few seconds apart, classifies the endpoint as `reported` / `silent` / `inconclusive` and suggests configuration (this is billed: an estimate is printed first, and non-interactive use needs `--yes`).
117
+
118
+ ## Keys
119
+
120
+ | Key | Effect |
121
+ | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
122
+ | Enter | Send; while running = steer (inserted into the current turn) |
123
+ | Alt+Enter | While running, queue after this turn (followUp); when idle, same as Enter |
124
+ | Shift+Enter / Ctrl+J | New line |
125
+ | Esc | Interrupt: queued messages go back into the input box, then the current run stops; closes completion first when it is open |
126
+ | Esc Esc (idle) | Empty input: open the rewind list (same as `/rewind`); with text: clear it and save it into input history |
127
+ | Alt+↑ | Recall the last queued message |
128
+ | Shift+Tab / Tab | Cycle permission modes Manual → Accept edits → Plan → Auto → Bypass permissions (Tab only on an empty input with completion closed, otherwise still completion; entering Bypass asks to confirm, see "Entering Bypass" below) |
129
+ | Ctrl+O | Expand / fold tool output and thinking blocks |
130
+ | Ctrl+L / Ctrl+T | Pick model / thinking level |
131
+ | Ctrl+G | Bottom info line two lines (full) ↔ one line (compact), this session only |
132
+ | Ctrl+V | Paste an image from the clipboard: saved in the data directory, `@<path>` inserted at the cursor (same as `/paste`) |
133
+ | Ctrl+C | Clear the input; on an empty input, press again within 1.5 seconds to quit (exit code 130) |
134
+ | Ctrl+D | Quit on an empty input |
135
+ | Tab | Complete |
136
+ | ↑ / ↓ | Browse history on a single line (`<data dir>/history`, 500 entries) |
137
+ | Ctrl+B / ↓ (empty input) | Enter the agent bar (when there are sub-agent tasks; with text Ctrl+B still moves the cursor left, use ↓ in tmux), see "Sub-agents" (from wave 6 W6-A) |
138
+
139
+ Keys can be overridden in `~/.config/ama/keybindings.json`: keys are action ids (`app.interrupt`, `app.rewind`, `app.message.followUp`, `app.statusLine.toggle`, `app.paste.image`, `app.agents.focus`, `tui.editor.newLine` …), values are a key or an array of keys, and an empty array disables the action. `app.rewind` is the key double-pressed while idle (Esc by default, at most 800 ms apart).
140
+
141
+ ## Rewind
142
+
143
+ Design in [rewind-plan.md](../rewind-plan.md) (Chinese). Every user message that starts a new turn is a rewind point; files changed by edit / write have a checkpoint before the message is sent (`checkpoints.mode`; bash changes are only picked up when the next turn re-snapshots tracked files).
144
+
145
+ - **Entry**: `/rewind`, or double Esc while idle with an empty input box: the first press shows a hint at the bottom to press Esc again to rewind (gone after 1 second), and a second press within 800 ms opens the list. With text in the input box, double Esc clears it instead (with a matching hint), and the text goes into input history, recallable with ↑. While running, Esc still interrupts; when an approval dialog or a picker is open, Esc belongs to them.
146
+ - **Interrupt to withdraw**: when Esc interrupts a run and this turn has no reply text or tool call yet and the input box is empty (`ui.restoreOnCancel`, default true), the message is withdrawn automatically and the original text put back into the input box, with a line in the message area saying the interrupted message was withdrawn.
147
+ - **List**: rewind points on the active path, oldest at the top, newest at the bottom, with the last one selected by default. On the right of the highlighted row is the code change summary (a preview of that row, cached): `3 files +12 −48` / no code changes, `…` while computing, `—` when the preview fails; rows without a checkpoint (in-memory sessions, checkpoints off, beyond the retention count) are marked conversation only.
148
+ - **Confirmation panel**: a left-bar panel at the bottom with the original message (at most 3 lines) and its time, followed by numbered options, each with a preview on the next line:
149
+
150
+ ```
151
+ ▎ Rewind to before this message 3 minutes ago
152
+ ▎ › change the differential rendering in src/tui/tui.ts to compare by line,
153
+ ▎ and add tests
154
+ ▎
155
+ ▎ › 1. Restore code and conversation
156
+ ▎ will restore 3 files +12 −48 · the conversation will fork
157
+ ▎ 2. Restore conversation
158
+ ▎ code unchanged (later changes kept) · the conversation will fork
159
+ ▎ 3. Restore code
160
+ ▎ will restore 3 files +12 −48 · conversation unchanged
161
+ ▎ 4. Summarize from here
162
+ ▎ the conversation forks; the abandoned part becomes a summary
163
+ ▎ 5. Summarize up to here
164
+ ▎ earlier conversation is compacted into a summary, later kept
165
+ ▎ 6. Cancel
166
+ ▎
167
+ ▎ git HEAD changed: 3f2a9c1 → 9e8d7c6 (ama does not touch git)
168
+ ▎ git log --oneline 3f2a9c1e0b7d..HEAD
169
+ ▎ git reset --soft 3f2a9c1e0b7d
170
+ ▎
171
+ ▎ ↑↓ select · 1-6 run directly · Enter confirm · Esc cancel
172
+ ```
173
+
174
+ - The two "restore code" items only appear when the preview has changes. "The conversation will fork": it goes back to before this message, and the original continuation stays in the session tree (reachable via `/tree`); after conversation operations the message area is redrawn and the original message put back into the input box (images are sent with the next message). The model, thinking level and permission mode stay unchanged.
175
+ - The two summary items accept inline instructions: once selected, just type and press Enter to submit; number keys run directly without instructions; with instructions present, Esc clears them first.
176
+ - Conflicts (files changed outside the turn) and unrecoverable files (symbolic links, hard links, moved parent directories, too large to back up …) are listed below the options; choosing a code option with conflicts adds a step: skip conflicting files and restore the rest / overwrite conflicting files / back.
177
+ - When git HEAD differs from what the checkpoint recorded, two commands are shown; ama only shows them and never runs them.
178
+ - **Result**: one notification in the message area (e.g. restored 3 files, skipped 1 (1 conflict); no files restored, skipped 2 (1 symbolic link, 1 moved parent directory); code unchanged), followed by at most 5 lines of skip details; running, no checkpoint and total failure each have their own message (cannot rewind while running, press Esc to interrupt first; this message has no code checkpoint, only the conversation can be restored; no files were restored: …).
179
+ - Below 56 columns the panel drops blank lines and only draws the preview for the selected item. In ASCII mode (`AMA_ASCII=1`) the bar is `|`, the minus `-` and the arrows `^v`.
180
+ - **Line mode** (`--no-tui`): `/rewind` lists numbers (1 = oldest); `/rewind <n> [both|conversation|code] [overwrite]` (default both, conversation when there is no checkpoint; `overwrite` overwrites conflicting files); `/rewind <n> summarize-from|summarize-up-to [instructions]`. A single-line original message goes back into the edit line.
181
+
182
+ ## Commands
183
+
184
+ `/help` lists all commands. Interactive mode also has:
185
+
186
+ - `/rewind`: the rewind list and confirmation panel (see "Rewind" above); with arguments it behaves like line mode.
187
+ - `/tree`: lists every user message in the session (forks indented, `●` marks the current branch); picking one goes back to before it with the text put back into the input box, and sending an edited version creates a new branch.
188
+ - `/fork` (no arguments): also picks a user message, then copies a new session up to before it.
189
+ - `/model`, `/resume`, `/permission` and `/thinking` without arguments open pickers; `/permissions` shows the permission decision order, loaded rules and the latest 20 auto decisions (tier, result, reason).
190
+ - The `/permission` picker, titled permission mode: Manual / Accept edits / Plan / Auto / Bypass permissions / Allowlist only, each with a one-line explanation and number keys 1–6 on the right for direct selection; the current mode is checked `✓`, the default mode from config is marked `Default`, Auto is marked `Recommended`, with a key hint line at the bottom. `/permission auto` and `/permission Accept edits` switch directly. The far left of the status bar is the mode's display name. When auto mode needs confirmation, the approval dialog has an extra line naming the auto rule tier / classifier and the reason. Details in [permissions.md](permissions.md).
191
+ - Pickers have a key hint line at the bottom (`↑↓ select · Enter confirm · Esc cancel`) and a background on the selected row (≥ 256 colors; accent bold with fewer). The `/model` picker checks the current model with `✓` and shows an `(i/n)` count; it groups by "provider · channel" (multi-channel models get one item per channel, non-preferred channels marked `@channel`), and descriptions include context size and `img` (accepts images); `/model packy/kimi-k2.5@messages` switches to a specific channel directly.
192
+ - An `@image-path` in the input (quotes allowed, Tab completes the path), or a pasted / dropped image file path, is sent as an image attachment with the message; when the current model does not accept images an `@` attachment is an error and nothing is sent, while paths without `@` are ignored (see [providers.md](providers.md) "Image input").
193
+ - `/statusline [full|compact]`: switch the bottom info line (without arguments it toggles, same as `Ctrl+G`), this session only; line mode has no bottom info line.
194
+ - `/session`, `/cache`: session usage and cache stats panels (see "Cache and context" above); `/permissions` is a panel too, with allow in green, deny in red and the decision order wrapped and aligned. With sub-agent tasks `/session` gains a "Sub-agents" line (task count and states), and after using external agents an "External agents" section (runs and usage per agent, USD / tokens / requests each in its own unit, never converted).
195
+ - `/plan`: the current plan panel (see "Plan approval" below); `/plan <goal>` enters Plan mode and sends the goal; `/plan approve [mode|fresh]` and `/plan reject` approve / discard directly without a dialog.
196
+ - `/tasks`: focus the agent bar, `/tasks <id>` opens the sub-agent view; `/agents`: the available sub-agent types (see "Sub-agents" below).
197
+ - `/paste`: same as `Ctrl+V`.
198
+
199
+ ## Entering Bypass
200
+
201
+ Before switching to Bypass permissions (`full-auto`), a confirmation box pops up at the bottom, styled like the approval dialog (yellow border):
202
+
203
+ ```
204
+ ╭─ Enter Bypass permissions? ──────────────────────────────────────────────────╮
205
+ │ No tool call will ask anymore: writes, commands and network are allowed │
206
+ │ Only dangerous commands still ask and deny rules still apply; use it only in │
207
+ │ throwaway sandboxes or containers │
208
+ │ │
209
+ │ 1. Enter Bypass y │
210
+ │ › 2. Cancel n Esc │
211
+ │ │
212
+ │ ↑↓ select · Enter confirm · 1-2 pick · Esc cancel │
213
+ ╰──────────────────────────────────────────────────────────────────────────────╯
214
+ ```
215
+
216
+ - Triggers: cycling to Bypass with Tab / Shift+Tab, choosing Bypass in the `/permission` picker, `/permission full-auto`. "Cancel" is selected by default: ↑↓ move, Enter confirms, `1` / `2` or `y` / `n` pick directly, Esc / Ctrl+C cancel (Ctrl+C here does not count as the first press of quitting).
217
+ - Cancelling: while cycling, it **skips Bypass and returns to the start of the cycle, Manual** (with a bottom hint that Bypass was not entered and the mode is Manual), so you can Tab all the way round without entering Bypass and always land on something stricter than Auto; cancelling from the picker or the command keeps the previous mode (with a message saying so).
218
+ - Once confirmed in a run, switching to Bypass again does not ask; if the run started in Bypass (`--permission-mode full-auto`, config, profile) it counts as confirmed and nothing pops up.
219
+ - Below 56 columns blank lines are removed and the key hint shortened; in ASCII mode the border is `+ - |`, the selection marker `>` and the arrows `^v`. Frame goldens: `test/fixtures/tui/bypass-confirm-*.txt`.
220
+ - Line mode (`--no-tui`): `/permission full-auto` first prints the two explanatory lines above, then asks a `[y/N]` question (single key, Enter = N); piped input has no such step.
221
+
222
+ ## Keys for choices and confirmations
223
+
224
+ Every place that asks for a choice supports ↑↓ to move + Enter to confirm, keeping the existing shortcuts:
225
+
226
+ | Where | Keys |
227
+ | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
228
+ | Approval dialog (including the external agent first-run confirmation) | ↑↓ Enter · 1–3 · y / a / n · Esc deny · v full input |
229
+ | Plan approval box (main options, execution mode) | ↑↓ Enter · 1–4 / 1–3 · e edit plan · Esc stay in Plan / back |
230
+ | Rewind confirmation panel, second confirmation for overwriting conflicts | ↑↓ Enter · numbers run directly · Esc cancel / back |
231
+ | Entering Bypass confirmation | ↑↓ Enter · 1–2 · y / n · Esc cancel |
232
+ | Permission mode and thinking level pickers | ↑↓ Enter · numbers pick directly · Esc cancel |
233
+ | Model, session, tree and task pickers | ↑↓ Enter · type to filter · Esc cancel (filterable lists have no number keys) |
234
+ | Trusting the directory at startup | ↑↓ Enter · 1–4 pick directly · Esc / Ctrl+C = do not trust this time |
235
+ | CLI subcommand billing / write confirmations (TTY) | ↑↓ Enter · 1–2 · y / n · Esc / Ctrl+C cancel (cancel by default) |
236
+
237
+ CLI subcommands (write confirmations of `ama providers add` / `refresh` and the `--probe` billing confirmation, `ama models cache-probe`) use the same arrow-key selection on a TTY, collapsing to a single answered line and restoring the terminal afterwards; when stdin is not a TTY (pipes, CI) it is still a text `[y/N]` question (these commands require `--yes` when non-interactive anyway), and `--yes` skips the confirmation.
238
+
239
+ ## Completion
240
+
241
+ - `/` at the start of the first line: commands, prompt templates (`/<name>`), Skills (`/skill:<name>`).
242
+ - `@` (at the start of a line or after a space): files and directories under the current directory (respecting `.gitignore`); with `*` `?` `[` `{` it matches relative paths as a glob.
243
+
244
+ ## Approvals
245
+
246
+ When a tool call needs confirmation, a dialog pops up at the bottom: the title is the reason (confirmation needed / dangerous command / a hook asked for confirmation; requests from sub-agents and external agents carry origin labels, see "Sub-agents" below), and the border turns red / yellow with the preview's severity; bash shows the full command, write shows the path and line count, edit shows a −/+ summary per change. Numbered options follow:
247
+
248
+ ```
249
+ ╭─ Dangerous command ─────────────────────────────────────╮
250
+ │ bash dangerous command │
251
+ │ $ rm -rf build dist/*.map > out.log │
252
+ │ │
253
+ │ delete build/: directory, 132 files, 1.2 MB │
254
+ │ This command may be destructive, please confirm │
255
+ │ │
256
+ │ 1. Allow y │
257
+ │ 2. Allow this kind for the session a │
258
+ │ › 3. Deny n Esc │
259
+ │ │
260
+ │ ↑↓ select · Enter confirm · v full input │
261
+ ╰─────────────────────────────────────────────────────────╯
262
+ ```
263
+
264
+ Pick with `1`–`3` or `↑↓` + Enter; `y` allows, `a` stops asking for the same kind in this session, `n` / Esc / Ctrl+C deny, `v` shows the full input. The default selection is "Deny" for dangerous commands and "Allow" otherwise. Below 56 columns it is compact (the tool name on its own line, no blank lines). Without an answer for 10 minutes it counts as deny (`AMA_APPROVAL_TIMEOUT_MS` changes it).
265
+
266
+ After the input summary comes the **pre-execution preview**: what this step will touch.
267
+
268
+ - bash: in every command segment (including commands nested in `sh -c`, `eval`, `xargs`, `find -exec`) it recognizes `rm` / `rmdir` / `unlink`, `mv`, `git clean`, `git checkout -- <path>`, `git reset --hard` and `>` / `>>` redirect targets, and lists whether the paths exist, their size and how many files a directory holds; globs and variables are not expanded but shown as is, with a note that the real scope may be larger.
269
+ - write: whether the target exists, its current line count and size → the new content; overwriting a file not read in this session is marked yellow.
270
+ - edit: a dry run against the original, listing −n/+m lines per change and the total; when a match fails or is not unique, this is said up front.
271
+
272
+ The preview is colored by severity (danger red, warning yellow, the rest dim), read-only and bounded: at most 2000 entries counted per directory and a 200 ms budget for the whole preview; beyond that it only gives a hint without lowering severity; files over 2 MiB only report their size. A failed preview does not affect the approval. Line mode prints the same preview line by line before the question; RPC clients get it from `permission_request.preview` ([rpc.md](rpc.md) "Approvals").
273
+
274
+ ## Plan approval
275
+
276
+ In Plan mode (Shift+Tab, `/permission plan`, `/plan <goal>`, `--permission-mode plan`) the model researches read-only and ends with a `<proposed_plan>` block (rules in [plan.md](../plan.md), Chinese). When the turn ends and the session is idle, an approval box pops up at the bottom:
277
+
278
+ ```
279
+ ╭─ Plan awaiting approval ─────────────────────────────────────────────────────╮
280
+ │ Plan v1 · 3 steps · ~/.local/share/ama/plans/3f2a9c1e-…-v1.md │
281
+ │ Show the fallback model in the status bar │
282
+ │ S1 read status-bar.ts and status-area.ts │
283
+ │ S2 record the main and fallback models on model_fallback │
284
+ │ S3 frame goldens and docs │
285
+ │ │
286
+ │ › 1. Approve and execute │
287
+ │ 2. Approve, execute in a fresh context │
288
+ │ 3. Keep revising… │
289
+ │ 4. Discard and leave Plan mode │
290
+ │ │
291
+ │ ↑↓ select · Enter confirm · e edit plan · Esc stay in Plan │
292
+ ╰──────────────────────────────────────────────────────────────────────────────╯
293
+ ```
294
+
295
+ - **1 Approve and execute** / **2 Approve, execute in a fresh context**: then pick the execution mode: back to the previous mode (default) / Accept edits / Auto; Esc goes back. After approval the plan's steps become todos (the first in progress), the mode switches and execution starts. "Fresh context" creates a new session carrying the approved plan and todos and starts executing with the full plan as the first message (the original session stays in the tree).
296
+ - **3 Keep revising**: write feedback in the box (Enter sends, `Ctrl+E` switches to an external editor, Esc goes back); the feedback is sent to the model as an ordinary message, still in Plan mode, and the box pops up again after the model rewrites the plan. Typing into the input box and sending has the same effect.
297
+ - **4 Discard**: the plan is marked discarded and the mode returns to the one before Plan. **Esc**: the plan is marked discarded but you stay in Plan mode (keep talking, let the model plan again).
298
+ - **e Edit plan**: opens the full plan with `$VISUAL` / `$EDITOR` (default `vi`, `notepad` on Windows) while the interface is suspended; after saving and exiting the box notes that the plan was edited, and approval executes the edited version (with a new version number).
299
+ - `/plan`: the panel lists the version, status (awaiting approval / approved / discarded / superseded by a new version), plan file, current mode and the mode to return to after approval, steps and todo progress; when a plan awaits approval it also reopens the approval box (on resume the message area mentions it in one line).
300
+ - Below 56 columns it is compact (no blank lines, shortened key hints, truncated summary); in ASCII mode the selection marker is `>` and the arrows `^v`.
301
+ - **Line mode**: when a plan is proposed it prints one line saying plan v1 awaits approval (with the file), and that `/plan approve [mode|fresh]` approves, `/plan reject` discards and typing feedback revises; replying `1` / `2` / `3` also approves (the mode before entering such as Manual / Accept edits / Auto). After `/plan approve` starts execution, the next line is read only once that round finishes.
302
+
303
+ ## Sub-agents
304
+
305
+ Sub-agents started by the `task` tool ([agents.md](../agents.md), Chinese) fold into a task tool line in the message area, with one status line while running:
306
+
307
+ ```
308
+ ⏺ task check test coverage gaps in src/tui
309
+ ⎿ ⠋ explore · running 1m05s · 3 turns · read grep bash · ↑12k ↓3.4k
310
+ ⏺ task background review
311
+ ⎿ done · 0.0s
312
+ ↳ t2 explore · running 40s · 1 turn · read
313
+ ```
314
+
315
+ - The status line shows the type (external agents show a runner such as `claude (claude)`), status and elapsed time, turns, the latest 3 tools and usage; after a foreground task ends it is replaced by the result summary. A background task's (`background: true`) tool call returns immediately, with an extra follow-up status line below (refreshed every second while running); when it completes, the `<task-notification>` the model receives shows in the message area as a single line (e.g. "↳ sub-agent notification: t2 explore done · 7 turns · see /tasks for output"), plus a yellow notice on failure or stop.
316
+ - `/tasks`: focus the agent bar (below); `/tasks <id>` opens that task's sub-agent view directly; `/tasks stop <id>` stops it. With `ui.agentBar: "off"` (the default in embedding hosts) `/tasks` is still the task picker (newest on top, Enter shows the output, running tasks can be stopped). Line mode: `/tasks` lists, `/tasks <id>` shows output, `/tasks stop <id>` stops.
317
+ - `/agents`: the available types: name, runner, source (built-in / user / project / profile / host), external agents marked installed with a version or not installed, plus a one-line description.
318
+ - Notices reported by external agents themselves (budget exhausted, timeout, mode downgrade …) show in the message area as a single line `[claude · t3] …`.
319
+
320
+ ### Agent bar
321
+
322
+ Above the status line (below the hint line) the bar lists sub-agent tasks, one line each, at most 3 lines, with an "N more" line for the rest:
323
+
324
+ ```
325
+ ⏺ t1 explore · running 1m05s · 3 turns · grep find test gaps in src/tui
326
+ ⏺ t2 codex · awaiting approval 40s review the diff
327
+ ⏺ t3 explore · queued a queued task
328
+ 1 more
329
+ ```
330
+
331
+ - States: queued (the concurrency pool is full) / running (elapsed time, turns, latest tool) / awaiting approval (the approval dialog currently holds its request) / done / failed / stopped (plus out of turns and interrupted); `⏺` is the accent color while running, green when done, red on failure, yellow / dim otherwise; `*` in ASCII.
332
+ - When it shows: while any task is queued, running or awaiting approval; tasks that ended in this session and have not been looked at in the view stay until viewed, at most 10 minutes. Tasks already finished when a session is resumed are not shown (`/tasks` lists them).
333
+ - Entering: `Ctrl+B` with an empty input box (whenever there are tasks), or `↓` (while the bar is visible) — tmux's default prefix swallows `Ctrl+B`, so use `↓` there; with text in the input box `Ctrl+B` still moves the cursor left and `↓` still moves down / through history. The key action is `app.agents.focus`, configurable in `keybindings.json`.
334
+ - In the bar: `↑` `↓` select (lists every task of the session, the window scrolls along; `↑` on the first item returns to the input box), Enter opens the sub-agent view, Esc / `Ctrl+B` return to the input box; typing returns to the input box with the text filled in. The last line is a key hint.
335
+ - Embedding hosts (with a profile) default to `ui.agentBar: "off"`: no bar, and `Ctrl+B` / `↓` go to the editor as usual.
336
+
337
+ ### Sub-agent view
338
+
339
+ Opened with Enter in the bar or `/tasks <id>`. It is a bottom overlay on the main screen, terminal rows − 1 tall (no alternate screen), so the message area and scrollback are unchanged after closing it:
340
+
341
+ ```
342
+ t2 explore · running 1m05s · 3 turns · ↑12k ↓3.4k · Esc back · /tasks stop t2 to stop
343
+ › find test gaps in src/tui
344
+
345
+ ⏺ grep "describe(" src/tui
346
+ ⎿ 14 matches · 6 files
347
+ …
348
+ ────────────────────────────────────────
349
+ › message t2
350
+ ────────────────────────────────────────
351
+ ```
352
+
353
+ - The body follows live: for ama sub-agents it shows every message and tool call of the sub-session (rendered like the message area); when the sub-session handle has been released (at most 16 are kept) or the session was resumed, the sub-session file is loaded read-only and live events are attached when the task runs again. External agents (claude / codex / ACP) show the live output held in this process's memory (text, thinking, tool start / end, turns, notices; at most 2000 items / 1 MB, never written to disk); after ama restarts only one line remains, saying to use the original CLI's resume <session id> for the full text.
354
+ - With an empty input box: `↑` / PgUp scroll up (pausing follow, with "follow paused · End to resume" at the bottom), `↓` / PgDn scroll down, End (or `f` while paused) resumes following; `←` `→` switch to the previous / next task; Esc returns to the main screen. With text in the input box, Esc clears it first.
355
+ - Enter sends the input to this sub-agent (recorded in the sub-session as a user message with `origin: "direct"`, see [session-format.md](../session-format.md), Chinese): ama sub-agent running → delivered when its current turn ends; external agent running or task still queued → continued after this run ends; finished → continued in the background (like `task_ctl send`; the main session receives the `<task-notification>` as usual when it completes). A line at the bottom reports the result. The parent session's model does not know you talked to the sub-agent directly; the result comes back through the completion notification.
356
+ - Nothing is interrupted from the view: Esc only goes back. To stop the task use `/tasks stop <id>`, which also works in the view's input box (the only command the view accepts).
357
+ - When the viewed task waits for approval the title says "awaiting approval", and the approval dialog pops up over the view as usual (with the `[task:<type>]` origin).
358
+
359
+ Origin labels on approval boxes:
360
+
361
+ | Origin | Title prefix | Body |
362
+ | --------------------------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------- |
363
+ | Tool calls of a task sub-agent | `[task:explore]` (`[task]` when the type is unknown) | Same as the main session |
364
+ | Permission requests from external agents (claude / codex / ACP) | `[claude · session abc12345]` | The title, kind, paths involved and input summary given by the external agent |
365
+ | First run of an external agent in this session | Title "first run of an external agent" | An explanation (runs with your login in that CLI) and the mode |
366
+
367
+ All three offer only "allow / allow this kind for the session / deny" (for external agents, "allow for the session" is remembered by the agent itself). In Manual mode `task(agent="claude")` would ask twice (once for the task call, once for the first run): the approval box of the task call already says it runs with your login in the claude CLI (including the first-run confirmation for this session), so after allowing it the immediately following first-run confirmation passes automatically, with one line in the message area saying task was allowed along with the previous confirmation; if another approval comes in between, it is denied, more than 60 seconds pass, or the task was not created by this call, the first-run confirmation pops up as usual.
368
+
369
+ ## Traces
370
+
371
+ `/trace` opens the current session's trace: layered as turn → request → tool → sub-call / sub-agent, each row showing duration, tokens and cache hits, so you can see where a reply was slow (first token, decoding, tools, approvals, retries, compaction). `/trace t2` looks at task t2 directly: an ama sub-agent shows its own sub-trace, external agents (claude / codex …) only have a turn skeleton (kind, state, times and counts, no command lines or paths).
372
+
373
+ The overlay sits at the bottom of the main screen, `rows − 1` tall, and leaves the message area unchanged when closed:
374
+
375
+ ```text
376
+ Trace · 1 turn · 2 requests · 3 tool calls · 12s · ↑8.1k ↓240 · cache 70% · ttft p50 0.8s / p90 0.9s · 120 tok/s
377
+ ▾ #1 run the tests and find TODOs 12s ▕██░░░░░░░▒██▏ ↑8.1k ↓240 70%
378
+ ▾ request claude-sonnet-4-5 · ttft 0.8s · 167 tok/s 1.7s ▕██░░░░░░░░ ▏ ↑3.9k ↓150 46%
379
+ bash pnpm test 8.0s ▕ ░░░░░░░░░ ▏
380
+ grep TODO 0.3s ▕ ░░ ▏
381
+ ⛔ write notes.md 2.2s ▕ ░░░░ ▏
382
+ › request claude-sonnet-4-5 · ttft 0.9s · 82 tok/s 2.0s ▕ ▒██▏ ↑4.2k ↓90 93%
383
+ ↑↓ move · → expand · ← collapse · Enter details · f follow · Esc close
384
+ ```
385
+
386
+ - **Bars** are a relative timeline of the turn: `▒` waiting for the first token (TTFT), `█` decoding, `░` tools; in-progress nodes only draw a start mark `│` and no made-up duration. With ASCII (`ui.ascii` / `AMA_ASCII=1`) or no color (`NO_COLOR`) they degrade to `[==..--]` (`.` TTFT, `=` decoding, `-` tools, `|` start).
387
+ - **Columns**: ↑ is prompt tokens (including cache reads and writes), ↓ is output tokens, the percentage is the cache hit rate (cache reads / prompt tokens). Below 60 columns only the label and duration remain; 40 columns works.
388
+ - **Marks**: `✗` failed, `⛔` denied, `↻` a request replaced by a retry, `!` interrupted or unfinished, `·` in progress; `≈` (ASCII `~`) before a duration means **estimated** — sessions from before 0.6 have no timing records, so durations are estimated from entry times, first token and throughput are not shown, and the summary's ttft percentiles use exact values only.
389
+ - **Keys**: `↑↓` / `PgUp` `PgDn` / `Home` `End` move; `→` expands (expanding a sub-agent reads its sub-session) or moves to the first child, `←` collapses or returns to the parent; `Enter` opens a detail card (kind, state, start time, duration, model and attempts, fallback source, TTFT, throughput, tokens and cache, cost, approval wait; the turn's prompt, the request's reply text, tool arguments (cut at 500 characters) and results (cut at 2000 characters)), with `↑↓` to scroll in the card and `Esc` / `Enter` to go back; `f` toggles following; `Esc` closes the details first, then the view.
390
+ - **Long sessions**: the last 50 turns show first; `Enter` on the top line "N earlier turns" (or `↑` again on the first line) loads 50 more; only visible rows are rendered.
391
+ - **While running**: the trace refreshes with session events (at most twice a second); with in-progress nodes it follows the newest row, moving up manually pauses it ("follow paused" at the right of the title), and `End` or `f` resumes.
392
+ - Auxiliary requests such as warming and permission classification are grouped at the end under "N auxiliary requests", collapsed by default.
393
+ - In line mode (`--ui line`, pipes) `/trace [task id]` prints the same tree as text (fully expanded, no bars).
394
+
395
+ Timing comes from `custom{customType:"ama.trace"}` entries in the session file ([session-format.md](../session-format.md), Chinese), which hold only ids, times and counts; previews of prompts, arguments and results are read from session entries on demand and never enter the trace itself. The HTML export `ama sessions trace` and RPC `get_trace` are described in [sessions.md](sessions.md) and [rpc.md](rpc.md).
396
+
397
+ ## Memory
398
+
399
+ Requires memory to be enabled (`ama memory enable` or `--memory`, see [memory.md](../memory.md), Chinese). `/memory` draws a card in the message area: one section per scope (`user /memories/user/ · N entries · index X / 4.0 KiB`), one line per entry "name — description updated date", entries not updated for over 90 days greyed out; when the index exceeds its limit a yellow line says how many entries did not make it into the system prompt; an untrusted project and writes disabled for this session each add a line at the bottom of the card.
400
+
401
+ `/memory show <name>` renders the body as a card; `/memory edit [name|scope]` suspends the interface and opens `$VISUAL` / `$EDITOR` (on a temporary copy, saved back and the index rebuilt after you save and quit, with the same credential and size checks as model writes); `/memory rm <name>` asks for confirmation (default "Cancel", `y` deletes, `n` / Esc cancels); `/memory on|off` toggles writes for this session; `/memory reload` re-renders the system prompt's `memory` section (breaking the cache once). Line mode has the same commands with text output; `edit` uses `ama memory edit` instead and `rm` needs `--yes`. When memory is not enabled for the session it only explains how to enable it.
402
+
403
+ ## Clipboard images
404
+
405
+ `Ctrl+V` or `/paste` reads an image from the system clipboard (macOS `osascript` / `pngpaste`, Linux `wl-paste` / `xclip`, Windows PowerShell), saves it as `<data dir>/clipboard/<time>.png` and inserts `@<path>` at the cursor in the input box; on send it is handled as an `@image` attachment (resized per `images.resize` when above the current model's per-image limit). When no usable command exists or the clipboard holds no image, a line appears at the bottom and the input box is unchanged. Text still uses the terminal's own paste (Cmd+V / Ctrl+Shift+V). `ama sessions prune` cleans clipboard files older than 7 days.
406
+
407
+ ## Startup screen
408
+
409
+ `ui.quietStartup` / `--quiet-startup`: `normal` shows a boxed startup header: title, model and thinking level, directory (`~` abbreviated) and trust state, permission mode / preset / codemode, loaded context files / Skills / prompt templates / hooks, warning count and common keys; below 56 columns or with `ui.compact` the box is dropped and each item takes one line. `header` is a single line `✻ ama version · model · mode · /help` (the profile default); `silent` shows nothing. When `--resume` has no id, the model has no key, the session directory does not exist or project resources need trust, a small selection / input prompt appears before the interface starts, collapsing into one line on screen once answered.
410
+
411
+ ## In tmux / Armadra terminal nodes
412
+
413
+ - Bracketed paste: enabled at startup; pasted multi-line content enters the input box as a whole (folded into a paste placeholder with the line count beyond 10 lines or 1 000 characters), and an Enter right after a paste sends directly, which suits writes from external programs.
414
+ - Terminal capabilities are not queried, and mouse and the Kitty keyboard protocol are not enabled, so no replies get mixed into input; tmux ≥ 3.4 passes synchronized output through, and older versions display fine too.
415
+ - When the window size changes the last screen is redrawn in full; history in the scrollback is unaffected.
416
+ - Automatic fallback: non-TTY, `TERM=dumb`, `--no-tui` or a failed terminal initialization use line mode, with the same commands and approval prompts.
417
+
418
+ ## Configuration and troubleshooting
419
+
420
+ The `ui` section of `config.json` (settable at project level too):
421
+
422
+ | Key | Default | Effect |
423
+ | ----------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
424
+ | `ui.theme` | `dark` | `dark` / `light` / `auto`; auto only looks at `COLORFGBG` (no terminal query) and uses dark when unsure; configuring it explicitly is recommended |
425
+ | `ui.ascii` | auto-detected | ASCII glyphs (`›` → `>`, `⏺` → `*`, `⎿` → `L`, box lines → `+ - \|`, a 4-frame spinner) |
426
+ | `ui.compact` | `false` | No blank lines between message blocks, no box around the startup header |
427
+ | `ui.animation` | `true` | `false`: the spinner stays still as `·` while running and redraws only when seconds change |
428
+ | `ui.markdown` | `true` | `false`: assistant text is not rendered as Markdown |
429
+ | `ui.showThinking` | `collapsed` | See "Layout" |
430
+ | `ui.quietStartup` | `normal` | See "Startup screen" |
431
+
432
+ - **ASCII mode**: `AMA_ASCII=1` (or `ui.ascii: true`) forces it on, `AMA_ASCII=0` forces it off; auto-detection turns it on when the locale (`LC_ALL` > `LC_CTYPE` > `LANG`) is set but lacks UTF-8, with `TERM=linux`, or on Windows without `WT_SESSION` or `TERM_PROGRAM` (legacy conhost). Windows Terminal uses Unicode.
433
+ - **Misaligned characters**: `⏺` (U+23FA), `⎿` and `▎` render two cells wide in some fonts (emoji fallback fonts in particular), while width is computed per wcwidth (one cell), causing misaligned columns or ghosting; switch to a monospace font or set `AMA_ASCII=1`.
434
+ - **Colors**: no color with `NO_COLOR` or `TERM=dumb`; 16-color terminals take the nearest color from a built-in table and mark the selected row with accent bold instead of a background; on light terminals set `ui.theme: "light"`.
435
+
436
+ ### The `/config` settings panel and `ama config`
437
+
438
+ `/config` opens the settings panel (a bottom overlay): about 60 scalar settings listed by group, each row "label · effective value · when it takes effect · source".
439
+
440
+ ```text
441
+ ▎ Settings writing to: user level ~/.config/ama/config.json [Tab to switch]
442
+ ▎ / search
443
+ ▎ Interface
444
+ ▎ › Theme light restart source user
445
+ ▎ Markdown rendering true immediate
446
+ ▎ Permissions
447
+ ▎ Permission mode plan immediate [locked] project
448
+ ▎ ────────────────────────────────────────────────────────────
449
+ ▎ Color theme: dark, light, or auto (…)
450
+ ▎ ↑↓ select · Enter/Space change · / search · Tab user/project · Backspace reset · Esc close
451
+ ```
452
+
453
+ - **Keys**: ↑↓ move; Enter / Space: toggles booleans, cycles enums of ≤ 4 values, opens a picker for longer enums (thinking level, permission mode …) and models, and inline input for numbers and text (invalid values stay in the box in red, Esc gives up); `/` searches key names, labels, enum values and descriptions, Esc clears the search first and then closes; pressing Backspace / Delete twice removes the key from the target layer (falling back to the value below).
454
+ - **Target layer**: writes go to the user-level `~/.config/ama/config.json` by default; Tab switches to the project-level `.ama/config.json`, which may only tighten (the same check as the merge rules), with user-level-only items greyed out and Enter explaining why. Changes are **written to disk immediately** (the file is re-read before writing, only this key changes, it is validated, a `.bak` is kept); there is no "save" button and no file lock, so when `ama config edit` changes the same key concurrently, the last writer wins for that key. Hand-made formatting is normalized to 2-space indentation.
455
+ - **Source and locking**: the source is default / user / profile / project / cli / env; items overridden by a higher layer (profile, project level, command-line flags, environment variables such as `AMA_CACHE_WARMING`) are marked `[locked]`, the description line gives the reason, and they cannot be changed. In an embedding host (with a profile) the title notes that writes go to the user-level config.
456
+ - **When it takes effect**: "immediate" items apply to this session and the interface right away (`ui` display items except the theme, `defaultModel`, `thinkingLevel`, `permission.mode`, `compaction.enabled`, `retry.enabled`, `cache.warming`); "new session" items apply after `/new` / `/resume`; "restart" items (tool preset, codemode, sandbox, `ui.theme`, `ui.ascii`, `ui.language` …) apply at the next start. The panel = persistence; `/model` `/thinking` `/permission` `/statusline` still change only this session.
457
+ - **Cache**: items marked as affecting the cache change the cache prefix; the first time such an item is changed after the conversation already has replies, the bottom of the panel notes once that the next request will be billed as a miss.
458
+ - Setting `permission.mode` to `full-auto` in the panel first shows the Bypass confirmation, explaining that it will apply on every start from now on.
459
+ - On close, the message area gets a summary such as "Theme: dark → light (user level)", with items that need a restart / new session on a separate line; nothing is shown without changes.
460
+ - List and object keys are not in the panel; the last group, "change elsewhere", gives the entry points (`ama providers`, `/permissions`, `ama config edit`, `--json-value` …).
461
+
462
+ `/config key=value` (or `/config key value`) writes one user-level key without opening the panel, echoing like the command line; it works in line mode too, and without arguments lists all settings.
463
+
464
+ Command line (sharing the editing core with the panel):
465
+
466
+ ```text
467
+ ama config get <key> [--json] effective value, source, when it takes effect
468
+ ama config set <key> <value> [--project] [--json-value] [--yes]
469
+ ama config unset <key> [--project]
470
+ ama config list [prefix] [--json] [--all] by default only the settings shown in the panel
471
+ ```
472
+
473
+ Values are parsed by type: `true/false/on/off/1/0`, numbers (`30_000` allowed), enums case-insensitively, `none` / `unset` = delete; lists and objects use `--json-value` (e.g. `ama config set tools.disabled '["bash"]' --json-value`). Unknown keys, invalid values and loosening rejected at project level all exit with 3 and leave the file alone; `get` / `list` never create the config directory. `ama config set permission.mode full-auto` asks for confirmation in a terminal and needs `--yes` otherwise.
474
+
475
+ The optional `ui.replyLanguage` (e.g. `Chinese`): at session start one English rule, `Reply to the user in Chinese.`, is appended to the end of the system prompt's `rules` section; requests are byte-identical when unset; user level / profile only.
476
+
477
+ ## Component library (`@armadra/agent/tui`)
478
+
479
+ The terminal components used by interactive mode are exported separately with zero dependencies, so hosts and other Node programs can use them to draw main-screen interfaces.
480
+
481
+ ```ts
482
+ import { TUI, ProcessTerminal, Text, Editor, createTheme } from "@armadra/agent/tui";
483
+
484
+ const tui = new TUI(new ProcessTerminal());
485
+ const theme = createTheme("dark");
486
+ const log = new Text("");
487
+ const editor = new Editor({
488
+ theme,
489
+ requestRender: () => tui.requestRender(),
490
+ onSubmit: (text) => {
491
+ log.setText(`you said: ${text}`);
492
+ tui.requestRender();
493
+ },
494
+ });
495
+ tui.addChild(log);
496
+ tui.addChild(editor);
497
+ tui.setFocus(editor);
498
+ tui.start();
499
+ ```
500
+
501
+ | Export | Purpose |
502
+ | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
503
+ | `Component`, `Focusable`, `CURSOR_MARKER` | The component contract: `render(width)` returns lines (each with visible width ≤ width), `handleInput?(data)`, `invalidate()`; the focused component emits `CURSOR_MARKER` at the cursor |
504
+ | `TUI` | Root container and differential rendering (main screen, synchronized output): `addChild`, `start` / `stop`, `requestRender`, `setFocus`, `addInputListener`, `showOverlay` |
505
+ | `ProcessTerminal`, `MemoryTerminal`, `VirtualScreen` | A real terminal (raw mode, bracketed paste); an in-memory terminal and a VT screen (tests, frame goldens) |
506
+ | `Container`, `Text`, `TruncatedText`, `Markdown`, `Box`, `Card`, `Spacer` | Basic components; `Card` is a left-bar card, `Box` accepts `borderColor` |
507
+ | `Loader` | Running indicator: `setVerb(verb, extras, { elapsed })`, `frame` / `onFrame` (changes glyph in the same frame as other components), `animation: false` |
508
+ | `Editor`, `EditorBuffer`, `PasteStore` | Multi-line editor (history, the `AutocompleteProvider` completion interface, paste folding) |
509
+ | `SelectList` | Filterable selection list: groups, badges, number keys, `stacked`, `currentValue` (✓), `footer` key hints |
510
+ | `KeyValue`, `Meter` | Two-column aligned key-value table (`wrap` wraps aligned to the value column); a meter (`levelColor` threshold coloring) |
511
+ | `compositeOverlays`, `OverlayOptions` | Overlay compositing (centered / bottom-anchored) |
512
+ | `createTheme`, `plainTheme`, `detectCapabilities`, `Theme` | Themes and color capability detection (`NO_COLOR`, 16 / 256 / truecolor); 14 semantic colors, `resolveThemeName("auto")` |
513
+ | `Theme.glyphs`, `UNICODE_GLYPHS`, `ASCII_GLYPHS`, `detectAscii` | Glyph tables (`›` `⏺` `⎿` `✻` `▎`, box lines, spinner frames …) with ASCII fallback; `createTheme(name, { ascii })` |
514
+ | `Keybindings`, `DEFAULT_KEYBINDINGS`, `loadKeybindingsFile` | Action id → keys, overridden by `keybindings.json` |
515
+ | `parseKey`, `matchesKey`, `StdinBuffer` | Key sequence parsing and Esc timeout splitting (`AMA_TUI_ESC_TIMEOUT`) |
516
+ | `visibleWidth`, `truncateToWidth`, `wrapTextWithAnsi`, `sliceByColumn` … | Width computation and truncation aware of ANSI and wide characters |
517
+
518
+ ## Testing
519
+
520
+ Frame goldens all live in `test/fixtures/tui/`; `MemoryTerminal` reconstructs the screen (without color, verifying only layout and glyphs):
521
+
522
+ - `src/modes/interactive/interactive-mode.test.ts`: a complete read-file run at 80x24 and 40x24 (startup, input, tool running, finish, `Ctrl+O` expand, exit summary) → `run-*.txt`; approvals, cache notices and more.
523
+ - `src/modes/interactive/interactive-frames.test.ts`: startup headers (`startup-normal-*`, `header-quiet-*`), tool hierarchy (`tools-*`), notices (`notices-*`), running verbs (`loader-verbs-*`), the `/session` panel (`panel-session-*`), a whole run in ASCII mode (`ascii-run-*`).
524
+ - Wave 5 (W5-U): `plan-dialog.test.ts` (`plan-dialog-*`: four options, execution mode, feedback, external editor, ASCII, 40 columns), `approval-origin.test.ts` (`approval-origin-*`, `approval-task-agent-*`, `approval-first-run-*`, `approval-task-external-*` and the first-run merge), `subagent-view.test.ts` (`subagent-view-*`), `tasks-panel.test.ts` (`tasks-picker-*`, `tasks-output-*`, `agents-panel-*`), `harness-notices.test.ts` (`harness-notices-*`), `interactive-w5.test.ts` (plan → approval → execution, `/plan`, background tasks into `/tasks`, Ctrl+V; `interactive-plan-*`, `interactive-tasks-*`).
525
+ - `src/tui/tui-frames.test.ts`: component level (conversation, Markdown, editor placeholder / multi-line / paste / completion); `status-widths.txt` of `status-bar.test.ts`; approvals and mode pickers in `approval-dialog.test.ts` and `pickers.test.ts`.
526
+
527
+ After interface changes, update with `AMA_UPDATE_GOLDEN=1 pnpm vitest run src/modes/interactive src/tui` and review `git diff test/fixtures/tui` one by one.