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,256 @@
1
+ /**
2
+ * Prompt history, read out of the record that already exists.
3
+ *
4
+ * Darwin never had prompt history, and never needed a store for one: every prompt a
5
+ * session sent is already a `userInput` line in
6
+ * `~/.darwin/sessions/<project-key>/<session-id>/trajectory.jsonl`, which is
7
+ * append-only, per project, and readable with no model call and no network. So this
8
+ * module is a *reader* — it opens nothing else, writes nothing, and repairs nothing.
9
+ * Everything it is allowed to say about damage it says by counting, exactly like
10
+ * {@link readTrajectory}.
11
+ *
12
+ * Two properties are load-bearing and neither is obvious.
13
+ *
14
+ * **It reads tails, not files.** A trajectory may reach `MAX_FILE_BYTES` (64 MiB), and
15
+ * the prompts a person wants back are the *last* ones written. Reading the whole file
16
+ * to keep 100 strings would be I/O nobody asked for, so each record is read from its
17
+ * end ({@link MAX_HISTORY_TAIL_BYTES}) and the first line of that window — which the
18
+ * byte offset may have cut in half — is dropped and counted. That is the same
19
+ * tolerate-and-report rule the reader already has for an interrupted write.
20
+ *
21
+ * **What it offers is what was *sent*.** The record's `text` is the string handed to
22
+ * `agent.stream()`, so a skill or project command appears expanded (that is the
23
+ * trajectory contract, not a choice made here). An expanded skill is a multi-kilobyte
24
+ * document, and putting one back in the editor would be useless; entries past
25
+ * {@link MAX_HISTORY_ENTRY_CHARS} are therefore skipped and counted. That cap sits
26
+ * *below* the record's own field cap (`MAX_FIELD_CHARS`, 8000), which is the second
27
+ * reason for it: a `userInput` text that was truncated on the way in must never be
28
+ * offered back, because re-sending a silently shortened prompt is worse than being
29
+ * offered nothing.
30
+ *
31
+ * Local commands (`/usage`, `/mode`, `/clear`, …) never reach `AgentRuntime.send` and
32
+ * so were never recorded; empty submissions never reach it either. Neither needs
33
+ * filtering here — history is what the session sent, and those were never sent.
34
+ */
35
+ import { open, stat } from 'node:fs/promises';
36
+ import { listSessionIds, trajectoryPath } from '../agent/session.js';
37
+ import { parseRecordLine } from './record.js';
38
+ /** Prompts kept in memory, newest first, after consecutive duplicates are collapsed. */
39
+ export const MAX_HISTORY_ENTRIES = 100;
40
+ /**
41
+ * Longest prompt offered back, in code points.
42
+ *
43
+ * Below the record's own `MAX_FIELD_CHARS` on purpose — see the module note. Also the
44
+ * bound that keeps an expanded skill body out of the editor.
45
+ */
46
+ export const MAX_HISTORY_ENTRY_CHARS = 4000;
47
+ /** Trajectory files opened by one read. */
48
+ export const MAX_HISTORY_SESSIONS = 20;
49
+ /**
50
+ * Sessions whose record is stat-ed to order them before those files are chosen.
51
+ *
52
+ * Ordering by the record's own mtime rather than by session id is what keeps a
53
+ * `--session my-experiment` run in its real place: ids sort chronologically only
54
+ * because darwin generates them that way, and a named one sorts alphabetically.
55
+ */
56
+ export const MAX_HISTORY_STAT_SESSIONS = 200;
57
+ /** Bytes read from the end of one record. */
58
+ export const MAX_HISTORY_TAIL_BYTES = 256 * 1024;
59
+ /** The reading a session starts from, and the one an empty project keeps. */
60
+ export const NO_PROMPT_HISTORY = {
61
+ entries: [],
62
+ available: 0,
63
+ entriesBounded: false,
64
+ sessionsRead: 0,
65
+ sessionsSkipped: 0,
66
+ tailBounded: 0,
67
+ longSkipped: 0,
68
+ problem: undefined,
69
+ };
70
+ /**
71
+ * This project's prompts, newest first.
72
+ *
73
+ * Never rejects: a missing session directory, an unreadable record, a half-written
74
+ * line and a project that has never run are all *readings*, not failures — the editor
75
+ * has to stay usable while `trajectory: false` is in effect, and an editor that threw
76
+ * on a keystroke because a file was absent would be a worse feature than no history.
77
+ */
78
+ export async function readPromptHistory(projectRoot) {
79
+ let problem;
80
+ let sessionIds = [];
81
+ try {
82
+ sessionIds = await listSessionIds(projectRoot);
83
+ }
84
+ catch (error) {
85
+ // `listSessionIds` already swallows a missing directory; this is the belt to that
86
+ // braces, so no reading can become an exception on the editor's path.
87
+ return { ...NO_PROMPT_HISTORY, problem: describe(error) };
88
+ }
89
+ const statted = sessionIds.slice(0, MAX_HISTORY_STAT_SESSIONS);
90
+ let sessionsSkipped = sessionIds.length - statted.length;
91
+ const found = [];
92
+ await Promise.all(statted.map(async (sessionId) => {
93
+ const file = trajectoryPath(projectRoot, sessionId);
94
+ try {
95
+ const info = await stat(file);
96
+ if (info.isFile() && info.size > 0)
97
+ found.push({ file, mtimeMs: info.mtimeMs, size: info.size });
98
+ }
99
+ catch {
100
+ // No record for this session — the ordinary case for a session that started and
101
+ // exited without a turn, and for every session of a run with `trajectory: false`.
102
+ }
103
+ }));
104
+ // Newest record first: the prompt a person wants back is almost always from the last
105
+ // conversation they had here.
106
+ found.sort((left, right) => right.mtimeMs - left.mtimeMs);
107
+ const chosen = found.slice(0, MAX_HISTORY_SESSIONS);
108
+ sessionsSkipped += found.length - chosen.length;
109
+ const candidates = [];
110
+ let sessionsRead = 0;
111
+ let tailBounded = 0;
112
+ let longSkipped = 0;
113
+ let entriesBounded = false;
114
+ for (const record of chosen) {
115
+ let tail;
116
+ try {
117
+ tail = await readTail(record.file, record.size);
118
+ }
119
+ catch (error) {
120
+ problem ??= describe(error);
121
+ continue;
122
+ }
123
+ sessionsRead += 1;
124
+ if (!tail.fromStart)
125
+ tailBounded += 1;
126
+ const lines = tail.text.split('\n');
127
+ // A window that does not start at byte 0 begins mid-line — possibly mid-UTF-8
128
+ // sequence. Dropped rather than parsed: `tailBounded` already says that older
129
+ // prompts in this record were not reached.
130
+ const usable = tail.fromStart ? lines : lines.slice(1);
131
+ let fromThisRecord = 0;
132
+ // Backwards: the newest prompts are at the end, and this is what bounds the work
133
+ // per record to the entries actually kept rather than to the record's length.
134
+ for (let index = usable.length - 1; index >= 0; index -= 1) {
135
+ if (fromThisRecord >= MAX_HISTORY_ENTRIES) {
136
+ // Older prompts are in this record and were deliberately not looked at. Said,
137
+ // not silently implied: the reading's own counts would otherwise read as "this
138
+ // is everything there is".
139
+ entriesBounded = true;
140
+ break;
141
+ }
142
+ const line = usable[index];
143
+ if (line.trim() === '')
144
+ continue;
145
+ const parsed = parseRecordLine(line);
146
+ // Undefined is expected damage (an interrupted write), tolerated exactly as
147
+ // `readTrajectory` tolerates it, and never repaired.
148
+ if (parsed === undefined || parsed.type !== 'userInput')
149
+ continue;
150
+ const text = parsed.text;
151
+ if (typeof text !== 'string')
152
+ continue;
153
+ const trimmed = text.trim();
154
+ if (trimmed === '')
155
+ continue;
156
+ if (exceedsCodePoints(trimmed, MAX_HISTORY_ENTRY_CHARS)) {
157
+ longSkipped += 1;
158
+ continue;
159
+ }
160
+ candidates.push({ text: trimmed, at: typeof parsed.t === 'string' ? parsed.t : '' });
161
+ fromThisRecord += 1;
162
+ }
163
+ }
164
+ // Across records, order by the time the prompt was observed. `sort` is stable, so
165
+ // records that share a timestamp (or carry none) keep the newest-first order the
166
+ // backwards scan produced.
167
+ candidates.sort((left, right) => (left.at < right.at ? 1 : left.at > right.at ? -1 : 0));
168
+ const collapsed = [];
169
+ for (const candidate of candidates) {
170
+ // Consecutive duplicates collapse to one entry, so `Up` twice reaches the previous
171
+ // *distinct* prompt — the Claude Code semantics, applied in recall order.
172
+ if (collapsed[collapsed.length - 1] === candidate.text)
173
+ continue;
174
+ collapsed.push(candidate.text);
175
+ }
176
+ return {
177
+ entries: collapsed.slice(0, MAX_HISTORY_ENTRIES),
178
+ available: collapsed.length,
179
+ entriesBounded,
180
+ sessionsRead,
181
+ sessionsSkipped,
182
+ tailBounded,
183
+ longSkipped,
184
+ problem,
185
+ };
186
+ }
187
+ /**
188
+ * One line stating what a reading is not showing, or nothing when it is complete.
189
+ *
190
+ * Rides on the recall indicator the editor already draws — never a row of its own, for
191
+ * the same reason the workspace-scan note rides on the completion menu's title
192
+ * (`src/tui/frame-budget.ts`).
193
+ */
194
+ export function promptHistoryNote(history) {
195
+ const parts = [];
196
+ if (history.available > history.entries.length) {
197
+ parts.push(`newest ${history.entries.length} of ${history.available}`);
198
+ }
199
+ else if (history.entriesBounded) {
200
+ // "records", not "prompts": the scan stopped reading *lines* at the bound, and the
201
+ // lines it did not look at may or may not have been prompts. The row must not claim
202
+ // more than the reader knows.
203
+ parts.push(`newest ${history.entries.length}, older records not read`);
204
+ }
205
+ if (history.sessionsSkipped > 0)
206
+ parts.push(`${history.sessionsSkipped} session(s) not read`);
207
+ if (history.tailBounded > 0)
208
+ parts.push(`${history.tailBounded} record(s) read from the end only`);
209
+ if (history.longSkipped > 0)
210
+ parts.push(`${history.longSkipped} long prompt(s) skipped`);
211
+ if (history.problem !== undefined)
212
+ parts.push(`partial read: ${history.problem}`);
213
+ return parts.length === 0 ? undefined : parts.join(', ');
214
+ }
215
+ /**
216
+ * The last {@link MAX_HISTORY_TAIL_BYTES} of a file, as text.
217
+ *
218
+ * Opened read-only and closed on every path, including a failed read: an observer that
219
+ * leaked a descriptor per keystroke would eventually take the session down with it.
220
+ * `size` is the stat already taken, so the window is chosen without a second syscall.
221
+ */
222
+ async function readTail(file, size) {
223
+ const length = Math.min(size, MAX_HISTORY_TAIL_BYTES);
224
+ const position = size - length;
225
+ const handle = await open(file, 'r');
226
+ try {
227
+ const buffer = Buffer.alloc(length);
228
+ const { bytesRead } = await handle.read(buffer, 0, length, position);
229
+ return { text: buffer.subarray(0, bytesRead).toString('utf8'), fromStart: position === 0 };
230
+ }
231
+ finally {
232
+ await handle.close();
233
+ }
234
+ }
235
+ /**
236
+ * Whether a string has more than `limit` code points — counted, and stopped at the
237
+ * limit rather than measured in full.
238
+ *
239
+ * Code points, not UTF-16 units, for the same reason the record's own caps count that
240
+ * way; early-exit because a record from another darwin's schema is not obliged to have
241
+ * been capped at all, and spreading an arbitrarily long string to measure it would be
242
+ * the one unbounded thing in a bounded reader.
243
+ */
244
+ function exceedsCodePoints(value, limit) {
245
+ let count = 0;
246
+ for (const _codePoint of value) {
247
+ count += 1;
248
+ if (count > limit)
249
+ return true;
250
+ }
251
+ return false;
252
+ }
253
+ function describe(error) {
254
+ return error instanceof Error ? error.message : String(error);
255
+ }
256
+ //# sourceMappingURL=prompt-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-history.js","sourceRoot":"","sources":["../../../src/trajectory/prompt-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,wFAAwF;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,2CAA2C;AAC3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,6CAA6C;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC;AAyBjD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,CAAC;IACZ,cAAc,EAAE,KAAK;IACrB,YAAY,EAAE,CAAC;IACf,eAAe,EAAE,CAAC;IAClB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,SAAS;CACnB,CAAC;AAQF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,WAAmB;IACzD,IAAI,OAA2B,CAAC;IAChC,IAAI,UAAU,GAAa,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,UAAU,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,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,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type TrajectoryRecord } from './record.js';
2
+ export interface TrajectoryReadResult {
3
+ /** Absolute path read. */
4
+ file: string;
5
+ records: TrajectoryRecord[];
6
+ /** Bytes on disk at read time. */
7
+ bytes: number;
8
+ /** The final line lacked its terminating newline: an interrupted last write. */
9
+ partialTrailingLine: boolean;
10
+ /** Complete lines that did not parse as a record — earlier interrupted writes. */
11
+ unreadableLines: number;
12
+ }
13
+ /** Raised only when the file itself is absent or unreadable; damage inside is not an error. */
14
+ export declare class TrajectoryMissingError extends Error {
15
+ readonly file: string;
16
+ readonly reason: string;
17
+ constructor(file: string, reason: string);
18
+ }
19
+ export declare function readTrajectory(file: string): Promise<TrajectoryReadResult>;
20
+ /** One line naming any damage found, or `undefined` when the file was clean. */
21
+ export declare function describeDamage(result: TrajectoryReadResult): string | undefined;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Reading a trajectory file.
3
+ *
4
+ * The reader's whole job is to be tolerant *and* honest: an interrupted write
5
+ * leaves a partial trailing line, and a run that appended after such an
6
+ * interruption leaves that damage in the middle of the file. Both are skipped and
7
+ * counted, never repaired — the record is append-only, so a reader that rewrote it
8
+ * to "fix" a line would destroy the only evidence of what happened.
9
+ */
10
+ import { readFile } from 'node:fs/promises';
11
+ import { parseRecordLine } from './record.js';
12
+ /** Raised only when the file itself is absent or unreadable; damage inside is not an error. */
13
+ export class TrajectoryMissingError extends Error {
14
+ file;
15
+ reason;
16
+ constructor(file, reason) {
17
+ super(`No trajectory record at ${file}: ${reason}`);
18
+ this.file = file;
19
+ this.reason = reason;
20
+ this.name = 'TrajectoryMissingError';
21
+ }
22
+ }
23
+ export async function readTrajectory(file) {
24
+ let raw;
25
+ let bytes;
26
+ try {
27
+ const buffer = await readFile(file);
28
+ bytes = buffer.byteLength;
29
+ raw = buffer.toString('utf8');
30
+ }
31
+ catch (error) {
32
+ throw new TrajectoryMissingError(file, error instanceof Error ? error.message : String(error));
33
+ }
34
+ const records = [];
35
+ let unreadableLines = 0;
36
+ // A file that ends without a newline has an incomplete final line. Split first,
37
+ // then treat that last element separately: it is expected damage, not a parse bug.
38
+ const partialTrailingLine = raw !== '' && !raw.endsWith('\n');
39
+ const lines = raw.split('\n');
40
+ const complete = partialTrailingLine ? lines.slice(0, -1) : lines;
41
+ for (const line of complete) {
42
+ if (line.trim() === '')
43
+ continue;
44
+ const record = parseRecordLine(line);
45
+ if (record === undefined) {
46
+ unreadableLines += 1;
47
+ continue;
48
+ }
49
+ records.push(record);
50
+ }
51
+ return { file, records, bytes, partialTrailingLine, unreadableLines };
52
+ }
53
+ /** One line naming any damage found, or `undefined` when the file was clean. */
54
+ export function describeDamage(result) {
55
+ const parts = [];
56
+ if (result.partialTrailingLine)
57
+ parts.push('ignored 1 partial trailing line');
58
+ if (result.unreadableLines > 0)
59
+ parts.push(`skipped ${result.unreadableLines} unreadable line(s)`);
60
+ return parts.length === 0 ? undefined : parts.join('; ');
61
+ }
62
+ //# sourceMappingURL=reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../src/trajectory/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC;AAcrE,+FAA+F;AAC/F,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC1B,IAAI;IAAmB,MAAM;IAAlD,YAAqB,IAAY,EAAW,MAAc;QACxD,KAAK,CAAC,2BAA2B,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;oBADjC,IAAI;sBAAmB,MAAM;QAEhD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,CAAC,KAAK,U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