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,260 @@
1
+ /**
2
+ * Wildcard allow-rules: "stop asking about calls like this one".
3
+ *
4
+ * A rule is a string, so it survives a round trip through `.darwin/config.json`
5
+ * unchanged and stays readable in it:
6
+ *
7
+ * - `bash:pnpm *` — pattern matched against the command, `*` is any run of characters
8
+ * - `fileEditor:src/**` — glob on the path, `**` crosses `/`, `*` does not
9
+ * - `bash` — no colon: every call of that tool. The only shape available for
10
+ * unknown and MCP tools, whose input has no structure we can reason about.
11
+ *
12
+ * The matcher is deliberately conservative in the same way the static risk rules
13
+ * are: anything it cannot reason about does not match, and a non-match only costs
14
+ * a prompt.
15
+ */
16
+ import path from 'node:path';
17
+ import { isSensitiveDarwinPath } from '../paths.js';
18
+ /**
19
+ * Redirection and substitution turn an otherwise recognizable command into a
20
+ * write (`echo x > f`) or hide arbitrary execution (`` `...` ``, `$(...)`). `<`
21
+ * is included because `<(...)` process substitution executes its body.
22
+ */
23
+ const SHELL_METACHARACTERS = /[><`]|\$\(/;
24
+ /** Sensitive file basenames no rule may cover. */
25
+ const ENV_FILE = /^\.env(\..+)?$/;
26
+ /**
27
+ * Commands whose first word is only a dispatcher: `git push` and `git status`
28
+ * have nothing in common, so a rule derived from `git …` alone would be far
29
+ * broader than what the user just approved.
30
+ */
31
+ const SUBCOMMAND_DRIVERS = new Set([
32
+ 'git',
33
+ 'pnpm',
34
+ 'npm',
35
+ 'npx',
36
+ 'yarn',
37
+ 'cargo',
38
+ 'docker',
39
+ 'go',
40
+ 'uv',
41
+ 'pip',
42
+ 'python',
43
+ 'python3',
44
+ 'node',
45
+ 'make',
46
+ 'gh',
47
+ 'kubectl',
48
+ 'aws',
49
+ 'poetry',
50
+ ]);
51
+ /**
52
+ * Longest label the prompt's single-line option row can carry. Kept short on
53
+ * purpose: the row has to survive an 80-column terminal without wrapping, and a
54
+ * wrapped row is one more line of the live frame Ink drops on a short screen.
55
+ */
56
+ const MAX_LABEL_CHARS = 24;
57
+ /** True when the command contains redirection or substitution. */
58
+ export function hasShellMetacharacters(command) {
59
+ return SHELL_METACHARACTERS.test(command);
60
+ }
61
+ /**
62
+ * Splits a command on the chaining operators, so `a && b` is only covered when
63
+ * both halves are. Naive on purpose: a mis-split drops out of the safe path,
64
+ * never into it.
65
+ */
66
+ export function splitBashSegments(command) {
67
+ return command
68
+ .split(/&&|\|\||[;|\n]/)
69
+ .map((segment) => segment.trim())
70
+ .filter((segment) => segment !== '');
71
+ }
72
+ /** A rule split into its parts, or undefined when the string is not a rule. */
73
+ export function parseRule(rule) {
74
+ const colon = rule.indexOf(':');
75
+ if (colon === -1) {
76
+ const toolName = rule.trim();
77
+ return toolName === '' ? undefined : { toolName };
78
+ }
79
+ const toolName = rule.slice(0, colon).trim();
80
+ const pattern = rule.slice(colon + 1).trim();
81
+ if (toolName === '' || pattern === '')
82
+ return undefined;
83
+ return { toolName, pattern };
84
+ }
85
+ /** Whether a config entry is a usable rule. Used to reject typos at load time. */
86
+ export function isValidRule(rule) {
87
+ return parseRule(rule) !== undefined;
88
+ }
89
+ /**
90
+ * The first rule that covers this call, or undefined when none does.
91
+ *
92
+ * Exempt targets (see {@link isRuleExempt}) match nothing, whatever the rules
93
+ * say — a broad rule must not be a path to the agent widening its own
94
+ * permissions.
95
+ */
96
+ export function matchesAnyRule(rules, target, projectRoot) {
97
+ if (isRuleExempt(target, projectRoot))
98
+ return undefined;
99
+ for (const rule of rules) {
100
+ const parsed = parseRule(rule);
101
+ if (parsed === undefined)
102
+ continue;
103
+ if (parsed.toolName !== target.toolName)
104
+ continue;
105
+ // No pattern: the user asked for the whole tool.
106
+ if (parsed.pattern === undefined)
107
+ return rule;
108
+ if (patternCovers(parsed.pattern, target, projectRoot))
109
+ return rule;
110
+ }
111
+ return undefined;
112
+ }
113
+ /**
114
+ * Calls no rule may ever cover: darwin's own config (a rule there lets the agent
115
+ * grant itself more rules) and environment files. Both are also `dangerous`
116
+ * statically, so the effect is that they always ask.
117
+ */
118
+ export function isRuleExempt(target, projectRoot) {
119
+ if (target.toolName === 'memory_save')
120
+ return true;
121
+ if (target.toolName !== 'fileEditor')
122
+ return false;
123
+ const filePath = readString(target.input, 'path');
124
+ if (filePath === undefined)
125
+ return false;
126
+ const resolved = path.resolve(projectRoot, filePath);
127
+ if (ENV_FILE.test(path.basename(resolved)))
128
+ return true;
129
+ return isSensitiveDarwinPath(projectRoot, resolved);
130
+ }
131
+ /**
132
+ * At most two offers, most specific first: one derived from this call, then the
133
+ * whole tool. Empty for an exempt target — offering a rule that could never
134
+ * apply would be a lie told in a security prompt.
135
+ */
136
+ export function suggestRules(target, projectRoot) {
137
+ if (isRuleExempt(target, projectRoot))
138
+ return [];
139
+ const specific = specificSuggestion(target, projectRoot);
140
+ const wholeTool = {
141
+ rule: target.toolName,
142
+ label: clipLabel(`all ${target.toolName}`),
143
+ };
144
+ return specific === undefined ? [wholeTool] : [specific, wholeTool];
145
+ }
146
+ function specificSuggestion(target, projectRoot) {
147
+ if (target.toolName === 'bash') {
148
+ const pattern = bashPattern(readString(target.input, 'command') ?? '');
149
+ return pattern === undefined ? undefined : { rule: `bash:${pattern}`, label: clipLabel(pattern) };
150
+ }
151
+ if (target.toolName === 'fileEditor') {
152
+ const filePath = readString(target.input, 'path');
153
+ if (filePath === undefined)
154
+ return undefined;
155
+ const pattern = directoryPattern(filePath, projectRoot);
156
+ return { rule: `fileEditor:${pattern}`, label: clipLabel(pattern) };
157
+ }
158
+ // Unknown and MCP tools: the input shape is unknown, so the whole tool is the
159
+ // only honest offer.
160
+ return undefined;
161
+ }
162
+ /** `pnpm typecheck --watch` → `pnpm typecheck *`; `rm -rf x` → `rm *`. */
163
+ function bashPattern(command) {
164
+ const words = normalizeSpaces(command).split(' ').filter((word) => word !== '');
165
+ const [first, second] = words;
166
+ if (first === undefined)
167
+ return undefined;
168
+ if (SUBCOMMAND_DRIVERS.has(first) && second !== undefined && !second.startsWith('-')) {
169
+ return `${first} ${second} *`;
170
+ }
171
+ return `${first} *`;
172
+ }
173
+ /** `src/tui/App.tsx` → `src/tui/**`; a project-root file → `**`. */
174
+ function directoryPattern(filePath, projectRoot) {
175
+ const resolved = path.resolve(projectRoot, filePath);
176
+ const relative = path.relative(projectRoot, resolved);
177
+ const inside = relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
178
+ const target = toPosix(inside ? relative : resolved);
179
+ const directory = target.includes('/') ? target.slice(0, target.lastIndexOf('/')) : '';
180
+ return directory === '' ? '**' : `${directory}/**`;
181
+ }
182
+ function patternCovers(pattern, target, projectRoot) {
183
+ if (target.toolName === 'bash') {
184
+ const command = readString(target.input, 'command') ?? '';
185
+ // Same fail-closed reasoning as the static rules: with redirection or
186
+ // substitution in play, the words no longer say what will run.
187
+ if (hasShellMetacharacters(command))
188
+ return false;
189
+ const segments = splitBashSegments(command);
190
+ if (segments.length === 0)
191
+ return false;
192
+ return segments.every((segment) => commandMatches(pattern, segment));
193
+ }
194
+ if (target.toolName === 'fileEditor') {
195
+ const filePath = readString(target.input, 'path');
196
+ if (filePath === undefined)
197
+ return false;
198
+ const resolved = path.resolve(projectRoot, filePath);
199
+ const relative = path.relative(projectRoot, resolved);
200
+ const inside = relative !== '' && !relative.startsWith('..') && !path.isAbsolute(relative);
201
+ return pathMatches(pattern, toPosix(inside ? relative : resolved));
202
+ }
203
+ // A pattern for a tool whose input we cannot read means nothing; only the
204
+ // whole-tool form applies there.
205
+ return false;
206
+ }
207
+ /** `*` is any run of characters. Whitespace is normalized on both sides. */
208
+ function commandMatches(pattern, command) {
209
+ const normalized = normalizeSpaces(pattern);
210
+ // A trailing ` *` reads as "and anything after", which has to include nothing
211
+ // at all: `pnpm typecheck *` must cover a bare `pnpm typecheck`.
212
+ const openEnded = normalized.endsWith(' *');
213
+ const body = openEnded ? normalized.slice(0, -2) : normalized;
214
+ const core = body.split('*').map(escapeRegExp).join('[\\s\\S]*');
215
+ const source = openEnded ? `^${core}(?: [\\s\\S]*)?$` : `^${core}$`;
216
+ return new RegExp(source).test(normalizeSpaces(command));
217
+ }
218
+ /** `**` matches across `/`, `*` and `?` stay within one path segment. */
219
+ function pathMatches(pattern, target) {
220
+ let source = '^';
221
+ for (let index = 0; index < pattern.length; index += 1) {
222
+ const char = pattern[index];
223
+ if (char === '*') {
224
+ if (pattern[index + 1] === '*') {
225
+ source += '.*';
226
+ index += 1;
227
+ }
228
+ else {
229
+ source += '[^/]*';
230
+ }
231
+ }
232
+ else if (char === '?') {
233
+ source += '[^/]';
234
+ }
235
+ else {
236
+ source += escapeRegExp(char ?? '');
237
+ }
238
+ }
239
+ return new RegExp(`${source}$`).test(target);
240
+ }
241
+ function normalizeSpaces(value) {
242
+ return value.trim().replace(/\s+/g, ' ');
243
+ }
244
+ /** Patterns are written with `/`, so Windows separators are folded to it. */
245
+ function toPosix(value) {
246
+ return value.split(path.sep).join('/');
247
+ }
248
+ function escapeRegExp(value) {
249
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
250
+ }
251
+ function clipLabel(label) {
252
+ return label.length <= MAX_LABEL_CHARS ? label : `${label.slice(0, MAX_LABEL_CHARS - 1)}…`;
253
+ }
254
+ function readString(input, key) {
255
+ if (typeof input !== 'object' || input === null || Array.isArray(input))
256
+ return undefined;
257
+ const value = input[key];
258
+ return typeof value === 'string' ? value : undefined;
259
+ }
260
+ //# sourceMappingURL=permission-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-rules.js","sourceRoot":"","sources":["../../../src/agent/permission-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA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IAAI,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,GAAG,CAAC;AAC7F,CAAC;AAED,SAAS,UAAU,CAAC,KAAc,EAAE,GAAW;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,MAAM,KAAK,GAAI,KAAiC,CAAC,GAAG,CAAC,CAAC;IACtD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
@@ -0,0 +1,361 @@
1
+ import { InterventionHandler } from '@strands-agents/sdk';
2
+ import type { BeforeToolCallEvent } from '@strands-agents/sdk';
3
+ import { type RuleSuggestion } from './permission-rules.js';
4
+ /**
5
+ * The `InterventionAction` union is not re-exported from the package root and
6
+ * `./interventions` has no subpath export, so derive it from the base class.
7
+ */
8
+ type InterventionAction = Awaited<ReturnType<InterventionHandler['beforeToolCall']>>;
9
+ /** How a tool call is classified. `read` calls run without asking. */
10
+ export type PermissionKind = 'read' | 'write' | 'execute';
11
+ /**
12
+ * How much confirmation the gate demands.
13
+ *
14
+ * - `default`: statically safe calls run silently; everything else asks.
15
+ * - `auto`: like `default`, but calls the static rules cannot clear are judged
16
+ * by a model classifier first; only classifier-flagged calls ask.
17
+ * - `plan`: reads run; writes and executes are denied without escalation.
18
+ * - `yolo`: everything runs without asking.
19
+ */
20
+ export type ApprovalMode = 'default' | 'auto' | 'plan' | 'yolo';
21
+ export declare const APPROVAL_MODES: readonly ["default", "auto", "plan", "yolo"];
22
+ export declare function isApprovalMode(value: unknown): value is ApprovalMode;
23
+ /**
24
+ * One clause per mode, for a notice that has to say what the mode the user just
25
+ * typed actually does. The header words the same three states itself, because it
26
+ * has one row to spend and a notice does not.
27
+ */
28
+ export declare function describeApprovalMode(mode: ApprovalMode): string;
29
+ /**
30
+ * Whether a call is *provably* safe. `dangerous` means "not on the safe list",
31
+ * not "known harmful": the rules only whitelist, so a parsing miss can cost an
32
+ * extra prompt but never a silent approval.
33
+ */
34
+ export type PermissionRisk = 'safe' | 'dangerous';
35
+ export interface RiskAssessment {
36
+ risk: PermissionRisk;
37
+ /** Human-readable, shown in the confirmation prompt. */
38
+ riskReason: string;
39
+ }
40
+ /**
41
+ * What the UI needs to render a confirmation. `summary` is a one-line headline;
42
+ * `details` holds the parts worth showing in full (a command, or a file path
43
+ * plus the replacement text).
44
+ */
45
+ export interface PermissionRequest {
46
+ toolName: string;
47
+ kind: PermissionKind;
48
+ /** Single-line description, e.g. `bash: pnpm typecheck`. */
49
+ summary: string;
50
+ /** Labelled blocks for multi-line rendering, in display order. */
51
+ details: PermissionDetail[];
52
+ /** Raw tool input, for a UI that wants to show or diff it itself. */
53
+ input: unknown;
54
+ }
55
+ export interface PermissionDetail {
56
+ label: string;
57
+ value: string;
58
+ /**
59
+ * Marks a block whose value is raw edit content (`file_text`, `old_str`,
60
+ * `new_str`). A presenting UI may substitute exactly these blocks with a line
61
+ * diff computed from `PermissionRequest.input` — the same strings, one
62
+ * projection — and must keep every unmarked block stated. Renderers that do
63
+ * not diff (dev-repl) ignore the flag and keep the raw blocks.
64
+ */
65
+ editContent?: boolean;
66
+ }
67
+ /**
68
+ * Which agent a request came from.
69
+ *
70
+ * Parent and every child share one gate instance (that is what keeps allow-rules
71
+ * and the live bridge coherent), and children run concurrently — so without this
72
+ * a prompt cannot say whose work it is about. `label` is bounded and ready to
73
+ * render: a permission box shares the live frame with the header, so provenance
74
+ * has to ride an existing line rather than earn one.
75
+ */
76
+ export interface PermissionSource {
77
+ /** `parent` is the one assembled agent; `child` is a tracked dispatch. */
78
+ kind: 'parent' | 'child';
79
+ /** `parent`, or `<agent>#<dispatchId>`. */
80
+ label: string;
81
+ /** Child only: which dispatch asked. */
82
+ dispatchId?: string;
83
+ /** Child only: the dispatched definition name. */
84
+ agentName?: string;
85
+ /**
86
+ * Child only, `workflow` nodes that declared them (SER-065): normalized
87
+ * project-relative path prefixes this child may write under. The gate denies a
88
+ * `fileEditor` write outside every entry before any other step; absent means
89
+ * the child is judged exactly like an unscoped one.
90
+ */
91
+ writeScopes?: readonly string[];
92
+ }
93
+ /**
94
+ * The one source every non-delegated call carries. Frozen because it is shared by
95
+ * every parent request: a consumer that mutated it would relabel all of them.
96
+ */
97
+ export declare const PARENT_PERMISSION_SOURCE: PermissionSource;
98
+ /**
99
+ * Resolves a child `Agent.id` to its dispatch, or `undefined` when the id is not
100
+ * a tracked dispatch — which in darwin means the parent, because the runtime
101
+ * builds exactly one `Agent` plus the children the dispatch registry records.
102
+ *
103
+ * Deliberately a narrow function rather than the registry type: the permission
104
+ * layer must not depend on the delegation tool to know who is asking.
105
+ */
106
+ export type DispatchSourceResolver = (agentId: string) => {
107
+ dispatchId: string;
108
+ agentName: string;
109
+ label: string;
110
+ writeScopes?: readonly string[];
111
+ } | undefined;
112
+ /**
113
+ * A {@link PermissionRequest} with its risk assessment, its origin, and the
114
+ * "always allow" offers derived from it — what bridges see.
115
+ */
116
+ export interface AssessedPermissionRequest extends PermissionRequest, RiskAssessment {
117
+ /** Which agent this call belongs to. Always present, parent calls included. */
118
+ source: PermissionSource;
119
+ /** Stable across mode-change re-decisions of this one logical tool call. */
120
+ promptIdentity?: object;
121
+ /**
122
+ * Wildcard rules the user may accept alongside this one call, most specific
123
+ * first. Empty when no rule could ever cover the call.
124
+ */
125
+ suggestions: readonly RuleSuggestion[];
126
+ /**
127
+ * Aborts when the user changes the permission mode while this request is
128
+ * pending — the one case where the question on screen was asked under a policy
129
+ * that is no longer in force.
130
+ *
131
+ * A bridge that shows a prompt **must** drop it when this fires: the gate has
132
+ * stopped waiting and will re-decide the whole call under the new mode, so an
133
+ * answer arriving afterwards is discarded rather than applied. A bridge that
134
+ * ignores the signal is not unsafe (the answer is still discarded), it merely
135
+ * leaves a stale question on screen.
136
+ */
137
+ withdrawn: AbortSignal;
138
+ }
139
+ /**
140
+ * A signal that never aborts, for the bridges and fixtures that construct a
141
+ * request themselves. Frozen into one instance on purpose: an
142
+ * {@link AbortController} per fixture would suggest withdrawal is in play there.
143
+ */
144
+ export declare const NEVER_WITHDRAWN: AbortSignal;
145
+ /** What the human answered: allow or not, and any rule to remember. */
146
+ export interface PermissionDecision {
147
+ allowed: boolean;
148
+ /**
149
+ * A rule from `request.suggestions` the user chose. The gate applies it to the
150
+ * rest of the session; persisting it is the caller's business, so a failed
151
+ * write costs the file, not the session.
152
+ */
153
+ rule?: string;
154
+ }
155
+ /**
156
+ * Asks the human to approve one tool call.
157
+ *
158
+ * Implementations may block for as long as they need — the SDK awaits
159
+ * intervention callbacks serially, so the agent loop waits.
160
+ */
161
+ export type PermissionBridge = (request: AssessedPermissionRequest) => Promise<PermissionDecision>;
162
+ /** Approves everything without asking. For non-interactive runs and tests. */
163
+ export declare const allowAllBridge: PermissionBridge;
164
+ /** The classifier's judgement of one call, in `auto` mode. */
165
+ export interface SafetyVerdict {
166
+ safe: boolean;
167
+ reason: string;
168
+ }
169
+ /**
170
+ * Judges a call the static rules could not clear. May call a model; the gate
171
+ * bounds it with a timeout and treats any failure as "not safe".
172
+ */
173
+ export type SafetyClassifier = (request: AssessedPermissionRequest) => Promise<SafetyVerdict>;
174
+ export interface PermissionGateOptions {
175
+ /** Where enforcement starts. `PermissionGate.setMode` moves it, user-only. */
176
+ mode: ApprovalMode;
177
+ /** Root the static path-containment rules resolve against. */
178
+ projectRoot: string;
179
+ ask: PermissionBridge;
180
+ /** Wildcard allow-rules from the config; see `./permission-rules.ts`. */
181
+ allowRules?: readonly string[];
182
+ /** Consulted for dangerous calls in `auto` mode; ignored otherwise. */
183
+ classifier?: SafetyClassifier;
184
+ /** How long `auto` waits for the classifier before falling back to asking. */
185
+ classifierTimeoutMs?: number;
186
+ /**
187
+ * Labels a call with the child dispatch it came from. Omitted means every call
188
+ * reads as the parent's, which is only true for a runtime with no delegation.
189
+ */
190
+ dispatchSource?: DispatchSourceResolver;
191
+ }
192
+ /**
193
+ * Where a live allow-rule came from. `configured` means it was loaded from the
194
+ * project's `permission-rules.json` at startup; `session` means the user granted
195
+ * it in a confirmation prompt during this session. A configured rule that is
196
+ * revoked and later re-granted reads as `session`, because that is when the
197
+ * authority it carries was actually given.
198
+ */
199
+ export type AllowRuleOrigin = 'configured' | 'session';
200
+ /** One live allow-rule with its provenance, for the `/permissions` report. */
201
+ export interface AllowRuleEntry {
202
+ rule: string;
203
+ origin: AllowRuleOrigin;
204
+ }
205
+ /** What a mode change did, for the notice that reports it. */
206
+ export interface PermissionModeChange {
207
+ /** The mode now in force. */
208
+ mode: ApprovalMode;
209
+ previous: ApprovalMode;
210
+ /**
211
+ * Pending tool decisions withdrawn by the change — a classifier call in flight
212
+ * or a prompt waiting for an answer. Each is re-decided from the top under
213
+ * {@link mode}; none is resolved under {@link previous}.
214
+ */
215
+ withdrawn: number;
216
+ }
217
+ export declare class PermissionGate extends InterventionHandler {
218
+ private readonly options;
219
+ readonly name = "darwin:permission-gate";
220
+ /** Config rules plus anything the user accepted during this session. */
221
+ private readonly rules;
222
+ /**
223
+ * Provenance of every rule in {@link rules}, keyed by the rule string. Kept as
224
+ * a side table rather than widening `rules` because the decision path
225
+ * (`matchesAnyRule`) reads the plain strings and must stay unchanged.
226
+ */
227
+ private readonly ruleOrigins;
228
+ /**
229
+ * Live enforcement policy, not `options.mode`: `/mode` moves it mid-session and
230
+ * every decision — parent and child, since they share this instance — reads it
231
+ * from here.
232
+ */
233
+ private currentMode;
234
+ /**
235
+ * One controller per in-flight decision that is waiting on something external
236
+ * (a classifier verdict, or the user's answer). {@link setMode} aborts them all.
237
+ */
238
+ private readonly waiting;
239
+ constructor(options: PermissionGateOptions);
240
+ /** The mode enforcing right now. */
241
+ get mode(): ApprovalMode;
242
+ /**
243
+ * Switches the mode for the rest of the session. **User-only**: nothing the
244
+ * model can emit reaches this — no tool mutates the gate, the value is never
245
+ * read back from a file after startup, and the two callers (the TUI's submit
246
+ * handler and the dev REPL's input loop) are fed by the keyboard alone.
247
+ *
248
+ * Every decision still pending is *withdrawn* rather than resolved: a
249
+ * classifier verdict answers a question only `auto` asks, and a prompt on screen
250
+ * was worded under the previous policy. The gate re-decides each of those calls
251
+ * from the top under the new mode, so no call is ever half-judged by two modes.
252
+ * One rule for every transition on purpose — the alternative is a table of which
253
+ * transitions are benign, and that table is where the bug would live.
254
+ *
255
+ * Deliberately not persisted: this changes *enforcement*, and a widening that
256
+ * outlives the session is exactly what the allow-rule exemptions exist to
257
+ * prevent (`./permission-rules.ts`).
258
+ */
259
+ setMode(next: ApprovalMode): PermissionModeChange;
260
+ /**
261
+ * Starts honouring a rule immediately. Separate from persistence on purpose: a
262
+ * rule the user just accepted must hold for the rest of the session even if
263
+ * writing it to the config fails.
264
+ */
265
+ addAllowRule(rule: string): void;
266
+ /**
267
+ * Stops honouring a rule immediately: the very next matching call goes back
268
+ * through the ordinary decision path and prompts. Removal-only by construction
269
+ * — this is the narrowing half of the rule lifecycle, and there is nothing it
270
+ * can add. Returns whether the rule was live, so the caller can refuse to
271
+ * "revoke" (and persist the removal of) a rule that was never in force.
272
+ */
273
+ removeAllowRule(rule: string): boolean;
274
+ /** Rules currently in effect, config and session alike. */
275
+ get allowRules(): readonly string[];
276
+ /**
277
+ * The live rules with their provenance, in the order they are consulted.
278
+ * A fresh array per call: the report must not hand out a mutable window onto
279
+ * the enforcement surface.
280
+ */
281
+ listAllowRules(): AllowRuleEntry[];
282
+ /**
283
+ * Denies plan-mode mutation before hooks, rules, classifiers, or prompts can
284
+ * have side effects. Undefined means the ordinary permission flow still owns
285
+ * the call; callers must not treat it as approval.
286
+ *
287
+ * Reads the live mode, so entering plan mid-session guards the very next call
288
+ * and leaving it stops guarding immediately.
289
+ */
290
+ planGuard(toolName: string, input: unknown): InterventionAction | undefined;
291
+ /**
292
+ * Decides one call, restarting whenever the user changes the mode underneath it.
293
+ *
294
+ * The loop is the whole in-flight contract: a withdrawn decision is discarded,
295
+ * never applied, and the call is judged again from the top — plan guard first —
296
+ * by whatever mode is in force now.
297
+ */
298
+ beforeToolCall(event: BeforeToolCallEvent): Promise<InterventionAction>;
299
+ /**
300
+ * One pass of the decision, under the mode in force when it started.
301
+ *
302
+ * Returns {@link WITHDRAWN} instead of a decision when the mode changed while
303
+ * this pass was waiting on the classifier or on the user — including the case
304
+ * where the answer and the change land in the same tick, which is why the race
305
+ * re-checks `aborted` after the promise settles.
306
+ */
307
+ private decideOnce;
308
+ /**
309
+ * Who is asking. A tracked dispatch resolves to its child label; anything else
310
+ * is the parent, because the runtime assembles exactly one `Agent` and every
311
+ * other agent in the process is a dispatch this resolver knows about.
312
+ */
313
+ private sourceOf;
314
+ /**
315
+ * Denies a scoped `workflow` node's `fileEditor` write that lands outside every
316
+ * declared scope. Undefined means the ordinary flow owns the call — including
317
+ * every parent call, every `subagent` dispatch, every unscoped node, `view`, and
318
+ * every other tool (bash is deliberately not covered: a command's write set is
319
+ * not statically knowable, and the description says so).
320
+ */
321
+ private writeScopeGuard;
322
+ /**
323
+ * Runs the classifier with a hard timeout. Every failure mode — missing
324
+ * classifier, throw, timeout, or a hung promise — collapses to "not safe", so
325
+ * degradation always lands on asking the user, never on silent approval.
326
+ */
327
+ private classifierVerdict;
328
+ }
329
+ /**
330
+ * Maps a tool call to a permission decision and a renderable summary.
331
+ *
332
+ * Classification is `(toolName, input)`, not name alone: `fileEditor` is a single
333
+ * tool whose `command` spans reading and writing, so the name by itself cannot
334
+ * tell them apart.
335
+ *
336
+ * Unknown tools (including everything from MCP servers) default to `execute`,
337
+ * so a new tool is gated until someone classifies it deliberately.
338
+ */
339
+ export declare function classify(toolName: string, rawInput: unknown): PermissionRequest;
340
+ /**
341
+ * The static safety rules shared by `default` and `auto`. Whitelist only: a
342
+ * call is `safe` when the rules can *prove* it harmless, `dangerous` otherwise
343
+ * — including every unknown and MCP tool.
344
+ */
345
+ export declare function assessRisk(request: PermissionRequest, projectRoot: string): RiskAssessment;
346
+ /**
347
+ * Whether one `fileEditor` write falls outside every declared scope (SER-065).
348
+ *
349
+ * Judged by `(toolName, input)` like the rest of the gate. `scopes` are the
350
+ * normalized project-relative prefixes `workflow` validated (no leading `./`,
351
+ * no trailing `/`, no `..`, never `.`); containment is by path segment, so
352
+ * `src/tui` covers `src/tui/App.tsx` but not `src/tuix`. The request path is
353
+ * resolved against `projectRoot` (absolute or relative), and one that escapes
354
+ * the project is outside every scope by construction. Any other tool, any other
355
+ * command, an unscoped caller — `undefined`, and the ordinary flow owns the call.
356
+ */
357
+ export declare function writeScopeViolation(toolName: string, rawInput: unknown, scopes: readonly string[], projectRoot: string): {
358
+ command: string;
359
+ path: string;
360
+ } | undefined;
361
+ export {};