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,320 @@
1
+ /**
2
+ * The model price cache: `~/.darwin/model-prices.json`, filled from LiteLLM's public
3
+ * price table one model id at a time.
4
+ *
5
+ * This module is the feature's only I/O and darwin's only use of the network outside
6
+ * tools and MCP. Its contract, decided by the user (2026-09-04):
7
+ *
8
+ * - The file stores **only the resolved mapping** — darwin model id → the four base
9
+ * rates plus the LiteLLM key they were read under and when — never the 2 MB table.
10
+ * - **A mapped id is never refetched.** Only an id the file does not know triggers a
11
+ * fetch, and at most one per process for that id (concurrent callers share it, a
12
+ * failed attempt is not retried until the next launch). An id LiteLLM does not
13
+ * list is recorded as `litellmKey: null` so it, too, is fetched once and not on
14
+ * every launch.
15
+ * - Every failure degrades to "price unavailable": no thrown error, no warning into
16
+ * the frame, no file write. A missing or damaged cache reads as empty.
17
+ * - Reads are synchronous and side-effect free, so `/status` and `/usage` can read
18
+ * through {@link ModelPriceStore.lookup} without becoming a fetch or a write.
19
+ */
20
+ import { randomBytes } from 'node:crypto';
21
+ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
22
+ import path from 'node:path';
23
+ import { userModelPricesFile } from '../paths.js';
24
+ export const MODEL_PRICES_SOURCE_URL = 'https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json';
25
+ export const MODEL_PRICES_SCHEMA_VERSION = 1;
26
+ /** The table is ~2.1 MB today; anything past this is not the table. */
27
+ export const MODEL_PRICES_MAX_BYTES = 8 * 1024 * 1024;
28
+ export const MODEL_PRICES_FETCH_TIMEOUT_MS = 10_000;
29
+ export function emptyModelPriceCache() {
30
+ return { version: MODEL_PRICES_SCHEMA_VERSION, source: MODEL_PRICES_SOURCE_URL, models: {} };
31
+ }
32
+ /**
33
+ * Reads the cache, tolerant by construction: a missing file, unparsable JSON, a
34
+ * foreign schema version or a non-object root all read as empty, and a malformed
35
+ * entry is skipped rather than failing the file. Never throws.
36
+ */
37
+ export function readModelPriceCache(file) {
38
+ let text;
39
+ try {
40
+ text = readFileSync(file, 'utf8');
41
+ }
42
+ catch {
43
+ return emptyModelPriceCache();
44
+ }
45
+ let parsed;
46
+ try {
47
+ parsed = JSON.parse(text);
48
+ }
49
+ catch {
50
+ return emptyModelPriceCache();
51
+ }
52
+ if (!isRecord(parsed) || parsed['version'] !== MODEL_PRICES_SCHEMA_VERSION || !isRecord(parsed['models'])) {
53
+ return emptyModelPriceCache();
54
+ }
55
+ const cache = emptyModelPriceCache();
56
+ if (typeof parsed['source'] === 'string')
57
+ cache.source = parsed['source'];
58
+ for (const [id, raw] of Object.entries(parsed['models'])) {
59
+ const entry = validEntry(raw);
60
+ if (entry !== undefined)
61
+ cache.models[id] = entry;
62
+ }
63
+ return cache;
64
+ }
65
+ function validEntry(raw) {
66
+ if (!isRecord(raw) || typeof raw['fetchedAt'] !== 'string')
67
+ return undefined;
68
+ const key = raw['litellmKey'];
69
+ if (key === null)
70
+ return { litellmKey: null, fetchedAt: raw['fetchedAt'] };
71
+ if (typeof key !== 'string')
72
+ return undefined;
73
+ const rates = ratesFrom(raw, {
74
+ input: 'inputCostPerToken',
75
+ output: 'outputCostPerToken',
76
+ cacheRead: 'cacheReadInputTokenCost',
77
+ cacheWrite: 'cacheCreationInputTokenCost',
78
+ });
79
+ if (rates === undefined)
80
+ return undefined;
81
+ return { litellmKey: key, fetchedAt: raw['fetchedAt'], ...rates };
82
+ }
83
+ /**
84
+ * Writes the whole cache atomically: a sibling temp file, then `rename`, so a
85
+ * reader never sees a half-written file and a crash leaves the previous one intact.
86
+ * Throws on I/O failure; the store catches, because a price is never worth a turn.
87
+ */
88
+ export function writeModelPriceCache(file, cache) {
89
+ mkdirSync(path.dirname(file), { recursive: true });
90
+ const temp = `${file}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
91
+ try {
92
+ writeFileSync(temp, `${JSON.stringify(cache, null, 2)}\n`, 'utf8');
93
+ renameSync(temp, file);
94
+ }
95
+ catch (error) {
96
+ rmSync(temp, { force: true });
97
+ throw error;
98
+ }
99
+ }
100
+ /**
101
+ * The LiteLLM keys to try for one darwin model id, most specific match first: the
102
+ * exact id (Bedrock inference profiles such as `global.anthropic.claude-sonnet-5`
103
+ * are listed bare), then the provider-prefixed form LiteLLM uses when the bare id
104
+ * is ambiguous — `bedrock/`, `bedrock_mantle/` (OpenAI-compatible Bedrock), `anthropic/`, `openai/`.
105
+ */
106
+ export function priceCandidateKeys(config) {
107
+ const id = config.model;
108
+ switch (config.provider) {
109
+ case 'bedrock':
110
+ return [id, `bedrock/${id}`];
111
+ case 'anthropic':
112
+ return [id, `anthropic/${id}`];
113
+ case 'openai':
114
+ return config.bedrockMantle === true ? [id, `bedrock_mantle/${id}`] : [id, `openai/${id}`];
115
+ }
116
+ }
117
+ /**
118
+ * Resolves one model against a fetched table: the first candidate key whose entry
119
+ * carries numeric `input_cost_per_token` and `output_cost_per_token` wins; the
120
+ * cache rates are copied when present. No hit records `litellmKey: null` — a
121
+ * resolved "no price", not an absence, so the id is not fetched again next launch.
122
+ */
123
+ export function resolveModelPrice(table, config, fetchedAt) {
124
+ if (isRecord(table)) {
125
+ for (const key of priceCandidateKeys(config)) {
126
+ const rates = ratesFrom(table[key], {
127
+ input: 'input_cost_per_token',
128
+ output: 'output_cost_per_token',
129
+ cacheRead: 'cache_read_input_token_cost',
130
+ cacheWrite: 'cache_creation_input_token_cost',
131
+ });
132
+ if (rates !== undefined)
133
+ return { litellmKey: key, fetchedAt, ...rates };
134
+ }
135
+ }
136
+ return { litellmKey: null, fetchedAt };
137
+ }
138
+ /** Projects one cache entry (or its absence) into the lookup the surfaces render. */
139
+ export function lookupFromEntry(entry) {
140
+ if (entry === undefined)
141
+ return { kind: 'unavailable' };
142
+ if (entry.litellmKey === null || entry.inputCostPerToken === undefined || entry.outputCostPerToken === undefined) {
143
+ return { kind: 'none' };
144
+ }
145
+ return {
146
+ kind: 'priced',
147
+ litellmKey: entry.litellmKey,
148
+ rates: {
149
+ inputCostPerToken: entry.inputCostPerToken,
150
+ outputCostPerToken: entry.outputCostPerToken,
151
+ ...(entry.cacheReadInputTokenCost !== undefined && { cacheReadInputTokenCost: entry.cacheReadInputTokenCost }),
152
+ ...(entry.cacheCreationInputTokenCost !== undefined && {
153
+ cacheCreationInputTokenCost: entry.cacheCreationInputTokenCost,
154
+ }),
155
+ },
156
+ };
157
+ }
158
+ /**
159
+ * Fetches the LiteLLM table with a bounded timeout and a bounded body, or returns
160
+ * `undefined` — never throws. Non-2xx, an over-cap body (by `content-length` or by
161
+ * actually counting the streamed bytes), invalid JSON or a non-object root are all
162
+ * "unavailable"; nothing is written by this function.
163
+ */
164
+ export async function fetchPriceTable(options = {}) {
165
+ const fetchImpl = options.fetch ?? globalThis.fetch;
166
+ const maxBytes = options.maxBytes ?? MODEL_PRICES_MAX_BYTES;
167
+ const controller = new AbortController();
168
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? MODEL_PRICES_FETCH_TIMEOUT_MS);
169
+ timer.unref();
170
+ try {
171
+ const response = await fetchImpl(options.url ?? MODEL_PRICES_SOURCE_URL, {
172
+ signal: controller.signal,
173
+ headers: { accept: 'application/json' },
174
+ });
175
+ if (!response.ok)
176
+ return undefined;
177
+ const declared = Number(response.headers.get('content-length'));
178
+ if (Number.isFinite(declared) && declared > maxBytes)
179
+ return undefined;
180
+ const text = await readBounded(response, maxBytes);
181
+ if (text === undefined)
182
+ return undefined;
183
+ const parsed = JSON.parse(text);
184
+ return isRecord(parsed) ? parsed : undefined;
185
+ }
186
+ catch {
187
+ return undefined;
188
+ }
189
+ finally {
190
+ clearTimeout(timer);
191
+ }
192
+ }
193
+ /** Reads the body while counting bytes; `undefined` the moment the cap is exceeded. */
194
+ async function readBounded(response, maxBytes) {
195
+ const body = response.body;
196
+ if (body === null) {
197
+ const text = await response.text();
198
+ return Buffer.byteLength(text, 'utf8') > maxBytes ? undefined : text;
199
+ }
200
+ const reader = body.getReader();
201
+ const chunks = [];
202
+ let total = 0;
203
+ for (;;) {
204
+ const { done, value } = await reader.read();
205
+ if (done)
206
+ break;
207
+ total += value.byteLength;
208
+ if (total > maxBytes) {
209
+ await reader.cancel().catch(() => undefined);
210
+ return undefined;
211
+ }
212
+ chunks.push(value);
213
+ }
214
+ return Buffer.concat(chunks).toString('utf8');
215
+ }
216
+ /** Set to `off` to disable the background price fetch for the process; the cache is still read. */
217
+ export const MODEL_PRICES_FETCH_ENV = 'DARWIN_MODEL_PRICES_FETCH';
218
+ /**
219
+ * The per-process price store: read-only {@link lookup} for every surface, and
220
+ * {@link ensure} — lookup, fetch once if absent, record — for startup and `/model`.
221
+ */
222
+ export class ModelPriceStore {
223
+ options;
224
+ /** One settled-or-pending attempt per model id: the "one fetch per process per id" rule. */
225
+ attempts = new Map();
226
+ constructor(options) {
227
+ this.options = options;
228
+ }
229
+ get file() {
230
+ return this.options.file;
231
+ }
232
+ /** What the cache says about this model right now. Synchronous; reads the file, writes nothing. */
233
+ lookup(config) {
234
+ try {
235
+ return lookupFromEntry(readModelPriceCache(this.options.file).models[config.model]);
236
+ }
237
+ catch {
238
+ return { kind: 'unavailable' };
239
+ }
240
+ }
241
+ /**
242
+ * Makes sure the cache has an entry for this model if the network can provide one.
243
+ * A mapped id returns without fetching; an unmapped id fetches at most once per
244
+ * process (shared by concurrent callers) and records the result — the resolved
245
+ * rates, or `litellmKey: null`. Never rejects: callers fire and forget it.
246
+ */
247
+ async ensure(config) {
248
+ try {
249
+ if (readModelPriceCache(this.options.file).models[config.model] !== undefined)
250
+ return;
251
+ if (this.options.fetchEnabled === false)
252
+ return;
253
+ let attempt = this.attempts.get(config.model);
254
+ if (attempt === undefined) {
255
+ attempt = this.fetchAndRecord(config).catch(() => undefined);
256
+ this.attempts.set(config.model, attempt);
257
+ }
258
+ await attempt;
259
+ }
260
+ catch {
261
+ // Degrade to "price unavailable"; a price is never worth a turn or a notice.
262
+ }
263
+ }
264
+ async fetchAndRecord(config) {
265
+ const table = await fetchPriceTable({
266
+ ...(this.options.fetch !== undefined && { fetch: this.options.fetch }),
267
+ ...(this.options.timeoutMs !== undefined && { timeoutMs: this.options.timeoutMs }),
268
+ ...(this.options.maxBytes !== undefined && { maxBytes: this.options.maxBytes }),
269
+ ...(this.options.url !== undefined && { url: this.options.url }),
270
+ });
271
+ if (table === undefined)
272
+ return;
273
+ const fetchedAt = (this.options.now ?? (() => new Date()))().toISOString();
274
+ const entry = resolveModelPrice(table, config, fetchedAt);
275
+ // Re-read before merging so two processes filling different ids cannot erase
276
+ // each other's work; the rename below then publishes the merged file whole.
277
+ const cache = readModelPriceCache(this.options.file);
278
+ cache.source = this.options.url ?? MODEL_PRICES_SOURCE_URL;
279
+ cache.models[config.model] = entry;
280
+ writeModelPriceCache(this.options.file, cache);
281
+ }
282
+ }
283
+ let defaultStore;
284
+ /**
285
+ * The process-wide store over `~/.darwin/model-prices.json`. One instance per
286
+ * process so a `/clear` successor runtime shares the fetch-once bookkeeping with
287
+ * its predecessor instead of starting a second download of the same table.
288
+ * `DARWIN_MODEL_PRICES_FETCH=off` in the environment keeps it cache-only.
289
+ */
290
+ export function defaultModelPriceStore() {
291
+ defaultStore ??= new ModelPriceStore({
292
+ file: userModelPricesFile(),
293
+ fetchEnabled: process.env[MODEL_PRICES_FETCH_ENV]?.trim().toLowerCase() !== 'off',
294
+ });
295
+ return defaultStore;
296
+ }
297
+ function isRecord(value) {
298
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
299
+ }
300
+ /** Reads the four rates under the given field names; undefined unless input and output are finite, non-negative numbers. */
301
+ function ratesFrom(raw, fields) {
302
+ if (!isRecord(raw))
303
+ return undefined;
304
+ const input = rate(raw[fields.input]);
305
+ const output = rate(raw[fields.output]);
306
+ if (input === undefined || output === undefined)
307
+ return undefined;
308
+ const cacheRead = rate(raw[fields.cacheRead]);
309
+ const cacheWrite = rate(raw[fields.cacheWrite]);
310
+ return {
311
+ inputCostPerToken: input,
312
+ outputCostPerToken: output,
313
+ ...(cacheRead !== undefined && { cacheReadInputTokenCost: cacheRead }),
314
+ ...(cacheWrite !== undefined && { cacheCreationInputTokenCost: cacheWrite }),
315
+ };
316
+ }
317
+ function rate(value) {
318
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : undefined;
319
+ }
320
+ //# sourceMappingURL=model-prices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-prices.js","sourceRoot":"","sources":["../../../src/pricing/model-prices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,CAAC,MAAM,uBAAuB,GAClC,6FAA6F,CAAC;AAChG,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,uEAAuE;AACvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACtD,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAqBpD,MAAM,UAAU,oBAAoB;IAClC,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC/F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,YAAY,CAAC,IAAI,EAA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AC;IAClE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAChD,OAAO;QACL,iBAAiB,EAAE,KAAK;QACxB,kBAAkB,EAAE,MAAM;QAC1B,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,uBAAuB,EAAE,SAAS,EAAE,CAAC;QACtE,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,2BAA2B,EAAE,UAAU,EAAE,CAAC;KAC7E,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** The two markers, each a token that only the patched SDK file contains. */
2
+ export declare const SDK_PATCH_MARKERS: readonly [{
3
+ readonly file: 'index.js';
4
+ readonly token: 'DEFAULT_SUMMARIZATION_PROMPT';
5
+ }, {
6
+ readonly file: 'vended-plugins/context-offloader/plugin.js';
7
+ readonly token: 'excludeTools';
8
+ }];
9
+ export declare const SDK_PATCH_PREFLIGHT_EXIT_CODE = 1;
10
+ /**
11
+ * The refusal text for the given missing markers (`undefined` when none is missing):
12
+ * what is wrong, why it happened, and the one supported fix. Bounded and fixed —
13
+ * the names are the SDK file paths above.
14
+ */
15
+ export declare function unpatchedSdkNotice(missing: readonly string[]): string | undefined;
16
+ /**
17
+ * Inspect the installed SDK's marker files. `sources` maps a marker file (relative to
18
+ * the SDK's `dist/src/`) to its text, or `undefined` when unreadable; the default reads
19
+ * the files next to the SDK's resolved entry point.
20
+ */
21
+ export declare function missingSdkPatchMarkers(sources?: (file: string) => string | undefined): string[];
22
+ /** The refusal to print (stderr) and exit nonzero with, or `undefined` when the SDK is patched. */
23
+ export declare function sdkPatchPreflight(): string | undefined;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Startup preflight: refuse to run on an unpatched `@strands-agents/sdk`.
3
+ *
4
+ * darwin depends on its pinned SDK patch (`patches/@strands-agents__sdk@1.16.0.patch`).
5
+ * pnpm applies it in a clone; the npm package applies it from `postinstall` with
6
+ * `patch-package`. An install that skipped scripts (`npm install --ignore-scripts`,
7
+ * or `pnpm add -g`, whose isolated layout patch-package cannot address) leaves the
8
+ * SDK unpatched, and the first symptom used to be ESM's raw
9
+ * `does not provide an export named 'DEFAULT_SUMMARIZATION_PROMPT'` from
10
+ * `src/agent/compact.ts` — thrown while *linking* the module graph, before any
11
+ * statement of `cli.ts` ran. That is why the check lives in a module whose imports
12
+ * never reach the SDK and why `cli.ts` loads the rest of the program with a dynamic
13
+ * `import()` only after it passed: a static import would fail first.
14
+ *
15
+ * The check reads two marker files instead of importing the SDK, so `--help` stays
16
+ * cheap and no SDK module is evaluated before the refusal: the root re-export that
17
+ * the raw error was about, and the `excludeTools` option of the context offloader,
18
+ * which an unpatched SDK would silently ignore at runtime.
19
+ */
20
+ import { readFileSync } from 'node:fs';
21
+ import { fileURLToPath } from 'node:url';
22
+ import { DARWIN_PACKAGE_NAME } from './version.js';
23
+ /** The two markers, each a token that only the patched SDK file contains. */
24
+ export const SDK_PATCH_MARKERS = [
25
+ { file: 'index.js', token: 'DEFAULT_SUMMARIZATION_PROMPT' },
26
+ { file: 'vended-plugins/context-offloader/plugin.js', token: 'excludeTools' },
27
+ ];
28
+ export const SDK_PATCH_PREFLIGHT_EXIT_CODE = 1;
29
+ /**
30
+ * The refusal text for the given missing markers (`undefined` when none is missing):
31
+ * what is wrong, why it happened, and the one supported fix. Bounded and fixed —
32
+ * the names are the SDK file paths above.
33
+ */
34
+ export function unpatchedSdkNotice(missing) {
35
+ if (missing.length === 0)
36
+ return undefined;
37
+ return [
38
+ `error: the installed @strands-agents/sdk is not patched (missing: ${missing.join(', ')}).`,
39
+ 'darwin needs its pinned SDK patch, which `patch-package` applies from this package\'s `postinstall` script;',
40
+ 'that script did not run here — typically an `npm install --ignore-scripts`, or `pnpm add -g`, which is unsupported.',
41
+ `Fix: reinstall through the supported route, \`npm install -g ${DARWIN_PACKAGE_NAME}\` (scripts enabled).`,
42
+ 'Developing in a clone: `pnpm install` applies the same patch through pnpm.',
43
+ '',
44
+ ].join('\n');
45
+ }
46
+ /**
47
+ * Inspect the installed SDK's marker files. `sources` maps a marker file (relative to
48
+ * the SDK's `dist/src/`) to its text, or `undefined` when unreadable; the default reads
49
+ * the files next to the SDK's resolved entry point.
50
+ */
51
+ export function missingSdkPatchMarkers(sources = readInstalledSdkFile) {
52
+ return SDK_PATCH_MARKERS.filter(({ file, token }) => !(sources(file)?.includes(token) ?? false))
53
+ .map(({ file, token }) => `${token} in ${file}`);
54
+ }
55
+ function readInstalledSdkFile(file) {
56
+ // `@strands-agents/sdk` resolves to `dist/src/index.node.js`; the marker files are
57
+ // its siblings. Resolution failure (no SDK at all) is a different, louder problem
58
+ // and is left to surface as itself.
59
+ const entry = import.meta.resolve('@strands-agents/sdk');
60
+ try {
61
+ return readFileSync(fileURLToPath(new URL(`./${file}`, entry)), 'utf8');
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ /** The refusal to print (stderr) and exit nonzero with, or `undefined` when the SDK is patched. */
68
+ export function sdkPatchPreflight() {
69
+ return unpatchedSdkNotice(missingSdkPatchMarkers());
70
+ }
71
+ //# sourceMappingURL=sdk-patch-preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-patch-preflight.js","sourceRoot":"","sources":["../../src/sdk-patch-preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,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CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,iBAAiB;IAC/B,OAAO,kBAAkB,CAAC,sBAAsB,EAAE,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: commit-message
3
+ description: Write git commit messages following this project's conventions. Use when the user asks for a commit message, or asks you to commit staged changes.
4
+ ---
5
+
6
+ # Commit message conventions
7
+
8
+ Follow these rules exactly when writing a commit message for this project.
9
+
10
+ ## Format
11
+
12
+ ```
13
+ <type>(<scope>): <subject>
14
+
15
+ <body>
16
+
17
+ 🤖 Committed with Darwin Coding Agent
18
+ ```
19
+
20
+ ## Rules
21
+
22
+ 1. `type` must be one of: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`.
23
+ 2. `scope` is the affected module, lowercase, no spaces (e.g. `permission`, `mcp`, `skills`).
24
+ 3. `subject` is imperative mood, lowercase, no trailing period, at most 60 characters.
25
+ 4. Separate subject and body with one blank line.
26
+ 5. Wrap the body at 72 characters.
27
+ 6. The body explains **why**, never **what** — the diff already shows what changed.
28
+ 7. Never mention tooling or AI assistance in the subject or body. The only
29
+ exception is the signature line below.
30
+ 8. End every message with the signature `🤖 Committed with Darwin Coding Agent`
31
+ on its own line, separated from the body by one blank line.
32
+
33
+ ## Example
34
+
35
+ ```
36
+ fix(permission): deny unknown tools by default
37
+
38
+ MCP servers register tools we have no policy entry for. Defaulting to
39
+ "execute" means a new tool is gated until someone classifies it, rather
40
+ than silently running unprompted.
41
+
42
+ 🤖 Committed with Darwin Coding Agent
43
+ ```
44
+
45
+ See `references/types.md` for when to use each type.
@@ -0,0 +1,8 @@
1
+ # Choosing a commit type
2
+
3
+ - `feat` — adds user-visible capability
4
+ - `fix` — corrects broken behaviour
5
+ - `docs` — documentation only
6
+ - `refactor` — restructuring with no behaviour change
7
+ - `test` — tests only
8
+ - `chore` — build, deps, tooling
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: developer
3
+ description: Supervise one complete headless darwin worker and independently accept its result. Use when delegating repository work to a persistent darwin conversation.
4
+ ---
5
+
6
+ # Developer supervisor
7
+
8
+ Act as the supervising developer in this Host conversation. Delegate implementation to a headless darwin child; do not replace the SDK loop or hide a child failure by editing the implementation yourself.
9
+
10
+ ## 1. Frame the delegation
11
+
12
+ Before launching anything, establish from the request and repository evidence:
13
+
14
+ - the absolute target repository root;
15
+ - the exact requirement and independently observable acceptance checks;
16
+ - decisions the user has already made versus product decisions only the user can make; and
17
+ - the authorized mutation and command scope.
18
+
19
+ Ask the user when any of these boundaries is unresolved. Never infer authorization merely because a command is convenient.
20
+
21
+ Model-call budgets are opt-in. Do not add `--max-model-calls` to a child command by default. If the user or Host explicitly sets a cost ceiling, pass that positive integer through unchanged and report it; the generic CLI guard then refuses the next provider request after the ceiling.
22
+
23
+ ## 2. Launch the complete child worker
24
+
25
+ Construct a shell-safe command for the target root and launch it with the `bash` tool in **`start` mode**. Every child invocation must be a managed background task; never run `darwin -p ...` with foreground `execute`. Run the first worker with `--yolo --context-offload`: offload is already default-on for ordinary runs, and this compatible process-only override deliberately force-enables it even if persistent config opted out. Do not use `--compact-before` on a fresh child: there is no prior transcript to summarize, and this one turn owns the complete repository workflow. Add `--max-model-calls <n>` only for an explicit user/Host ceiling.
26
+
27
+ The first prompt must give the child the requirement, evidence, repository scope, acceptance criteria, and authorized mutation/command scope. Tell it to derive, before implementing, a concise requirement-to-test checklist — each externally observable requirement (exact routes, contracts, flags) paired with the check that proves it — and to verify every entry before reporting completion: an entry no test covers is a gap to close, not a line to drop. Tell it to proceed autonomously through the repository's own configured workflow: load any relevant non-developer skills, create or maintain task/planning/research artifacts when those skills require them, implement, run focused and final checks, update specs, and commit when authorized. It must not load the `developer` skill, start another darwin, or delegate the supervision task again. Do not make the child wait for Host plan approval; unresolved product, scope, or authorization questions are the only reason to stop and ask.
28
+
29
+ ### Tool batching and verification economy
30
+
31
+ The child's own system prompt already states the round-trip rules (batch independent reads, consolidate known edits, verification in the message after the edits); do not restate them. Add only the supervision-specific rule: the child must never repeat a file read or a green check merely to reconfirm it.
32
+
33
+ Use a verification pyramid. While editing, run the smallest reproduction and focused suite, then typecheck. After source settles, the child runs the complete project gate once before commit. A commit with no source change is followed only by commit/diff/status checks, not another full suite. The Host independently runs the complete acceptance gate once. A failed check is fixed and rerun; this rule removes duplicate green runs, not failure diagnosis.
34
+
35
+
36
+ Run the child from the exact target root. Do not substitute the Host's source repository or prepend a `cd` to some other directory. Keep the returned `bg-*` background task id. Tell the user that `/tasks` remains available while this Host turn runs. Monitor completion with `bash status` and incremental `bash output`; do not synchronize with fixed sleeps. For every child task, call `bash output` at least once. After it reaches a terminal state, keep calling `bash output` until `hasMore: false` before reviewing the reply or taking the next step. Status metadata and `outputBytes` are not the child's response.
37
+
38
+ From the first task's combined output, capture only the exact stderr record matching:
39
+
40
+ ```text
41
+ ^session: ([a-z0-9_-]+)$
42
+ ```
43
+
44
+ That captured value is the **child conversation session id**. It is not the `bg-*` task id. Never use a background id as a session id, and never recover identity from `--continue` or the resume pointer (`last-session.json` under `~/.darwin/sessions/<project-key>/`): both resolve to whichever session most recently finished, which may not be this child.
45
+
46
+ From **every** child task's drained output — initial worker, correction, and retry alike — also capture the exact stderr record matching:
47
+
48
+ ```text
49
+ ^usage: input=(\d+|-) output=(\d+|-) cacheRead=(\d+|-) cacheWrite=(\d+|-)$
50
+ ```
51
+
52
+ That is the child process's token spend for that one invocation. The four fields are mutually exclusive cost buckets: `input` excludes every reported cache read and cache write, so aggregate each field independently across tasks and apply its own provider rate. A `-` means the provider never reported that metric; it does not mean zero, so carry it through as unknown rather than adding it in as `0`. Each child process reports only its own run, so the totals never overlap. A task that fails before any model call completes may report zeros or no line at all — record its absence rather than inventing a number.
53
+
54
+ Beside it, capture the exact stderr record matching:
55
+
56
+ ```text
57
+ ^cost: total=(\d+\.\d+|-) input=(\d+\.\d+|-) output=(\d+\.\d+|-) cacheRead=(\d+\.\d+|-) cacheWrite=(\d+\.\d+|-) model=(\S+) pricing=(\S+)$
58
+ ```
59
+
60
+ That is the same spend in approximate USD at LiteLLM base rates, per model. `total` is the figure to report per task; `-` is unknown (an unreported bucket or a model with no cached price), never zero, so a task whose `total` is `-` stays unknown in the aggregate rather than being summed as `0`. A task with no `cost:` line is stated as such.
61
+
62
+ ## 3. Handle child questions or completion
63
+
64
+ Read the complete worker reply and compare it with the requirement and repository evidence. Answer a child question directly only when existing evidence resolves it. If product intent, scope, or authorization remains unresolved, ask the user in this Host conversation instead of inventing an answer. A worker stopped by an explicit user/Host ceiling may continue in the same session only with renewed authorization and a precise remaining-work prompt; do not call incomplete work accepted.
65
+
66
+ ## 4. Continue the exact child session only for correction
67
+
68
+ After independent acceptance finds a concrete failure, launch a correction as another `bash start` task in the same target root with `--session <captured-id> --yolo --context-offload`. Never use `--continue` or `--resume`, and never omit the explicit session, yolo, or force-on context-offload flags. Add `--max-model-calls <n>` only when the user or Host explicitly authorized a ceiling. Add `--compact-before` only when the prior worker turn left a broad implementation/check transcript; a narrow correction should retain cached continuity without paying for an unnecessary summary. State the exact acceptance failure, any explicit ceiling, and the compaction decision. Tell the child to correct, run affected focused checks, commit the fix when authorized, and report without reopening unrelated work.
69
+
70
+ Headless children cannot receive interactive permission prompts, so this workflow always runs them in yolo mode. Keep every child command inside the authorized target repository and mutation scope established above; yolo changes confirmation behavior, not task scope.
71
+
72
+ For each task, retain its new `bg-*` id, monitor with `status`, consume output incrementally with `output`, and inspect failures. A process failure or bad result may be corrected by another explicit `--session <captured-id>` turn when useful.
73
+
74
+ ### Retry transient child server failures
75
+
76
+ If the drained child stderr ends the turn with a provider-side server error — the headless driver prints it as `error: <message>`, for example `error: The server had an error while processing your request. Sorry about that!` (an HTTP 5xx/overloaded answer from the provider, not a darwin error) — retry the same requested turn automatically. Use another managed `bash start` invocation with the same target root, prompt, yolo/context-offload flags and any explicit user/Host ceiling; when a child session id has been captured, include the same explicit `--session <captured-id>`. Preserve the prior turn's compact-before decision; an explicit ceiling exhaustion requires renewed authorization rather than an automatic retry. If the first worker attempt failed before emitting an exact session record, start a fresh worker attempt and capture its new record instead of guessing an id.
77
+
78
+ Retry at most two times after the original attempt. Drain and record every retry task normally. Do not retry deterministic failures such as invalid configuration, denied scope, failed tests, or rejected tool input under this rule. If the transient server failure persists after two retries, report it as a blocker rather than looping or implementing in the Host.
79
+
80
+ ## 5. Accept independently
81
+
82
+ After the child reports completion, independently inspect the repository diff and run the named acceptance checks from the Host. This is the one Host full-gate pass in the verification pyramid; do not duplicate a green child full gate before inspecting the diff. Do not accept the child's prose or its claimed test result as evidence. If acceptance fails, send the exact failure and a focused correction to the same child session through another managed background invocation, then rerun only affected focused checks before the final full gate. Do not patch the implementation yourself merely to conceal the failure.
83
+
84
+ After every accepted requirement iteration in the darwin repository, run `pnpm build` from the repository root before reporting acceptance or launching the next worker. This refreshes the `dist` CLI and copied built-in skills that the next `darwin` process actually loads; typecheck and tests do not replace it. Treat a failed build as an acceptance failure and send the exact failure to the same child session for correction.
85
+
86
+ ## 6. Wrap up: keep the user-facing docs in step
87
+
88
+ Acceptance proves the code; the wrap-up proves a reader can find out about it. After each accepted iteration, ask whether the change altered anything a user or maintainer reads about — a command, flag, key chord, config field, output format, contract or invariant — and check the three surfaces that describe darwin to people:
89
+
90
+ - **README** (`README.md` and `README.zh-CN.md`): the command/flag tables and the short feature prose;
91
+ - **user guide** (`docs/user-guide/`): the task-oriented page the change belongs to (`using-darwin`, `getting-started`, `configuration`, `sessions-and-state`, `permissions`, `extensions`, `development`) as well as `reference.md` — children usually update the reference and README and skip the narrative pages, so that is where to look; English and `zh-CN` stay in step;
92
+ - **architecture docs** (`docs/architecture/load-bearing-decisions.md`, and `AGENTS.md`'s index table only when a new load-bearing invariant exists): the rationale heading the change belongs under.
93
+
94
+ Only edit where something is actually stale or missing; a change with no user-visible surface needs no docs commit, and say so. A docs-only sync carries no source change, so the Host may write it directly in one `docs(...)` commit — the "never patch to conceal a failure" rule in section 5 is about implementation, not documentation — or hand it to the same child session as a focused correction when the gap is large or needs code-level knowledge the child already holds. Either way: run every suite that pins documentation text (search `spike/` for the doc paths you touched — for example `verify-cli-args.ts` quotes `CLI_USAGE` from `reference.md`), respect the `AGENTS.md` byte cap (`MAX_INSTRUCTIONS_BYTES`: check `wc -c AGENTS.md` before and after; rationale goes to the load-bearing doc when the cap is near), and run `pnpm build` again if the sync touched a built-in skill under `src/skills/builtin/`.
95
+
96
+ ## 7. Report
97
+
98
+ Report:
99
+
100
+ - the child conversation session id;
101
+ - every background task id and terminal outcome;
102
+ - changed files and independently run acceptance checks/results;
103
+ - the docs wrap-up: which README / user-guide / architecture pages were synced (and the commit), or that none needed it;
104
+ - **token spend**: the captured `usage:` figures per child task, plus an aggregate total across every task in this delegation (state `-` metrics as unknown rather than folding them into a sum, and say when a task reported no line at all), and the captured `cost:` USD `total` per task plus its aggregate on the same rule (`-` unknown, never summed as 0; a task with no line stated); and
105
+ - unresolved risks, denied operations, or decisions still needed.
106
+
107
+ The background registry owns short-lived process lifecycle; the persisted child session owns conversation continuity. Keep those identities separate throughout.