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,8 @@
1
+ import type { Agent } from '@strands-agents/sdk';
2
+ /** A process-scoped guardrail, not a billing claim: compaction uses a separate model path. */
3
+ export declare class ModelCallBudgetError extends Error {
4
+ readonly limit: number;
5
+ constructor(limit: number);
6
+ }
7
+ /** Refuses parent-Agent call `limit + 1` before the provider is invoked. */
8
+ export declare function installModelCallBudget(agent: Agent, limit: number): void;
@@ -0,0 +1,24 @@
1
+ import { BeforeModelCallEvent } from '@strands-agents/sdk';
2
+ /** A process-scoped guardrail, not a billing claim: compaction uses a separate model path. */
3
+ export class ModelCallBudgetError extends Error {
4
+ limit;
5
+ constructor(limit) {
6
+ super(`Model-call budget exhausted: this process allows ${limit} call(s). ` +
7
+ `Start a focused follow-up turn with a fresh budget.`);
8
+ this.limit = limit;
9
+ this.name = 'ModelCallBudgetError';
10
+ }
11
+ }
12
+ /** Refuses parent-Agent call `limit + 1` before the provider is invoked. */
13
+ export function installModelCallBudget(agent, limit) {
14
+ if (!Number.isSafeInteger(limit) || limit < 1) {
15
+ throw new RangeError(`Model-call budget must be a positive safe integer, got ${limit}.`);
16
+ }
17
+ let calls = 0;
18
+ agent.addHook(BeforeModelCallEvent, () => {
19
+ calls += 1;
20
+ if (calls > limit)
21
+ throw new ModelCallBudgetError(limit);
22
+ });
23
+ }
24
+ //# sourceMappingURL=model-call-budget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-call-budget.js","sourceRoot":"","sources":["../../../src/agent/model-call-budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,8FAA8F;AAC9F,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACxB,KAAK;IAA1B,YAAqB,KAAa;QAChC,KAAK,CACH,oDAAoD,KAAK,YAAY;YACnE,qDAAqD,CACxD,CAAC;qBAJiB,KAAK;QAKxB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,UAAU,sBAAsB,CAAC,KAAY,EAAE,KAAa;IAChE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,UAAU,CAAC,0DAA0D,KAAK,GAAG,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,GAAG,EAAE;QACvC,KAAK,IAAI,CAAC,CAAC;QACX,IAAI,KAAK,GAAG,KAAK;YAAE,MAAM,IAAI,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Darwin-owned model-call retry (SER-066): the SDK's schedule, a cancellable wait,
3
+ * and a visible failure.
4
+ *
5
+ * The pinned SDK's `DefaultModelRetryStrategy` sleeps inside its `AfterModelCallEvent`
6
+ * hook callback, and `Agent._streamCore` runs hook callbacks *before* it yields the
7
+ * event to the consumer — so a driver learns of a throttled attempt only after the
8
+ * whole backoff has elapsed, and `agent.cancel()` during that sleep does nothing
9
+ * until it ends (the loop then spends one more model call before settling). Any
10
+ * darwin hook that slept in the same place would inherit both defects, so the wait
11
+ * is split across two SDK extension points on the same Agent:
12
+ *
13
+ * 1. The `AfterModelCallEvent` hook only *decides*: classifies the error, computes
14
+ * the delay, publishes the bounded wait state, and sets `event.retry = true` at
15
+ * once. The failed event therefore reaches the driver within milliseconds of the
16
+ * failure, and the loop moves on to the next attempt.
17
+ * 2. An `InvokeModelStage` wrap middleware — the SDK's designed interception point
18
+ * around one model call — performs the pending wait *before* calling `next()`.
19
+ * The wait resolves on its timer or on `cancelSignal` abort; on abort the
20
+ * middleware rethrows the attempt's original error without invoking the provider,
21
+ * so the loop's ordinary catch path (`AfterModelCallEvent` with that error, no
22
+ * retry because the signal is aborted) ends the turn with no further model call.
23
+ *
24
+ * `AgentRuntime.create` and `buildRecipeChild` pass `retryStrategy: null` so the SDK
25
+ * default no longer stacks its own uncancellable sleep; each Agent gets one installer
26
+ * call and one private state (never shared across agents). The schedule is the SDK's
27
+ * own numbers through the SDK's own exported `ExponentialBackoff`.
28
+ */
29
+ import { type BackoffStrategy, type LocalAgent } from '@strands-agents/sdk';
30
+ /** The SDK default's numbers (`DefaultModelRetryStrategy`), kept on purpose. */
31
+ export declare const DEFAULT_MODEL_RETRY_MAX_ATTEMPTS = 6;
32
+ export declare const DEFAULT_MODEL_RETRY_BASE_MS = 4000;
33
+ export declare const DEFAULT_MODEL_RETRY_MAX_MS = 240000;
34
+ /** Upper bound of the published `reason`, in code points. */
35
+ export declare const RETRY_REASON_MAX_CODE_POINTS = 200;
36
+ export interface ModelRetrySchedule {
37
+ /** Total model calls one retry budget may make (the SDK counts the first as attempt 1). */
38
+ readonly maxAttempts: number;
39
+ readonly backoff: BackoffStrategy;
40
+ }
41
+ /** One retry wait, published before it begins and cleared when it ends. Immutable. */
42
+ export interface RetryWaitState {
43
+ /** The attempt that failed (1-based, the SDK's `attemptCount`). */
44
+ readonly attempt: number;
45
+ readonly maxAttempts: number;
46
+ readonly waitMs: number;
47
+ /** Epoch milliseconds when the next attempt may start. */
48
+ readonly until: number;
49
+ /** ≤ {@link RETRY_REASON_MAX_CODE_POINTS} code points, derived from the error name/message. */
50
+ readonly reason: string;
51
+ }
52
+ /**
53
+ * How the last turn's retry budget ended, when it ended badly (SER-067). `exhausted`:
54
+ * every one of `attempts` calls was throttled and the last error propagated.
55
+ * `cancelled`: the wait before `attempt` (the attempt that was about to be made, out of
56
+ * `maxAttempts`) was aborted by `cancel()`, so the turn ended with the previous attempt's
57
+ * error and no further model call. Cleared when the next invocation begins.
58
+ */
59
+ export type ModelRetryOutcome = {
60
+ readonly kind: 'exhausted';
61
+ readonly attempts: number;
62
+ } | {
63
+ readonly kind: 'cancelled';
64
+ readonly attempt: number;
65
+ readonly maxAttempts: number;
66
+ };
67
+ export interface ModelRetryHandle {
68
+ /** The wait in progress (or decided and about to start), `undefined` otherwise. */
69
+ retryWait(): RetryWaitState | undefined;
70
+ /** The last invocation's bad retry ending, until the next invocation begins. */
71
+ retryOutcome(): ModelRetryOutcome | undefined;
72
+ }
73
+ /**
74
+ * Optional observer for one installer's waits — how a recipe child publishes its
75
+ * (otherwise private) wait as a dispatch phase. Callbacks run synchronously inside the
76
+ * hook/middleware and must not throw; a throw is swallowed so it cannot alter the loop.
77
+ */
78
+ export interface ModelRetryObserver {
79
+ /** A wait was decided and is about to begin. */
80
+ waitStarted?(state: RetryWaitState): void;
81
+ /**
82
+ * The wait ended: `completed` is true when the timer elapsed and the next attempt
83
+ * begins, false when it was cancelled (or abandoned before it ran).
84
+ */
85
+ waitEnded?(state: RetryWaitState, completed: boolean): void;
86
+ }
87
+ /**
88
+ * The attempt a wait leads to — `state.attempt` is the one that failed, so the next
89
+ * is one more. Every SER-067 surface (busy row, headless event, child phase, notices)
90
+ * names *this* number: "retry 3/6" is the third call of six about to be made.
91
+ */
92
+ export declare function retryNextAttempt(state: RetryWaitState): number;
93
+ /**
94
+ * `throttled, retry 3/6 in 12s` — the one bounded phrase every live surface appends.
95
+ * Remaining seconds are `until` against `nowMs`, rounded up so `0s` appears only once
96
+ * the deadline has passed, and never negative. No `reason`: the row is bounded and
97
+ * provider text may be long.
98
+ */
99
+ export declare function describeRetryWait(state: RetryWaitState, nowMs: number): string;
100
+ /**
101
+ * The failed turn's notice, with the retry ending named when there is one:
102
+ * `turn failed after 6 attempts: <message>` at the cap, `cancelled during retry wait
103
+ * (attempt 2/6): <message>` after a cancelled wait, plain `turn failed: <message>`
104
+ * otherwise. Shared by the TUI and headless drivers so the two cannot drift.
105
+ */
106
+ export declare function retryFailureNotice(outcome: ModelRetryOutcome | undefined, message: string): string;
107
+ /** The heading alone (`turn failed after 6 attempts`), or `undefined` when retry played no part. */
108
+ export declare function retryFailureHeading(outcome: ModelRetryOutcome | undefined): string | undefined;
109
+ /** A fresh SDK-default schedule: 6 attempts, exponential 4 s base / 240 s cap, full jitter. */
110
+ export declare function defaultModelRetrySchedule(): ModelRetrySchedule;
111
+ export declare function setModelRetryScheduleForTest(factory: (() => ModelRetrySchedule) | undefined): void;
112
+ /**
113
+ * Whether a failed model call may be retried against unchanged history.
114
+ *
115
+ * `ModelThrottledError` is the SDK's own retryable set (in-stream Bedrock throttling,
116
+ * Anthropic/OpenAI 429s). The second clause covers Bedrock's *pre-stream* 429: the AWS
117
+ * client's `ThrottlingException` is rethrown as-is by the Bedrock provider and wrapped
118
+ * by `Model.streamAggregated` as a plain `ModelError` whose `cause` is that exception.
119
+ * Overflow, output-token exhaustion and the stream-interruption `ModelError` owned by
120
+ * `stream-resumption.ts` are never retried here, whatever their cause says.
121
+ */
122
+ export declare function isRetryableModelError(error: unknown): boolean;
123
+ /** `<name>: <message>` (the AWS cause's name for the pre-stream case), bounded in code points. */
124
+ export declare function retryReason(error: Error): string;
125
+ /**
126
+ * Installs darwin's retry on one Agent constructed with `retryStrategy: null`.
127
+ *
128
+ * Per-budget timing state resets when `event.attemptCount === 1`, exactly where the
129
+ * SDK's `DefaultModelRetryStrategy.onFirstModelAttempt` resets its own. The hook
130
+ * defers to a hook that already set `event.retry`, ignores successes, never acts once
131
+ * the agent's `cancelSignal` is aborted, and stops at `maxAttempts` so the last
132
+ * attempt's error propagates unchanged from the loop.
133
+ */
134
+ export declare function installModelRetry(agent: LocalAgent, schedule?: ModelRetrySchedule, observer?: ModelRetryObserver): ModelRetryHandle;
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Darwin-owned model-call retry (SER-066): the SDK's schedule, a cancellable wait,
3
+ * and a visible failure.
4
+ *
5
+ * The pinned SDK's `DefaultModelRetryStrategy` sleeps inside its `AfterModelCallEvent`
6
+ * hook callback, and `Agent._streamCore` runs hook callbacks *before* it yields the
7
+ * event to the consumer — so a driver learns of a throttled attempt only after the
8
+ * whole backoff has elapsed, and `agent.cancel()` during that sleep does nothing
9
+ * until it ends (the loop then spends one more model call before settling). Any
10
+ * darwin hook that slept in the same place would inherit both defects, so the wait
11
+ * is split across two SDK extension points on the same Agent:
12
+ *
13
+ * 1. The `AfterModelCallEvent` hook only *decides*: classifies the error, computes
14
+ * the delay, publishes the bounded wait state, and sets `event.retry = true` at
15
+ * once. The failed event therefore reaches the driver within milliseconds of the
16
+ * failure, and the loop moves on to the next attempt.
17
+ * 2. An `InvokeModelStage` wrap middleware — the SDK's designed interception point
18
+ * around one model call — performs the pending wait *before* calling `next()`.
19
+ * The wait resolves on its timer or on `cancelSignal` abort; on abort the
20
+ * middleware rethrows the attempt's original error without invoking the provider,
21
+ * so the loop's ordinary catch path (`AfterModelCallEvent` with that error, no
22
+ * retry because the signal is aborted) ends the turn with no further model call.
23
+ *
24
+ * `AgentRuntime.create` and `buildRecipeChild` pass `retryStrategy: null` so the SDK
25
+ * default no longer stacks its own uncancellable sleep; each Agent gets one installer
26
+ * call and one private state (never shared across agents). The schedule is the SDK's
27
+ * own numbers through the SDK's own exported `ExponentialBackoff`.
28
+ */
29
+ import { AfterInvocationEvent, AfterModelCallEvent, BeforeInvocationEvent, ContextWindowOverflowError, ExponentialBackoff, InvokeModelStage, MaxTokensError, ModelError, ModelThrottledError, } from '@strands-agents/sdk';
30
+ import { isRetryableStreamInterruption } from './stream-resumption.js';
31
+ /** The SDK default's numbers (`DefaultModelRetryStrategy`), kept on purpose. */
32
+ export const DEFAULT_MODEL_RETRY_MAX_ATTEMPTS = 6;
33
+ export const DEFAULT_MODEL_RETRY_BASE_MS = 4_000;
34
+ export const DEFAULT_MODEL_RETRY_MAX_MS = 240_000;
35
+ /** Upper bound of the published `reason`, in code points. */
36
+ export const RETRY_REASON_MAX_CODE_POINTS = 200;
37
+ /**
38
+ * The attempt a wait leads to — `state.attempt` is the one that failed, so the next
39
+ * is one more. Every SER-067 surface (busy row, headless event, child phase, notices)
40
+ * names *this* number: "retry 3/6" is the third call of six about to be made.
41
+ */
42
+ export function retryNextAttempt(state) {
43
+ return state.attempt + 1;
44
+ }
45
+ /**
46
+ * `throttled, retry 3/6 in 12s` — the one bounded phrase every live surface appends.
47
+ * Remaining seconds are `until` against `nowMs`, rounded up so `0s` appears only once
48
+ * the deadline has passed, and never negative. No `reason`: the row is bounded and
49
+ * provider text may be long.
50
+ */
51
+ export function describeRetryWait(state, nowMs) {
52
+ const remainingSeconds = Math.max(0, Math.ceil((state.until - nowMs) / 1000));
53
+ return `throttled, retry ${retryNextAttempt(state)}/${state.maxAttempts} in ${remainingSeconds}s`;
54
+ }
55
+ /**
56
+ * The failed turn's notice, with the retry ending named when there is one:
57
+ * `turn failed after 6 attempts: <message>` at the cap, `cancelled during retry wait
58
+ * (attempt 2/6): <message>` after a cancelled wait, plain `turn failed: <message>`
59
+ * otherwise. Shared by the TUI and headless drivers so the two cannot drift.
60
+ */
61
+ export function retryFailureNotice(outcome, message) {
62
+ const heading = retryFailureHeading(outcome);
63
+ return `${heading ?? 'turn failed'}: ${message}`;
64
+ }
65
+ /** The heading alone (`turn failed after 6 attempts`), or `undefined` when retry played no part. */
66
+ export function retryFailureHeading(outcome) {
67
+ if (outcome === undefined)
68
+ return undefined;
69
+ if (outcome.kind === 'exhausted') {
70
+ return `turn failed after ${outcome.attempts} ${outcome.attempts === 1 ? 'attempt' : 'attempts'}`;
71
+ }
72
+ return `cancelled during retry wait (attempt ${outcome.attempt}/${outcome.maxAttempts})`;
73
+ }
74
+ /** A fresh SDK-default schedule: 6 attempts, exponential 4 s base / 240 s cap, full jitter. */
75
+ export function defaultModelRetrySchedule() {
76
+ return {
77
+ maxAttempts: DEFAULT_MODEL_RETRY_MAX_ATTEMPTS,
78
+ backoff: new ExponentialBackoff({ baseMs: DEFAULT_MODEL_RETRY_BASE_MS, maxMs: DEFAULT_MODEL_RETRY_MAX_MS }),
79
+ };
80
+ }
81
+ /**
82
+ * Test seam: a factory for the schedule every later installer call uses, so offline
83
+ * suites run in seconds. Production never sets it — the default stays the SDK's numbers.
84
+ */
85
+ let scheduleFactoryForTest;
86
+ export function setModelRetryScheduleForTest(factory) {
87
+ scheduleFactoryForTest = factory;
88
+ }
89
+ /**
90
+ * Whether a failed model call may be retried against unchanged history.
91
+ *
92
+ * `ModelThrottledError` is the SDK's own retryable set (in-stream Bedrock throttling,
93
+ * Anthropic/OpenAI 429s). The second clause covers Bedrock's *pre-stream* 429: the AWS
94
+ * client's `ThrottlingException` is rethrown as-is by the Bedrock provider and wrapped
95
+ * by `Model.streamAggregated` as a plain `ModelError` whose `cause` is that exception.
96
+ * Overflow, output-token exhaustion and the stream-interruption `ModelError` owned by
97
+ * `stream-resumption.ts` are never retried here, whatever their cause says.
98
+ */
99
+ export function isRetryableModelError(error) {
100
+ if (error instanceof ModelThrottledError)
101
+ return true;
102
+ if (!(error instanceof ModelError))
103
+ return false;
104
+ if (error instanceof ContextWindowOverflowError || error instanceof MaxTokensError)
105
+ return false;
106
+ // Guarded through an `unknown` alias: the type guard would otherwise narrow the
107
+ // already-known `ModelError` to `never` on its false branch.
108
+ const candidate = error;
109
+ if (isRetryableStreamInterruption(candidate))
110
+ return false;
111
+ const cause = error.cause;
112
+ return cause instanceof Error && cause.name === 'ThrottlingException';
113
+ }
114
+ /** `<name>: <message>` (the AWS cause's name for the pre-stream case), bounded in code points. */
115
+ export function retryReason(error) {
116
+ const cause = error.cause;
117
+ const label = !(error instanceof ModelThrottledError) && cause instanceof Error && cause.name !== '' ? cause.name : error.name;
118
+ const message = error.message.trim();
119
+ const text = message === '' ? label : `${label}: ${message}`;
120
+ const points = Array.from(text);
121
+ if (points.length <= RETRY_REASON_MAX_CODE_POINTS)
122
+ return text;
123
+ return `${points.slice(0, RETRY_REASON_MAX_CODE_POINTS - 1).join('')}…`;
124
+ }
125
+ /**
126
+ * Resolves `true` when `until` has passed, `false` as soon as `signal` aborts. The
127
+ * timer is cleared on both paths, so a cancelled wait leaves no handle behind.
128
+ */
129
+ function waitUntilOrAbort(until, signal) {
130
+ return new Promise((resolve) => {
131
+ if (signal.aborted) {
132
+ resolve(false);
133
+ return;
134
+ }
135
+ const remaining = Math.max(0, until - Date.now());
136
+ const onAbort = () => {
137
+ clearTimeout(timer);
138
+ resolve(false);
139
+ };
140
+ const timer = setTimeout(() => {
141
+ signal.removeEventListener('abort', onAbort);
142
+ resolve(true);
143
+ }, remaining);
144
+ signal.addEventListener('abort', onAbort, { once: true });
145
+ });
146
+ }
147
+ /**
148
+ * Installs darwin's retry on one Agent constructed with `retryStrategy: null`.
149
+ *
150
+ * Per-budget timing state resets when `event.attemptCount === 1`, exactly where the
151
+ * SDK's `DefaultModelRetryStrategy.onFirstModelAttempt` resets its own. The hook
152
+ * defers to a hook that already set `event.retry`, ignores successes, never acts once
153
+ * the agent's `cancelSignal` is aborted, and stops at `maxAttempts` so the last
154
+ * attempt's error propagates unchanged from the loop.
155
+ */
156
+ export function installModelRetry(agent, schedule = scheduleFactoryForTest?.() ?? defaultModelRetrySchedule(), observer = {}) {
157
+ if (!Number.isInteger(schedule.maxAttempts) || schedule.maxAttempts < 1) {
158
+ throw new RangeError(`Model retry maxAttempts must be an integer >= 1, got ${schedule.maxAttempts}.`);
159
+ }
160
+ let firstFailureAt;
161
+ let lastDelayMs;
162
+ let pending;
163
+ let current;
164
+ let outcome;
165
+ const notify = (callback) => {
166
+ try {
167
+ callback?.();
168
+ }
169
+ catch {
170
+ // An observer is presentation; it cannot be allowed to change the loop's course.
171
+ }
172
+ };
173
+ /** Ends the published wait (if any) and tells the observer how it ended. */
174
+ const endWait = (completed) => {
175
+ const ended = current;
176
+ pending = undefined;
177
+ current = undefined;
178
+ if (ended !== undefined)
179
+ notify(() => observer.waitEnded?.(ended, completed));
180
+ };
181
+ // A fresh invocation starts with no story to tell about the previous one.
182
+ agent.addHook(BeforeInvocationEvent, () => {
183
+ outcome = undefined;
184
+ });
185
+ agent.addHook(AfterModelCallEvent, (event) => {
186
+ if (event.attemptCount === 1) {
187
+ firstFailureAt = undefined;
188
+ lastDelayMs = undefined;
189
+ }
190
+ // A wait that was decided but never consumed (another hook redirected the loop)
191
+ // must not leak into a later, unrelated call.
192
+ endWait(false);
193
+ if (event.retry === true || event.error === undefined)
194
+ return;
195
+ if (event.agent.cancelSignal.aborted)
196
+ return;
197
+ if (!isRetryableModelError(event.error))
198
+ return;
199
+ if (event.attemptCount >= schedule.maxAttempts) {
200
+ outcome = Object.freeze({ kind: 'exhausted', attempts: event.attemptCount });
201
+ return;
202
+ }
203
+ const now = Date.now();
204
+ if (firstFailureAt === undefined)
205
+ firstFailureAt = now;
206
+ const waitMs = Math.max(0, schedule.backoff.nextDelay({
207
+ attempt: event.attemptCount,
208
+ elapsedMs: now - firstFailureAt,
209
+ ...(lastDelayMs === undefined ? {} : { lastDelayMs }),
210
+ }));
211
+ lastDelayMs = waitMs;
212
+ const state = Object.freeze({
213
+ attempt: event.attemptCount,
214
+ maxAttempts: schedule.maxAttempts,
215
+ waitMs,
216
+ until: now + waitMs,
217
+ reason: retryReason(event.error),
218
+ });
219
+ current = state;
220
+ pending = { state, error: event.error };
221
+ event.retry = true;
222
+ notify(() => observer.waitStarted?.(state));
223
+ });
224
+ // Turn end or failure, whichever way the loop left: nothing is waiting any more.
225
+ agent.addHook(AfterInvocationEvent, () => endWait(false));
226
+ const waitBeforeModelCall = async function* (context, next) {
227
+ const wait = pending;
228
+ if (wait !== undefined) {
229
+ pending = undefined;
230
+ let completed = false;
231
+ try {
232
+ completed = await waitUntilOrAbort(wait.state.until, context.agent.cancelSignal);
233
+ }
234
+ finally {
235
+ if (!completed) {
236
+ outcome = Object.freeze({
237
+ kind: 'cancelled',
238
+ attempt: retryNextAttempt(wait.state),
239
+ maxAttempts: wait.state.maxAttempts,
240
+ });
241
+ }
242
+ endWait(completed);
243
+ }
244
+ // Cancelled mid-wait: the attempt that was scheduled never asks the provider.
245
+ // Rethrowing the failed attempt's own error keeps what `send()` reports exactly
246
+ // what the provider last said; the loop's catch yields the ordinary
247
+ // AfterModelCallEvent for it, and the hook above declines to retry an aborted agent.
248
+ if (!completed)
249
+ throw wait.error;
250
+ }
251
+ return yield* next(context);
252
+ };
253
+ agent.addMiddleware(InvokeModelStage, waitBeforeModelCall);
254
+ return { retryWait: () => current, retryOutcome: () => outcome };
255
+ }
256
+ //# sourceMappingURL=model-retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-retry.js","sourceRoot":"","sources":["../../../src/agent/model-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,mBAAmB,GAIpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAEvE,gFAAgF;AAChF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AACjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAqDhD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,OAAO,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAqB,EAAE,KAAa;IACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,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ACvB,OAAO,GAAG,SAAS,CAAC;YACpB,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,IAAI,CAAC;gBACH,SAAS,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACnF,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;wBACtB,IAAI,EAAE,WAAW;wBACjB,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;wBACrC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;qBACpC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,CAAC,SAAS,CAAC,CAAC;YACrB,CAAC;YACD,8EAA8E;YAC9E,gFAAgF;YAChF,oEAAoE;YACpE,qFAAqF;YACrF,IAAI,CAAC,SAAS;gBAAE,MAAM,IAAI,CAAC,KAAK,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC;IACF,KAAK,CAAC,aAAa,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;IAE3D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AACnE,CAAC"}
@@ -0,0 +1,47 @@
1
+ /** What the matcher needs from a tool call. `PermissionRequest` satisfies it. */
2
+ export interface RuleTarget {
3
+ toolName: string;
4
+ input: unknown;
5
+ }
6
+ /** One "always allow" offer, ready to render on the prompt's option line. */
7
+ export interface RuleSuggestion {
8
+ /** The rule string, as it will be written to the config. */
9
+ rule: string;
10
+ /** Short label for the option line, e.g. `pnpm *` or `all bash`. */
11
+ label: string;
12
+ }
13
+ /** True when the command contains redirection or substitution. */
14
+ export declare function hasShellMetacharacters(command: string): boolean;
15
+ /**
16
+ * Splits a command on the chaining operators, so `a && b` is only covered when
17
+ * both halves are. Naive on purpose: a mis-split drops out of the safe path,
18
+ * never into it.
19
+ */
20
+ export declare function splitBashSegments(command: string): string[];
21
+ /** A rule split into its parts, or undefined when the string is not a rule. */
22
+ export declare function parseRule(rule: string): {
23
+ toolName: string;
24
+ pattern?: string;
25
+ } | undefined;
26
+ /** Whether a config entry is a usable rule. Used to reject typos at load time. */
27
+ export declare function isValidRule(rule: string): boolean;
28
+ /**
29
+ * The first rule that covers this call, or undefined when none does.
30
+ *
31
+ * Exempt targets (see {@link isRuleExempt}) match nothing, whatever the rules
32
+ * say — a broad rule must not be a path to the agent widening its own
33
+ * permissions.
34
+ */
35
+ export declare function matchesAnyRule(rules: readonly string[], target: RuleTarget, projectRoot: string): string | undefined;
36
+ /**
37
+ * Calls no rule may ever cover: darwin's own config (a rule there lets the agent
38
+ * grant itself more rules) and environment files. Both are also `dangerous`
39
+ * statically, so the effect is that they always ask.
40
+ */
41
+ export declare function isRuleExempt(target: RuleTarget, projectRoot: string): boolean;
42
+ /**
43
+ * At most two offers, most specific first: one derived from this call, then the
44
+ * whole tool. Empty for an exempt target — offering a rule that could never
45
+ * apply would be a lie told in a security prompt.
46
+ */
47
+ export declare function suggestRules(target: RuleTarget, projectRoot: string): RuleSuggestion[];