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,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure presentation for `/status` — one consolidated read-only report of the live
|
|
3
|
+
* session (SER-026), on the `/mcp` read-only-projection precedent.
|
|
4
|
+
*
|
|
5
|
+
* A formatter over state the runtime already holds, never a new information
|
|
6
|
+
* channel: every field of {@link StatusFacts} comes from an existing accessor
|
|
7
|
+
* (`runtime.config`, `runtime.promptCache`, `runtime.listMcpServers()`, …), this
|
|
8
|
+
* module performs no I/O, no model call and no mutation, and its output is a
|
|
9
|
+
* transcript notice — the live frame gains no row. The report may restate what the
|
|
10
|
+
* header shows (model, mode): a scrolled-away header is exactly the use case.
|
|
11
|
+
*
|
|
12
|
+
* This module also owns the model-line suffix renderers the header uses
|
|
13
|
+
* ({@link formatPromptCache}, {@link formatThinking}), moved here from `App.tsx`
|
|
14
|
+
* so the header and `/status` cannot describe the same cache or effort state
|
|
15
|
+
* differently.
|
|
16
|
+
*/
|
|
17
|
+
import type { ApprovalMode } from '../agent/permission.js';
|
|
18
|
+
import type { PromptCachePlan } from '../agent/prompt-cache.js';
|
|
19
|
+
import type { ContextEstimate, UsageTotals } from '../agent/runtime.js';
|
|
20
|
+
import type { ThinkingPlan } from '../agent/thinking.js';
|
|
21
|
+
import { type ModelPriceLookup, type ModelUsageShare } from '../agent/cost.js';
|
|
22
|
+
import { type SessionCallStats } from '../agent/call-stats.js';
|
|
23
|
+
import type { AppConfig } from '../config.js';
|
|
24
|
+
import type { McpServerStatus } from '../mcp/registry.js';
|
|
25
|
+
import type { TrajectoryStatus } from '../trajectory/writer.js';
|
|
26
|
+
import type { DiagnosticsStatus } from '../agent/diagnostics.js';
|
|
27
|
+
/**
|
|
28
|
+
* Representative names shown per list (MCP servers, skills) before the report
|
|
29
|
+
* says `… N more` — the `MAX_MCP_TOOL_NAMES` rule: bounded by construction,
|
|
30
|
+
* never an unbounded dump into the transcript.
|
|
31
|
+
*/
|
|
32
|
+
export declare const MAX_STATUS_NAMES = 6;
|
|
33
|
+
/**
|
|
34
|
+
* Everything `/status` states, as plain data. Each field names the accessor it
|
|
35
|
+
* is read from so a new fact cannot arrive without an existing source.
|
|
36
|
+
*/
|
|
37
|
+
export interface StatusFacts {
|
|
38
|
+
/** The live config (`runtime.config`) — moves with `/model`, unlike `info.config`. */
|
|
39
|
+
config: AppConfig;
|
|
40
|
+
/** `runtime.info.sessionId`. */
|
|
41
|
+
sessionId: string;
|
|
42
|
+
/** `runtime.info.resumed`. */
|
|
43
|
+
resumed: boolean;
|
|
44
|
+
/** The live cache plan (`runtime.promptCache`) — moves with `/model`. */
|
|
45
|
+
promptCache: PromptCachePlan;
|
|
46
|
+
/** The live thinking plan (`runtime.thinking`) — moves with `/effort`. */
|
|
47
|
+
thinking: ThinkingPlan;
|
|
48
|
+
/** The live mode (`runtime.permissionMode`) — moves with `/mode`. */
|
|
49
|
+
mode: ApprovalMode;
|
|
50
|
+
/** `runtime.allowRuleCount` — config rules plus grants accepted this session. */
|
|
51
|
+
allowRuleCount: number;
|
|
52
|
+
/** `runtime.listMcpServers()` — states as they are; this report connects nothing. */
|
|
53
|
+
mcpServers: readonly McpServerStatus[];
|
|
54
|
+
/** `runtime.info.skillNames`. */
|
|
55
|
+
skillNames: readonly string[];
|
|
56
|
+
/** `runtime.trajectoryStatus`; undefined when recording is off. */
|
|
57
|
+
trajectory: TrajectoryStatus | undefined;
|
|
58
|
+
/** `runtime.diagnosticsStatus`; undefined when the log is off (the default). */
|
|
59
|
+
diagnostics: DiagnosticsStatus | undefined;
|
|
60
|
+
/** `runtime.usage` — the SDK's per-process meter. */
|
|
61
|
+
usage: UsageTotals;
|
|
62
|
+
/**
|
|
63
|
+
* `runtime.modelPrice` — what the price cache says about the live model. A read
|
|
64
|
+
* of the cache file, never a fetch or a write: `/status` prices what it already
|
|
65
|
+
* knows and says `unavailable` otherwise.
|
|
66
|
+
*/
|
|
67
|
+
modelPrice: ModelPriceLookup;
|
|
68
|
+
/**
|
|
69
|
+
* `runtime.modelShares` — the meter split per model, each with its own price
|
|
70
|
+
* lookup, so the cost row prices every model's tokens at its own rates after a
|
|
71
|
+
* `/model` switch. One share for a single-model session. Same read-only rule.
|
|
72
|
+
*/
|
|
73
|
+
modelShares: readonly ModelUsageShare[];
|
|
74
|
+
/**
|
|
75
|
+
* `runtime.childUsage` — subagent/workflow child spend summed over the
|
|
76
|
+
* dispatch registry, or undefined when no dispatch ever reported usage.
|
|
77
|
+
*/
|
|
78
|
+
childUsage: {
|
|
79
|
+
dispatches: number;
|
|
80
|
+
usage: UsageTotals;
|
|
81
|
+
} | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* `runtime.callStats` — per-model-call efficiency tallies, or undefined when
|
|
84
|
+
* no completed call has been observed (which keeps the zero-call report
|
|
85
|
+
* byte-identical, the childUsage convention).
|
|
86
|
+
*/
|
|
87
|
+
callStats: SessionCallStats | undefined;
|
|
88
|
+
/** True while a turn streams: the meter has not counted it yet, said out loud. */
|
|
89
|
+
turnInFlight: boolean;
|
|
90
|
+
/** The awaited `runtime.contextEstimate()`, or undefined when it failed. */
|
|
91
|
+
context: ContextEstimate | undefined;
|
|
92
|
+
/** Why the estimate is absent, when it is — degradation, never a failed report. */
|
|
93
|
+
contextProblem?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The `/status` report: one aligned label block, transcript-history only.
|
|
97
|
+
*
|
|
98
|
+
* Honesty rules carried over from the reports it consolidates: unknown metrics
|
|
99
|
+
* read `not reported`, never 0 (`usageBuckets`, the SER-007/SER-022 rule); token
|
|
100
|
+
* scope is this run, with the resumed and in-flight caveats `/usage` states; a
|
|
101
|
+
* failed MCP server is stated as failed exactly as `/mcp` states it, never
|
|
102
|
+
* omitted. Exported for the free spike, like `formatMcpReport`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function formatStatusReport(facts: StatusFacts): string;
|
|
105
|
+
/** Plain cache state for notices that give prompt caching its own labelled row. */
|
|
106
|
+
export declare function formatPromptCacheState(plan: PromptCachePlan): string;
|
|
107
|
+
/**
|
|
108
|
+
* Cache state as a suffix on the model line rather than a line of its own — see the
|
|
109
|
+
* comment in `Header`. Provider-managed caching is stated as automatic; truly off
|
|
110
|
+
* remains empty because it is either the user's choice or reported as a warning.
|
|
111
|
+
*/
|
|
112
|
+
export declare function formatPromptCache(plan: PromptCachePlan): string;
|
|
113
|
+
/**
|
|
114
|
+
* Thinking depth as a suffix on the model line — same reasoning as
|
|
115
|
+
* {@link formatPromptCache}. Always shown: unlike caching there is no "off" state
|
|
116
|
+
* to stay quiet about, and the level is worth knowing *before* spending a turn at
|
|
117
|
+
* it. A clamped level shows what will actually happen, not what was asked for; the
|
|
118
|
+
* reason is the yellow line in `Header`.
|
|
119
|
+
*/
|
|
120
|
+
export declare function formatThinking(plan: ThinkingPlan): string;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { formatUsageValue, sumUsage, usageBuckets } from '../agent/usage.js';
|
|
2
|
+
import { describeCost, describeModelCosts, withChildUsage } from '../agent/cost.js';
|
|
3
|
+
import { describeCallEfficiency } from '../agent/call-stats.js';
|
|
4
|
+
import { formatContextValue } from './context-format.js';
|
|
5
|
+
/**
|
|
6
|
+
* Representative names shown per list (MCP servers, skills) before the report
|
|
7
|
+
* says `… N more` — the `MAX_MCP_TOOL_NAMES` rule: bounded by construction,
|
|
8
|
+
* never an unbounded dump into the transcript.
|
|
9
|
+
*/
|
|
10
|
+
export const MAX_STATUS_NAMES = 6;
|
|
11
|
+
/**
|
|
12
|
+
* The `/status` report: one aligned label block, transcript-history only.
|
|
13
|
+
*
|
|
14
|
+
* Honesty rules carried over from the reports it consolidates: unknown metrics
|
|
15
|
+
* read `not reported`, never 0 (`usageBuckets`, the SER-007/SER-022 rule); token
|
|
16
|
+
* scope is this run, with the resumed and in-flight caveats `/usage` states; a
|
|
17
|
+
* failed MCP server is stated as failed exactly as `/mcp` states it, never
|
|
18
|
+
* omitted. Exported for the free spike, like `formatMcpReport`.
|
|
19
|
+
*/
|
|
20
|
+
export function formatStatusReport(facts) {
|
|
21
|
+
const rows = [
|
|
22
|
+
[
|
|
23
|
+
'model',
|
|
24
|
+
`${facts.config.provider}/${facts.config.model}` +
|
|
25
|
+
`${formatPromptCache(facts.promptCache)}${formatThinking(facts.thinking)}`,
|
|
26
|
+
],
|
|
27
|
+
['session', `${facts.sessionId}${facts.resumed ? ' (resumed)' : ''}`],
|
|
28
|
+
['mode', describeMode(facts.mode, facts.allowRuleCount)],
|
|
29
|
+
['mcp', describeMcpServers(facts.mcpServers)],
|
|
30
|
+
['skills', describeNames(facts.skillNames)],
|
|
31
|
+
['trajectory', describeTrajectory(facts.trajectory)],
|
|
32
|
+
['diagnostics', describeDiagnostics(facts.diagnostics)],
|
|
33
|
+
['tokens', describeTokens(facts)],
|
|
34
|
+
// Directly beside the tokens it prices, through the one shared projection
|
|
35
|
+
// (`/usage` and the headless `cost:` record use the same arithmetic): each
|
|
36
|
+
// model's share at its own rates, one share for a single-model session.
|
|
37
|
+
['cost', describeModelCosts(facts.modelShares)],
|
|
38
|
+
[
|
|
39
|
+
'context',
|
|
40
|
+
facts.context === undefined
|
|
41
|
+
? `unavailable — ${facts.contextProblem ?? 'no estimate'}`
|
|
42
|
+
: formatContextValue(facts.context),
|
|
43
|
+
],
|
|
44
|
+
];
|
|
45
|
+
const labelWidth = Math.max(...rows.map(([label]) => label.length));
|
|
46
|
+
const lines = rows.map(([label, value]) => ` ${label.padEnd(labelWidth)} ${value}`);
|
|
47
|
+
// Child spend rides directly under the cost row as `label: value` lines rather
|
|
48
|
+
// than table rows, so today's aligned block stays byte-identical when no
|
|
49
|
+
// dispatch reported usage — the additive-everywhere contract. Each child usage
|
|
50
|
+
// line is followed by its cost line: children run the parent's live model config,
|
|
51
|
+
// so their tokens are priced at its rates, and the session total folds them into
|
|
52
|
+
// the live model's share beside the parent's per-model shares.
|
|
53
|
+
if (facts.childUsage !== undefined) {
|
|
54
|
+
const { dispatches, usage } = facts.childUsage;
|
|
55
|
+
const total = sumUsage([facts.usage, usage]);
|
|
56
|
+
const plural = `${dispatches} dispatch${dispatches === 1 ? '' : 'es'}`;
|
|
57
|
+
const costIndex = rows.findIndex(([label]) => label === 'cost');
|
|
58
|
+
lines.splice(costIndex + 1, 0, ` usage (subagents, ${plural}): ${describeCounters(usage, facts.config)}`, ` cost (subagents, ${plural}): ${describeCost(facts.modelPrice, usage, facts.config)}`, ` usage (session total): ${describeCounters(total, facts.config)}`, ` cost (session total): ${describeModelCosts(withChildUsage(facts.modelShares, usage, facts.config, facts.modelPrice))}`);
|
|
59
|
+
}
|
|
60
|
+
// Per-call efficiency rides the same additive convention, one bounded line from
|
|
61
|
+
// the shared `describeCallEfficiency` renderer (the same arithmetic the /usage
|
|
62
|
+
// efficiency section derives from), directly under the token/cost block.
|
|
63
|
+
if (facts.callStats !== undefined) {
|
|
64
|
+
const costIndex = rows.findIndex(([label]) => label === 'cost');
|
|
65
|
+
lines.splice(costIndex + 1 + (facts.childUsage === undefined ? 0 : 4), 0, ` model calls: ${describeCallEfficiency(facts.callStats, facts.config)}`);
|
|
66
|
+
}
|
|
67
|
+
return ['status — this session', ...lines].join('\n');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The header's own wording for the three mode states, so `/status` and the header
|
|
71
|
+
* row cannot disagree about what the mode does — plus the live rule count, which
|
|
72
|
+
* `/permissions` can expand.
|
|
73
|
+
*/
|
|
74
|
+
function describeMode(mode, allowRuleCount) {
|
|
75
|
+
if (mode === 'yolo')
|
|
76
|
+
return 'yolo — every tool call runs without confirmation';
|
|
77
|
+
if (mode === 'plan') {
|
|
78
|
+
return ('plan — read-only; write and execute calls are denied' +
|
|
79
|
+
(allowRuleCount > 0 ? ` · ${allowRuleCount} allow rule(s) ignored` : ''));
|
|
80
|
+
}
|
|
81
|
+
return `${mode}${allowRuleCount > 0 ? ` · ${allowRuleCount} allow rule(s)` : ''}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Every server with its state on one bounded line. States use `/mcp`'s own
|
|
85
|
+
* vocabulary — a failed server is *stated* as failed, never omitted — and `/mcp`
|
|
86
|
+
* remains the report with per-server tool listings and config provenance.
|
|
87
|
+
*/
|
|
88
|
+
function describeMcpServers(servers) {
|
|
89
|
+
if (servers.length === 0)
|
|
90
|
+
return 'none configured';
|
|
91
|
+
const shown = servers.slice(0, MAX_STATUS_NAMES).map((server) => {
|
|
92
|
+
switch (server.state) {
|
|
93
|
+
case 'connected':
|
|
94
|
+
return `${server.name} connected (${describeToolCount(server.toolNames)})`;
|
|
95
|
+
case 'failed':
|
|
96
|
+
return `${server.name} failed — could not connect`;
|
|
97
|
+
case 'disconnected':
|
|
98
|
+
return `${server.name} not connected`;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const remainder = servers.length - shown.length;
|
|
102
|
+
const suffix = remainder > 0 ? ` … ${remainder} more` : '';
|
|
103
|
+
return `${servers.length} server${servers.length === 1 ? '' : 's'} — ${shown.join(', ')}${suffix} (details: /mcp)`;
|
|
104
|
+
}
|
|
105
|
+
/** A connected server's tool count, without inventing one the SDK cannot read. */
|
|
106
|
+
function describeToolCount(toolNames) {
|
|
107
|
+
if (toolNames === undefined)
|
|
108
|
+
return 'tool names unavailable';
|
|
109
|
+
return `${toolNames.length} tool${toolNames.length === 1 ? '' : 's'}`;
|
|
110
|
+
}
|
|
111
|
+
/** Count plus representative names, bounded like the server list. */
|
|
112
|
+
function describeNames(names) {
|
|
113
|
+
if (names.length === 0)
|
|
114
|
+
return 'none';
|
|
115
|
+
const shown = names.slice(0, MAX_STATUS_NAMES);
|
|
116
|
+
const remainder = names.length - shown.length;
|
|
117
|
+
const suffix = remainder > 0 ? ` … ${remainder} more` : '';
|
|
118
|
+
return `${names.length} — ${shown.join(', ')}${suffix}`;
|
|
119
|
+
}
|
|
120
|
+
/** `formatTrajectoryReport`'s states at line scale; the file is the useful fact. */
|
|
121
|
+
function describeTrajectory(status) {
|
|
122
|
+
if (status === undefined)
|
|
123
|
+
return 'not recording (trajectory: false)';
|
|
124
|
+
return `${status.active ? 'recording' : 'stopped'} — ${status.file}`;
|
|
125
|
+
}
|
|
126
|
+
/** Off is the default and stated as such; on names the file so it can be read. */
|
|
127
|
+
function describeDiagnostics(status) {
|
|
128
|
+
if (status === undefined)
|
|
129
|
+
return 'off';
|
|
130
|
+
return `${status.active ? 'logging' : 'stopped'} — ${status.file}`;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Process token spend on one line, from `usageBuckets` directly: an unreported
|
|
134
|
+
* metric stays `not reported` — never 0 — whatever the provider.
|
|
135
|
+
*/
|
|
136
|
+
function describeTokens(facts) {
|
|
137
|
+
const counters = describeCounters(facts.usage, facts.config);
|
|
138
|
+
// "This run" is the honest scope: the SDK's meter is per-process, so a resumed
|
|
139
|
+
// session's earlier spend is simply not knowable here — /usage's exact bargain.
|
|
140
|
+
const scope = facts.resumed ? 'this run; earlier runs not counted' : 'this run';
|
|
141
|
+
const inFlight = facts.turnInFlight ? ' (the turn in flight is not counted yet)' : '';
|
|
142
|
+
return `${counters} — ${scope}${inFlight}`;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The four counters of one meter, in the tokens row's own vocabulary and order —
|
|
146
|
+
* shared with the child/session-total lines so the three cannot drift apart.
|
|
147
|
+
*/
|
|
148
|
+
function describeCounters(usage, config) {
|
|
149
|
+
const buckets = usageBuckets(usage, config);
|
|
150
|
+
return [
|
|
151
|
+
`input ${formatUsageValue(buckets.input)}`,
|
|
152
|
+
`output ${formatUsageValue(buckets.output)}`,
|
|
153
|
+
`cache read ${formatUsageValue(buckets.cacheRead)}`,
|
|
154
|
+
`cache write ${formatUsageValue(buckets.cacheWrite)}`,
|
|
155
|
+
].join(' · ');
|
|
156
|
+
}
|
|
157
|
+
/** Plain cache state for notices that give prompt caching its own labelled row. */
|
|
158
|
+
export function formatPromptCacheState(plan) {
|
|
159
|
+
if (plan.problem !== undefined)
|
|
160
|
+
return plan.problem;
|
|
161
|
+
if (plan.automatic)
|
|
162
|
+
return 'auto';
|
|
163
|
+
return plan.enabled ? plan.parts.join(', ') : 'off';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Cache state as a suffix on the model line rather than a line of its own — see the
|
|
167
|
+
* comment in `Header`. Provider-managed caching is stated as automatic; truly off
|
|
168
|
+
* remains empty because it is either the user's choice or reported as a warning.
|
|
169
|
+
*/
|
|
170
|
+
export function formatPromptCache(plan) {
|
|
171
|
+
if (plan.automatic)
|
|
172
|
+
return ' · cache auto';
|
|
173
|
+
if (!plan.enabled)
|
|
174
|
+
return '';
|
|
175
|
+
const ttl = plan.ttl ?? 'on';
|
|
176
|
+
// A single-part plan (no provider produces one today; the shape stays legal)
|
|
177
|
+
// names its part, since a bare "cache on" would overstate what is cached.
|
|
178
|
+
return plan.parts.length === 1 ? ` · cache ${ttl} (${plan.parts[0]})` : ` · cache ${ttl}`;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Thinking depth as a suffix on the model line — same reasoning as
|
|
182
|
+
* {@link formatPromptCache}. Always shown: unlike caching there is no "off" state
|
|
183
|
+
* to stay quiet about, and the level is worth knowing *before* spending a turn at
|
|
184
|
+
* it. A clamped level shows what will actually happen, not what was asked for; the
|
|
185
|
+
* reason is the yellow line in `Header`.
|
|
186
|
+
*/
|
|
187
|
+
export function formatThinking(plan) {
|
|
188
|
+
if (!plan.enabled || plan.effective === undefined)
|
|
189
|
+
return ' · no thinking';
|
|
190
|
+
return ` · effort ${plan.effective}`;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=status-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-format.js","sourceRoot":"","sources":["../../../src/tui/status-format.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAA+C,MAAM,kBAAkB,CAAC;AACjI,OAAO,EAAE,sBAAsB,EAAyB,MAAM,wBAAwB,CAAC;AAKvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA8DlC;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACnD,MAAM,IAAI,GAAuB;QAC/B;YACE,OAAO;YACP,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;gBAC9C,GAAG,iBAAiB,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;SAC7E;QACD,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACrE,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;QACxD,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC,QAAQ,EAAE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,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO,eAAe,CAAC;IAC3C,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC;IAC7B,6EAA6E;IAC7E,0EAA0E;IAC1E,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,GAAG,EAAE,CAAC;AAC5F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAkB;IAC/C,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,gBAAgB,CAAC;IAC3E,OAAO,aAAa,IAAI,CAAC,SAAS,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type SubagentCancelResult, type SubagentDispatchPhase, type SubagentDispatchStatus } from '../agents/dispatch-registry.js';
|
|
2
|
+
/** Elapsed milliseconds for one dispatch, defensive about the ISO contract. */
|
|
3
|
+
export declare function dispatchElapsedMs(dispatch: SubagentDispatchStatus, nowMs?: number): number;
|
|
4
|
+
/**
|
|
5
|
+
* The `/agents` report: one row per dispatch of this run.
|
|
6
|
+
*
|
|
7
|
+
* The empty wording names *dispatches*, not agents, so the report can never be
|
|
8
|
+
* misread as the list of definitions available to delegate to — that catalogue is
|
|
9
|
+
* `runtime.info.agentNames`, shown in the header, and is a different question.
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatDispatchesReport(dispatches: readonly SubagentDispatchStatus[], nowMs?: number): string;
|
|
12
|
+
/** The observer notice for a dispatch that just reached a terminal state. */
|
|
13
|
+
export declare function formatDispatchCompletion(dispatch: SubagentDispatchStatus): string;
|
|
14
|
+
/** Closed phase text shared by live rows and headless heartbeat projections. */
|
|
15
|
+
export declare function formatDispatchPhase(phase: SubagentDispatchPhase): string;
|
|
16
|
+
/** Bounded local response for `/agents cancel <id>`. */
|
|
17
|
+
export declare function formatDispatchCancellation(dispatchId: string, result: SubagentCancelResult): string;
|
|
18
|
+
/** `<agent>#<dispatchId>`, the identity every surface shows for one dispatch. */
|
|
19
|
+
export { dispatchLabel } from '../agents/dispatch-registry.js';
|
|
20
|
+
/**
|
|
21
|
+
* The live/history row for a delegation call, or `undefined` for any other tool.
|
|
22
|
+
*
|
|
23
|
+
* Computed from the parent's own tool-use block alone — no registry lookup — so
|
|
24
|
+
* the TUI reducer stays pure while still printing the same dispatch id the
|
|
25
|
+
* registry recorded: {@link shortDispatchId} is a pure function of the tool-use id.
|
|
26
|
+
* Concurrent dispatches are what make this worth showing: several `subagent` rows
|
|
27
|
+
* are alive at once, and `subagent: general` repeated three times says nothing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function subagentCallSummary(toolName: string, input: unknown, toolUseId: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* SER-064: the three readings one background-routed delegation row goes through.
|
|
32
|
+
*
|
|
33
|
+
* The transcript sees a delegation the model marked `_background_execution: true`
|
|
34
|
+
* three times: as a live row while the child runs (the SDK's ack keeps the parent
|
|
35
|
+
* going, but the child *is* still running, and the dispatch heartbeat lands on this
|
|
36
|
+
* row), as one finished ack row when the parent receives the dispatch
|
|
37
|
+
* acknowledgement, and as the finished result row when the background run's own
|
|
38
|
+
* `afterToolCallEvent` arrives — the same row a foreground call ends with, so the
|
|
39
|
+
* report renders exactly like a foreground result. All three are pure functions of
|
|
40
|
+
* the parent's tool-use block and the SDK's ack text; none reads a task registry.
|
|
41
|
+
*/
|
|
42
|
+
export declare function backgroundDelegationRequested(toolName: string, input: unknown): boolean;
|
|
43
|
+
/** Live-panel label while the background child is still running. */
|
|
44
|
+
export declare function backgroundDelegationLiveSummary(baseSummary: string): string;
|
|
45
|
+
/** The finished ack row: the parent was released while task `taskId` runs. */
|
|
46
|
+
export declare function backgroundDelegationAckSummary(baseSummary: string, taskId: string): string;
|
|
47
|
+
/** The finished result row, carrying the child's report like a foreground call. */
|
|
48
|
+
export declare function backgroundDelegationResultSummary(baseSummary: string): string;
|
|
49
|
+
export { backgroundAckTaskId } from '../agent/background-delegation.js';
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, presentation-time projections of subagent dispatch state.
|
|
3
|
+
*
|
|
4
|
+
* Same division of labour as `background-tool-presentation.ts`: the registry keeps
|
|
5
|
+
* full fidelity (whole task text, ISO timestamps), and everything a terminal draws
|
|
6
|
+
* is truncated here — by Unicode code points, so a task ending in an emoji cannot
|
|
7
|
+
* render as `�`.
|
|
8
|
+
*
|
|
9
|
+
* Nothing in this module can reach a child's transcript: it only ever sees the
|
|
10
|
+
* dispatch record (name, task, state, timestamps) and the parent's own tool-use
|
|
11
|
+
* block.
|
|
12
|
+
*/
|
|
13
|
+
import { SUBAGENT_TOOL_NAME } from '../agents/subagent-tool.js';
|
|
14
|
+
import { WORKFLOW_TOOL_NAME } from '../agents/workflow-tool.js';
|
|
15
|
+
import { backgroundExecutionRequested } from '../agent/background-delegation.js';
|
|
16
|
+
import { dispatchLabel, shortDispatchId, } from '../agents/dispatch-registry.js';
|
|
17
|
+
import { formatTaskDuration, summarizeTaskCommand } from './task-format.js';
|
|
18
|
+
/** A delegated task is prose, so it gets less room than a shell command. */
|
|
19
|
+
const TASK_SUMMARY_LIMIT = 56;
|
|
20
|
+
/** Room for `succeeded`, the longest state word, plus a space. */
|
|
21
|
+
const STATE_COLUMN = 9;
|
|
22
|
+
/** A bounded name plus `#` plus eight id characters; longer labels just push. */
|
|
23
|
+
const LABEL_COLUMN = 25;
|
|
24
|
+
/** Elapsed milliseconds for one dispatch, defensive about the ISO contract. */
|
|
25
|
+
export function dispatchElapsedMs(dispatch, nowMs = Date.now()) {
|
|
26
|
+
const started = Date.parse(dispatch.startedAt);
|
|
27
|
+
const finished = dispatch.finishedAt === null ? nowMs : Date.parse(dispatch.finishedAt);
|
|
28
|
+
if (!Number.isFinite(started) || !Number.isFinite(finished))
|
|
29
|
+
return 0;
|
|
30
|
+
return Math.max(0, finished - started);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The `/agents` report: one row per dispatch of this run.
|
|
34
|
+
*
|
|
35
|
+
* The empty wording names *dispatches*, not agents, so the report can never be
|
|
36
|
+
* misread as the list of definitions available to delegate to — that catalogue is
|
|
37
|
+
* `runtime.info.agentNames`, shown in the header, and is a different question.
|
|
38
|
+
*/
|
|
39
|
+
export function formatDispatchesReport(dispatches, nowMs = Date.now()) {
|
|
40
|
+
if (dispatches.length === 0)
|
|
41
|
+
return 'subagent dispatches — none in this run';
|
|
42
|
+
return [
|
|
43
|
+
`subagent dispatches — this run (${dispatches.length})`,
|
|
44
|
+
...dispatches.map((dispatch) => ` ${dispatchLabel(dispatch).padEnd(LABEL_COLUMN)} ${dispatch.state.padEnd(STATE_COLUMN)} ` +
|
|
45
|
+
`${formatTaskDuration(dispatchElapsedMs(dispatch, nowMs)).padStart(7)} ` +
|
|
46
|
+
`${summarizeTaskCommand(dispatch.task, TASK_SUMMARY_LIMIT)}${dispatchUsageSuffix(dispatch)}`),
|
|
47
|
+
].join('\n');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* ` — tokens in=X out=Y` when the dispatch snapshot carries usage, nothing
|
|
51
|
+
* otherwise — a row never invents a zero for a meter that was not read.
|
|
52
|
+
* Counters only, like everything else on the row.
|
|
53
|
+
*/
|
|
54
|
+
function dispatchUsageSuffix(dispatch) {
|
|
55
|
+
if (dispatch.usage === undefined)
|
|
56
|
+
return '';
|
|
57
|
+
return ` — tokens in=${dispatch.usage.inputTokens} out=${dispatch.usage.outputTokens}`;
|
|
58
|
+
}
|
|
59
|
+
/** The observer notice for a dispatch that just reached a terminal state. */
|
|
60
|
+
export function formatDispatchCompletion(dispatch) {
|
|
61
|
+
return (`subagent ${dispatchLabel(dispatch)} ${dispatch.state} in ` +
|
|
62
|
+
`${formatTaskDuration(dispatchElapsedMs(dispatch))} — ` +
|
|
63
|
+
`${summarizeTaskCommand(dispatch.task, TASK_SUMMARY_LIMIT)}`);
|
|
64
|
+
}
|
|
65
|
+
/** Closed phase text shared by live rows and headless heartbeat projections. */
|
|
66
|
+
export function formatDispatchPhase(phase) {
|
|
67
|
+
switch (phase.kind) {
|
|
68
|
+
case 'tool':
|
|
69
|
+
return `tool ${phase.toolName}`;
|
|
70
|
+
case 'waiting-on-model':
|
|
71
|
+
// The child's own throttled retry wait (SER-067): the attempt about to be made.
|
|
72
|
+
return `waiting on model, retry ${phase.attempt}/${phase.maxAttempts}`;
|
|
73
|
+
default:
|
|
74
|
+
return phase.kind;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Bounded local response for `/agents cancel <id>`. */
|
|
78
|
+
export function formatDispatchCancellation(dispatchId, result) {
|
|
79
|
+
switch (result.outcome) {
|
|
80
|
+
case 'cancelled':
|
|
81
|
+
return `cancelling subagent ${dispatchLabel(result.dispatch)}`;
|
|
82
|
+
case 'ambiguous':
|
|
83
|
+
return `subagent dispatch id ${dispatchId} is ambiguous — no dispatch cancelled`;
|
|
84
|
+
case 'terminal':
|
|
85
|
+
return `subagent dispatch ${dispatchId} is already finished`;
|
|
86
|
+
case 'already-requested':
|
|
87
|
+
return `subagent dispatch ${dispatchId} cancellation was already requested`;
|
|
88
|
+
case 'not-found':
|
|
89
|
+
return `no subagent dispatch ${dispatchId}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** `<agent>#<dispatchId>`, the identity every surface shows for one dispatch. */
|
|
93
|
+
export { dispatchLabel } from '../agents/dispatch-registry.js';
|
|
94
|
+
/**
|
|
95
|
+
* The live/history row for a delegation call, or `undefined` for any other tool.
|
|
96
|
+
*
|
|
97
|
+
* Computed from the parent's own tool-use block alone — no registry lookup — so
|
|
98
|
+
* the TUI reducer stays pure while still printing the same dispatch id the
|
|
99
|
+
* registry recorded: {@link shortDispatchId} is a pure function of the tool-use id.
|
|
100
|
+
* Concurrent dispatches are what make this worth showing: several `subagent` rows
|
|
101
|
+
* are alive at once, and `subagent: general` repeated three times says nothing.
|
|
102
|
+
*/
|
|
103
|
+
export function subagentCallSummary(toolName, input, toolUseId) {
|
|
104
|
+
if (toolName !== SUBAGENT_TOOL_NAME)
|
|
105
|
+
return undefined;
|
|
106
|
+
const record = isRecord(input) ? input : {};
|
|
107
|
+
const agentName = typeof record['agent'] === 'string' && record['agent'].trim() !== ''
|
|
108
|
+
? record['agent'].trim()
|
|
109
|
+
: 'general';
|
|
110
|
+
const task = typeof record['task'] === 'string' ? record['task'] : '';
|
|
111
|
+
const label = `${SUBAGENT_TOOL_NAME} ${dispatchLabel({ agentName, dispatchId: shortDispatchId(toolUseId) })}`;
|
|
112
|
+
return task === '' ? label : `${label}: ${summarizeTaskCommand(task, TASK_SUMMARY_LIMIT)}`;
|
|
113
|
+
}
|
|
114
|
+
function isRecord(value) {
|
|
115
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* SER-064: the three readings one background-routed delegation row goes through.
|
|
119
|
+
*
|
|
120
|
+
* The transcript sees a delegation the model marked `_background_execution: true`
|
|
121
|
+
* three times: as a live row while the child runs (the SDK's ack keeps the parent
|
|
122
|
+
* going, but the child *is* still running, and the dispatch heartbeat lands on this
|
|
123
|
+
* row), as one finished ack row when the parent receives the dispatch
|
|
124
|
+
* acknowledgement, and as the finished result row when the background run's own
|
|
125
|
+
* `afterToolCallEvent` arrives — the same row a foreground call ends with, so the
|
|
126
|
+
* report renders exactly like a foreground result. All three are pure functions of
|
|
127
|
+
* the parent's tool-use block and the SDK's ack text; none reads a task registry.
|
|
128
|
+
*/
|
|
129
|
+
export function backgroundDelegationRequested(toolName, input) {
|
|
130
|
+
return ((toolName === SUBAGENT_TOOL_NAME || toolName === WORKFLOW_TOOL_NAME) &&
|
|
131
|
+
backgroundExecutionRequested(input));
|
|
132
|
+
}
|
|
133
|
+
/** Live-panel label while the background child is still running. */
|
|
134
|
+
export function backgroundDelegationLiveSummary(baseSummary) {
|
|
135
|
+
return `${baseSummary} · background`;
|
|
136
|
+
}
|
|
137
|
+
/** The finished ack row: the parent was released while task `taskId` runs. */
|
|
138
|
+
export function backgroundDelegationAckSummary(baseSummary, taskId) {
|
|
139
|
+
return `${baseSummary} · delegated in background (task ${taskId})`;
|
|
140
|
+
}
|
|
141
|
+
/** The finished result row, carrying the child's report like a foreground call. */
|
|
142
|
+
export function backgroundDelegationResultSummary(baseSummary) {
|
|
143
|
+
return `${baseSummary} · background result`;
|
|
144
|
+
}
|
|
145
|
+
export { backgroundAckTaskId } from '../agent/background-delegation.js';
|
|
146
|
+
//# sourceMappingURL=subagent-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-format.js","sourceRoot":"","sources":["../../../src/tui/subagent-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EACL,aAAa,EACb,eAAe,GAIhB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,kEAAkE;AAClE,MAAM,YAAY,GAAG,CAAC,CAAC;AA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KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,6BAA6B,CAAC,QAAgB,EAAE,KAAc;IAC5E,OAAO,CACL,CAAC,QAAQ,KAAK,kBAAkB,IAAI,QAAQ,KAAK,kBAAkB,CAAC;QACpE,4BAA4B,CAAC,KAAK,CAAC,CACpC,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,+BAA+B,CAAC,WAAmB;IACjE,OAAO,GAAG,WAAW,eAAe,CAAC;AACvC,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,8BAA8B,CAAC,WAAmB,EAAE,MAAc;IAChF,OAAO,GAAG,WAAW,oCAAoC,MAAM,GAAG,CAAC;AACrE,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,iCAAiC,CAAC,WAAmB;IACnE,OAAO,GAAG,WAAW,sBAAsB,CAAC;AAC9C,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BackgroundTaskStatus } from '../tools/background-bash.js';
|
|
2
|
+
import { type BackgroundTail } from '../tools/background-tail.js';
|
|
3
|
+
/** Width of one tail row's text; with its indent and marker it matches the widest job row. */
|
|
4
|
+
export declare const TASK_TAIL_LINE_LIMIT = 100;
|
|
5
|
+
/** Indent plus a marker no job row starts with, so tail rows cannot read as jobs. */
|
|
6
|
+
export declare const TASK_TAIL_PREFIX = " \u2502 ";
|
|
7
|
+
export declare const TASK_TAIL_EMPTY_NOTICE = "(no output yet)";
|
|
8
|
+
export declare const TASK_TAIL_UNAVAILABLE_NOTICE = "(output unavailable)";
|
|
9
|
+
/** Keeps task ids recognizable without printing an entire UUID in every notice. */
|
|
10
|
+
export declare function formatTaskId(taskId: string): string;
|
|
11
|
+
/** Makes arbitrary shell source a bounded, single-line terminal label. */
|
|
12
|
+
export declare function summarizeTaskCommand(command: string, limit?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* The rows under one job: its recent output lines, or one stated reason there are none.
|
|
15
|
+
* Lines arrive already ANSI-stripped and tab-expanded from the reader; only the width is
|
|
16
|
+
* applied here, so replay/export see exactly what the transcript showed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatTaskTail(tail: BackgroundTail | undefined, limit?: number): string[];
|
|
19
|
+
/** Defensive elapsed time calculation over the manager's ISO timestamp contract. */
|
|
20
|
+
export declare function taskElapsedMs(task: BackgroundTaskStatus, nowMs?: number): number;
|
|
21
|
+
/** Compact duration for transcript rows; terminal tasks use their fixed finish time. */
|
|
22
|
+
export declare function formatTaskDuration(milliseconds: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* The `/tasks` notice. With `tails` (keyed by task id) every job row is followed by its
|
|
25
|
+
* tail rows — a task the reader did not cover reads as unavailable; without `tails` the
|
|
26
|
+
* report keeps its original one-row-per-job shape.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatTasksReport(tasks: readonly BackgroundTaskStatus[], nowMs?: number, tails?: ReadonlyMap<string, BackgroundTail>): string;
|
|
29
|
+
export declare function formatTaskCompletion(task: BackgroundTaskStatus): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TASK_TAIL_LINES } from '../tools/background-tail.js';
|
|
2
|
+
const COMMAND_SUMMARY_LIMIT = 72;
|
|
3
|
+
/** Width of one tail row's text; with its indent and marker it matches the widest job row. */
|
|
4
|
+
export const TASK_TAIL_LINE_LIMIT = 100;
|
|
5
|
+
/** Indent plus a marker no job row starts with, so tail rows cannot read as jobs. */
|
|
6
|
+
export const TASK_TAIL_PREFIX = ' │ ';
|
|
7
|
+
export const TASK_TAIL_EMPTY_NOTICE = '(no output yet)';
|
|
8
|
+
export const TASK_TAIL_UNAVAILABLE_NOTICE = '(output unavailable)';
|
|
9
|
+
/** Keeps task ids recognizable without printing an entire UUID in every notice. */
|
|
10
|
+
export function formatTaskId(taskId) {
|
|
11
|
+
const match = /^bg-([0-9a-f]{8})[0-9a-f-]*$/i.exec(taskId);
|
|
12
|
+
return match === null ? taskId : `bg-${match[1]}`;
|
|
13
|
+
}
|
|
14
|
+
/** End-first truncation by code point with a one-character ellipsis; never splits a code point. */
|
|
15
|
+
function truncateEnd(text, limit) {
|
|
16
|
+
if (limit <= 0)
|
|
17
|
+
return '';
|
|
18
|
+
const codePoints = [...text];
|
|
19
|
+
if (codePoints.length <= limit)
|
|
20
|
+
return text;
|
|
21
|
+
if (limit === 1)
|
|
22
|
+
return '…';
|
|
23
|
+
return `${codePoints.slice(0, limit - 1).join('')}…`;
|
|
24
|
+
}
|
|
25
|
+
/** Makes arbitrary shell source a bounded, single-line terminal label. */
|
|
26
|
+
export function summarizeTaskCommand(command, limit = COMMAND_SUMMARY_LIMIT) {
|
|
27
|
+
return truncateEnd(command.replace(/\s+/g, ' ').trim(), limit);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The rows under one job: its recent output lines, or one stated reason there are none.
|
|
31
|
+
* Lines arrive already ANSI-stripped and tab-expanded from the reader; only the width is
|
|
32
|
+
* applied here, so replay/export see exactly what the transcript showed.
|
|
33
|
+
*/
|
|
34
|
+
export function formatTaskTail(tail, limit = TASK_TAIL_LINE_LIMIT) {
|
|
35
|
+
if (tail === undefined || tail.kind === 'unavailable')
|
|
36
|
+
return [`${TASK_TAIL_PREFIX}${TASK_TAIL_UNAVAILABLE_NOTICE}`];
|
|
37
|
+
if (tail.kind === 'empty')
|
|
38
|
+
return [`${TASK_TAIL_PREFIX}${TASK_TAIL_EMPTY_NOTICE}`];
|
|
39
|
+
return tail.lines
|
|
40
|
+
.slice(Math.max(0, tail.lines.length - TASK_TAIL_LINES))
|
|
41
|
+
.map((line) => `${TASK_TAIL_PREFIX}${truncateEnd(line, limit)}`);
|
|
42
|
+
}
|
|
43
|
+
/** Defensive elapsed time calculation over the manager's ISO timestamp contract. */
|
|
44
|
+
export function taskElapsedMs(task, nowMs = Date.now()) {
|
|
45
|
+
const started = Date.parse(task.startedAt);
|
|
46
|
+
const finished = task.finishedAt === null ? nowMs : Date.parse(task.finishedAt);
|
|
47
|
+
if (!Number.isFinite(started) || !Number.isFinite(finished))
|
|
48
|
+
return 0;
|
|
49
|
+
return Math.max(0, finished - started);
|
|
50
|
+
}
|
|
51
|
+
/** Compact duration for transcript rows; terminal tasks use their fixed finish time. */
|
|
52
|
+
export function formatTaskDuration(milliseconds) {
|
|
53
|
+
const seconds = Math.floor(Math.max(0, milliseconds) / 1000);
|
|
54
|
+
if (seconds < 60)
|
|
55
|
+
return `${seconds}s`;
|
|
56
|
+
const minutes = Math.floor(seconds / 60);
|
|
57
|
+
const remainingSeconds = seconds % 60;
|
|
58
|
+
if (minutes < 60)
|
|
59
|
+
return `${minutes}m ${remainingSeconds}s`;
|
|
60
|
+
const hours = Math.floor(minutes / 60);
|
|
61
|
+
return `${hours}h ${minutes % 60}m`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The `/tasks` notice. With `tails` (keyed by task id) every job row is followed by its
|
|
65
|
+
* tail rows — a task the reader did not cover reads as unavailable; without `tails` the
|
|
66
|
+
* report keeps its original one-row-per-job shape.
|
|
67
|
+
*/
|
|
68
|
+
export function formatTasksReport(tasks, nowMs = Date.now(), tails) {
|
|
69
|
+
if (tasks.length === 0)
|
|
70
|
+
return 'background tasks — none in this run';
|
|
71
|
+
return [
|
|
72
|
+
`background tasks — this run (${tasks.length})`,
|
|
73
|
+
...tasks.flatMap((task) => [
|
|
74
|
+
` ${formatTaskId(task.taskId)} ${task.state.padEnd(9)} ${formatTaskDuration(taskElapsedMs(task, nowMs)).padStart(7)} ${summarizeTaskCommand(task.command)}`,
|
|
75
|
+
...(tails === undefined ? [] : formatTaskTail(tails.get(task.taskId))),
|
|
76
|
+
]),
|
|
77
|
+
].join('\n');
|
|
78
|
+
}
|
|
79
|
+
export function formatTaskCompletion(task) {
|
|
80
|
+
const exitMetadata = [
|
|
81
|
+
task.exitCode === null ? undefined : `exit ${task.exitCode}`,
|
|
82
|
+
task.signal === null ? undefined : `signal ${task.signal}`,
|
|
83
|
+
].filter((value) => value !== undefined).join(', ');
|
|
84
|
+
const metadata = task.state === 'failed' && exitMetadata !== '' ? ` (${exitMetadata})` : '';
|
|
85
|
+
return `background task ${formatTaskId(task.taskId)} ${task.state}${metadata} in ${formatTaskDuration(taskElapsedMs(task))} — ${summarizeTaskCommand(task.command)}`;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=task-format.js.map
|