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 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/memory/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAsB,MAAM,iBAAiB,CAAC;AAE3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,IAAI,GAAG,EAAE,mBAAmB,GAAG,cAAc,CAAC,CAAC;AAC5I,8FAA8F;AAC9F,2FAA2F;AAC3F,+FAA+F;AAC/F,MAAM,gBAAgB,GAAG,C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I,CAAoC,EAAE,IAAI,EAAE,uBAAuB,EAAE,WAAW,EAAE,gKAAgK,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7X,IAAI,CAAkC,EAAE,IAAI,EAAE,qBAAqB,EAAE,WAAW,EAAE,8WAA8W,EAAE,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,KAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACnkB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type MemorySourceAnchor, type MemoryState } from './state.js';
|
|
2
|
+
export declare const MEMORY_SOURCE_MAX_BYTES: number;
|
|
3
|
+
export declare const MEMORY_SOURCE_MAX_LINES = 10000;
|
|
4
|
+
export declare const MEMORY_SOURCE_LINE_MAX_CODE_POINTS = 4000;
|
|
5
|
+
export declare const MEMORY_HORIZON_MS_PER_DAY: number;
|
|
6
|
+
export interface MemoryValidationOptions {
|
|
7
|
+
readonly horizonDays: number;
|
|
8
|
+
readonly now?: () => Date;
|
|
9
|
+
readonly persist?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ValidatedMemory {
|
|
12
|
+
readonly state: MemoryState;
|
|
13
|
+
readonly eligible: MemoryState;
|
|
14
|
+
}
|
|
15
|
+
export declare function validateMemoryState(projectRoot: string, state: MemoryState, options: MemoryValidationOptions): Promise<ValidatedMemory>;
|
|
16
|
+
type AnchorResult = {
|
|
17
|
+
state: 'invalid' | 'unknown';
|
|
18
|
+
reason: string;
|
|
19
|
+
} | 'valid';
|
|
20
|
+
export declare function validateAnchor(projectRoot: string, anchor: MemorySourceAnchor): Promise<AnchorResult>;
|
|
21
|
+
/** Closed reason set for exact-line anchoring failures; each save rejection names one. */
|
|
22
|
+
export type SourceAnchorFailure = 'quote-not-one-line' | 'unsafe-path' | 'oversized-source' | 'unreadable-source' | 'no-matching-line' | 'multiple-matching-lines';
|
|
23
|
+
export type SourceAnchorResolution = {
|
|
24
|
+
readonly ok: true;
|
|
25
|
+
readonly anchor: MemorySourceAnchor;
|
|
26
|
+
} | {
|
|
27
|
+
readonly ok: false;
|
|
28
|
+
readonly failure: SourceAnchorFailure;
|
|
29
|
+
};
|
|
30
|
+
export declare function resolveExactSourceAnchor(projectRoot: string, pathname: string, evidence: string): Promise<SourceAnchorResolution>;
|
|
31
|
+
export declare function sourceAnchor(pathname: string, line: number, text: string): MemorySourceAnchor;
|
|
32
|
+
export declare function safeRelativePath(value: string): boolean;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, open, realpath } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { TextDecoder } from 'node:util';
|
|
6
|
+
import {} from './state.js';
|
|
7
|
+
export const MEMORY_SOURCE_MAX_BYTES = 256 * 1024;
|
|
8
|
+
export const MEMORY_SOURCE_MAX_LINES = 10_000;
|
|
9
|
+
export const MEMORY_SOURCE_LINE_MAX_CODE_POINTS = 4_000;
|
|
10
|
+
export const MEMORY_HORIZON_MS_PER_DAY = 24 * 60 * 60 * 1_000;
|
|
11
|
+
export async function validateMemoryState(projectRoot, state, options) {
|
|
12
|
+
const now = options.now?.() ?? new Date();
|
|
13
|
+
const generated = [];
|
|
14
|
+
for (const entry of state.generated)
|
|
15
|
+
generated.push({ ...entry, validation: await validateEntry(projectRoot, entry, options.horizonDays, now) });
|
|
16
|
+
const validated = { ...state, generated };
|
|
17
|
+
const eligible = { ...validated, generated: generated.filter((entry) => entry.validation.state === 'valid') };
|
|
18
|
+
return { state: validated, eligible };
|
|
19
|
+
}
|
|
20
|
+
async function validateEntry(projectRoot, entry, horizonDays, now) {
|
|
21
|
+
const checkedAt = now.toISOString();
|
|
22
|
+
const sourceTime = Date.parse(entry.source.at);
|
|
23
|
+
if (horizonDays > 0 && now.getTime() - sourceTime >= horizonDays * MEMORY_HORIZON_MS_PER_DAY)
|
|
24
|
+
return { state: 'expired', reason: `generated evidence reached the ${horizonDays}-day horizon`, checkedAt };
|
|
25
|
+
if (entry.evidence.kind === 'userInput')
|
|
26
|
+
return { state: 'valid', reason: 'exact current user-input quote was verified before durable commit', checkedAt };
|
|
27
|
+
const result = await validateAnchor(projectRoot, entry.evidence.anchor);
|
|
28
|
+
return result === 'valid' ? { state: 'valid', reason: 'exact source anchor matches the current worktree', checkedAt } : { ...result, checkedAt };
|
|
29
|
+
}
|
|
30
|
+
export async function validateAnchor(projectRoot, anchor) {
|
|
31
|
+
if (!safeRelativePath(anchor.path))
|
|
32
|
+
return { state: 'invalid', reason: 'source anchor path is not a safe project-relative path' };
|
|
33
|
+
let canonicalRoot;
|
|
34
|
+
try {
|
|
35
|
+
canonicalRoot = await realpath(projectRoot);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return { state: 'unknown', reason: 'canonical project root could not be resolved' };
|
|
39
|
+
}
|
|
40
|
+
const candidate = path.resolve(canonicalRoot, ...anchor.path.split('/'));
|
|
41
|
+
if (!inside(canonicalRoot, candidate))
|
|
42
|
+
return { state: 'invalid', reason: 'source anchor escapes the canonical project root' };
|
|
43
|
+
let handle;
|
|
44
|
+
try {
|
|
45
|
+
const pathStat = await lstat(candidate);
|
|
46
|
+
if (pathStat.isSymbolicLink() || !pathStat.isFile())
|
|
47
|
+
return { state: 'invalid', reason: 'source anchor is not a regular project file' };
|
|
48
|
+
const canonicalCandidate = await realpath(candidate);
|
|
49
|
+
if (!inside(canonicalRoot, canonicalCandidate))
|
|
50
|
+
return { state: 'invalid', reason: 'source anchor resolves outside the canonical project root' };
|
|
51
|
+
handle = await open(candidate, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
52
|
+
const stat = await handle.stat();
|
|
53
|
+
if (!stat.isFile())
|
|
54
|
+
return { state: 'invalid', reason: 'source anchor is not a regular project file' };
|
|
55
|
+
if (stat.size > MEMORY_SOURCE_MAX_BYTES)
|
|
56
|
+
return { state: 'unknown', reason: 'source file exceeds the validation byte bound' };
|
|
57
|
+
const buffer = Buffer.alloc(stat.size + 1);
|
|
58
|
+
let offset = 0;
|
|
59
|
+
while (offset < stat.size) {
|
|
60
|
+
const read = await handle.read(buffer, offset, stat.size - offset, offset);
|
|
61
|
+
if (read.bytesRead === 0)
|
|
62
|
+
break;
|
|
63
|
+
offset += read.bytesRead;
|
|
64
|
+
}
|
|
65
|
+
const after = await handle.stat();
|
|
66
|
+
if (offset !== stat.size || after.size !== stat.size || after.mtimeMs !== stat.mtimeMs || after.ctimeMs !== stat.ctimeMs)
|
|
67
|
+
return { state: 'unknown', reason: 'source file changed while validation read it' };
|
|
68
|
+
let text;
|
|
69
|
+
try {
|
|
70
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(buffer.subarray(0, offset));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return { state: 'unknown', reason: 'source file is not valid UTF-8 text' };
|
|
74
|
+
}
|
|
75
|
+
if (text.includes('\0'))
|
|
76
|
+
return { state: 'unknown', reason: 'source file is binary text' };
|
|
77
|
+
const lines = text.replace(/\r\n?/g, '\n').split('\n');
|
|
78
|
+
if (lines.length > MEMORY_SOURCE_MAX_LINES)
|
|
79
|
+
return { state: 'unknown', reason: 'source file exceeds the validation line bound' };
|
|
80
|
+
const line = lines[anchor.line - 1];
|
|
81
|
+
if (line === undefined)
|
|
82
|
+
return { state: 'invalid', reason: 'anchored source line no longer exists' };
|
|
83
|
+
if ([...line].length > MEMORY_SOURCE_LINE_MAX_CODE_POINTS)
|
|
84
|
+
return { state: 'unknown', reason: 'anchored source line exceeds the validation bound' };
|
|
85
|
+
if ([...line].length !== anchor.codePoints || hashLine(line) !== anchor.hash)
|
|
86
|
+
return { state: 'invalid', reason: 'anchored source text changed' };
|
|
87
|
+
return 'valid';
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const code = errorCode(error);
|
|
91
|
+
if (code === 'ENOENT' || code === 'ENOTDIR')
|
|
92
|
+
return { state: 'invalid', reason: 'anchored source file was deleted' };
|
|
93
|
+
if (code === 'ELOOP')
|
|
94
|
+
return { state: 'invalid', reason: 'source anchor is a symbolic link' };
|
|
95
|
+
return { state: 'unknown', reason: 'source file could not be read safely' };
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
await handle?.close().catch(() => { });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const anchorFailure = (failure) => ({ ok: false, failure });
|
|
102
|
+
export async function resolveExactSourceAnchor(projectRoot, pathname, evidence) {
|
|
103
|
+
if (!safeRelativePath(pathname))
|
|
104
|
+
return anchorFailure('unsafe-path');
|
|
105
|
+
if (evidence.includes('\n') || [...evidence].length > MEMORY_SOURCE_LINE_MAX_CODE_POINTS)
|
|
106
|
+
return anchorFailure('quote-not-one-line');
|
|
107
|
+
const root = await realpath(projectRoot).catch(() => undefined);
|
|
108
|
+
if (root === undefined)
|
|
109
|
+
return anchorFailure('unreadable-source');
|
|
110
|
+
const candidate = path.resolve(root, ...pathname.split('/'));
|
|
111
|
+
if (!inside(root, candidate))
|
|
112
|
+
return anchorFailure('unsafe-path');
|
|
113
|
+
let handle;
|
|
114
|
+
try {
|
|
115
|
+
const pathStat = await lstat(candidate);
|
|
116
|
+
if (!pathStat.isFile() || pathStat.isSymbolicLink() || !inside(root, await realpath(candidate)))
|
|
117
|
+
return anchorFailure('unsafe-path');
|
|
118
|
+
handle = await open(candidate, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
119
|
+
const stat = await handle.stat();
|
|
120
|
+
if (!stat.isFile())
|
|
121
|
+
return anchorFailure('unsafe-path');
|
|
122
|
+
if (stat.size > MEMORY_SOURCE_MAX_BYTES)
|
|
123
|
+
return anchorFailure('oversized-source');
|
|
124
|
+
const buffer = Buffer.alloc(stat.size);
|
|
125
|
+
let offset = 0;
|
|
126
|
+
while (offset < stat.size) {
|
|
127
|
+
const read = await handle.read(buffer, offset, stat.size - offset, offset);
|
|
128
|
+
if (read.bytesRead === 0)
|
|
129
|
+
break;
|
|
130
|
+
offset += read.bytesRead;
|
|
131
|
+
}
|
|
132
|
+
if (offset !== stat.size)
|
|
133
|
+
return anchorFailure('unreadable-source');
|
|
134
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(buffer);
|
|
135
|
+
if (text.includes('\0'))
|
|
136
|
+
return anchorFailure('unreadable-source');
|
|
137
|
+
const lines = text.replace(/\r\n?/g, '\n').split('\n');
|
|
138
|
+
if (lines.length > MEMORY_SOURCE_MAX_LINES)
|
|
139
|
+
return anchorFailure('oversized-source');
|
|
140
|
+
const matches = lines.flatMap((line, index) => line === evidence ? [index + 1] : []);
|
|
141
|
+
if (matches.length === 0)
|
|
142
|
+
return anchorFailure('no-matching-line');
|
|
143
|
+
if (matches.length > 1)
|
|
144
|
+
return anchorFailure('multiple-matching-lines');
|
|
145
|
+
return { ok: true, anchor: sourceAnchor(pathname, matches[0], evidence) };
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return anchorFailure('unreadable-source');
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
await handle?.close().catch(() => { });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export function sourceAnchor(pathname, line, text) { return { path: pathname, line, hash: hashLine(text), codePoints: [...text].length }; }
|
|
155
|
+
export function safeRelativePath(value) { return value !== '' && !path.isAbsolute(value) && !value.includes('\\') && value.split('/').every((part) => part !== '' && part !== '.' && part !== '..'); }
|
|
156
|
+
function hashLine(value) { return createHash('sha256').update(value, 'utf8').digest('hex'); }
|
|
157
|
+
function inside(root, candidate) { const relative = path.relative(root, candidate); return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative)); }
|
|
158
|
+
function errorCode(error) { return typeof error === 'object' && error !== null ? error.code : undefined; }
|
|
159
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/memory/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAKN,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAC;AAClD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC9C,MAAM,CAAC,MAAM,kCAAkC,GAAG,KAAK,CAAC;AACxD,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAK9D,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAmB,EAAE,KAAkB,EAAE,OAAgC;IACjH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;IAAC,MAAM,SAAS,GAA2B,EAAE,CAAC;IACxF,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,SAAS;QAAE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,EA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Aa,OAAO,KAAK,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;AACvN,SAAS,QAAQ,CAAC,KAAa,IAAY,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC7G,SAAS,MAAM,CAAC,IAAY,EAAE,SAAiB,IAAa,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACpO,SAAS,SAAS,CAAC,KAAc,IAAa,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAE,KAA4B,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** One generated file: its source pnpm patch and where the patch-package copy went. */
|
|
2
|
+
export interface GeneratedPatch {
|
|
3
|
+
readonly source: string;
|
|
4
|
+
readonly output: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Convert every pnpm patch in `patchesDir` into `outputDir`, which is recreated from
|
|
8
|
+
* scratch so a renamed or removed source never leaves a stale copy behind. Files
|
|
9
|
+
* whose names are not in pnpm's `name@version.patch` shape are skipped and reported.
|
|
10
|
+
*/
|
|
11
|
+
export declare function generatePatchPackageFiles(options: {
|
|
12
|
+
readonly patchesDir: string;
|
|
13
|
+
readonly outputDir: string;
|
|
14
|
+
}): {
|
|
15
|
+
readonly generated: readonly GeneratedPatch[];
|
|
16
|
+
readonly skipped: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The package root, found by walking up from this module to the `package.json` that
|
|
20
|
+
* names darwin — the same rule `version.ts` uses, so it holds for `src/npm-package/`
|
|
21
|
+
* under tsx and `dist/src/npm-package/` after a build alike.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findPackageRoot(start?: string): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build step: generate the `patch-package` copy of every pinned pnpm patch.
|
|
3
|
+
*
|
|
4
|
+
* `pnpm build` runs this after `tsc` (`node dist/src/npm-package/generate-patch.js`).
|
|
5
|
+
* It reads `patches/*.patch` — the pnpm patches `pnpm patch-commit` writes and
|
|
6
|
+
* `pnpm-workspace.yaml` applies — and writes their patch-package dialect to
|
|
7
|
+
* `dist/patches/` (see `patch-package-format.ts` for the two differences). That
|
|
8
|
+
* directory is a build artifact like the rest of `dist/`: gitignored, and shipped by
|
|
9
|
+
* the `files` whitelist in `package.json`, where `postinstall` runs
|
|
10
|
+
* `patch-package --patch-dir dist/patches` against it.
|
|
11
|
+
*
|
|
12
|
+
* Both install paths stay green because of what patch-package does at the edges:
|
|
13
|
+
* a fresh clone's `pnpm install` runs `postinstall` before any build, finds no
|
|
14
|
+
* `dist/patches/` and exits 0 ("No patch files found"); a developer's later
|
|
15
|
+
* `pnpm install` finds the generated file but an SDK pnpm has already patched, and
|
|
16
|
+
* exits 0 as well (already applied). `spike/verify-npm-patch-format.ts` pins the
|
|
17
|
+
* conversion; `spike/verify-npm-package.ts` packs and installs the real tarball.
|
|
18
|
+
*/
|
|
19
|
+
import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import process from 'node:process';
|
|
22
|
+
import { pathToFileURL } from 'node:url';
|
|
23
|
+
import { DARWIN_PACKAGE_NAME } from '../version.js';
|
|
24
|
+
import { parsePnpmPatchFileName, patchPackageFileName, toPatchPackageFormat } from './patch-package-format.js';
|
|
25
|
+
/**
|
|
26
|
+
* Convert every pnpm patch in `patchesDir` into `outputDir`, which is recreated from
|
|
27
|
+
* scratch so a renamed or removed source never leaves a stale copy behind. Files
|
|
28
|
+
* whose names are not in pnpm's `name@version.patch` shape are skipped and reported.
|
|
29
|
+
*/
|
|
30
|
+
export function generatePatchPackageFiles(options) {
|
|
31
|
+
const generated = [];
|
|
32
|
+
const skipped = [];
|
|
33
|
+
const sources = readdirSync(options.patchesDir).filter((name) => name.endsWith('.patch')).sort();
|
|
34
|
+
rmSync(options.outputDir, { recursive: true, force: true });
|
|
35
|
+
mkdirSync(options.outputDir, { recursive: true });
|
|
36
|
+
for (const fileName of sources) {
|
|
37
|
+
const identity = parsePnpmPatchFileName(fileName);
|
|
38
|
+
if (identity === undefined) {
|
|
39
|
+
skipped.push(fileName);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const source = path.join(options.patchesDir, fileName);
|
|
43
|
+
const output = path.join(options.outputDir, patchPackageFileName(identity));
|
|
44
|
+
writeFileSync(output, toPatchPackageFormat(readFileSync(source, 'utf8'), identity.packageName), 'utf8');
|
|
45
|
+
generated.push({ source, output });
|
|
46
|
+
}
|
|
47
|
+
return { generated, skipped };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The package root, found by walking up from this module to the `package.json` that
|
|
51
|
+
* names darwin — the same rule `version.ts` uses, so it holds for `src/npm-package/`
|
|
52
|
+
* under tsx and `dist/src/npm-package/` after a build alike.
|
|
53
|
+
*/
|
|
54
|
+
export function findPackageRoot(start = import.meta.dirname) {
|
|
55
|
+
let directory = start;
|
|
56
|
+
for (let depth = 0; depth < 5; depth += 1) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(readFileSync(path.join(directory, 'package.json'), 'utf8'));
|
|
59
|
+
if (parsed.name === DARWIN_PACKAGE_NAME)
|
|
60
|
+
return directory;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Not this directory: keep walking.
|
|
64
|
+
}
|
|
65
|
+
const parent = path.dirname(directory);
|
|
66
|
+
if (parent === directory)
|
|
67
|
+
break;
|
|
68
|
+
directory = parent;
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`generate-patch: no package.json named ${DARWIN_PACKAGE_NAME} above ${start}`);
|
|
71
|
+
}
|
|
72
|
+
if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
73
|
+
const root = findPackageRoot();
|
|
74
|
+
const { generated, skipped } = generatePatchPackageFiles({
|
|
75
|
+
patchesDir: path.join(root, 'patches'),
|
|
76
|
+
outputDir: path.join(root, 'dist', 'patches'),
|
|
77
|
+
});
|
|
78
|
+
for (const { source, output } of generated) {
|
|
79
|
+
process.stdout.write(`generated ${path.relative(root, output)} from ${path.relative(root, source)}\n`);
|
|
80
|
+
}
|
|
81
|
+
for (const name of skipped)
|
|
82
|
+
process.stderr.write(`generate-patch: skipped patches/${name} (not a pnpm patch file name)\n`);
|
|
83
|
+
if (generated.length === 0) {
|
|
84
|
+
process.stderr.write('generate-patch: no pnpm patch found under patches/\n');
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=generate-patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-patch.js","sourceRoot":"","sources":["../../../src/npm-package/generate-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAA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E,SAAS,EAAE,OAAO,EAAE,GAAG,yBAAyB,CAAC;QACvD,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC;QACtC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC;KAC9C,CAAC,CAAC;IACH,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;QAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACzG,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,OAAO;QAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,IAAI,iCAAiC,CAAC,CAAC;IAC3H,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC7E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion of a pnpm dependency patch into `patch-package` format.
|
|
3
|
+
*
|
|
4
|
+
* The repository pins its SDK patch once, as a pnpm patch
|
|
5
|
+
* (`patches/@strands-agents__sdk@1.16.0.patch`, `pnpm patch-commit`, applied by
|
|
6
|
+
* `pnpm-workspace.yaml` `patchedDependencies`). The npm package cannot use pnpm's
|
|
7
|
+
* mechanism, so `postinstall` runs `patch-package`, which reads the *same* patch in a
|
|
8
|
+
* slightly different dialect. The two formats differ only in two places:
|
|
9
|
+
*
|
|
10
|
+
* - **paths** — pnpm writes them relative to the package (`a/dist/src/index.js`),
|
|
11
|
+
* patch-package expects them rooted at the app (`a/node_modules/@strands-agents/sdk/dist/src/index.js`);
|
|
12
|
+
* - **file name** — pnpm encodes the scope slash as `__` and separates the version
|
|
13
|
+
* with `@` (`@strands-agents__sdk@1.16.0.patch`), patch-package uses `+` for both
|
|
14
|
+
* (`@strands-agents+sdk+1.16.0.patch`).
|
|
15
|
+
*
|
|
16
|
+
* This module is the whole conversion, as pure functions. It is applied at build time
|
|
17
|
+
* by `generate-patch.ts`, so there is never a second hand-maintained copy of the patch:
|
|
18
|
+
* `pnpm patch-commit` stays the single source and the generated file is a build
|
|
19
|
+
* artifact. Every function is idempotent — feeding it its own output changes nothing.
|
|
20
|
+
*/
|
|
21
|
+
/** The parsed identity of a pnpm patch file name. */
|
|
22
|
+
export interface PnpmPatchIdentity {
|
|
23
|
+
/** The package name, scope slash restored (`@strands-agents/sdk`). */
|
|
24
|
+
readonly packageName: string;
|
|
25
|
+
/** The exact version the patch was recorded against (`1.16.0`). */
|
|
26
|
+
readonly version: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse a pnpm patch file name (`@scope__name@version.patch` or `name@version.patch`),
|
|
30
|
+
* or `undefined` when the name is not in that shape.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parsePnpmPatchFileName(fileName: string): PnpmPatchIdentity | undefined;
|
|
33
|
+
/** The patch-package file name for an identity (`@strands-agents+sdk+1.16.0.patch`). */
|
|
34
|
+
export declare function patchPackageFileName(identity: PnpmPatchIdentity): string;
|
|
35
|
+
/** Where patch-package expects the package to live, relative to the app root, with a trailing slash. */
|
|
36
|
+
export declare function patchPackagePathPrefix(packageName: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Rewrite a pnpm patch body into patch-package format by prefixing every path in the
|
|
39
|
+
* `diff --git a/… b/…`, `--- a/…` and `+++ b/…` header lines with
|
|
40
|
+
* `node_modules/<package>/`. Hunk bodies, `index` lines, mode lines and `/dev/null`
|
|
41
|
+
* sides are untouched. Idempotent: a path that already carries the prefix is left alone.
|
|
42
|
+
*/
|
|
43
|
+
export declare function toPatchPackageFormat(pnpmPatch: string, packageName: string): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion of a pnpm dependency patch into `patch-package` format.
|
|
3
|
+
*
|
|
4
|
+
* The repository pins its SDK patch once, as a pnpm patch
|
|
5
|
+
* (`patches/@strands-agents__sdk@1.16.0.patch`, `pnpm patch-commit`, applied by
|
|
6
|
+
* `pnpm-workspace.yaml` `patchedDependencies`). The npm package cannot use pnpm's
|
|
7
|
+
* mechanism, so `postinstall` runs `patch-package`, which reads the *same* patch in a
|
|
8
|
+
* slightly different dialect. The two formats differ only in two places:
|
|
9
|
+
*
|
|
10
|
+
* - **paths** — pnpm writes them relative to the package (`a/dist/src/index.js`),
|
|
11
|
+
* patch-package expects them rooted at the app (`a/node_modules/@strands-agents/sdk/dist/src/index.js`);
|
|
12
|
+
* - **file name** — pnpm encodes the scope slash as `__` and separates the version
|
|
13
|
+
* with `@` (`@strands-agents__sdk@1.16.0.patch`), patch-package uses `+` for both
|
|
14
|
+
* (`@strands-agents+sdk+1.16.0.patch`).
|
|
15
|
+
*
|
|
16
|
+
* This module is the whole conversion, as pure functions. It is applied at build time
|
|
17
|
+
* by `generate-patch.ts`, so there is never a second hand-maintained copy of the patch:
|
|
18
|
+
* `pnpm patch-commit` stays the single source and the generated file is a build
|
|
19
|
+
* artifact. Every function is idempotent — feeding it its own output changes nothing.
|
|
20
|
+
*/
|
|
21
|
+
const PNPM_PATCH_FILE = /^(?<name>@?[^@]+)@(?<version>[^@]+)\.patch$/;
|
|
22
|
+
/**
|
|
23
|
+
* Parse a pnpm patch file name (`@scope__name@version.patch` or `name@version.patch`),
|
|
24
|
+
* or `undefined` when the name is not in that shape.
|
|
25
|
+
*/
|
|
26
|
+
export function parsePnpmPatchFileName(fileName) {
|
|
27
|
+
const match = PNPM_PATCH_FILE.exec(fileName);
|
|
28
|
+
if (match?.groups === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
const { name, version } = match.groups;
|
|
31
|
+
return { packageName: name.replace('__', '/'), version };
|
|
32
|
+
}
|
|
33
|
+
/** The patch-package file name for an identity (`@strands-agents+sdk+1.16.0.patch`). */
|
|
34
|
+
export function patchPackageFileName(identity) {
|
|
35
|
+
return `${identity.packageName.replace('/', '+')}+${identity.version}.patch`;
|
|
36
|
+
}
|
|
37
|
+
/** Where patch-package expects the package to live, relative to the app root, with a trailing slash. */
|
|
38
|
+
export function patchPackagePathPrefix(packageName) {
|
|
39
|
+
return `node_modules/${packageName}/`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Rewrite a pnpm patch body into patch-package format by prefixing every path in the
|
|
43
|
+
* `diff --git a/… b/…`, `--- a/…` and `+++ b/…` header lines with
|
|
44
|
+
* `node_modules/<package>/`. Hunk bodies, `index` lines, mode lines and `/dev/null`
|
|
45
|
+
* sides are untouched. Idempotent: a path that already carries the prefix is left alone.
|
|
46
|
+
*/
|
|
47
|
+
export function toPatchPackageFormat(pnpmPatch, packageName) {
|
|
48
|
+
const prefix = patchPackagePathPrefix(packageName);
|
|
49
|
+
const withPrefix = (pathText) => pathText.startsWith(prefix) ? pathText : `${prefix}${pathText}`;
|
|
50
|
+
return pnpmPatch
|
|
51
|
+
.split('\n')
|
|
52
|
+
.map((line) => {
|
|
53
|
+
const header = /^diff --git a\/(?<from>.+) b\/(?<to>.+)$/.exec(line);
|
|
54
|
+
if (header?.groups !== undefined) {
|
|
55
|
+
const { from, to } = header.groups;
|
|
56
|
+
return `diff --git a/${withPrefix(from)} b/${withPrefix(to)}`;
|
|
57
|
+
}
|
|
58
|
+
if (line.startsWith('--- a/'))
|
|
59
|
+
return `--- a/${withPrefix(line.slice('--- a/'.length))}`;
|
|
60
|
+
if (line.startsWith('+++ b/'))
|
|
61
|
+
return `+++ b/${withPrefix(line.slice('+++ b/'.length))}`;
|
|
62
|
+
return line;
|
|
63
|
+
})
|
|
64
|
+
.join('\n');
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=patch-package-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-package-format.js","sourceRoot":"","sources":["../../../src/npm-package/patch-package-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,MAAM,eAAe,GAAG,6CAA6C,CAAC;AAEtE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,KAAK,EAAE,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,MAA2C,CAAC;IAC5E,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC;AAC3D,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAAC,QAA2B;IAC9D,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,OAAO,QAAQ,CAAC;AAC/E,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACxD,OAAO,gBAAgB,WAAW,GAAG,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAE,WAAmB;IACzE,MAAM,MAAM,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAU,EAAE,CAC9C,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC;IAClE,OAAO,SAAS;SACb,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,MAAM,GAAG,0CAA0C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,IAAI,MAAM,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,MAAsC,CAAC;YACnE,OAAO,gBAAgB,UAAU,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;QAChE,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,SAAS,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACzF,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,SAAS,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACzF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const DARWIN_DIRNAME = ".darwin";
|
|
2
|
+
export declare const AGENTS_DIRNAME = ".agents";
|
|
3
|
+
/** `<projectRoot>/.darwin`, for repository-owned resources and legacy state. */
|
|
4
|
+
export declare function darwinDir(projectRoot: string): string;
|
|
5
|
+
/** `<projectRoot>/.agents`, for portable project extension resources. */
|
|
6
|
+
export declare function agentsDir(projectRoot: string): string;
|
|
7
|
+
/** `~/.darwin`, resolved from the current user's home directory. */
|
|
8
|
+
export declare function userDarwinDir(): string;
|
|
9
|
+
/** `~/.agents`, for portable user-global extension resources. */
|
|
10
|
+
export declare function userAgentsDir(): string;
|
|
11
|
+
export interface ExtensionRoot {
|
|
12
|
+
root: string;
|
|
13
|
+
scope: 'project' | 'global';
|
|
14
|
+
kind: 'darwin' | 'agents';
|
|
15
|
+
}
|
|
16
|
+
/** Named-resource precedence, highest first after built-in reservations. */
|
|
17
|
+
export declare function extensionRoots(projectRoot: string): ExtensionRoot[];
|
|
18
|
+
/** Hook wrapper order, outermost/global first. Post execution reverses this list. */
|
|
19
|
+
export declare function hookExtensionRoots(projectRoot: string): ExtensionRoot[];
|
|
20
|
+
/** A stable, readable and collision-resistant directory name for one working tree. */
|
|
21
|
+
export declare function projectKey(projectRoot: string): string;
|
|
22
|
+
/** User-owned state scoped to one canonical project. */
|
|
23
|
+
export declare function userProjectDir(projectRoot: string): string;
|
|
24
|
+
/** User-global session state scoped to one canonical project. */
|
|
25
|
+
export declare function userProjectSessionsDir(projectRoot: string): string;
|
|
26
|
+
/** Derived, project-scoped learned memory. Never part of the repository itself. */
|
|
27
|
+
export declare function projectMemoryDir(projectRoot: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* `~/.darwin/model-prices.json` — the user-global cache of resolved per-model
|
|
30
|
+
* token prices (darwin model id → LiteLLM rates). Global, not project-scoped:
|
|
31
|
+
* a model's price does not depend on the repository it is used in.
|
|
32
|
+
*/
|
|
33
|
+
export declare function userModelPricesFile(): string;
|
|
34
|
+
/** Files that can change Darwin's own authorization or executable policy. */
|
|
35
|
+
export declare function sensitiveDarwinPaths(projectRoot: string): string[];
|
|
36
|
+
/** Directories whose contents are executable hook policy. */
|
|
37
|
+
export declare function sensitiveHookDirectories(projectRoot: string): string[];
|
|
38
|
+
/** Containment-aware policy check shared by risk classification and allow rules. */
|
|
39
|
+
export declare function isSensitiveDarwinPath(projectRoot: string, candidate: string): boolean;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Shared path ownership for Darwin's user-global and project-local state. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { realpathSync } from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
export const DARWIN_DIRNAME = '.darwin';
|
|
7
|
+
export const AGENTS_DIRNAME = '.agents';
|
|
8
|
+
/** `<projectRoot>/.darwin`, for repository-owned resources and legacy state. */
|
|
9
|
+
export function darwinDir(projectRoot) {
|
|
10
|
+
return path.join(projectRoot, DARWIN_DIRNAME);
|
|
11
|
+
}
|
|
12
|
+
/** `<projectRoot>/.agents`, for portable project extension resources. */
|
|
13
|
+
export function agentsDir(projectRoot) {
|
|
14
|
+
return path.join(projectRoot, AGENTS_DIRNAME);
|
|
15
|
+
}
|
|
16
|
+
/** `~/.darwin`, resolved from the current user's home directory. */
|
|
17
|
+
export function userDarwinDir() {
|
|
18
|
+
return path.join(os.homedir(), DARWIN_DIRNAME);
|
|
19
|
+
}
|
|
20
|
+
/** `~/.agents`, for portable user-global extension resources. */
|
|
21
|
+
export function userAgentsDir() {
|
|
22
|
+
return path.join(os.homedir(), AGENTS_DIRNAME);
|
|
23
|
+
}
|
|
24
|
+
/** Named-resource precedence, highest first after built-in reservations. */
|
|
25
|
+
export function extensionRoots(projectRoot) {
|
|
26
|
+
return [
|
|
27
|
+
{ root: darwinDir(projectRoot), scope: 'project', kind: 'darwin' },
|
|
28
|
+
{ root: agentsDir(projectRoot), scope: 'project', kind: 'agents' },
|
|
29
|
+
{ root: userDarwinDir(), scope: 'global', kind: 'darwin' },
|
|
30
|
+
{ root: userAgentsDir(), scope: 'global', kind: 'agents' },
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
/** Hook wrapper order, outermost/global first. Post execution reverses this list. */
|
|
34
|
+
export function hookExtensionRoots(projectRoot) {
|
|
35
|
+
return [
|
|
36
|
+
{ root: userAgentsDir(), scope: 'global', kind: 'agents' },
|
|
37
|
+
{ root: userDarwinDir(), scope: 'global', kind: 'darwin' },
|
|
38
|
+
{ root: agentsDir(projectRoot), scope: 'project', kind: 'agents' },
|
|
39
|
+
{ root: darwinDir(projectRoot), scope: 'project', kind: 'darwin' },
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
/** A stable, readable and collision-resistant directory name for one working tree. */
|
|
43
|
+
export function projectKey(projectRoot) {
|
|
44
|
+
let canonical;
|
|
45
|
+
try {
|
|
46
|
+
canonical = realpathSync.native(projectRoot);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
canonical = path.resolve(projectRoot);
|
|
50
|
+
}
|
|
51
|
+
const readable = canonical.replace(/[^a-zA-Z0-9_-]/g, '-').slice(0, 180) || 'project';
|
|
52
|
+
const digest = createHash('sha256').update(canonical).digest('hex');
|
|
53
|
+
return `${readable}--${digest}`;
|
|
54
|
+
}
|
|
55
|
+
/** User-owned state scoped to one canonical project. */
|
|
56
|
+
export function userProjectDir(projectRoot) {
|
|
57
|
+
return path.join(userDarwinDir(), 'projects', projectKey(projectRoot));
|
|
58
|
+
}
|
|
59
|
+
/** User-global session state scoped to one canonical project. */
|
|
60
|
+
export function userProjectSessionsDir(projectRoot) {
|
|
61
|
+
return path.join(userDarwinDir(), 'sessions', projectKey(projectRoot));
|
|
62
|
+
}
|
|
63
|
+
/** Derived, project-scoped learned memory. Never part of the repository itself. */
|
|
64
|
+
export function projectMemoryDir(projectRoot) {
|
|
65
|
+
return path.join(userProjectDir(projectRoot), 'memory');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `~/.darwin/model-prices.json` — the user-global cache of resolved per-model
|
|
69
|
+
* token prices (darwin model id → LiteLLM rates). Global, not project-scoped:
|
|
70
|
+
* a model's price does not depend on the repository it is used in.
|
|
71
|
+
*/
|
|
72
|
+
export function userModelPricesFile() {
|
|
73
|
+
return path.join(userDarwinDir(), 'model-prices.json');
|
|
74
|
+
}
|
|
75
|
+
/** Files that can change Darwin's own authorization or executable policy. */
|
|
76
|
+
export function sensitiveDarwinPaths(projectRoot) {
|
|
77
|
+
return [
|
|
78
|
+
path.join(userDarwinDir(), 'config.json'),
|
|
79
|
+
path.join(userDarwinDir(), 'hooks.json'),
|
|
80
|
+
path.join(userAgentsDir(), 'hooks.json'),
|
|
81
|
+
path.join(userProjectDir(projectRoot), 'permission-rules.json'),
|
|
82
|
+
path.join(darwinDir(projectRoot), 'hooks.json'),
|
|
83
|
+
path.join(agentsDir(projectRoot), 'hooks.json'),
|
|
84
|
+
path.join(darwinDir(projectRoot), 'config.json'),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
/** Directories whose contents are executable hook policy. */
|
|
88
|
+
export function sensitiveHookDirectories(projectRoot) {
|
|
89
|
+
return extensionRoots(projectRoot).map(({ root }) => path.join(root, 'hooks'));
|
|
90
|
+
}
|
|
91
|
+
/** Containment-aware policy check shared by risk classification and allow rules. */
|
|
92
|
+
export function isSensitiveDarwinPath(projectRoot, candidate) {
|
|
93
|
+
const resolved = path.resolve(candidate);
|
|
94
|
+
if (sensitiveDarwinPaths(projectRoot).some((file) => samePath(file, resolved)))
|
|
95
|
+
return true;
|
|
96
|
+
return sensitiveHookDirectories(projectRoot).some((directory) => isInside(directory, resolved));
|
|
97
|
+
}
|
|
98
|
+
function samePath(left, right) {
|
|
99
|
+
return path.relative(left, right) === '';
|
|
100
|
+
}
|
|
101
|
+
function isInside(root, candidate) {
|
|
102
|
+
const relative = path.relative(root, candidate);
|
|
103
|
+
return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/paths.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAExC,gFAAgF;AAChF,MAAM,UAAU,S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