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,119 @@
|
|
|
1
|
+
import { type EditorValue } from './prompt-editor.js';
|
|
2
|
+
/** The character that opens a path query. */
|
|
3
|
+
export declare const PATH_TRIGGER = "@";
|
|
4
|
+
/**
|
|
5
|
+
* Longest query treated as a path prefix.
|
|
6
|
+
*
|
|
7
|
+
* A token this long is prose, a URL or a pasted blob, not something a person is
|
|
8
|
+
* completing — and matching it against every candidate on every keystroke is work
|
|
9
|
+
* with a guaranteed empty result.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MAX_PATH_QUERY_LENGTH = 256;
|
|
12
|
+
/** Directory entries the scan may inspect before it stops and says so. */
|
|
13
|
+
export declare const MAX_SCAN_ENTRIES = 8000;
|
|
14
|
+
/**
|
|
15
|
+
* Levels below the project root the scan may descend.
|
|
16
|
+
*
|
|
17
|
+
* This repository is 6 levels deep excluding the skipped directories, so 8 covers
|
|
18
|
+
* it whole; the bound exists for the tree that does not stop.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_SCAN_DEPTH = 8;
|
|
21
|
+
/** Candidates kept in memory for matching. */
|
|
22
|
+
export declare const MAX_PATH_CANDIDATES = 4000;
|
|
23
|
+
/**
|
|
24
|
+
* Directory names a repository scan has no business walking.
|
|
25
|
+
*
|
|
26
|
+
* Neither walked nor offered: a completion for `node_modules/.pnpm/…` is not a path
|
|
27
|
+
* anyone means, and walking it is how typing would come to depend on the size of a
|
|
28
|
+
* dependency tree. Matched by name at any depth.
|
|
29
|
+
*/
|
|
30
|
+
export declare const EXCLUDED_DIRECTORY_NAMES: ReadonlySet<string>;
|
|
31
|
+
/** An open `@` query: where it starts, where the cursor is, and what was typed. */
|
|
32
|
+
export interface PathQuery {
|
|
33
|
+
/** Source offset of the `@` itself. */
|
|
34
|
+
readonly start: number;
|
|
35
|
+
/** Source offset one past the query, i.e. the cursor. */
|
|
36
|
+
readonly end: number;
|
|
37
|
+
/** Text typed after the `@`; empty right after the trigger. */
|
|
38
|
+
readonly text: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The `@` query under the cursor, or nothing.
|
|
42
|
+
*
|
|
43
|
+
* A query is open when scanning back from the cursor reaches an `@` without
|
|
44
|
+
* crossing whitespace, *and* the character before that `@` is the start of the
|
|
45
|
+
* draft or whitespace. That one rule is what keeps the menu out of prose:
|
|
46
|
+
* `user@example.com` has `r` before the `@`, and so does every decorator or handle
|
|
47
|
+
* typed inside a word. A newline counts as whitespace, so a multi-line draft
|
|
48
|
+
* triggers per line, and a space typed after the query closes it again — the same
|
|
49
|
+
* "a space ends it" shape `computeCompletions` uses for commands.
|
|
50
|
+
*
|
|
51
|
+
* Recognizing a trigger is not the same as opening a menu: a query that matches no
|
|
52
|
+
* workspace path offers no rows at all, which is what makes `@someone` in a
|
|
53
|
+
* sentence a no-op rather than a hijacked keyboard.
|
|
54
|
+
*/
|
|
55
|
+
export declare function pathCompletionQuery(text: string, cursorOffset: number): PathQuery | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Candidates matching a query, best first.
|
|
58
|
+
*
|
|
59
|
+
* Two tiers, no scoring: paths that start with the query, then — only when the
|
|
60
|
+
* query names no directory of its own — paths whose *last segment* starts with it,
|
|
61
|
+
* so `@InputBox` finds `src/tui/InputBox.tsx` without anyone having to type the
|
|
62
|
+
* directories. Both tiers are case-insensitive and keep the candidate order they
|
|
63
|
+
* were scanned in, which is breadth-first, so shallow paths come first. Fuzzy
|
|
64
|
+
* matching is deliberately absent: a menu whose top row moves for reasons the user
|
|
65
|
+
* cannot see is worse than one they can predict.
|
|
66
|
+
*
|
|
67
|
+
* Every match is returned. The list is already bounded by {@link MAX_PATH_CANDIDATES},
|
|
68
|
+
* and the caller needs the true total to say how many rows it is not showing.
|
|
69
|
+
*/
|
|
70
|
+
export declare function matchWorkspacePaths(candidates: readonly string[], query: string): string[];
|
|
71
|
+
/**
|
|
72
|
+
* The draft with the accepted path in place of the `@` token.
|
|
73
|
+
*
|
|
74
|
+
* The `@` is scaffolding, not content: accepting a **file** replaces the whole token
|
|
75
|
+
* with the plain path and one space, which is the text a person would have typed;
|
|
76
|
+
* accepting a **directory** keeps the marker (`@src/`) so the next keystroke carries
|
|
77
|
+
* on completing inside it. Nothing else about the draft moves, and nothing is read
|
|
78
|
+
* from the path itself — this function only ever touches strings.
|
|
79
|
+
*/
|
|
80
|
+
export declare function applyPathCompletion(value: EditorValue, query: PathQuery, chosen: string): EditorValue;
|
|
81
|
+
/** One bounded reading of the workspace's paths. */
|
|
82
|
+
export interface WorkspacePaths {
|
|
83
|
+
/**
|
|
84
|
+
* Project-relative paths, breadth-first; a directory carries a trailing `/`.
|
|
85
|
+
*/
|
|
86
|
+
readonly paths: readonly string[];
|
|
87
|
+
/** Directory entries inspected, whether or not they became candidates. */
|
|
88
|
+
readonly entriesSeen: number;
|
|
89
|
+
/** True when a bound stopped the scan before the tree ran out. */
|
|
90
|
+
readonly truncated: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Why the reading is partial for a reason other than a bound — an unreadable
|
|
93
|
+
* root, typically. Undefined for a complete scan, like the other bounded
|
|
94
|
+
* loaders in this project.
|
|
95
|
+
*/
|
|
96
|
+
readonly problem: string | undefined;
|
|
97
|
+
}
|
|
98
|
+
/** The reading used before any scan has finished: offers nothing, says nothing. */
|
|
99
|
+
export declare const NO_WORKSPACE_PATHS: WorkspacePaths;
|
|
100
|
+
/**
|
|
101
|
+
* Lists the project's paths, breadth-first and bounded.
|
|
102
|
+
*
|
|
103
|
+
* Breadth-first for two reasons: the shallow paths are the ones a person completes,
|
|
104
|
+
* and it makes truncation drop the deepest entries rather than an arbitrary subtree.
|
|
105
|
+
* Bounded three ways — {@link MAX_SCAN_ENTRIES}, {@link MAX_SCAN_DEPTH},
|
|
106
|
+
* {@link MAX_PATH_CANDIDATES} — and reporting which bound it hit, because a menu
|
|
107
|
+
* that silently shows a subset of the workspace is a menu that lies.
|
|
108
|
+
*
|
|
109
|
+
* Never throws. A directory that cannot be read is skipped and the rest is still
|
|
110
|
+
* offered: `resource-safety.ts` refuses activation on the same conditions because a
|
|
111
|
+
* skill about to run is a security boundary, while a completion list degrading to
|
|
112
|
+
* fewer rows must never stop somebody typing.
|
|
113
|
+
*
|
|
114
|
+
* Symlinks are never traversed, and are offered only when they resolve inside the
|
|
115
|
+
* project root — the scan of a workspace must not be able to name a path outside it.
|
|
116
|
+
*/
|
|
117
|
+
export declare function scanWorkspacePaths(projectRoot: string): Promise<WorkspacePaths>;
|
|
118
|
+
/** One line stating what a bounded or degraded reading is not showing. */
|
|
119
|
+
export declare function workspacePathsNote(reading: WorkspacePaths): string | undefined;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@` path completion: which workspace paths the editor offers, and what accepting
|
|
3
|
+
* one does to the draft.
|
|
4
|
+
*
|
|
5
|
+
* The product decision this file encodes is *path text, never file content*. Three
|
|
6
|
+
* peers offer `@` in a composer and disagree about what follows: Codex inserts the
|
|
7
|
+
* path, OpenCode inlines the file's bytes, Claude Code autocompletes the path.
|
|
8
|
+
* Darwin takes the Codex shape deliberately — every byte of file content keeps
|
|
9
|
+
* flowing through the existing `fileEditor` read, which is classified, gated and
|
|
10
|
+
* recorded in the trajectory, while inlining would be a second, ungated route for
|
|
11
|
+
* file content into the model's context. So nothing here opens a file: the scan
|
|
12
|
+
* reads *directory entries* (`opendir`/`lstat`/`realpath`) and nothing else.
|
|
13
|
+
*
|
|
14
|
+
* The split matters for testing. Everything the editor does per keystroke —
|
|
15
|
+
* recognizing a trigger, matching a prefix, rewriting the draft — is pure and
|
|
16
|
+
* synchronous ({@link pathCompletionQuery}, {@link matchWorkspacePaths},
|
|
17
|
+
* {@link applyPathCompletion}), exactly like `computeCompletions`. The one thing
|
|
18
|
+
* that touches the filesystem ({@link scanWorkspacePaths}) is asynchronous, bounded
|
|
19
|
+
* and cached by the caller, because a keystroke must never wait on a tree that may
|
|
20
|
+
* hold a `node_modules`.
|
|
21
|
+
*/
|
|
22
|
+
import { opendir, realpath } from 'node:fs/promises';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { snapCursor } from './prompt-editor.js';
|
|
25
|
+
/** The character that opens a path query. */
|
|
26
|
+
export const PATH_TRIGGER = '@';
|
|
27
|
+
/**
|
|
28
|
+
* Longest query treated as a path prefix.
|
|
29
|
+
*
|
|
30
|
+
* A token this long is prose, a URL or a pasted blob, not something a person is
|
|
31
|
+
* completing — and matching it against every candidate on every keystroke is work
|
|
32
|
+
* with a guaranteed empty result.
|
|
33
|
+
*/
|
|
34
|
+
export const MAX_PATH_QUERY_LENGTH = 256;
|
|
35
|
+
/** Directory entries the scan may inspect before it stops and says so. */
|
|
36
|
+
export const MAX_SCAN_ENTRIES = 8000;
|
|
37
|
+
/**
|
|
38
|
+
* Levels below the project root the scan may descend.
|
|
39
|
+
*
|
|
40
|
+
* This repository is 6 levels deep excluding the skipped directories, so 8 covers
|
|
41
|
+
* it whole; the bound exists for the tree that does not stop.
|
|
42
|
+
*/
|
|
43
|
+
export const MAX_SCAN_DEPTH = 8;
|
|
44
|
+
/** Candidates kept in memory for matching. */
|
|
45
|
+
export const MAX_PATH_CANDIDATES = 4000;
|
|
46
|
+
/**
|
|
47
|
+
* Directory names a repository scan has no business walking.
|
|
48
|
+
*
|
|
49
|
+
* Neither walked nor offered: a completion for `node_modules/.pnpm/…` is not a path
|
|
50
|
+
* anyone means, and walking it is how typing would come to depend on the size of a
|
|
51
|
+
* dependency tree. Matched by name at any depth.
|
|
52
|
+
*/
|
|
53
|
+
export const EXCLUDED_DIRECTORY_NAMES = new Set([
|
|
54
|
+
'.git',
|
|
55
|
+
'.hg',
|
|
56
|
+
'.svn',
|
|
57
|
+
'.idea',
|
|
58
|
+
'.cache',
|
|
59
|
+
'.gradle',
|
|
60
|
+
'.next',
|
|
61
|
+
'.nuxt',
|
|
62
|
+
'.pnpm-store',
|
|
63
|
+
'.turbo',
|
|
64
|
+
'.venv',
|
|
65
|
+
'.yarn',
|
|
66
|
+
'__pycache__',
|
|
67
|
+
'build',
|
|
68
|
+
'coverage',
|
|
69
|
+
'dist',
|
|
70
|
+
'node_modules',
|
|
71
|
+
'out',
|
|
72
|
+
'target',
|
|
73
|
+
'vendor',
|
|
74
|
+
'venv',
|
|
75
|
+
]);
|
|
76
|
+
/**
|
|
77
|
+
* The `@` query under the cursor, or nothing.
|
|
78
|
+
*
|
|
79
|
+
* A query is open when scanning back from the cursor reaches an `@` without
|
|
80
|
+
* crossing whitespace, *and* the character before that `@` is the start of the
|
|
81
|
+
* draft or whitespace. That one rule is what keeps the menu out of prose:
|
|
82
|
+
* `user@example.com` has `r` before the `@`, and so does every decorator or handle
|
|
83
|
+
* typed inside a word. A newline counts as whitespace, so a multi-line draft
|
|
84
|
+
* triggers per line, and a space typed after the query closes it again — the same
|
|
85
|
+
* "a space ends it" shape `computeCompletions` uses for commands.
|
|
86
|
+
*
|
|
87
|
+
* Recognizing a trigger is not the same as opening a menu: a query that matches no
|
|
88
|
+
* workspace path offers no rows at all, which is what makes `@someone` in a
|
|
89
|
+
* sentence a no-op rather than a hijacked keyboard.
|
|
90
|
+
*/
|
|
91
|
+
export function pathCompletionQuery(text, cursorOffset) {
|
|
92
|
+
const cursor = Math.max(0, Math.min(text.length, cursorOffset));
|
|
93
|
+
let index = cursor - 1;
|
|
94
|
+
while (index >= 0) {
|
|
95
|
+
const character = text[index];
|
|
96
|
+
if (isWhitespace(character))
|
|
97
|
+
return undefined;
|
|
98
|
+
if (character === PATH_TRIGGER)
|
|
99
|
+
break;
|
|
100
|
+
index -= 1;
|
|
101
|
+
}
|
|
102
|
+
if (index < 0)
|
|
103
|
+
return undefined;
|
|
104
|
+
const before = index === 0 ? undefined : text[index - 1];
|
|
105
|
+
if (before !== undefined && !isWhitespace(before))
|
|
106
|
+
return undefined;
|
|
107
|
+
const query = text.slice(index + 1, cursor);
|
|
108
|
+
if (query.length > MAX_PATH_QUERY_LENGTH)
|
|
109
|
+
return undefined;
|
|
110
|
+
return { start: index, end: cursor, text: query };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Candidates matching a query, best first.
|
|
114
|
+
*
|
|
115
|
+
* Two tiers, no scoring: paths that start with the query, then — only when the
|
|
116
|
+
* query names no directory of its own — paths whose *last segment* starts with it,
|
|
117
|
+
* so `@InputBox` finds `src/tui/InputBox.tsx` without anyone having to type the
|
|
118
|
+
* directories. Both tiers are case-insensitive and keep the candidate order they
|
|
119
|
+
* were scanned in, which is breadth-first, so shallow paths come first. Fuzzy
|
|
120
|
+
* matching is deliberately absent: a menu whose top row moves for reasons the user
|
|
121
|
+
* cannot see is worse than one they can predict.
|
|
122
|
+
*
|
|
123
|
+
* Every match is returned. The list is already bounded by {@link MAX_PATH_CANDIDATES},
|
|
124
|
+
* and the caller needs the true total to say how many rows it is not showing.
|
|
125
|
+
*/
|
|
126
|
+
export function matchWorkspacePaths(candidates, query) {
|
|
127
|
+
const needle = normalizeQuery(query).toLowerCase();
|
|
128
|
+
if (needle === '')
|
|
129
|
+
return [...candidates];
|
|
130
|
+
const byPath = [];
|
|
131
|
+
const byBasename = [];
|
|
132
|
+
const wantsBasenames = !needle.includes('/');
|
|
133
|
+
for (const candidate of candidates) {
|
|
134
|
+
const lowered = candidate.toLowerCase();
|
|
135
|
+
if (lowered.startsWith(needle))
|
|
136
|
+
byPath.push(candidate);
|
|
137
|
+
else if (wantsBasenames && basename(lowered).startsWith(needle))
|
|
138
|
+
byBasename.push(candidate);
|
|
139
|
+
}
|
|
140
|
+
return [...byPath, ...byBasename];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The draft with the accepted path in place of the `@` token.
|
|
144
|
+
*
|
|
145
|
+
* The `@` is scaffolding, not content: accepting a **file** replaces the whole token
|
|
146
|
+
* with the plain path and one space, which is the text a person would have typed;
|
|
147
|
+
* accepting a **directory** keeps the marker (`@src/`) so the next keystroke carries
|
|
148
|
+
* on completing inside it. Nothing else about the draft moves, and nothing is read
|
|
149
|
+
* from the path itself — this function only ever touches strings.
|
|
150
|
+
*/
|
|
151
|
+
export function applyPathCompletion(value, query, chosen) {
|
|
152
|
+
const isDirectory = chosen.endsWith('/');
|
|
153
|
+
const inserted = isDirectory ? `${PATH_TRIGGER}${chosen}` : `${chosen} `;
|
|
154
|
+
const start = Math.max(0, Math.min(value.text.length, query.start));
|
|
155
|
+
const end = Math.max(start, Math.min(value.text.length, query.end));
|
|
156
|
+
const text = value.text.slice(0, start) + inserted + value.text.slice(end);
|
|
157
|
+
return { text, cursor: snapCursor(text, { offset: start + inserted.length, affinity: 'upstream' }) };
|
|
158
|
+
}
|
|
159
|
+
/** The reading used before any scan has finished: offers nothing, says nothing. */
|
|
160
|
+
export const NO_WORKSPACE_PATHS = {
|
|
161
|
+
paths: [],
|
|
162
|
+
entriesSeen: 0,
|
|
163
|
+
truncated: false,
|
|
164
|
+
problem: undefined,
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Lists the project's paths, breadth-first and bounded.
|
|
168
|
+
*
|
|
169
|
+
* Breadth-first for two reasons: the shallow paths are the ones a person completes,
|
|
170
|
+
* and it makes truncation drop the deepest entries rather than an arbitrary subtree.
|
|
171
|
+
* Bounded three ways — {@link MAX_SCAN_ENTRIES}, {@link MAX_SCAN_DEPTH},
|
|
172
|
+
* {@link MAX_PATH_CANDIDATES} — and reporting which bound it hit, because a menu
|
|
173
|
+
* that silently shows a subset of the workspace is a menu that lies.
|
|
174
|
+
*
|
|
175
|
+
* Never throws. A directory that cannot be read is skipped and the rest is still
|
|
176
|
+
* offered: `resource-safety.ts` refuses activation on the same conditions because a
|
|
177
|
+
* skill about to run is a security boundary, while a completion list degrading to
|
|
178
|
+
* fewer rows must never stop somebody typing.
|
|
179
|
+
*
|
|
180
|
+
* Symlinks are never traversed, and are offered only when they resolve inside the
|
|
181
|
+
* project root — the scan of a workspace must not be able to name a path outside it.
|
|
182
|
+
*/
|
|
183
|
+
export async function scanWorkspacePaths(projectRoot) {
|
|
184
|
+
const root = path.resolve(projectRoot);
|
|
185
|
+
let realRoot;
|
|
186
|
+
try {
|
|
187
|
+
realRoot = await realpath(root);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
return { ...NO_WORKSPACE_PATHS, problem: describe(error) };
|
|
191
|
+
}
|
|
192
|
+
const paths = [];
|
|
193
|
+
let entriesSeen = 0;
|
|
194
|
+
let truncated = false;
|
|
195
|
+
let problem;
|
|
196
|
+
/** Project-relative directories still to read, shallowest first. */
|
|
197
|
+
let level = [''];
|
|
198
|
+
for (let depth = 0; depth < MAX_SCAN_DEPTH && level.length > 0; depth += 1) {
|
|
199
|
+
const next = [];
|
|
200
|
+
for (const relative of level) {
|
|
201
|
+
if (entriesSeen >= MAX_SCAN_ENTRIES || paths.length >= MAX_PATH_CANDIDATES) {
|
|
202
|
+
truncated = true;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
const outcome = await readLevel(root, realRoot, relative);
|
|
206
|
+
if (outcome.problem !== undefined) {
|
|
207
|
+
problem ??= outcome.problem;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
for (const entry of outcome.entries) {
|
|
211
|
+
entriesSeen += 1;
|
|
212
|
+
if (entriesSeen > MAX_SCAN_ENTRIES) {
|
|
213
|
+
truncated = true;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
if (entry.excluded)
|
|
217
|
+
continue;
|
|
218
|
+
if (paths.length >= MAX_PATH_CANDIDATES) {
|
|
219
|
+
truncated = true;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
paths.push(entry.directory ? `${entry.relative}/` : entry.relative);
|
|
223
|
+
if (entry.directory)
|
|
224
|
+
next.push(entry.relative);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (truncated)
|
|
228
|
+
break;
|
|
229
|
+
level = next;
|
|
230
|
+
}
|
|
231
|
+
// Depth, not entries: unread directories were reached but never descended into.
|
|
232
|
+
if (!truncated && level.length > 0)
|
|
233
|
+
truncated = true;
|
|
234
|
+
return { paths, entriesSeen, truncated, problem };
|
|
235
|
+
}
|
|
236
|
+
/** One line stating what a bounded or degraded reading is not showing. */
|
|
237
|
+
export function workspacePathsNote(reading) {
|
|
238
|
+
if (reading.problem !== undefined)
|
|
239
|
+
return `partial scan: ${reading.problem}`;
|
|
240
|
+
if (reading.truncated)
|
|
241
|
+
return `bounded scan: ${reading.paths.length} paths`;
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
async function readLevel(root, realRoot, relative) {
|
|
245
|
+
const directory = relative === '' ? root : path.join(root, relative);
|
|
246
|
+
let handle;
|
|
247
|
+
try {
|
|
248
|
+
handle = await opendir(directory);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
return { entries: [], problem: describe(error) };
|
|
252
|
+
}
|
|
253
|
+
const entries = [];
|
|
254
|
+
try {
|
|
255
|
+
for await (const entry of handle) {
|
|
256
|
+
const child = relative === '' ? entry.name : `${relative}/${entry.name}`;
|
|
257
|
+
if (entry.isSymbolicLink()) {
|
|
258
|
+
entries.push({ relative: child, directory: false, excluded: !(await resolvesInside(realRoot, path.join(directory, entry.name))) });
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const isDirectory = entry.isDirectory();
|
|
262
|
+
entries.push({
|
|
263
|
+
relative: child,
|
|
264
|
+
directory: isDirectory,
|
|
265
|
+
excluded: isDirectory && EXCLUDED_DIRECTORY_NAMES.has(entry.name),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
return { entries, problem: describe(error) };
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
await handle.close().catch(() => { });
|
|
274
|
+
}
|
|
275
|
+
entries.sort((left, right) => left.relative.localeCompare(right.relative));
|
|
276
|
+
return { entries, problem: undefined };
|
|
277
|
+
}
|
|
278
|
+
/** A link is offered only when what it points at is still inside the project. */
|
|
279
|
+
async function resolvesInside(realRoot, link) {
|
|
280
|
+
try {
|
|
281
|
+
return isInside(realRoot, await realpath(link));
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function isInside(root, candidate) {
|
|
288
|
+
const relative = path.relative(root, candidate);
|
|
289
|
+
return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
|
|
290
|
+
}
|
|
291
|
+
function normalizeQuery(query) {
|
|
292
|
+
return query.startsWith('./') ? query.slice(2) : query;
|
|
293
|
+
}
|
|
294
|
+
function basename(candidate) {
|
|
295
|
+
const trimmed = candidate.endsWith('/') ? candidate.slice(0, -1) : candidate;
|
|
296
|
+
const slash = trimmed.lastIndexOf('/');
|
|
297
|
+
return slash === -1 ? trimmed : trimmed.slice(slash + 1);
|
|
298
|
+
}
|
|
299
|
+
function isWhitespace(character) {
|
|
300
|
+
return /\s/.test(character);
|
|
301
|
+
}
|
|
302
|
+
function describe(error) {
|
|
303
|
+
return error instanceof Error ? error.message : String(error);
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=path-completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-completion.js","sourceRoot":"","sources":["../../../src/tui/path-completion.ts"],"names":[],"mappings":"AAAA;;;;;;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CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7E,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,YAAY,CAAC,SAAiB;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges the async {@link PermissionBridge} contract to React state.
|
|
3
|
+
*
|
|
4
|
+
* The gate awaits a promise deep inside the agent loop; the UI resolves it from a
|
|
5
|
+
* keypress handler. This queue is the seam between them, and lives outside React
|
|
6
|
+
* so the bridge can be handed to `AgentRuntime.create()` before any component
|
|
7
|
+
* mounts.
|
|
8
|
+
*
|
|
9
|
+
* Requests are serialized: concurrent tool calls each get their own prompt, one
|
|
10
|
+
* at a time, so two confirmations can never race for the same keystroke.
|
|
11
|
+
*
|
|
12
|
+
* One request can also leave without being answered: `request.withdrawn` fires when
|
|
13
|
+
* the user changes the permission mode, and the entry is dropped so the question
|
|
14
|
+
* asked under the old policy cannot stay on screen.
|
|
15
|
+
*/
|
|
16
|
+
import type { AssessedPermissionRequest, PermissionBridge, PermissionDecision } from '../agent/permission.js';
|
|
17
|
+
export declare class PermissionQueue {
|
|
18
|
+
private observe?;
|
|
19
|
+
private observedIdentities;
|
|
20
|
+
constructor(observe?: ((request: AssessedPermissionRequest) => void) | undefined);
|
|
21
|
+
/** Installs a session-owned observer; `/clear` starts a fresh identity scope. */
|
|
22
|
+
setObserver(observe: ((request: AssessedPermissionRequest) => void) | undefined): void;
|
|
23
|
+
private readonly entries;
|
|
24
|
+
private readonly listeners;
|
|
25
|
+
/** Set once the session is over, so late requests deny instead of hanging. */
|
|
26
|
+
private closed;
|
|
27
|
+
/** The {@link PermissionBridge} to hand to the runtime. */
|
|
28
|
+
readonly bridge: PermissionBridge;
|
|
29
|
+
/** The request currently awaiting an answer, if any. */
|
|
30
|
+
get current(): AssessedPermissionRequest | undefined;
|
|
31
|
+
/** How many requests are waiting behind the current one. */
|
|
32
|
+
get waiting(): number;
|
|
33
|
+
/** Answers the current request. No-op when nothing is pending. */
|
|
34
|
+
answer(decision: PermissionDecision): void;
|
|
35
|
+
/**
|
|
36
|
+
* Denies everything still queued, leaving the queue usable.
|
|
37
|
+
*
|
|
38
|
+
* For cancelling a turn: the agent loop may be blocked on a prompt the user has
|
|
39
|
+
* just abandoned, but the session continues and later turns must still be able
|
|
40
|
+
* to ask.
|
|
41
|
+
*/
|
|
42
|
+
denyPending(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Denies everything queued and refuses future requests. Called on shutdown, so
|
|
45
|
+
* a tool call racing the exit cannot leave the agent loop waiting forever on a
|
|
46
|
+
* prompt nobody will answer.
|
|
47
|
+
*/
|
|
48
|
+
close(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Drops one entry wherever it sits, current or queued, and lets whatever is
|
|
51
|
+
* behind it take the screen. Used only for withdrawal: the promise is settled so
|
|
52
|
+
* the awaiting gate is not left holding it, and the gate discards the value
|
|
53
|
+
* because the withdrawal signal already fired.
|
|
54
|
+
*/
|
|
55
|
+
private remove;
|
|
56
|
+
subscribe(listener: () => void): () => void;
|
|
57
|
+
/** Identity changes whenever the queue changes, for useSyncExternalStore. */
|
|
58
|
+
getSnapshot: () => AssessedPermissionRequest | undefined;
|
|
59
|
+
private observeCurrent;
|
|
60
|
+
private emit;
|
|
61
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export class PermissionQueue {
|
|
2
|
+
observe;
|
|
3
|
+
observedIdentities = new WeakSet();
|
|
4
|
+
constructor(observe) {
|
|
5
|
+
this.observe = observe;
|
|
6
|
+
}
|
|
7
|
+
/** Installs a session-owned observer; `/clear` starts a fresh identity scope. */
|
|
8
|
+
setObserver(observe) {
|
|
9
|
+
this.observe = observe;
|
|
10
|
+
this.observedIdentities = new WeakSet();
|
|
11
|
+
this.observeCurrent();
|
|
12
|
+
}
|
|
13
|
+
entries = [];
|
|
14
|
+
listeners = new Set();
|
|
15
|
+
/** Set once the session is over, so late requests deny instead of hanging. */
|
|
16
|
+
closed = false;
|
|
17
|
+
/** The {@link PermissionBridge} to hand to the runtime. */
|
|
18
|
+
bridge = (request) => new Promise((resolve) => {
|
|
19
|
+
if (this.closed || request.withdrawn.aborted) {
|
|
20
|
+
resolve({ allowed: false });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const entry = { request, resolve, release: () => undefined, observed: false };
|
|
24
|
+
// A mode change withdraws the question itself: the gate has stopped waiting
|
|
25
|
+
// and will re-decide the call under the new mode, so the prompt has to leave
|
|
26
|
+
// the screen. Resolving it is bookkeeping — the gate discards this answer.
|
|
27
|
+
const onWithdraw = () => {
|
|
28
|
+
this.remove(entry);
|
|
29
|
+
};
|
|
30
|
+
request.withdrawn.addEventListener('abort', onWithdraw, { once: true });
|
|
31
|
+
entry.release = () => {
|
|
32
|
+
request.withdrawn.removeEventListener('abort', onWithdraw);
|
|
33
|
+
};
|
|
34
|
+
this.entries.push(entry);
|
|
35
|
+
this.observeCurrent();
|
|
36
|
+
this.emit();
|
|
37
|
+
});
|
|
38
|
+
/** The request currently awaiting an answer, if any. */
|
|
39
|
+
get current() {
|
|
40
|
+
return this.entries[0]?.request;
|
|
41
|
+
}
|
|
42
|
+
/** How many requests are waiting behind the current one. */
|
|
43
|
+
get waiting() {
|
|
44
|
+
return Math.max(0, this.entries.length - 1);
|
|
45
|
+
}
|
|
46
|
+
/** Answers the current request. No-op when nothing is pending. */
|
|
47
|
+
answer(decision) {
|
|
48
|
+
const entry = this.entries.shift();
|
|
49
|
+
if (entry === undefined)
|
|
50
|
+
return;
|
|
51
|
+
entry.release();
|
|
52
|
+
entry.resolve(decision);
|
|
53
|
+
this.observeCurrent();
|
|
54
|
+
this.emit();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Denies everything still queued, leaving the queue usable.
|
|
58
|
+
*
|
|
59
|
+
* For cancelling a turn: the agent loop may be blocked on a prompt the user has
|
|
60
|
+
* just abandoned, but the session continues and later turns must still be able
|
|
61
|
+
* to ask.
|
|
62
|
+
*/
|
|
63
|
+
denyPending() {
|
|
64
|
+
while (this.entries.length > 0) {
|
|
65
|
+
const entry = this.entries.shift();
|
|
66
|
+
if (entry === undefined)
|
|
67
|
+
continue;
|
|
68
|
+
entry.release();
|
|
69
|
+
entry.resolve({ allowed: false });
|
|
70
|
+
}
|
|
71
|
+
this.emit();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Denies everything queued and refuses future requests. Called on shutdown, so
|
|
75
|
+
* a tool call racing the exit cannot leave the agent loop waiting forever on a
|
|
76
|
+
* prompt nobody will answer.
|
|
77
|
+
*/
|
|
78
|
+
close() {
|
|
79
|
+
this.closed = true;
|
|
80
|
+
this.denyPending();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Drops one entry wherever it sits, current or queued, and lets whatever is
|
|
84
|
+
* behind it take the screen. Used only for withdrawal: the promise is settled so
|
|
85
|
+
* the awaiting gate is not left holding it, and the gate discards the value
|
|
86
|
+
* because the withdrawal signal already fired.
|
|
87
|
+
*/
|
|
88
|
+
remove(entry) {
|
|
89
|
+
const index = this.entries.indexOf(entry);
|
|
90
|
+
if (index === -1)
|
|
91
|
+
return;
|
|
92
|
+
this.entries.splice(index, 1);
|
|
93
|
+
entry.release();
|
|
94
|
+
entry.resolve({ allowed: false });
|
|
95
|
+
this.observeCurrent();
|
|
96
|
+
this.emit();
|
|
97
|
+
}
|
|
98
|
+
subscribe(listener) {
|
|
99
|
+
this.listeners.add(listener);
|
|
100
|
+
return () => {
|
|
101
|
+
this.listeners.delete(listener);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** Identity changes whenever the queue changes, for useSyncExternalStore. */
|
|
105
|
+
getSnapshot = () => this.current;
|
|
106
|
+
observeCurrent() {
|
|
107
|
+
const entry = this.entries[0];
|
|
108
|
+
if (entry === undefined || entry.observed || this.closed)
|
|
109
|
+
return;
|
|
110
|
+
entry.observed = true;
|
|
111
|
+
const identity = entry.request.promptIdentity;
|
|
112
|
+
if (identity !== undefined) {
|
|
113
|
+
if (this.observedIdentities.has(identity))
|
|
114
|
+
return;
|
|
115
|
+
this.observedIdentities.add(identity);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
this.observe?.(entry.request);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// Observation can never alter or strand the permission decision.
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
emit() {
|
|
125
|
+
for (const listener of this.listeners)
|
|
126
|
+
listener();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=permission-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-queue.js","sourceRoot":"","sources":["../../../src/tui/permission-queue.ts"],"names":[],"mappings":"AA6BA,MAAM,OAAO,eAAe;IAGN,OAAO;IAFnB,kBAAkB,GAAG,IAAI,OAAO,EAAU,CAAC;IAEnD,YAAoB,OAAsD;uBAAtD,OAAO;IAAkD,CAAC;IAE9E,iFAAiF;IACjF,WAAW,CAAC,OAAmE;QAC7E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAU,CAAC;QAChD,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CA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are function planItemText(item: PlanItem): string;
|
|
4
|
+
/**
|
|
5
|
+
* A plan block consumes one title row and item rows. If the grant cannot show the
|
|
6
|
+
* complete list, its final row states exactly how many items are omitted.
|
|
7
|
+
*/
|
|
8
|
+
export declare function planRows(plan: readonly PlanItem[], maxRows: number, title?: string): readonly string[];
|
|
9
|
+
export declare function finalPlanRows(plan: readonly PlanItem[]): readonly string[];
|