strands-darwin 0.0.3

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 (417) hide show
  1. package/README.md +140 -0
  2. package/README.zh-CN.md +140 -0
  3. package/dist/patches/@strands-agents+sdk+1.16.0.patch +1443 -0
  4. package/dist/src/agent/background-delegation.d.ts +67 -0
  5. package/dist/src/agent/background-delegation.js +159 -0
  6. package/dist/src/agent/background-delegation.js.map +1 -0
  7. package/dist/src/agent/call-stats.d.ts +118 -0
  8. package/dist/src/agent/call-stats.js +128 -0
  9. package/dist/src/agent/call-stats.js.map +1 -0
  10. package/dist/src/agent/compact.d.ts +108 -0
  11. package/dist/src/agent/compact.js +192 -0
  12. package/dist/src/agent/compact.js.map +1 -0
  13. package/dist/src/agent/context-anchor.d.ts +64 -0
  14. package/dist/src/agent/context-anchor.js +43 -0
  15. package/dist/src/agent/context-anchor.js.map +1 -0
  16. package/dist/src/agent/cost.d.ts +56 -0
  17. package/dist/src/agent/cost.js +44 -0
  18. package/dist/src/agent/cost.js.map +1 -0
  19. package/dist/src/agent/diagnostics.d.ts +212 -0
  20. package/dist/src/agent/diagnostics.js +374 -0
  21. package/dist/src/agent/diagnostics.js.map +1 -0
  22. package/dist/src/agent/instructions.d.ts +54 -0
  23. package/dist/src/agent/instructions.js +118 -0
  24. package/dist/src/agent/instructions.js.map +1 -0
  25. package/dist/src/agent/max-tokens-recovery.d.ts +17 -0
  26. package/dist/src/agent/max-tokens-recovery.js +65 -0
  27. package/dist/src/agent/max-tokens-recovery.js.map +1 -0
  28. package/dist/src/agent/model-call-budget.d.ts +8 -0
  29. package/dist/src/agent/model-call-budget.js +24 -0
  30. package/dist/src/agent/model-call-budget.js.map +1 -0
  31. package/dist/src/agent/model-retry.d.ts +134 -0
  32. package/dist/src/agent/model-retry.js +256 -0
  33. package/dist/src/agent/model-retry.js.map +1 -0
  34. package/dist/src/agent/permission-rules.d.ts +47 -0
  35. package/dist/src/agent/permission-rules.js +260 -0
  36. package/dist/src/agent/permission-rules.js.map +1 -0
  37. package/dist/src/agent/permission.d.ts +361 -0
  38. package/dist/src/agent/permission.js +797 -0
  39. package/dist/src/agent/permission.js.map +1 -0
  40. package/dist/src/agent/prompt-cache.d.ts +66 -0
  41. package/dist/src/agent/prompt-cache.js +194 -0
  42. package/dist/src/agent/prompt-cache.js.map +1 -0
  43. package/dist/src/agent/refusal.d.ts +20 -0
  44. package/dist/src/agent/refusal.js +23 -0
  45. package/dist/src/agent/refusal.js.map +1 -0
  46. package/dist/src/agent/retry-guard.d.ts +26 -0
  47. package/dist/src/agent/retry-guard.js +193 -0
  48. package/dist/src/agent/retry-guard.js.map +1 -0
  49. package/dist/src/agent/rewind.d.ts +29 -0
  50. package/dist/src/agent/rewind.js +118 -0
  51. package/dist/src/agent/rewind.js.map +1 -0
  52. package/dist/src/agent/runtime.d.ts +814 -0
  53. package/dist/src/agent/runtime.js +1596 -0
  54. package/dist/src/agent/runtime.js.map +1 -0
  55. package/dist/src/agent/safety-classifier.d.ts +11 -0
  56. package/dist/src/agent/safety-classifier.js +0 -0
  57. package/dist/src/agent/safety-classifier.js.map +1 -0
  58. package/dist/src/agent/sdk-logging.d.ts +49 -0
  59. package/dist/src/agent/sdk-logging.js +110 -0
  60. package/dist/src/agent/sdk-logging.js.map +1 -0
  61. package/dist/src/agent/session.d.ts +102 -0
  62. package/dist/src/agent/session.js +244 -0
  63. package/dist/src/agent/session.js.map +1 -0
  64. package/dist/src/agent/stream-resumption.d.ts +16 -0
  65. package/dist/src/agent/stream-resumption.js +33 -0
  66. package/dist/src/agent/stream-resumption.js.map +1 -0
  67. package/dist/src/agent/system-prompt.d.ts +50 -0
  68. package/dist/src/agent/system-prompt.js +161 -0
  69. package/dist/src/agent/system-prompt.js.map +1 -0
  70. package/dist/src/agent/thinking.d.ts +99 -0
  71. package/dist/src/agent/thinking.js +145 -0
  72. package/dist/src/agent/thinking.js.map +1 -0
  73. package/dist/src/agent/usage.d.ts +132 -0
  74. package/dist/src/agent/usage.js +233 -0
  75. package/dist/src/agent/usage.js.map +1 -0
  76. package/dist/src/agent/working-context.d.ts +51 -0
  77. package/dist/src/agent/working-context.js +160 -0
  78. package/dist/src/agent/working-context.js.map +1 -0
  79. package/dist/src/agents/child-recipe.d.ts +33 -0
  80. package/dist/src/agents/child-recipe.js +98 -0
  81. package/dist/src/agents/child-recipe.js.map +1 -0
  82. package/dist/src/agents/concurrency-limit.d.ts +25 -0
  83. package/dist/src/agents/concurrency-limit.js +43 -0
  84. package/dist/src/agents/concurrency-limit.js.map +1 -0
  85. package/dist/src/agents/dispatch-registry.d.ts +180 -0
  86. package/dist/src/agents/dispatch-registry.js +289 -0
  87. package/dist/src/agents/dispatch-registry.js.map +1 -0
  88. package/dist/src/agents/failed-child-text.d.ts +44 -0
  89. package/dist/src/agents/failed-child-text.js +69 -0
  90. package/dist/src/agents/failed-child-text.js.map +1 -0
  91. package/dist/src/agents/loader.d.ts +26 -0
  92. package/dist/src/agents/loader.js +134 -0
  93. package/dist/src/agents/loader.js.map +1 -0
  94. package/dist/src/agents/report-projection.d.ts +31 -0
  95. package/dist/src/agents/report-projection.js +125 -0
  96. package/dist/src/agents/report-projection.js.map +1 -0
  97. package/dist/src/agents/subagent-tool.d.ts +61 -0
  98. package/dist/src/agents/subagent-tool.js +180 -0
  99. package/dist/src/agents/subagent-tool.js.map +1 -0
  100. package/dist/src/agents/workflow-tool.d.ts +85 -0
  101. package/dist/src/agents/workflow-tool.js +530 -0
  102. package/dist/src/agents/workflow-tool.js.map +1 -0
  103. package/dist/src/cli-args.d.ts +39 -0
  104. package/dist/src/cli-args.js +198 -0
  105. package/dist/src/cli-args.js.map +1 -0
  106. package/dist/src/cli-doctor.d.ts +26 -0
  107. package/dist/src/cli-doctor.js +398 -0
  108. package/dist/src/cli-doctor.js.map +1 -0
  109. package/dist/src/cli-main.d.ts +1 -0
  110. package/dist/src/cli-main.js +279 -0
  111. package/dist/src/cli-main.js.map +1 -0
  112. package/dist/src/cli-sessions.d.ts +17 -0
  113. package/dist/src/cli-sessions.js +136 -0
  114. package/dist/src/cli-sessions.js.map +1 -0
  115. package/dist/src/cli-trajectory.d.ts +37 -0
  116. package/dist/src/cli-trajectory.js +303 -0
  117. package/dist/src/cli-trajectory.js.map +1 -0
  118. package/dist/src/cli-usage.d.ts +18 -0
  119. package/dist/src/cli-usage.js +53 -0
  120. package/dist/src/cli-usage.js.map +1 -0
  121. package/dist/src/cli.d.ts +2 -0
  122. package/dist/src/cli.js +29 -0
  123. package/dist/src/cli.js.map +1 -0
  124. package/dist/src/commands/custom-commands.d.ts +43 -0
  125. package/dist/src/commands/custom-commands.js +155 -0
  126. package/dist/src/commands/custom-commands.js.map +1 -0
  127. package/dist/src/commands/workflow-command.d.ts +26 -0
  128. package/dist/src/commands/workflow-command.js +56 -0
  129. package/dist/src/commands/workflow-command.js.map +1 -0
  130. package/dist/src/config.d.ts +463 -0
  131. package/dist/src/config.js +1457 -0
  132. package/dist/src/config.js.map +1 -0
  133. package/dist/src/context-overflow-error.d.ts +7 -0
  134. package/dist/src/context-overflow-error.js +26 -0
  135. package/dist/src/context-overflow-error.js.map +1 -0
  136. package/dist/src/dev-repl.d.ts +1 -0
  137. package/dist/src/dev-repl.js +365 -0
  138. package/dist/src/dev-repl.js.map +1 -0
  139. package/dist/src/headless-protocol.d.ts +147 -0
  140. package/dist/src/headless-protocol.js +359 -0
  141. package/dist/src/headless-protocol.js.map +1 -0
  142. package/dist/src/headless-runner.d.ts +30 -0
  143. package/dist/src/headless-runner.js +405 -0
  144. package/dist/src/headless-runner.js.map +1 -0
  145. package/dist/src/headless-stdin.d.ts +28 -0
  146. package/dist/src/headless-stdin.js +78 -0
  147. package/dist/src/headless-stdin.js.map +1 -0
  148. package/dist/src/headless.d.ts +106 -0
  149. package/dist/src/headless.js +229 -0
  150. package/dist/src/headless.js.map +1 -0
  151. package/dist/src/hooks/codex-hook-runner.d.ts +92 -0
  152. package/dist/src/hooks/codex-hook-runner.js +446 -0
  153. package/dist/src/hooks/codex-hook-runner.js.map +1 -0
  154. package/dist/src/hooks/codex-hooks.d.ts +23 -0
  155. package/dist/src/hooks/codex-hooks.js +152 -0
  156. package/dist/src/hooks/codex-hooks.js.map +1 -0
  157. package/dist/src/hooks/hook-process.d.ts +23 -0
  158. package/dist/src/hooks/hook-process.js +241 -0
  159. package/dist/src/hooks/hook-process.js.map +1 -0
  160. package/dist/src/hooks/lifecycle-hooks.d.ts +37 -0
  161. package/dist/src/hooks/lifecycle-hooks.js +153 -0
  162. package/dist/src/hooks/lifecycle-hooks.js.map +1 -0
  163. package/dist/src/hooks/tool-hooks.d.ts +63 -0
  164. package/dist/src/hooks/tool-hooks.js +350 -0
  165. package/dist/src/hooks/tool-hooks.js.map +1 -0
  166. package/dist/src/mcp/codegraph-preflight.d.ts +29 -0
  167. package/dist/src/mcp/codegraph-preflight.js +232 -0
  168. package/dist/src/mcp/codegraph-preflight.js.map +1 -0
  169. package/dist/src/mcp/registry.d.ts +133 -0
  170. package/dist/src/mcp/registry.js +209 -0
  171. package/dist/src/mcp/registry.js.map +1 -0
  172. package/dist/src/mcp/web-search-empty-results.d.ts +14 -0
  173. package/dist/src/mcp/web-search-empty-results.js +94 -0
  174. package/dist/src/mcp/web-search-empty-results.js.map +1 -0
  175. package/dist/src/memory/command.d.ts +11 -0
  176. package/dist/src/memory/command.js +253 -0
  177. package/dist/src/memory/command.js.map +1 -0
  178. package/dist/src/memory/controller.d.ts +51 -0
  179. package/dist/src/memory/controller.js +316 -0
  180. package/dist/src/memory/controller.js.map +1 -0
  181. package/dist/src/memory/prompt.d.ts +4 -0
  182. package/dist/src/memory/prompt.js +22 -0
  183. package/dist/src/memory/prompt.js.map +1 -0
  184. package/dist/src/memory/scheduler.d.ts +33 -0
  185. package/dist/src/memory/scheduler.js +134 -0
  186. package/dist/src/memory/scheduler.js.map +1 -0
  187. package/dist/src/memory/state.d.ts +112 -0
  188. package/dist/src/memory/state.js +355 -0
  189. package/dist/src/memory/state.js.map +1 -0
  190. package/dist/src/memory/store.d.ts +19 -0
  191. package/dist/src/memory/store.js +130 -0
  192. package/dist/src/memory/store.js.map +1 -0
  193. package/dist/src/memory/tools.d.ts +29 -0
  194. package/dist/src/memory/tools.js +22 -0
  195. package/dist/src/memory/tools.js.map +1 -0
  196. package/dist/src/memory/validation.d.ts +33 -0
  197. package/dist/src/memory/validation.js +159 -0
  198. package/dist/src/memory/validation.js.map +1 -0
  199. package/dist/src/npm-package/generate-patch.d.ts +23 -0
  200. package/dist/src/npm-package/generate-patch.js +88 -0
  201. package/dist/src/npm-package/generate-patch.js.map +1 -0
  202. package/dist/src/npm-package/patch-package-format.d.ts +43 -0
  203. package/dist/src/npm-package/patch-package-format.js +66 -0
  204. package/dist/src/npm-package/patch-package-format.js.map +1 -0
  205. package/dist/src/paths.d.ts +39 -0
  206. package/dist/src/paths.js +105 -0
  207. package/dist/src/paths.js.map +1 -0
  208. package/dist/src/pricing/cost.d.ts +182 -0
  209. package/dist/src/pricing/cost.js +215 -0
  210. package/dist/src/pricing/cost.js.map +1 -0
  211. package/dist/src/pricing/model-prices.d.ts +112 -0
  212. package/dist/src/pricing/model-prices.js +320 -0
  213. package/dist/src/pricing/model-prices.js.map +1 -0
  214. package/dist/src/sdk-patch-preflight.d.ts +23 -0
  215. package/dist/src/sdk-patch-preflight.js +71 -0
  216. package/dist/src/sdk-patch-preflight.js.map +1 -0
  217. package/dist/src/skills/builtin/commit-message/SKILL.md +45 -0
  218. package/dist/src/skills/builtin/commit-message/references/types.md +8 -0
  219. package/dist/src/skills/builtin/developer/SKILL.md +107 -0
  220. package/dist/src/skills/builtin/self-evolution-research/SKILL.md +150 -0
  221. package/dist/src/skills/builtin/self-evolution-research/scripts/roll-research-path.mjs +208 -0
  222. package/dist/src/skills/builtin/self-reflection/SKILL.md +172 -0
  223. package/dist/src/skills/builtin/self-reflection/references/reflection-template.md +90 -0
  224. package/dist/src/skills/builtin/self-reflection/scripts/locate-trajectory.mjs +175 -0
  225. package/dist/src/skills/loader.d.ts +26 -0
  226. package/dist/src/skills/loader.js +186 -0
  227. package/dist/src/skills/loader.js.map +1 -0
  228. package/dist/src/skills/plugin.d.ts +34 -0
  229. package/dist/src/skills/plugin.js +137 -0
  230. package/dist/src/skills/plugin.js.map +1 -0
  231. package/dist/src/skills/prompt.d.ts +8 -0
  232. package/dist/src/skills/prompt.js +214 -0
  233. package/dist/src/skills/prompt.js.map +1 -0
  234. package/dist/src/skills/resource-safety.d.ts +15 -0
  235. package/dist/src/skills/resource-safety.js +149 -0
  236. package/dist/src/skills/resource-safety.js.map +1 -0
  237. package/dist/src/tools/background-bash.d.ts +95 -0
  238. package/dist/src/tools/background-bash.js +639 -0
  239. package/dist/src/tools/background-bash.js.map +1 -0
  240. package/dist/src/tools/background-tail.d.ts +28 -0
  241. package/dist/src/tools/background-tail.js +75 -0
  242. package/dist/src/tools/background-tail.js.map +1 -0
  243. package/dist/src/tools/background-wait-contract.d.ts +4 -0
  244. package/dist/src/tools/background-wait-contract.js +7 -0
  245. package/dist/src/tools/background-wait-contract.js.map +1 -0
  246. package/dist/src/tools/file-editor-serial.d.ts +24 -0
  247. package/dist/src/tools/file-editor-serial.js +99 -0
  248. package/dist/src/tools/file-editor-serial.js.map +1 -0
  249. package/dist/src/tools/image-viewer.d.ts +43 -0
  250. package/dist/src/tools/image-viewer.js +256 -0
  251. package/dist/src/tools/image-viewer.js.map +1 -0
  252. package/dist/src/tools/update-plan.d.ts +30 -0
  253. package/dist/src/tools/update-plan.js +65 -0
  254. package/dist/src/tools/update-plan.js.map +1 -0
  255. package/dist/src/tools/web-fetch.d.ts +70 -0
  256. package/dist/src/tools/web-fetch.js +667 -0
  257. package/dist/src/tools/web-fetch.js.map +1 -0
  258. package/dist/src/trajectory/export.d.ts +31 -0
  259. package/dist/src/trajectory/export.js +116 -0
  260. package/dist/src/trajectory/export.js.map +1 -0
  261. package/dist/src/trajectory/fork.d.ts +19 -0
  262. package/dist/src/trajectory/fork.js +110 -0
  263. package/dist/src/trajectory/fork.js.map +1 -0
  264. package/dist/src/trajectory/memory-tool.d.ts +20 -0
  265. package/dist/src/trajectory/memory-tool.js +98 -0
  266. package/dist/src/trajectory/memory-tool.js.map +1 -0
  267. package/dist/src/trajectory/prompt-history.d.ts +62 -0
  268. package/dist/src/trajectory/prompt-history.js +256 -0
  269. package/dist/src/trajectory/prompt-history.js.map +1 -0
  270. package/dist/src/trajectory/reader.d.ts +21 -0
  271. package/dist/src/trajectory/reader.js +62 -0
  272. package/dist/src/trajectory/reader.js.map +1 -0
  273. package/dist/src/trajectory/record.d.ts +417 -0
  274. package/dist/src/trajectory/record.js +394 -0
  275. package/dist/src/trajectory/record.js.map +1 -0
  276. package/dist/src/trajectory/replay.d.ts +74 -0
  277. package/dist/src/trajectory/replay.js +285 -0
  278. package/dist/src/trajectory/replay.js.map +1 -0
  279. package/dist/src/trajectory/resume-recap.d.ts +43 -0
  280. package/dist/src/trajectory/resume-recap.js +68 -0
  281. package/dist/src/trajectory/resume-recap.js.map +1 -0
  282. package/dist/src/trajectory/search.d.ts +40 -0
  283. package/dist/src/trajectory/search.js +127 -0
  284. package/dist/src/trajectory/search.js.map +1 -0
  285. package/dist/src/trajectory/spend.d.ts +157 -0
  286. package/dist/src/trajectory/spend.js +264 -0
  287. package/dist/src/trajectory/spend.js.map +1 -0
  288. package/dist/src/trajectory/stream.d.ts +30 -0
  289. package/dist/src/trajectory/stream.js +30 -0
  290. package/dist/src/trajectory/stream.js.map +1 -0
  291. package/dist/src/trajectory/writer.d.ts +310 -0
  292. package/dist/src/trajectory/writer.js +636 -0
  293. package/dist/src/trajectory/writer.js.map +1 -0
  294. package/dist/src/tui/App.d.ts +109 -0
  295. package/dist/src/tui/App.js +2660 -0
  296. package/dist/src/tui/App.js.map +1 -0
  297. package/dist/src/tui/InputBox.d.ts +90 -0
  298. package/dist/src/tui/InputBox.js +129 -0
  299. package/dist/src/tui/InputBox.js.map +1 -0
  300. package/dist/src/tui/MarkdownText.d.ts +16 -0
  301. package/dist/src/tui/MarkdownText.js +117 -0
  302. package/dist/src/tui/MarkdownText.js.map +1 -0
  303. package/dist/src/tui/MessageList.d.ts +27 -0
  304. package/dist/src/tui/MessageList.js +61 -0
  305. package/dist/src/tui/MessageList.js.map +1 -0
  306. package/dist/src/tui/PermissionPrompt.d.ts +18 -0
  307. package/dist/src/tui/PermissionPrompt.js +114 -0
  308. package/dist/src/tui/PermissionPrompt.js.map +1 -0
  309. package/dist/src/tui/PlanChecklist.d.ts +7 -0
  310. package/dist/src/tui/PlanChecklist.js +12 -0
  311. package/dist/src/tui/PlanChecklist.js.map +1 -0
  312. package/dist/src/tui/QueuedMessages.d.ts +8 -0
  313. package/dist/src/tui/QueuedMessages.js +24 -0
  314. package/dist/src/tui/QueuedMessages.js.map +1 -0
  315. package/dist/src/tui/StartupScreen.d.ts +25 -0
  316. package/dist/src/tui/StartupScreen.js +51 -0
  317. package/dist/src/tui/StartupScreen.js.map +1 -0
  318. package/dist/src/tui/ToolCallPanel.d.ts +33 -0
  319. package/dist/src/tui/ToolCallPanel.js +112 -0
  320. package/dist/src/tui/ToolCallPanel.js.map +1 -0
  321. package/dist/src/tui/WelcomeHeader.d.ts +30 -0
  322. package/dist/src/tui/WelcomeHeader.js +69 -0
  323. package/dist/src/tui/WelcomeHeader.js.map +1 -0
  324. package/dist/src/tui/background-tool-presentation.d.ts +22 -0
  325. package/dist/src/tui/background-tool-presentation.js +209 -0
  326. package/dist/src/tui/background-tool-presentation.js.map +1 -0
  327. package/dist/src/tui/busy-suffix.d.ts +37 -0
  328. package/dist/src/tui/busy-suffix.js +39 -0
  329. package/dist/src/tui/busy-suffix.js.map +1 -0
  330. package/dist/src/tui/clipboard-image.d.ts +18 -0
  331. package/dist/src/tui/clipboard-image.js +109 -0
  332. package/dist/src/tui/clipboard-image.js.map +1 -0
  333. package/dist/src/tui/context-format.d.ts +43 -0
  334. package/dist/src/tui/context-format.js +71 -0
  335. package/dist/src/tui/context-format.js.map +1 -0
  336. package/dist/src/tui/copy-command.d.ts +68 -0
  337. package/dist/src/tui/copy-command.js +182 -0
  338. package/dist/src/tui/copy-command.js.map +1 -0
  339. package/dist/src/tui/edit-diff.d.ts +135 -0
  340. package/dist/src/tui/edit-diff.js +356 -0
  341. package/dist/src/tui/edit-diff.js.map +1 -0
  342. package/dist/src/tui/frame-budget.d.ts +351 -0
  343. package/dist/src/tui/frame-budget.js +446 -0
  344. package/dist/src/tui/frame-budget.js.map +1 -0
  345. package/dist/src/tui/help-format.d.ts +17 -0
  346. package/dist/src/tui/help-format.js +38 -0
  347. package/dist/src/tui/help-format.js.map +1 -0
  348. package/dist/src/tui/live-text.d.ts +51 -0
  349. package/dist/src/tui/live-text.js +154 -0
  350. package/dist/src/tui/live-text.js.map +1 -0
  351. package/dist/src/tui/markdown.d.ts +62 -0
  352. package/dist/src/tui/markdown.js +244 -0
  353. package/dist/src/tui/markdown.js.map +1 -0
  354. package/dist/src/tui/mcp-format.d.ts +28 -0
  355. package/dist/src/tui/mcp-format.js +67 -0
  356. package/dist/src/tui/mcp-format.js.map +1 -0
  357. package/dist/src/tui/path-completion.d.ts +119 -0
  358. package/dist/src/tui/path-completion.js +305 -0
  359. package/dist/src/tui/path-completion.js.map +1 -0
  360. package/dist/src/tui/permission-queue.d.ts +61 -0
  361. package/dist/src/tui/permission-queue.js +129 -0
  362. package/dist/src/tui/permission-queue.js.map +1 -0
  363. package/dist/src/tui/plan-format.d.ts +9 -0
  364. package/dist/src/tui/plan-format.js +30 -0
  365. package/dist/src/tui/plan-format.js.map +1 -0
  366. package/dist/src/tui/prompt-completion.d.ts +22 -0
  367. package/dist/src/tui/prompt-completion.js +46 -0
  368. package/dist/src/tui/prompt-completion.js.map +1 -0
  369. package/dist/src/tui/prompt-editor.d.ts +102 -0
  370. package/dist/src/tui/prompt-editor.js +379 -0
  371. package/dist/src/tui/prompt-editor.js.map +1 -0
  372. package/dist/src/tui/prompt-history-search.d.ts +53 -0
  373. package/dist/src/tui/prompt-history-search.js +123 -0
  374. package/dist/src/tui/prompt-history-search.js.map +1 -0
  375. package/dist/src/tui/prompt-queue.d.ts +58 -0
  376. package/dist/src/tui/prompt-queue.js +74 -0
  377. package/dist/src/tui/prompt-queue.js.map +1 -0
  378. package/dist/src/tui/prompt-recall.d.ts +74 -0
  379. package/dist/src/tui/prompt-recall.js +90 -0
  380. package/dist/src/tui/prompt-recall.js.map +1 -0
  381. package/dist/src/tui/react-environment.d.ts +11 -0
  382. package/dist/src/tui/react-environment.js +24 -0
  383. package/dist/src/tui/react-environment.js.map +1 -0
  384. package/dist/src/tui/rewind-search.d.ts +34 -0
  385. package/dist/src/tui/rewind-search.js +68 -0
  386. package/dist/src/tui/rewind-search.js.map +1 -0
  387. package/dist/src/tui/shell-command.d.ts +114 -0
  388. package/dist/src/tui/shell-command.js +310 -0
  389. package/dist/src/tui/shell-command.js.map +1 -0
  390. package/dist/src/tui/spend-advisory.d.ts +52 -0
  391. package/dist/src/tui/spend-advisory.js +64 -0
  392. package/dist/src/tui/spend-advisory.js.map +1 -0
  393. package/dist/src/tui/status-format.d.ts +120 -0
  394. package/dist/src/tui/status-format.js +192 -0
  395. package/dist/src/tui/status-format.js.map +1 -0
  396. package/dist/src/tui/subagent-format.d.ts +49 -0
  397. package/dist/src/tui/subagent-format.js +146 -0
  398. package/dist/src/tui/subagent-format.js.map +1 -0
  399. package/dist/src/tui/task-format.d.ts +29 -0
  400. package/dist/src/tui/task-format.js +87 -0
  401. package/dist/src/tui/task-format.js.map +1 -0
  402. package/dist/src/tui/terminal-bell.d.ts +20 -0
  403. package/dist/src/tui/terminal-bell.js +33 -0
  404. package/dist/src/tui/terminal-bell.js.map +1 -0
  405. package/dist/src/tui/tool-detail-presentation.d.ts +60 -0
  406. package/dist/src/tui/tool-detail-presentation.js +206 -0
  407. package/dist/src/tui/tool-detail-presentation.js.map +1 -0
  408. package/dist/src/tui/turn-state.d.ts +195 -0
  409. package/dist/src/tui/turn-state.js +548 -0
  410. package/dist/src/tui/turn-state.js.map +1 -0
  411. package/dist/src/tui/visual-language.d.ts +45 -0
  412. package/dist/src/tui/visual-language.js +57 -0
  413. package/dist/src/tui/visual-language.js.map +1 -0
  414. package/dist/src/version.d.ts +7 -0
  415. package/dist/src/version.js +38 -0
  416. package/dist/src/version.js.map +1 -0
  417. package/package.json +60 -0
@@ -0,0 +1,548 @@
1
+ import { classify } from '../agent/permission.js';
2
+ import { parsePlanInput, UPDATE_PLAN_TOOL_NAME } from '../tools/update-plan.js';
3
+ import { backgroundBashMode, compactBackgroundCallSummary, compactBackgroundResult, } from './background-tool-presentation.js';
4
+ import { diffStat, fileEditorDiff, fileEditorInputProjection } from './edit-diff.js';
5
+ import { fenceOpenAfter } from './markdown.js';
6
+ import { SHELL_TOOL_NAME, shellOutcomeStatus, shellOutcomeSummary, } from './shell-command.js';
7
+ import { shortDispatchId } from '../agents/dispatch-registry.js';
8
+ import { backgroundAckTaskId, backgroundDelegationAckSummary, backgroundDelegationLiveSummary, backgroundDelegationRequested, backgroundDelegationResultSummary, subagentCallSummary, } from './subagent-format.js';
9
+ import { compactEditDiff, expandedToolInput, toolResultPreview } from './tool-detail-presentation.js';
10
+ export const initialTurnState = {
11
+ history: [],
12
+ liveText: '',
13
+ answerCloseCommit: 0,
14
+ committedAnswer: '',
15
+ thinking: false,
16
+ activeTools: [],
17
+ livePlan: [],
18
+ toolDetailsExpanded: false,
19
+ staticEpoch: 0,
20
+ };
21
+ let idCounter = 0;
22
+ function nextId(prefix) {
23
+ idCounter += 1;
24
+ return `${prefix}-${idCounter}`;
25
+ }
26
+ export function turnReducer(state, action) {
27
+ switch (action.type) {
28
+ case 'userInput':
29
+ return {
30
+ ...state,
31
+ history: [...state.history, { kind: 'user', id: nextId('user'), text: action.text }],
32
+ };
33
+ case 'notice':
34
+ return {
35
+ ...state,
36
+ history: [
37
+ ...state.history,
38
+ { kind: 'notice', id: nextId('notice'), text: action.text, severity: action.severity ?? 'info' },
39
+ ],
40
+ };
41
+ case 'toggleToolDetails': {
42
+ const toolDetailsExpanded = !state.toolDetailsExpanded;
43
+ return {
44
+ ...state,
45
+ toolDetailsExpanded,
46
+ history: [
47
+ ...state.history,
48
+ {
49
+ kind: 'notice',
50
+ id: nextId('notice'),
51
+ text: `tool details: ${toolDetailsExpanded ? 'expanded' : 'compact'}`,
52
+ severity: 'info',
53
+ },
54
+ ],
55
+ };
56
+ }
57
+ case 'subagentProgress':
58
+ return {
59
+ ...state,
60
+ activeTools: state.activeTools.map((tool) => tool.name === 'subagent' && shortDispatchId(tool.id) === action.progress.dispatchId
61
+ ? { ...tool, subagentProgress: action.progress }
62
+ : tool),
63
+ };
64
+ case 'prepareAnswerClose':
65
+ // Ink cannot atomically move mutable rows into `<Static>`: if the same
66
+ // render removes `liveText` and appends that text to history, some terminals
67
+ // retain the old rows in scrollback before Static writes them again. The
68
+ // monotonically identified state change lets the driver await this specific
69
+ // React commit before flushing Ink and publishing contentBlockEvent.
70
+ // `committedAnswer` stays intact because closeAnswer still reconciles the
71
+ // authoritative block against every piece already written to Static.
72
+ if (action.id <= state.answerCloseCommit)
73
+ return state;
74
+ return { ...state, liveText: '', answerCloseCommit: action.id };
75
+ case 'turnEnded': {
76
+ return finishTurn(state);
77
+ }
78
+ case 'clear':
79
+ // `/clear` starts a new session, so the transcript of the old one goes with it.
80
+ // Everything conversation-shaped is dropped and the `<Static>` epoch is bumped
81
+ // (see {@link TurnState.staticEpoch}); `toolDetailsExpanded` is not, because it
82
+ // is how this *user* wants tool calls drawn, not part of any conversation.
83
+ return {
84
+ ...initialTurnState,
85
+ toolDetailsExpanded: state.toolDetailsExpanded,
86
+ staticEpoch: state.staticEpoch + 1,
87
+ };
88
+ case 'streamEvent':
89
+ return applyStreamEvent(state, action.event);
90
+ case 'shellStarted':
91
+ // The running `!` command borrows the tool panel: spinner, elapsed suffix and
92
+ // counted detail rows all come from machinery that already exists, so a user
93
+ // command adds no frame surface of its own. `input` holds the live output
94
+ // tail as plain text — `toolInputRows` renders it raw for this name.
95
+ return {
96
+ ...state,
97
+ activeTools: [
98
+ ...state.activeTools,
99
+ {
100
+ id: action.id,
101
+ name: SHELL_TOOL_NAME,
102
+ summary: `$ ${action.command.replace(/\s*\n\s*/g, ' ')}`,
103
+ startedAt: Date.now(),
104
+ input: '',
105
+ },
106
+ ],
107
+ };
108
+ case 'shellOutput':
109
+ return {
110
+ ...state,
111
+ activeTools: state.activeTools.map((tool) => tool.id === action.id ? { ...tool, input: action.tail } : tool),
112
+ };
113
+ case 'shellCommand':
114
+ // Composed from the action's recorded fields only, so a replayed
115
+ // `shellCommand` record produces this exact row. `expanded: false` always:
116
+ // the preview *is* the one bounded projection, complete with its marker.
117
+ return {
118
+ ...state,
119
+ activeTools: state.activeTools.filter((tool) => tool.name !== SHELL_TOOL_NAME),
120
+ history: [
121
+ ...state.history,
122
+ {
123
+ kind: 'tool',
124
+ id: nextId('tool'),
125
+ name: SHELL_TOOL_NAME,
126
+ summary: shellOutcomeSummary(action),
127
+ status: shellOutcomeStatus(action),
128
+ preview: action.output,
129
+ inputPreview: '',
130
+ expanded: false,
131
+ },
132
+ ],
133
+ };
134
+ }
135
+ }
136
+ function applyStreamEvent(state, event) {
137
+ switch (event.type) {
138
+ case 'modelStreamUpdateEvent': {
139
+ const inner = event.event;
140
+ if (inner.type !== 'modelContentBlockDeltaEvent')
141
+ return state;
142
+ switch (inner.delta.type) {
143
+ case 'textDelta':
144
+ // Incremental answer text: the only thing appended character by character.
145
+ return commitFinishedLines({
146
+ ...state,
147
+ liveText: state.liveText + inner.delta.text,
148
+ thinking: false,
149
+ });
150
+ case 'reasoningContentDelta':
151
+ // Reasoning is shown as a status indicator, never as answer text: it is
152
+ // a different register from the reply and interleaving them reads as
153
+ // corruption.
154
+ return { ...state, thinking: true };
155
+ default:
156
+ // toolUseInputDelta / citationsDelta: partial tool arguments and citation
157
+ // spans. The assembled values arrive on beforeToolCallEvent and
158
+ // contentBlockEvent, so nothing to draw from the partials.
159
+ return state;
160
+ }
161
+ }
162
+ case 'contentBlockEvent': {
163
+ const block = event.contentBlock;
164
+ if (block.type === 'textBlock') {
165
+ // The assembled block is authoritative — it closes off the accumulated
166
+ // deltas and survives any delta we failed to observe. What is different now
167
+ // is that some of those deltas are already in `<Static>`, which cannot be
168
+ // taken back, so this is a reconciliation rather than a write.
169
+ return closeAnswer(state, block.text.trim());
170
+ }
171
+ if (block.type === 'reasoningBlock') {
172
+ return { ...state, thinking: false };
173
+ }
174
+ return state;
175
+ }
176
+ case 'beforeToolCallEvent': {
177
+ // classify() already produces the human-readable summary the permission
178
+ // prompt uses; reusing it keeps one description of a tool call, not two.
179
+ const request = classify(event.toolUse.name, event.toolUse.input);
180
+ const backgroundMode = backgroundBashMode(event.toolUse.name, event.toolUse.input);
181
+ // Delegation rows carry the dispatch identity and the task: several children
182
+ // run at once, so three rows reading `subagent: general` distinguish nothing.
183
+ // Pure in the tool-use block — the reducer never reads the dispatch registry.
184
+ const baseSummary = subagentCallSummary(event.toolUse.name, event.toolUse.input, event.toolUse.toolUseId) ??
185
+ request.summary;
186
+ // A delegation the model routed to the SDK's background executor (SER-064):
187
+ // the row stays live while the child runs — the ack only releases the parent.
188
+ const background = backgroundDelegationRequested(event.toolUse.name, event.toolUse.input);
189
+ const summary = background ? backgroundDelegationLiveSummary(baseSummary) : baseSummary;
190
+ return {
191
+ ...flushLiveText(state),
192
+ thinking: false,
193
+ activeTools: [
194
+ ...state.activeTools,
195
+ {
196
+ id: event.toolUse.toolUseId,
197
+ name: event.toolUse.name,
198
+ summary,
199
+ startedAt: Date.now(),
200
+ input: event.toolUse.input,
201
+ ...(backgroundMode === undefined
202
+ ? {}
203
+ : {
204
+ backgroundMode,
205
+ compactSummary: compactBackgroundCallSummary(backgroundMode, event.toolUse.input),
206
+ }),
207
+ ...(background ? { backgroundDelegation: { baseSummary } } : {}),
208
+ },
209
+ ],
210
+ };
211
+ }
212
+ case 'toolResultEvent': {
213
+ // Foreground results already finished their row on `afterToolCallEvent`. The
214
+ // one result that reaches a still-live row is the SDK's background dispatch
215
+ // ack (SER-064): the executor returns it in place of an after-event, and the
216
+ // background run's own after-event finishes the row later. Anything else on a
217
+ // background row — admission failed, an unrecognized ack — means no run will
218
+ // follow, so the row finishes here with what the model received.
219
+ const result = event.result;
220
+ const active = state.activeTools.find((tool) => tool.id === result.toolUseId && tool.backgroundDelegation !== undefined);
221
+ if (active?.backgroundDelegation === undefined)
222
+ return state;
223
+ const taskId = result.status === 'error' ? undefined : backgroundAckTaskId(result.content);
224
+ if (taskId === undefined) {
225
+ return finishToolCall(state, { name: active.name, toolUseId: active.id, input: active.input }, result);
226
+ }
227
+ const baseSummary = active.backgroundDelegation.baseSummary;
228
+ return {
229
+ ...state,
230
+ activeTools: state.activeTools.map((tool) => tool.id === active.id ? { ...tool, backgroundDelegation: { baseSummary, taskId } } : tool),
231
+ history: [
232
+ ...state.history,
233
+ {
234
+ kind: 'tool',
235
+ id: nextId('tool'),
236
+ name: active.name,
237
+ summary: backgroundDelegationAckSummary(baseSummary, taskId),
238
+ status: 'ok',
239
+ preview: '',
240
+ inputPreview: '',
241
+ expanded: state.toolDetailsExpanded,
242
+ },
243
+ ],
244
+ };
245
+ }
246
+ case 'afterToolCallEvent':
247
+ return finishToolCall(state, event.toolUse, event.result);
248
+ case 'messageAddedEvent': {
249
+ // The SDK delivers a finished background task to the model as a synthetic
250
+ // `strands_background_task_result` tool-use/tool-result pair (SER-064). The
251
+ // run's own `afterToolCallEvent` has normally finished the row already; only a
252
+ // task that never ran its tool body — cancelled while queued, an execution
253
+ // error before the body — still has a live row here, and finishes with the
254
+ // delivered content so no row outlives its result. Ordinary tool-result
255
+ // messages carry model-issued tool-use ids, which never match a task id.
256
+ if (event.message.role !== 'user')
257
+ return state;
258
+ let next = state;
259
+ for (const block of event.message.content) {
260
+ if (block.type !== 'toolResultBlock')
261
+ continue;
262
+ const active = next.activeTools.find((tool) => tool.backgroundDelegation?.taskId === block.toolUseId);
263
+ if (active === undefined)
264
+ continue;
265
+ next = finishToolCall(next, { name: active.name, toolUseId: active.id, input: active.input }, block);
266
+ }
267
+ return next;
268
+ }
269
+ default:
270
+ return state;
271
+ }
272
+ }
273
+ /**
274
+ * Finishes one tool call's row from its result — the `afterToolCallEvent` body, in
275
+ * a function because a background delegation's ack, delivered pair and after-event
276
+ * must all end the same way (SER-064).
277
+ */
278
+ function finishToolCall(state, toolUse, result) {
279
+ const toolUseId = toolUse.toolUseId;
280
+ const active = state.activeTools.find((tool) => tool.id === toolUseId);
281
+ // The active row's summary first, then the same delegation projection, then
282
+ // the plain classification: a finished dispatch must not lose the identity
283
+ // the live row showed just because the panel entry was already dropped. A
284
+ // background-routed delegation ends as its result row.
285
+ let summary = active?.backgroundDelegation !== undefined
286
+ ? backgroundDelegationResultSummary(active.backgroundDelegation.baseSummary)
287
+ : active?.summary ??
288
+ subagentCallSummary(toolUse.name, toolUse.input, toolUseId) ??
289
+ classify(toolUse.name, toolUse.input).summary;
290
+ let preview = previewToolResult(result.content);
291
+ const status = result.status === 'error' ? (preview.startsWith('DENIED:') ? 'denied' : 'error') : 'ok';
292
+ const activeTools = state.activeTools.filter((tool) => tool.id !== toolUseId);
293
+ const toolInput = active?.input ?? toolUse.input;
294
+ const plan = status === 'ok' && toolUse.name === UPDATE_PLAN_TOOL_NAME
295
+ ? parsePlanInput(toolInput)
296
+ : undefined;
297
+ // Failures always retain the ordinary diagnostic. Compact presentation is
298
+ // applied only after a successful manager result has been safely decoded.
299
+ // Some SDK after-events omit the original input, so prefer the mode captured
300
+ // when the call entered the live panel.
301
+ const backgroundMode = active?.backgroundMode ?? backgroundBashMode(toolUse.name, toolUse.input);
302
+ if (backgroundMode !== undefined && !state.toolDetailsExpanded) {
303
+ // Compact labels stay bounded even when a call fails or its successful
304
+ // payload drifts. Failures and fallbacks still retain the full preview.
305
+ summary = active?.compactSummary ?? compactBackgroundCallSummary(backgroundMode, active?.input ?? toolUse.input);
306
+ if (status === 'ok') {
307
+ const compact = compactBackgroundResult(backgroundMode, active?.input ?? toolUse.input, result.content);
308
+ if (compact.kind === 'suppress')
309
+ return { ...state, activeTools };
310
+ if (compact.kind === 'compact') {
311
+ summary = compact.summary;
312
+ preview = compact.preview;
313
+ }
314
+ }
315
+ }
316
+ // The diff-bearing presentation of a finished fileEditor write, computed
317
+ // from the same input the SDK received. A finished row lands in `<Static>`
318
+ // scrollback — written once, never repainted — so the diff is shown
319
+ // complete in both modes: compact rows carry the bare diff, expanded rows
320
+ // the labelled projection. Only the live surfaces (active panel,
321
+ // permission box) stay bounded, and other tools keep the bounded
322
+ // `expandedToolInput` JSON.
323
+ const fullDiff = toolUse.name === 'fileEditor' ? fileEditorDiff(toolInput) : undefined;
324
+ const fullProjection = toolUse.name === 'fileEditor' ? fileEditorInputProjection(toolInput) : undefined;
325
+ return {
326
+ ...state,
327
+ activeTools,
328
+ livePlan: plan ?? state.livePlan,
329
+ history: [
330
+ ...state.history,
331
+ {
332
+ kind: 'tool',
333
+ id: nextId('tool'),
334
+ name: toolUse.name,
335
+ summary,
336
+ status,
337
+ // Bound before immutable history/replay state owns the string.
338
+ preview: toolResultPreview(preview, status, state.toolDetailsExpanded).join('\n'),
339
+ inputPreview: state.toolDetailsExpanded
340
+ ? fullProjection ?? expandedToolInput(toolInput, toolUse.name).join('\n')
341
+ : compactEditDiff(toolInput, toolUse.name).join('\n'),
342
+ expanded: state.toolDetailsExpanded,
343
+ ...(fullDiff === undefined ? {} : { diffStat: diffStat(fullDiff) }),
344
+ },
345
+ ],
346
+ };
347
+ }
348
+ /**
349
+ * Moves answer lines that can no longer change into `<Static>` history.
350
+ *
351
+ * Committed is every complete line up to — but not including — the **last non-blank
352
+ * complete line**. Two things fall out of that, and both are load-bearing:
353
+ *
354
+ * - The newest finished line is always held back, so `closeAnswer` always has
355
+ * something left to write. That closing piece is what carries the `last` part, and
356
+ * with it the blank row below the answer; Ink fixes an entry's margin when it
357
+ * writes it, so an answer that had already committed everything could never get
358
+ * that row back.
359
+ * - **Trailing blank lines are held back too.** `contentBlockEvent` trims the
360
+ * assembled text, so a blank line at the end of the answer is not part of it —
361
+ * committing one would make the authoritative text disagree with history and
362
+ * report a divergence for an answer that had none. Measured on `a\nb\nc\n\n\n`,
363
+ * which is an ordinary way for a model to finish.
364
+ *
365
+ * Interior blank lines *are* committed: a paragraph break is content, and holding it
366
+ * back would move the text under the cursor as the answer arrives.
367
+ *
368
+ * The committed text is recorded in `committedAnswer` verbatim, because that is what
369
+ * makes the reconciliation at the end a comparison rather than a guess.
370
+ */
371
+ function commitFinishedLines(state) {
372
+ const lines = state.liveText.split('\n');
373
+ // The final element is the line still arriving — never complete, always held.
374
+ let hold = lines.length - 1;
375
+ for (let index = lines.length - 2; index >= 0; index -= 1) {
376
+ if (lines[index].trim() !== '') {
377
+ hold = index;
378
+ break;
379
+ }
380
+ }
381
+ if (hold === 0)
382
+ return state;
383
+ let text = lines.slice(0, hold).join('\n');
384
+ const liveText = lines.slice(hold).join('\n');
385
+ if (state.committedAnswer === '') {
386
+ // The assembled block is trimmed at both ends, so leading blank lines are not
387
+ // part of the answer either.
388
+ text = text.replace(/^\s+/u, '');
389
+ if (text === '')
390
+ return { ...state, liveText };
391
+ }
392
+ return {
393
+ ...state,
394
+ liveText,
395
+ committedAnswer: state.committedAnswer === '' ? text : `${state.committedAnswer}\n${text}`,
396
+ history: [
397
+ ...state.history,
398
+ {
399
+ kind: 'assistant',
400
+ id: nextId('assistant'),
401
+ text,
402
+ part: state.committedAnswer === '' ? 'first' : 'middle',
403
+ // The fence state the pieces already in `<Static>` left behind; `''`
404
+ // (a `first` piece) is always closed-state.
405
+ codeOpen: fenceOpenAfter(state.committedAnswer),
406
+ },
407
+ ],
408
+ };
409
+ }
410
+ /**
411
+ * Closes the answer against the authoritative assembled text.
412
+ *
413
+ * Three outcomes, and the middle one is the whole reason this is not a plain write:
414
+ *
415
+ * - nothing committed yet → the answer enters history in one entry, exactly as it
416
+ * did before any of this existed;
417
+ * - the authoritative text continues what was committed → only the remainder is
418
+ * written, as the `last` part;
419
+ * - it *diverges* → the difference is stated as a warning and the authoritative
420
+ * text is written in full. The rows already printed are not retracted, because
421
+ * they cannot be; showing two versions with a line explaining why is the honest
422
+ * option, and silently dropping either one is not.
423
+ */
424
+ function closeAnswer(state, authoritative) {
425
+ const settled = { ...state, liveText: '', committedAnswer: '', thinking: false };
426
+ if (state.committedAnswer === '') {
427
+ if (authoritative === '')
428
+ return settled;
429
+ return { ...settled, history: [...state.history, answerEntry(authoritative, 'whole', false)] };
430
+ }
431
+ const committedCodeOpen = fenceOpenAfter(state.committedAnswer);
432
+ const prefix = `${state.committedAnswer}\n`;
433
+ if (authoritative === state.committedAnswer) {
434
+ // Defensive: `commitFinishedLines` holds back the last non-blank line, so there
435
+ // is normally something left to write. If a stream ever leaves nothing, the
436
+ // blank row below the answer is still owed, and an empty `last` entry is exactly
437
+ // that row and nothing else.
438
+ return { ...settled, history: [...state.history, answerEntry('', 'last', committedCodeOpen)] };
439
+ }
440
+ if (authoritative.startsWith(prefix)) {
441
+ return {
442
+ ...settled,
443
+ history: [...state.history, answerEntry(authoritative.slice(prefix.length), 'last', committedCodeOpen)],
444
+ };
445
+ }
446
+ return {
447
+ ...settled,
448
+ history: [
449
+ ...state.history,
450
+ {
451
+ kind: 'notice',
452
+ id: nextId('notice'),
453
+ text: 'the model’s final text differs from what was streamed; the lines above are what arrived, ' +
454
+ 'and the answer below is the authoritative version',
455
+ severity: 'warn',
456
+ },
457
+ // The authoritative text is written in full, so it styles from its own start.
458
+ answerEntry(authoritative, 'whole', false),
459
+ ],
460
+ };
461
+ }
462
+ function answerEntry(text, part, codeOpen) {
463
+ return { kind: 'assistant', id: nextId('assistant'), text, part, codeOpen };
464
+ }
465
+ /** Commits terminal-only turn projections once, appended after the closing answer. */
466
+ function finishTurn(state) {
467
+ // Flush anything the model left unterminated (e.g. a cancelled turn) so it is
468
+ // not lost when the live area clears. The final checklist is presentation-only
469
+ // and is *appended*, never inserted before entries already in history: Ink's
470
+ // `<Static>` consumes its items by index (`items.slice(index)`), so a mid-array
471
+ // insert shifts the already-written suffix back into the unconsumed window —
472
+ // the closing answer would be written to the terminal a second time and the
473
+ // checklist itself silently swallowed (the reported duplicate-final-reply bug,
474
+ // reproduced by `spike/probe-final-reply-duplication.ts`). Append-only is the
475
+ // one ordering `<Static>` can render exactly once.
476
+ const flushed = flushLiveText(state);
477
+ return {
478
+ ...flushed,
479
+ thinking: false,
480
+ activeTools: [],
481
+ livePlan: [],
482
+ history: state.livePlan.length === 0
483
+ ? flushed.history
484
+ : [...flushed.history, { kind: 'plan', id: nextId('plan'), plan: state.livePlan }],
485
+ };
486
+ }
487
+ /**
488
+ * Writes out whatever answer text is still uncommitted.
489
+ *
490
+ * Reached when a tool call interrupts the text, and when a turn ends without the
491
+ * model closing its block (a cancel, or a failure). Only the *uncommitted*
492
+ * remainder is written — the committed lines are already in history, and writing
493
+ * them again is the one thing progressive commits make easy to get wrong.
494
+ */
495
+ function flushLiveText(state) {
496
+ const text = state.liveText.trim();
497
+ if (text === '') {
498
+ if (state.committedAnswer === '')
499
+ return { ...state, liveText: '' };
500
+ // Committed lines with nothing left over still owe the blank row below.
501
+ return {
502
+ ...state,
503
+ liveText: '',
504
+ committedAnswer: '',
505
+ history: [...state.history, answerEntry('', 'last', fenceOpenAfter(state.committedAnswer))],
506
+ };
507
+ }
508
+ return {
509
+ ...state,
510
+ liveText: '',
511
+ committedAnswer: '',
512
+ history: [
513
+ ...state.history,
514
+ answerEntry(text, state.committedAnswer === '' ? 'whole' : 'last',
515
+ // `''` is closed-state, so this is right for the `whole` case too.
516
+ fenceOpenAfter(state.committedAnswer)),
517
+ ],
518
+ };
519
+ }
520
+ /** Flattens tool result content into text for the collapsed preview. */
521
+ export function previewToolResult(content) {
522
+ const parts = [];
523
+ for (const block of content) {
524
+ if (typeof block !== 'object' || block === null)
525
+ continue;
526
+ const typed = block;
527
+ if (typed.type === 'textBlock' && typeof typed.text === 'string') {
528
+ parts.push(typed.text);
529
+ }
530
+ else if (typed.type === 'jsonBlock') {
531
+ parts.push(safeStringify(typed.json));
532
+ }
533
+ else if (typeof typed.type === 'string') {
534
+ // Images, video and documents have no useful text form here.
535
+ parts.push(`[${typed.type}]`);
536
+ }
537
+ }
538
+ return parts.join('\n').trim();
539
+ }
540
+ function safeStringify(value) {
541
+ try {
542
+ return JSON.stringify(value) ?? String(value);
543
+ }
544
+ catch {
545
+ return String(value);
546
+ }
547
+ }
548
+ //# sourceMappingURL=turn-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-state.js","sourceRoot":"","sources":["../../../src/tui/turn-state.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAiB,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,GAExB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAiC,MAAM,gCAAgC,CAAC;AAChG,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,+BAA+B,EAC/B,6BAA6B,EAC7B,iCAAiC,EACjC,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AA4HtG,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;IACZ,iBAAiB,EAAE,CAAC;IACpB,eAAe,EAAE,EAAE;IACnB,QAAQ,EAAE,KAAK;IACf,WAAW,EAA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AC,IAAI,KAAK,WAAW,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;aAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1C,6DAA6D;YAC7D,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Darwin's semantic visual language.
3
+ *
4
+ * Colour reinforces hierarchy, but never carries a state by itself: the stable
5
+ * markers below survive ANSI stripping, monochrome terminals, logs, and pty tests.
6
+ * Keep component-specific layout out of this module — it names roles, not boxes.
7
+ */
8
+ export declare const visualColor: {
9
+ readonly identity: 'cyan';
10
+ readonly assistant: 'cyan';
11
+ readonly tool: 'cyan';
12
+ readonly active: 'cyan';
13
+ readonly success: 'green';
14
+ readonly information: 'cyan';
15
+ readonly warning: 'yellow';
16
+ readonly danger: 'red';
17
+ };
18
+ export declare const visualMarker: {
19
+ readonly identity: '◆';
20
+ readonly user: 'you>';
21
+ readonly assistant: 'darwin>';
22
+ readonly tool: 'tool ·';
23
+ readonly notice: {
24
+ readonly info: 'info ·';
25
+ readonly warn: 'warn !';
26
+ readonly error: 'error !';
27
+ };
28
+ readonly activeTool: 'tool ·';
29
+ readonly completion: '❯';
30
+ readonly permission: '◆';
31
+ };
32
+ export declare function noticeColor(severity: 'info' | 'warn' | 'error'): (typeof visualColor)[keyof typeof visualColor];
33
+ /**
34
+ * Colour for one diff-toned row: additions succeed-green, removals danger-red.
35
+ * The `+ `/`- ` markers on the row text stay the durable statement; this is the
36
+ * enhancement layered over them.
37
+ */
38
+ export declare function diffToneColor(tone: 'add' | 'remove'): (typeof visualColor)[keyof typeof visualColor];
39
+ /**
40
+ * Colour for markdown code in an assistant answer — inline `` `code` `` spans
41
+ * and fenced code block lines. The backticks and fences on the text stay the
42
+ * durable statement (they survive ANSI stripping); this is the enhancement
43
+ * layered over them, exactly like a diff row's tone.
44
+ */
45
+ export declare const markdownCodeColor: (typeof visualColor)[keyof typeof visualColor];