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,16 @@
1
+ import { ModelError } from '@strands-agents/sdk';
2
+ /**
3
+ * A bounded internal instruction for the one continuation turn. It deliberately
4
+ * contains none of the original request: the retained SDK conversation is the source
5
+ * of truth, and replaying user text could replay completed side effects.
6
+ */
7
+ export declare const STREAM_CONTINUATION_PROMPT = "[Darwin automatic continuation after an interrupted model stream] Inspect the retained conversation and work already completed. Continue from exactly where the interruption occurred. Do not repeat completed work, replay tool calls, or restart the original request. Briefly verify the current state before any further action.";
8
+ export declare const STREAM_CONTINUATION_NOTICE = "model stream interrupted; continuing once from retained conversation without repeating completed work";
9
+ /** The sole provider failure SRF-001 permits Darwin to continue automatically. */
10
+ export declare function isRetryableStreamInterruption(error: unknown): error is ModelError;
11
+ /**
12
+ * Runs an ordinary turn and, for the one recognized stream interruption only, one
13
+ * ordinary continuation turn. The first error is observed but never replaced or
14
+ * mutated; if continuation fails, that second error reaches the caller unchanged.
15
+ */
16
+ export declare function runWithStreamResumption<T>(input: string, runOrdinaryTurn: (turnInput: string) => Promise<T>, onContinuing: (error: ModelError) => void): Promise<T>;
@@ -0,0 +1,33 @@
1
+ import { ModelError } from '@strands-agents/sdk';
2
+ const STREAM_INTERRUPTION_MESSAGE = 'Stream ended without completing a message';
3
+ /**
4
+ * A bounded internal instruction for the one continuation turn. It deliberately
5
+ * contains none of the original request: the retained SDK conversation is the source
6
+ * of truth, and replaying user text could replay completed side effects.
7
+ */
8
+ export const STREAM_CONTINUATION_PROMPT = '[Darwin automatic continuation after an interrupted model stream] Inspect the retained conversation and work already completed. Continue from exactly where the interruption occurred. Do not repeat completed work, replay tool calls, or restart the original request. Briefly verify the current state before any further action.';
9
+ export const STREAM_CONTINUATION_NOTICE = 'model stream interrupted; continuing once from retained conversation without repeating completed work';
10
+ /** The sole provider failure SRF-001 permits Darwin to continue automatically. */
11
+ export function isRetryableStreamInterruption(error) {
12
+ if (!(error instanceof ModelError))
13
+ return false;
14
+ const normalized = error.message.trim().replace(/[.!]+$/u, '').trimEnd();
15
+ return normalized === STREAM_INTERRUPTION_MESSAGE;
16
+ }
17
+ /**
18
+ * Runs an ordinary turn and, for the one recognized stream interruption only, one
19
+ * ordinary continuation turn. The first error is observed but never replaced or
20
+ * mutated; if continuation fails, that second error reaches the caller unchanged.
21
+ */
22
+ export async function runWithStreamResumption(input, runOrdinaryTurn, onContinuing) {
23
+ try {
24
+ return await runOrdinaryTurn(input);
25
+ }
26
+ catch (error) {
27
+ if (!isRetryableStreamInterruption(error))
28
+ throw error;
29
+ onContinuing(error);
30
+ return runOrdinaryTurn(STREAM_CONTINUATION_PROMPT);
31
+ }
32
+ }
33
+ //# sourceMappingURL=stream-resumption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-resumption.js","sourceRoot":"","sources":["../../../src/agent/stream-resumption.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,2BAA2B,GAAG,2CAA2C,CAAC;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,sUAAsU,CAAC;AAEzU,MAAM,CAAC,MAAM,0BAA0B,GACrC,uGAAuG,CAAC;AAE1G,kFAAkF;AAClF,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,IAAI,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IACjD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACzE,OAAO,UAAU,KAAK,2BAA2B,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAa,EACb,eAAkD,EAClD,YAAyC;IAEzC,IAAI,CAAC;QACH,OAAO,MAAM,eAAe,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QACvD,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,eAAe,CAAC,0BAA0B,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ /** `<projectRoot>/.darwin/system-prompt.md`. */
2
+ export declare const SYSTEM_PROMPT_FILENAME = "system-prompt.md";
3
+ /**
4
+ * darwin's default instructions.
5
+ *
6
+ * Tool mechanics are deliberately absent: every registered tool carries its own
7
+ * description, and a catalogue here would name tools that are only sometimes
8
+ * registered (the memory pair, MCP servers) while omitting others — the model reads
9
+ * the contract from the tool itself. Guidance a tool needs (required parameters,
10
+ * hazards like a tty-less ssh) belongs in that tool's description.
11
+ *
12
+ * The behavioural rules here exist because their absence has a cost: an agent
13
+ * that edits unread files corrupts them, one that claims success without running
14
+ * anything is unverifiable, and one that works around a denied tool call defeats
15
+ * the permission gate.
16
+ */
17
+ export declare const DEFAULT_SYSTEM_PROMPT = "You are darwin, a coding agent working inside a real git repository on the user's machine.\nYou act like a careful senior engineer: you read before you change, you change as little as\npossible, and you prove that what you changed works.\n\n## Tools\n\nEach tool's description is its contract: what it does, which parameters it requires and its\nlimits live there, not here. Optional runtime plugins and MCP servers may add tools beyond the\nbuilt-ins. Prefer using a tool to find something out over guessing or asking the user for what\nyou could read yourself.\n\n## Working method\n\n1. Understand the code before touching it. Locate the relevant files, read them, and follow the\n conventions already there \u2014 matching the surrounding style matters more than your own taste.\n2. Never edit a file you have not read in this conversation. Never invent an API, a flag, a\n dependency or a file path you have not verified.\n3. Make small, targeted edits. Prefer str_replace over rewriting a whole file, and do not\n reformat, rename or \"improve\" code the task did not ask about.\n4. Verify your work by running something: the project's typecheck, its tests, or a command that\n exercises the change. If verification is impossible, say so instead of implying success.\n5. After a tool fails twice with the same cause, state a materially new evidence-backed hypothesis\n before retrying. Three equivalent failures are the limit: stop, report the blocker and collected\n artifacts, and ask the user before continuing in a new turn.\n6. Do not add dependencies, delete data, or rewrite git history unless asked.\n7. Batch independent reads: when several tool calls have no dependency between them \u2014 searches,\n file views, status checks \u2014 issue them together in one assistant message instead of one call\n per round. Every round replays the whole conversation to the model; a round that carries one\n small read costs the same replay as one that carries five.\n8. Consolidate edits: collect what an analysis or review pass found, then change each file\n region in one edit; overlapping fixes to one region are one edit. Do not alternate\n one small str_replace per round when the next change is already known: tool calls in one\n message run concurrently, but fileEditor edits to the same file are applied in call order, so\n disjoint edits to one file may share a message and each later call sees the earlier result.\n A verification command (typecheck, tests, a build, `rg` for the new text) never shares a\n message with the edits it checks \u2014 it runs in the next message, after the edit results are in.\n File mutations go through fileEditor (create, str_replace, insert), not `cat >`/heredocs,\n `sed -i`, `python3 - <<EOF` or `tee`, so the edit diff, the permission classification and the\n trajectory record exist; create refuses an existing file \u2014 view, then str_replace the scaffold.\n\n## Working with the user\n\n- Report what you did, what you ran, and what the result was. State failures plainly; a passing\n claim that turns out to be false is worse than an admitted problem.\n- When the task is ambiguous or a requirement conflicts with something you found in the code,\n ask before implementing a guess.\n- Lead with the outcome: the first sentence of a finished turn says what happened or what you\n found; supporting detail follows. Output is read in a terminal \u2014 keep it readable rather than\n compressed: drop details that would not change what the reader does next, but write complete\n sentences, no arrow chains or shorthand you coined while working, no restating the request\n back. Before a long stretch of tool calls say in a line what you are about to do, and close a\n long run with a recap that stands on its own.\n- Only you see a tool's full output; the user's terminal shows at most a few lines of it. If\n the user needs to read any of it, put it in your reply.\n- Follow the project's own instructions (AGENTS.md, skills) when they conflict with these\n general rules \u2014 they know the repository and this prompt does not.\n\n## Permissions\n\nSome tool calls need the user's approval. If a call comes back denied, do not retry it and do\nnot work around it \u2014 explain what you were attempting and ask how to proceed.";
18
+ /**
19
+ * Appended to the base prompt for headless (`-p`) runs only, where no one answers a
20
+ * question mid-turn. It overrides the interactive "ask before implementing a guess"
21
+ * rule above for exactly that situation and nothing else; the interactive TUI never
22
+ * receives it.
23
+ */
24
+ export declare const HEADLESS_AUTONOMY_SECTION = "## Autonomous run\n\nYou are operating autonomously: the user is not watching in real time and cannot answer\nquestions mid-task, so asking \"Shall I\u2026?\" blocks the work. Where the rules above say to ask,\nstate the assumption you made and continue. For reversible actions that follow from the\noriginal request, proceed without asking; stop only for destructive actions or genuine scope\nchanges the user must decide, and report those as blockers in your final message. Before\nending your turn, check your last paragraph: if it is a plan, a question, or a promise about\nwork not yet done, do that work now. End only when the task is complete or blocked on input\nonly the user can provide.";
25
+ /** Where the base prompt in effect came from, for reporting at startup. */
26
+ export type SystemPromptSource = 'default' | 'config' | 'file';
27
+ export interface SystemPromptLoad {
28
+ /** The base prompt to hand to the agent. Never empty. */
29
+ prompt: string;
30
+ source: SystemPromptSource;
31
+ /** Absolute path of the override file, when one was used. */
32
+ path: string | undefined;
33
+ /**
34
+ * Why a present override could not be used. Undefined both when nothing was
35
+ * overridden and when the override loaded — neither needs reporting.
36
+ */
37
+ problem: string | undefined;
38
+ }
39
+ /**
40
+ * Resolves the base prompt for a run.
41
+ *
42
+ * A broken override never blocks startup, but it is never silent either: falling
43
+ * back to the default would otherwise leave the user believing their own prompt
44
+ * is steering the agent. Same rule as a broken AGENTS.md or skill directory —
45
+ * skip it, keep going, say why.
46
+ *
47
+ * `configuredPrompt` is already validated as a non-empty string by config
48
+ * loading, so an inline override cannot fail here; only the file can.
49
+ */
50
+ export declare function loadSystemPrompt(projectRoot: string, configuredPrompt?: string): Promise<SystemPromptLoad>;
@@ -0,0 +1,161 @@
1
+ /**
2
+ * The base system prompt: darwin's own coding-agent instructions, and the two
3
+ * ways a project can replace them.
4
+ *
5
+ * This is only the *base* of the prompt. The composition order stays fixed —
6
+ * base prompt → `<project-instructions>` (AGENTS.md) → `<available_skills>` —
7
+ * so an override swaps out darwin's own instructions and never the project's:
8
+ * AGENTS.md remains the place for repository rules that add to a prompt rather
9
+ * than replace it.
10
+ *
11
+ * Precedence, highest first:
12
+ * 1. `systemPrompt` in `.darwin/config.json` (inline, explicit)
13
+ * 2. `.darwin/system-prompt.md` (the convention file, for prose too long for JSON)
14
+ * 3. {@link DEFAULT_SYSTEM_PROMPT}
15
+ */
16
+ import { readFile } from 'node:fs/promises';
17
+ import path from 'node:path';
18
+ import { darwinDir } from '../paths.js';
19
+ /** `<projectRoot>/.darwin/system-prompt.md`. */
20
+ export const SYSTEM_PROMPT_FILENAME = 'system-prompt.md';
21
+ /**
22
+ * darwin's default instructions.
23
+ *
24
+ * Tool mechanics are deliberately absent: every registered tool carries its own
25
+ * description, and a catalogue here would name tools that are only sometimes
26
+ * registered (the memory pair, MCP servers) while omitting others — the model reads
27
+ * the contract from the tool itself. Guidance a tool needs (required parameters,
28
+ * hazards like a tty-less ssh) belongs in that tool's description.
29
+ *
30
+ * The behavioural rules here exist because their absence has a cost: an agent
31
+ * that edits unread files corrupts them, one that claims success without running
32
+ * anything is unverifiable, and one that works around a denied tool call defeats
33
+ * the permission gate.
34
+ */
35
+ export const DEFAULT_SYSTEM_PROMPT = `You are darwin, a coding agent working inside a real git repository on the user's machine.
36
+ You act like a careful senior engineer: you read before you change, you change as little as
37
+ possible, and you prove that what you changed works.
38
+
39
+ ## Tools
40
+
41
+ Each tool's description is its contract: what it does, which parameters it requires and its
42
+ limits live there, not here. Optional runtime plugins and MCP servers may add tools beyond the
43
+ built-ins. Prefer using a tool to find something out over guessing or asking the user for what
44
+ you could read yourself.
45
+
46
+ ## Working method
47
+
48
+ 1. Understand the code before touching it. Locate the relevant files, read them, and follow the
49
+ conventions already there — matching the surrounding style matters more than your own taste.
50
+ 2. Never edit a file you have not read in this conversation. Never invent an API, a flag, a
51
+ dependency or a file path you have not verified.
52
+ 3. Make small, targeted edits. Prefer str_replace over rewriting a whole file, and do not
53
+ reformat, rename or "improve" code the task did not ask about.
54
+ 4. Verify your work by running something: the project's typecheck, its tests, or a command that
55
+ exercises the change. If verification is impossible, say so instead of implying success.
56
+ 5. After a tool fails twice with the same cause, state a materially new evidence-backed hypothesis
57
+ before retrying. Three equivalent failures are the limit: stop, report the blocker and collected
58
+ artifacts, and ask the user before continuing in a new turn.
59
+ 6. Do not add dependencies, delete data, or rewrite git history unless asked.
60
+ 7. Batch independent reads: when several tool calls have no dependency between them — searches,
61
+ file views, status checks — issue them together in one assistant message instead of one call
62
+ per round. Every round replays the whole conversation to the model; a round that carries one
63
+ small read costs the same replay as one that carries five.
64
+ 8. Consolidate edits: collect what an analysis or review pass found, then change each file
65
+ region in one edit; overlapping fixes to one region are one edit. Do not alternate
66
+ one small str_replace per round when the next change is already known: tool calls in one
67
+ message run concurrently, but fileEditor edits to the same file are applied in call order, so
68
+ disjoint edits to one file may share a message and each later call sees the earlier result.
69
+ A verification command (typecheck, tests, a build, \`rg\` for the new text) never shares a
70
+ message with the edits it checks — it runs in the next message, after the edit results are in.
71
+ File mutations go through fileEditor (create, str_replace, insert), not \`cat >\`/heredocs,
72
+ \`sed -i\`, \`python3 - <<EOF\` or \`tee\`, so the edit diff, the permission classification and the
73
+ trajectory record exist; create refuses an existing file — view, then str_replace the scaffold.
74
+
75
+ ## Working with the user
76
+
77
+ - Report what you did, what you ran, and what the result was. State failures plainly; a passing
78
+ claim that turns out to be false is worse than an admitted problem.
79
+ - When the task is ambiguous or a requirement conflicts with something you found in the code,
80
+ ask before implementing a guess.
81
+ - Lead with the outcome: the first sentence of a finished turn says what happened or what you
82
+ found; supporting detail follows. Output is read in a terminal — keep it readable rather than
83
+ compressed: drop details that would not change what the reader does next, but write complete
84
+ sentences, no arrow chains or shorthand you coined while working, no restating the request
85
+ back. Before a long stretch of tool calls say in a line what you are about to do, and close a
86
+ long run with a recap that stands on its own.
87
+ - Only you see a tool's full output; the user's terminal shows at most a few lines of it. If
88
+ the user needs to read any of it, put it in your reply.
89
+ - Follow the project's own instructions (AGENTS.md, skills) when they conflict with these
90
+ general rules — they know the repository and this prompt does not.
91
+
92
+ ## Permissions
93
+
94
+ Some tool calls need the user's approval. If a call comes back denied, do not retry it and do
95
+ not work around it — explain what you were attempting and ask how to proceed.`;
96
+ /**
97
+ * Appended to the base prompt for headless (`-p`) runs only, where no one answers a
98
+ * question mid-turn. It overrides the interactive "ask before implementing a guess"
99
+ * rule above for exactly that situation and nothing else; the interactive TUI never
100
+ * receives it.
101
+ */
102
+ export const HEADLESS_AUTONOMY_SECTION = `## Autonomous run
103
+
104
+ You are operating autonomously: the user is not watching in real time and cannot answer
105
+ questions mid-task, so asking "Shall I…?" blocks the work. Where the rules above say to ask,
106
+ state the assumption you made and continue. For reversible actions that follow from the
107
+ original request, proceed without asking; stop only for destructive actions or genuine scope
108
+ changes the user must decide, and report those as blockers in your final message. Before
109
+ ending your turn, check your last paragraph: if it is a plan, a question, or a promise about
110
+ work not yet done, do that work now. End only when the task is complete or blocked on input
111
+ only the user can provide.`;
112
+ /**
113
+ * Resolves the base prompt for a run.
114
+ *
115
+ * A broken override never blocks startup, but it is never silent either: falling
116
+ * back to the default would otherwise leave the user believing their own prompt
117
+ * is steering the agent. Same rule as a broken AGENTS.md or skill directory —
118
+ * skip it, keep going, say why.
119
+ *
120
+ * `configuredPrompt` is already validated as a non-empty string by config
121
+ * loading, so an inline override cannot fail here; only the file can.
122
+ */
123
+ export async function loadSystemPrompt(projectRoot, configuredPrompt) {
124
+ if (configuredPrompt !== undefined) {
125
+ return { prompt: configuredPrompt, source: 'config', path: undefined, problem: undefined };
126
+ }
127
+ const filePath = path.join(darwinDir(projectRoot), SYSTEM_PROMPT_FILENAME);
128
+ let text;
129
+ try {
130
+ text = await readFile(filePath, 'utf8');
131
+ }
132
+ catch (error) {
133
+ return {
134
+ prompt: DEFAULT_SYSTEM_PROMPT,
135
+ source: 'default',
136
+ path: undefined,
137
+ // A missing file is the normal case: the default is what most projects want.
138
+ problem: isMissingFile(error) ? undefined : describe(error),
139
+ };
140
+ }
141
+ // An empty file is treated as "no override" rather than as an empty prompt:
142
+ // sending no instructions at all is never what someone meant to configure.
143
+ if (text.trim() === '') {
144
+ return {
145
+ prompt: DEFAULT_SYSTEM_PROMPT,
146
+ source: 'default',
147
+ path: undefined,
148
+ problem: `${filePath} is empty — using the default prompt`,
149
+ };
150
+ }
151
+ return { prompt: text.trimEnd(), source: 'file', path: filePath, problem: undefined };
152
+ }
153
+ /** True when the file is simply not there (ENOTDIR: a file sits where a dir should). */
154
+ function isMissingFile(error) {
155
+ const code = typeof error === 'object' && error !== null ? error.code : undefined;
156
+ return code === 'ENOENT' || code === 'ENOTDIR';
157
+ }
158
+ function describe(error) {
159
+ return error instanceof Error ? error.message : String(error);
160
+ }
161
+ //# sourceMappingURL=system-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/agent/system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,gDAAgD;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8EA4DyC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;2BASd,CAAC;AAkB5B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,gBAAyB;IAEzB,IAAI,gBAAgB,KAAK,SAAS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AAK,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC;AACjD,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,99 @@
1
+ /**
2
+ * Thinking effort: how hard the model reasons before it answers.
3
+ *
4
+ * Claude 4.6 and later replace a hand-picked `budget_tokens` with *adaptive*
5
+ * thinking — the model decides per request whether to think and for how long —
6
+ * steered by a coarse effort level. Anthropic's own ladder and default are used
7
+ * verbatim (`high`), because a private scale would only invite the question of
8
+ * what it maps to:
9
+ *
10
+ * | effort | behaviour |
11
+ * |----------|--------------------------------------------------------------|
12
+ * | `low` | minimizes thinking; skips it for simple tasks |
13
+ * | `medium` | moderate thinking; may skip it for very simple queries |
14
+ * | `high` | always thinks (the default) |
15
+ * | `xhigh` | always thinks, extended depth — Opus only |
16
+ * | `max` | always thinks, no depth constraint |
17
+ *
18
+ * See
19
+ * https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-adaptive-thinking.html
20
+ *
21
+ * The Opus restriction on `xhigh` is measured, not read: that page says `max` is
22
+ * Opus-only too, and it is not. What Bedrock actually answers, in us-west-2
23
+ * (`spike/verify-thinking-live.ts` re-checks it):
24
+ *
25
+ * | model | low | medium | high | xhigh | max |
26
+ * |--------------------------|-----|--------|------|----------------------|-----|
27
+ * | `claude-sonnet-4-6` | ok | ok | ok | rejected | ok |
28
+ * | `claude-opus-5` | ok | ok | ok | ok | ok |
29
+ * | `claude-sonnet-4-5` | rejected — the whole `output_config` is refused |
30
+ *
31
+ * The `xhigh` rejection is a `ValidationException` reading
32
+ * `output_config.effort: Input should be 'low', 'medium', 'high' or 'max'`.
33
+ *
34
+ * Like {@link ../agent/prompt-cache.ts | prompt caching}, this module only decides
35
+ * *what to ask for* and hands the provider its fields; it never touches a request.
36
+ * The reason it decides at all — rather than passing the user's level straight
37
+ * through — is that an unsupported level is not degraded by the API, it is
38
+ * rejected, and on **every** request. So a level the model cannot serve is clamped
39
+ * to the highest one it can, and the clamp is reported rather than performed
40
+ * silently.
41
+ */
42
+ import type { JSONValue } from '@strands-agents/sdk';
43
+ import type { AppConfig, OpenAIApiMode } from '../config.js';
44
+ /** Effort levels, weakest first. Order is load-bearing: clamping walks it down. */
45
+ export declare const THINKING_EFFORTS: readonly ['low', 'medium', 'high', 'xhigh', 'max'];
46
+ export type ThinkingEffort = (typeof THINKING_EFFORTS)[number];
47
+ /** Anthropic's own default, and the strongest level every adaptive model accepts. */
48
+ export declare const DEFAULT_THINKING_EFFORT: ThinkingEffort;
49
+ export interface ThinkingPlan {
50
+ /** True when the request will carry thinking fields at all. */
51
+ enabled: boolean;
52
+ /** What the user asked for, whether or not it is what gets sent. */
53
+ requested: ThinkingEffort;
54
+ /**
55
+ * The level actually sent. Equal to {@link requested} unless the model could
56
+ * not serve it; undefined when nothing is sent at all.
57
+ */
58
+ effective: ThinkingEffort | undefined;
59
+ /**
60
+ * Why the effective level differs from the requested one, or why no thinking is
61
+ * configured despite a level being set. Undefined when the request carries
62
+ * exactly what was asked for — the same rule as the other startup loaders: only
63
+ * a gap between intent and reality is worth a line.
64
+ */
65
+ problem: string | undefined;
66
+ }
67
+ /**
68
+ * Decides what this run asks the model to think.
69
+ *
70
+ * Pure and cheap, so the model factory, the runtime and the header all call it
71
+ * rather than threading a plan through the config type — same shape as
72
+ * `planPromptCache`.
73
+ */
74
+ export declare function planThinking(config: AppConfig, effort?: "high" | "low" | "max" | "medium" | "xhigh"): ThinkingPlan;
75
+ /**
76
+ * The Bedrock `additionalRequestFields` (and the Anthropic `params`) for a plan,
77
+ * or undefined when the model gets no thinking configuration.
78
+ *
79
+ * `effort` deliberately sits in its own `output_config` object: Bedrock returns a
80
+ * `ValidationException` when it is nested inside `thinking`.
81
+ *
82
+ * `type: 'adaptive'` is the only mode used, never `enabled`/`budget_tokens`. Two
83
+ * reasons beyond it being the recommended form: the newest models reject the old
84
+ * one outright, and switching *between* modes invalidates the conversation cache
85
+ * breakpoint — so always-adaptive is what makes `/effort` free to change
86
+ * mid-session.
87
+ */
88
+ export declare function claudeThinkingFields(plan: ThinkingPlan): JSONValue | undefined;
89
+ /**
90
+ * The OpenAI `params` for a plan, or undefined when nothing is configured.
91
+ *
92
+ * The two APIs spell it differently and neither tolerates the other's spelling:
93
+ * Chat Completions takes a flat `reasoning_effort`, while the Responses API takes
94
+ * a nested `reasoning.effort` and answers `400 Unknown parameter:
95
+ * 'reasoning_effort'` to the flat one — measured on Mantle, see the table above.
96
+ */
97
+ export declare function openaiThinkingParams(plan: ThinkingPlan, api?: OpenAIApiMode): Record<string, unknown> | undefined;
98
+ /** Narrows an arbitrary value to an effort level. */
99
+ export declare function isThinkingEffort(value: unknown): value is ThinkingEffort;
@@ -0,0 +1,145 @@
1
+ /** Effort levels, weakest first. Order is load-bearing: clamping walks it down. */
2
+ export const THINKING_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
3
+ /** Anthropic's own default, and the strongest level every adaptive model accepts. */
4
+ export const DEFAULT_THINKING_EFFORT = 'high';
5
+ /**
6
+ * Levels only the Opus tier serves. Just `xhigh`, however the AWS page reads — see
7
+ * the measured table above.
8
+ */
9
+ const OPUS_ONLY_EFFORTS = ['xhigh'];
10
+ /**
11
+ * Model ids that support adaptive thinking. Matched as substrings of the model id
12
+ * rather than compared to a table of exact ids: Bedrock ids carry a profile prefix
13
+ * and often a version suffix (`us.anthropic.claude-sonnet-4-6`,
14
+ * `anthropic.claude-opus-4-6-v1`), so an exact-match table would silently stop
15
+ * recognizing a model the day AWS appends a suffix.
16
+ */
17
+ const ADAPTIVE_MODEL_MARKERS = [
18
+ 'claude-sonnet-4-6',
19
+ 'claude-opus-4-6',
20
+ 'claude-opus-4-7',
21
+ 'claude-opus-5',
22
+ 'claude-mythos',
23
+ 'claude-fable',
24
+ ];
25
+ /** The subset of {@link ADAPTIVE_MODEL_MARKERS} that also serves `xhigh` and `max`. */
26
+ const OPUS_TIER_MARKERS = ['claude-opus-4-6', 'claude-opus-4-7', 'claude-opus-5', 'claude-mythos', 'claude-fable'];
27
+ /**
28
+ * OpenAI's `reasoning_effort` stops at `high`; the two levels above it have no
29
+ * equivalent, so they are clamped rather than passed through to a 400.
30
+ *
31
+ * Bedrock Mantle is the measured exception — `spike/probe-mantle.ts` against
32
+ * `openai.gpt-5.6-sol` in us-east-1, on the Responses API:
33
+ *
34
+ * | field | low | medium | high | xhigh | max |
35
+ * |------------------------------|-----|--------|------|-------|-----|
36
+ * | `reasoning: { effort }` | ok | ok | ok | ok | ok |
37
+ * | `reasoning_effort` (flat) | 400 Unknown parameter — every level |
38
+ *
39
+ * Two more facts from the same run, both load-bearing elsewhere: that model
40
+ * refuses `/v1/chat/completions` outright (`api: 'responses'` is mandatory, hence
41
+ * `openaiApi` in the config), and no `reasoningContentDelta` ever reaches the
42
+ * stream — not even with `reasoning.summary` set to `auto` or `detailed` — so
43
+ * effort is spent but never displayed.
44
+ */
45
+ const OPENAI_MAX_EFFORT = 'high';
46
+ /**
47
+ * Decides what this run asks the model to think.
48
+ *
49
+ * Pure and cheap, so the model factory, the runtime and the header all call it
50
+ * rather than threading a plan through the config type — same shape as
51
+ * `planPromptCache`.
52
+ */
53
+ export function planThinking(config, effort = config.thinkingEffort) {
54
+ switch (config.provider) {
55
+ case 'bedrock':
56
+ case 'anthropic':
57
+ return planClaude(config.model, effort);
58
+ case 'openai':
59
+ // Not gated on the model id: OpenAI's reasoning models are not identifiable
60
+ // from a prefix the way Claude's are, and refusing a model we failed to
61
+ // recognize would be worse than the request error. A non-reasoning model
62
+ // rejects the reasoning field outright — documented on the config field.
63
+ //
64
+ // Mantle is exempt from the clamp because it was measured not to need it:
65
+ // `openai.gpt-5.6-sol` accepts the whole ladder through `max` on the
66
+ // Responses API. Clamping it anyway would quietly think less than asked.
67
+ return config.bedrockMantle !== true && isAbove(effort, OPENAI_MAX_EFFORT)
68
+ ? {
69
+ enabled: true,
70
+ requested: effort,
71
+ effective: OPENAI_MAX_EFFORT,
72
+ problem: `provider "openai" has no ${effort} reasoning effort — using ${OPENAI_MAX_EFFORT}`,
73
+ }
74
+ : { enabled: true, requested: effort, effective: effort, problem: undefined };
75
+ }
76
+ }
77
+ /** Adaptive thinking for a Claude model id, clamped to what that model serves. */
78
+ function planClaude(modelId, effort) {
79
+ const lowered = modelId.toLowerCase();
80
+ if (!ADAPTIVE_MODEL_MARKERS.some((marker) => lowered.includes(marker))) {
81
+ return {
82
+ enabled: false,
83
+ requested: effort,
84
+ effective: undefined,
85
+ problem: `${modelId} does not support adaptive thinking — Claude Sonnet 4.6 / Opus 4.6 and later do`,
86
+ };
87
+ }
88
+ const opusTier = OPUS_TIER_MARKERS.some((marker) => lowered.includes(marker));
89
+ if (!opusTier && OPUS_ONLY_EFFORTS.includes(effort)) {
90
+ // Down to `high`, not up to `max`, even though `max` would be accepted: asking
91
+ // for more depth than the user did is a bill they did not agree to.
92
+ return {
93
+ enabled: true,
94
+ requested: effort,
95
+ effective: DEFAULT_THINKING_EFFORT,
96
+ problem: `${modelId} does not support ${effort} effort (Opus only) — using ${DEFAULT_THINKING_EFFORT}`,
97
+ };
98
+ }
99
+ return { enabled: true, requested: effort, effective: effort, problem: undefined };
100
+ }
101
+ /**
102
+ * The Bedrock `additionalRequestFields` (and the Anthropic `params`) for a plan,
103
+ * or undefined when the model gets no thinking configuration.
104
+ *
105
+ * `effort` deliberately sits in its own `output_config` object: Bedrock returns a
106
+ * `ValidationException` when it is nested inside `thinking`.
107
+ *
108
+ * `type: 'adaptive'` is the only mode used, never `enabled`/`budget_tokens`. Two
109
+ * reasons beyond it being the recommended form: the newest models reject the old
110
+ * one outright, and switching *between* modes invalidates the conversation cache
111
+ * breakpoint — so always-adaptive is what makes `/effort` free to change
112
+ * mid-session.
113
+ */
114
+ export function claudeThinkingFields(plan) {
115
+ if (!plan.enabled || plan.effective === undefined)
116
+ return undefined;
117
+ return {
118
+ thinking: { type: 'adaptive' },
119
+ output_config: { effort: plan.effective },
120
+ };
121
+ }
122
+ /**
123
+ * The OpenAI `params` for a plan, or undefined when nothing is configured.
124
+ *
125
+ * The two APIs spell it differently and neither tolerates the other's spelling:
126
+ * Chat Completions takes a flat `reasoning_effort`, while the Responses API takes
127
+ * a nested `reasoning.effort` and answers `400 Unknown parameter:
128
+ * 'reasoning_effort'` to the flat one — measured on Mantle, see the table above.
129
+ */
130
+ export function openaiThinkingParams(plan, api = 'chat') {
131
+ if (!plan.enabled || plan.effective === undefined)
132
+ return undefined;
133
+ return api === 'responses'
134
+ ? { reasoning: { effort: plan.effective } }
135
+ : { reasoning_effort: plan.effective };
136
+ }
137
+ /** Narrows an arbitrary value to an effort level. */
138
+ export function isThinkingEffort(value) {
139
+ return typeof value === 'string' && THINKING_EFFORTS.includes(value);
140
+ }
141
+ /** True when `effort` sits above `limit` on the ladder. */
142
+ function isAbove(effort, limit) {
143
+ return THINKING_EFFORTS.indexOf(effort) > THINKING_EFFORTS.indexOf(limit);
144
+ }
145
+ //# sourceMappingURL=thinking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking.js","sourceRoot":"","sources":["../../../src/agent/thinking.ts"],"names":[],"mappings":"AA6CA,mFAAmF;AACnF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAGnF,qFAAqF;AACrF,MAAM,CAAC,MAAM,uBAAuB,GAAmB,MAAM,CAAC;AAE9D;;;GAGG;AACH,MAAM,iBAAiB,GAA8B,CAAC,OAAO,CAAC,CAAC;AAqB/D;;;;;;GAMG;AACH,MAAM,sBAAsB,GAAG;IAC7B,mBAAmB;IACnB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,cAAc;CACf,CAAC;AAEF,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,CAAC,iB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