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,132 @@
1
+ import type { AppConfig } from '../config.js';
2
+ import type { CallSpendProjector, TurnSpendMeter } from '../trajectory/record.js';
3
+ /** Cumulative token counts reported by the active model during this process. */
4
+ export interface UsageTotals {
5
+ inputTokens: number;
6
+ outputTokens: number;
7
+ /** Undefined until the provider reports this metric. */
8
+ cacheReadInputTokens?: number;
9
+ /** Undefined until the provider reports this metric. */
10
+ cacheWriteInputTokens?: number;
11
+ }
12
+ /** Mutually exclusive token buckets suitable for provider-specific cost accounting. */
13
+ export interface UsageBuckets {
14
+ /** Undefined when a provider-native total cannot be split without guessing. */
15
+ input: number | undefined;
16
+ output: number;
17
+ /** Undefined until the provider reports this metric. */
18
+ cacheRead: number | undefined;
19
+ /** Undefined until the provider reports this metric. */
20
+ cacheWrite: number | undefined;
21
+ }
22
+ /**
23
+ * Normalizes provider-native counters into independently billable buckets.
24
+ *
25
+ * OpenAI Responses includes cache activity inside `inputTokens`; Bedrock and
26
+ * Anthropic report those counters beside it. When either Responses cache
27
+ * subset is unreported, uncached input stays unknown instead of being guessed.
28
+ */
29
+ export declare function usageBuckets(usage: UsageTotals, config: AppConfig): UsageBuckets;
30
+ /**
31
+ * How many tokens one call actually submitted — the prompt side of the request,
32
+ * cache hits included.
33
+ *
34
+ * The split follows {@link usageBuckets}: OpenAI Responses reports cache activity
35
+ * as subsets of `input_tokens`, so its input *is* the request total, while every
36
+ * other provider reports cache reads/writes beside uncached input, so the request
37
+ * is their sum (an unreported cache counter contributing nothing rather than
38
+ * blocking the total). `undefined` when the buckets cannot split honestly —
39
+ * unknown, never 0.
40
+ *
41
+ * Shared by `/usage`'s per-call average and the `/context` measurement anchor, so
42
+ * the two cannot disagree about what a request cost. Cache reads are counted on
43
+ * purpose: they still occupy the context window, which is the question `/context`
44
+ * answers — this is deliberately not a billing view.
45
+ */
46
+ export declare function requestInputTokens(usage: UsageTotals, config: AppConfig): number | undefined;
47
+ export interface UsageRow {
48
+ label: string;
49
+ /** Undefined means the provider/API did not report this metric. */
50
+ value: number | undefined;
51
+ }
52
+ /**
53
+ * Projects provider-neutral SDK counters into the terminology and availability
54
+ * contract of the active provider/API.
55
+ */
56
+ export declare function usageRows(usage: UsageTotals, config: AppConfig): readonly UsageRow[];
57
+ /** Renders one projected value without turning an absent metric into zero. */
58
+ export declare function formatUsageValue(value: number | undefined): string;
59
+ /**
60
+ * Adds several meters' totals into one — the parent's meter plus each child
61
+ * dispatch's, for the session-total projection.
62
+ *
63
+ * The numeric fields are plain sums. The optional cache counters follow the
64
+ * "unknown metric is never 0" rule in aggregate form: a cache key is present in
65
+ * the result only if at least one operand reports it, and within that sum an
66
+ * absent operand counts as 0 — a meter that never reported cache activity adds
67
+ * nothing, but cannot erase what another meter measured. When *no* operand
68
+ * reports a cache counter the result omits it too, so an all-unknown metric
69
+ * still renders as `not reported`, never as an invented zero.
70
+ */
71
+ export declare function sumUsage(totals: readonly UsageTotals[]): UsageTotals;
72
+ /**
73
+ * Subtracts `before` from `after` to produce the delta for one turn.
74
+ *
75
+ * Undefined metrics propagate: if the provider did not report a metric
76
+ * before the turn it will not be present in the delta either, so the
77
+ * last-turn section never invents a zero for an unreported counter.
78
+ * The accumulator never goes backwards, so negative deltas are clamped to 0.
79
+ */
80
+ export declare function deltaUsage(before: UsageTotals, after: UsageTotals): UsageTotals;
81
+ /**
82
+ * A meter for one turn: the spend from `before` up to whenever it is read.
83
+ *
84
+ * Lives here, beside {@link deltaUsage} and {@link usageBuckets}, because those two
85
+ * define what the numbers mean; the trajectory only stores them. `AgentRuntime.send`
86
+ * creates one per turn and hands it to the recorder, which reads it while the turn's
87
+ * closing record is composed — the only moment at which the turn's spend is both final
88
+ * and still in front of the write.
89
+ *
90
+ * Two properties are the reason this is a function and not four lines inlined at the
91
+ * call site. It **cannot throw**: an observer that reads a number must never become a
92
+ * second reason a turn dies, so any failure degrades to `undefined`, which the record
93
+ * stores as nothing and every report reads as unknown. And it is the *same* projection
94
+ * the headless `usage:` line prints ({@link usageBuckets}), so a recorded turn and a
95
+ * process total are comparable field for field — including the part where an unreported
96
+ * metric is absent on both sides rather than zero on either.
97
+ *
98
+ * The provider/model labels are stamped from the config in effect for this turn, so a
99
+ * `/model` switch mid-session cannot leave one total silently mixing two price lists.
100
+ */
101
+ export declare function startTurnSpend(before: UsageTotals, readUsage: () => UsageTotals, config: AppConfig): TurnSpendMeter;
102
+ /**
103
+ * The per-call sibling of {@link startTurnSpend}: projects one completed model
104
+ * call's own counters — `afterModelCallEvent.stopData.message.metadata.usage`, not a
105
+ * meter delta — through the same {@link usageBuckets}, stamped with the same
106
+ * per-turn provider/model attribution.
107
+ *
108
+ * Lives here for `startTurnSpend`'s reasons, verbatim: the buckets define what the
109
+ * numbers mean, the trajectory only stores them, and `src/trajectory/**` must not
110
+ * import the config this projection needs. `project()` cannot throw — a counter it
111
+ * cannot project degrades to `undefined`, which the record stores as nothing and
112
+ * every report reads as unknown.
113
+ */
114
+ export declare function startCallSpend(config: AppConfig): CallSpendProjector;
115
+ /** A derived effectiveness metric; undefined means the provider never reported it. */
116
+ export interface CacheEffectivenessRow {
117
+ label: string;
118
+ /** Pre-rendered, since a ratio is a percentage rather than a token count. */
119
+ value: string | undefined;
120
+ }
121
+ /**
122
+ * How well the prompt cache is working, derived from the same counters
123
+ * {@link usageRows} projects.
124
+ *
125
+ * Provider-aware for the same reason: Bedrock/Anthropic report cache reads and
126
+ * writes *beside* `inputTokens`, so the request total is their sum, while OpenAI
127
+ * Responses reports them as *subsets* of `input_tokens`, which is already the
128
+ * total. An unreported metric keeps every derived row at "not reported" —
129
+ * arithmetic over an invented zero would claim the cache is broken rather than
130
+ * unmeasured.
131
+ */
132
+ export declare function cacheEffectivenessRows(usage: UsageTotals, config: AppConfig): readonly CacheEffectivenessRow[];
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Normalizes provider-native counters into independently billable buckets.
3
+ *
4
+ * OpenAI Responses includes cache activity inside `inputTokens`; Bedrock and
5
+ * Anthropic report those counters beside it. When either Responses cache
6
+ * subset is unreported, uncached input stays unknown instead of being guessed.
7
+ */
8
+ export function usageBuckets(usage, config) {
9
+ const cacheRead = usage.cacheReadInputTokens;
10
+ const cacheWrite = usage.cacheWriteInputTokens;
11
+ const input = config.provider === 'openai' && config.openaiApi === 'responses'
12
+ ? cacheRead === undefined || cacheWrite === undefined
13
+ ? undefined
14
+ : Math.max(0, usage.inputTokens - cacheRead - cacheWrite)
15
+ : usage.inputTokens;
16
+ return { input, output: usage.outputTokens, cacheRead, cacheWrite };
17
+ }
18
+ /**
19
+ * How many tokens one call actually submitted — the prompt side of the request,
20
+ * cache hits included.
21
+ *
22
+ * The split follows {@link usageBuckets}: OpenAI Responses reports cache activity
23
+ * as subsets of `input_tokens`, so its input *is* the request total, while every
24
+ * other provider reports cache reads/writes beside uncached input, so the request
25
+ * is their sum (an unreported cache counter contributing nothing rather than
26
+ * blocking the total). `undefined` when the buckets cannot split honestly —
27
+ * unknown, never 0.
28
+ *
29
+ * Shared by `/usage`'s per-call average and the `/context` measurement anchor, so
30
+ * the two cannot disagree about what a request cost. Cache reads are counted on
31
+ * purpose: they still occupy the context window, which is the question `/context`
32
+ * answers — this is deliberately not a billing view.
33
+ */
34
+ export function requestInputTokens(usage, config) {
35
+ const buckets = usageBuckets(usage, config);
36
+ if (config.provider === 'openai' && config.openaiApi === 'responses')
37
+ return usage.inputTokens;
38
+ if (buckets.input === undefined)
39
+ return undefined;
40
+ return buckets.input + (buckets.cacheRead ?? 0) + (buckets.cacheWrite ?? 0);
41
+ }
42
+ /**
43
+ * Projects provider-neutral SDK counters into the terminology and availability
44
+ * contract of the active provider/API.
45
+ */
46
+ export function usageRows(usage, config) {
47
+ const buckets = usageBuckets(usage, config);
48
+ const common = {
49
+ input: { label: 'input', value: buckets.input },
50
+ output: { label: 'output', value: buckets.output },
51
+ };
52
+ if (config.provider === 'openai' && config.openaiApi === 'responses') {
53
+ return [
54
+ common.input,
55
+ { label: 'cached read', value: buckets.cacheRead },
56
+ { label: 'cache write', value: buckets.cacheWrite },
57
+ common.output,
58
+ ];
59
+ }
60
+ if (config.provider === 'bedrock' || config.provider === 'anthropic') {
61
+ return [
62
+ common.input,
63
+ { label: 'cache read', value: usage.cacheReadInputTokens ?? 0 },
64
+ { label: 'cache write', value: usage.cacheWriteInputTokens ?? 0 },
65
+ common.output,
66
+ ];
67
+ }
68
+ return [
69
+ common.input,
70
+ { label: 'cache read', value: undefined },
71
+ { label: 'cache write', value: undefined },
72
+ common.output,
73
+ ];
74
+ }
75
+ /** Renders one projected value without turning an absent metric into zero. */
76
+ export function formatUsageValue(value) {
77
+ return value === undefined ? 'not reported' : value.toLocaleString('en-US');
78
+ }
79
+ /**
80
+ * Adds several meters' totals into one — the parent's meter plus each child
81
+ * dispatch's, for the session-total projection.
82
+ *
83
+ * The numeric fields are plain sums. The optional cache counters follow the
84
+ * "unknown metric is never 0" rule in aggregate form: a cache key is present in
85
+ * the result only if at least one operand reports it, and within that sum an
86
+ * absent operand counts as 0 — a meter that never reported cache activity adds
87
+ * nothing, but cannot erase what another meter measured. When *no* operand
88
+ * reports a cache counter the result omits it too, so an all-unknown metric
89
+ * still renders as `not reported`, never as an invented zero.
90
+ */
91
+ export function sumUsage(totals) {
92
+ const sum = {
93
+ inputTokens: totals.reduce((acc, usage) => acc + usage.inputTokens, 0),
94
+ outputTokens: totals.reduce((acc, usage) => acc + usage.outputTokens, 0),
95
+ };
96
+ if (totals.some((usage) => usage.cacheReadInputTokens !== undefined)) {
97
+ sum.cacheReadInputTokens = totals.reduce((acc, usage) => acc + (usage.cacheReadInputTokens ?? 0), 0);
98
+ }
99
+ if (totals.some((usage) => usage.cacheWriteInputTokens !== undefined)) {
100
+ sum.cacheWriteInputTokens = totals.reduce((acc, usage) => acc + (usage.cacheWriteInputTokens ?? 0), 0);
101
+ }
102
+ return sum;
103
+ }
104
+ /**
105
+ * Subtracts `before` from `after` to produce the delta for one turn.
106
+ *
107
+ * Undefined metrics propagate: if the provider did not report a metric
108
+ * before the turn it will not be present in the delta either, so the
109
+ * last-turn section never invents a zero for an unreported counter.
110
+ * The accumulator never goes backwards, so negative deltas are clamped to 0.
111
+ */
112
+ export function deltaUsage(before, after) {
113
+ const delta = {
114
+ inputTokens: Math.max(0, after.inputTokens - before.inputTokens),
115
+ outputTokens: Math.max(0, after.outputTokens - before.outputTokens),
116
+ };
117
+ if (after.cacheReadInputTokens !== undefined) {
118
+ delta.cacheReadInputTokens = Math.max(0, after.cacheReadInputTokens - (before.cacheReadInputTokens ?? 0));
119
+ }
120
+ if (after.cacheWriteInputTokens !== undefined) {
121
+ delta.cacheWriteInputTokens = Math.max(0, after.cacheWriteInputTokens - (before.cacheWriteInputTokens ?? 0));
122
+ }
123
+ return delta;
124
+ }
125
+ /**
126
+ * A meter for one turn: the spend from `before` up to whenever it is read.
127
+ *
128
+ * Lives here, beside {@link deltaUsage} and {@link usageBuckets}, because those two
129
+ * define what the numbers mean; the trajectory only stores them. `AgentRuntime.send`
130
+ * creates one per turn and hands it to the recorder, which reads it while the turn's
131
+ * closing record is composed — the only moment at which the turn's spend is both final
132
+ * and still in front of the write.
133
+ *
134
+ * Two properties are the reason this is a function and not four lines inlined at the
135
+ * call site. It **cannot throw**: an observer that reads a number must never become a
136
+ * second reason a turn dies, so any failure degrades to `undefined`, which the record
137
+ * stores as nothing and every report reads as unknown. And it is the *same* projection
138
+ * the headless `usage:` line prints ({@link usageBuckets}), so a recorded turn and a
139
+ * process total are comparable field for field — including the part where an unreported
140
+ * metric is absent on both sides rather than zero on either.
141
+ *
142
+ * The provider/model labels are stamped from the config in effect for this turn, so a
143
+ * `/model` switch mid-session cannot leave one total silently mixing two price lists.
144
+ */
145
+ export function startTurnSpend(before, readUsage, config) {
146
+ return {
147
+ read: () => {
148
+ try {
149
+ const buckets = usageBuckets(deltaUsage(before, readUsage()), config);
150
+ return {
151
+ provider: config.provider,
152
+ model: config.model,
153
+ ...(buckets.input !== undefined && { input: buckets.input }),
154
+ output: buckets.output,
155
+ ...(buckets.cacheRead !== undefined && { cacheRead: buckets.cacheRead }),
156
+ ...(buckets.cacheWrite !== undefined && { cacheWrite: buckets.cacheWrite }),
157
+ };
158
+ }
159
+ catch {
160
+ return undefined;
161
+ }
162
+ },
163
+ };
164
+ }
165
+ /**
166
+ * The per-call sibling of {@link startTurnSpend}: projects one completed model
167
+ * call's own counters — `afterModelCallEvent.stopData.message.metadata.usage`, not a
168
+ * meter delta — through the same {@link usageBuckets}, stamped with the same
169
+ * per-turn provider/model attribution.
170
+ *
171
+ * Lives here for `startTurnSpend`'s reasons, verbatim: the buckets define what the
172
+ * numbers mean, the trajectory only stores them, and `src/trajectory/**` must not
173
+ * import the config this projection needs. `project()` cannot throw — a counter it
174
+ * cannot project degrades to `undefined`, which the record stores as nothing and
175
+ * every report reads as unknown.
176
+ */
177
+ export function startCallSpend(config) {
178
+ return {
179
+ project: (usage) => {
180
+ try {
181
+ const buckets = usageBuckets(usage, config);
182
+ return {
183
+ provider: config.provider,
184
+ model: config.model,
185
+ ...(buckets.input !== undefined && { input: buckets.input }),
186
+ output: buckets.output,
187
+ ...(buckets.cacheRead !== undefined && { cacheRead: buckets.cacheRead }),
188
+ ...(buckets.cacheWrite !== undefined && { cacheWrite: buckets.cacheWrite }),
189
+ };
190
+ }
191
+ catch {
192
+ return undefined;
193
+ }
194
+ },
195
+ };
196
+ }
197
+ /**
198
+ * How well the prompt cache is working, derived from the same counters
199
+ * {@link usageRows} projects.
200
+ *
201
+ * Provider-aware for the same reason: Bedrock/Anthropic report cache reads and
202
+ * writes *beside* `inputTokens`, so the request total is their sum, while OpenAI
203
+ * Responses reports them as *subsets* of `input_tokens`, which is already the
204
+ * total. An unreported metric keeps every derived row at "not reported" —
205
+ * arithmetic over an invented zero would claim the cache is broken rather than
206
+ * unmeasured.
207
+ */
208
+ export function cacheEffectivenessRows(usage, config) {
209
+ const read = usage.cacheReadInputTokens;
210
+ if (read === undefined) {
211
+ return [
212
+ { label: 'cache hit ratio', value: undefined },
213
+ { label: 'served from cache', value: undefined },
214
+ ];
215
+ }
216
+ const submitted = config.provider === 'openai' && config.openaiApi === 'responses'
217
+ ? usage.inputTokens
218
+ : usage.inputTokens + read + (usage.cacheWriteInputTokens ?? 0);
219
+ return [
220
+ // A zero denominator means no request has completed yet; that is a measured
221
+ // nothing, not an unreported metric.
222
+ { label: 'cache hit ratio', value: submitted <= 0 ? '0%' : formatRatioPercent(read / submitted) },
223
+ { label: 'served from cache', value: formatUsageValue(read) },
224
+ ];
225
+ }
226
+ /** Integer percent with a `<1%` floor, so a barely-warm cache never reads as cold. */
227
+ function formatRatioPercent(ratio) {
228
+ const percent = ratio * 100;
229
+ if (percent > 0 && percent < 1)
230
+ return '<1%';
231
+ return `${Math.round(percent)}%`;
232
+ }
233
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../src/agent/usage.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,MAAiB;IAChE,MAAM,SAAS,GAAG,KAAK,CAAC,oBAAoB,CAAC;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,qBAAqB,CAAC;IAC/C,MAAM,KAAK,GACT,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,KAAK,WAAW;QAC9D,CAAC,CAAC,SAAS,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS;YACnD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;QAC3D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mB,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE;KAC9D,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,SAAS,kBAAkB,CAAC,KAAa;IACvC,MAAM,OAAO,GAAG,KAAK,GAAG,GAAG,CAAC;IAC5B,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AACnC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { SystemPromptHolder } from './prompt-cache.js';
2
+ export declare const WORKING_CONTEXT_TAG = "working-context";
3
+ /**
4
+ * How many directory entries the block may name.
5
+ *
6
+ * Generous for a repository root and still bounded for a directory holding
7
+ * thousands of files. What is dropped is reported in the block, so the model can
8
+ * tell "these are all of them" from "here are the first two hundred".
9
+ */
10
+ export declare const MAX_LISTED_ENTRIES = 200;
11
+ export interface WorkingContextLoad {
12
+ /** The system-prompt fragment, delimited and ready to append. Never empty. */
13
+ fragment: string;
14
+ /**
15
+ * Why the entry list is missing from an otherwise valid fragment. Undefined
16
+ * when the directory was read, since a successful load needs no reporting —
17
+ * same rule as the other startup loaders.
18
+ */
19
+ problem: string | undefined;
20
+ }
21
+ /**
22
+ * Assembles the fragment for one run.
23
+ *
24
+ * `now` is injectable so a test can assert an exact date instead of racing the
25
+ * clock. A directory that cannot be listed degrades to a fragment without the
26
+ * listing: the working directory, platform and date are still worth sending, and
27
+ * refusing to start over an unreadable folder would be absurd.
28
+ */
29
+ export declare function buildWorkingContext(projectRoot: string, now?: Date): Promise<WorkingContextLoad>;
30
+ /**
31
+ * Replaces any working context already in `prompt` with `fragment`, appending it
32
+ * last.
33
+ *
34
+ * Replacement, not plain appending, because a resumed session does not start from
35
+ * the freshly composed prompt: the SDK restores `systemPrompt` from the snapshot
36
+ * during `initialize()`, so the prompt in hand may already carry the block a
37
+ * previous run wrote — with that run's date and that run's directory listing.
38
+ * Stripping every occurrence also means a double application is harmless.
39
+ */
40
+ export declare function withWorkingContext(prompt: string, fragment: string): string;
41
+ /**
42
+ * Refreshes the one current working-context block after initialization/restore.
43
+ *
44
+ * The official skills plugin keeps its catalogue in a separate TextBlock, and
45
+ * Darwin keeps the cache point last. `refreshKnownPrompt` accepts only those
46
+ * explicit Darwin-owned shapes, preserves the catalogue, replaces working
47
+ * context, and drops the old cache point so the current run can re-place it.
48
+ */
49
+ export declare function applyWorkingContext(agent: SystemPromptHolder, fragment: string): boolean;
50
+ /** Removes every working-context block, leaving the rest of the prompt intact. */
51
+ export declare function stripWorkingContext(prompt: string): string;
@@ -0,0 +1,160 @@
1
+ import { readdir } from 'node:fs/promises';
2
+ import os from 'node:os';
3
+ import { refreshKnownPrompt } from '../skills/prompt.js';
4
+ export const WORKING_CONTEXT_TAG = 'working-context';
5
+ /**
6
+ * How many directory entries the block may name.
7
+ *
8
+ * Generous for a repository root and still bounded for a directory holding
9
+ * thousands of files. What is dropped is reported in the block, so the model can
10
+ * tell "these are all of them" from "here are the first two hundred".
11
+ */
12
+ export const MAX_LISTED_ENTRIES = 200;
13
+ /** How wide the entry list wraps. Matches the prose width of the base prompt. */
14
+ const WRAP_COLUMNS = 88;
15
+ /**
16
+ * Assembles the fragment for one run.
17
+ *
18
+ * `now` is injectable so a test can assert an exact date instead of racing the
19
+ * clock. A directory that cannot be listed degrades to a fragment without the
20
+ * listing: the working directory, platform and date are still worth sending, and
21
+ * refusing to start over an unreadable folder would be absurd.
22
+ */
23
+ export async function buildWorkingContext(projectRoot, now = new Date()) {
24
+ const listing = await listEntries(projectRoot);
25
+ const lines = [
26
+ `- working directory: ${projectRoot}`,
27
+ `- platform: ${os.platform()} ${os.release()} (${os.arch()})`,
28
+ `- shell: ${process.env['SHELL'] ?? '(unknown)'}`,
29
+ `- node: ${process.version}`,
30
+ `- date: ${now.toISOString().slice(0, 10)} (UTC), local time zone ${timeZone()}`,
31
+ ];
32
+ if (listing.problem === undefined) {
33
+ lines.push(`- ${describeCounts(listing)}`, ...wrap(listing.names).map((line) => ` ${line}`));
34
+ if (listing.omitted > 0) {
35
+ lines.push(` (${listing.omitted} more entr${listing.omitted === 1 ? 'y' : 'ies'} not listed)`);
36
+ }
37
+ }
38
+ return {
39
+ fragment: [
40
+ `<${WORKING_CONTEXT_TAG}>`,
41
+ 'Where this session started. The directory listing and the date are a snapshot taken at',
42
+ 'startup, not live state: re-check anything that may have changed since, including your own',
43
+ 'edits. Paths are absolute unless stated otherwise.',
44
+ ...lines,
45
+ `</${WORKING_CONTEXT_TAG}>`,
46
+ ].join('\n'),
47
+ problem: listing.problem,
48
+ };
49
+ }
50
+ /**
51
+ * Replaces any working context already in `prompt` with `fragment`, appending it
52
+ * last.
53
+ *
54
+ * Replacement, not plain appending, because a resumed session does not start from
55
+ * the freshly composed prompt: the SDK restores `systemPrompt` from the snapshot
56
+ * during `initialize()`, so the prompt in hand may already carry the block a
57
+ * previous run wrote — with that run's date and that run's directory listing.
58
+ * Stripping every occurrence also means a double application is harmless.
59
+ */
60
+ export function withWorkingContext(prompt, fragment) {
61
+ const stripped = stripWorkingContext(prompt);
62
+ return stripped === '' ? fragment : `${stripped}\n\n${fragment}`;
63
+ }
64
+ /**
65
+ * Refreshes the one current working-context block after initialization/restore.
66
+ *
67
+ * The official skills plugin keeps its catalogue in a separate TextBlock, and
68
+ * Darwin keeps the cache point last. `refreshKnownPrompt` accepts only those
69
+ * explicit Darwin-owned shapes, preserves the catalogue, replaces working
70
+ * context, and drops the old cache point so the current run can re-place it.
71
+ */
72
+ export function applyWorkingContext(agent, fragment) {
73
+ const refreshed = refreshKnownPrompt(agent.systemPrompt, fragment);
74
+ if (refreshed === undefined)
75
+ return false;
76
+ agent.systemPrompt = refreshed;
77
+ return true;
78
+ }
79
+ /** Removes every working-context block, leaving the rest of the prompt intact. */
80
+ export function stripWorkingContext(prompt) {
81
+ const block = new RegExp(`\\n*<${WORKING_CONTEXT_TAG}>[\\s\\S]*?</${WORKING_CONTEXT_TAG}>`, 'g');
82
+ return prompt.replace(block, '').trimEnd();
83
+ }
84
+ /**
85
+ * Immediate children only, directories first.
86
+ *
87
+ * One level is the useful level: it is what a person reads to orient themselves,
88
+ * and it stays a single `readdir` no matter how deep the tree is. A trailing `/`
89
+ * marks a directory and `@` a symlink, which is not followed — claiming a link to
90
+ * a directory is a file would be worse than saying nothing about it.
91
+ */
92
+ async function listEntries(projectRoot) {
93
+ let entries;
94
+ try {
95
+ entries = await readdir(projectRoot, { withFileTypes: true });
96
+ }
97
+ catch (error) {
98
+ return { names: [], directories: 0, files: 0, omitted: 0, problem: describe(error) };
99
+ }
100
+ const directories = [];
101
+ const files = [];
102
+ for (const entry of entries) {
103
+ if (entry.isSymbolicLink())
104
+ files.push(`${entry.name}@`);
105
+ else if (entry.isDirectory())
106
+ directories.push(`${entry.name}/`);
107
+ else
108
+ files.push(entry.name);
109
+ }
110
+ directories.sort((a, b) => a.localeCompare(b));
111
+ files.sort((a, b) => a.localeCompare(b));
112
+ const all = [...directories, ...files];
113
+ return {
114
+ names: all.slice(0, MAX_LISTED_ENTRIES),
115
+ directories: directories.length,
116
+ files: files.length,
117
+ omitted: Math.max(0, all.length - MAX_LISTED_ENTRIES),
118
+ problem: undefined,
119
+ };
120
+ }
121
+ function describeCounts(listing) {
122
+ const total = listing.directories + listing.files;
123
+ if (total === 0)
124
+ return 'contents: empty';
125
+ return `contents (${plural(listing.directories, 'directory', 'directories')}, ${plural(listing.files, 'file', 'files')}):`;
126
+ }
127
+ function plural(count, one, many) {
128
+ return `${count} ${count === 1 ? one : many}`;
129
+ }
130
+ /** Greedy wrap: entry names are short, and a line break inside one would be a lie. */
131
+ function wrap(names) {
132
+ const lines = [];
133
+ let line = '';
134
+ for (const name of names) {
135
+ if (line === '')
136
+ line = name;
137
+ else if (line.length + name.length + 2 <= WRAP_COLUMNS)
138
+ line = `${line} ${name}`;
139
+ else {
140
+ lines.push(line);
141
+ line = name;
142
+ }
143
+ }
144
+ if (line !== '')
145
+ lines.push(line);
146
+ return lines;
147
+ }
148
+ /** Never throws: a host without ICU data still has a working directory. */
149
+ function timeZone() {
150
+ try {
151
+ return Intl.DateTimeFormat().resolvedOptions().timeZone ?? '(unknown)';
152
+ }
153
+ catch {
154
+ return '(unknown)';
155
+ }
156
+ }
157
+ function describe(error) {
158
+ return error instanceof Error ? error.message : String(error);
159
+ }
160
+ //# sourceMappingURL=working-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-context.js","sourceRoot":"","sources":["../../../src/agent/working-context.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,iFAAiF;AACjF,MAAM,YAAY,GAAG,EAAE,CAAC;AAaxB;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,GAAG,GAAS,IAAI,IAAI,EAAE;IAEtB,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG;QACZ,wBAAwB,WAAW,EAAE;QACrC,eAAe,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG;QAC7D,YAAY,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,WAAW,EAAE;QACjD,WAAW,OAAO,CAAC,OAAO,EAAE;QAC5B,WAAW,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,2BAA2B,QAAQ,EAAE,EAAE;KACjF,CAAC;IAEF,IA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M,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY;YAAE,IAAI,GAAG,GAAG,IAAI,KAAK,IAAI,EAAE,CAAC;aAC7E,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAI,GAAG,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,IAAI,IAAI,KAAK,EAAE;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2EAA2E;AAC3E,SAAS,QAAQ;IACf,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ,IAAI,WAAW,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,WAAW,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { Agent } from '@strands-agents/sdk';
2
+ import type { InterventionHandler, Model, Tool } from '@strands-agents/sdk';
3
+ import type { ProjectInstructions } from '../agent/instructions.js';
4
+ import type { AppConfig } from '../config.js';
5
+ import type { SubagentDispatchHandle } from './dispatch-registry.js';
6
+ import type { AgentDefinition } from './loader.js';
7
+ export interface ChildRecipeOptions {
8
+ definition: AgentDefinition;
9
+ /** Config snapshot the caller took before its async model construction. */
10
+ config: AppConfig;
11
+ model: Model;
12
+ /** The parent's child-eligible catalogue; filtered per definition here. */
13
+ tools: readonly Tool[];
14
+ /** The parent's own gate instance, so live allow-rules keep applying. */
15
+ intervention: InterventionHandler;
16
+ projectInstructions: ProjectInstructions | undefined;
17
+ /** Part of the child agent id: `darwin-<idPrefix>-<name>-<uuid>`. */
18
+ idPrefix: string;
19
+ dispatch: SubagentDispatchHandle | undefined;
20
+ }
21
+ /**
22
+ * Builds one fresh, isolated child Agent and binds it to its dispatch record.
23
+ *
24
+ * The child never receives a `SessionManager`, parent messages, or a delegation
25
+ * tool; its conversation manager mirrors the main Agent's overflow strategy from
26
+ * the same config snapshot. Hooks expose only operation boundaries — never model
27
+ * messages, tool input/results, reasoning, or child transcript.
28
+ */
29
+ export declare function buildRecipeChild(options: ChildRecipeOptions): Agent;
30
+ /** `tools` omitted means the whole eligible catalogue, `[]` none, a list an exact filter. */
31
+ export declare function toolsForDefinition(definition: AgentDefinition, tools: readonly Tool[]): Tool[];
32
+ /** Reaps the persistent shell associated with one child Agent, if it used bash. */
33
+ export declare function stopBashSession(agent: Agent): Promise<void>;