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 @@
1
+ {"version":3,"file":"task-format.js","sourceRoot":"","sources":["../../../src/tui/task-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAEnF,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,8FAA8F;AAC9F,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,qFAAqF;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AACxD,MAAM,CAAC,MAAM,4BAA4B,GAAG,sBAAsB,CAAC;AAEnE,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,KAAK,GAAG,+BAA+B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,mGAAmG;AACnG,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,IAAI,UAAU,CAAC,MAAM,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC5B,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,C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AC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YAC/J,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACvE,CAAC;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAA0B;IAC7D,MAAM,YAAY,GAAG;QACnB,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;QAC5D,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE;KAC3D,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,OAAO,mBAAmB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,QAAQ,OAAO,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;AACvK,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Config-gated terminal attention bell for the interactive TUI driver.
3
+ *
4
+ * One raw BEL (`\x07`) goes straight to the process's real stdout at the two
5
+ * driver-owned moments a detached user needs back: a permission prompt being
6
+ * published to the screen, and a turn completing. BEL is a non-printing control
7
+ * byte, so it is never an Ink row — the frame budget, ANSI-stripped pty
8
+ * assertions, `/export` byte-stability and replay are all untouched.
9
+ *
10
+ * Deliberately not wired anywhere else: never per frame render, never in the
11
+ * headless drivers (`-p`/structured), never for child agents, and never inside
12
+ * lifecycle hook command execution. Disabled (the default) performs no write at
13
+ * all, so the off path stays byte-identical to before the feature existed.
14
+ */
15
+ export declare const TERMINAL_BELL = "\u0007";
16
+ /**
17
+ * Writes exactly one BEL when `enabled`, nothing otherwise. The injectable
18
+ * writer exists only for tests; production callers use the real stdout.
19
+ */
20
+ export declare function ringTerminalBell(enabled: boolean, write?: (chunk: string) => void): void;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Config-gated terminal attention bell for the interactive TUI driver.
3
+ *
4
+ * One raw BEL (`\x07`) goes straight to the process's real stdout at the two
5
+ * driver-owned moments a detached user needs back: a permission prompt being
6
+ * published to the screen, and a turn completing. BEL is a non-printing control
7
+ * byte, so it is never an Ink row — the frame budget, ANSI-stripped pty
8
+ * assertions, `/export` byte-stability and replay are all untouched.
9
+ *
10
+ * Deliberately not wired anywhere else: never per frame render, never in the
11
+ * headless drivers (`-p`/structured), never for child agents, and never inside
12
+ * lifecycle hook command execution. Disabled (the default) performs no write at
13
+ * all, so the off path stays byte-identical to before the feature existed.
14
+ */
15
+ export const TERMINAL_BELL = '\u0007';
16
+ /**
17
+ * Writes exactly one BEL when `enabled`, nothing otherwise. The injectable
18
+ * writer exists only for tests; production callers use the real stdout.
19
+ */
20
+ export function ringTerminalBell(enabled, write = writeToStdout) {
21
+ if (!enabled)
22
+ return;
23
+ try {
24
+ write(TERMINAL_BELL);
25
+ }
26
+ catch {
27
+ // A closed or broken stdout must never take down the session for a chime.
28
+ }
29
+ }
30
+ function writeToStdout(chunk) {
31
+ process.stdout.write(chunk);
32
+ }
33
+ //# sourceMappingURL=terminal-bell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-bell.js","sourceRoot":"","sources":["../../../src/tui/terminal-bell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAgB,EAChB,KAAK,GAA4B,aAAa;IAE9C,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC;QACH,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;IAC5E,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,60 @@
1
+ /** Bounded, Unicode-safe presentation of tool inputs and results. */
2
+ export type ToolPreviewStatus = 'ok' | 'error' | 'denied';
3
+ export declare const COMPACT_RESULT_CODE_POINTS = 2000;
4
+ export declare const COMPACT_RESULT_LINES = 4;
5
+ export declare const EXPANDED_INPUT_CODE_POINTS = 8000;
6
+ export declare const EXPANDED_INPUT_LINES = 100;
7
+ export declare const EXPANDED_RESULT_CODE_POINTS = 32000;
8
+ export declare const EXPANDED_RESULT_LINES = 200;
9
+ export declare const PERMISSION_DETAIL_CODE_POINTS = 500;
10
+ export declare const PERMISSION_DETAIL_LINES = 14;
11
+ export declare const PERMISSION_SUMMARY_CODE_POINTS = 160;
12
+ export interface TextBounds {
13
+ codePoints: number;
14
+ lines: number;
15
+ }
16
+ /** Permission summary, bounded as one rendered headline. */
17
+ export declare function permissionSummary(summary: string): string;
18
+ /** Permission detail, bounded without changing any short source value. */
19
+ export declare function permissionDetail(value: string): string[];
20
+ /** JSON when possible, a defensive string fallback otherwise. */
21
+ export declare function serializeToolInput(input: unknown): string;
22
+ /**
23
+ * Expanded tool input, bounded from the head because inputs read in source order.
24
+ *
25
+ * A `fileEditor` write is projected as labelled header lines plus the marker-
26
+ * prefixed line diff of the same input — the identical strings the JSON carried,
27
+ * in the shape the permission box already presents — and falls back to JSON for
28
+ * anything the diff reader does not recognize. Presentation-time only: the SDK
29
+ * retains and receives the original input object either way.
30
+ */
31
+ export declare function expandedToolInput(input: unknown, toolName?: string): string[];
32
+ /** Result preview for the mode selected when the call completed. */
33
+ export declare function toolResultPreview(preview: string, status: ToolPreviewStatus, expanded: boolean): string[];
34
+ /**
35
+ * The diff a finished `fileEditor` write shows in default compact mode —
36
+ * SER-023's answer to `inputPreview: ''`, which showed no diff at all for an
37
+ * auto-approved edit — shown **complete, never truncated**.
38
+ *
39
+ * Finished tool rows are written once into `<Static>` scrollback and never
40
+ * redrawn, so a large diff costs scrollback length, not live-frame rows — the
41
+ * frame budget only governs what is repainted. The live surfaces (the active
42
+ * tool panel and the permission box) keep their existing bounds; this
43
+ * projection is for history rows only.
44
+ *
45
+ * Returns `[]` for anything that is not a `fileEditor` write the diff reader
46
+ * recognizes — those keep today's no-input compact presentation.
47
+ */
48
+ export declare function compactEditDiff(input: unknown, toolName?: string): string[];
49
+ /**
50
+ * Applies independent logical-line and code-point caps without splitting a
51
+ * surrogate pair. Success keeps the head, errors the tail, and denials retain
52
+ * their leading reason plus the diagnostic tail.
53
+ */
54
+ export declare function boundText(text: string, status: ToolPreviewStatus, bounds: TextBounds): string[];
55
+ /**
56
+ * Exported for `shell-command.ts`, whose collection cap can drop output that
57
+ * `boundText` never saw: the `!` projection recomputes this marker over the true
58
+ * totals so the one truncation vocabulary never understates.
59
+ */
60
+ export declare function truncationMarker(omittedPoints: number, omittedLines: number): string;
@@ -0,0 +1,206 @@
1
+ /** Bounded, Unicode-safe presentation of tool inputs and results. */
2
+ import { REPLACE_ALL_ROW, fileEditorDiff, fileEditorInputProjection, fileEditorReplaceAll } from './edit-diff.js';
3
+ export const COMPACT_RESULT_CODE_POINTS = 2_000;
4
+ export const COMPACT_RESULT_LINES = 4;
5
+ export const EXPANDED_INPUT_CODE_POINTS = 8_000;
6
+ export const EXPANDED_INPUT_LINES = 100;
7
+ export const EXPANDED_RESULT_CODE_POINTS = 32_000;
8
+ export const EXPANDED_RESULT_LINES = 200;
9
+ export const PERMISSION_DETAIL_CODE_POINTS = 500;
10
+ export const PERMISSION_DETAIL_LINES = 14;
11
+ export const PERMISSION_SUMMARY_CODE_POINTS = 160;
12
+ /** Permission summary, bounded as one rendered headline. */
13
+ export function permissionSummary(summary) {
14
+ return boundPermissionText(summary, {
15
+ codePoints: PERMISSION_SUMMARY_CODE_POINTS,
16
+ lines: 1,
17
+ }).join('\n');
18
+ }
19
+ /** Permission detail, bounded without changing any short source value. */
20
+ export function permissionDetail(value) {
21
+ return boundPermissionText(value, {
22
+ codePoints: PERMISSION_DETAIL_CODE_POINTS,
23
+ lines: PERMISSION_DETAIL_LINES,
24
+ });
25
+ }
26
+ /**
27
+ * Head projection for security-sensitive permission text. Unlike tool previews,
28
+ * short blank values are significant and the explicit marker consumes the same
29
+ * line/code-point budgets as retained source content.
30
+ */
31
+ function boundPermissionText(text, bounds) {
32
+ const sourceLines = text.split('\n');
33
+ const sourcePoints = [...text];
34
+ if (sourceLines.length <= bounds.lines && sourcePoints.length <= bounds.codePoints) {
35
+ return sourceLines;
36
+ }
37
+ const markerOwnsLine = bounds.lines > 1;
38
+ const contentLines = markerOwnsLine ? bounds.lines - 1 : 1;
39
+ let marker = permissionTruncationMarker(sourcePoints.length, sourceLines.length - 1);
40
+ let kept = '';
41
+ // Omission counts affect marker width, which affects retained content. Iterate
42
+ // to the tiny fixed point rather than allowing a digit boundary to exceed the cap.
43
+ for (;;) {
44
+ // A newline (detail) or space (summary) separates retained content from marker.
45
+ const separatorPoints = kept === '' ? 0 : 1;
46
+ const contentBudget = Math.max(0, bounds.codePoints - [...marker].length - separatorPoints);
47
+ kept = takeHead(sourceLines, contentLines, contentBudget).join('\n');
48
+ const keptLines = kept === '' ? 0 : kept.split('\n').length;
49
+ const next = permissionTruncationMarker(sourcePoints.length - [...kept].length, Math.max(0, sourceLines.length - keptLines));
50
+ if (next === marker)
51
+ break;
52
+ marker = next;
53
+ }
54
+ if (!markerOwnsLine)
55
+ return [`${kept}${kept === '' ? '' : ' '}${marker}`];
56
+ return kept === '' ? [marker] : [...kept.split('\n'), marker];
57
+ }
58
+ function permissionTruncationMarker(omittedPoints, omittedLines) {
59
+ const points = `${omittedPoints} code point${omittedPoints === 1 ? '' : 's'}`;
60
+ const lines = omittedLines === 0
61
+ ? ''
62
+ : ` and ${omittedLines} line${omittedLines === 1 ? '' : 's'}`;
63
+ return `… truncated ${points}${lines}`;
64
+ }
65
+ /** JSON when possible, a defensive string fallback otherwise. */
66
+ export function serializeToolInput(input) {
67
+ try {
68
+ // Pretty-print in expanded mode so structured input is inspectable and the
69
+ // independent logical-line bound has useful work to do. This is only a TUI
70
+ // projection; the SDK retains and receives the original input object.
71
+ const json = JSON.stringify(input, null, 2);
72
+ if (json !== undefined)
73
+ return json;
74
+ }
75
+ catch {
76
+ // Fall through to the one representation still available.
77
+ }
78
+ try {
79
+ return String(input);
80
+ }
81
+ catch {
82
+ return '[unprintable input]';
83
+ }
84
+ }
85
+ /**
86
+ * Expanded tool input, bounded from the head because inputs read in source order.
87
+ *
88
+ * A `fileEditor` write is projected as labelled header lines plus the marker-
89
+ * prefixed line diff of the same input — the identical strings the JSON carried,
90
+ * in the shape the permission box already presents — and falls back to JSON for
91
+ * anything the diff reader does not recognize. Presentation-time only: the SDK
92
+ * retains and receives the original input object either way.
93
+ */
94
+ export function expandedToolInput(input, toolName) {
95
+ const projected = toolName === 'fileEditor' ? fileEditorInputProjection(input) : undefined;
96
+ return boundText(projected ?? serializeToolInput(input), 'ok', {
97
+ codePoints: EXPANDED_INPUT_CODE_POINTS,
98
+ lines: EXPANDED_INPUT_LINES,
99
+ });
100
+ }
101
+ /** Result preview for the mode selected when the call completed. */
102
+ export function toolResultPreview(preview, status, expanded) {
103
+ return boundText(preview, status, expanded
104
+ ? { codePoints: EXPANDED_RESULT_CODE_POINTS, lines: EXPANDED_RESULT_LINES }
105
+ : { codePoints: COMPACT_RESULT_CODE_POINTS, lines: COMPACT_RESULT_LINES });
106
+ }
107
+ /**
108
+ * The diff a finished `fileEditor` write shows in default compact mode —
109
+ * SER-023's answer to `inputPreview: ''`, which showed no diff at all for an
110
+ * auto-approved edit — shown **complete, never truncated**.
111
+ *
112
+ * Finished tool rows are written once into `<Static>` scrollback and never
113
+ * redrawn, so a large diff costs scrollback length, not live-frame rows — the
114
+ * frame budget only governs what is repainted. The live surfaces (the active
115
+ * tool panel and the permission box) keep their existing bounds; this
116
+ * projection is for history rows only.
117
+ *
118
+ * Returns `[]` for anything that is not a `fileEditor` write the diff reader
119
+ * recognizes — those keep today's no-input compact presentation.
120
+ */
121
+ export function compactEditDiff(input, toolName) {
122
+ if (toolName !== 'fileEditor')
123
+ return [];
124
+ const diff = fileEditorDiff(input);
125
+ if (diff === undefined)
126
+ return [];
127
+ // A `replace_all: true` str_replace states its scope on one header row above
128
+ // the bare pair (SER-055) — input-derived, so the finished row can say "every
129
+ // occurrence" without ever reading the file; the stat stays the pair's.
130
+ return [...(fileEditorReplaceAll(input) ? [REPLACE_ALL_ROW] : []), ...diff.split('\n')];
131
+ }
132
+ /**
133
+ * Applies independent logical-line and code-point caps without splitting a
134
+ * surrogate pair. Success keeps the head, errors the tail, and denials retain
135
+ * their leading reason plus the diagnostic tail.
136
+ */
137
+ export function boundText(text, status, bounds) {
138
+ if (text.trim() === '' || bounds.codePoints <= 0 || bounds.lines <= 0)
139
+ return [];
140
+ const sourceLines = text.split('\n');
141
+ const originalPoints = [...text].length;
142
+ let kept;
143
+ switch (status) {
144
+ case 'ok':
145
+ kept = takeHead(sourceLines, bounds.lines, bounds.codePoints);
146
+ break;
147
+ case 'error':
148
+ kept = takeTail(sourceLines, bounds.lines, bounds.codePoints);
149
+ break;
150
+ case 'denied':
151
+ kept = takeDenied(sourceLines, bounds.lines, bounds.codePoints);
152
+ break;
153
+ }
154
+ const keptText = kept.join('\n');
155
+ if (keptText === text)
156
+ return kept;
157
+ const omittedPoints = Math.max(0, originalPoints - [...keptText].length);
158
+ const omittedLines = Math.max(0, sourceLines.length - kept.length);
159
+ const marker = truncationMarker(omittedPoints, omittedLines);
160
+ if (status === 'ok')
161
+ return [...kept, marker];
162
+ if (status === 'error')
163
+ return [marker, ...kept];
164
+ if (kept.length <= 1)
165
+ return [...kept, marker];
166
+ return [kept[0], marker, ...kept.slice(1)];
167
+ }
168
+ function takeHead(lines, lineLimit, pointLimit) {
169
+ const candidate = lines.slice(0, lineLimit).join('\n');
170
+ return [...candidate].slice(0, pointLimit).join('').split('\n');
171
+ }
172
+ function takeTail(lines, lineLimit, pointLimit) {
173
+ const candidate = lines.slice(-lineLimit).join('\n');
174
+ return [...candidate].slice(-pointLimit).join('').split('\n');
175
+ }
176
+ function takeDenied(lines, lineLimit, pointLimit) {
177
+ const first = lines[0] ?? '';
178
+ if (lines.length === 1 || lineLimit === 1) {
179
+ return [[...first].slice(0, pointLimit).join('')];
180
+ }
181
+ const firstPoints = [...first];
182
+ if (firstPoints.length >= pointLimit)
183
+ return [firstPoints.slice(0, pointLimit).join('')];
184
+ const tail = lines.slice(1).slice(-(lineLimit - 1)).join('\n');
185
+ const tailBudget = Math.max(0, pointLimit - firstPoints.length - 1);
186
+ // `slice(-0)` is `slice(0)`, not an empty slice. Without this guard, a
187
+ // denial whose reason consumes all but the separating newline budget would
188
+ // retain its entire tail and bypass the code-point cap.
189
+ if (tailBudget === 0)
190
+ return [first];
191
+ const keptTail = [...tail].slice(-tailBudget).join('');
192
+ return keptTail === '' ? [first] : [first, ...keptTail.split('\n')];
193
+ }
194
+ /**
195
+ * Exported for `shell-command.ts`, whose collection cap can drop output that
196
+ * `boundText` never saw: the `!` projection recomputes this marker over the true
197
+ * totals so the one truncation vocabulary never understates.
198
+ */
199
+ export function truncationMarker(omittedPoints, omittedLines) {
200
+ const points = `${omittedPoints} code point${omittedPoints === 1 ? '' : 's'}`;
201
+ const lines = omittedLines === 0
202
+ ? ''
203
+ : ` and ${omittedLines} line${omittedLines === 1 ? '' : 's'}`;
204
+ return `… truncated ${points}${lines}`;
205
+ }
206
+ //# sourceMappingURL=tool-detail-presentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-detail-presentation.js","sourceRoot":"","sources":["../../../src/tui/tool-detail-presentation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAIlH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAOlD,4DAA4D;AAC5D,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,mBAAmB,CAAC,OAAO,EAAE;QAClC,UAAU,EAAE,8BAA8B;QAC1C,KAAK,EAAE,CAAC;KACT,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,mBAAmB,CAAC,KAAK,EAAE;QAChC,UAAU,EAAE,6BAA6B;QACzC,KAAK,EAAE,uBAAuB;KAC/B,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,IAAY,EAAE,MAAkB;IAC3D,MAAM,WAAW,GAAG,IA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AAM,KAAK,GAAG,YAAY,KAAK,CAAC;QAC9B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,QAAQ,YAAY,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IAChE,OAAO,eAAe,MAAM,GAAG,KAAK,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Maps SDK stream events onto what the TUI draws.
3
+ *
4
+ * Kept as a pure reducer, separate from the components, so the event mapping can
5
+ * be tested without a terminal — the part most likely to break when the SDK's
6
+ * event shapes change.
7
+ *
8
+ * Event mapping follows the catalog measured in
9
+ * `research/spike-results.md` §4.
10
+ */
11
+ import type { AgentStreamEvent } from '@strands-agents/sdk';
12
+ import { type PlanItem } from '../tools/update-plan.js';
13
+ import { type BackgroundBashMode } from './background-tool-presentation.js';
14
+ import { type ShellOutcome } from './shell-command.js';
15
+ import { type SubagentDispatchProgress } from '../agents/dispatch-registry.js';
16
+ export type HistoryItem = {
17
+ kind: 'user';
18
+ id: string;
19
+ text: string;
20
+ } | {
21
+ kind: 'assistant';
22
+ id: string;
23
+ text: string;
24
+ part: AnswerPart;
25
+ /**
26
+ * Fence state at the start of this piece — true when a fenced code block
27
+ * opened by an earlier piece of the same answer is still open. Decided at
28
+ * push time like {@link AnswerPart}, because `<Static>` never redraws what
29
+ * it wrote; purely presentational (`markdown.ts`), invisible to replay.
30
+ */
31
+ codeOpen: boolean;
32
+ } | {
33
+ kind: 'tool';
34
+ id: string;
35
+ name: string;
36
+ summary: string;
37
+ status: ToolStatus;
38
+ preview: string;
39
+ /** Already bounded before entering immutable transcript history. */
40
+ inputPreview: string;
41
+ expanded: boolean;
42
+ /**
43
+ * `+added/-removed` line counts of a `fileEditor` write's diff, derived from
44
+ * the same markers the diff states (`edit-diff.ts`). Absent means "not a
45
+ * diff", never 0 — non-fileEditor calls and unrecognized shapes carry
46
+ * nothing. Rendering only: `formatReplay` prints `summary`/`preview` alone,
47
+ * so replay and `/export` output stay byte-identical.
48
+ */
49
+ diffStat?: {
50
+ readonly added: number;
51
+ readonly removed: number;
52
+ };
53
+ } | {
54
+ kind: 'notice';
55
+ id: string;
56
+ text: string;
57
+ severity: NoticeSeverity;
58
+ } | {
59
+ kind: 'plan';
60
+ id: string;
61
+ plan: readonly PlanItem[];
62
+ };
63
+ /**
64
+ * Where one assistant entry sits in its answer.
65
+ *
66
+ * An answer reaches history in pieces now — finished lines are committed to
67
+ * `<Static>` while the rest is still arriving — so the label and the blank row
68
+ * below cannot both belong to every entry, or a 120-line answer becomes 120
69
+ * labelled blocks. `<Static>` never redraws what it wrote, so which piece carries
70
+ * which cannot be decided later: it is decided as each piece is pushed, which is
71
+ * why the last complete line is always held back (see `commitFinishedLines`).
72
+ *
73
+ * - `whole` — the entire answer in one entry: label above, blank row below.
74
+ * - `first` — label, no blank row; more is coming.
75
+ * - `middle` — neither.
76
+ * - `last` — no label, blank row below.
77
+ */
78
+ export type AnswerPart = 'whole' | 'first' | 'middle' | 'last';
79
+ export type ToolStatus = 'ok' | 'error' | 'denied';
80
+ /**
81
+ * How a notice renders, not what it says: `error` for something that failed
82
+ * outright, `warn` for a degradation the session survives, `info` for the rest.
83
+ */
84
+ export type NoticeSeverity = 'info' | 'warn' | 'error';
85
+ /** A tool call that has started but not finished. */
86
+ export interface ActiveTool {
87
+ id: string;
88
+ name: string;
89
+ summary: string;
90
+ /** Epoch ms when the call entered the live panel; drives the elapsed suffix. */
91
+ startedAt: number;
92
+ compactSummary?: string;
93
+ /** Raw only while active; the renderer bounds it before drawing. */
94
+ input: unknown;
95
+ /** Safe registry-only progress for an active delegation row. */
96
+ subagentProgress?: SubagentDispatchProgress;
97
+ backgroundMode?: BackgroundBashMode;
98
+ /**
99
+ * Set when the model routed this delegation to the SDK's background executor
100
+ * (SER-064). `baseSummary` is the row's label without the background marker;
101
+ * `taskId` arrives with the SDK's ack and lets the delivered
102
+ * `strands_background_task_result` pair find this row if no `afterToolCallEvent`
103
+ * ever does.
104
+ */
105
+ backgroundDelegation?: {
106
+ readonly baseSummary: string;
107
+ readonly taskId?: string;
108
+ };
109
+ }
110
+ export interface TurnState {
111
+ /** Finished entries, rendered once and never redrawn. */
112
+ history: HistoryItem[];
113
+ /** Assistant text still arriving, and not yet committed to history. */
114
+ liveText: string;
115
+ /** Latest terminal-only close preparation committed by React. */
116
+ answerCloseCommit: number;
117
+ /**
118
+ * Text of the in-flight answer already committed to `<Static>`, newlines
119
+ * included, `''` when no piece of the current answer has been written yet.
120
+ *
121
+ * Kept because `<Static>` cannot be taken back: when `contentBlockEvent` closes
122
+ * the answer with the authoritative text, this is what that text is reconciled
123
+ * against — the remainder is appended if it is a continuation, and a divergence
124
+ * has to be *said* rather than silently corrected.
125
+ */
126
+ committedAnswer: string;
127
+ /** True while the model is emitting reasoning rather than answer text. */
128
+ thinking: boolean;
129
+ activeTools: ActiveTool[];
130
+ /** Latest successful whole-list update in this turn; never persisted or replay-authored. */
131
+ livePlan: readonly PlanItem[];
132
+ /** Session-local display preference; immutable Static history is never rewritten. */
133
+ toolDetailsExpanded: boolean;
134
+ /**
135
+ * Bumped by `clear`, and used as the `<Static>` React key.
136
+ *
137
+ * Emptying `history` is not enough to clear the screen: Ink accumulates every byte
138
+ * `<Static>` ever wrote in `fullStaticOutput` and re-emits it on any later
139
+ * whole-screen redraw, so the old transcript would reappear at the next overflow.
140
+ * Remounting `<Static>` is what makes Ink drop that buffer (`reconciler.js` fires
141
+ * `onStaticChange` on a node-identity change), which is why this is a key and not a
142
+ * counter nobody reads.
143
+ */
144
+ staticEpoch: number;
145
+ }
146
+ export declare const initialTurnState: TurnState;
147
+ export type TurnAction = {
148
+ type: 'userInput';
149
+ text: string;
150
+ } | {
151
+ type: 'notice';
152
+ text: string;
153
+ severity?: NoticeSeverity;
154
+ } | {
155
+ type: 'toggleToolDetails';
156
+ } | {
157
+ type: 'subagentProgress';
158
+ progress: SubagentDispatchProgress;
159
+ } | {
160
+ type: 'streamEvent';
161
+ event: AgentStreamEvent;
162
+ }
163
+ /** Clears mutable answer rows and identifies the React commit the driver must await. */
164
+ | {
165
+ type: 'prepareAnswerClose';
166
+ id: number;
167
+ } | {
168
+ type: 'turnEnded';
169
+ } | {
170
+ type: 'clear';
171
+ }
172
+ /** A `!` command started: one pseudo-tool row in the live panel (live only, never replayed). */
173
+ | {
174
+ type: 'shellStarted';
175
+ id: string;
176
+ command: string;
177
+ }
178
+ /** Fresh live tail for the running `!` command's detail rows (live only). */
179
+ | {
180
+ type: 'shellOutput';
181
+ id: string;
182
+ tail: string;
183
+ }
184
+ /**
185
+ * A `!` command finished. Carries recorded fields only — the reducer composes the
186
+ * finished row from them, which is what lets replay dispatch the identical action
187
+ * from a `shellCommand` record and reproduce the identical history.
188
+ */
189
+ | ({
190
+ type: 'shellCommand';
191
+ output: string;
192
+ } & ShellOutcome);
193
+ export declare function turnReducer(state: TurnState, action: TurnAction): TurnState;
194
+ /** Flattens tool result content into text for the collapsed preview. */
195
+ export declare function previewToolResult(content: readonly unknown[]): string;