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,814 @@
1
+ import type { AgentStreamEvent, ImageBlock, McpClient } from '@strands-agents/sdk';
2
+ import { type CompactResult } from './compact.js';
3
+ import { DiagnosticsLog, type DiagnosticsStatus } from './diagnostics.js';
4
+ import { type ModelRetryOutcome, type RetryWaitState } from './model-retry.js';
5
+ import { type SubagentCancelResult, type SubagentDispatchListener, type SubagentDispatchProgressListener, type SubagentDispatchStatus } from '../agents/dispatch-registry.js';
6
+ import { type ExpandedCustomCommand } from '../commands/custom-commands.js';
7
+ import { createModelFromConfig, type AppConfig, type ModelChoice } from '../config.js';
8
+ import { BackgroundBashManager, type BackgroundTaskListener, type BackgroundTaskStatus } from '../tools/background-bash.js';
9
+ import { LifecycleHookRunner, type TurnCompleteOutcome, type TurnCompleteSource } from '../hooks/lifecycle-hooks.js';
10
+ import { CodexHookRunner } from '../hooks/codex-hook-runner.js';
11
+ import { type McpLoadResult, type McpServerStatus } from '../mcp/registry.js';
12
+ import { type ExpandedSkillCommand } from '../skills/plugin.js';
13
+ import { type MemoryCommandResult } from '../memory/command.js';
14
+ import { MemoryToolController } from '../memory/controller.js';
15
+ import type { MemoryStatus } from '../memory/store.js';
16
+ import { type RecorderOptions, type TrajectoryStatus } from '../trajectory/writer.js';
17
+ import { type ProjectInstructionsSummary } from './instructions.js';
18
+ import { type AllowRuleEntry, type ApprovalMode, type PermissionBridge, type PermissionModeChange } from './permission.js';
19
+ import { type PromptCachePlan } from './prompt-cache.js';
20
+ import { type SessionSelector } from './session.js';
21
+ import { type SystemPromptSource } from './system-prompt.js';
22
+ import { type ThinkingEffort, type ThinkingPlan } from './thinking.js';
23
+ import { type RewindCatalogue, type RewindCheckpoint } from './rewind.js';
24
+ import { type UsageTotals } from './usage.js';
25
+ import { type SessionCallStats } from './call-stats.js';
26
+ import type { ModelPriceLookup, ModelUsageShare } from './cost.js';
27
+ /** Test seam for proving startup unwind after resources have been acquired. */
28
+ type RuntimeCreateCheckpoint = 'after-initialize';
29
+ export declare function setRuntimeCreateCheckpointForTest(callback: ((checkpoint: RuntimeCreateCheckpoint) => void) | undefined): void;
30
+ declare let runtimeRecorderOverrides: Pick<RecorderOptions, 'openFile' | 'inputDurabilityTimeoutMs'> | undefined;
31
+ export declare function setRuntimeModelFactoryForTest(factory: typeof createModelFromConfig | undefined): void;
32
+ export declare function setRuntimeRecorderOverridesForTest(overrides: typeof runtimeRecorderOverrides): void;
33
+ export interface RuntimeOptions {
34
+ projectRoot: string;
35
+ /** Conversation to create or restore. */
36
+ session: SessionSelector;
37
+ /** Called once the effective id is known, before provider startup. */
38
+ onSessionResolved?: (sessionId: string) => void;
39
+ /** Suppress unbounded MCP subprocess banners from the process terminal. */
40
+ quietMcpStderr?: boolean;
41
+ /** Asks the user to approve write and execute tool calls. */
42
+ permissionBridge: PermissionBridge;
43
+ /** Overrides the config's `permissionMode` (CLI flags win over the file). */
44
+ permissionModeOverride?: ApprovalMode;
45
+ /** Process-local force-on override for ContextOffloader; never persisted. */
46
+ contextOffloadOverride?: true;
47
+ /** Refuses the next parent-Agent SDK model call after this many in the process. */
48
+ maxModelCalls?: number;
49
+ /**
50
+ * One driver-owned section appended to the base prompt, before project instructions.
51
+ * Headless runs pass `HEADLESS_AUTONOMY_SECTION` (system-prompt.ts); the interactive TUI passes
52
+ * nothing. Only the base is user-overridable, so a `.darwin/system-prompt.md`
53
+ * override still receives it.
54
+ */
55
+ systemPromptSuffix?: string;
56
+ /** Internal source checkpoint used only by a fresh `/rewind` successor. */
57
+ rewindRestore?: {
58
+ readonly sourceSessionId: string;
59
+ readonly snapshotId: string;
60
+ };
61
+ /**
62
+ * Resources a predecessor runtime hands to its successor across `/clear` or `/rewind`.
63
+ *
64
+ * Set only by {@link AgentRuntime.startNewSession}. Everything here belongs to the
65
+ * *process* rather than to the conversation, so duplicating it would spawn a second
66
+ * copy and releasing it would break something the user is still using. Everything
67
+ * *not* here is session-scoped and rebuilt: session manager, trajectory recorder,
68
+ * diagnostics log, offload storage, skills plugin, permission gate, dispatch
69
+ * registry, usage meter and message history.
70
+ */
71
+ inherit?: InheritedRuntimeResources;
72
+ }
73
+ /** @see RuntimeOptions.inherit */
74
+ export interface InheritedRuntimeResources {
75
+ /**
76
+ * The predecessor's *live* config, so a `/model` or `/effort` change made this
77
+ * session does not silently revert to whatever is on disk.
78
+ */
79
+ config: AppConfig;
80
+ /**
81
+ * The already-connected MCP clients and the metadata the header reports about
82
+ * them. Reusing the client objects spawns no second stdio server: `initialize()`
83
+ * only calls `listTools()`, and `McpClient.connect()` no-ops when connected.
84
+ */
85
+ mcp: McpLoadResult;
86
+ /**
87
+ * The background-job manager, with its running jobs. Jobs are owned by the
88
+ * process, so `/clear` neither stops them nor loses track of them; their logs stay
89
+ * in the directory of the session that started them.
90
+ */
91
+ backgroundBash: BackgroundBashManager;
92
+ }
93
+ export type { CompactResult } from './compact.js';
94
+ export type { UsageTotals } from './usage.js';
95
+ /**
96
+ * The outcome of an `/effort` change: what the model will now do, and a promise
97
+ * for the attempt to remember it in `~/.darwin/config.json`.
98
+ *
99
+ * The write is handed back unawaited on purpose — see
100
+ * {@link AgentRuntime.changeThinkingEffort}.
101
+ */
102
+ export interface ThinkingChangeResult {
103
+ plan: ThinkingPlan;
104
+ saved: Promise<void>;
105
+ }
106
+ /**
107
+ * The outcome of a `/model` change: which configuration is now live, what it can
108
+ * cache, how hard it will think — and a promise for the attempt to remember the
109
+ * switch in `~/.darwin/config.json`.
110
+ *
111
+ * The cache and thinking plans come back because both are model-dependent: the
112
+ * new model may not cache at all, and it may not serve the effort level the old
113
+ * one did. Reporting that is the point; discovering it on the next turn is not.
114
+ */
115
+ export interface ModelChangeResult {
116
+ choice: ModelChoice;
117
+ thinking: ThinkingPlan;
118
+ promptCache: PromptCachePlan;
119
+ saved: Promise<void>;
120
+ }
121
+ export type ExpandedSlashCommand = ({
122
+ kind: 'skill';
123
+ } & ExpandedSkillCommand) | ({
124
+ kind: 'command';
125
+ } & ExpandedCustomCommand) | {
126
+ kind: 'workflow';
127
+ message: string;
128
+ };
129
+ /** Estimated size of the next request's context, plus the model's window. */
130
+ export interface ContextEstimate {
131
+ /** Provider-native count when enabled/supported, otherwise the SDK heuristic. */
132
+ estimatedTokens: number;
133
+ messageCount: number;
134
+ /** The model's context window, when the SDK knows it for this model id. */
135
+ windowTokens: number | undefined;
136
+ /**
137
+ * The measured prompt-token total of the most recent completed model call, when a
138
+ * live anchor supplied the base for {@link estimatedTokens}. Absent means no
139
+ * measurement was available — the `usageBuckets` rule: unknown, never 0.
140
+ */
141
+ measuredTokens?: number;
142
+ /**
143
+ * The estimated size of the messages appended since that call — 0 for an empty
144
+ * tail, absent when the tail count itself failed (the measured base is still
145
+ * reported rather than discarded).
146
+ */
147
+ tailTokens?: number;
148
+ }
149
+ export interface RuntimeInfo {
150
+ config: AppConfig;
151
+ /**
152
+ * The directory this session resolves everything against — `src/paths.ts`'s one
153
+ * input, carried here so a UI that has to name or scan the workspace (the `@`
154
+ * path completion in `src/tui/path-completion.ts`) reads it from the live session
155
+ * rather than calling `process.cwd()` a second time.
156
+ */
157
+ projectRoot: string;
158
+ /** Effective approval mode after CLI overrides. */
159
+ permissionMode: ApprovalMode;
160
+ sessionId: string;
161
+ resumed: boolean;
162
+ /** Names of skills discovered under `.darwin/skills/`. */
163
+ skillNames: string[];
164
+ /** Skill directories that were skipped, with the reason. */
165
+ skillProblems: {
166
+ directory: string;
167
+ reason: string;
168
+ }[];
169
+ /** Names of custom prompts discovered under `.darwin/commands/`. */
170
+ commandNames: string[];
171
+ /** Custom command files that were skipped, with the reason. */
172
+ commandProblems: {
173
+ file: string;
174
+ reason: string;
175
+ }[];
176
+ /** Built-in and project-defined child agents available to the delegation tool. */
177
+ agentNames: string[];
178
+ /** Project agent files that were skipped, with the reason. */
179
+ agentProblems: {
180
+ file: string;
181
+ reason: string;
182
+ }[];
183
+ /** AGENTS.md preloaded from the run directory, or undefined when there is none. */
184
+ projectInstructions: ProjectInstructionsSummary | undefined;
185
+ /** Why a present AGENTS.md was skipped; undefined when there is no such file. */
186
+ projectInstructionsProblem: string | undefined;
187
+ /** Where the base system prompt came from: built-in, config, or override file. */
188
+ systemPromptSource: SystemPromptSource;
189
+ /** Path of the system prompt override file, when one is in effect. */
190
+ systemPromptPath: string | undefined;
191
+ /** Why a present system prompt override was skipped; undefined when there is none. */
192
+ systemPromptProblem: string | undefined;
193
+ /**
194
+ * Why the working context carries no directory listing. Undefined in the normal
195
+ * case: the rest of the block (directory, platform, date) is always sent.
196
+ */
197
+ workingContextProblem: string | undefined;
198
+ /** What this run caches, or why it caches nothing. */
199
+ promptCache: PromptCachePlan;
200
+ /**
201
+ * How hard the model thinks at startup, and why that differs from the config
202
+ * when it does. Only the startup value: the live one moves with `/effort`, so
203
+ * read {@link AgentRuntime.thinking} for that.
204
+ */
205
+ thinking: ThinkingPlan;
206
+ /** Path to the MCP config that was read, or undefined when there is none. */
207
+ mcpConfigPath: string | undefined;
208
+ /** Every MCP config layer that contributed servers. */
209
+ mcpConfigPaths: string[];
210
+ /** Project server names that replaced global definitions. */
211
+ mcpOverriddenServerNames: string[];
212
+ /** Root `.mcp.json` left unread because `.darwin/mcp.json` took precedence. */
213
+ /** Project-scoped user-state file where accepted allow rules persist. */
214
+ permissionRulesPath: string;
215
+ /** Active hook source files, in Pre policy order. */
216
+ hookSources: string[];
217
+ /** Legacy .darwin hook inputs shadowed by authoritative hooks/*.json directories. */
218
+ hookShadowNotices: {
219
+ layer: string;
220
+ directory: string;
221
+ shadowed: string[];
222
+ }[];
223
+ mcpIgnoredConfigPath: string | undefined;
224
+ /** Number of MCP servers configured (some may have failed to connect). */
225
+ mcpServerCount: number;
226
+ /** Agent-facing names of every tool registered, MCP tools included. */
227
+ toolNames: string[];
228
+ /**
229
+ * Where this session's append-only trajectory is recorded, or undefined when
230
+ * `trajectory: false` switched recording off. Reported rather than assumed: the
231
+ * whole point of the record is that something else can read it later.
232
+ */
233
+ trajectoryFile: string | undefined;
234
+ /**
235
+ * Where this session's diagnostics are written, or undefined when `diagnostics` is
236
+ * off — which is the default. Reported so the TUI can say where the file is in one
237
+ * transcript notice: a log nobody can find is a log nobody reads, and the header
238
+ * contract forbids spending a frame row on it.
239
+ */
240
+ diagnosticsFile: string | undefined;
241
+ }
242
+ export declare class AgentRuntime {
243
+ private readonly agent;
244
+ private model;
245
+ private readonly projectRoot;
246
+ /** Kept whole, not just the clients: a successor inherits the header metadata too. */
247
+ private readonly mcp;
248
+ private readonly skills;
249
+ private readonly commands;
250
+ private readonly subagents;
251
+ private readonly workflows;
252
+ private readonly subagentDispatches;
253
+ /** Forwards background runs' `AfterToolCallEvent`s into `send()`'s stream (SER-064). */
254
+ private readonly backgroundDelegation;
255
+ /** The parent Agent's own retry state; children keep theirs behind their installer (SER-066). */
256
+ private readonly modelRetry;
257
+ private readonly backgroundBash;
258
+ private readonly gate;
259
+ /** Undefined when neither native lifecycle event is configured. */
260
+ private readonly lifecycleHooks;
261
+ private readonly toolHookLayers;
262
+ /** Portable Codex-dialect session/tool/lifecycle adapter. */
263
+ private readonly codexHooks;
264
+ private readonly sessionManager;
265
+ /** The `/compact` recent window; the manager itself is built per call (focus is constructor-only). */
266
+ private readonly preserveRecentMessages;
267
+ /** Undefined when `trajectory: false` switched recording off for this run. */
268
+ private readonly trajectory;
269
+ /** Undefined unless `diagnostics: true` asked for the log. Off is the default. */
270
+ private readonly diagnosticsLog;
271
+ /** Undefined only when effective config disables derived project context. */
272
+ private readonly memoryController;
273
+ readonly info: RuntimeInfo;
274
+ /**
275
+ * What this runtime was created with, so {@link startNewSession} can assemble its
276
+ * successor through the same factory instead of a second, drifting assembly.
277
+ */
278
+ private readonly createOptions;
279
+ /**
280
+ * The live thinking plan. Mutable, unlike everything in {@link RuntimeInfo}:
281
+ * `/effort` changes it mid-session by reconfiguring the model in place.
282
+ */
283
+ private thinkingPlan;
284
+ /**
285
+ * The config in effect right now. Diverges from `info.config` after `/model`:
286
+ * `info` is the startup snapshot, this moves with the session.
287
+ */
288
+ private liveConfig;
289
+ /** What the live model can cache. Recomputed on `/model`, like the plan above. */
290
+ private promptCachePlan;
291
+ private lastTurnDelta;
292
+ /**
293
+ * Completed turns' meter deltas, tallied under the config in effect for each turn —
294
+ * the same `before` snapshot and config the trajectory's turn meter reads, so the
295
+ * in-process per-model shares and the recorded per-turn spend attribute identically.
296
+ * Exists so `/status`, `/usage` and the headless `cost:` record can price each
297
+ * model's tokens at its own rates after a `/model` switch instead of the live
298
+ * model's rates over the whole meter. Read through {@link modelShares}.
299
+ */
300
+ private readonly turnUsageByModel;
301
+ /**
302
+ * Per-model-call efficiency tallies for this session (issue #8 follow-up A).
303
+ * Parent-only and session-scoped by construction: only this runtime's own
304
+ * `send()` feeds it, and `/clear`'s successor runtime starts a fresh one.
305
+ */
306
+ private callStatsState;
307
+ /**
308
+ * Latched on the first tally failure. The stats are an observer of the stream:
309
+ * a broken tally degrades every surface to absence (no efficiency section, no
310
+ * `model-calls:` record) rather than reporting numbers it can no longer trust —
311
+ * and can never become a second reason a turn dies.
312
+ */
313
+ private callStatsBroken;
314
+ /**
315
+ * The most recent completed model call's measured prompt size, with where the
316
+ * conversation stood when it was measured — the base {@link contextEstimate} builds
317
+ * on. Parent-only and session-scoped for the same reason as the call stats: only
318
+ * this runtime's `send()` installs it, and `/clear`/`/rewind` successors start
319
+ * without one. `undefined` until a metered call completes, which is also what a
320
+ * resumed session reports until its first turn.
321
+ */
322
+ private contextAnchor;
323
+ /**
324
+ * Latched on the first anchor failure, separately from {@link callStatsBroken}: the
325
+ * two observers must not be able to break each other, and a broken anchor degrades
326
+ * `/context` to the plain heuristic line rather than to a wrong number.
327
+ */
328
+ private contextAnchorBroken;
329
+ /** Serializes the bounded list/save/list critical section across concurrent callers. */
330
+ private rewindCaptureTail;
331
+ /**
332
+ * The per-process model price cache (`~/.darwin/model-prices.json`). Process-wide
333
+ * on purpose: a `/clear` successor shares its fetch-once bookkeeping, and children
334
+ * never touch it — they report tokens, the parent prices them.
335
+ */
336
+ private readonly modelPrices;
337
+ private constructor();
338
+ /**
339
+ * Releases startup-owned observers and external clients when construction fails.
340
+ * Successful creation transfers the same resources to `shutdown()` instead.
341
+ */
342
+ static unwindCreate(diagnosticsLog: DiagnosticsLog | undefined, mcpClients?: readonly McpClient[], backgroundBash?: BackgroundBashManager, memoryController?: MemoryToolController, lifecycleHooks?: LifecycleHookRunner, codexHooks?: CodexHookRunner): Promise<void>;
343
+ static create(options: RuntimeOptions): Promise<AgentRuntime>;
344
+ /**
345
+ * Runs one turn, yielding SDK stream events untouched so callers can render
346
+ * whichever ones they care about.
347
+ *
348
+ * Snapshots the accumulated usage before the turn so `lastTurnUsage` can
349
+ * report the delta — including cancelled turns, where the delta reflects
350
+ * whatever model calls completed before the cancel.
351
+ *
352
+ * The trajectory recorder first crosses one bounded, no-throw durability barrier
353
+ * for `userInput`, before `Agent.stream()` can invoke a provider or tool. Later
354
+ * events are observed between `stream()` and the `yield`, in {@link recordStream} —
355
+ * a pass-through generator that records synchronously and cannot throw, so it can
356
+ * neither reorder, delay nor swallow an event. Both properties are measured over a
357
+ * real offline `AgentRuntime` in `spike/verify-trajectory.ts`.
358
+ *
359
+ * The turn's spend reaches the record through a meter handed to `beginTurn`, and not
360
+ * from this `finally`, because of when the two run: `recordStream`'s `finally` closes
361
+ * and buffers the `turnEnded` record *before* this one executes, so a number produced
362
+ * here would always be one step too late for it. The meter is read while that record is
363
+ * composed. Keeping the write there also keeps it off this error path, where a throw
364
+ * would replace the provider's error object with the recorder's — the one thing the
365
+ * observer contract forbids.
366
+ *
367
+ * One `before` snapshot feeds both the meter and `lastTurnDelta`, so what the record
368
+ * says a turn cost and what `/usage` says it cost cannot be two different readings.
369
+ */
370
+ send(input: string, userInput?: string, image?: ImageBlock): AsyncIterable<AgentStreamEvent>;
371
+ /**
372
+ * Adds one completed turn's delta to its model's share. Runs in `send`'s `finally`,
373
+ * so it cannot throw: a tally that failed would replace the provider's error with
374
+ * its own, which the observer contract forbids — a failure costs the tally, not
375
+ * the turn (the remainder rule in {@link modelShares} then attributes the tokens
376
+ * to the live model, so nothing goes uncounted).
377
+ */
378
+ private tallyTurnUsage;
379
+ /**
380
+ * What this run has recorded, or `undefined` when recording is switched off.
381
+ *
382
+ * Read rather than pushed: a trajectory problem is worth one notice after the
383
+ * turn that hit it (where the context-pressure check already lives), not an
384
+ * observer that could interrupt the frame mid-stream.
385
+ */
386
+ get trajectoryStatus(): TrajectoryStatus | undefined;
387
+ /**
388
+ * Records a user-typed `!` command (SER-024) in the session's trajectory.
389
+ *
390
+ * A passthrough to the recorder and nothing else: the command was run by the
391
+ * TUI under the user's own authority, so it neither enters the agent loop nor
392
+ * asks permission here — this is the honesty half of that bargain. No-op when
393
+ * recording is off or has latched itself off, like every other record.
394
+ */
395
+ recordShellCommand(entry: {
396
+ command: string;
397
+ exitCode: number | null;
398
+ signal: string | null;
399
+ timedOut: boolean;
400
+ durationMs: number;
401
+ output: string;
402
+ }): void;
403
+ /**
404
+ * The diagnostics log, or `undefined` when nobody asked for one.
405
+ *
406
+ * Handed out rather than wrapped in per-entry methods so a caller can decide *once*
407
+ * whether it is logging at all: the TUI swaps its whole dispatch function on this
408
+ * being defined, which is what keeps a default run's notice path byte-for-byte what
409
+ * it was. Everything on it is synchronous and non-throwing by contract.
410
+ */
411
+ get diagnostics(): DiagnosticsLog | undefined;
412
+ /**
413
+ * What this run has logged, or `undefined` when the log is off. Read after a turn,
414
+ * exactly like {@link trajectoryStatus} and for the same reason: a problem is worth
415
+ * one notice where the context-pressure check already lives, never an observer that
416
+ * interrupts the frame mid-stream.
417
+ */
418
+ get diagnosticsStatus(): DiagnosticsStatus | undefined;
419
+ /** Best-effort status of enabled derived project memory. */
420
+ get memoryStatus(): MemoryStatus | undefined;
421
+ /**
422
+ * Runs the user-only local `/memory` command and refreshes the verified Darwin-owned
423
+ * prompt block before a successful mutation returns. No Agent invocation is made.
424
+ */
425
+ manageMemory(input: string): Promise<MemoryCommandResult>;
426
+ /**
427
+ * Replaces old conversation history with rolling summaries, keeping the recent
428
+ * configured window verbatim, then persists the rewritten session immediately.
429
+ *
430
+ * This is deliberately a direct conversation-manager call, not an agent turn:
431
+ * `/compact` must not become part of the context it is trying to shrink. The
432
+ * original messages are cloned so any model/count/storage failure can put the
433
+ * live agent back exactly where it started.
434
+ *
435
+ * `focus` (trimmed here; blank means none) makes this one summary keep what it
436
+ * names: the summarizer's system prompt becomes the SDK default followed by one
437
+ * fixed focus section. Without a focus the manager is configured exactly as
438
+ * before per-call construction existed. An over-cap focus is refused here,
439
+ * before the PreCompact hook and before any model call.
440
+ */
441
+ compact(focus?: string): Promise<CompactResult>;
442
+ /** Messages restored from a resumed session, for showing prior context. */
443
+ get messageCount(): number;
444
+ /**
445
+ * Estimates the context the next model request would carry, without sending it:
446
+ * this reads messages and never mutates them, so it is safe to call mid-turn.
447
+ *
448
+ * Two shapes, one honest reading. With a live measurement anchor
449
+ * (`src/agent/context-anchor.ts`) the base is the provider's own prompt-token total
450
+ * for the most recent completed call — system prompt and every `toolSpec` included,
451
+ * measured rather than guessed — and only the messages appended since that call are
452
+ * counted here, which bounds the estimated part to one call's worth of tail. Without
453
+ * one (a fresh or resumed session before its first metered call, after `/compact`,
454
+ * after a `/model` switch) it falls back to counting the whole assembled request.
455
+ *
456
+ * Either way the count itself is the SDK's character heuristic in practice —
457
+ * `useNativeTokenCount` is on, but Bedrock's `CountTokens` refuses the
458
+ * inference-profile ids darwin requires (see README "Known limitations"), so the
459
+ * first attempt per model may make one cheap non-streaming call that fails and is
460
+ * then cached as skipped. The window comes from the SDK's own per-model table,
461
+ * `undefined` when unknown.
462
+ */
463
+ contextEstimate(): Promise<ContextEstimate>;
464
+ /**
465
+ * How many wildcard allow-rules are in effect right now — config plus anything
466
+ * accepted this session. Read live from the gate rather than snapshotted into
467
+ * `info`, which is fixed at startup.
468
+ */
469
+ get allowRuleCount(): number;
470
+ /**
471
+ * Persists a rule the user accepted in a confirmation prompt. The gate is
472
+ * already honouring it (it came back on the decision), so a rejected write only
473
+ * costs the memory of it in the next session — which is why this throws instead
474
+ * of swallowing: the caller reports it to the user.
475
+ */
476
+ saveAllowRule(rule: string): Promise<void>;
477
+ /**
478
+ * The live allow-rules with their provenance — config-loaded vs granted this
479
+ * session — for the `/permissions` report. Read live from the gate, like
480
+ * {@link allowRuleCount}.
481
+ */
482
+ listAllowRules(): readonly AllowRuleEntry[];
483
+ /**
484
+ * The configured MCP servers with their live connection state and registered
485
+ * tool names, for the `/mcp` report. A read-only projection — names, states and
486
+ * counts only, never tool results or server output — that connects nothing:
487
+ * a server that never connected is reported as such, not probed.
488
+ */
489
+ listMcpServers(): McpServerStatus[];
490
+ /**
491
+ * Revokes allow-rules, on the user's instruction only.
492
+ *
493
+ * The gate stops honouring them *before* this returns — the live rule list is
494
+ * the enforcement surface, so the very next matching call prompts again — and
495
+ * `saved` is the persistence of exactly the rules that were live, reported by
496
+ * the caller rather than awaited (the grant flow's shape, and the same
497
+ * degradation: a failed write costs the file, not the session — the rule only
498
+ * resurrects in the next process). Rules that were not live are skipped, never
499
+ * "revoked": persisting the removal of a rule that was never in force would
500
+ * make this command able to edit the file beyond narrowing what it showed.
501
+ */
502
+ revokeAllowRules(rules: readonly string[]): {
503
+ removed: string[];
504
+ saved: Promise<void>;
505
+ };
506
+ /**
507
+ * The approval mode enforcing right now — `info.permissionMode` is the startup
508
+ * one, which is a different question and the one the trajectory record and the
509
+ * headless report mean. Read live from the gate, which owns the value.
510
+ */
511
+ get permissionMode(): ApprovalMode;
512
+ /**
513
+ * Switches the approval mode for the rest of this session, on the user's
514
+ * instruction only.
515
+ *
516
+ * Nothing is persisted, deliberately and unlike `/effort` or `/model`: this
517
+ * changes *enforcement*, so a widening that outlived the process would defeat the
518
+ * rule that no allow-rule may cover `~/.darwin/config.json`. The next process
519
+ * starts from configured/CLI policy again.
520
+ *
521
+ * Synchronous, and it must stay that way: the mode has to be in force before the
522
+ * very next gate decision, and there is nothing to await — no file, no model, no
523
+ * rebuild. The gate is the single decision point, so the intervention the parent
524
+ * and every child share sees the new value with no further plumbing.
525
+ */
526
+ changePermissionMode(next: ApprovalMode): PermissionModeChange;
527
+ /** How hard the model is thinking right now, and why that is not what was asked. */
528
+ get thinking(): ThinkingPlan;
529
+ /**
530
+ * Switches the effort level for the rest of the session and remembers it in
531
+ * `~/.darwin/config.json`.
532
+ *
533
+ * The model is reconfigured before the file is written, and the new plan is
534
+ * returned rather than awaited alongside the write: an effort change must take
535
+ * effect on the very next turn, so a slow or failing disk cannot be allowed to
536
+ * hold it up. A rejected write therefore means "this session only", which is why
537
+ * it rethrows through {@link ThinkingChangeResult.saved} instead of being
538
+ * swallowed — the caller says so.
539
+ *
540
+ * Only ever `adaptive` → `adaptive`, so this does not invalidate the conversation
541
+ * cache breakpoint (switching thinking *modes* would).
542
+ */
543
+ changeThinkingEffort(effort: ThinkingEffort): ThinkingChangeResult;
544
+ /** The config in effect now — the startup one until `/model` changes it. */
545
+ get config(): AppConfig;
546
+ /** What this run can cache right now; moves with `/model`. */
547
+ get promptCache(): PromptCachePlan;
548
+ /**
549
+ * What the price cache knows about the live model — `priced` with its LiteLLM
550
+ * key and base rates, `none` when LiteLLM lists no such id, `unavailable` until
551
+ * the background fetch has recorded it. A read of the cache file, never a fetch
552
+ * or a write, so `/status` and `/usage` stay byte-zero mutation.
553
+ */
554
+ get modelPrice(): ModelPriceLookup;
555
+ /**
556
+ * This process's meter split per model, each share with the config that projects
557
+ * it and what the price cache says about it — what `/status`, `/usage` and the
558
+ * headless `cost:` record price, each model at its own rates.
559
+ *
560
+ * The completed turns' tally comes first, in first-appearance order; whatever the
561
+ * meter holds beyond it — the turn in flight, or a tally that failed — belongs to
562
+ * the live model, so the shares always sum to {@link usage} metric for metric and a
563
+ * single-model session is exactly one share over the whole meter (which keeps its
564
+ * reports byte-identical to the one-lookup rendering). A zero remainder adds no
565
+ * share once any turn has been tallied, so a `/model` switch that has not run a
566
+ * turn yet does not appear as a second model that spent nothing; before the first
567
+ * turn, the live model's zero share is the report's only subject.
568
+ *
569
+ * A read of the cache file per share, never a fetch or a write.
570
+ */
571
+ get modelShares(): readonly ModelUsageShare[];
572
+ /** Every configured model, with the live one marked. */
573
+ get modelChoices(): readonly ModelChoice[];
574
+ /**
575
+ * Switches the live model to another configured entry, keeping the conversation.
576
+ *
577
+ * `Agent.model` is a mutable property, so this replaces the model in place
578
+ * instead of rebuilding the agent — which is the whole point: the history, the
579
+ * session file, the tools and the permission gate all survive. Both switch
580
+ * directions were measured to carry a conversation containing tool calls
581
+ * (`spike/probe-model-switch.ts`); a Claude reasoning block in the history is
582
+ * dropped with a warning by the OpenAI adapter rather than rejected, which is
583
+ * why the TUI routes SDK warnings into notices.
584
+ *
585
+ * The thinking and cache plans are recomputed rather than carried over: effort
586
+ * clamping is per-model and caching is per-provider, so the old plans would
587
+ * describe a model that is no longer there.
588
+ */
589
+ changeModel(target: ModelChoice): Promise<ModelChangeResult>;
590
+ /**
591
+ * Token totals for every model call this agent has made so far.
592
+ *
593
+ * Read live from the SDK's meter rather than tallied from stream events:
594
+ * `accumulatedUsage` is a lifetime accumulator (see the SDK reuse section of
595
+ * `docs/architecture/load-bearing-decisions.md`), so it is already the
596
+ * running total and is readable between turns, including after a cancelled one
597
+ * that never produced an `agentResultEvent`.
598
+ *
599
+ * Counts this process only. Sessions persist messages, not metrics, so a
600
+ * `--resume`d session starts from zero however much it spent before — callers
601
+ * that show these numbers should say so.
602
+ */
603
+ get usage(): UsageTotals;
604
+ /**
605
+ * Token delta for the most recently completed turn, or `undefined` before any
606
+ * turn has finished. A cancelled turn still produces a delta covering whatever
607
+ * model calls completed before the cancel.
608
+ */
609
+ get lastTurnUsage(): UsageTotals | undefined;
610
+ /**
611
+ * The parent Agent's model-retry wait in progress — decided on a failed attempt,
612
+ * cleared when the wait ends (timer or cancel) and at turn end — or `undefined`
613
+ * when no attempt is waiting. Read on the driver's existing tick; a child's wait is
614
+ * reachable only through its own installer and never surfaces here (SER-066).
615
+ */
616
+ retryWait(): RetryWaitState | undefined;
617
+ /**
618
+ * How the parent's last turn ended when retry played a part — the cap reached, or
619
+ * a wait cancelled — for the driver's failure notice; `undefined` otherwise and
620
+ * once the next turn begins (SER-067). Parent only, like {@link retryWait}.
621
+ */
622
+ retryOutcome(): ModelRetryOutcome | undefined;
623
+ /**
624
+ * Folds one stream event into the session call stats. Synchronous, and swallows
625
+ * its own failures on the recorder's terms: an observer between `stream()` and
626
+ * `yield` that could throw would be a second way for a turn to die. The first
627
+ * failure latches the stats broken — every surface then reads absence rather
628
+ * than a tally that silently missed calls.
629
+ */
630
+ private observeCallStats;
631
+ /**
632
+ * Folds one stream event into the `/context` measurement anchor: a completed model
633
+ * call's provider counters say exactly how large the request it just sent was, so
634
+ * that number replaces the heuristic base for the next estimate.
635
+ *
636
+ * Same observer discipline as {@link observeCallStats}, with its own latch so
637
+ * neither can break the other. A call that measures nothing (failed attempt,
638
+ * unreported counters, a split that cannot be made honestly) leaves the previous
639
+ * anchor in place — it is still the best measurement available — rather than
640
+ * downgrading `/context` to a pure heuristic mid-session.
641
+ */
642
+ private observeContextAnchor;
643
+ /**
644
+ * Per-model-call efficiency stats for this session's parent agent, or
645
+ * `undefined` until a completed call has been observed — so every surface that
646
+ * reads this stays byte-identical to before the feature existed when nothing
647
+ * happened yet (the `childUsage` convention). Also `undefined` after a tally
648
+ * failure: a broken stat degrades to absence, never to a wrong number. Children
649
+ * are deliberately not counted here; their spend is {@link childUsage}'s story.
650
+ */
651
+ get callStats(): SessionCallStats | undefined;
652
+ /**
653
+ * Token totals for this run's child agents (subagent dispatches and workflow
654
+ * nodes), summed over the dispatch registry — running children read live,
655
+ * finished ones report their frozen terminal reading, and a cancelled or
656
+ * failed child still counts what it spent. `dispatches` counts only the
657
+ * dispatches whose usage was included in the sum. `undefined` when no
658
+ * dispatch ever reported usage, so zero-delegation sessions are
659
+ * indistinguishable from before children were counted at all.
660
+ */
661
+ get childUsage(): {
662
+ dispatches: number;
663
+ usage: UsageTotals;
664
+ } | undefined;
665
+ /**
666
+ * Everything this session has spent: the parent meter ({@link usage}) plus
667
+ * {@link childUsage} when any child reported spend — exactly `this.usage`
668
+ * otherwise, so callers without delegation see the same totals they always
669
+ * did. Summed with `sumUsage`, whose cache counters stay absent until some
670
+ * meter reports them (never an invented zero). Like the parent meter across
671
+ * `/model` switches, the raw sum is projected with the *live* config.
672
+ */
673
+ get sessionUsage(): UsageTotals;
674
+ /** Current-process background tasks, without creating an agent tool call. */
675
+ listBackgroundTasks(): Promise<BackgroundTaskStatus[]>;
676
+ /** Publishes future terminal task snapshots until the returned closure is called. */
677
+ subscribeToBackgroundTasks(listener: BackgroundTaskListener): () => void;
678
+ /**
679
+ * Every subagent dispatch of this run, in start order, running and finished
680
+ * alike. Synchronous — unlike {@link listBackgroundTasks}, which snapshots live
681
+ * OS processes through per-task queues, this is an in-memory registry with no
682
+ * I/O at all.
683
+ *
684
+ * These are *runs*, not the catalogue: `info.agentNames` lists the definitions
685
+ * that may be dispatched, which is a different question answered by a different
686
+ * path. Records carry name, task text, closed phase, state, timestamps and the
687
+ * child meter's usage counters — never any part of a child's transcript or tool
688
+ * payload.
689
+ */
690
+ listSubagentDispatches(): SubagentDispatchStatus[];
691
+ /** Publishes future terminal dispatch snapshots until the returned closure is called. */
692
+ subscribeToSubagentDispatches(listener: SubagentDispatchListener): () => void;
693
+ /** User-visible safe phase updates and periodic heartbeats; never model/trajectory input. */
694
+ subscribeToSubagentProgress(listener: SubagentDispatchProgressListener): () => void;
695
+ /** User-only exact-id cancellation; no agent tool exposes this operation. */
696
+ cancelSubagentDispatch(dispatchId: string): SubagentCancelResult;
697
+ /**
698
+ * Asks the agent to stop the current turn at its next safe point. The stream
699
+ * ends with `stopReason: 'cancelled'` rather than throwing.
700
+ */
701
+ cancel(): void;
702
+ /** Publishes a bounded driver-owned turn outcome; command results are unobservable. */
703
+ observeTurnComplete(outcome: TurnCompleteOutcome, source: TurnCompleteSource): void;
704
+ /** Drains bounded portable-hook diagnostics for the existing driver notice channels. */
705
+ takeHookProblems(): string[];
706
+ /** Publishes one truthful approval request only when it becomes visible. */
707
+ observePermissionRequest(request: {
708
+ source: string;
709
+ toolName: string;
710
+ toolInput: unknown;
711
+ }): void;
712
+ /** Completed prompt boundaries available for an in-session conversation branch. */
713
+ listRewindCheckpoints(): Promise<RewindCatalogue>;
714
+ /**
715
+ * Branches from one catalogued source boundary into a fresh runtime.
716
+ *
717
+ * Selection is re-read immediately before assembly, so a stale UI row cannot name
718
+ * an arbitrary SDK snapshot. Source files remain read-only throughout; only the
719
+ * fresh successor id receives a latest snapshot.
720
+ */
721
+ startRewind(checkpoint: RewindCheckpoint): Promise<AgentRuntime>;
722
+ /**
723
+ * Records this session as the one `--resume` should reopen. Called after a turn
724
+ * completes, so an unused session never displaces a useful one.
725
+ */
726
+ markResumable(): Promise<void>;
727
+ /**
728
+ * Starts a brand-new session in this process and returns the runtime that owns it.
729
+ * This runtime is retired and must not be used again; the caller becomes
730
+ * responsible for shutting the successor down.
731
+ *
732
+ * A *new Agent* is what makes this a new session, and there is no cheaper way:
733
+ * `SessionManager` is an SDK plugin whose snapshot hooks are registered during
734
+ * `initialize()` with no removal path, and its session id is private and readonly.
735
+ * Assigning a second manager
736
+ * would leave the first one's hooks live, and at the end of the next turn it would
737
+ * overwrite the *previous* session's `snapshot_latest.json` with the cleared
738
+ * conversation — destroying the thing `/clear` exists to preserve. So the successor
739
+ * is assembled through the same {@link create} factory rather than a second
740
+ * hand-written assembly that could drift from it.
741
+ *
742
+ * Nothing is deleted, moved or rewritten: the session being left keeps its snapshot,
743
+ * its `trajectory.jsonl` (flushed here, never truncated), its `offload/` and its
744
+ * `background/` exactly as they are, and stays resumable by id.
745
+ *
746
+ * The resume pointer is deliberately *not* moved. `markResumable()` writes it after a
747
+ * completed turn precisely so an unused session cannot displace a useful one — and
748
+ * an empty session has no snapshot to resume, so pointing `--resume` at it would cost
749
+ * the user the conversation they just set aside. The successor claims the pointer on
750
+ * its first finished turn, through the ordinary path.
751
+ *
752
+ * If assembling the successor fails, this runtime stays fully usable: nothing it owns
753
+ * has been released yet, and the diagnostics tap it installed at startup is put back
754
+ * (the failed successor's unwind clears the process-global sink).
755
+ */
756
+ startNewSession(): Promise<AgentRuntime>;
757
+ /**
758
+ * Releases what this runtime owns *alone* after a successor has taken over.
759
+ *
760
+ * The complement of {@link shutdown}, and the difference is the point: the MCP
761
+ * clients and the background-job manager now belong to the successor, so
762
+ * disconnecting the servers or stopping the jobs here would break a live session.
763
+ * The process-global SDK verbose sink is left alone for the same reason — the
764
+ * successor installed its own, and clearing it would silence the new session's
765
+ * diagnostics.
766
+ *
767
+ * What is released: this Agent's own persistent bash shell (the vended tool keys
768
+ * shells per Agent, so leaving it would hold the event loop open forever), the
769
+ * subagent tool, and the two observers, closed so their bytes are durable. Failures
770
+ * are settled, not thrown: a retirement that cannot flush must not take the new
771
+ * session down with it.
772
+ */
773
+ private retire;
774
+ /**
775
+ * Creates one bounded rewind snapshot, serialized so concurrent callers cannot
776
+ * both observe the final free slot. The tail is repaired after rejection so one
777
+ * storage failure does not permanently block later ordinary turns.
778
+ */
779
+ private captureRewindCheckpoint;
780
+ /**
781
+ * Expands a built-in prompt command, a skill, or a project command into the
782
+ * prompt sent to the model. `/workflow` is checked first: built-in
783
+ * reservation precedes skills and custom commands, so no extension can
784
+ * shadow it. Its bare form returns null — the drivers own that local usage
785
+ * notice, and the runtime never fabricates a turn. Skills are checked before
786
+ * custom commands as a defensive backstop to the loader's collision
787
+ * filtering. Unknown slash input remains ordinary user input.
788
+ */
789
+ expandSlashCommand(input: string): Promise<ExpandedSlashCommand | null>;
790
+ /**
791
+ * Releases every child process the session owns. Must run on exit: both the
792
+ * bash shell and stdio MCP servers are spawned subprocesses whose open pipes
793
+ * keep the event loop alive, so skipping this hangs the process instead of
794
+ * exiting.
795
+ */
796
+ shutdown(options?: {
797
+ throwOnError?: boolean;
798
+ }): Promise<void>;
799
+ /**
800
+ * Kills the persistent bash shell the vended `bash` tool keeps per agent.
801
+ *
802
+ * The SDK registers a `beforeExit` handler to do this, but `beforeExit` only
803
+ * fires once the event loop is empty — and the shell's own stdio pipes are what
804
+ * keep it non-empty, so that handler never runs and the process hangs forever
805
+ * after any command has been executed.
806
+ *
807
+ * `mode: 'restart'` is the public way to reach the session: it stops the running
808
+ * shell and installs a fresh one that is only spawned on the next command, so
809
+ * nothing is left holding the loop open. The call is made directly (bypassing
810
+ * the model loop) with history recording off, so it neither prompts for
811
+ * permission nor appears in the conversation.
812
+ */
813
+ private stopBashSession;
814
+ }