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.
- package/README.md +140 -0
- package/README.zh-CN.md +140 -0
- package/dist/patches/@strands-agents+sdk+1.16.0.patch +1443 -0
- package/dist/src/agent/background-delegation.d.ts +67 -0
- package/dist/src/agent/background-delegation.js +159 -0
- package/dist/src/agent/background-delegation.js.map +1 -0
- package/dist/src/agent/call-stats.d.ts +118 -0
- package/dist/src/agent/call-stats.js +128 -0
- package/dist/src/agent/call-stats.js.map +1 -0
- package/dist/src/agent/compact.d.ts +108 -0
- package/dist/src/agent/compact.js +192 -0
- package/dist/src/agent/compact.js.map +1 -0
- package/dist/src/agent/context-anchor.d.ts +64 -0
- package/dist/src/agent/context-anchor.js +43 -0
- package/dist/src/agent/context-anchor.js.map +1 -0
- package/dist/src/agent/cost.d.ts +56 -0
- package/dist/src/agent/cost.js +44 -0
- package/dist/src/agent/cost.js.map +1 -0
- package/dist/src/agent/diagnostics.d.ts +212 -0
- package/dist/src/agent/diagnostics.js +374 -0
- package/dist/src/agent/diagnostics.js.map +1 -0
- package/dist/src/agent/instructions.d.ts +54 -0
- package/dist/src/agent/instructions.js +118 -0
- package/dist/src/agent/instructions.js.map +1 -0
- package/dist/src/agent/max-tokens-recovery.d.ts +17 -0
- package/dist/src/agent/max-tokens-recovery.js +65 -0
- package/dist/src/agent/max-tokens-recovery.js.map +1 -0
- package/dist/src/agent/model-call-budget.d.ts +8 -0
- package/dist/src/agent/model-call-budget.js +24 -0
- package/dist/src/agent/model-call-budget.js.map +1 -0
- package/dist/src/agent/model-retry.d.ts +134 -0
- package/dist/src/agent/model-retry.js +256 -0
- package/dist/src/agent/model-retry.js.map +1 -0
- package/dist/src/agent/permission-rules.d.ts +47 -0
- package/dist/src/agent/permission-rules.js +260 -0
- package/dist/src/agent/permission-rules.js.map +1 -0
- package/dist/src/agent/permission.d.ts +361 -0
- package/dist/src/agent/permission.js +797 -0
- package/dist/src/agent/permission.js.map +1 -0
- package/dist/src/agent/prompt-cache.d.ts +66 -0
- package/dist/src/agent/prompt-cache.js +194 -0
- package/dist/src/agent/prompt-cache.js.map +1 -0
- package/dist/src/agent/refusal.d.ts +20 -0
- package/dist/src/agent/refusal.js +23 -0
- package/dist/src/agent/refusal.js.map +1 -0
- package/dist/src/agent/retry-guard.d.ts +26 -0
- package/dist/src/agent/retry-guard.js +193 -0
- package/dist/src/agent/retry-guard.js.map +1 -0
- package/dist/src/agent/rewind.d.ts +29 -0
- package/dist/src/agent/rewind.js +118 -0
- package/dist/src/agent/rewind.js.map +1 -0
- package/dist/src/agent/runtime.d.ts +814 -0
- package/dist/src/agent/runtime.js +1596 -0
- package/dist/src/agent/runtime.js.map +1 -0
- package/dist/src/agent/safety-classifier.d.ts +11 -0
- package/dist/src/agent/safety-classifier.js +0 -0
- package/dist/src/agent/safety-classifier.js.map +1 -0
- package/dist/src/agent/sdk-logging.d.ts +49 -0
- package/dist/src/agent/sdk-logging.js +110 -0
- package/dist/src/agent/sdk-logging.js.map +1 -0
- package/dist/src/agent/session.d.ts +102 -0
- package/dist/src/agent/session.js +244 -0
- package/dist/src/agent/session.js.map +1 -0
- package/dist/src/agent/stream-resumption.d.ts +16 -0
- package/dist/src/agent/stream-resumption.js +33 -0
- package/dist/src/agent/stream-resumption.js.map +1 -0
- package/dist/src/agent/system-prompt.d.ts +50 -0
- package/dist/src/agent/system-prompt.js +161 -0
- package/dist/src/agent/system-prompt.js.map +1 -0
- package/dist/src/agent/thinking.d.ts +99 -0
- package/dist/src/agent/thinking.js +145 -0
- package/dist/src/agent/thinking.js.map +1 -0
- package/dist/src/agent/usage.d.ts +132 -0
- package/dist/src/agent/usage.js +233 -0
- package/dist/src/agent/usage.js.map +1 -0
- package/dist/src/agent/working-context.d.ts +51 -0
- package/dist/src/agent/working-context.js +160 -0
- package/dist/src/agent/working-context.js.map +1 -0
- package/dist/src/agents/child-recipe.d.ts +33 -0
- package/dist/src/agents/child-recipe.js +98 -0
- package/dist/src/agents/child-recipe.js.map +1 -0
- package/dist/src/agents/concurrency-limit.d.ts +25 -0
- package/dist/src/agents/concurrency-limit.js +43 -0
- package/dist/src/agents/concurrency-limit.js.map +1 -0
- package/dist/src/agents/dispatch-registry.d.ts +180 -0
- package/dist/src/agents/dispatch-registry.js +289 -0
- package/dist/src/agents/dispatch-registry.js.map +1 -0
- package/dist/src/agents/failed-child-text.d.ts +44 -0
- package/dist/src/agents/failed-child-text.js +69 -0
- package/dist/src/agents/failed-child-text.js.map +1 -0
- package/dist/src/agents/loader.d.ts +26 -0
- package/dist/src/agents/loader.js +134 -0
- package/dist/src/agents/loader.js.map +1 -0
- package/dist/src/agents/report-projection.d.ts +31 -0
- package/dist/src/agents/report-projection.js +125 -0
- package/dist/src/agents/report-projection.js.map +1 -0
- package/dist/src/agents/subagent-tool.d.ts +61 -0
- package/dist/src/agents/subagent-tool.js +180 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/agents/workflow-tool.d.ts +85 -0
- package/dist/src/agents/workflow-tool.js +530 -0
- package/dist/src/agents/workflow-tool.js.map +1 -0
- package/dist/src/cli-args.d.ts +39 -0
- package/dist/src/cli-args.js +198 -0
- package/dist/src/cli-args.js.map +1 -0
- package/dist/src/cli-doctor.d.ts +26 -0
- package/dist/src/cli-doctor.js +398 -0
- package/dist/src/cli-doctor.js.map +1 -0
- package/dist/src/cli-main.d.ts +1 -0
- package/dist/src/cli-main.js +279 -0
- package/dist/src/cli-main.js.map +1 -0
- package/dist/src/cli-sessions.d.ts +17 -0
- package/dist/src/cli-sessions.js +136 -0
- package/dist/src/cli-sessions.js.map +1 -0
- package/dist/src/cli-trajectory.d.ts +37 -0
- package/dist/src/cli-trajectory.js +303 -0
- package/dist/src/cli-trajectory.js.map +1 -0
- package/dist/src/cli-usage.d.ts +18 -0
- package/dist/src/cli-usage.js +53 -0
- package/dist/src/cli-usage.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +29 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/custom-commands.d.ts +43 -0
- package/dist/src/commands/custom-commands.js +155 -0
- package/dist/src/commands/custom-commands.js.map +1 -0
- package/dist/src/commands/workflow-command.d.ts +26 -0
- package/dist/src/commands/workflow-command.js +56 -0
- package/dist/src/commands/workflow-command.js.map +1 -0
- package/dist/src/config.d.ts +463 -0
- package/dist/src/config.js +1457 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/context-overflow-error.d.ts +7 -0
- package/dist/src/context-overflow-error.js +26 -0
- package/dist/src/context-overflow-error.js.map +1 -0
- package/dist/src/dev-repl.d.ts +1 -0
- package/dist/src/dev-repl.js +365 -0
- package/dist/src/dev-repl.js.map +1 -0
- package/dist/src/headless-protocol.d.ts +147 -0
- package/dist/src/headless-protocol.js +359 -0
- package/dist/src/headless-protocol.js.map +1 -0
- package/dist/src/headless-runner.d.ts +30 -0
- package/dist/src/headless-runner.js +405 -0
- package/dist/src/headless-runner.js.map +1 -0
- package/dist/src/headless-stdin.d.ts +28 -0
- package/dist/src/headless-stdin.js +78 -0
- package/dist/src/headless-stdin.js.map +1 -0
- package/dist/src/headless.d.ts +106 -0
- package/dist/src/headless.js +229 -0
- package/dist/src/headless.js.map +1 -0
- package/dist/src/hooks/codex-hook-runner.d.ts +92 -0
- package/dist/src/hooks/codex-hook-runner.js +446 -0
- package/dist/src/hooks/codex-hook-runner.js.map +1 -0
- package/dist/src/hooks/codex-hooks.d.ts +23 -0
- package/dist/src/hooks/codex-hooks.js +152 -0
- package/dist/src/hooks/codex-hooks.js.map +1 -0
- package/dist/src/hooks/hook-process.d.ts +23 -0
- package/dist/src/hooks/hook-process.js +241 -0
- package/dist/src/hooks/hook-process.js.map +1 -0
- package/dist/src/hooks/lifecycle-hooks.d.ts +37 -0
- package/dist/src/hooks/lifecycle-hooks.js +153 -0
- package/dist/src/hooks/lifecycle-hooks.js.map +1 -0
- package/dist/src/hooks/tool-hooks.d.ts +63 -0
- package/dist/src/hooks/tool-hooks.js +350 -0
- package/dist/src/hooks/tool-hooks.js.map +1 -0
- package/dist/src/mcp/codegraph-preflight.d.ts +29 -0
- package/dist/src/mcp/codegraph-preflight.js +232 -0
- package/dist/src/mcp/codegraph-preflight.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +133 -0
- package/dist/src/mcp/registry.js +209 -0
- package/dist/src/mcp/registry.js.map +1 -0
- package/dist/src/mcp/web-search-empty-results.d.ts +14 -0
- package/dist/src/mcp/web-search-empty-results.js +94 -0
- package/dist/src/mcp/web-search-empty-results.js.map +1 -0
- package/dist/src/memory/command.d.ts +11 -0
- package/dist/src/memory/command.js +253 -0
- package/dist/src/memory/command.js.map +1 -0
- package/dist/src/memory/controller.d.ts +51 -0
- package/dist/src/memory/controller.js +316 -0
- package/dist/src/memory/controller.js.map +1 -0
- package/dist/src/memory/prompt.d.ts +4 -0
- package/dist/src/memory/prompt.js +22 -0
- package/dist/src/memory/prompt.js.map +1 -0
- package/dist/src/memory/scheduler.d.ts +33 -0
- package/dist/src/memory/scheduler.js +134 -0
- package/dist/src/memory/scheduler.js.map +1 -0
- package/dist/src/memory/state.d.ts +112 -0
- package/dist/src/memory/state.js +355 -0
- package/dist/src/memory/state.js.map +1 -0
- package/dist/src/memory/store.d.ts +19 -0
- package/dist/src/memory/store.js +130 -0
- package/dist/src/memory/store.js.map +1 -0
- package/dist/src/memory/tools.d.ts +29 -0
- package/dist/src/memory/tools.js +22 -0
- package/dist/src/memory/tools.js.map +1 -0
- package/dist/src/memory/validation.d.ts +33 -0
- package/dist/src/memory/validation.js +159 -0
- package/dist/src/memory/validation.js.map +1 -0
- package/dist/src/npm-package/generate-patch.d.ts +23 -0
- package/dist/src/npm-package/generate-patch.js +88 -0
- package/dist/src/npm-package/generate-patch.js.map +1 -0
- package/dist/src/npm-package/patch-package-format.d.ts +43 -0
- package/dist/src/npm-package/patch-package-format.js +66 -0
- package/dist/src/npm-package/patch-package-format.js.map +1 -0
- package/dist/src/paths.d.ts +39 -0
- package/dist/src/paths.js +105 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/pricing/cost.d.ts +182 -0
- package/dist/src/pricing/cost.js +215 -0
- package/dist/src/pricing/cost.js.map +1 -0
- package/dist/src/pricing/model-prices.d.ts +112 -0
- package/dist/src/pricing/model-prices.js +320 -0
- package/dist/src/pricing/model-prices.js.map +1 -0
- package/dist/src/sdk-patch-preflight.d.ts +23 -0
- package/dist/src/sdk-patch-preflight.js +71 -0
- package/dist/src/sdk-patch-preflight.js.map +1 -0
- package/dist/src/skills/builtin/commit-message/SKILL.md +45 -0
- package/dist/src/skills/builtin/commit-message/references/types.md +8 -0
- package/dist/src/skills/builtin/developer/SKILL.md +107 -0
- package/dist/src/skills/builtin/self-evolution-research/SKILL.md +150 -0
- package/dist/src/skills/builtin/self-evolution-research/scripts/roll-research-path.mjs +208 -0
- package/dist/src/skills/builtin/self-reflection/SKILL.md +172 -0
- package/dist/src/skills/builtin/self-reflection/references/reflection-template.md +90 -0
- package/dist/src/skills/builtin/self-reflection/scripts/locate-trajectory.mjs +175 -0
- package/dist/src/skills/loader.d.ts +26 -0
- package/dist/src/skills/loader.js +186 -0
- package/dist/src/skills/loader.js.map +1 -0
- package/dist/src/skills/plugin.d.ts +34 -0
- package/dist/src/skills/plugin.js +137 -0
- package/dist/src/skills/plugin.js.map +1 -0
- package/dist/src/skills/prompt.d.ts +8 -0
- package/dist/src/skills/prompt.js +214 -0
- package/dist/src/skills/prompt.js.map +1 -0
- package/dist/src/skills/resource-safety.d.ts +15 -0
- package/dist/src/skills/resource-safety.js +149 -0
- package/dist/src/skills/resource-safety.js.map +1 -0
- package/dist/src/tools/background-bash.d.ts +95 -0
- package/dist/src/tools/background-bash.js +639 -0
- package/dist/src/tools/background-bash.js.map +1 -0
- package/dist/src/tools/background-tail.d.ts +28 -0
- package/dist/src/tools/background-tail.js +75 -0
- package/dist/src/tools/background-tail.js.map +1 -0
- package/dist/src/tools/background-wait-contract.d.ts +4 -0
- package/dist/src/tools/background-wait-contract.js +7 -0
- package/dist/src/tools/background-wait-contract.js.map +1 -0
- package/dist/src/tools/file-editor-serial.d.ts +24 -0
- package/dist/src/tools/file-editor-serial.js +99 -0
- package/dist/src/tools/file-editor-serial.js.map +1 -0
- package/dist/src/tools/image-viewer.d.ts +43 -0
- package/dist/src/tools/image-viewer.js +256 -0
- package/dist/src/tools/image-viewer.js.map +1 -0
- package/dist/src/tools/update-plan.d.ts +30 -0
- package/dist/src/tools/update-plan.js +65 -0
- package/dist/src/tools/update-plan.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +70 -0
- package/dist/src/tools/web-fetch.js +667 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/trajectory/export.d.ts +31 -0
- package/dist/src/trajectory/export.js +116 -0
- package/dist/src/trajectory/export.js.map +1 -0
- package/dist/src/trajectory/fork.d.ts +19 -0
- package/dist/src/trajectory/fork.js +110 -0
- package/dist/src/trajectory/fork.js.map +1 -0
- package/dist/src/trajectory/memory-tool.d.ts +20 -0
- package/dist/src/trajectory/memory-tool.js +98 -0
- package/dist/src/trajectory/memory-tool.js.map +1 -0
- package/dist/src/trajectory/prompt-history.d.ts +62 -0
- package/dist/src/trajectory/prompt-history.js +256 -0
- package/dist/src/trajectory/prompt-history.js.map +1 -0
- package/dist/src/trajectory/reader.d.ts +21 -0
- package/dist/src/trajectory/reader.js +62 -0
- package/dist/src/trajectory/reader.js.map +1 -0
- package/dist/src/trajectory/record.d.ts +417 -0
- package/dist/src/trajectory/record.js +394 -0
- package/dist/src/trajectory/record.js.map +1 -0
- package/dist/src/trajectory/replay.d.ts +74 -0
- package/dist/src/trajectory/replay.js +285 -0
- package/dist/src/trajectory/replay.js.map +1 -0
- package/dist/src/trajectory/resume-recap.d.ts +43 -0
- package/dist/src/trajectory/resume-recap.js +68 -0
- package/dist/src/trajectory/resume-recap.js.map +1 -0
- package/dist/src/trajectory/search.d.ts +40 -0
- package/dist/src/trajectory/search.js +127 -0
- package/dist/src/trajectory/search.js.map +1 -0
- package/dist/src/trajectory/spend.d.ts +157 -0
- package/dist/src/trajectory/spend.js +264 -0
- package/dist/src/trajectory/spend.js.map +1 -0
- package/dist/src/trajectory/stream.d.ts +30 -0
- package/dist/src/trajectory/stream.js +30 -0
- package/dist/src/trajectory/stream.js.map +1 -0
- package/dist/src/trajectory/writer.d.ts +310 -0
- package/dist/src/trajectory/writer.js +636 -0
- package/dist/src/trajectory/writer.js.map +1 -0
- package/dist/src/tui/App.d.ts +109 -0
- package/dist/src/tui/App.js +2660 -0
- package/dist/src/tui/App.js.map +1 -0
- package/dist/src/tui/InputBox.d.ts +90 -0
- package/dist/src/tui/InputBox.js +129 -0
- package/dist/src/tui/InputBox.js.map +1 -0
- package/dist/src/tui/MarkdownText.d.ts +16 -0
- package/dist/src/tui/MarkdownText.js +117 -0
- package/dist/src/tui/MarkdownText.js.map +1 -0
- package/dist/src/tui/MessageList.d.ts +27 -0
- package/dist/src/tui/MessageList.js +61 -0
- package/dist/src/tui/MessageList.js.map +1 -0
- package/dist/src/tui/PermissionPrompt.d.ts +18 -0
- package/dist/src/tui/PermissionPrompt.js +114 -0
- package/dist/src/tui/PermissionPrompt.js.map +1 -0
- package/dist/src/tui/PlanChecklist.d.ts +7 -0
- package/dist/src/tui/PlanChecklist.js +12 -0
- package/dist/src/tui/PlanChecklist.js.map +1 -0
- package/dist/src/tui/QueuedMessages.d.ts +8 -0
- package/dist/src/tui/QueuedMessages.js +24 -0
- package/dist/src/tui/QueuedMessages.js.map +1 -0
- package/dist/src/tui/StartupScreen.d.ts +25 -0
- package/dist/src/tui/StartupScreen.js +51 -0
- package/dist/src/tui/StartupScreen.js.map +1 -0
- package/dist/src/tui/ToolCallPanel.d.ts +33 -0
- package/dist/src/tui/ToolCallPanel.js +112 -0
- package/dist/src/tui/ToolCallPanel.js.map +1 -0
- package/dist/src/tui/WelcomeHeader.d.ts +30 -0
- package/dist/src/tui/WelcomeHeader.js +69 -0
- package/dist/src/tui/WelcomeHeader.js.map +1 -0
- package/dist/src/tui/background-tool-presentation.d.ts +22 -0
- package/dist/src/tui/background-tool-presentation.js +209 -0
- package/dist/src/tui/background-tool-presentation.js.map +1 -0
- package/dist/src/tui/busy-suffix.d.ts +37 -0
- package/dist/src/tui/busy-suffix.js +39 -0
- package/dist/src/tui/busy-suffix.js.map +1 -0
- package/dist/src/tui/clipboard-image.d.ts +18 -0
- package/dist/src/tui/clipboard-image.js +109 -0
- package/dist/src/tui/clipboard-image.js.map +1 -0
- package/dist/src/tui/context-format.d.ts +43 -0
- package/dist/src/tui/context-format.js +71 -0
- package/dist/src/tui/context-format.js.map +1 -0
- package/dist/src/tui/copy-command.d.ts +68 -0
- package/dist/src/tui/copy-command.js +182 -0
- package/dist/src/tui/copy-command.js.map +1 -0
- package/dist/src/tui/edit-diff.d.ts +135 -0
- package/dist/src/tui/edit-diff.js +356 -0
- package/dist/src/tui/edit-diff.js.map +1 -0
- package/dist/src/tui/frame-budget.d.ts +351 -0
- package/dist/src/tui/frame-budget.js +446 -0
- package/dist/src/tui/frame-budget.js.map +1 -0
- package/dist/src/tui/help-format.d.ts +17 -0
- package/dist/src/tui/help-format.js +38 -0
- package/dist/src/tui/help-format.js.map +1 -0
- package/dist/src/tui/live-text.d.ts +51 -0
- package/dist/src/tui/live-text.js +154 -0
- package/dist/src/tui/live-text.js.map +1 -0
- package/dist/src/tui/markdown.d.ts +62 -0
- package/dist/src/tui/markdown.js +244 -0
- package/dist/src/tui/markdown.js.map +1 -0
- package/dist/src/tui/mcp-format.d.ts +28 -0
- package/dist/src/tui/mcp-format.js +67 -0
- package/dist/src/tui/mcp-format.js.map +1 -0
- package/dist/src/tui/path-completion.d.ts +119 -0
- package/dist/src/tui/path-completion.js +305 -0
- package/dist/src/tui/path-completion.js.map +1 -0
- package/dist/src/tui/permission-queue.d.ts +61 -0
- package/dist/src/tui/permission-queue.js +129 -0
- package/dist/src/tui/permission-queue.js.map +1 -0
- package/dist/src/tui/plan-format.d.ts +9 -0
- package/dist/src/tui/plan-format.js +30 -0
- package/dist/src/tui/plan-format.js.map +1 -0
- package/dist/src/tui/prompt-completion.d.ts +22 -0
- package/dist/src/tui/prompt-completion.js +46 -0
- package/dist/src/tui/prompt-completion.js.map +1 -0
- package/dist/src/tui/prompt-editor.d.ts +102 -0
- package/dist/src/tui/prompt-editor.js +379 -0
- package/dist/src/tui/prompt-editor.js.map +1 -0
- package/dist/src/tui/prompt-history-search.d.ts +53 -0
- package/dist/src/tui/prompt-history-search.js +123 -0
- package/dist/src/tui/prompt-history-search.js.map +1 -0
- package/dist/src/tui/prompt-queue.d.ts +58 -0
- package/dist/src/tui/prompt-queue.js +74 -0
- package/dist/src/tui/prompt-queue.js.map +1 -0
- package/dist/src/tui/prompt-recall.d.ts +74 -0
- package/dist/src/tui/prompt-recall.js +90 -0
- package/dist/src/tui/prompt-recall.js.map +1 -0
- package/dist/src/tui/react-environment.d.ts +11 -0
- package/dist/src/tui/react-environment.js +24 -0
- package/dist/src/tui/react-environment.js.map +1 -0
- package/dist/src/tui/rewind-search.d.ts +34 -0
- package/dist/src/tui/rewind-search.js +68 -0
- package/dist/src/tui/rewind-search.js.map +1 -0
- package/dist/src/tui/shell-command.d.ts +114 -0
- package/dist/src/tui/shell-command.js +310 -0
- package/dist/src/tui/shell-command.js.map +1 -0
- package/dist/src/tui/spend-advisory.d.ts +52 -0
- package/dist/src/tui/spend-advisory.js +64 -0
- package/dist/src/tui/spend-advisory.js.map +1 -0
- package/dist/src/tui/status-format.d.ts +120 -0
- package/dist/src/tui/status-format.js +192 -0
- package/dist/src/tui/status-format.js.map +1 -0
- package/dist/src/tui/subagent-format.d.ts +49 -0
- package/dist/src/tui/subagent-format.js +146 -0
- package/dist/src/tui/subagent-format.js.map +1 -0
- package/dist/src/tui/task-format.d.ts +29 -0
- package/dist/src/tui/task-format.js +87 -0
- package/dist/src/tui/task-format.js.map +1 -0
- package/dist/src/tui/terminal-bell.d.ts +20 -0
- package/dist/src/tui/terminal-bell.js +33 -0
- package/dist/src/tui/terminal-bell.js.map +1 -0
- package/dist/src/tui/tool-detail-presentation.d.ts +60 -0
- package/dist/src/tui/tool-detail-presentation.js +206 -0
- package/dist/src/tui/tool-detail-presentation.js.map +1 -0
- package/dist/src/tui/turn-state.d.ts +195 -0
- package/dist/src/tui/turn-state.js +548 -0
- package/dist/src/tui/turn-state.js.map +1 -0
- package/dist/src/tui/visual-language.d.ts +45 -0
- package/dist/src/tui/visual-language.js +57 -0
- package/dist/src/tui/visual-language.js.map +1 -0
- package/dist/src/version.d.ts +7 -0
- package/dist/src/version.js +38 -0
- package/dist/src/version.js.map +1 -0
- 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;AAgBpD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,kDAAkD;AAClD,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAElC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,KAAK;IACL,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,IAAI;IACJ,SAAS;IACT,KAAK;IACL,QA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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 {};
|