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":"task-format.js","sourceRoot":"","sources":["../../../src/tui/task-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAuB,MAAM,6BAA6B,CAAC;AAEnF,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,8FAA8F;AAC9F,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,qFAAqF;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AACxD,MAAM,CAAC,MAAM,4BAA4B,GAAG,sBAAsB,CAAC;AAEnE,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,KAAK,GAAG,+BAA+B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,mGAAmG;AACnG,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,UAAU,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AoB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;AACvK,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config-gated terminal attention bell for the interactive TUI driver.
|
|
3
|
+
*
|
|
4
|
+
* One raw BEL (`\x07`) goes straight to the process's real stdout at the two
|
|
5
|
+
* driver-owned moments a detached user needs back: a permission prompt being
|
|
6
|
+
* published to the screen, and a turn completing. BEL is a non-printing control
|
|
7
|
+
* byte, so it is never an Ink row — the frame budget, ANSI-stripped pty
|
|
8
|
+
* assertions, `/export` byte-stability and replay are all untouched.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately not wired anywhere else: never per frame render, never in the
|
|
11
|
+
* headless drivers (`-p`/structured), never for child agents, and never inside
|
|
12
|
+
* lifecycle hook command execution. Disabled (the default) performs no write at
|
|
13
|
+
* all, so the off path stays byte-identical to before the feature existed.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TERMINAL_BELL = "\u0007";
|
|
16
|
+
/**
|
|
17
|
+
* Writes exactly one BEL when `enabled`, nothing otherwise. The injectable
|
|
18
|
+
* writer exists only for tests; production callers use the real stdout.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ringTerminalBell(enabled: boolean, write?: (chunk: string) => void): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config-gated terminal attention bell for the interactive TUI driver.
|
|
3
|
+
*
|
|
4
|
+
* One raw BEL (`\x07`) goes straight to the process's real stdout at the two
|
|
5
|
+
* driver-owned moments a detached user needs back: a permission prompt being
|
|
6
|
+
* published to the screen, and a turn completing. BEL is a non-printing control
|
|
7
|
+
* byte, so it is never an Ink row — the frame budget, ANSI-stripped pty
|
|
8
|
+
* assertions, `/export` byte-stability and replay are all untouched.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately not wired anywhere else: never per frame render, never in the
|
|
11
|
+
* headless drivers (`-p`/structured), never for child agents, and never inside
|
|
12
|
+
* lifecycle hook command execution. Disabled (the default) performs no write at
|
|
13
|
+
* all, so the off path stays byte-identical to before the feature existed.
|
|
14
|
+
*/
|
|
15
|
+
export const TERMINAL_BELL = '\u0007';
|
|
16
|
+
/**
|
|
17
|
+
* Writes exactly one BEL when `enabled`, nothing otherwise. The injectable
|
|
18
|
+
* writer exists only for tests; production callers use the real stdout.
|
|
19
|
+
*/
|
|
20
|
+
export function ringTerminalBell(enabled, write = writeToStdout) {
|
|
21
|
+
if (!enabled)
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
write(TERMINAL_BELL);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// A closed or broken stdout must never take down the session for a chime.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function writeToStdout(chunk) {
|
|
31
|
+
process.stdout.write(chunk);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=terminal-bell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-bell.js","sourceRoot":"","sources":["../../../src/tui/terminal-bell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAgB,EAChB,KAAK,GAA4B,aAAa;IAE9C,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC;QACH,KAAK,CAAC,aAAa,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;IAC5E,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Bounded, Unicode-safe presentation of tool inputs and results. */
|
|
2
|
+
export type ToolPreviewStatus = 'ok' | 'error' | 'denied';
|
|
3
|
+
export declare const COMPACT_RESULT_CODE_POINTS = 2000;
|
|
4
|
+
export declare const COMPACT_RESULT_LINES = 4;
|
|
5
|
+
export declare const EXPANDED_INPUT_CODE_POINTS = 8000;
|
|
6
|
+
export declare const EXPANDED_INPUT_LINES = 100;
|
|
7
|
+
export declare const EXPANDED_RESULT_CODE_POINTS = 32000;
|
|
8
|
+
export declare const EXPANDED_RESULT_LINES = 200;
|
|
9
|
+
export declare const PERMISSION_DETAIL_CODE_POINTS = 500;
|
|
10
|
+
export declare const PERMISSION_DETAIL_LINES = 14;
|
|
11
|
+
export declare const PERMISSION_SUMMARY_CODE_POINTS = 160;
|
|
12
|
+
export interface TextBounds {
|
|
13
|
+
codePoints: number;
|
|
14
|
+
lines: number;
|
|
15
|
+
}
|
|
16
|
+
/** Permission summary, bounded as one rendered headline. */
|
|
17
|
+
export declare function permissionSummary(summary: string): string;
|
|
18
|
+
/** Permission detail, bounded without changing any short source value. */
|
|
19
|
+
export declare function permissionDetail(value: string): string[];
|
|
20
|
+
/** JSON when possible, a defensive string fallback otherwise. */
|
|
21
|
+
export declare function serializeToolInput(input: unknown): string;
|
|
22
|
+
/**
|
|
23
|
+
* Expanded tool input, bounded from the head because inputs read in source order.
|
|
24
|
+
*
|
|
25
|
+
* A `fileEditor` write is projected as labelled header lines plus the marker-
|
|
26
|
+
* prefixed line diff of the same input — the identical strings the JSON carried,
|
|
27
|
+
* in the shape the permission box already presents — and falls back to JSON for
|
|
28
|
+
* anything the diff reader does not recognize. Presentation-time only: the SDK
|
|
29
|
+
* retains and receives the original input object either way.
|
|
30
|
+
*/
|
|
31
|
+
export declare function expandedToolInput(input: unknown, toolName?: string): string[];
|
|
32
|
+
/** Result preview for the mode selected when the call completed. */
|
|
33
|
+
export declare function toolResultPreview(preview: string, status: ToolPreviewStatus, expanded: boolean): string[];
|
|
34
|
+
/**
|
|
35
|
+
* The diff a finished `fileEditor` write shows in default compact mode —
|
|
36
|
+
* SER-023's answer to `inputPreview: ''`, which showed no diff at all for an
|
|
37
|
+
* auto-approved edit — shown **complete, never truncated**.
|
|
38
|
+
*
|
|
39
|
+
* Finished tool rows are written once into `<Static>` scrollback and never
|
|
40
|
+
* redrawn, so a large diff costs scrollback length, not live-frame rows — the
|
|
41
|
+
* frame budget only governs what is repainted. The live surfaces (the active
|
|
42
|
+
* tool panel and the permission box) keep their existing bounds; this
|
|
43
|
+
* projection is for history rows only.
|
|
44
|
+
*
|
|
45
|
+
* Returns `[]` for anything that is not a `fileEditor` write the diff reader
|
|
46
|
+
* recognizes — those keep today's no-input compact presentation.
|
|
47
|
+
*/
|
|
48
|
+
export declare function compactEditDiff(input: unknown, toolName?: string): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Applies independent logical-line and code-point caps without splitting a
|
|
51
|
+
* surrogate pair. Success keeps the head, errors the tail, and denials retain
|
|
52
|
+
* their leading reason plus the diagnostic tail.
|
|
53
|
+
*/
|
|
54
|
+
export declare function boundText(text: string, status: ToolPreviewStatus, bounds: TextBounds): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Exported for `shell-command.ts`, whose collection cap can drop output that
|
|
57
|
+
* `boundText` never saw: the `!` projection recomputes this marker over the true
|
|
58
|
+
* totals so the one truncation vocabulary never understates.
|
|
59
|
+
*/
|
|
60
|
+
export declare function truncationMarker(omittedPoints: number, omittedLines: number): string;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/** Bounded, Unicode-safe presentation of tool inputs and results. */
|
|
2
|
+
import { REPLACE_ALL_ROW, fileEditorDiff, fileEditorInputProjection, fileEditorReplaceAll } from './edit-diff.js';
|
|
3
|
+
export const COMPACT_RESULT_CODE_POINTS = 2_000;
|
|
4
|
+
export const COMPACT_RESULT_LINES = 4;
|
|
5
|
+
export const EXPANDED_INPUT_CODE_POINTS = 8_000;
|
|
6
|
+
export const EXPANDED_INPUT_LINES = 100;
|
|
7
|
+
export const EXPANDED_RESULT_CODE_POINTS = 32_000;
|
|
8
|
+
export const EXPANDED_RESULT_LINES = 200;
|
|
9
|
+
export const PERMISSION_DETAIL_CODE_POINTS = 500;
|
|
10
|
+
export const PERMISSION_DETAIL_LINES = 14;
|
|
11
|
+
export const PERMISSION_SUMMARY_CODE_POINTS = 160;
|
|
12
|
+
/** Permission summary, bounded as one rendered headline. */
|
|
13
|
+
export function permissionSummary(summary) {
|
|
14
|
+
return boundPermissionText(summary, {
|
|
15
|
+
codePoints: PERMISSION_SUMMARY_CODE_POINTS,
|
|
16
|
+
lines: 1,
|
|
17
|
+
}).join('\n');
|
|
18
|
+
}
|
|
19
|
+
/** Permission detail, bounded without changing any short source value. */
|
|
20
|
+
export function permissionDetail(value) {
|
|
21
|
+
return boundPermissionText(value, {
|
|
22
|
+
codePoints: PERMISSION_DETAIL_CODE_POINTS,
|
|
23
|
+
lines: PERMISSION_DETAIL_LINES,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Head projection for security-sensitive permission text. Unlike tool previews,
|
|
28
|
+
* short blank values are significant and the explicit marker consumes the same
|
|
29
|
+
* line/code-point budgets as retained source content.
|
|
30
|
+
*/
|
|
31
|
+
function boundPermissionText(text, bounds) {
|
|
32
|
+
const sourceLines = text.split('\n');
|
|
33
|
+
const sourcePoints = [...text];
|
|
34
|
+
if (sourceLines.length <= bounds.lines && sourcePoints.length <= bounds.codePoints) {
|
|
35
|
+
return sourceLines;
|
|
36
|
+
}
|
|
37
|
+
const markerOwnsLine = bounds.lines > 1;
|
|
38
|
+
const contentLines = markerOwnsLine ? bounds.lines - 1 : 1;
|
|
39
|
+
let marker = permissionTruncationMarker(sourcePoints.length, sourceLines.length - 1);
|
|
40
|
+
let kept = '';
|
|
41
|
+
// Omission counts affect marker width, which affects retained content. Iterate
|
|
42
|
+
// to the tiny fixed point rather than allowing a digit boundary to exceed the cap.
|
|
43
|
+
for (;;) {
|
|
44
|
+
// A newline (detail) or space (summary) separates retained content from marker.
|
|
45
|
+
const separatorPoints = kept === '' ? 0 : 1;
|
|
46
|
+
const contentBudget = Math.max(0, bounds.codePoints - [...marker].length - separatorPoints);
|
|
47
|
+
kept = takeHead(sourceLines, contentLines, contentBudget).join('\n');
|
|
48
|
+
const keptLines = kept === '' ? 0 : kept.split('\n').length;
|
|
49
|
+
const next = permissionTruncationMarker(sourcePoints.length - [...kept].length, Math.max(0, sourceLines.length - keptLines));
|
|
50
|
+
if (next === marker)
|
|
51
|
+
break;
|
|
52
|
+
marker = next;
|
|
53
|
+
}
|
|
54
|
+
if (!markerOwnsLine)
|
|
55
|
+
return [`${kept}${kept === '' ? '' : ' '}${marker}`];
|
|
56
|
+
return kept === '' ? [marker] : [...kept.split('\n'), marker];
|
|
57
|
+
}
|
|
58
|
+
function permissionTruncationMarker(omittedPoints, omittedLines) {
|
|
59
|
+
const points = `${omittedPoints} code point${omittedPoints === 1 ? '' : 's'}`;
|
|
60
|
+
const lines = omittedLines === 0
|
|
61
|
+
? ''
|
|
62
|
+
: ` and ${omittedLines} line${omittedLines === 1 ? '' : 's'}`;
|
|
63
|
+
return `… truncated ${points}${lines}`;
|
|
64
|
+
}
|
|
65
|
+
/** JSON when possible, a defensive string fallback otherwise. */
|
|
66
|
+
export function serializeToolInput(input) {
|
|
67
|
+
try {
|
|
68
|
+
// Pretty-print in expanded mode so structured input is inspectable and the
|
|
69
|
+
// independent logical-line bound has useful work to do. This is only a TUI
|
|
70
|
+
// projection; the SDK retains and receives the original input object.
|
|
71
|
+
const json = JSON.stringify(input, null, 2);
|
|
72
|
+
if (json !== undefined)
|
|
73
|
+
return json;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Fall through to the one representation still available.
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return String(input);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return '[unprintable input]';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Expanded tool input, bounded from the head because inputs read in source order.
|
|
87
|
+
*
|
|
88
|
+
* A `fileEditor` write is projected as labelled header lines plus the marker-
|
|
89
|
+
* prefixed line diff of the same input — the identical strings the JSON carried,
|
|
90
|
+
* in the shape the permission box already presents — and falls back to JSON for
|
|
91
|
+
* anything the diff reader does not recognize. Presentation-time only: the SDK
|
|
92
|
+
* retains and receives the original input object either way.
|
|
93
|
+
*/
|
|
94
|
+
export function expandedToolInput(input, toolName) {
|
|
95
|
+
const projected = toolName === 'fileEditor' ? fileEditorInputProjection(input) : undefined;
|
|
96
|
+
return boundText(projected ?? serializeToolInput(input), 'ok', {
|
|
97
|
+
codePoints: EXPANDED_INPUT_CODE_POINTS,
|
|
98
|
+
lines: EXPANDED_INPUT_LINES,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Result preview for the mode selected when the call completed. */
|
|
102
|
+
export function toolResultPreview(preview, status, expanded) {
|
|
103
|
+
return boundText(preview, status, expanded
|
|
104
|
+
? { codePoints: EXPANDED_RESULT_CODE_POINTS, lines: EXPANDED_RESULT_LINES }
|
|
105
|
+
: { codePoints: COMPACT_RESULT_CODE_POINTS, lines: COMPACT_RESULT_LINES });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The diff a finished `fileEditor` write shows in default compact mode —
|
|
109
|
+
* SER-023's answer to `inputPreview: ''`, which showed no diff at all for an
|
|
110
|
+
* auto-approved edit — shown **complete, never truncated**.
|
|
111
|
+
*
|
|
112
|
+
* Finished tool rows are written once into `<Static>` scrollback and never
|
|
113
|
+
* redrawn, so a large diff costs scrollback length, not live-frame rows — the
|
|
114
|
+
* frame budget only governs what is repainted. The live surfaces (the active
|
|
115
|
+
* tool panel and the permission box) keep their existing bounds; this
|
|
116
|
+
* projection is for history rows only.
|
|
117
|
+
*
|
|
118
|
+
* Returns `[]` for anything that is not a `fileEditor` write the diff reader
|
|
119
|
+
* recognizes — those keep today's no-input compact presentation.
|
|
120
|
+
*/
|
|
121
|
+
export function compactEditDiff(input, toolName) {
|
|
122
|
+
if (toolName !== 'fileEditor')
|
|
123
|
+
return [];
|
|
124
|
+
const diff = fileEditorDiff(input);
|
|
125
|
+
if (diff === undefined)
|
|
126
|
+
return [];
|
|
127
|
+
// A `replace_all: true` str_replace states its scope on one header row above
|
|
128
|
+
// the bare pair (SER-055) — input-derived, so the finished row can say "every
|
|
129
|
+
// occurrence" without ever reading the file; the stat stays the pair's.
|
|
130
|
+
return [...(fileEditorReplaceAll(input) ? [REPLACE_ALL_ROW] : []), ...diff.split('\n')];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Applies independent logical-line and code-point caps without splitting a
|
|
134
|
+
* surrogate pair. Success keeps the head, errors the tail, and denials retain
|
|
135
|
+
* their leading reason plus the diagnostic tail.
|
|
136
|
+
*/
|
|
137
|
+
export function boundText(text, status, bounds) {
|
|
138
|
+
if (text.trim() === '' || bounds.codePoints <= 0 || bounds.lines <= 0)
|
|
139
|
+
return [];
|
|
140
|
+
const sourceLines = text.split('\n');
|
|
141
|
+
const originalPoints = [...text].length;
|
|
142
|
+
let kept;
|
|
143
|
+
switch (status) {
|
|
144
|
+
case 'ok':
|
|
145
|
+
kept = takeHead(sourceLines, bounds.lines, bounds.codePoints);
|
|
146
|
+
break;
|
|
147
|
+
case 'error':
|
|
148
|
+
kept = takeTail(sourceLines, bounds.lines, bounds.codePoints);
|
|
149
|
+
break;
|
|
150
|
+
case 'denied':
|
|
151
|
+
kept = takeDenied(sourceLines, bounds.lines, bounds.codePoints);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
const keptText = kept.join('\n');
|
|
155
|
+
if (keptText === text)
|
|
156
|
+
return kept;
|
|
157
|
+
const omittedPoints = Math.max(0, originalPoints - [...keptText].length);
|
|
158
|
+
const omittedLines = Math.max(0, sourceLines.length - kept.length);
|
|
159
|
+
const marker = truncationMarker(omittedPoints, omittedLines);
|
|
160
|
+
if (status === 'ok')
|
|
161
|
+
return [...kept, marker];
|
|
162
|
+
if (status === 'error')
|
|
163
|
+
return [marker, ...kept];
|
|
164
|
+
if (kept.length <= 1)
|
|
165
|
+
return [...kept, marker];
|
|
166
|
+
return [kept[0], marker, ...kept.slice(1)];
|
|
167
|
+
}
|
|
168
|
+
function takeHead(lines, lineLimit, pointLimit) {
|
|
169
|
+
const candidate = lines.slice(0, lineLimit).join('\n');
|
|
170
|
+
return [...candidate].slice(0, pointLimit).join('').split('\n');
|
|
171
|
+
}
|
|
172
|
+
function takeTail(lines, lineLimit, pointLimit) {
|
|
173
|
+
const candidate = lines.slice(-lineLimit).join('\n');
|
|
174
|
+
return [...candidate].slice(-pointLimit).join('').split('\n');
|
|
175
|
+
}
|
|
176
|
+
function takeDenied(lines, lineLimit, pointLimit) {
|
|
177
|
+
const first = lines[0] ?? '';
|
|
178
|
+
if (lines.length === 1 || lineLimit === 1) {
|
|
179
|
+
return [[...first].slice(0, pointLimit).join('')];
|
|
180
|
+
}
|
|
181
|
+
const firstPoints = [...first];
|
|
182
|
+
if (firstPoints.length >= pointLimit)
|
|
183
|
+
return [firstPoints.slice(0, pointLimit).join('')];
|
|
184
|
+
const tail = lines.slice(1).slice(-(lineLimit - 1)).join('\n');
|
|
185
|
+
const tailBudget = Math.max(0, pointLimit - firstPoints.length - 1);
|
|
186
|
+
// `slice(-0)` is `slice(0)`, not an empty slice. Without this guard, a
|
|
187
|
+
// denial whose reason consumes all but the separating newline budget would
|
|
188
|
+
// retain its entire tail and bypass the code-point cap.
|
|
189
|
+
if (tailBudget === 0)
|
|
190
|
+
return [first];
|
|
191
|
+
const keptTail = [...tail].slice(-tailBudget).join('');
|
|
192
|
+
return keptTail === '' ? [first] : [first, ...keptTail.split('\n')];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Exported for `shell-command.ts`, whose collection cap can drop output that
|
|
196
|
+
* `boundText` never saw: the `!` projection recomputes this marker over the true
|
|
197
|
+
* totals so the one truncation vocabulary never understates.
|
|
198
|
+
*/
|
|
199
|
+
export function truncationMarker(omittedPoints, omittedLines) {
|
|
200
|
+
const points = `${omittedPoints} code point${omittedPoints === 1 ? '' : 's'}`;
|
|
201
|
+
const lines = omittedLines === 0
|
|
202
|
+
? ''
|
|
203
|
+
: ` and ${omittedLines} line${omittedLines === 1 ? '' : 's'}`;
|
|
204
|
+
return `… truncated ${points}${lines}`;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=tool-detail-presentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-detail-presentation.js","sourceRoot":"","sources":["../../../src/tui/tool-detail-presentation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAIlH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;AAClD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAOlD,4DAA4D;AAC5D,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,mBAAmB,CAAC,OAAO,EAAE;QAClC,UAAU,EAAE,8BAA8B;QAC1C,KAAK,EAAE,CAAC;KACT,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,mBAAmB,CAAC,KAAK,EAAE;QAChC,UAAU,EAAE,6BAA6B;QACzC,K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AAoB;IAC1E,MAAM,MAAM,GAAG,GAAG,aAAa,cAAc,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IAC9E,MAAM,KAAK,GAAG,YAAY,KAAK,CAAC;QAC9B,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,QAAQ,YAAY,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IAChE,OAAO,eAAe,MAAM,GAAG,KAAK,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps SDK stream events onto what the TUI draws.
|
|
3
|
+
*
|
|
4
|
+
* Kept as a pure reducer, separate from the components, so the event mapping can
|
|
5
|
+
* be tested without a terminal — the part most likely to break when the SDK's
|
|
6
|
+
* event shapes change.
|
|
7
|
+
*
|
|
8
|
+
* Event mapping follows the catalog measured in
|
|
9
|
+
* `research/spike-results.md` §4.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentStreamEvent } from '@strands-agents/sdk';
|
|
12
|
+
import { type PlanItem } from '../tools/update-plan.js';
|
|
13
|
+
import { type BackgroundBashMode } from './background-tool-presentation.js';
|
|
14
|
+
import { type ShellOutcome } from './shell-command.js';
|
|
15
|
+
import { type SubagentDispatchProgress } from '../agents/dispatch-registry.js';
|
|
16
|
+
export type HistoryItem = {
|
|
17
|
+
kind: 'user';
|
|
18
|
+
id: string;
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'assistant';
|
|
22
|
+
id: string;
|
|
23
|
+
text: string;
|
|
24
|
+
part: AnswerPart;
|
|
25
|
+
/**
|
|
26
|
+
* Fence state at the start of this piece — true when a fenced code block
|
|
27
|
+
* opened by an earlier piece of the same answer is still open. Decided at
|
|
28
|
+
* push time like {@link AnswerPart}, because `<Static>` never redraws what
|
|
29
|
+
* it wrote; purely presentational (`markdown.ts`), invisible to replay.
|
|
30
|
+
*/
|
|
31
|
+
codeOpen: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'tool';
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
summary: string;
|
|
37
|
+
status: ToolStatus;
|
|
38
|
+
preview: string;
|
|
39
|
+
/** Already bounded before entering immutable transcript history. */
|
|
40
|
+
inputPreview: string;
|
|
41
|
+
expanded: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* `+added/-removed` line counts of a `fileEditor` write's diff, derived from
|
|
44
|
+
* the same markers the diff states (`edit-diff.ts`). Absent means "not a
|
|
45
|
+
* diff", never 0 — non-fileEditor calls and unrecognized shapes carry
|
|
46
|
+
* nothing. Rendering only: `formatReplay` prints `summary`/`preview` alone,
|
|
47
|
+
* so replay and `/export` output stay byte-identical.
|
|
48
|
+
*/
|
|
49
|
+
diffStat?: {
|
|
50
|
+
readonly added: number;
|
|
51
|
+
readonly removed: number;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'notice';
|
|
55
|
+
id: string;
|
|
56
|
+
text: string;
|
|
57
|
+
severity: NoticeSeverity;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'plan';
|
|
60
|
+
id: string;
|
|
61
|
+
plan: readonly PlanItem[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Where one assistant entry sits in its answer.
|
|
65
|
+
*
|
|
66
|
+
* An answer reaches history in pieces now — finished lines are committed to
|
|
67
|
+
* `<Static>` while the rest is still arriving — so the label and the blank row
|
|
68
|
+
* below cannot both belong to every entry, or a 120-line answer becomes 120
|
|
69
|
+
* labelled blocks. `<Static>` never redraws what it wrote, so which piece carries
|
|
70
|
+
* which cannot be decided later: it is decided as each piece is pushed, which is
|
|
71
|
+
* why the last complete line is always held back (see `commitFinishedLines`).
|
|
72
|
+
*
|
|
73
|
+
* - `whole` — the entire answer in one entry: label above, blank row below.
|
|
74
|
+
* - `first` — label, no blank row; more is coming.
|
|
75
|
+
* - `middle` — neither.
|
|
76
|
+
* - `last` — no label, blank row below.
|
|
77
|
+
*/
|
|
78
|
+
export type AnswerPart = 'whole' | 'first' | 'middle' | 'last';
|
|
79
|
+
export type ToolStatus = 'ok' | 'error' | 'denied';
|
|
80
|
+
/**
|
|
81
|
+
* How a notice renders, not what it says: `error` for something that failed
|
|
82
|
+
* outright, `warn` for a degradation the session survives, `info` for the rest.
|
|
83
|
+
*/
|
|
84
|
+
export type NoticeSeverity = 'info' | 'warn' | 'error';
|
|
85
|
+
/** A tool call that has started but not finished. */
|
|
86
|
+
export interface ActiveTool {
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
summary: string;
|
|
90
|
+
/** Epoch ms when the call entered the live panel; drives the elapsed suffix. */
|
|
91
|
+
startedAt: number;
|
|
92
|
+
compactSummary?: string;
|
|
93
|
+
/** Raw only while active; the renderer bounds it before drawing. */
|
|
94
|
+
input: unknown;
|
|
95
|
+
/** Safe registry-only progress for an active delegation row. */
|
|
96
|
+
subagentProgress?: SubagentDispatchProgress;
|
|
97
|
+
backgroundMode?: BackgroundBashMode;
|
|
98
|
+
/**
|
|
99
|
+
* Set when the model routed this delegation to the SDK's background executor
|
|
100
|
+
* (SER-064). `baseSummary` is the row's label without the background marker;
|
|
101
|
+
* `taskId` arrives with the SDK's ack and lets the delivered
|
|
102
|
+
* `strands_background_task_result` pair find this row if no `afterToolCallEvent`
|
|
103
|
+
* ever does.
|
|
104
|
+
*/
|
|
105
|
+
backgroundDelegation?: {
|
|
106
|
+
readonly baseSummary: string;
|
|
107
|
+
readonly taskId?: string;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface TurnState {
|
|
111
|
+
/** Finished entries, rendered once and never redrawn. */
|
|
112
|
+
history: HistoryItem[];
|
|
113
|
+
/** Assistant text still arriving, and not yet committed to history. */
|
|
114
|
+
liveText: string;
|
|
115
|
+
/** Latest terminal-only close preparation committed by React. */
|
|
116
|
+
answerCloseCommit: number;
|
|
117
|
+
/**
|
|
118
|
+
* Text of the in-flight answer already committed to `<Static>`, newlines
|
|
119
|
+
* included, `''` when no piece of the current answer has been written yet.
|
|
120
|
+
*
|
|
121
|
+
* Kept because `<Static>` cannot be taken back: when `contentBlockEvent` closes
|
|
122
|
+
* the answer with the authoritative text, this is what that text is reconciled
|
|
123
|
+
* against — the remainder is appended if it is a continuation, and a divergence
|
|
124
|
+
* has to be *said* rather than silently corrected.
|
|
125
|
+
*/
|
|
126
|
+
committedAnswer: string;
|
|
127
|
+
/** True while the model is emitting reasoning rather than answer text. */
|
|
128
|
+
thinking: boolean;
|
|
129
|
+
activeTools: ActiveTool[];
|
|
130
|
+
/** Latest successful whole-list update in this turn; never persisted or replay-authored. */
|
|
131
|
+
livePlan: readonly PlanItem[];
|
|
132
|
+
/** Session-local display preference; immutable Static history is never rewritten. */
|
|
133
|
+
toolDetailsExpanded: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Bumped by `clear`, and used as the `<Static>` React key.
|
|
136
|
+
*
|
|
137
|
+
* Emptying `history` is not enough to clear the screen: Ink accumulates every byte
|
|
138
|
+
* `<Static>` ever wrote in `fullStaticOutput` and re-emits it on any later
|
|
139
|
+
* whole-screen redraw, so the old transcript would reappear at the next overflow.
|
|
140
|
+
* Remounting `<Static>` is what makes Ink drop that buffer (`reconciler.js` fires
|
|
141
|
+
* `onStaticChange` on a node-identity change), which is why this is a key and not a
|
|
142
|
+
* counter nobody reads.
|
|
143
|
+
*/
|
|
144
|
+
staticEpoch: number;
|
|
145
|
+
}
|
|
146
|
+
export declare const initialTurnState: TurnState;
|
|
147
|
+
export type TurnAction = {
|
|
148
|
+
type: 'userInput';
|
|
149
|
+
text: string;
|
|
150
|
+
} | {
|
|
151
|
+
type: 'notice';
|
|
152
|
+
text: string;
|
|
153
|
+
severity?: NoticeSeverity;
|
|
154
|
+
} | {
|
|
155
|
+
type: 'toggleToolDetails';
|
|
156
|
+
} | {
|
|
157
|
+
type: 'subagentProgress';
|
|
158
|
+
progress: SubagentDispatchProgress;
|
|
159
|
+
} | {
|
|
160
|
+
type: 'streamEvent';
|
|
161
|
+
event: AgentStreamEvent;
|
|
162
|
+
}
|
|
163
|
+
/** Clears mutable answer rows and identifies the React commit the driver must await. */
|
|
164
|
+
| {
|
|
165
|
+
type: 'prepareAnswerClose';
|
|
166
|
+
id: number;
|
|
167
|
+
} | {
|
|
168
|
+
type: 'turnEnded';
|
|
169
|
+
} | {
|
|
170
|
+
type: 'clear';
|
|
171
|
+
}
|
|
172
|
+
/** A `!` command started: one pseudo-tool row in the live panel (live only, never replayed). */
|
|
173
|
+
| {
|
|
174
|
+
type: 'shellStarted';
|
|
175
|
+
id: string;
|
|
176
|
+
command: string;
|
|
177
|
+
}
|
|
178
|
+
/** Fresh live tail for the running `!` command's detail rows (live only). */
|
|
179
|
+
| {
|
|
180
|
+
type: 'shellOutput';
|
|
181
|
+
id: string;
|
|
182
|
+
tail: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A `!` command finished. Carries recorded fields only — the reducer composes the
|
|
186
|
+
* finished row from them, which is what lets replay dispatch the identical action
|
|
187
|
+
* from a `shellCommand` record and reproduce the identical history.
|
|
188
|
+
*/
|
|
189
|
+
| ({
|
|
190
|
+
type: 'shellCommand';
|
|
191
|
+
output: string;
|
|
192
|
+
} & ShellOutcome);
|
|
193
|
+
export declare function turnReducer(state: TurnState, action: TurnAction): TurnState;
|
|
194
|
+
/** Flattens tool result content into text for the collapsed preview. */
|
|
195
|
+
export declare function previewToolResult(content: readonly unknown[]): string;
|