@andorra-labs/code 0.1.11 → 0.1.13
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 +8 -2
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/account-presentation.d.ts +1 -37
- package/dist/src/account-presentation.js +2 -42
- package/dist/src/activity.d.ts +0 -25
- package/dist/src/activity.js +1 -23
- package/dist/src/agent-definitions.d.ts +0 -26
- package/dist/src/agent-definitions.js +0 -43
- package/dist/src/agent-execution.d.ts +0 -2
- package/dist/src/agent-execution.js +59 -414
- package/dist/src/agent-mcp-catalog.d.ts +0 -8
- package/dist/src/agent-mcp-catalog.js +0 -2
- package/dist/src/agent-mcp.d.ts +0 -56
- package/dist/src/agent-mcp.js +14 -153
- package/dist/src/agent-modifiers.d.ts +0 -1
- package/dist/src/agent-modifiers.js +25 -68
- package/dist/src/analytics.d.ts +0 -66
- package/dist/src/analytics.js +0 -45
- package/dist/src/anthropic-console-auth.d.ts +0 -24
- package/dist/src/anthropic-console-auth.js +0 -37
- package/dist/src/anthropic-credentials.d.ts +0 -25
- package/dist/src/anthropic-credentials.js +0 -28
- package/dist/src/app-server/protocol.d.ts +19 -244
- package/dist/src/app-server/protocol.js +1 -132
- package/dist/src/app-server/reasoning.d.ts +0 -31
- package/dist/src/app-server/reasoning.js +0 -54
- package/dist/src/app-server/terminal.d.ts +0 -36
- package/dist/src/app-server/terminal.js +3 -39
- package/dist/src/app-server/workspace.d.ts +0 -167
- package/dist/src/app-server/workspace.js +4 -406
- package/dist/src/app-server.d.ts +33 -918
- package/dist/src/app-server.js +608 -2984
- package/dist/src/artifacts.d.ts +0 -10
- package/dist/src/artifacts.js +1 -11
- package/dist/src/attachments.d.ts +4 -98
- package/dist/src/attachments.js +10 -130
- package/dist/src/auth/AuthManager.d.ts +0 -93
- package/dist/src/auth/AuthManager.js +3 -165
- package/dist/src/auth/callback-page.d.ts +0 -1
- package/dist/src/auth/callback-page.js +0 -4
- package/dist/src/auth/callback.d.ts +0 -25
- package/dist/src/auth/callback.js +1 -29
- package/dist/src/auth/deployment.d.ts +0 -16
- package/dist/src/auth/deployment.js +0 -16
- package/dist/src/auth/index.d.ts +0 -11
- package/dist/src/auth/index.js +0 -11
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +7 -108
- package/dist/src/auth/store.js +21 -129
- package/dist/src/auth/types.d.ts +0 -8
- package/dist/src/auth-commands.d.ts +0 -5
- package/dist/src/auth-commands.js +0 -1
- package/dist/src/automation-runner.d.ts +0 -9
- package/dist/src/automation-runner.js +0 -11
- package/dist/src/automation-service.d.ts +0 -10
- package/dist/src/automation-service.js +3 -17
- package/dist/src/automation-tool.js +0 -5
- package/dist/src/automation-worker-shutdown.d.ts +0 -1
- package/dist/src/automation-worker-shutdown.js +0 -3
- package/dist/src/automations.d.ts +23 -2
- package/dist/src/automations.js +91 -12
- package/dist/src/background-tasks.d.ts +0 -23
- package/dist/src/background-tasks.js +0 -11
- package/dist/src/boot-trace.d.ts +0 -13
- package/dist/src/boot-trace.js +1 -14
- package/dist/src/browser-activity.js +0 -2
- package/dist/src/browser-bridge.d.ts +0 -2
- package/dist/src/browser-bridge.js +0 -27
- package/dist/src/browser-captcha-tool.d.ts +0 -13
- package/dist/src/browser-captcha-tool.js +3 -35
- package/dist/src/browser-extensions-tool.d.ts +24 -0
- package/dist/src/browser-extensions-tool.js +137 -0
- package/dist/src/browser-extensions.d.ts +127 -0
- package/dist/src/browser-extensions.js +729 -0
- package/dist/src/browser-observation.d.ts +0 -15
- package/dist/src/browser-observation.js +1 -22
- package/dist/src/browser-panel-tool.d.ts +10 -25
- package/dist/src/browser-panel-tool.js +64 -60
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +7 -46
- package/dist/src/browser-server.d.ts +0 -6
- package/dist/src/browser-server.js +6 -229
- package/dist/src/browser-session.d.ts +0 -25
- package/dist/src/browser-session.js +1 -71
- package/dist/src/browser-stealth.d.ts +0 -12
- package/dist/src/browser-stealth.js +0 -36
- package/dist/src/browser-ui/app.js +7 -174
- package/dist/src/browser-ui/style.css +0 -68
- package/dist/src/browser-ui/tokens.css +11 -93
- package/dist/src/browser-view.d.ts +52 -290
- package/dist/src/browser-view.js +354 -567
- package/dist/src/capabilities.d.ts +0 -8
- package/dist/src/capabilities.js +0 -29
- package/dist/src/capsolver.d.ts +0 -13
- package/dist/src/capsolver.js +0 -15
- package/dist/src/clarification-ui.d.ts +0 -7
- package/dist/src/clarification-ui.js +0 -8
- package/dist/src/claude-executable.d.ts +0 -1
- package/dist/src/claude-executable.js +1 -2
- package/dist/src/claude-provider.d.ts +6 -19
- package/dist/src/claude-provider.js +166 -61
- package/dist/src/cli-executable.d.ts +0 -16
- package/dist/src/cli-executable.js +0 -7
- package/dist/src/cli-process.d.ts +0 -26
- package/dist/src/cli-process.js +0 -18
- package/dist/src/cli-sign-in.d.ts +0 -20
- package/dist/src/cli-sign-in.js +1 -17
- package/dist/src/cli.d.ts +3 -56
- package/dist/src/cli.js +193 -702
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +27 -100
- package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
- package/dist/src/code-intelligence/ContextLedger.js +0 -10
- package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
- package/dist/src/code-intelligence/ContextRouter.js +0 -8
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
- package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
- package/dist/src/code-intelligence/repository.d.ts +0 -9
- package/dist/src/code-intelligence/repository.js +1 -11
- package/dist/src/code-intelligence/types.d.ts +0 -8
- package/dist/src/codex-auth.d.ts +0 -44
- package/dist/src/codex-auth.js +0 -45
- package/dist/src/codex-browser-auth.d.ts +0 -13
- package/dist/src/codex-browser-auth.js +3 -20
- package/dist/src/codex-errors.js +0 -2
- package/dist/src/codex-executable.d.ts +0 -2
- package/dist/src/codex-executable.js +1 -7
- package/dist/src/codex-provider.d.ts +0 -13
- package/dist/src/codex-provider.js +1 -26
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +6 -27
- package/dist/src/coding-tools.js +193 -205
- package/dist/src/command-metrics.d.ts +0 -4
- package/dist/src/command-output-tap.d.ts +0 -11
- package/dist/src/command-output-tap.js +0 -3
- package/dist/src/command-screens.d.ts +24 -0
- package/dist/src/command-screens.js +132 -100
- package/dist/src/commands.d.ts +6 -63
- package/dist/src/commands.js +20 -100
- package/dist/src/completion-gates.d.ts +0 -47
- package/dist/src/completion-gates.js +0 -14
- package/dist/src/completion.d.ts +2 -58
- package/dist/src/completion.js +90 -186
- package/dist/src/config.d.ts +12 -116
- package/dist/src/config.js +41 -171
- package/dist/src/context-budget.d.ts +0 -22
- package/dist/src/context-budget.js +0 -44
- package/dist/src/context-compaction.d.ts +29 -6
- package/dist/src/context-compaction.js +94 -25
- package/dist/src/context-selection.d.ts +0 -24
- package/dist/src/context-selection.js +0 -34
- package/dist/src/dashboard-view.d.ts +0 -2
- package/dist/src/dashboard-view.js +0 -35
- package/dist/src/dashboard.d.ts +0 -2
- package/dist/src/dashboard.js +0 -9
- package/dist/src/deadline.d.ts +0 -45
- package/dist/src/deadline.js +0 -54
- package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
- package/dist/src/decision/ContinuationAdapter.js +0 -5
- package/dist/src/decision/DecisionEngine.d.ts +0 -4
- package/dist/src/decision/DecisionManager.d.ts +0 -1
- package/dist/src/decision/DecisionManager.js +2 -7
- package/dist/src/decision/DecisionPolicy.d.ts +0 -1
- package/dist/src/decision/DecisionPolicy.js +0 -1
- package/dist/src/decision/FactContinuations.d.ts +11 -43
- package/dist/src/decision/FactContinuations.js +126 -95
- package/dist/src/decision/FactServiceGate.d.ts +0 -1
- package/dist/src/decision/FactServiceGate.js +0 -4
- package/dist/src/decision/PreparedSteps.d.ts +0 -15
- package/dist/src/decision/PreparedSteps.js +1 -11
- package/dist/src/decision/applyToolMenu.d.ts +0 -1
- package/dist/src/decision/applyToolMenu.js +1 -5
- package/dist/src/decision/checks.d.ts +15 -28
- package/dist/src/decision/checks.js +118 -49
- package/dist/src/decision/facts.d.ts +0 -16
- package/dist/src/decision/facts.js +0 -30
- package/dist/src/decision/guidancePolicy.js +0 -1
- package/dist/src/decision/hostedPolicy.d.ts +0 -6
- package/dist/src/decision/hostedPolicy.js +0 -7
- package/dist/src/decision/hostedSkills.d.ts +0 -19
- package/dist/src/decision/hostedSkills.js +0 -19
- package/dist/src/decision/optimizationPolicy.d.ts +0 -3
- package/dist/src/decision/optimizationPolicy.js +1 -4
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
- package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
- package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
- package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
- package/dist/src/decision/routeTools.d.ts +0 -8
- package/dist/src/decision/routeTools.js +1 -8
- package/dist/src/decision/toolFamilies.d.ts +0 -1
- package/dist/src/decision/toolFamilies.js +0 -1
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +0 -6
- package/dist/src/default-graph.d.ts +0 -9
- package/dist/src/default-graph.js +0 -9
- package/dist/src/delegation-changes.d.ts +0 -56
- package/dist/src/delegation-changes.js +15 -124
- package/dist/src/diff-preview.d.ts +1 -1
- package/dist/src/diff-preview.js +4 -12
- package/dist/src/duration.d.ts +0 -50
- package/dist/src/duration.js +0 -50
- package/dist/src/efficiency.d.ts +0 -39
- package/dist/src/efficiency.js +0 -16
- package/dist/src/engine/protocol.d.ts +0 -2
- package/dist/src/engine/protocol.js +0 -2
- package/dist/src/engine-streams.d.ts +13 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +76 -37
- package/dist/src/favicons.d.ts +0 -26
- package/dist/src/favicons.js +0 -34
- package/dist/src/file-diff.d.ts +2 -58
- package/dist/src/file-diff.js +0 -32
- package/dist/src/file-read-key.d.ts +1 -0
- package/dist/src/file-read-key.js +5 -0
- package/dist/src/file-read-state.d.ts +0 -1
- package/dist/src/file-read-state.js +0 -4
- package/dist/src/firefox-cookies.d.ts +0 -34
- package/dist/src/firefox-cookies.js +1 -55
- package/dist/src/git-identity-audit.d.ts +27 -0
- package/dist/src/git-identity-audit.js +286 -0
- package/dist/src/git-identity-guard.d.ts +4 -0
- package/dist/src/git-identity-guard.js +998 -0
- package/dist/src/git-identity-hold.d.ts +12 -0
- package/dist/src/git-identity-hold.js +81 -0
- package/dist/src/git-summary.d.ts +0 -58
- package/dist/src/git-summary.js +2 -212
- package/dist/src/goal-completion-verification.d.ts +2 -2
- package/dist/src/goal-completion-verification.js +3 -6
- package/dist/src/graph-account.d.ts +0 -21
- package/dist/src/graph-account.js +0 -17
- package/dist/src/graph-editor-session.d.ts +0 -1
- package/dist/src/graph-editor-session.js +1 -3
- package/dist/src/graph-health.d.ts +7 -49
- package/dist/src/graph-health.js +35 -46
- package/dist/src/graph-manager-chat.d.ts +27 -128
- package/dist/src/graph-manager-chat.js +36 -166
- package/dist/src/graph-provider-portability.d.ts +1 -21
- package/dist/src/graph-provider-portability.js +6 -45
- package/dist/src/graph-quota.d.ts +0 -33
- package/dist/src/graph-quota.js +1 -44
- package/dist/src/graph-runner.d.ts +0 -1
- package/dist/src/graph-runner.js +47 -387
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +0 -14
- package/dist/src/graph-server.d.ts +3 -11
- package/dist/src/graph-server.js +70 -111
- package/dist/src/graph-studio-features.d.ts +0 -5
- package/dist/src/graph-studio-features.js +2 -42
- package/dist/src/graph-sync.d.ts +0 -78
- package/dist/src/graph-sync.js +5 -201
- package/dist/src/graph-tool.d.ts +0 -18
- package/dist/src/graph-tool.js +0 -27
- package/dist/src/graph-ui/app.js +229 -498
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +47 -43
- package/dist/src/graph-ui/controls.js +0 -88
- package/dist/src/graph-ui/drafts.js +0 -12
- package/dist/src/graph-ui/edge-router.js +0 -62
- package/dist/src/graph-ui/embed.js +0 -59
- package/dist/src/graph-ui/icons.js +2 -7
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/library.css +0 -5
- package/dist/src/graph-ui/manager-markdown.js +0 -11
- package/dist/src/graph-ui/manager-state.js +110 -49
- package/dist/src/graph-ui/manager.css +2 -20
- package/dist/src/graph-ui/manager.js +251 -166
- package/dist/src/graph-ui/model-picker.js +250 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- package/dist/src/graph-ui/sidebar.js +2 -3
- package/dist/src/graph-ui/skill-picker.js +373 -39
- package/dist/src/graph-ui/studio-canvas.js +3 -38
- package/dist/src/graph-ui/studio.css +0 -18
- package/dist/src/graph-ui/studio.js +3 -71
- package/dist/src/graph-ui/style.css +11 -134
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +15 -114
- package/dist/src/graphs.d.ts +7 -156
- package/dist/src/graphs.js +72 -273
- package/dist/src/grep-regex-worker.js +0 -2
- package/dist/src/grep-regex.d.ts +1 -5
- package/dist/src/grep-regex.js +6 -8
- package/dist/src/grok-provider.d.ts +0 -17
- package/dist/src/grok-provider.js +1 -26
- package/dist/src/handoffs.d.ts +0 -11
- package/dist/src/handoffs.js +0 -13
- package/dist/src/hardened-runtime.d.ts +0 -10
- package/dist/src/hardened-runtime.js +8 -46
- package/dist/src/harness-home.d.ts +21 -0
- package/dist/src/harness-home.js +87 -0
- package/dist/src/host-process-guard.d.ts +0 -50
- package/dist/src/host-process-guard.js +0 -641
- package/dist/src/limits.d.ts +0 -64
- package/dist/src/limits.js +0 -62
- package/dist/src/managed-sign-in.d.ts +0 -12
- package/dist/src/managed-sign-in.js +0 -16
- package/dist/src/markdown.d.ts +0 -28
- package/dist/src/markdown.js +1 -175
- package/dist/src/mcp.d.ts +21 -82
- package/dist/src/mcp.js +228 -237
- package/dist/src/membership-errors.d.ts +0 -14
- package/dist/src/membership-errors.js +0 -13
- package/dist/src/membership.d.ts +2 -60
- package/dist/src/membership.js +0 -85
- package/dist/src/memory/LocalToolMemory.d.ts +0 -1
- package/dist/src/memory/LocalToolMemory.js +2 -7
- package/dist/src/memory/MemoryDistiller.js +0 -15
- package/dist/src/memory/MemoryManager.d.ts +0 -3
- package/dist/src/memory/MemoryManager.js +6 -18
- package/dist/src/memory/MemoryPolicy.d.ts +0 -2
- package/dist/src/memory/MemoryPolicy.js +0 -2
- package/dist/src/memory/MemoryProvider.d.ts +0 -6
- package/dist/src/memory/MemoryRetriever.js +0 -7
- package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
- package/dist/src/memory/PermissionMemoryProvider.js +0 -1
- package/dist/src/memory/ProjectMemory.d.ts +42 -0
- package/dist/src/memory/ProjectMemory.js +285 -0
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
- package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
- package/dist/src/memory/redaction.d.ts +0 -5
- package/dist/src/memory/redaction.js +0 -11
- package/dist/src/memory/repository.d.ts +0 -6
- package/dist/src/memory/repository.js +2 -12
- package/dist/src/memory/types.d.ts +0 -1
- package/dist/src/model-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +1 -49
- package/dist/src/model-metadata.d.ts +0 -18
- package/dist/src/model-metadata.js +2 -42
- package/dist/src/model-override.d.ts +0 -36
- package/dist/src/model-override.js +0 -43
- package/dist/src/model-tiers.d.ts +0 -13
- package/dist/src/model-tiers.js +0 -23
- package/dist/src/opencode-catalog.d.ts +0 -2
- package/dist/src/opencode-catalog.js +0 -11
- package/dist/src/opencode-cli-provider.d.ts +0 -35
- package/dist/src/opencode-cli-provider.js +1 -44
- package/dist/src/opencode-provider.d.ts +0 -2
- package/dist/src/opencode-provider.js +6 -22
- package/dist/src/package-name.d.ts +1 -0
- package/dist/src/package-name.js +1 -0
- package/dist/src/paged-transcript.d.ts +0 -11
- package/dist/src/paged-transcript.js +2 -20
- package/dist/src/palette.d.ts +0 -63
- package/dist/src/palette.js +0 -63
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +0 -17
- package/dist/src/powershell-pool.d.ts +0 -9
- package/dist/src/powershell-pool.js +3 -26
- package/dist/src/process-warnings.d.ts +4 -0
- package/dist/src/process-warnings.js +103 -0
- package/dist/src/profile.d.ts +0 -43
- package/dist/src/profile.js +0 -43
- package/dist/src/project-reservation.d.ts +11 -0
- package/dist/src/project-reservation.js +143 -0
- package/dist/src/provider-connection.d.ts +0 -18
- package/dist/src/provider-connection.js +0 -39
- package/dist/src/provider-engine.d.ts +0 -21
- package/dist/src/provider-engine.js +3 -98
- package/dist/src/provider-import.d.ts +0 -49
- package/dist/src/provider-import.js +0 -60
- package/dist/src/provider-keys.d.ts +1 -36
- package/dist/src/provider-keys.js +5 -48
- package/dist/src/provider-settings.d.ts +0 -2
- package/dist/src/provider-settings.js +0 -32
- package/dist/src/providers.d.ts +0 -217
- package/dist/src/providers.js +0 -315
- package/dist/src/pull-requests.d.ts +0 -173
- package/dist/src/pull-requests.js +5 -195
- package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
- package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
- package/dist/src/qa/command-policy.d.ts +0 -23
- package/dist/src/qa/command-policy.js +0 -30
- package/dist/src/qa/guidance.d.ts +0 -21
- package/dist/src/qa/guidance.js +0 -20
- package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
- package/dist/src/qa/profile/ProjectInspector.js +0 -6
- package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
- package/dist/src/qa/profile/QaConfigLoader.js +0 -6
- package/dist/src/qa/profile/QaProfile.d.ts +0 -7
- package/dist/src/qa/profile/QaProfile.js +0 -7
- package/dist/src/qa/profile/yaml.d.ts +0 -9
- package/dist/src/qa/profile/yaml.js +0 -13
- package/dist/src/qa/qa-authorize.d.ts +0 -19
- package/dist/src/qa/qa-authorize.js +4 -11
- package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
- package/dist/src/qa/runtime/ProcessManager.js +4 -41
- package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
- package/dist/src/qa/runtime/PtyManager.js +2 -7
- package/dist/src/qa/runtime/changes.d.ts +0 -11
- package/dist/src/qa/runtime/changes.js +1 -3
- package/dist/src/qa/tools.d.ts +0 -10
- package/dist/src/qa/tools.js +0 -12
- package/dist/src/qa/types.d.ts +0 -13
- package/dist/src/react-runtime.d.ts +2 -21
- package/dist/src/react-runtime.js +106 -418
- package/dist/src/read-document-doc.d.ts +0 -6
- package/dist/src/read-document-doc.js +0 -55
- package/dist/src/read-document-docx.d.ts +0 -16
- package/dist/src/read-document-docx.js +2 -69
- package/dist/src/read-document-text.d.ts +0 -17
- package/dist/src/read-document-text.js +0 -22
- package/dist/src/read-document-tool.d.ts +0 -31
- package/dist/src/read-document-tool.js +0 -30
- package/dist/src/read-document.d.ts +0 -49
- package/dist/src/read-document.js +1 -67
- package/dist/src/read-image.d.ts +0 -32
- package/dist/src/read-image.js +0 -33
- package/dist/src/remote/cert.d.ts +1 -19
- package/dist/src/remote/cert.js +2 -51
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +2 -117
- package/dist/src/remote/command.js +0 -17
- package/dist/src/remote/engine-pool.d.ts +0 -152
- package/dist/src/remote/engine-pool.js +17 -335
- package/dist/src/remote/errors.d.ts +0 -15
- package/dist/src/remote/errors.js +0 -7
- package/dist/src/remote/network.d.ts +0 -26
- package/dist/src/remote/network.js +1 -34
- package/dist/src/remote/pairing.d.ts +16 -51
- package/dist/src/remote/pairing.js +50 -57
- package/dist/src/remote/pem.d.ts +2 -0
- package/dist/src/remote/pem.js +7 -0
- package/dist/src/remote/roots.d.ts +0 -20
- package/dist/src/remote/roots.js +0 -8
- package/dist/src/remote/serve.d.ts +0 -47
- package/dist/src/remote/serve.js +0 -30
- package/dist/src/remote/server.d.ts +0 -14
- package/dist/src/remote/server.js +1 -79
- package/dist/src/remote/types.d.ts +1 -32
- package/dist/src/remote/types.js +0 -10
- package/dist/src/run-control.d.ts +0 -7
- package/dist/src/run-control.js +0 -7
- package/dist/src/run-progress.d.ts +0 -170
- package/dist/src/run-progress.js +0 -285
- package/dist/src/run-records.d.ts +0 -443
- package/dist/src/run-records.js +44 -678
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +11 -227
- package/dist/src/runtime.js +0 -127
- package/dist/src/sandbox-child.js +0 -1
- package/dist/src/save-lock.d.ts +0 -12
- package/dist/src/save-lock.js +0 -28
- package/dist/src/screen-selection.d.ts +0 -23
- package/dist/src/screen-selection.js +0 -22
- package/dist/src/secret-redaction.d.ts +0 -12
- package/dist/src/secret-redaction.js +0 -45
- package/dist/src/session-changes.d.ts +4 -80
- package/dist/src/session-changes.js +25 -130
- package/dist/src/session-goal.d.ts +129 -0
- package/dist/src/session-goal.js +230 -0
- package/dist/src/session-monitor.d.ts +1 -10
- package/dist/src/session-monitor.js +2 -39
- package/dist/src/session-reaper.d.ts +0 -15
- package/dist/src/session-reaper.js +0 -14
- package/dist/src/session-skills.d.ts +15 -44
- package/dist/src/session-skills.js +75 -60
- package/dist/src/session-summary.d.ts +0 -26
- package/dist/src/session-summary.js +0 -32
- package/dist/src/session-title.d.ts +0 -1
- package/dist/src/session-title.js +0 -2
- package/dist/src/sessions.d.ts +2 -120
- package/dist/src/sessions.js +9 -178
- package/dist/src/shell.d.ts +3 -20
- package/dist/src/shell.js +8 -72
- package/dist/src/side-panel.d.ts +5 -99
- package/dist/src/side-panel.js +76 -133
- package/dist/src/sign-in-detection.d.ts +43 -0
- package/dist/src/sign-in-detection.js +154 -0
- package/dist/src/sign-in-offer.d.ts +17 -0
- package/dist/src/sign-in-offer.js +103 -0
- package/dist/src/skill-commands.d.ts +0 -1
- package/dist/src/skill-commands.js +1 -4
- package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +22 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/invocable-skills.d.ts +0 -18
- package/dist/src/skills/invocable-skills.js +0 -17
- package/dist/src/skills/project-skills.d.ts +0 -1
- package/dist/src/skills/project-skills.js +0 -3
- package/dist/src/skills/prompt-skills.js +0 -14
- package/dist/src/skills/runtime-skills.d.ts +1 -8
- package/dist/src/skills/runtime-skills.js +8 -32
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +5 -0
- package/dist/src/stray-files.js +65 -0
- package/dist/src/structured-step.d.ts +0 -22
- package/dist/src/structured-step.js +0 -22
- package/dist/src/subagent-run.d.ts +0 -163
- package/dist/src/subagent-run.js +10 -374
- package/dist/src/subagent-tree.d.ts +32 -0
- package/dist/src/subagent-tree.js +128 -0
- package/dist/src/telemetry/aggregate.d.ts +0 -37
- package/dist/src/telemetry/aggregate.js +0 -40
- package/dist/src/telemetry/capture-core.d.ts +0 -87
- package/dist/src/telemetry/capture-core.js +0 -67
- package/dist/src/telemetry/capture.d.ts +0 -1
- package/dist/src/telemetry/capture.js +0 -3
- package/dist/src/telemetry/classify.d.ts +0 -58
- package/dist/src/telemetry/classify.js +0 -60
- package/dist/src/telemetry/decision-capture.d.ts +0 -1
- package/dist/src/telemetry/emitter.d.ts +0 -30
- package/dist/src/telemetry/emitter.js +1 -62
- package/dist/src/telemetry/gate.d.ts +0 -29
- package/dist/src/telemetry/gate.js +0 -22
- package/dist/src/telemetry/identity.d.ts +0 -13
- package/dist/src/telemetry/identity.js +0 -29
- package/dist/src/telemetry/outbox.d.ts +0 -64
- package/dist/src/telemetry/outbox.js +1 -108
- package/dist/src/telemetry/schema.d.ts +1 -49
- package/dist/src/telemetry/schema.js +1 -82
- package/dist/src/telemetry/state.d.ts +0 -53
- package/dist/src/telemetry/state.js +0 -64
- package/dist/src/telemetry/surface.d.ts +0 -31
- package/dist/src/telemetry/surface.js +1 -39
- package/dist/src/telemetry/uploader.d.ts +0 -11
- package/dist/src/telemetry/uploader.js +0 -46
- package/dist/src/telemetry/uploads.d.ts +0 -11
- package/dist/src/telemetry/uploads.js +0 -11
- package/dist/src/telemetry/version.d.ts +0 -4
- package/dist/src/telemetry/version.js +0 -14
- package/dist/src/telemetry/workspace.d.ts +0 -7
- package/dist/src/telemetry/workspace.js +1 -22
- package/dist/src/terminal-ui.d.ts +15 -524
- package/dist/src/terminal-ui.js +80 -876
- package/dist/src/test-edit-guard.d.ts +74 -0
- package/dist/src/test-edit-guard.js +269 -0
- package/dist/src/text.d.ts +0 -1
- package/dist/src/text.js +0 -1
- package/dist/src/time-limit.d.ts +0 -36
- package/dist/src/time-limit.js +0 -37
- package/dist/src/timers.d.ts +0 -161
- package/dist/src/timers.js +0 -126
- package/dist/src/todos.d.ts +0 -1
- package/dist/src/todos.js +0 -3
- package/dist/src/token-rate.d.ts +0 -94
- package/dist/src/token-rate.js +0 -154
- package/dist/src/tool-activity.d.ts +0 -6
- package/dist/src/tool-activity.js +1 -8
- package/dist/src/tool-availability.d.ts +0 -13
- package/dist/src/tool-availability.js +1 -14
- package/dist/src/tool-call-clock.d.ts +1 -4
- package/dist/src/tool-call-clock.js +0 -13
- package/dist/src/tool-catalog.d.ts +0 -11
- package/dist/src/tool-catalog.js +0 -23
- package/dist/src/tool-dependencies.d.ts +0 -5
- package/dist/src/tool-dependencies.js +0 -4
- package/dist/src/tool-diff-stats.d.ts +0 -23
- package/dist/src/tool-diff-stats.js +0 -49
- package/dist/src/tool-errors.d.ts +9 -7
- package/dist/src/tool-errors.js +13 -6
- package/dist/src/tool-failure-tracker.d.ts +3 -11
- package/dist/src/tool-failure-tracker.js +19 -27
- package/dist/src/tool-names.d.ts +0 -16
- package/dist/src/tool-names.js +0 -12
- package/dist/src/tool-profile.d.ts +6 -0
- package/dist/src/tool-profile.js +23 -0
- package/dist/src/tool-result-filter.d.ts +0 -19
- package/dist/src/tool-result-filter.js +1 -66
- package/dist/src/tool-schema-compatibility.d.ts +1 -2
- package/dist/src/tool-schema-compatibility.js +2 -7
- package/dist/src/tools.d.ts +0 -4
- package/dist/src/tools.js +11 -114
- package/dist/src/trajectory.d.ts +0 -13
- package/dist/src/trajectory.js +23 -79
- package/dist/src/transcript.d.ts +1 -37
- package/dist/src/transcript.js +11 -61
- package/dist/src/types.d.ts +2 -167
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +105 -0
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +2 -16
- package/dist/src/update.d.ts +4 -29
- package/dist/src/update.js +20 -98
- package/dist/src/usage-analytics.d.ts +17 -17
- package/dist/src/usage-analytics.js +168 -209
- package/dist/src/web-search.d.ts +0 -23
- package/dist/src/web-search.js +1 -27
- package/dist/src/widgets.d.ts +0 -25
- package/dist/src/widgets.js +0 -24
- package/dist/src/workspace-facts.d.ts +0 -12
- package/dist/src/workspace-facts.js +1 -18
- package/dist/src/workspace-git-metadata.d.ts +4 -5
- package/dist/src/workspace-git-metadata.js +37 -9
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +7 -20
- package/package.json +2 -2
package/dist/src/terminal-ui.js
CHANGED
|
@@ -6,40 +6,27 @@ import { stripVTControlCharacters } from 'node:util';
|
|
|
6
6
|
import stringWidth from 'string-width';
|
|
7
7
|
import { DashboardMetrics } from './dashboard.js';
|
|
8
8
|
import { dashboardRows } from './dashboard-view.js';
|
|
9
|
+
import { goalStatusLabel } from './session-goal.js';
|
|
9
10
|
import { transcriptColor } from './transcript.js';
|
|
10
11
|
import { ToolCallClock, toolHeaderRows } from './tool-call-clock.js';
|
|
11
12
|
import { formatDuration, formatHms } from './duration.js';
|
|
12
13
|
import { PagedTranscript } from './paged-transcript.js';
|
|
13
14
|
import { emptySelection, highlightRow, selectedSpan, selectedText, wordAt } from './screen-selection.js';
|
|
14
15
|
import { accentSgr, ATTACHMENT_TOKEN, ATTENTION, DIM, FAINT, GRAY, SKILL_CHIP, SUBTLE, WHITE } from './palette.js';
|
|
15
|
-
import { isCustomGraph, panelRowText, panelWidth, PANEL_MIN_COLUMNS, PANEL_MIN_ROWS, sidePanelRows } from './side-panel.js';
|
|
16
|
+
import { isCustomGraph, panelRowText, panelWidth, PANEL_MIN_COLUMNS, PANEL_MIN_ROWS, sidePanelRows, subagentTreeRows } from './side-panel.js';
|
|
16
17
|
import { TokenRateMeter } from './token-rate.js';
|
|
18
|
+
import { SubagentTracker } from './subagent-tree.js';
|
|
17
19
|
import { attachmentLabel, droppedPaths, formatBytes, isLargePaste, MAX_ATTACHMENTS } from './attachments.js';
|
|
20
|
+
import { holdWarnings } from './process-warnings.js';
|
|
18
21
|
const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
19
22
|
const graphemes = (text) => [...segmenter.segment(text)].map(part => part.segment);
|
|
20
|
-
/**
|
|
21
|
-
* Attachment tokens live in the composer draft as one code point each from Supplementary
|
|
22
|
-
* Private Use Area-B, which no font or input method emits. `clean` strips that plane from
|
|
23
|
-
* everything typed or pasted, so only `addAttachment` can put a token into the draft.
|
|
24
|
-
*/
|
|
25
23
|
const TOKEN_BASE = 0x100000;
|
|
26
24
|
const isToken = (part) => (part.codePointAt(0) ?? 0) >= TOKEN_BASE;
|
|
27
|
-
/**
|
|
28
|
-
* The skill chip: the leading `/name` of a picked skill, held as one code point so Backspace, Delete,
|
|
29
|
-
* the arrows and selections treat it as a unit. It sits at the top of the private-use plane, above
|
|
30
|
-
* every attachment marker, and like them it cannot be typed or pasted (`clean` strips the plane).
|
|
31
|
-
*/
|
|
32
25
|
const SKILL_TOKEN = String.fromCodePoint(0x10FFFD);
|
|
33
|
-
/** Graphemes of a draft, keeping each token its own element even when a combining mark follows it. */
|
|
34
26
|
const composerGraphemes = (text) => graphemes(text).flatMap(part => isToken(part) && part.length > 2 ? [part.slice(0, 2), part.slice(2)] : [part]);
|
|
35
27
|
const clean = (text) => stripVTControlCharacters(text).replace(/\r\n?/g, '\n').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, '').replace(/[\u{100000}-\u{10FFFF}]/gu, '').replace(/\t/g, ' ');
|
|
36
28
|
const oneLine = (text) => clean(text).replace(/\n/g, ' ');
|
|
37
|
-
const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/status', '/clear', '/compact', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
|
|
38
|
-
/**
|
|
39
|
-
* The arguments the popup offers once a command and a space are typed. The read-only choice comes
|
|
40
|
-
* first wherever there is one, so a second Enter on a freshly opened list reports rather than
|
|
41
|
-
* changes a setting.
|
|
42
|
-
*/
|
|
29
|
+
const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/status', '/clear', '/compact', '/goal', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
|
|
43
30
|
const argumentCompletions = {
|
|
44
31
|
'/jev': ['/jev status', '/jev on', '/jev off'],
|
|
45
32
|
'/feedback': ['/feedback status', '/feedback on', '/feedback off'],
|
|
@@ -47,38 +34,26 @@ const argumentCompletions = {
|
|
|
47
34
|
'/reasoning': ['default', 'none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'].map(level => `/reasoning ${level}`),
|
|
48
35
|
'/codegraph': ['/codegraph status', '/codegraph enable', '/codegraph disable', '/codegraph rebuild', '/codegraph enable --global', '/codegraph disable --global'],
|
|
49
36
|
'/attach': [],
|
|
37
|
+
'/goal': ['/goal clear'],
|
|
50
38
|
'/logout': ['/logout codex'],
|
|
51
39
|
'/skill': ['/skill off', '/skill on', '/skill remove'],
|
|
52
40
|
};
|
|
53
|
-
/**
|
|
54
|
-
* Commands that do nothing useful bare. Enter or Tab on one fills in the command and a space and
|
|
55
|
-
* waits for the argument instead of running it; `/logout` is complete on its own.
|
|
56
|
-
*/
|
|
57
41
|
const argumentRequired = new Set(['/jev', '/feedback', '/yolo', '/reasoning', '/codegraph', '/attach']);
|
|
58
42
|
const completionOptions = (query, skills = []) => {
|
|
59
43
|
const command = /^(\/\S+)\s/.exec(query)?.[1];
|
|
60
|
-
// A command typed in full is offered first, so `/skill` runs itself rather than `/skills`, which
|
|
61
|
-
// a shorter prefix such as `/sk` still reaches first.
|
|
62
44
|
return (command === undefined ? [...commands, ...skills] : argumentCompletions[command] ?? []).filter(option => option.startsWith(query))
|
|
63
45
|
.sort((a, b) => Number(b === query) - Number(a === query));
|
|
64
46
|
};
|
|
65
|
-
/**
|
|
66
|
-
* Whether the composer text is a command name, or a command with arguments, that the popup completes.
|
|
67
|
-
* A command that is complete on its own lists its arguments only once one is being typed: `/logout `
|
|
68
|
-
* must submit the bare sign-out, not have Enter pick `/logout codex` from a list nobody asked for.
|
|
69
|
-
*/
|
|
70
47
|
const completable = (query) => {
|
|
71
48
|
if (/^\/\S*$/.test(query))
|
|
72
49
|
return true;
|
|
73
50
|
const [, command, argument] = /^(\/\S+) (\S*)$/.exec(query) ?? [];
|
|
74
51
|
return command !== undefined && Object.hasOwn(argumentCompletions, command) && (argument !== '' || argumentRequired.has(command));
|
|
75
52
|
};
|
|
76
|
-
/** A fixed-width, two-line terminal wordmark for the default Andorra CLI. */
|
|
77
53
|
const ANDORRA_WORDMARK = [
|
|
78
54
|
'▄▀█ █▄ █ █▀▄ █▀█ █▀█ █▀█ ▄▀█',
|
|
79
55
|
'█▀█ █ ▀█ █▄▀ █▄█ █▀▄ █▀▄ █▀█',
|
|
80
56
|
];
|
|
81
|
-
/** Said under the workflow name while the selected graph cannot bind to this machine's providers. */
|
|
82
57
|
const OVERRIDE_HINT = 'Choose a model to override the nodes with · /model';
|
|
83
58
|
const commandDescriptions = {
|
|
84
59
|
'/browser': 'Open the browser workspace',
|
|
@@ -97,87 +72,41 @@ const commandDescriptions = {
|
|
|
97
72
|
'/permissions': 'Choose workspace permissions',
|
|
98
73
|
'/tools': 'Available coding tools', '/status': 'Workspace and settings', '/clear': 'Clear conversation',
|
|
99
74
|
'/compact': 'Compact conversation history',
|
|
75
|
+
'/goal': 'Set, show or clear the session goal', '/goal clear': 'Remove the session goal',
|
|
100
76
|
'/help': 'Show command help', '/exit': 'Exit Andorra', '/quit': 'Alias for /exit',
|
|
101
77
|
};
|
|
102
|
-
/**
|
|
103
|
-
* The session command a submitted line starts with, if any.
|
|
104
|
-
*
|
|
105
|
-
* The first whitespace-delimited token must match a known command's root exactly. A leading-slash
|
|
106
|
-
* test alone would swallow legitimate steering text that merely mentions a path such as
|
|
107
|
-
* `/src/app.ts`, and an unknown `/notacommand` is not a session command either.
|
|
108
|
-
* @param value - the submitted composer text.
|
|
109
|
-
* @returns the command token, or undefined when the text is ordinary input.
|
|
110
|
-
*/
|
|
111
78
|
const submittedCommand = (value) => {
|
|
112
79
|
const [token] = value.trim().split(/\s+/);
|
|
113
80
|
return commands.some(command => command.split(/\s+/)[0] === token) ? token : undefined;
|
|
114
81
|
};
|
|
115
|
-
/**
|
|
116
|
-
* The hint shown when a session command is typed while a task is working.
|
|
117
|
-
*
|
|
118
|
-
* Commands run between tasks: a started run has its history snapshotted and stays pinned to
|
|
119
|
-
* its graph revision, so executing one mid-run would misreport what the run actually used.
|
|
120
|
-
* The hint names the command and the way out instead of queueing the text as an instruction
|
|
121
|
-
* the model would then follow.
|
|
122
|
-
* @param command - the recognized command token that was submitted.
|
|
123
|
-
*/
|
|
124
82
|
const workingCommandHint = (command) => `${command} doesn't run while a task is working. Press Ctrl+C to stop this task, then run ${command}.`
|
|
125
83
|
+ (command === '/graph' ? ' Switching graphs clears the previous graph progress and starts fresh.' : '');
|
|
126
|
-
/** Commands the run input handler executes live during a run, plus its exits; they must reach it. */
|
|
127
84
|
const liveRunCommands = ['/browser', '/attach', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools', '/exit', '/quit'];
|
|
128
85
|
const paint = (text, color = GRAY) => typeof color === 'number'
|
|
129
86
|
? `\x1b[38;5;${color}m${text}\x1b[0m`
|
|
130
87
|
: `\x1b[${color}m${text}\x1b[0m`;
|
|
131
|
-
/**
|
|
132
|
-
* Foreground sequence for the Andorra accent.
|
|
133
|
-
*
|
|
134
|
-
* Resolved per render rather than at module load: truecolor support is read from the
|
|
135
|
-
* environment, which a test or embedder may set after this module is imported, and
|
|
136
|
-
* caching the first answer would pin the fallback for the whole process.
|
|
137
|
-
*/
|
|
138
88
|
const accentPaint = () => accentSgr();
|
|
139
|
-
/** Thousands as `1.2k`, the shape both footer token readouts need to stay on one row. */
|
|
140
89
|
const compactNumber = (value) => Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 }).format(value);
|
|
141
90
|
const MAX_INPUT = 65_536;
|
|
142
|
-
/**
|
|
143
|
-
* Bracketed-paste accumulation ceiling. An in-flight paste may exceed the inline limit because
|
|
144
|
-
* a large paste never inlines: it spools to an attachment, whose own cap this matches.
|
|
145
|
-
*/
|
|
146
91
|
const PASTE_ACCUMULATE_LIMIT = 1_048_576;
|
|
147
92
|
const INPUT_BURST_MS = 40;
|
|
148
|
-
/** Two presses on one cell within this window select the word under it. */
|
|
149
93
|
const DOUBLE_CLICK_MS = 400;
|
|
150
|
-
/** The legacy X10 mouse report prefix: ESC [ M, followed by three payload bytes. */
|
|
151
94
|
const LEGACY_MOUSE = Buffer.from([0x1b, 0x5b, 0x4d]);
|
|
152
|
-
/** The bracketed-paste terminator, as bytes. */
|
|
153
95
|
const PASTE_END = Buffer.from('\x1b[201~', 'latin1');
|
|
154
|
-
/** How many trailing bytes of `buffer` could still grow into a `LEGACY_MOUSE` prefix. */
|
|
155
96
|
const legacyMousePrefixLength = (buffer) => {
|
|
156
97
|
for (let length = Math.min(2, buffer.length); length > 0; length--)
|
|
157
98
|
if (buffer.subarray(buffer.length - length).equals(LEGACY_MOUSE.subarray(0, length)))
|
|
158
99
|
return length;
|
|
159
100
|
return 0;
|
|
160
101
|
};
|
|
161
|
-
/** Rows an echoed prompt may occupy before the tail is replaced by an omission marker. */
|
|
162
102
|
const MAX_PROMPT_ROWS = 200;
|
|
163
|
-
/** Long submitted prompts collapse in chat history until the user expands them with Ctrl+O. */
|
|
164
103
|
const PROMPT_COLLAPSE_AFTER_ROWS = 12;
|
|
165
104
|
const PROMPT_COLLAPSED_BODY_ROWS = 6;
|
|
166
|
-
/**
|
|
167
|
-
* Characters of streamed reasoning retained for the live preview. Only the tail ever
|
|
168
|
-
* renders, so the buffer is a bounded window, not the full reasoning transcript.
|
|
169
|
-
*/
|
|
170
105
|
const THINKING_KEEP = 4_000;
|
|
171
|
-
|
|
106
|
+
const AGENT_FALLBACK_MAX_ROWS = 7;
|
|
107
|
+
const AGENT_FALLBACK_MAX_COLUMNS = 60;
|
|
172
108
|
const THINKING_ROWS = 6;
|
|
173
|
-
/** Minimum milliseconds between preview repaints; faster streams coalesce into one render. */
|
|
174
109
|
const THINKING_PAINT_MS = 80;
|
|
175
|
-
/**
|
|
176
|
-
* Ownership token for the composer while steering.
|
|
177
|
-
*
|
|
178
|
-
* A deferred Enter is only delivered when the surface that armed it still owns the
|
|
179
|
-
* composer, so this stands in for `pending` when the steering composer is the owner.
|
|
180
|
-
*/
|
|
181
110
|
const STEERING_OWNER = Symbol('steering');
|
|
182
111
|
const commandPopupRows = (width, height, inputRows, matches) => width < 12 || height < 9
|
|
183
112
|
? 0 : Math.min(6, Math.max(1, matches), Math.max(0, height - inputRows - 11));
|
|
@@ -232,7 +161,6 @@ function wrap(text, width) {
|
|
|
232
161
|
}
|
|
233
162
|
return result;
|
|
234
163
|
}
|
|
235
|
-
/** Display-column span [start, end) of the selected graphemes on one wrapped composer row. */
|
|
236
164
|
function selectedColumns(text, positions, [from, to], row) {
|
|
237
165
|
let start = Infinity, end = -Infinity;
|
|
238
166
|
for (let index = from; index < to; index++) {
|
|
@@ -244,10 +172,6 @@ function selectedColumns(text, positions, [from, to], row) {
|
|
|
244
172
|
}
|
|
245
173
|
return start < end ? [start, end] : undefined;
|
|
246
174
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Paint one composer row: attachment token columns in bold, and the selected column span in
|
|
249
|
-
* reverse video over whichever color it covers.
|
|
250
|
-
*/
|
|
251
175
|
function composerRow(text, color, selection, tokens) {
|
|
252
176
|
let painted = '', run = '', style = '';
|
|
253
177
|
let column = 0;
|
|
@@ -267,14 +191,12 @@ function composerRow(text, color, selection, tokens) {
|
|
|
267
191
|
flush();
|
|
268
192
|
return painted;
|
|
269
193
|
}
|
|
270
|
-
/** The display-column spans the draft's tokens occupy on one composer row. */
|
|
271
194
|
function tokenColumns(draft, visible, positions, row) {
|
|
272
195
|
const spans = [];
|
|
273
196
|
draft.forEach((part, index) => { const position = positions[index]; if (isToken(part) && position?.row === row)
|
|
274
197
|
spans.push([position.column, position.column + stringWidth(visible[index]), part === SKILL_TOKEN ? 'skill' : 'attachment']); });
|
|
275
198
|
return spans;
|
|
276
199
|
}
|
|
277
|
-
/** Whitespace as one editor element; a token label is a single element that contains spaces. */
|
|
278
200
|
const blank = (part) => /^\s+$/u.test(part);
|
|
279
201
|
function editor(text, width) {
|
|
280
202
|
const lines = [''];
|
|
@@ -335,7 +257,6 @@ function editor(text, width) {
|
|
|
335
257
|
}
|
|
336
258
|
return { lines, positions };
|
|
337
259
|
}
|
|
338
|
-
/** Full-screen terminal presentation; provider/runtime behavior remains owned by the CLI. */
|
|
339
260
|
export class TerminalUI extends EventEmitter {
|
|
340
261
|
input;
|
|
341
262
|
output;
|
|
@@ -345,30 +266,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
345
266
|
keys = new PassThrough();
|
|
346
267
|
decoder = new StringDecoder('utf8');
|
|
347
268
|
status;
|
|
348
|
-
/**
|
|
349
|
-
* Graph nodes the user currently has running, in the order they started.
|
|
350
|
-
*
|
|
351
|
-
* `provider` and `model` are what each node's own executor reported, not what the graph file
|
|
352
|
-
* configured, so a retry that falls back to another profile moves the footer with it.
|
|
353
|
-
*
|
|
354
|
-
* `resolved` carries the reasoning effort and context window of that same resolution. It stays
|
|
355
|
-
* absent until a run reports them, and an absent `resolved` keeps the session's own numbers on
|
|
356
|
-
* the footer; a present one whose fields are undefined means that node's model has no effort or
|
|
357
|
-
* window of its own, which the footer shows as `provider default` and as no window at all
|
|
358
|
-
* rather than falling back to the session's unrelated values.
|
|
359
|
-
*/
|
|
360
269
|
activeNodes = new Map();
|
|
361
|
-
/**
|
|
362
|
-
* Node ids the current run has finished, in visit order.
|
|
363
|
-
*
|
|
364
|
-
* The side panel's zoom marks the run's trail with it, so it survives the run's end - a
|
|
365
|
-
* reader looking at a finished run can still see where it went - and is cleared only when
|
|
366
|
-
* the next run starts, which is the point the trail stops describing what is on screen.
|
|
367
|
-
*/
|
|
368
|
-
/** Whether the last frame drew without the panel, so its return can be announced once. */
|
|
369
270
|
panelWasHidden = true;
|
|
370
271
|
visitedNodes = new Set();
|
|
371
|
-
|
|
272
|
+
subagents = new SubagentTracker();
|
|
372
273
|
stoppedNode;
|
|
373
274
|
toolClock = new ToolCallClock();
|
|
374
275
|
toolClockTimer;
|
|
@@ -389,38 +290,21 @@ export class TerminalUI extends EventEmitter {
|
|
|
389
290
|
dashboardNotices = [];
|
|
390
291
|
nodeModels = new Map();
|
|
391
292
|
toggleDashboard() { this.dashboard = !this.dashboard; this.scroll = 0; this.scheduleRender(); }
|
|
392
|
-
/** Start of a run: open the dashboard's run window. */
|
|
393
293
|
startTask() { this.runActive = true; this.dashboardMetrics.startTask(); this.dashboardNotices = []; this.nodeModels.clear(); this.scheduleRender(); }
|
|
394
|
-
/** End of a run: close the dashboard's run window. */
|
|
395
294
|
finishTask() { this.runActive = false; this.dashboardMetrics.finishTask(); this.scheduleRender(); }
|
|
396
295
|
resetDashboardSession(usage) { this.dashboardMetrics.resetSession(usage); this.dashboardModel = 0; this.dashboardGraphOffset = 0; this.nodeModels.clear(); this.dashboardNotices = []; this.scheduleRender(); }
|
|
397
|
-
/** Clock backing the per-node speed meters; see {@link TerminalOptions.tokenClock}. */
|
|
398
296
|
tokenClock;
|
|
399
|
-
/**
|
|
400
|
-
* One cumulative speed meter per generating identity, each stamped with the provider, model
|
|
401
|
-
* and reasoning effort its requests were measured under.
|
|
402
|
-
*
|
|
403
|
-
* Parallel nodes interleave model calls (`src/graph-runner.ts` runs branch workers side by
|
|
404
|
-
* side), so a single shared meter would have one node's first request discard the other's
|
|
405
|
-
* in-flight window and both nodes' totals alternate between wipes. Keys extend the nodeId
|
|
406
|
-
* with the parallel `copy` number the modifier stamps on every forwarded event, because two
|
|
407
|
-
* copies of one node can resolve different models and retry independently. Keeping the
|
|
408
|
-
* accumulation per identity means a switch simply displays the new identity's own average,
|
|
409
|
-
* and returning to an earlier one resumes the average it built.
|
|
410
|
-
*/
|
|
411
297
|
speedMeters = new Map();
|
|
412
|
-
/** The executor's `invocationId` → the meter key whose marker opened that request's window. */
|
|
413
298
|
speedInvocations = new Map();
|
|
414
|
-
/** The node whose requests the readout currently follows: the most recent to open a call. */
|
|
415
299
|
activeSpeedNode;
|
|
416
|
-
/** The parallel copy of {@link activeSpeedNode} the readout follows, when one is named. */
|
|
417
300
|
activeSpeedCopy;
|
|
418
|
-
/** The exact meter key the readout displays - a node, a node's copy, or a distillation. */
|
|
419
301
|
activeSpeedKey;
|
|
420
302
|
handleRuntimeEvent(event) {
|
|
421
303
|
if (this.closed)
|
|
422
304
|
return;
|
|
423
305
|
this.dashboardMetrics.handle(event);
|
|
306
|
+
if (this.subagents.handle(event, nodeId => oneLine(String(this.status.graph?.nodes[nodeId]?.name ?? this.activeNodes.get(nodeId)?.name ?? nodeId))))
|
|
307
|
+
this.scheduleRender();
|
|
424
308
|
if (event.type === 'agent.session.started' && !event.data.subagentId) {
|
|
425
309
|
const session = event.data;
|
|
426
310
|
const nodeId = session.nodeId, provider = session.provider, model = session.model;
|
|
@@ -431,12 +315,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
431
315
|
const effort = typeof session.reasoningEffort === 'string' ? oneLine(session.reasoningEffort) : undefined;
|
|
432
316
|
if (providerLabel !== undefined && modelLabel !== undefined)
|
|
433
317
|
this.nodeModels.set(nodeId, oneLine(`${providerLabel}/${modelLabel}`));
|
|
434
|
-
// The executor re-announces a node's resolution when a whole-agent retry falls back to
|
|
435
|
-
// the node's other profile: same nodeId, different provider, model or effort. The
|
|
436
|
-
// accumulated average measured the previous resolution, so it is rebuilt from zero
|
|
437
|
-
// under the new one - while a repeat of the same resolution, which every ordinary run
|
|
438
|
-
// emits, keeps it. Parallel copies carry their own `copy` number, so one copy's
|
|
439
|
-
// fallback never resets a sibling copy still running on the primary model.
|
|
440
318
|
this.stampSpeedMeter(this.speedKey(nodeId, typeof session.copy === 'number' ? session.copy : undefined), providerLabel, modelLabel, effort);
|
|
441
319
|
}
|
|
442
320
|
if (event.type.startsWith('dashboard.'))
|
|
@@ -446,31 +324,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
446
324
|
if (event.type.startsWith('node.tool.'))
|
|
447
325
|
this.scheduleRender();
|
|
448
326
|
const data = event.data;
|
|
449
|
-
// The executor emits `agent.turn.started` and `agent.iteration.started` back-to-back
|
|
450
|
-
// around one model call (`src/hardened-runtime.ts`), so they are aliases of a single
|
|
451
|
-
// boundary: opening a window for both would queue two per request, and since a completion
|
|
452
|
-
// closes only one, the leftover start would be consumed by a *later* completion and every
|
|
453
|
-
// reading would age against an ever-longer window. `iteration.started` is the marker every
|
|
454
|
-
// other consumer already uses, so it alone opens the window the main call's tokens spread
|
|
455
|
-
// across. Context compaction runs its own model calls between iterations and emits no
|
|
456
|
-
// iteration marker (the next one belongs to the main request): its batch-level start
|
|
457
|
-
// event opens the first window, and because a rejected summary attempt has already spent
|
|
458
|
-
// that window on its usage, every attempt re-emits
|
|
459
|
-
// `agent.context.compaction.attempt.started` so the retry gets a fresh one. All of these
|
|
460
|
-
// events carry the executor's `invocationId`, and the same id names the request on its
|
|
461
|
-
// usage delta, so each window is keyed by it: concurrent requests (branch workers,
|
|
462
|
-
// parallel copies, subagents) completing out of order each spread over their own window
|
|
463
|
-
// instead of the oldest one still open.
|
|
464
|
-
// Goal verification calls the adapter outside every iteration marker with this run's
|
|
465
|
-
// invocationId - the id whose iteration window the main response already closed - so its
|
|
466
|
-
// own boundary re-opens the key and its completion spreads over the verification request
|
|
467
|
-
// instead of the one-second synthetic fallback, whose false spike would then be held.
|
|
468
327
|
if (event.type === 'agent.iteration.started' || event.type === 'agent.context.compaction.started' || event.type === 'agent.context.compaction.attempt.started' || event.type === 'agent.completion.verification.started') {
|
|
469
|
-
// The speed readout averages one generating identity at a time. Every marker above
|
|
470
|
-
// carries the `nodeId` the emit wrapper stamped on it - and, inside a parallel copy,
|
|
471
|
-
// the `copy` number the modifier added - so the readout follows the copy generating
|
|
472
|
-
// now, and because the accumulation lives per identity a switch neither wipes the
|
|
473
|
-
// previous one's totals nor its still-open request window.
|
|
474
328
|
const nodeId = typeof data.nodeId === 'string' ? data.nodeId : 'engineer';
|
|
475
329
|
const invocationId = typeof data.invocationId === 'string' ? data.invocationId : undefined;
|
|
476
330
|
const copy = typeof data.copy === 'number' ? data.copy : undefined;
|
|
@@ -489,19 +343,9 @@ export class TerminalUI extends EventEmitter {
|
|
|
489
343
|
}
|
|
490
344
|
}
|
|
491
345
|
entry.meter.beginRequest(invocationId);
|
|
492
|
-
// The focus moved: the node row and the speed readout now describe another copy or node, so
|
|
493
|
-
// the frame is repainted even though no token reading has arrived yet.
|
|
494
346
|
this.scheduleRender();
|
|
495
347
|
return;
|
|
496
348
|
}
|
|
497
|
-
// Memory distillation calls the adapter directly, outside every executor marker, so the
|
|
498
|
-
// dashboard adapter's start event is the only boundary it emits. Its metadata names the
|
|
499
|
-
// operation and carries the invocation id the distiller stamps on its usage deltas, plus
|
|
500
|
-
// the provider and model that actually perform it - finalization runs on the graph's own
|
|
501
|
-
// resolution, not inside any node's iteration, so without a nodeId of its own it is keyed
|
|
502
|
-
// by that resolution instead of whichever node generated last. Main model calls also pass
|
|
503
|
-
// through the dashboard adapter but are already covered by their iteration marker, so
|
|
504
|
-
// only the distillation operation opens a window here.
|
|
505
349
|
if (event.type === 'dashboard.model.started' && data.operation === 'memory.distillation') {
|
|
506
350
|
const invocationId = typeof data.invocationId === 'string' ? data.invocationId : undefined;
|
|
507
351
|
const provider = typeof data.provider === 'string' ? oneLine(data.provider) : undefined;
|
|
@@ -517,8 +361,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
517
361
|
if (model !== undefined)
|
|
518
362
|
entry.model = model;
|
|
519
363
|
entry.meter.beginRequest(invocationId);
|
|
520
|
-
// Distillation is work the user can watch decode: the readout follows the meter that
|
|
521
|
-
// performed it, whether or not an iteration marker already named one.
|
|
522
364
|
this.activeSpeedKey = key;
|
|
523
365
|
if (typeof data.nodeId === 'string') {
|
|
524
366
|
this.activeSpeedNode = data.nodeId;
|
|
@@ -526,19 +368,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
526
368
|
}
|
|
527
369
|
return;
|
|
528
370
|
}
|
|
529
|
-
// Run boundaries no longer reset the speed readout: each node's cumulative average stays
|
|
530
|
-
// up across runs, and the readout simply follows whichever node generates next.
|
|
531
371
|
if (['graph.started', 'graph.completed', 'graph.stopped'].includes(event.type)) {
|
|
532
372
|
this.activeNodes.clear();
|
|
533
|
-
// The trail belongs to the run that walked it, and so does the position it stopped at:
|
|
534
|
-
// a new run starts over from its own entry.
|
|
535
373
|
if (event.type === 'graph.started') {
|
|
536
374
|
this.visitedNodes.clear();
|
|
537
375
|
this.stoppedNode = undefined;
|
|
538
376
|
}
|
|
539
|
-
// A run that was cancelled, exhausted or failed names the node it stopped on. That node
|
|
540
|
-
// never completes, so without keeping it the zoom would show the last completed
|
|
541
|
-
// predecessor as the position and the node the run actually died on as untouched.
|
|
542
377
|
if (event.type === 'graph.stopped')
|
|
543
378
|
this.stoppedNode = typeof data.nodeId === 'string' ? data.nodeId : undefined;
|
|
544
379
|
this.scheduleRender();
|
|
@@ -548,19 +383,11 @@ export class TerminalUI extends EventEmitter {
|
|
|
548
383
|
return;
|
|
549
384
|
if (event.type === 'graph.node.completed') {
|
|
550
385
|
this.activeNodes.delete(data.nodeId);
|
|
551
|
-
// A node reached twice (a bounded cycle) is moved to the end of the trail rather than left
|
|
552
|
-
// where it was first inserted: the set's order is the visit order the panel's focus reads,
|
|
553
|
-
// so a repeated visit has to be the last one recorded even though the id stays unique.
|
|
554
386
|
this.visitedNodes.delete(data.nodeId);
|
|
555
387
|
this.visitedNodes.add(data.nodeId);
|
|
556
388
|
this.scheduleRender();
|
|
557
389
|
return;
|
|
558
390
|
}
|
|
559
|
-
// The executor reports the provider and model a node is actually running on, including the
|
|
560
|
-
// profile a retry falls back to, so the footer follows a mid-node switch. A delegated child
|
|
561
|
-
// repeats its parent's nodeId, and an ordinary prompt run reports the synthetic 'engineer'
|
|
562
|
-
// id with no graph node behind it, so only a node the graph already reported as started is
|
|
563
|
-
// updated: nothing else may put a node name on the footer.
|
|
564
391
|
if (event.type === 'agent.session.started') {
|
|
565
392
|
const progress = this.activeNodes.get(data.nodeId);
|
|
566
393
|
if (!progress || typeof data.subagentId === 'string')
|
|
@@ -569,22 +396,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
569
396
|
const model = typeof data.model === 'string' ? oneLine(data.model) : undefined;
|
|
570
397
|
if (!provider && !model)
|
|
571
398
|
return;
|
|
572
|
-
// The CLI adds the effort and window of that same resolution (`withNodeModelResolution` in
|
|
573
|
-
// cli.ts). `contextWindow` being present at all - even as undefined - marks the node's own
|
|
574
|
-
// resolution as authoritative, so its unknown window cannot inherit the session's.
|
|
575
399
|
const resolved = Object.hasOwn(data, 'contextWindow')
|
|
576
400
|
? { reasoningEffort: typeof data.reasoningEffort === 'string' ? oneLine(data.reasoningEffort) : undefined,
|
|
577
401
|
contextWindow: typeof data.contextWindow === 'number' && Number.isFinite(data.contextWindow) && data.contextWindow > 0 ? data.contextWindow : undefined }
|
|
578
402
|
: progress.resolved;
|
|
579
|
-
// Parallel copies of one node can resolve different profiles - one falls back while another
|
|
580
|
-
// stays on the primary model - so the resolution is kept per copy as well as for the node:
|
|
581
|
-
// the last announcement must not become the whole node's model.
|
|
582
403
|
const copiesResolved = new Map(progress.copiesResolved ?? []);
|
|
583
404
|
const copyIndex = typeof data.copy === 'number' ? data.copy : 0;
|
|
584
|
-
// The copy keeps the *complete* resolution it announced - effort and window alongside the
|
|
585
|
-
// provider and model - because the footer names one model, and a copy's thinking settings
|
|
586
|
-
// belong to that same resolution: inheriting the node's would describe this copy with a
|
|
587
|
-
// sibling's effort, which the rate comparison then reads as a mismatch and suppresses.
|
|
588
405
|
const ownResolution = Object.hasOwn(data, 'contextWindow')
|
|
589
406
|
? resolved
|
|
590
407
|
: typeof data.reasoningEffort === 'string' ? { reasoningEffort: oneLine(data.reasoningEffort), contextWindow: undefined } : undefined;
|
|
@@ -616,49 +433,16 @@ export class TerminalUI extends EventEmitter {
|
|
|
616
433
|
const nodes = [...this.activeNodes.values()];
|
|
617
434
|
return nodes.slice(0, 2).map(node => [node.name, node.loop, node.copies.size ? `copy ${[...node.copies].sort((a, b) => a - b).join(',')}/${node.totalCopies}` : ''].filter(Boolean).join(' - ')).join(' + ') + (nodes.length > 2 ? ` +${nodes.length - 2} more` : '');
|
|
618
435
|
}
|
|
619
|
-
/**
|
|
620
|
-
* The columns the chat column actually draws in, panel and gutter excluded.
|
|
621
|
-
*
|
|
622
|
-
* Everything that measures chat content outside the render pass - input navigation, the
|
|
623
|
-
* echoed-prompt frame, the docked selection card, the command popup's own visibility gate -
|
|
624
|
-
* has to measure against this rather than the terminal width, or a draft that the composer
|
|
625
|
-
* wrapped onto two rows is treated as one by the arrow keys, and a stored card is built
|
|
626
|
-
* wider than the transcript that must re-wrap it.
|
|
627
|
-
*/
|
|
628
436
|
chatColumns() {
|
|
629
437
|
const columns = Math.max(1, this.output.columns || 80), height = Math.max(1, this.output.rows || 24);
|
|
630
438
|
const panel = this.panelColumns(columns, height);
|
|
631
439
|
return Math.max(1, columns - panel - (panel ? 1 : 0));
|
|
632
440
|
}
|
|
633
|
-
/**
|
|
634
|
-
* Columns the transcript itself would have with the panel drawn.
|
|
635
|
-
*
|
|
636
|
-
* A prompt echo is stored in the transcript and re-wrapped there, so its frame has to be built for
|
|
637
|
-
* that column rather than for whatever surface is on screen when the text is submitted: a task sent
|
|
638
|
-
* from the Ctrl+B dashboard (or from a modal) would otherwise freeze a full-width box whose rows the
|
|
639
|
-
* transcript splits as soon as the panel returns. This is `chatColumns()` with the two full-screen
|
|
640
|
-
* surfaces ignored.
|
|
641
|
-
*/
|
|
642
441
|
transcriptColumns() {
|
|
643
442
|
const columns = Math.max(1, this.output.columns || 80), height = Math.max(1, this.output.rows || 24);
|
|
644
443
|
const panel = columns < PANEL_MIN_COLUMNS || height < PANEL_MIN_ROWS ? 0 : panelWidth(columns);
|
|
645
444
|
return Math.max(1, columns - panel - (panel ? 1 : 0));
|
|
646
445
|
}
|
|
647
|
-
/**
|
|
648
|
-
* Columns the side panel occupies this frame, or 0 when it is not drawn.
|
|
649
|
-
*
|
|
650
|
-
* The panel is a second column of the same frame, so its width has to be known before the
|
|
651
|
-
* chat column renders: below {@link PANEL_MIN_COLUMNS} the chat column would be squeezed
|
|
652
|
-
* past the point where its own wrapping and the command popup still read well, and the two
|
|
653
|
-
* full-screen surfaces - the dashboard (which already reports the same state) and a modal
|
|
654
|
-
* screen (which is a focused flow) - keep the frame to themselves.
|
|
655
|
-
*/
|
|
656
|
-
/**
|
|
657
|
-
* Whether the side panel is on screen for the current terminal and surface.
|
|
658
|
-
*
|
|
659
|
-
* Exposed because the panel is the only consumer of the CLI's Git summary: a caller that would
|
|
660
|
-
* spawn processes to fill it can ask first, and skip the work while nothing can display it.
|
|
661
|
-
*/
|
|
662
446
|
panelVisible() {
|
|
663
447
|
return this.panelColumns(Math.max(1, this.output.columns || 80), Math.max(1, this.output.rows || 24)) > 0;
|
|
664
448
|
}
|
|
@@ -667,29 +451,15 @@ export class TerminalUI extends EventEmitter {
|
|
|
667
451
|
return 0;
|
|
668
452
|
return panelWidth(width);
|
|
669
453
|
}
|
|
670
|
-
/**
|
|
671
|
-
* The side panel's rows for this frame.
|
|
672
|
-
*
|
|
673
|
-
* Assembled per render rather than cached: the rows carry a clock (how long a background
|
|
674
|
-
* terminal has been running) and follow the node set the run is publishing, and the packing
|
|
675
|
-
* only ever walks a handful of sections.
|
|
676
|
-
* @param columns - total columns the panel occupies, divider and gutter included.
|
|
677
|
-
* @param height - rows the panel may use, the whole frame height.
|
|
678
|
-
*/
|
|
679
454
|
panelRows(columns, height) {
|
|
680
455
|
if (!columns)
|
|
681
456
|
return [];
|
|
682
457
|
const entries = [...this.activeNodes.entries()];
|
|
683
|
-
// The node the reader is watching - the one the speed readout follows - leads the section,
|
|
684
|
-
// and the rest follow so a parallel run still names every node that is working.
|
|
685
458
|
const focus = this.activeSpeedNode !== undefined && this.activeNodes.has(this.activeSpeedNode) ? this.activeSpeedNode : entries[0]?.[0];
|
|
686
459
|
const nodes = entries
|
|
687
460
|
.sort(([left], [right]) => (left === focus ? -1 : right === focus ? 1 : 0))
|
|
688
461
|
.map(([id, node]) => {
|
|
689
462
|
const detail = [node.loop, node.copies.size ? `copy ${[...node.copies].sort((a, b) => a - b).join(',')}/${node.totalCopies}` : ''].filter(Boolean).join(' · ');
|
|
690
|
-
// The row describes the copy the reader is watching: when the speed readout follows a
|
|
691
|
-
// parallel copy, that copy's own resolution is the one to name - another copy's fallback
|
|
692
|
-
// must not be reported as this one's model.
|
|
693
463
|
const perCopy = id === focus && this.activeSpeedCopy !== undefined ? node.copiesResolved?.get(this.activeSpeedCopy) : undefined;
|
|
694
464
|
const provider = perCopy?.provider ?? node.provider;
|
|
695
465
|
const model = perCopy?.model ?? node.model;
|
|
@@ -706,16 +476,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
706
476
|
...(this.stoppedNode ? { stoppedNode: this.stoppedNode } : {}),
|
|
707
477
|
todos: this.todos,
|
|
708
478
|
terminals: this.status.terminals ?? [],
|
|
479
|
+
agents: this.subagents.groups(),
|
|
709
480
|
now: this.tokenClock ? this.tokenClock() : Date.now(),
|
|
710
481
|
}, Math.max(8, columns - 2), height);
|
|
711
482
|
}
|
|
712
|
-
/**
|
|
713
|
-
* Compose the chat column's rows with the panel's into the frame's rows.
|
|
714
|
-
*
|
|
715
|
-
* Each row is padded to the chat width so the divider column stays unbroken, then carries
|
|
716
|
-
* the panel cell for that row. A painted row is measured with `stringWidth`, which ignores
|
|
717
|
-
* escape sequences, so padding cannot be confused by the color the chat row already holds.
|
|
718
|
-
*/
|
|
719
483
|
composePanel(lines, rows, columns, chatWidth) {
|
|
720
484
|
if (!columns)
|
|
721
485
|
return lines;
|
|
@@ -729,30 +493,14 @@ export class TerminalUI extends EventEmitter {
|
|
|
729
493
|
return padded + (text ? ` ${divider} ${text}` : ` ${divider}`);
|
|
730
494
|
});
|
|
731
495
|
}
|
|
732
|
-
/**
|
|
733
|
-
* The model currently answering, as its footer label plus the thinking effort and context window
|
|
734
|
-
* that belong to it.
|
|
735
|
-
*
|
|
736
|
-
* While a graph node is active this names the node the user is watching - the one whose
|
|
737
|
-
* requests the speed readout follows, or the first-started one when no speed identity is
|
|
738
|
-
* named - followed by the provider and model that node actually resolved and by the effort
|
|
739
|
-
* and window of that same resolution, so the whole line describes one model. With no active
|
|
740
|
-
* node it is the session's own selection, and no node is named for an idle prompt or for a
|
|
741
|
-
* plain run that never started a graph node.
|
|
742
|
-
*/
|
|
743
496
|
activeModel() {
|
|
744
497
|
const node = this.displayNode();
|
|
745
498
|
if (!node)
|
|
746
499
|
return { label: oneLine(`${this.status.provider} / ${this.status.model}`), reasoningEffort: this.status.reasoningEffort, contextWindow: this.status.contextWindow };
|
|
747
500
|
const more = this.activeNodes.size > 1 ? ` +${this.activeNodes.size - 1} more` : '';
|
|
748
|
-
// The row names the copy the readout follows, so it names that copy's resolution too: two
|
|
749
|
-
// copies of one node can run different profiles, and the last announcement is not the model
|
|
750
|
-
// generating now.
|
|
751
501
|
const perCopy = this.activeSpeedCopy !== undefined ? node.copiesResolved?.get(this.activeSpeedCopy) : undefined;
|
|
752
502
|
const provider = perCopy?.provider ?? node.provider ?? this.status.provider;
|
|
753
503
|
const model = perCopy?.model ?? node.model ?? this.status.model;
|
|
754
|
-
// The whole line describes one resolution: when the followed copy announced its own, that one
|
|
755
|
-
// answers for the effort and the window too, not the node's last announcement from a sibling.
|
|
756
504
|
const resolved = perCopy?.resolved ?? node.resolved;
|
|
757
505
|
return {
|
|
758
506
|
label: oneLine(`${node.name}${more} · ${provider} / ${model}`),
|
|
@@ -761,6 +509,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
761
509
|
};
|
|
762
510
|
}
|
|
763
511
|
started = false;
|
|
512
|
+
releaseWarnings;
|
|
764
513
|
closed = false;
|
|
765
514
|
wasRaw = false;
|
|
766
515
|
wasPaused = false;
|
|
@@ -775,47 +524,22 @@ export class TerminalUI extends EventEmitter {
|
|
|
775
524
|
todoOffset = 0;
|
|
776
525
|
todoPageSize = 0;
|
|
777
526
|
scroll = 0;
|
|
778
|
-
/** Whether a run is streaming. */
|
|
779
527
|
runActive = false;
|
|
780
|
-
/**
|
|
781
|
-
* The drag selection over the drawn frame, in screen cells.
|
|
782
|
-
*
|
|
783
|
-
* The app holds mouse reporting for the whole session so the wheel arrives as a wheel report
|
|
784
|
-
* and never as the Up/Down bytes that recall input history. Holding the mouse takes the drag
|
|
785
|
-
* away from the terminal, so the app draws the selection itself and copies it on release.
|
|
786
|
-
*/
|
|
787
528
|
selection;
|
|
788
|
-
/** The last left press, kept to recognize a double-click on the same cell. */
|
|
789
529
|
lastPress;
|
|
790
|
-
/** The frame as composed, before the selection highlight is laid over it. */
|
|
791
530
|
frame = [];
|
|
792
|
-
/**
|
|
793
|
-
* Live reasoning preview state. `thinkingActive` marks a stream in progress; the text
|
|
794
|
-
* is the bounded tail the preview renders from.
|
|
795
|
-
*/
|
|
796
531
|
thinking = '';
|
|
797
532
|
thinkingActive = false;
|
|
798
|
-
/** The preview opens expanded on every stream; Ctrl+Y collapses the current one. */
|
|
799
533
|
thinkingExpanded = true;
|
|
800
534
|
expandedPromptIds = new Set();
|
|
801
|
-
/** Prompts the reader explicitly collapsed; an explicit toggle wins over Ctrl+O (see promptExpanded). */
|
|
802
535
|
collapsedPromptIds = new Set();
|
|
803
|
-
/** Every prompt box the transcript currently holds, so Ctrl+O can invert each one on screen. */
|
|
804
536
|
promptBoxIds = new Set();
|
|
805
537
|
expandedPromptVisible = false;
|
|
806
538
|
nextPromptId = 1;
|
|
807
539
|
thinkingPaintedAt = 0;
|
|
808
540
|
thinkingFlush;
|
|
809
|
-
/**
|
|
810
|
-
* The rows currently on screen, so a repaint can rewrite only what changed.
|
|
811
|
-
*
|
|
812
|
-
* See {@link writeFrame}: a terminal drops an in-progress drag selection when the app
|
|
813
|
-
* rewrites the cells under it, and a run repaints eight times a second for its animation.
|
|
814
|
-
*/
|
|
815
541
|
drawn = [];
|
|
816
|
-
/** Terminal size `drawn` was produced at; a resize invalidates the comparison. */
|
|
817
542
|
drawnSize = '';
|
|
818
|
-
/** The caret sequence last emitted, so an unmoved caret costs no extra write. */
|
|
819
543
|
drawnCursor = '';
|
|
820
544
|
history = [];
|
|
821
545
|
historyIndex = 0;
|
|
@@ -823,15 +547,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
823
547
|
completion;
|
|
824
548
|
dismissedCompletion;
|
|
825
549
|
incoming = '';
|
|
826
|
-
/**
|
|
827
|
-
* Raw bytes not yet decoded to `incoming`.
|
|
828
|
-
*
|
|
829
|
-
* Legacy mouse reports are framed here, on bytes, before UTF-8 decoding: their payload
|
|
830
|
-
* is three value-plus-32 bytes that the decoder would buffer while an incomplete
|
|
831
|
-
* sequence (column 192, row 128 ends in E0 A0) and collapse when the pair forms a
|
|
832
|
-
* valid one (column 162, row 128 encodes as C2 A0), so no string-domain measurement
|
|
833
|
-
* can see a report in time without risking the keystroke that follows it.
|
|
834
|
-
*/
|
|
835
550
|
rawIncoming = Buffer.alloc(0);
|
|
836
551
|
rawTimer;
|
|
837
552
|
pasting = false;
|
|
@@ -844,36 +559,18 @@ export class TerminalUI extends EventEmitter {
|
|
|
844
559
|
plainQuestion;
|
|
845
560
|
modal;
|
|
846
561
|
modalInput = false;
|
|
847
|
-
/**
|
|
848
|
-
* The last selection screen that was answered.
|
|
849
|
-
*
|
|
850
|
-
* Setup closes a selection screen and then asks for a value, which used to leave the home
|
|
851
|
-
* card where the list had been: the reader lost both the list and the entry it led to the
|
|
852
|
-
* moment they started typing. The card is kept here so a typed field can be answered with
|
|
853
|
-
* the list still on screen (see selectionCard).
|
|
854
|
-
*/
|
|
855
562
|
lastSelection;
|
|
856
563
|
escapeTimer;
|
|
857
564
|
workingTimer;
|
|
858
|
-
/** The panel's one-second age clock; see render(). */
|
|
859
565
|
panelTimer;
|
|
860
566
|
workingSince;
|
|
861
567
|
workingElapsed = 0;
|
|
862
|
-
/**
|
|
863
|
-
* Whether the composer accepts input while a run is active.
|
|
864
|
-
*
|
|
865
|
-
* Enabled for the duration of an interactive run so the user can steer it. Text
|
|
866
|
-
* submitted in this mode is queued rather than resolved as a question answer.
|
|
867
|
-
*/
|
|
868
568
|
steering = false;
|
|
869
569
|
runInputHandler;
|
|
870
570
|
localCommandHandler;
|
|
871
571
|
commandInput = false;
|
|
872
|
-
/** Handle active commands and resumed direction synchronously; true consumes the input. */
|
|
873
572
|
setRunInputHandler(handler) { this.runInputHandler = handler; }
|
|
874
|
-
/** Observe slash commands consumed by the view without submitting them to the run. */
|
|
875
573
|
setLocalCommandHandler(handler) { this.localCommandHandler = handler; }
|
|
876
|
-
/** Settle the current approval after an explicit session permission change. */
|
|
877
574
|
resolveQuestion(value) {
|
|
878
575
|
const pending = this.pending;
|
|
879
576
|
if (!pending)
|
|
@@ -882,14 +579,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
882
579
|
pending.resolve(value);
|
|
883
580
|
this.scheduleRender();
|
|
884
581
|
}
|
|
885
|
-
/** Submit from the browser only while the terminal is accepting a conversation prompt. */
|
|
886
582
|
acceptConversationPrompt(value) {
|
|
887
583
|
if (!this.pending?.conversationPrompt || this.modal)
|
|
888
584
|
return false;
|
|
889
585
|
this.resolveQuestion(value);
|
|
890
586
|
return true;
|
|
891
587
|
}
|
|
892
|
-
/** Current runtime question for connected GUI surfaces. Conversation prompts stay in the composer. */
|
|
893
588
|
browserPendingIdentity;
|
|
894
589
|
browserQuestionNumber = 0;
|
|
895
590
|
browserQuestion() {
|
|
@@ -904,40 +599,15 @@ export class TerminalUI extends EventEmitter {
|
|
|
904
599
|
return { id: `terminal-${this.browserQuestionNumber}`, kind: pending.kind, question, approvalDetailsRequired: pending.kind === 'approval', approvalDetails: pending.approvalDetails, choices: pending.choices?.map(item => ({ id: item.id, label: item.label })) };
|
|
905
600
|
}
|
|
906
601
|
steered = [];
|
|
907
|
-
/**
|
|
908
|
-
* Attachments queued in the composer draft — large pastes spooled to text, dropped file
|
|
909
|
-
* paths, clipboard images. Each sits in the draft as an inline token (its `marker` code
|
|
910
|
-
* point), drawn as a bold label and edited as one character. They ride the next submitted
|
|
911
|
-
* task (or the next queued steer) and are drained by the CLI, mirroring how `steered` is
|
|
912
|
-
* drained at turn boundaries.
|
|
913
|
-
*/
|
|
914
602
|
attachments = [];
|
|
915
|
-
/** The skills the `/` popup offers after the built-in commands, with the description it shows. */
|
|
916
603
|
skillCommands = [];
|
|
917
|
-
/** The command the skill chip in the draft stands for, while one is there. */
|
|
918
604
|
skillChip;
|
|
919
605
|
attachmentSeq = 0;
|
|
920
|
-
/**
|
|
921
|
-
* Generation of the composer's attachment surface. Advanced by every draft clear and steer
|
|
922
|
-
* submission: an asynchronous clipboard probe that started before one of those lands nowhere,
|
|
923
|
-
* because the composer it was reading for is gone (steering keeps the same owner all run).
|
|
924
|
-
*/
|
|
925
606
|
clipboardProbe = 0;
|
|
926
607
|
clipboardImageProbe;
|
|
927
608
|
clipboardTextWriter;
|
|
928
|
-
/**
|
|
929
|
-
* Where the composer's Shift+Arrow selection started; it runs from here to the cursor.
|
|
930
|
-
* `selectionValue` is the draft it was made in: replacing the draft (a submission, history
|
|
931
|
-
* recall, a completion) swaps the array, which drops the selection without bookkeeping.
|
|
932
|
-
*/
|
|
933
609
|
selectionAnchor;
|
|
934
610
|
selectionValue;
|
|
935
|
-
/**
|
|
936
|
-
* A half-typed steer parked while a question temporarily takes the composer.
|
|
937
|
-
*
|
|
938
|
-
* Questions and steering share `value`; without this a partially typed steer would be
|
|
939
|
-
* wiped the moment the runtime asks for an approval or clarification.
|
|
940
|
-
*/
|
|
941
611
|
steerDraft;
|
|
942
612
|
steerCursor = 0;
|
|
943
613
|
constructor(options) {
|
|
@@ -964,38 +634,27 @@ export class TerminalUI extends EventEmitter {
|
|
|
964
634
|
this.input.setRawMode?.(true);
|
|
965
635
|
this.input.ref?.();
|
|
966
636
|
this.started = true;
|
|
637
|
+
if (this.output.isTTY)
|
|
638
|
+
this.releaseWarnings = holdWarnings();
|
|
967
639
|
this.input.on('data', this.onData);
|
|
968
640
|
this.input.on('end', this.onEnd);
|
|
969
641
|
this.output.on('resize', this.onResize);
|
|
970
642
|
this.input.resume();
|
|
971
|
-
// The app holds mouse reporting (?1002h/?1006h) from here to close(), so the wheel always
|
|
972
|
-
// arrives as a wheel report and scrolls the transcript: at the resting prompt, while a run
|
|
973
|
-
// streams and on every screen. Leaving the wheel to the terminal is not an option in the
|
|
974
|
-
// alternate screen. Windows Terminal, VTE and iTerm2 turn an uncaptured wheel into Up/Down
|
|
975
|
-
// sequences byte-identical to the arrow keys (alternate scroll mode, ?1007), which either
|
|
976
|
-
// recalls input history on every wheel tick or forces the arrows to give history up. With
|
|
977
|
-
// the mouse held, Up/Down stay purely keyboard, and ?1007 is switched off so a terminal
|
|
978
|
-
// that ignores the capture still sends nothing for the wheel. Button-event tracking (?1002)
|
|
979
|
-
// also reports the drag, which the app draws and copies itself (see `mouse`); the
|
|
980
|
-
// terminal's own selection stays reachable through its bypass, Shift+drag in most. Legacy
|
|
981
|
-
// ESC[M reports from terminals without the SGR encoding are framed in `consumeRaw`.
|
|
982
|
-
// writeFrame only rewrites rows that changed. Entering the alternate screen blanks it, so
|
|
983
|
-
// nothing drawn before is still there to diff.
|
|
984
643
|
this.drawn = [];
|
|
985
644
|
this.drawnSize = '';
|
|
986
645
|
this.drawnCursor = '';
|
|
987
|
-
//
|
|
988
|
-
//
|
|
989
|
-
//
|
|
990
|
-
//
|
|
991
|
-
//
|
|
992
|
-
|
|
993
|
-
this.output.write('\x1b[?1049l\x1b[?1049h\x1b[?2004h\x1b[?25l\x1b[?1007l\x1b[?1002h\x1b[?1006h');
|
|
646
|
+
// A stale alternate screen (a session that died without closing) is left before ours is
|
|
647
|
+
// entered, so Windows Terminal applies the resize it deferred. Leaving restores the saved
|
|
648
|
+
// cursor even on the main screen, where nothing was saved yet and the cursor goes home,
|
|
649
|
+
// and entering then saves that home position for the exit to restore: the shell prompt came
|
|
650
|
+
// back on row 1 over the old screen. Saving the cursor first (ESC 7) makes the leave a no-op.
|
|
651
|
+
this.output.write('\x1b7\x1b[?1049l\x1b[?1049h\x1b[?2004h\x1b[?25l\x1b[?1007l\x1b[?1002h\x1b[?1006h');
|
|
994
652
|
this.render();
|
|
995
653
|
}
|
|
996
654
|
question(prompt = '', options = {}) {
|
|
997
655
|
if (this.closed)
|
|
998
656
|
return Promise.reject(new Error('Terminal is closed'));
|
|
657
|
+
this.yieldScreen();
|
|
999
658
|
if (this.pending)
|
|
1000
659
|
return Promise.reject(new Error('A terminal question is already active'));
|
|
1001
660
|
if (this.modal)
|
|
@@ -1004,8 +663,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1004
663
|
return Promise.reject(new DOMException('Question aborted', 'AbortError'));
|
|
1005
664
|
if (!this.started)
|
|
1006
665
|
this.start();
|
|
1007
|
-
// A question (approval or clarification) can interrupt a run while a steer is half typed.
|
|
1008
|
-
// Park it, so taking the composer for the question does not silently discard the draft.
|
|
1009
666
|
if (this.steering && this.value.length) {
|
|
1010
667
|
this.steerDraft = this.parkedDraft();
|
|
1011
668
|
this.steerCursor = this.cursor;
|
|
@@ -1032,6 +689,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
1032
689
|
async chooseQuestion(prompt, items, options = {}) {
|
|
1033
690
|
if (!items.length || items.some(item => !item.id))
|
|
1034
691
|
throw new Error('Question choices require nonempty IDs');
|
|
692
|
+
this.yieldScreen();
|
|
1035
693
|
if (this.pending || this.modal)
|
|
1036
694
|
throw new Error('A terminal question or screen is already active');
|
|
1037
695
|
const displayedPrompt = prompt === 'Choose an answer' ? this.dashboardNotices.at(-1) ?? prompt : prompt;
|
|
@@ -1039,8 +697,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1039
697
|
this.print(prompt);
|
|
1040
698
|
const answer = this.question('↑↓ Choose · Enter confirm · Esc cancel', { ...options, history: false });
|
|
1041
699
|
const pending = this.pending;
|
|
1042
|
-
// Keep tool identity alongside its arguments so the browser snapshot sanitizer
|
|
1043
|
-
// can apply tool-specific privacy rules before any details leave the CLI.
|
|
1044
700
|
if (pending && options.kind === 'approval')
|
|
1045
701
|
pending.approvalDetails = options.approvalDetails;
|
|
1046
702
|
if (pending) {
|
|
@@ -1052,13 +708,16 @@ export class TerminalUI extends EventEmitter {
|
|
|
1052
708
|
this.scheduleRender();
|
|
1053
709
|
return (await answer) || undefined;
|
|
1054
710
|
}
|
|
711
|
+
yieldScreen() {
|
|
712
|
+
if (this.modal?.yieldToQuestions)
|
|
713
|
+
this.finishModal(undefined, new DOMException('Screen yielded to a question', 'AbortError'));
|
|
714
|
+
}
|
|
1055
715
|
select(title, items, options = {}) {
|
|
1056
716
|
let selected = Math.max(0, items.findIndex(item => item.id === options.selectedId));
|
|
1057
717
|
while (items[selected]?.separator)
|
|
1058
718
|
selected++;
|
|
1059
719
|
return this.openModal({ kind: 'select', title, items: [...items], lines: [], selected, selectedId: options.selectedId, ...options });
|
|
1060
720
|
}
|
|
1061
|
-
/** Move the select highlight, carrying the movement past separator rows: separators are visual line breaks, never choices. */
|
|
1062
721
|
moveSelection(modal, movement, homeEnd) {
|
|
1063
722
|
const selectable = (index) => index >= 0 && index < modal.items.length && !modal.items[index].separator;
|
|
1064
723
|
let target = homeEnd === 'home' ? 0 : homeEnd === 'end' ? modal.items.length - 1 : Math.max(0, Math.min(modal.items.length - 1, modal.selected + movement));
|
|
@@ -1115,8 +774,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1115
774
|
if (!modal)
|
|
1116
775
|
return;
|
|
1117
776
|
this.modal = undefined;
|
|
1118
|
-
// Only a selection that was actually made is worth docking: a cancelled list leads to no
|
|
1119
|
-
// field, and the caller returns to the conversation instead.
|
|
1120
777
|
if (modal.kind === 'select' && !error && typeof value === 'string')
|
|
1121
778
|
this.lastSelection = { title: modal.title, description: modal.description, items: modal.items.map(item => ({ ...item })), selected: modal.selected };
|
|
1122
779
|
this.updateWorkingClock();
|
|
@@ -1131,7 +788,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
1131
788
|
modal.resolve(value);
|
|
1132
789
|
this.scheduleRender();
|
|
1133
790
|
}
|
|
1134
|
-
print(text, detail, toolCall, conversation = false, notice = true, alignRight = false) {
|
|
791
|
+
print(text, detail, toolCall, conversation = false, notice = true, alignRight = false, clipRows = false) {
|
|
1135
792
|
if (notice) {
|
|
1136
793
|
this.dashboardNotices.push(clean(String(text)).slice(0, 100_000));
|
|
1137
794
|
this.dashboardNotices = this.dashboardNotices.slice(-12);
|
|
@@ -1140,37 +797,19 @@ export class TerminalUI extends EventEmitter {
|
|
|
1140
797
|
if (this.modal?.kind === 'loading')
|
|
1141
798
|
this.modal.lines = [...this.modal.lines, ...lines].slice(-100);
|
|
1142
799
|
const entry = { text: lines.join('\n'), ...(detail ? { detail: clean(detail) } : {}),
|
|
1143
|
-
...(toolCall ? { toolCall, timing: this.toolClock.get(toolCall.key) } : {}), ...(conversation ? { conversation: true } : {}), ...(alignRight ? { alignRight: true } : {}) };
|
|
800
|
+
...(toolCall ? { toolCall, timing: this.toolClock.get(toolCall.key) } : {}), ...(conversation ? { conversation: true } : {}), ...(alignRight ? { alignRight: true } : {}), ...(clipRows && detail ? { clipRows: true } : {}) };
|
|
1144
801
|
if (this.scroll)
|
|
1145
802
|
this.scroll += this.transcriptRows(entry, this.chatColumns()).length;
|
|
1146
803
|
this.transcript.append(entry);
|
|
1147
804
|
this.scheduleRender();
|
|
1148
805
|
}
|
|
1149
|
-
/**
|
|
1150
|
-
* Echo submitted text as its own bordered box.
|
|
1151
|
-
*
|
|
1152
|
-
* The box mirrors the live input field's frame and color so the text reads as the
|
|
1153
|
-
* same surface the user typed into, rather than a `You >` transcript prefix. The
|
|
1154
|
-
* frame itself identifies the text as user input, so a submitted prompt is left
|
|
1155
|
-
* untitled; only a surface that is genuinely something other than a task prompt —
|
|
1156
|
-
* a clarification answer — passes a title. The frame is sized to the terminal at
|
|
1157
|
-
* echo time; a later resize re-wraps the body but keeps the original box, which is
|
|
1158
|
-
* an accepted trade for not rewriting history on resize. The finished box is drawn right-aligned against the transcript's right margin (see wrapTranscript), so a submission reads as the user's speech bubble and re-aligns when the window is resized.
|
|
1159
|
-
* @param text - the submitted text to echo.
|
|
1160
|
-
* @param title - optional top-border label; omitted draws a plain frame.
|
|
1161
|
-
*/
|
|
1162
806
|
printPrompt(text, title = '') {
|
|
1163
|
-
// The width the transcript will show this box at, not the width of the surface submitting it.
|
|
1164
807
|
const width = Math.max(12, this.transcriptColumns()) - 4;
|
|
1165
|
-
// Reserve the four frame characters ('│ ', ' │') plus the two-space transcript indent,
|
|
1166
|
-
// so a body row can never exceed the width the render pass wraps at.
|
|
1167
808
|
const bodyWidth = Math.max(1, width - 4);
|
|
1168
809
|
const titleBudget = Math.max(0, width - 4);
|
|
1169
810
|
const label = oneLine(title).trim();
|
|
1170
811
|
const frameTitle = label ? clip(` ${label} `, titleBudget) : '';
|
|
1171
812
|
const rows = clean(String(text)).slice(0, 100_000).split('\n').flatMap(line => wrap(line, bodyWidth));
|
|
1172
|
-
// Expansion preserves the existing bounded-history contract: the model still receives the
|
|
1173
|
-
// full submitted input, while the transcript stores at most MAX_PROMPT_ROWS rendered rows.
|
|
1174
813
|
const omitted = rows.length - MAX_PROMPT_ROWS;
|
|
1175
814
|
const marker = omitted > 0 ? wrap(`… ${omitted + 1} more rows omitted`, bodyWidth) : [];
|
|
1176
815
|
const fullBody = omitted > 0 ? [...rows.slice(0, MAX_PROMPT_ROWS - marker.length), ...marker] : rows;
|
|
@@ -1183,13 +822,9 @@ export class TerminalUI extends EventEmitter {
|
|
|
1183
822
|
return [top, ...body.map(line => '│ ' + pad(line, inner) + ' │'), bottom].join('\n');
|
|
1184
823
|
};
|
|
1185
824
|
if (rows.length <= PROMPT_COLLAPSE_AFTER_ROWS) {
|
|
1186
|
-
// Positional call, so name the last flag: the echo is the user's speech bubble (alignRight).
|
|
1187
825
|
this.print(frame(fullBody), undefined, undefined, true, true, true);
|
|
1188
826
|
return;
|
|
1189
827
|
}
|
|
1190
|
-
// Reserve the entire wrapped disclosure before choosing preview rows. On a narrow terminal
|
|
1191
|
-
// the marker itself may need more than six rows; in that case the marker wins and the preview
|
|
1192
|
-
// shrinks to zero rather than hiding the actionable "Ctrl+O to expand" text.
|
|
1193
828
|
let previewRows = Math.max(0, PROMPT_COLLAPSED_BODY_ROWS - 1);
|
|
1194
829
|
let disclosure = [];
|
|
1195
830
|
for (let pass = 0; pass < 3; pass++) {
|
|
@@ -1211,15 +846,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1211
846
|
this.transcript.append(entry);
|
|
1212
847
|
this.scheduleRender();
|
|
1213
848
|
}
|
|
1214
|
-
/**
|
|
1215
|
-
* Stream one reasoning delta into the live preview line.
|
|
1216
|
-
*
|
|
1217
|
-
* The preview always shows the tail of what has arrived, so each call only has to grow
|
|
1218
|
-
* the bounded buffer; rendering stays on the working clock's repaint cadence, with a
|
|
1219
|
-
* small throttle so a token firehose cannot trigger a full-frame render per network
|
|
1220
|
-
* chunk.
|
|
1221
|
-
* @param delta - the reasoning fragment that just arrived; empty fragments are ignored.
|
|
1222
|
-
*/
|
|
1223
849
|
appendThinking(delta) {
|
|
1224
850
|
if (this.closed || !delta)
|
|
1225
851
|
return;
|
|
@@ -1235,14 +861,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1235
861
|
this.thinkingFlush.unref?.();
|
|
1236
862
|
}
|
|
1237
863
|
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Wipe the on-screen conversation so the display reads as a freshly started session.
|
|
1240
|
-
*
|
|
1241
|
-
* Only the transcript entries, the scroll position and the live reasoning preview are dropped:
|
|
1242
|
-
* the welcome card is rebuilt as the scrollback prefix on the next render, so the frame returns
|
|
1243
|
-
* to its startup shape without re-emitting a banner or a terminal clear escape. The composer's
|
|
1244
|
-
* prompt-recall history is deliberately kept — it is input history, not chat output.
|
|
1245
|
-
*/
|
|
1246
864
|
clearConversation() {
|
|
1247
865
|
if (this.closed)
|
|
1248
866
|
return;
|
|
@@ -1252,17 +870,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
1252
870
|
this.collapsedPromptIds.clear();
|
|
1253
871
|
this.promptBoxIds.clear();
|
|
1254
872
|
this.expandedPromptVisible = false;
|
|
1255
|
-
// A cleared conversation abandons its pending attachments with it: they were queued for a
|
|
1256
|
-
// task in this conversation, and silently attaching them to the next one would submit files
|
|
1257
|
-
// the user never re-chose.
|
|
1258
873
|
this.attachments = [];
|
|
1259
|
-
// The scroll offset is clamped against the transcript, so a stale offset would draw an empty
|
|
1260
|
-
// or misplaced window over the cleared list instead of the live tail.
|
|
1261
874
|
this.scroll = 0;
|
|
1262
875
|
this.clearThinking();
|
|
876
|
+
this.subagents.clear();
|
|
1263
877
|
this.scheduleRender();
|
|
1264
878
|
}
|
|
1265
|
-
/** Retract the preview: the stream ended, was retried, or the whole run finished. */
|
|
1266
879
|
clearThinking() {
|
|
1267
880
|
if (this.thinkingFlush) {
|
|
1268
881
|
clearTimeout(this.thinkingFlush);
|
|
@@ -1276,11 +889,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1276
889
|
this.scheduleRender();
|
|
1277
890
|
}
|
|
1278
891
|
setStatus(partial) {
|
|
1279
|
-
// The CLI reloads and re-validates the selected graph before every run, handing setStatus
|
|
1280
|
-
// a fresh object for an unchanged selection. Display bookkeeping treats any new graph
|
|
1281
|
-
// object as a change (its node identities repopulate from the run's own events anyway),
|
|
1282
|
-
// while the speed readout identifies the graph by id and revision: a reload of the same
|
|
1283
|
-
// graph keeps its average, a genuinely different or re-edited graph starts over.
|
|
1284
892
|
const graphIdentity = (graph) => graph === undefined ? undefined : `${graph.id}@${graph.revision}`;
|
|
1285
893
|
const modelChanged = (partial.provider !== undefined && partial.provider !== this.status.provider)
|
|
1286
894
|
|| (partial.model !== undefined && partial.model !== this.status.model)
|
|
@@ -1293,26 +901,17 @@ export class TerminalUI extends EventEmitter {
|
|
|
1293
901
|
this.dashboardGraphOffset = 0;
|
|
1294
902
|
}
|
|
1295
903
|
if (modelChanged || graphChanged) {
|
|
1296
|
-
// The nodes now decode under a different model or inference configuration, so every
|
|
1297
|
-
// accumulated average describes something the footer no longer shows.
|
|
1298
904
|
this.speedMeters.clear();
|
|
1299
905
|
this.speedInvocations.clear();
|
|
1300
906
|
this.activeSpeedNode = undefined;
|
|
1301
907
|
this.activeSpeedCopy = undefined;
|
|
1302
908
|
this.activeSpeedKey = undefined;
|
|
1303
909
|
}
|
|
1304
|
-
// A trail of node ids means nothing in another graph: the panel's zoom would focus an id
|
|
1305
|
-
// that does not exist there and count visits against the new graph's total, so a changed
|
|
1306
|
-
// selection starts it over - including the position a stopped run ended on, which is a node
|
|
1307
|
-
// id from that same graph. Reloading the same graph (same id and revision) keeps both.
|
|
1308
910
|
if (graphChanged) {
|
|
1309
911
|
this.visitedNodes.clear();
|
|
1310
912
|
this.stoppedNode = undefined;
|
|
1311
913
|
}
|
|
1312
914
|
this.status = { ...this.status, ...partial, ...(partial.activity !== undefined && partial.backgroundActivity === undefined ? { backgroundActivity: false } : {}) };
|
|
1313
|
-
// A run ending returns the footer to idle but does not retire the speed readout: each
|
|
1314
|
-
// node's cumulative average keeps describing the node that just ran, and it is the
|
|
1315
|
-
// baseline the next run of that node continues from.
|
|
1316
915
|
if (partial.activity === 'Ready') {
|
|
1317
916
|
this.activeNodes.clear();
|
|
1318
917
|
this.toolClock.stop();
|
|
@@ -1322,71 +921,32 @@ export class TerminalUI extends EventEmitter {
|
|
|
1322
921
|
this.updateWorkingClock();
|
|
1323
922
|
this.scheduleRender();
|
|
1324
923
|
}
|
|
1325
|
-
/**
|
|
1326
|
-
* Feed the footer's token-speed readout with one finished model request.
|
|
1327
|
-
*
|
|
1328
|
-
* Providers report a request's tokens only when it completes. A streamed request carries its
|
|
1329
|
-
* measured decode window, which is the time the tokens are credited with; otherwise the
|
|
1330
|
-
* number is measured over the window opened by the call's `agent.iteration.started` event
|
|
1331
|
-
* rather than credited to the instant it arrived, which would leave the readout no duration
|
|
1332
|
-
* to divide by. The completion also replaces the live estimate {@link noteStreamedOutput}
|
|
1333
|
-
* kept for the same request. `invocationId` - the id the executor stamps on both the start
|
|
1334
|
-
* event and the usage delta - selects that window and, through the marker that opened it,
|
|
1335
|
-
* the node whose average the measurement belongs to, so a completion from a concurrent request cannot
|
|
1336
|
-
* borrow another request's window or another node's average. The measurement folds into
|
|
1337
|
-
* that node's cumulative average, which only a changed selection or a changed model
|
|
1338
|
-
* resolution for the node resets. Deltas that carry no tokens (the adapter's per-attempt
|
|
1339
|
-
* request counting, retries included) are not completions and are passed through to the
|
|
1340
|
-
* meter, which ignores them for window pairing. A final delta without tokens - a provider
|
|
1341
|
-
* that omits usage - still closes its request's window but leaves the average untouched:
|
|
1342
|
-
* it describes the requests that did report.
|
|
1343
|
-
* @param tokens - output tokens the provider reported for that single request.
|
|
1344
|
-
* @param invocationId - request identity from the executor, when one is known.
|
|
1345
|
-
* @param final - true when the delta closes its request, per the runtime's origin flag.
|
|
1346
|
-
* @param decodeMs - the adapter's measured decode window for the request, when it has one.
|
|
1347
|
-
*/
|
|
1348
924
|
noteGeneratedTokens(tokens, invocationId, final, decodeMs) {
|
|
1349
925
|
const key = this.speedRoute(invocationId);
|
|
1350
|
-
// Attempt bookkeeping (zero tokens, not final) keeps its routing entry, so the completion
|
|
1351
|
-
// that follows the retries still finds its meter; a completion consumes the entry.
|
|
1352
926
|
if (invocationId !== undefined && (tokens > 0 || final))
|
|
1353
927
|
this.speedInvocations.delete(invocationId);
|
|
1354
928
|
this.ensureSpeedMeter(key).meter.report(tokens, invocationId, final, decodeMs);
|
|
1355
929
|
this.scheduleRender();
|
|
1356
930
|
}
|
|
1357
|
-
/**
|
|
1358
|
-
* Feed the footer's token-speed readout with a fragment a request is still streaming.
|
|
1359
|
-
*
|
|
1360
|
-
* A thinking model can stream for minutes before its usage arrives, and a readout that moved
|
|
1361
|
-
* only on completions sat on the previous number the whole time. The fragment is estimated
|
|
1362
|
-
* into the same meter the completion will report to, and repaints only when the number on
|
|
1363
|
-
* screen changes - a stream from a node the footer does not follow costs nothing.
|
|
1364
|
-
* @param text - the streamed reasoning or answer fragment.
|
|
1365
|
-
* @param invocationId - request identity from the executor, when one is known.
|
|
1366
|
-
*/
|
|
1367
931
|
noteStreamedOutput(text, invocationId) {
|
|
1368
932
|
const before = this.displayRate();
|
|
1369
933
|
this.ensureSpeedMeter(this.speedRoute(invocationId)).meter.stream(text, invocationId);
|
|
1370
934
|
if (this.displayRate() !== before)
|
|
1371
935
|
this.scheduleRender();
|
|
1372
936
|
}
|
|
1373
|
-
/** Drop a request's live estimate: the attempt failed, is about to be retried, or was aborted. */
|
|
1374
937
|
noteStreamEnded(invocationId) {
|
|
1375
938
|
const before = this.displayRate();
|
|
1376
939
|
this.speedMeters.get(this.speedRoute(invocationId))?.meter.endStream(invocationId);
|
|
1377
940
|
if (this.displayRate() !== before)
|
|
1378
941
|
this.scheduleRender();
|
|
1379
942
|
}
|
|
1380
|
-
/** The meter a request's measurements belong to: the one its start marker named, else the followed one. */
|
|
1381
943
|
speedRoute(invocationId) {
|
|
1382
944
|
const routed = invocationId !== undefined ? this.speedInvocations.get(invocationId) : undefined;
|
|
1383
945
|
return routed ?? this.activeSpeedKey ?? 'engineer';
|
|
1384
946
|
}
|
|
1385
|
-
/** The meter key for a node's requests: parallel copies each keep their own meter. */
|
|
1386
947
|
speedKey(nodeId, copy) {
|
|
1387
948
|
return copy === undefined ? nodeId : `${nodeId}#copy${copy}`;
|
|
1388
949
|
}
|
|
1389
|
-
/** The meter's speed entry, created on first sight so no measurement is ever dropped. */
|
|
1390
950
|
ensureSpeedMeter(key) {
|
|
1391
951
|
let entry = this.speedMeters.get(key);
|
|
1392
952
|
if (!entry) {
|
|
@@ -1395,14 +955,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1395
955
|
}
|
|
1396
956
|
return entry;
|
|
1397
957
|
}
|
|
1398
|
-
/**
|
|
1399
|
-
* Stamp a meter with the resolution its generating identity announced.
|
|
1400
|
-
*
|
|
1401
|
-
* A resolution different from the one the meter already measured under rebuilds the meter:
|
|
1402
|
-
* its average described the previous model or reasoning effort, which is exactly the
|
|
1403
|
-
* whole-agent-fallback case. Learning the identity for a meter that had none (the session
|
|
1404
|
-
* event merely arrives before the meter was stamped) never discards measurements.
|
|
1405
|
-
*/
|
|
1406
958
|
stampSpeedMeter(key, provider, model, reasoningEffort) {
|
|
1407
959
|
const entry = this.ensureSpeedMeter(key);
|
|
1408
960
|
const changed = (provider !== undefined && entry.provider !== undefined && provider !== entry.provider)
|
|
@@ -1419,34 +971,11 @@ export class TerminalUI extends EventEmitter {
|
|
|
1419
971
|
entry.reasoningEffort = reasoningEffort;
|
|
1420
972
|
}
|
|
1421
973
|
}
|
|
1422
|
-
/**
|
|
1423
|
-
* The footer's token speed: the cumulative average of the generating identity the readout
|
|
1424
|
-
* currently follows, unchanged between completions.
|
|
1425
|
-
*
|
|
1426
|
-
* Exposed for callers and tests that need the exact number the readout is based on. The
|
|
1427
|
-
* footer draws {@link displayRate}, which adds the model-identity check.
|
|
1428
|
-
*/
|
|
1429
974
|
tokenSpeed() { return this.activeSpeedKey === undefined ? 0 : this.speedMeters.get(this.activeSpeedKey)?.meter.rate() ?? 0; }
|
|
1430
|
-
/**
|
|
1431
|
-
* The node whose resolution the model row and the speed readout describe.
|
|
1432
|
-
*
|
|
1433
|
-
* This is the identity the readout follows - the most recent node or parallel copy to open
|
|
1434
|
-
* a model call - so the row names the same node whose average is drawn, not whichever node
|
|
1435
|
-
* happened to start first. Without a followed identity it falls back to the first active
|
|
1436
|
-
* node, and with no active node at all the session's own selection answers.
|
|
1437
|
-
*/
|
|
1438
975
|
displayNode() {
|
|
1439
976
|
return (this.activeSpeedNode !== undefined ? this.activeNodes.get(this.activeSpeedNode) : undefined)
|
|
1440
977
|
?? [...this.activeNodes.values()][0];
|
|
1441
978
|
}
|
|
1442
|
-
/**
|
|
1443
|
-
* The speed the footer shows: the followed identity's cumulative average, but only while
|
|
1444
|
-
* the model row names the resolution the average was measured under.
|
|
1445
|
-
*
|
|
1446
|
-
* After a run ends the row reverts to the session's own selection, so an average measured
|
|
1447
|
-
* on a node with a provider, model or effort override would otherwise sit beside a
|
|
1448
|
-
* different resolution's name; the segment disappears instead of misdescribing it.
|
|
1449
|
-
*/
|
|
1450
979
|
displayRate() {
|
|
1451
980
|
const entry = this.activeSpeedKey === undefined ? undefined : this.speedMeters.get(this.activeSpeedKey);
|
|
1452
981
|
if (!entry)
|
|
@@ -1455,8 +984,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1455
984
|
const perCopy = this.activeSpeedCopy !== undefined ? node?.copiesResolved?.get(this.activeSpeedCopy) : undefined;
|
|
1456
985
|
const provider = perCopy?.provider ?? node?.provider ?? this.status.provider;
|
|
1457
986
|
const model = perCopy?.model ?? node?.model ?? this.status.model;
|
|
1458
|
-
// The followed copy's own effort comes first: comparing the meter's reading against a
|
|
1459
|
-
// sibling's effort suppressed a rate that was measured on this copy's own resolution.
|
|
1460
987
|
const effort = perCopy?.resolved?.reasoningEffort ?? node?.resolved?.reasoningEffort ?? this.status.reasoningEffort;
|
|
1461
988
|
if ((entry.provider !== undefined && entry.provider !== provider)
|
|
1462
989
|
|| (entry.model !== undefined && entry.model !== model)
|
|
@@ -1464,22 +991,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
1464
991
|
return 0;
|
|
1465
992
|
return entry.meter.rate();
|
|
1466
993
|
}
|
|
1467
|
-
/**
|
|
1468
|
-
* Let the composer accept steering input for the duration of a run.
|
|
1469
|
-
*
|
|
1470
|
-
* Called with `true` when an interactive run starts and `false` when it ends, so the
|
|
1471
|
-
* normal question flow owns the composer outside a run.
|
|
1472
|
-
* @param enabled - whether submitted text should be queued as a steer.
|
|
1473
|
-
* @returns when disabling, any queued steers that can no longer be injected. The
|
|
1474
|
-
* executor's last poll happens before finalization, so a steer submitted in that
|
|
1475
|
-
* window is visibly accepted but has nowhere to go; returning it lets the caller say
|
|
1476
|
-
* so instead of dropping it silently.
|
|
1477
|
-
*/
|
|
1478
994
|
setSteering(enabled) {
|
|
1479
995
|
if (this.steering === enabled)
|
|
1480
996
|
return [];
|
|
1481
997
|
this.steering = enabled;
|
|
1482
|
-
// A parked draft belongs to the run that parked it.
|
|
1483
998
|
if (!enabled) {
|
|
1484
999
|
this.steerDraft = undefined;
|
|
1485
1000
|
this.steerCursor = 0;
|
|
@@ -1487,49 +1002,23 @@ export class TerminalUI extends EventEmitter {
|
|
|
1487
1002
|
this.scheduleRender();
|
|
1488
1003
|
if (enabled)
|
|
1489
1004
|
return [];
|
|
1490
|
-
// A steer that reached the executor's finalization window has nowhere to go: its text is
|
|
1491
|
-
// returned for the caller to report, and its chips return to the queue so they can ride the
|
|
1492
|
-
// next task. The queue itself survives too — a paste is draft material like typed text.
|
|
1493
1005
|
const undelivered = this.takeSteeringTurns();
|
|
1494
1006
|
for (const turn of undelivered)
|
|
1495
1007
|
for (const pending of turn.attachments)
|
|
1496
1008
|
this.addAttachment(pending);
|
|
1497
1009
|
return undelivered.map(turn => turn.text);
|
|
1498
1010
|
}
|
|
1499
|
-
/** The surface that currently owns the composer, if any. */
|
|
1500
1011
|
composerOwner() {
|
|
1501
1012
|
return this.pending ?? (this.steering ? STEERING_OWNER : undefined);
|
|
1502
1013
|
}
|
|
1503
|
-
/**
|
|
1504
|
-
* Whether a captured composer owner is still the owner.
|
|
1505
|
-
*
|
|
1506
|
-
* Deferred input (a paste, or an Enter held back by the input-burst window) is only
|
|
1507
|
-
* delivered when the surface that armed it still owns the composer. Steering is an
|
|
1508
|
-
* owner too, so a pasted steer must not be discarded just because no question is
|
|
1509
|
-
* pending.
|
|
1510
|
-
* @param token - the owner captured when the input arrived.
|
|
1511
|
-
* @returns whether that owner may still accept the deferred input.
|
|
1512
|
-
*/
|
|
1513
1014
|
ownsComposer(token) {
|
|
1514
|
-
// Object identity against a module-private sentinel, compared by reference and never by
|
|
1515
|
-
// value. A static analyser flags `===` near the word "token" as a secret comparison; there
|
|
1516
|
-
// is no secret here -- `STEERING_OWNER` is this module's own marker object and `token` is
|
|
1517
|
-
// never a string, so no constant-time byte comparison applies or would mean anything.
|
|
1518
1015
|
if (token === STEERING_OWNER)
|
|
1519
1016
|
return this.steering && !this.pending;
|
|
1520
1017
|
return token !== undefined && token === this.pending;
|
|
1521
1018
|
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Take every queued steer message, without blocking.
|
|
1524
|
-
*
|
|
1525
|
-
* The hardened executor polls this at turn boundaries; returning immediately with an
|
|
1526
|
-
* empty array is what lets a run continue when the user has typed nothing.
|
|
1527
|
-
* @returns the queued messages, oldest first.
|
|
1528
|
-
*/
|
|
1529
1019
|
takeSteering() {
|
|
1530
1020
|
return this.takeSteeringTurns().map(turn => turn.text);
|
|
1531
1021
|
}
|
|
1532
|
-
/** The queued steers with their attachments, oldest first; each turn is one injected user message. */
|
|
1533
1022
|
takeSteeringTurns() {
|
|
1534
1023
|
const queued = this.steered;
|
|
1535
1024
|
this.steered = [];
|
|
@@ -1537,20 +1026,34 @@ export class TerminalUI extends EventEmitter {
|
|
|
1537
1026
|
}
|
|
1538
1027
|
setTodos(todos) { this.todos = todos.map(todo => ({ ...todo, text: oneLine(todo.text) })); this.todoOffset = Math.min(this.todoOffset, Math.max(0, todos.length - 1)); if (!todos.length)
|
|
1539
1028
|
this.expandedTodos = false; this.scheduleRender(); }
|
|
1029
|
+
agentLines(width, maxRows) {
|
|
1030
|
+
const groups = this.subagents.groups();
|
|
1031
|
+
if (!groups.length || maxRows < 1)
|
|
1032
|
+
return [];
|
|
1033
|
+
const now = this.tokenClock ? this.tokenClock() : Date.now();
|
|
1034
|
+
const all = this.subagents.list();
|
|
1035
|
+
if (this.scroll > 0 || maxRows < 2) {
|
|
1036
|
+
const working = all.filter(entry => entry.status === 'running').length;
|
|
1037
|
+
return [paint(' ' + clip(`Agents ${all.length - working}/${all.length} done${working ? ` · ${working} running` : ''}`, width), GRAY)];
|
|
1038
|
+
}
|
|
1039
|
+
return subagentTreeRows(groups, Math.max(8, Math.min(AGENT_FALLBACK_MAX_COLUMNS, width - 2)), Math.min(AGENT_FALLBACK_MAX_ROWS, maxRows), now)
|
|
1040
|
+
.map(line => ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join(''));
|
|
1041
|
+
}
|
|
1042
|
+
goalLines(width, maxRows) {
|
|
1043
|
+
const goal = this.status.goal;
|
|
1044
|
+
if (!goal || maxRows < 1 || width < 12)
|
|
1045
|
+
return [];
|
|
1046
|
+
return [clip(`${goal.status === 'met' ? '✓' : '◎'} ${goalStatusLabel(goal)}: ${oneLine(goal.text)}`, width)];
|
|
1047
|
+
}
|
|
1540
1048
|
todoLines(maxRows) {
|
|
1541
1049
|
if (!this.todos.length || maxRows < 1)
|
|
1542
1050
|
return [];
|
|
1543
1051
|
const done = this.todos.filter(todo => todo.status === 'completed').length;
|
|
1544
|
-
// While scrolled back the todo block stays pinned but collapses to one line, so it
|
|
1545
|
-
// never competes with the transcript the user is reading. Scrolling to the live tail
|
|
1546
|
-
// restores the full list without changing the expand/collapse state.
|
|
1547
1052
|
if (this.scroll > 0 && !this.expandedTodos) {
|
|
1548
1053
|
const active = this.todos.find(todo => todo.status === 'in_progress');
|
|
1549
1054
|
const label = `${done}/${this.todos.length} done${active ? ` · ${active.text}` : ''}`;
|
|
1550
1055
|
return [`Todo ${label} · ctrl+t to expand`];
|
|
1551
1056
|
}
|
|
1552
|
-
// The expanded form needs a header, at least one item and a summary; the collapsed form
|
|
1553
|
-
// above needs only one row, so this guard sits after it rather than hiding both.
|
|
1554
1057
|
if (maxRows < 3)
|
|
1555
1058
|
return [];
|
|
1556
1059
|
const count = Math.min(this.todos.length, this.expandedTodos ? maxRows - 2 : Math.min(5, maxRows - 2));
|
|
@@ -1561,17 +1064,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1561
1064
|
const summary = this.expandedTodos && hidden ? `${this.todoOffset + 1}-${this.todoOffset + count}/${this.todos.length} · Page Up/Down · ` : hidden ? `… +${hidden} more ` : '';
|
|
1562
1065
|
return ['Todo', ...visible.map(todo => ` ${todo.status === 'completed' ? '✓' : todo.status === 'in_progress' ? '●' : '○'} ${todo.text}`), `${summary}(${done} done) · ctrl+t to ${this.expandedTodos ? 'collapse' : 'expand'}`];
|
|
1563
1066
|
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Rows for the live reasoning preview, standing in for the plain working line.
|
|
1566
|
-
*
|
|
1567
|
-
* Collapsed it keeps the latest reasoning on one row and pins elapsed time plus the
|
|
1568
|
-
* expand control on the row directly beneath it, so a growing reasoning tail cannot push
|
|
1569
|
-
* the control off to the right. Expanded, the default for every new stream, it opens a
|
|
1570
|
-
* fixed {@link THINKING_ROWS}-row window on the tail, padded at the top with the marker on
|
|
1571
|
-
* the first reasoning row, with the same control row beneath it. `maxRows`
|
|
1572
|
-
* is the room the terminal offers once the transcript keeps at least its last row; a
|
|
1573
|
-
* one-row budget still shows the reasoning row.
|
|
1574
|
-
*/
|
|
1575
1067
|
thinkingLines(width, seconds, maxRows) {
|
|
1576
1068
|
if (!this.thinkingActive || maxRows < 1)
|
|
1577
1069
|
return [];
|
|
@@ -1588,7 +1080,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1588
1080
|
const first = traceCount - wrapped.length;
|
|
1589
1081
|
return [...rows.map((row, index) => clip(`${index === first ? '◌ ' : ' '}${row}`, inner)), clip(`◌ ${stamp} · ctrl+y`, inner)];
|
|
1590
1082
|
}
|
|
1591
|
-
/** The last nonempty line of the retained reasoning, flattened for one row. */
|
|
1592
1083
|
thinkingTail() {
|
|
1593
1084
|
const rows = this.thinking.split('\n');
|
|
1594
1085
|
for (let index = rows.length - 1; index >= 0; index--)
|
|
@@ -1654,6 +1145,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
1654
1145
|
this.output.write('\x1b[?1002l\x1b[?1006l\x1b[?1007h\x1b[?2004l\x1b[?25h\x1b[0m\x1b[?1049l');
|
|
1655
1146
|
}
|
|
1656
1147
|
}
|
|
1148
|
+
this.releaseWarnings?.();
|
|
1149
|
+
this.releaseWarnings = undefined;
|
|
1657
1150
|
this.emit('close');
|
|
1658
1151
|
}
|
|
1659
1152
|
finishQuestion() {
|
|
@@ -1669,7 +1162,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1669
1162
|
this.pasteQuestion = undefined;
|
|
1670
1163
|
this.completion = undefined;
|
|
1671
1164
|
this.dismissedCompletion = undefined;
|
|
1672
|
-
// Put back a steer the question interrupted, so the user resumes where they left off.
|
|
1673
1165
|
if (this.steering && this.steerDraft !== undefined) {
|
|
1674
1166
|
this.value = this.restoredDraft(this.steerDraft);
|
|
1675
1167
|
this.cursor = Math.min(this.steerCursor, this.value.length);
|
|
@@ -1691,20 +1183,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1691
1183
|
this.consumeRaw();
|
|
1692
1184
|
this.consumeIncoming();
|
|
1693
1185
|
};
|
|
1694
|
-
/**
|
|
1695
|
-
* Frame legacy X10 mouse reports on the raw byte stream before UTF-8 decoding.
|
|
1696
|
-
*
|
|
1697
|
-
* A terminal with mouse tracking but without the SGR encoding of mode 1006 answers capture
|
|
1698
|
-
* with ESC[M plus three raw payload bytes (button, then coordinates, each offset by
|
|
1699
|
-
* 32). Those bytes are framed here rather than in the decoded string because decoding
|
|
1700
|
-
* buffers an incomplete trailing sequence and collapses a complete pair into one
|
|
1701
|
-
* character, so a string-domain match could only see a report late, consuming the
|
|
1702
|
-
* keystroke that follows it. A report split across reads holds the buffer for the
|
|
1703
|
-
* input burst, the same grace a lone Escape gets; a burst that elapses with an
|
|
1704
|
-
* incomplete prefix hands the bytes to the key parser as if they were typed. Inside a
|
|
1705
|
-
* bracketed paste the bytes are text, so once the decoded stream opens a paste the
|
|
1706
|
-
* remainder is handed over untouched.
|
|
1707
|
-
*/
|
|
1708
1186
|
consumeRaw() {
|
|
1709
1187
|
while (this.rawIncoming.length) {
|
|
1710
1188
|
const at = this.rawIncoming.indexOf(LEGACY_MOUSE);
|
|
@@ -1717,8 +1195,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1717
1195
|
if (at < 0)
|
|
1718
1196
|
break;
|
|
1719
1197
|
if (this.pasting) {
|
|
1720
|
-
// Only the paste body is text. Bytes after its terminator are framed again, so a
|
|
1721
|
-
// report that arrives in the same read as the end of a paste is still a report.
|
|
1722
1198
|
const closes = this.rawIncoming.indexOf(PASTE_END);
|
|
1723
1199
|
if (closes < 0) {
|
|
1724
1200
|
this.feedRaw(this.rawIncoming);
|
|
@@ -1737,11 +1213,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
1737
1213
|
}
|
|
1738
1214
|
const button = this.rawIncoming[3] - 32, column = this.rawIncoming[4] - 32, row = this.rawIncoming[5] - 32;
|
|
1739
1215
|
this.rawIncoming = this.rawIncoming.subarray(6);
|
|
1740
|
-
// The legacy encoding has no release flag: a release is reported as button 3.
|
|
1741
1216
|
this.mouse(button, (button & 3) !== 3 || (button & 64) !== 0, column, row);
|
|
1742
1217
|
}
|
|
1743
|
-
// Nothing report-shaped is pending: decode everything except a suffix that could
|
|
1744
|
-
// still grow into a report prefix, which waits for the next chunk or the burst.
|
|
1745
1218
|
const hold = legacyMousePrefixLength(this.rawIncoming);
|
|
1746
1219
|
if (this.rawIncoming.length > hold) {
|
|
1747
1220
|
const head = this.rawIncoming.subarray(0, this.rawIncoming.length - hold);
|
|
@@ -1756,11 +1229,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1756
1229
|
armRawTimer() {
|
|
1757
1230
|
if (this.rawTimer || this.closed)
|
|
1758
1231
|
return;
|
|
1759
|
-
// The burst has already done the lone-Escape disambiguation, so a flush that leaves
|
|
1760
|
-
// exactly an ESC resolves it as the Escape key. The surface that received the held
|
|
1761
|
-
// bytes is captured the way escapeTimer captures its own: if a load finished and
|
|
1762
|
-
// opened a modal during the window, the bytes die with the surface they belonged to
|
|
1763
|
-
// instead of closing or typing into the one that replaced it.
|
|
1764
1232
|
const modal = this.modal, question = this.pending;
|
|
1765
1233
|
this.rawTimer = setTimeout(() => {
|
|
1766
1234
|
this.rawTimer = undefined;
|
|
@@ -1779,7 +1247,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1779
1247
|
this.consumeIncoming();
|
|
1780
1248
|
}, INPUT_BURST_MS);
|
|
1781
1249
|
}
|
|
1782
|
-
/** Drain the decoded stream: paste markers, SGR mouse reports and ordinary keys. */
|
|
1783
1250
|
consumeIncoming() {
|
|
1784
1251
|
const start = '\x1b[200~', end = '\x1b[201~';
|
|
1785
1252
|
while (this.incoming) {
|
|
@@ -1840,13 +1307,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1840
1307
|
break;
|
|
1841
1308
|
}
|
|
1842
1309
|
}
|
|
1843
|
-
/**
|
|
1844
|
-
* The effective disclosure state of one prompt box.
|
|
1845
|
-
*
|
|
1846
|
-
* An explicit per-prompt toggle wins over the Ctrl+O default, and Ctrl+O clears those
|
|
1847
|
-
* toggles when it is pressed (see onKey), so the keyboard always remains a way out of
|
|
1848
|
-
* either state.
|
|
1849
|
-
*/
|
|
1850
1310
|
promptExpanded(id) {
|
|
1851
1311
|
if (this.expandedPromptIds.has(id))
|
|
1852
1312
|
return true;
|
|
@@ -1854,19 +1314,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1854
1314
|
return false;
|
|
1855
1315
|
return this.expandedTranscript;
|
|
1856
1316
|
}
|
|
1857
|
-
/**
|
|
1858
|
-
* Act on one mouse report: the wheel scrolls, and a left drag selects text on the screen.
|
|
1859
|
-
*
|
|
1860
|
-
* The selection lives in screen cells over the frame as drawn. Releasing the button copies
|
|
1861
|
-
* it; the highlight stays until the next key, click or wheel tick so the reader can see what
|
|
1862
|
-
* was taken. A press and release on one cell selects nothing, and a second press on the same
|
|
1863
|
-
* cell within the double-click window takes the word under it. Other buttons are swallowed,
|
|
1864
|
-
* so no click reaches the composer as text.
|
|
1865
|
-
* @param button - the report's button code, modifiers and motion bit included.
|
|
1866
|
-
* @param pressed - false for a release.
|
|
1867
|
-
* @param column - 1-based screen column.
|
|
1868
|
-
* @param row - 1-based screen row.
|
|
1869
|
-
*/
|
|
1870
1317
|
mouse(button, pressed, column, row) {
|
|
1871
1318
|
const base = button & ~28;
|
|
1872
1319
|
if (base === 64 || base === 65) {
|
|
@@ -1881,7 +1328,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1881
1328
|
}
|
|
1882
1329
|
const which = base & 3, motion = (base & 32) !== 0;
|
|
1883
1330
|
if (motion) {
|
|
1884
|
-
// A drag is not the first half of a double-click, even when it ends where it began.
|
|
1885
1331
|
if (which === 0 && this.selection?.dragging) {
|
|
1886
1332
|
this.selection.head = { row, column };
|
|
1887
1333
|
this.lastPress = undefined;
|
|
@@ -1893,7 +1339,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1893
1339
|
const now = Date.now(), last = this.lastPress;
|
|
1894
1340
|
const double = last !== undefined && last.row === row && last.column === column && now - last.at <= DOUBLE_CLICK_MS;
|
|
1895
1341
|
this.lastPress = double ? undefined : { row, column, at: now };
|
|
1896
|
-
// A drag that starts in the chat column stays there, so the side panel is not copied with it.
|
|
1897
1342
|
const chat = this.chatColumns(), limit = column <= chat ? chat : undefined;
|
|
1898
1343
|
const word = double ? wordAt(this.frame, { row, column }) : undefined;
|
|
1899
1344
|
this.selection = word ? { ...word, limit, dragging: false } : { anchor: { row, column }, head: { row, column }, limit, dragging: true };
|
|
@@ -1906,8 +1351,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1906
1351
|
const selection = this.selection;
|
|
1907
1352
|
if (!selection?.dragging)
|
|
1908
1353
|
return;
|
|
1909
|
-
// The release carries its own position: a fast drag can end past the last motion
|
|
1910
|
-
// report, or send no motion report at all.
|
|
1911
1354
|
selection.head = { row, column };
|
|
1912
1355
|
selection.dragging = false;
|
|
1913
1356
|
if (emptySelection(selection))
|
|
@@ -1917,7 +1360,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1917
1360
|
this.scheduleRender();
|
|
1918
1361
|
}
|
|
1919
1362
|
}
|
|
1920
|
-
/** Copy the screen selection; over SSH only the terminal's clipboard is the reader's own. */
|
|
1921
1363
|
copyScreenSelection() {
|
|
1922
1364
|
if (!this.selection)
|
|
1923
1365
|
return;
|
|
@@ -1925,17 +1367,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
1925
1367
|
if (text.trim())
|
|
1926
1368
|
this.copyText(text, { terminalOnly: Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY) });
|
|
1927
1369
|
}
|
|
1928
|
-
/** Lay the selection highlight over a composed frame. */
|
|
1929
1370
|
withSelection(lines) {
|
|
1930
1371
|
const selection = this.selection;
|
|
1931
1372
|
if (!selection || emptySelection(selection))
|
|
1932
1373
|
return lines;
|
|
1933
1374
|
return lines.map((line, index) => { const span = selectedSpan(selection, index + 1); return span ? highlightRow(line, span[0], span[1]) : line; });
|
|
1934
1375
|
}
|
|
1935
|
-
/**
|
|
1936
|
-
* Scroll the transcript (or the active screen). Positive `direction` scrolls up (toward
|
|
1937
|
-
* older output), which is what a wheel-up report and an Up key during a run both mean.
|
|
1938
|
-
*/
|
|
1939
1376
|
scrollBy(direction) {
|
|
1940
1377
|
if (this.modal) {
|
|
1941
1378
|
if (this.modal.kind === 'text')
|
|
@@ -1996,9 +1433,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
1996
1433
|
this.armPlainInput();
|
|
1997
1434
|
return;
|
|
1998
1435
|
}
|
|
1999
|
-
// Steering shares the plain-input path so a pasted steer is handled like pasted text,
|
|
2000
|
-
// but the deferred Enter must fire even with no pending question, so the ownership
|
|
2001
|
-
// token carries whichever surface currently owns the composer.
|
|
2002
1436
|
const owner = this.composerOwner();
|
|
2003
1437
|
if (/^[\r\n]$|^\r\n$/.test(text)) {
|
|
2004
1438
|
this.pendingBreak = text;
|
|
@@ -2028,19 +1462,9 @@ export class TerminalUI extends EventEmitter {
|
|
|
2028
1462
|
return; if (this.pending?.choices && text.startsWith('/'))
|
|
2029
1463
|
this.commandInput = true; const selected = this.selectionRange(); if (selected)
|
|
2030
1464
|
this.deleteSelection(selected); const before = this.value.slice(0, this.cursor).join(''), after = this.value.slice(this.cursor).join(''); const insertion = clean(text).slice(0, Math.max(0, MAX_INPUT - before.length - after.length)); this.value = composerGraphemes(before + insertion + after); this.cursor = composerGraphemes(before + insertion).length; this.chipTypedSkill(); this.completion = undefined; this.dismissedCompletion = undefined; this.scroll = 0; this.scheduleRender(); }
|
|
2031
|
-
/** Whether the surface that owns the composer accepts task input — the only place attachments mean anything. */
|
|
2032
1465
|
conversationComposer() {
|
|
2033
|
-
// Steering owns the conversation only while no question holds the composer: an approval or
|
|
2034
|
-
// clarification owns it the moment it appears, and a queued attachment would then ride a
|
|
2035
|
-
// later model turn while the visible question receives an empty Enter. This mirrors the
|
|
2036
|
-
// `steering && !pending` owner rule in ownsComposer's STEERING_OWNER branch.
|
|
2037
1466
|
return (this.steering && !this.pending) || this.pending?.conversationPrompt === true;
|
|
2038
1467
|
}
|
|
2039
|
-
/**
|
|
2040
|
-
* Land a completed bracketed paste. Terminal drag-and-drop arrives as one or more existing
|
|
2041
|
-
* filesystem paths, which become file references; a paste past the inline threshold becomes a
|
|
2042
|
-
* spooled text attachment instead of flooding the composer; everything else inlines as before.
|
|
2043
|
-
*/
|
|
2044
1468
|
landPaste(text) {
|
|
2045
1469
|
const cleaned = clean(text);
|
|
2046
1470
|
if (this.conversationComposer()) {
|
|
@@ -2057,11 +1481,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2057
1481
|
}
|
|
2058
1482
|
this.insert(cleaned);
|
|
2059
1483
|
}
|
|
2060
|
-
/**
|
|
2061
|
-
* Queue one attachment as an inline token at the composer cursor; false means the per-turn cap
|
|
2062
|
-
* refused it. Outside the conversation composer the token waits, and `adoptTokens` appends it
|
|
2063
|
-
* to the draft once that composer is armed again.
|
|
2064
|
-
*/
|
|
2065
1484
|
addAttachment(pending) {
|
|
2066
1485
|
if (this.attachments.length >= MAX_ATTACHMENTS) {
|
|
2067
1486
|
this.print(`Attachment limit reached (${MAX_ATTACHMENTS}). Submit, or press Ctrl+X to remove the last one.`);
|
|
@@ -2072,12 +1491,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
2072
1491
|
pending = { ...pending, name: `pasted-${seq}.txt` };
|
|
2073
1492
|
if (pending.kind === 'image' && !pending.name)
|
|
2074
1493
|
pending = { ...pending, name: `clipboard-${seq}.png` };
|
|
2075
|
-
// One code point per attachment for the session: a marker parked in a history or steer draft
|
|
2076
|
-
// after its attachment was dropped must never come back as a reference to a newer one.
|
|
2077
1494
|
const marker = String.fromCodePoint(TOKEN_BASE + seq % 0xFFFFE);
|
|
2078
1495
|
this.attachments.push({ marker, seq, pending });
|
|
2079
|
-
// The token replaces a selection, as a small paste does; a space follows it unless one
|
|
2080
|
-
// already does, so typing on reads as a new word.
|
|
2081
1496
|
if (this.conversationComposer()) {
|
|
2082
1497
|
const selected = this.selectionRange();
|
|
2083
1498
|
if (selected)
|
|
@@ -2091,14 +1506,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
2091
1506
|
this.scheduleRender();
|
|
2092
1507
|
return true;
|
|
2093
1508
|
}
|
|
2094
|
-
/** The skills the `/` popup lists after the built-in commands; a skill whose command a built-in owns is left out. */
|
|
2095
1509
|
setSkillCommands(skills) {
|
|
2096
1510
|
this.skillCommands = skills.filter(skill => /^\/\S+$/.test(skill.command) && !commands.includes(skill.command)).map(skill => ({ command: skill.command, description: oneLine(skill.description) }));
|
|
2097
1511
|
this.completion = undefined;
|
|
2098
1512
|
this.scheduleRender();
|
|
2099
1513
|
}
|
|
2100
1514
|
skillCommand(command) { return this.skillCommands.some(skill => skill.command === command); }
|
|
2101
|
-
/** Replace the draft's leading `command` (and anything typed after it) with the skill chip and a space. */
|
|
2102
1515
|
insertSkillChip(command, rest = ' ') {
|
|
2103
1516
|
this.skillChip = command;
|
|
2104
1517
|
this.value = [SKILL_TOKEN, ...composerGraphemes(rest.startsWith(' ') ? rest : ' ' + rest)];
|
|
@@ -2107,10 +1520,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2107
1520
|
this.dismissedCompletion = undefined;
|
|
2108
1521
|
this.selectionAnchor = undefined;
|
|
2109
1522
|
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Turn a leading, fully typed skill command into the chip once a space follows it, so a command
|
|
2112
|
-
* typed out in full reads the same as one picked from the popup.
|
|
2113
|
-
*/
|
|
2114
1523
|
chipTypedSkill() {
|
|
2115
1524
|
if (this.value[0] === SKILL_TOKEN)
|
|
2116
1525
|
return;
|
|
@@ -2123,10 +1532,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2123
1532
|
this.value.splice(0, length, SKILL_TOKEN);
|
|
2124
1533
|
this.cursor = Math.max(1, this.cursor - length + 1);
|
|
2125
1534
|
}
|
|
2126
|
-
/**
|
|
2127
|
-
* Backspace and Delete. Beside the skill chip they remove the chip and the space that follows it in
|
|
2128
|
-
* one keystroke, so a picked skill comes out as it went in.
|
|
2129
|
-
*/
|
|
2130
1535
|
backspace() {
|
|
2131
1536
|
if (this.cursor === 2 && this.value[0] === SKILL_TOKEN && this.value[1] === ' ') {
|
|
2132
1537
|
this.removeDraft(0, 2);
|
|
@@ -2143,9 +1548,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2143
1548
|
}
|
|
2144
1549
|
this.removeDraft(this.cursor, 1);
|
|
2145
1550
|
}
|
|
2146
|
-
/** Take every queued attachment in draft order, without blocking — the CLI drains this when a task is submitted. */
|
|
2147
1551
|
takeAttachments() { const queued = this.attachments.map(entry => entry.pending); this.attachments = []; this.scheduleRender(); return queued; }
|
|
2148
|
-
/** The bold label a token draws as in the composer. */
|
|
2149
1552
|
tokenLabel({ seq, pending }) {
|
|
2150
1553
|
if (pending.kind === 'text') {
|
|
2151
1554
|
const lines = pending.content.split('\n').length;
|
|
@@ -2157,7 +1560,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2157
1560
|
const folder = /[\\/]$/.test(label);
|
|
2158
1561
|
return `[${folder ? 'Folder' : 'File'} #${seq} · ${label.replace(/[\\/]+$/, '').split(/[\\/]/).pop() || label}${folder ? '/' : ''}]`;
|
|
2159
1562
|
}
|
|
2160
|
-
/** The draft as display elements: each token replaced by its label, clipped to the composer. */
|
|
2161
1563
|
visibleDraft(width) {
|
|
2162
1564
|
if (this.pending?.secret)
|
|
2163
1565
|
return this.value.map(() => '*');
|
|
@@ -2166,12 +1568,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2166
1568
|
labels.set(SKILL_TOKEN, clip(this.skillChip, Math.max(1, width)));
|
|
2167
1569
|
return this.value.map(part => labels.get(part) ?? (isToken(part) ? '' : part));
|
|
2168
1570
|
}
|
|
2169
|
-
/**
|
|
2170
|
-
* The draft as submitted text. Tokens become `[name]` references the model can match against
|
|
2171
|
-
* the attachment block, and the queue is put in the order the tokens appear. A draft that is
|
|
2172
|
-
* only tokens submits empty, so the CLI keeps its attachment-only task text, and a slash
|
|
2173
|
-
* command submits without them, so the command runs and the attachments stay queued.
|
|
2174
|
-
*/
|
|
2175
1571
|
submittedDraft() {
|
|
2176
1572
|
const order = new Map(this.value.map((part, index) => [part, index]));
|
|
2177
1573
|
this.attachments.sort((left, right) => (order.get(left.marker) ?? Infinity) - (order.get(right.marker) ?? Infinity));
|
|
@@ -2184,13 +1580,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2184
1580
|
const names = new Map(this.attachments.map(({ marker, pending }) => [marker, `[${pending.kind === 'file' ? pending.path : pending.name}]`]));
|
|
2185
1581
|
return draft.map(part => isToken(part) ? names.get(part) ?? '' : part).join('');
|
|
2186
1582
|
}
|
|
2187
|
-
/**
|
|
2188
|
-
* The draft as it is parked (history browsing, a question interrupting steering): the skill chip is
|
|
2189
|
-
* written out as its command, so `restoredDraft` can turn it back into a chip — the token alone would
|
|
2190
|
-
* not survive the trip, and the draft would lose the skill it names.
|
|
2191
|
-
*/
|
|
2192
1583
|
parkedDraft() { return this.value.map(part => part === SKILL_TOKEN ? this.skillChip ?? '' : part).join(''); }
|
|
2193
|
-
/** A parked draft brought back into the composer, keeping only tokens whose attachment is still queued. */
|
|
2194
1584
|
restoredDraft(text) {
|
|
2195
1585
|
const live = new Set(this.attachments.map(entry => entry.marker));
|
|
2196
1586
|
const parts = composerGraphemes(text).filter(part => !isToken(part) || live.has(part));
|
|
@@ -2200,7 +1590,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2200
1590
|
this.skillChip = match[1];
|
|
2201
1591
|
return [SKILL_TOKEN, ...parts.slice(graphemes(match[1]).length)];
|
|
2202
1592
|
}
|
|
2203
|
-
/** Remove draft elements, dropping the attachment behind every token they held. */
|
|
2204
1593
|
removeDraft(start, count) {
|
|
2205
1594
|
const removed = new Set(this.value.splice(start, count).filter(isToken));
|
|
2206
1595
|
if (removed.has(SKILL_TOKEN))
|
|
@@ -2208,11 +1597,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2208
1597
|
if (removed.size)
|
|
2209
1598
|
this.attachments = this.attachments.filter(entry => !removed.has(entry.marker));
|
|
2210
1599
|
}
|
|
2211
|
-
/**
|
|
2212
|
-
* Put every queued token that is missing from the armed conversation draft back at its end. A
|
|
2213
|
-
* submitted prompt clears the composer before the CLI drains the queue, and `/attach` queues a
|
|
2214
|
-
* file between prompts, so a token can be queued while no draft holds it.
|
|
2215
|
-
*/
|
|
2216
1600
|
adoptTokens() {
|
|
2217
1601
|
if (!this.conversationComposer() || this.historyIndex !== this.history.length)
|
|
2218
1602
|
return;
|
|
@@ -2224,9 +1608,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2224
1608
|
if (atEnd)
|
|
2225
1609
|
this.cursor = this.value.length;
|
|
2226
1610
|
}
|
|
2227
|
-
/** Whether attachments are queued, without draining them (the CLI decides whether a submission carries them). */
|
|
2228
1611
|
hasQueuedAttachments() { return this.attachments.length > 0; }
|
|
2229
|
-
/** Read the system clipboard for an image and attach it (Ctrl+V; terminals cannot paste images as text). */
|
|
2230
1612
|
pasteClipboardImage() {
|
|
2231
1613
|
if (!this.conversationComposer())
|
|
2232
1614
|
return;
|
|
@@ -2234,9 +1616,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2234
1616
|
this.print('Clipboard image paste is unavailable here.');
|
|
2235
1617
|
return;
|
|
2236
1618
|
}
|
|
2237
|
-
// The probe is asynchronous (a shell-out on Windows): bind the result to the composer that
|
|
2238
|
-
// initiated it — and to its generation, so a steer submitted while the probe ran cannot be
|
|
2239
|
-
// overtaken by an image the user pasted for a draft that no longer exists.
|
|
2240
1619
|
const owner = this.composerOwner();
|
|
2241
1620
|
const generation = this.clipboardProbe;
|
|
2242
1621
|
void this.clipboardImageProbe().then(buffer => {
|
|
@@ -2255,6 +1634,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
2255
1634
|
}
|
|
2256
1635
|
clearDraft() { this.clipboardProbe += 1; this.value = []; this.cursor = 0; this.historyIndex = this.history.length; this.draft = ''; this.commandInput = false; this.completion = undefined; this.dismissedCompletion = undefined; this.attachments = []; this.scroll = 0; this.scheduleRender(); }
|
|
2257
1636
|
onKey = (text, key) => {
|
|
1637
|
+
if (this.selection && key.ctrl && key.name === 'c' && !emptySelection(this.selection)) {
|
|
1638
|
+
this.copyScreenSelection();
|
|
1639
|
+
this.selection = undefined;
|
|
1640
|
+
this.scheduleRender();
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
2258
1643
|
if (this.selection) {
|
|
2259
1644
|
this.selection = undefined;
|
|
2260
1645
|
this.scheduleRender();
|
|
@@ -2273,8 +1658,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2273
1658
|
this.scheduleRender();
|
|
2274
1659
|
return;
|
|
2275
1660
|
}
|
|
2276
|
-
// Expanding from the collapsed summary must not throw the reader back to the live tail:
|
|
2277
|
-
// the summary advertises ctrl+t precisely while scrolled back, so the position is kept.
|
|
2278
1661
|
if (key.ctrl && key.name === 't' && !this.modal) {
|
|
2279
1662
|
this.expandedTodos = !this.expandedTodos;
|
|
2280
1663
|
this.todoOffset = 0;
|
|
@@ -2282,9 +1665,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2282
1665
|
return;
|
|
2283
1666
|
}
|
|
2284
1667
|
if (key.ctrl && key.name === 'o' && !this.modal && this.dashboard) {
|
|
2285
|
-
// Leaving the dashboard always lands on the expanded transcript, and no prompt box is on
|
|
2286
|
-
// screen to invert: inverting stored boxes the reader cannot see would silently change
|
|
2287
|
-
// rows behind their back, so every box simply follows the expanded flag.
|
|
2288
1668
|
this.dashboard = false;
|
|
2289
1669
|
this.expandedTranscript = true;
|
|
2290
1670
|
this.expandedPromptIds.clear();
|
|
@@ -2294,11 +1674,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2294
1674
|
return;
|
|
2295
1675
|
}
|
|
2296
1676
|
if (key.ctrl && key.name === 'o' && !this.modal) {
|
|
2297
|
-
// Ctrl+O inverts exactly what is on screen: the details flag flips, and every prompt box
|
|
2298
|
-
// flips relative to the state the reader could see, so one press performs the action each
|
|
2299
|
-
// row advertises ("Ctrl+O to expand" / "Ctrl+O to collapse"). A box
|
|
2300
|
-
// whose state contradicts the flipped flag keeps an explicit override, because no single
|
|
2301
|
-
// global value can express per-box inversion; boxes created later follow the flag.
|
|
2302
1677
|
const expandedBefore = new Set([...this.promptBoxIds].filter(id => this.expandedPromptIds.has(id)
|
|
2303
1678
|
|| (this.expandedTranscript && !this.collapsedPromptIds.has(id))));
|
|
2304
1679
|
this.expandedTranscript = this.dashboard || !this.expandedTranscript;
|
|
@@ -2315,7 +1690,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2315
1690
|
this.scheduleRender();
|
|
2316
1691
|
return;
|
|
2317
1692
|
}
|
|
2318
|
-
// The reasoning preview collapses and reopens from the keyboard; no click reaches the app.
|
|
2319
1693
|
if (key.ctrl && key.name === 'y' && !this.modal) {
|
|
2320
1694
|
if (this.thinkingActive) {
|
|
2321
1695
|
this.thinkingExpanded = !this.thinkingExpanded;
|
|
@@ -2323,11 +1697,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2323
1697
|
}
|
|
2324
1698
|
return;
|
|
2325
1699
|
}
|
|
2326
|
-
// Composer attachments: Ctrl+X removes the last queued chip, Ctrl+V reads the system
|
|
2327
|
-
// clipboard for an image (a terminal's own paste cannot deliver one). Both are no-ops
|
|
2328
|
-
// without queued attachments / a clipboard probe, so they never shadow other intents.
|
|
2329
|
-
// Over a composer selection Ctrl+C copies and Ctrl+X cuts, ahead of their other meanings
|
|
2330
|
-
// (clearing the draft, interrupting, removing a chip). A secret prompt never copies.
|
|
2331
1700
|
if (key.ctrl && (key.name === 'c' || key.name === 'x') && !this.modal && !this.pending?.secret && this.selectionRange()) {
|
|
2332
1701
|
this.copySelection(key.name === 'x');
|
|
2333
1702
|
return;
|
|
@@ -2352,13 +1721,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2352
1721
|
this.pasteClipboardImage();
|
|
2353
1722
|
return;
|
|
2354
1723
|
}
|
|
2355
|
-
// Ctrl+C clears a non-empty draft before it interrupts anything: the draft is the
|
|
2356
|
-
// user's unfinished work, and one stray press should not pause a run or exit the
|
|
2357
|
-
// session and take the draft with it. An empty composer escalates as before. Only a
|
|
2358
|
-
// modal screen truly hides the composer — the dashboard keeps it drawn and editable,
|
|
2359
|
-
// so a draft there clears like any other. Ctrl+C inside a paste payload is unreachable
|
|
2360
|
-
// here: while a bracketed paste is in flight the bytes accumulate in the paste buffer
|
|
2361
|
-
// and are stripped by clean() when the paste lands.
|
|
2362
1724
|
if (key.ctrl && key.name === 'c') {
|
|
2363
1725
|
if (!this.modal && (this.value.length || this.hasQueuedAttachments())) {
|
|
2364
1726
|
this.clearDraft();
|
|
@@ -2395,12 +1757,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2395
1757
|
this.scheduleRender();
|
|
2396
1758
|
return;
|
|
2397
1759
|
}
|
|
2398
|
-
// Enter runs what the popup is highlighting: the popup promises that the selected row is
|
|
2399
|
-
// the command that runs, and a prefix such as `/prov` is not itself a command, so sending
|
|
2400
|
-
// it verbatim only ever produced an unknown-command notice. A plain Enter (Alt+Enter keeps
|
|
2401
|
-
// inserting a newline) substitutes the visible selection for the draft and then falls
|
|
2402
|
-
// through to the ordinary submit path below, so a single press is enough and the
|
|
2403
|
-
// substituted text is submitted, echoed and recorded exactly as if it had been typed.
|
|
2404
1760
|
if ((key.name === 'return' || key.name === 'enter') && !key.meta && !key.shift) {
|
|
2405
1761
|
const selected = this.selectedCompletion();
|
|
2406
1762
|
if (selected && this.skillCommand(selected)) {
|
|
@@ -2447,17 +1803,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
2447
1803
|
this.scheduleRender();
|
|
2448
1804
|
return;
|
|
2449
1805
|
}
|
|
2450
|
-
// While no prompt is pending — a run streaming output — there is no history to
|
|
2451
|
-
// navigate, so Up/Down scroll the transcript, alongside Page Up/Down and the wheel.
|
|
2452
|
-
// Steering keeps the composer editable, so a draft rebinds the arrows to cursor movement
|
|
2453
|
-
// inside it.
|
|
2454
1806
|
if ((key.name === 'up' || key.name === 'down') && !this.pending && (!this.steering || !this.value.length)) {
|
|
2455
1807
|
this.scrollBy(key.name === 'up' ? 1 : -1);
|
|
2456
1808
|
return;
|
|
2457
1809
|
}
|
|
2458
|
-
// Steering owns the composer for the duration of a run: submitted text is queued for
|
|
2459
|
-
// the executor instead of resolving a question, and a real question (approval,
|
|
2460
|
-
// clarification) still takes precedence because it sets `pending`.
|
|
2461
1810
|
if (this.steering && !this.pending && !this.modal) {
|
|
2462
1811
|
if ((key.name === 'return' || key.name === 'enter') && (key.meta || key.shift)) {
|
|
2463
1812
|
this.insert('\n');
|
|
@@ -2465,9 +1814,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2465
1814
|
}
|
|
2466
1815
|
if (key.name === 'return' || key.name === 'enter') {
|
|
2467
1816
|
const value = this.submittedDraft().trim();
|
|
2468
|
-
// An attachment-only steer submits too: the tokens are the message, and the CLI names
|
|
2469
|
-
// them with the same stand-in text an attachment-only task gets. Enter with neither
|
|
2470
|
-
// text nor tokens stays a no-op.
|
|
2471
1817
|
if (value || this.hasQueuedAttachments()) {
|
|
2472
1818
|
const drainAttachments = () => {
|
|
2473
1819
|
const queuedAttachments = this.takeAttachments();
|
|
@@ -2480,21 +1826,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
2480
1826
|
this.history.push(value);
|
|
2481
1827
|
this.history = this.history.slice(-100);
|
|
2482
1828
|
}
|
|
2483
|
-
// Steering is the composer for the live run, so a slash command typed here would
|
|
2484
|
-
// otherwise be delivered to the model as an instruction. Session commands that cannot
|
|
2485
|
-
// run mid-run say so immediately rather than queueing text the run would treat as a
|
|
2486
|
-
// prompt; the live subset, exits, and paused runs fall through to the run input
|
|
2487
|
-
// handler, which owns them.
|
|
2488
1829
|
const command = submittedCommand(value);
|
|
2489
1830
|
const hinted = command && !liveRunCommands.includes(command) && this.status.activity !== 'Paused' ? command : undefined;
|
|
2490
1831
|
if (hinted)
|
|
2491
1832
|
this.print(workingCommandHint(hinted));
|
|
2492
1833
|
else {
|
|
2493
1834
|
this.printPrompt(value);
|
|
2494
|
-
// Attachments leave the queue only when the text actually becomes a steer. A live
|
|
2495
|
-
// command (`/status`, `/attach`, …) is consumed by the run input handler, and a
|
|
2496
|
-
// paused run turns the text into a resume direction: both keep the queue for the
|
|
2497
|
-
// next submission, so running a command never discards queued files.
|
|
2498
1835
|
if (!this.runInputHandler?.(value))
|
|
2499
1836
|
this.steered.push({ text: value, attachments: drainAttachments() });
|
|
2500
1837
|
}
|
|
@@ -2502,7 +1839,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2502
1839
|
else {
|
|
2503
1840
|
this.steered.push({ text: '', attachments: drainAttachments() });
|
|
2504
1841
|
}
|
|
2505
|
-
// The submission ends this draft: a clipboard probe still running belongs to it.
|
|
2506
1842
|
this.clipboardProbe += 1;
|
|
2507
1843
|
this.value = [];
|
|
2508
1844
|
this.cursor = 0;
|
|
@@ -2556,8 +1892,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2556
1892
|
this.value = [];
|
|
2557
1893
|
this.cursor = 0;
|
|
2558
1894
|
this.commandInput = false;
|
|
2559
|
-
// Clarification cancellation belongs to the question, not the live-run command
|
|
2560
|
-
// router. Never settle an approval or resume a paused run with this command.
|
|
2561
1895
|
if (command.toLowerCase() === '/cancel') {
|
|
2562
1896
|
if (this.pending.choices?.some(choice => choice.id === 'cancel')) {
|
|
2563
1897
|
this.resolveQuestion('cancel');
|
|
@@ -2644,6 +1978,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
2644
1978
|
this.finishModal(item.id.startsWith(':') ? item.id : modal.editPrefix + item.id);
|
|
2645
1979
|
return;
|
|
2646
1980
|
}
|
|
1981
|
+
if (modal.kind === 'select' && ((key.name === 'right' && modal.expandPrefix !== undefined) || (key.name === 'left' && modal.collapsePrefix !== undefined))) {
|
|
1982
|
+
const item = modal.items[modal.selected];
|
|
1983
|
+
if (item && !item.separator)
|
|
1984
|
+
this.finishModal((key.name === 'right' ? modal.expandPrefix : modal.collapsePrefix) + item.id);
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
2647
1987
|
if (key.name === 'escape') {
|
|
2648
1988
|
this.finishModal();
|
|
2649
1989
|
return;
|
|
@@ -2678,9 +2018,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2678
2018
|
if (this.moveRow(direction))
|
|
2679
2019
|
return;
|
|
2680
2020
|
const historyAt = this.pending?.history ? Math.max(0, Math.min(this.history.length, this.historyIndex + direction)) : this.historyIndex;
|
|
2681
|
-
// The wheel never reaches this method: the mouse is captured, so it arrives as a wheel
|
|
2682
|
-
// report (`mouse`) and never as arrow bytes. Up/Down are therefore purely the keyboard:
|
|
2683
|
-
// cursor movement above, history recall here.
|
|
2684
2021
|
if (this.pending?.history) {
|
|
2685
2022
|
if (this.historyIndex === this.history.length)
|
|
2686
2023
|
this.draft = this.parkedDraft();
|
|
@@ -2689,9 +2026,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2689
2026
|
this.cursor = this.value.length;
|
|
2690
2027
|
}
|
|
2691
2028
|
}
|
|
2692
|
-
/** Move the caret one wrapped row up or down inside the draft; false on the first/last row. */
|
|
2693
2029
|
moveRow(direction) {
|
|
2694
|
-
// Lay out the draft as it is drawn: a token is one element but spans its whole label.
|
|
2695
2030
|
const columns = Math.max(1, this.chatColumns() - 4);
|
|
2696
2031
|
const layout = editor(this.visibleDraft(columns), columns);
|
|
2697
2032
|
const current = layout.positions[this.cursor];
|
|
@@ -2703,7 +2038,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2703
2038
|
this.cursor = candidates[0]?.index ?? this.cursor;
|
|
2704
2039
|
return true;
|
|
2705
2040
|
}
|
|
2706
|
-
/** The composer's selected grapheme range, or undefined when nothing is selected. */
|
|
2707
2041
|
selectionRange() {
|
|
2708
2042
|
const anchor = this.selectionAnchor;
|
|
2709
2043
|
if (anchor === undefined || this.selectionValue !== this.value || anchor === this.cursor || anchor > this.value.length)
|
|
@@ -2717,13 +2051,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2717
2051
|
this.completion = undefined;
|
|
2718
2052
|
this.dismissedCompletion = undefined;
|
|
2719
2053
|
}
|
|
2720
|
-
/**
|
|
2721
|
-
* Selection keys for the prompt and steering editors. Shift with an arrow, Home or End
|
|
2722
|
-
* extends the selection from where it started (Shift+Up/Down past the first or last row runs
|
|
2723
|
-
* to that end of the draft, never into history). Over a selection a plain Left/Right
|
|
2724
|
-
* collapses it to that edge and Backspace/Delete remove it; typed or pasted text replaces it
|
|
2725
|
-
* in `insert`. Any other key drops it. True when the key was consumed.
|
|
2726
|
-
*/
|
|
2727
2054
|
selectionKey(key, text) {
|
|
2728
2055
|
if (key.shift && !key.ctrl && !key.meta && ['left', 'right', 'home', 'end', 'up', 'down'].includes(key.name ?? '')) {
|
|
2729
2056
|
if (this.selectionAnchor === undefined || this.selectionValue !== this.value) {
|
|
@@ -2768,18 +2095,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2768
2095
|
this.selectionAnchor = undefined;
|
|
2769
2096
|
return false;
|
|
2770
2097
|
}
|
|
2771
|
-
/**
|
|
2772
|
-
* Copy the composer selection to the clipboard; a cut also removes it from the draft.
|
|
2773
|
-
*
|
|
2774
|
-
* The system writer is preferred; without one, or when it fails, an OSC 52 sequence asks
|
|
2775
|
-
* the terminal to set the clipboard instead.
|
|
2776
|
-
*/
|
|
2777
|
-
/**
|
|
2778
|
-
* Put text on the clipboard of whoever is looking at this terminal.
|
|
2779
|
-
*
|
|
2780
|
-
* `terminalOnly` skips the system writer for an OSC 52 sequence alone: over SSH the system
|
|
2781
|
-
* clipboard belongs to the remote host, while the terminal's is the one on the user's own machine.
|
|
2782
|
-
*/
|
|
2783
2098
|
copyText(text, options = {}) {
|
|
2784
2099
|
const osc52 = () => { if (this.started && !this.closed)
|
|
2785
2100
|
this.output.write(`\x1b]52;c;${Buffer.from(text, 'utf8').toString('base64')}\x07`); };
|
|
@@ -2792,7 +2107,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2792
2107
|
const range = this.selectionRange();
|
|
2793
2108
|
if (!range)
|
|
2794
2109
|
return;
|
|
2795
|
-
// A token copies as what it stands for: the pasted text itself, a file's path, an image's name.
|
|
2796
2110
|
const tokens = new Map(this.attachments.map(({ marker, pending }) => [marker, pending.kind === 'text' ? pending.content : pending.kind === 'file' ? pending.path : `[${pending.name}]`]));
|
|
2797
2111
|
if (this.skillChip)
|
|
2798
2112
|
tokens.set(SKILL_TOKEN, this.skillChip);
|
|
@@ -2815,30 +2129,13 @@ export class TerminalUI extends EventEmitter {
|
|
|
2815
2129
|
this.awaitArgument(selected);
|
|
2816
2130
|
return;
|
|
2817
2131
|
} this.value = graphemes(selected); this.cursor = this.value.length; const options = completionOptions(selected, this.skillCommands.map(skill => skill.command)); this.completion = { query: selected, options, index: options.indexOf(selected) }; }
|
|
2818
|
-
/** Put `command ` in the composer and open its argument list, without submitting anything. */
|
|
2819
2132
|
awaitArgument(command) { this.value = graphemes(`${command} `); this.cursor = this.value.length; this.completion = undefined; this.dismissedCompletion = undefined; }
|
|
2820
|
-
/**
|
|
2821
|
-
* The command Enter must not run yet: the draft is only the name of a command that needs an
|
|
2822
|
-
* argument, so it is completed to `command ` and the argument list opens. Applies wherever the
|
|
2823
|
-
* popup does — the conversation prompt and the live-run composer — and never to a question,
|
|
2824
|
-
* a secret, or a modal.
|
|
2825
|
-
*/
|
|
2826
2133
|
argumentPending() {
|
|
2827
2134
|
if (this.pending?.secret || (!this.pending?.conversationPrompt && !this.runInputHandler) || this.modal)
|
|
2828
2135
|
return undefined;
|
|
2829
2136
|
const draft = this.value.join('').trim();
|
|
2830
2137
|
return argumentRequired.has(draft) ? draft : undefined;
|
|
2831
2138
|
}
|
|
2832
|
-
/**
|
|
2833
|
-
* The popup entry Enter should run, or undefined when there is nothing runnable.
|
|
2834
|
-
*
|
|
2835
|
-
* Re-derived from the composer text on every call rather than read from the cached
|
|
2836
|
-
* completion: that cache is shared with the renderer, and a resize or an edit outside the
|
|
2837
|
-
* popup's own key handling can leave it stale, which would let Enter run a row that is no
|
|
2838
|
-
* longer highlighted or no longer drawn. `commandMatches(true)` applies the same visibility
|
|
2839
|
-
* gate the renderer uses, so a candidate that is off-screen on a short terminal reports
|
|
2840
|
-
* nothing, and an entry identical to the draft is not a completion at all.
|
|
2841
|
-
*/
|
|
2842
2139
|
selectedCompletion() {
|
|
2843
2140
|
const completion = this.commandMatches(true);
|
|
2844
2141
|
const selected = completion?.options[completion.index];
|
|
@@ -2861,24 +2158,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2861
2158
|
scheduleRender() { if (!this.started || this.closed || this.scheduled)
|
|
2862
2159
|
return; this.scheduled = true; queueMicrotask(() => { this.scheduled = false; if (!this.closed)
|
|
2863
2160
|
this.render(); }); }
|
|
2864
|
-
/**
|
|
2865
|
-
* Paint a frame, rewriting only the rows whose content actually changed.
|
|
2866
|
-
*
|
|
2867
|
-
* The app never takes the mouse (`start`), so the terminal keeps drag-to-select and the
|
|
2868
|
-
* clipboard in every state. What defeated those selections was output churn: a run repaints eight times a second for the working animation alone, and an
|
|
2869
|
-
* emulator abandons the cells under a drag as soon as the app rewrites them. Diffing
|
|
2870
|
-
* against what is already drawn means an unchanged screen writes nothing at all, and every
|
|
2871
|
-
* *contiguous run* of changed rows gets its own write: when two separated rows change (the
|
|
2872
|
-
* animated working row and the footer counters after a request completes, say) the
|
|
2873
|
-
* unchanged rows between them are left alone, so a selection over the transcript, the
|
|
2874
|
-
* composer or the model line survives a footer update. The composed picture is identical
|
|
2875
|
-
* either way - the row diff is a delivery detail, never a change in what is drawn.
|
|
2876
|
-
* @param lines - the frame's rows, top to bottom, exactly as they should read.
|
|
2877
|
-
* @param cursor - optional caret sequence; re-emitted after any painted row, because painting
|
|
2878
|
-
* hides the caret and only this sequence brings it back. A frame that paints nothing and
|
|
2879
|
-
* leaves the caret where it was still writes zero bytes, so the caret can ride along with
|
|
2880
|
-
* the frame without breaking the settled-frame contract.
|
|
2881
|
-
*/
|
|
2882
2161
|
writeFrame(composed, cursor = '') {
|
|
2883
2162
|
this.frame = composed;
|
|
2884
2163
|
const lines = this.withSelection(composed);
|
|
@@ -2888,14 +2167,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
2888
2167
|
const unchanged = (index) => (previous?.[index] ?? '') === (lines[index] ?? '');
|
|
2889
2168
|
let painted = false;
|
|
2890
2169
|
if (!previous) {
|
|
2891
|
-
// The first frame has nothing trustworthy to compare against, so it draws every row and
|
|
2892
|
-
// clears the rest of the screen, byte for byte what an undiffed frame writes.
|
|
2893
2170
|
this.output.write('\x1b[?25l\x1b[H' + lines.map(line => '\x1b[2K' + line).join('\r\n') + '\x1b[J');
|
|
2894
2171
|
painted = true;
|
|
2895
2172
|
}
|
|
2896
2173
|
else {
|
|
2897
|
-
// One write per contiguous run of changed rows, never one write spanning the unchanged
|
|
2898
|
-
// rows that separate two runs: rewriting those cells is what breaks a drag selection.
|
|
2899
2174
|
const spans = [];
|
|
2900
2175
|
for (let index = 0; index < rows; index++) {
|
|
2901
2176
|
if (unchanged(index))
|
|
@@ -2907,8 +2182,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
2907
2182
|
index = end;
|
|
2908
2183
|
}
|
|
2909
2184
|
if (spans.length) {
|
|
2910
|
-
// A frame shorter than the one on screen is the only way content can linger underneath,
|
|
2911
|
-
// so that is the one case that still needs an erase-below.
|
|
2912
2185
|
const tail = lines.length < previous.length ? `\x1b[${lines.length + 1};1H\x1b[J` : '';
|
|
2913
2186
|
this.output.write('\x1b[?25l' + spans.join('') + tail);
|
|
2914
2187
|
painted = true;
|
|
@@ -2924,24 +2197,21 @@ export class TerminalUI extends EventEmitter {
|
|
|
2924
2197
|
else
|
|
2925
2198
|
this.drawnCursor = '';
|
|
2926
2199
|
}
|
|
2927
|
-
/** A quiet startup identity, never a full-width alert-colored diagnostics panel. */
|
|
2928
2200
|
welcome(width, viewportHeight) {
|
|
2929
2201
|
const status = this.status;
|
|
2930
|
-
const available = Math.max(1, width - 4);
|
|
2202
|
+
const available = Math.max(1, width - 4);
|
|
2931
2203
|
const graph = status.graph;
|
|
2932
2204
|
const selected = status.graphSelection ?? (graph?.id === 'software-engineer' ? 'default' : graph?.id);
|
|
2933
2205
|
const graphName = selected === 'default' ? 'Default · Andorra Agent' : oneLine(graph?.name ?? 'Not selected');
|
|
2934
2206
|
const nodes = graph ? Object.keys(graph.nodes).length : 0;
|
|
2935
2207
|
const nodeCount = graph && selected !== 'default' ? ` · ${nodes} ${nodes === 1 ? 'node' : 'nodes'}` : '';
|
|
2936
2208
|
const activity = oneLine(status.activity || 'Ready');
|
|
2937
|
-
// Compact terminals and setup screens use a legible single-line label.
|
|
2938
2209
|
const showArt = this.appName === 'ANDORRA CODE'
|
|
2939
2210
|
&& viewportHeight >= 10
|
|
2940
2211
|
&& ANDORRA_WORDMARK.every(row => stringWidth(row) <= available);
|
|
2941
2212
|
const brand = showArt
|
|
2942
2213
|
? [...ANDORRA_WORDMARK, `CODE · v${this.version}`]
|
|
2943
2214
|
: [`${this.appName} · v${this.version}`];
|
|
2944
|
-
// A short terminal must not scroll the fallback label out of its own welcome.
|
|
2945
2215
|
if (viewportHeight < 9)
|
|
2946
2216
|
return [
|
|
2947
2217
|
clip(brand.at(-1), available),
|
|
@@ -2959,22 +2229,10 @@ export class TerminalUI extends EventEmitter {
|
|
|
2959
2229
|
'',
|
|
2960
2230
|
];
|
|
2961
2231
|
}
|
|
2962
|
-
/**
|
|
2963
|
-
* The selection screen to dock above the composer while a typed field is being answered.
|
|
2964
|
-
*
|
|
2965
|
-
* A plain question that follows a selection screen is a field belonging to that screen, so
|
|
2966
|
-
* the card is drawn where the home card would otherwise be. Run-time questions (approvals,
|
|
2967
|
-
* clarifications) keep their own surface, and the card is windowed around the highlighted
|
|
2968
|
-
* entry so a long list cannot eat the composer's rows on a short terminal.
|
|
2969
|
-
* @param rows - the transcript rows the render pass left for this card.
|
|
2970
|
-
* @returns the card's lines, or undefined when the home card belongs there instead.
|
|
2971
|
-
*/
|
|
2972
2232
|
selectionCard(rows) {
|
|
2973
2233
|
const selection = this.lastSelection;
|
|
2974
2234
|
if (!selection || !this.pending || this.pending.choices || this.pending.conversationPrompt)
|
|
2975
2235
|
return undefined;
|
|
2976
|
-
// A run's own questions (approval, clarification) are not fields of a selection screen,
|
|
2977
|
-
// so the docked card stays with the idle configuration flow it belongs to.
|
|
2978
2236
|
if (this.status.activity && this.status.activity !== 'Ready')
|
|
2979
2237
|
return undefined;
|
|
2980
2238
|
const width = Math.max(8, this.chatColumns() - 4);
|
|
@@ -3013,7 +2271,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
3013
2271
|
const selected = index === modal.selected;
|
|
3014
2272
|
if (selected)
|
|
3015
2273
|
selectedStart = content.length;
|
|
3016
|
-
content.push({ text: `${selected ? '›' : ' '} ${oneLine(item.label)}${item.id === modal.selectedId ? ' ✓' : ''}`, selected, bold: item.bold });
|
|
2274
|
+
content.push({ text: `${selected ? '›' : ' '} ${oneLine(item.label)}${item.id === (modal.checkedId ?? modal.selectedId) ? ' ✓' : ''}`, selected, bold: item.bold });
|
|
3017
2275
|
if (item.description)
|
|
3018
2276
|
for (const line of wrap(clean(item.description), Math.max(1, innerWidth - 2)))
|
|
3019
2277
|
content.push({ text: ` ${line}`, selected, dim: true });
|
|
@@ -3066,14 +2324,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
3066
2324
|
rows.push(paint(pad(yolo, labelWidth), this.status.yolo ? ATTENTION : GRAY) + paint(clip(this.activeModel().label, footerWidth - labelWidth)));
|
|
3067
2325
|
this.writeFrame(rows);
|
|
3068
2326
|
}
|
|
3069
|
-
/**
|
|
3070
|
-
* Wrap transcript text into drawn rows.
|
|
3071
|
-
* @param alignRight - pad each stored row that fits the transcript allowance onto its right margin,
|
|
3072
|
-
* which is what makes a user submission read as a speech bubble. The decision is made on the
|
|
3073
|
-
* stored row rather than on the fragments: wrapping a row that does not fit leaves short tails
|
|
3074
|
-
* (the last cells of a split border) that would otherwise be pushed into the margin, smearing
|
|
3075
|
-
* the frame across the screen, so no fragment of an over-wide row is padded.
|
|
3076
|
-
*/
|
|
3077
2327
|
wrapTranscript(text, width, alignRight = false) {
|
|
3078
2328
|
return text.split('\n').flatMap(line => {
|
|
3079
2329
|
const diff = /^\s*[+-]\s+\d+\s*\|/.test(line), box = /^[╭╰│]/.test(line);
|
|
@@ -3081,8 +2331,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
3081
2331
|
const color = isBrand ? WHITE : box ? GRAY : !diff && line.includes(this.appName) ? accentPaint() : transcriptColor(line);
|
|
3082
2332
|
const allowance = Math.max(1, width - 4);
|
|
3083
2333
|
const aligned = alignRight && stringWidth(line) <= allowance;
|
|
3084
|
-
// A wrapped list item or indented line continues under its own text, not at the margin:
|
|
3085
|
-
// a list whose second rows start in column one reads as loose paragraphs.
|
|
3086
2334
|
const lead = diff || box || isBrand || aligned ? undefined : /^\s*(?:(?:[•◦└]|\d{1,3}[.)])\s+)?/u.exec(line)?.[0];
|
|
3087
2335
|
const hang = lead ? stringWidth(lead) : 0;
|
|
3088
2336
|
const rows = lead && hang > 0 && hang <= allowance / 2 && stringWidth(line) > allowance
|
|
@@ -3093,15 +2341,15 @@ export class TerminalUI extends EventEmitter {
|
|
|
3093
2341
|
}
|
|
3094
2342
|
transcriptRows(entry, width) {
|
|
3095
2343
|
const disclosure = entry.promptDisclosure;
|
|
3096
|
-
// Ctrl+O expands the whole transcript, collapsed prompt boxes included: the app never
|
|
3097
|
-
// takes the mouse, so the keyboard is the way to the stored rows. An explicit per-prompt
|
|
3098
|
-
// toggle wins.
|
|
3099
2344
|
const promptExpanded = disclosure ? this.promptExpanded(disclosure.id) : false;
|
|
3100
2345
|
const text = disclosure
|
|
3101
2346
|
? promptExpanded && entry.detail ? entry.detail : entry.text
|
|
3102
2347
|
: this.expandedTranscript && entry.detail ? entry.detail : entry.text + (entry.detail ? ' (Ctrl+O to expand)' : '');
|
|
3103
2348
|
if (!entry.toolCall) {
|
|
3104
|
-
const
|
|
2349
|
+
const shown = entry.clipRows && text !== entry.detail
|
|
2350
|
+
? text.split('\n').map((row, index, rows) => index < rows.length - 1 ? clip(row, Math.max(1, width - 4)) : row).join('\n')
|
|
2351
|
+
: text;
|
|
2352
|
+
const rows = this.wrapTranscript(shown + '\n', width, entry.alignRight === true);
|
|
3105
2353
|
if (!disclosure)
|
|
3106
2354
|
return rows;
|
|
3107
2355
|
return rows.map(row => {
|
|
@@ -3125,16 +2373,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
3125
2373
|
if (!this.started || this.closed)
|
|
3126
2374
|
return;
|
|
3127
2375
|
this.todoPageSize = 0;
|
|
3128
|
-
const working = Boolean(this.status.activity && this.status.activity !== 'Ready' && this.status.activity !== 'Paused' && !this.status.backgroundActivity && !this.pending && !this.modal);
|
|
2376
|
+
const working = Boolean(this.status.activity && this.status.activity !== 'Ready' && this.status.activity !== 'Paused' && !this.status.backgroundActivity && !this.pending && !this.modal);
|
|
3129
2377
|
const compactFooter = working || this.runActive;
|
|
3130
2378
|
const footerRows = compactFooter ? 2 : 3;
|
|
3131
2379
|
const fixedRows = 4 + footerRows;
|
|
3132
2380
|
this.updateWorkingClock();
|
|
3133
2381
|
const columns = Math.max(1, this.output.columns || 80), height = Math.max(1, this.output.rows || 24);
|
|
3134
|
-
// The token speed needs no refresh of its own: its reading is captured when a request
|
|
3135
|
-
// finishes and held static between calls, so the frame already on screen stays correct
|
|
3136
|
-
// across a paused run or an approval prompt, and `noteGeneratedTokens` schedules the one
|
|
3137
|
-
// render that reveals a new reading. Only the animations need the ticker.
|
|
3138
2382
|
const ticking = working || (this.dashboard && this.dashboardMetrics.snapshot().running);
|
|
3139
2383
|
if (ticking && !this.workingTimer) {
|
|
3140
2384
|
this.workingTimer = setInterval(() => this.scheduleRender(), 120);
|
|
@@ -3144,11 +2388,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
3144
2388
|
clearInterval(this.workingTimer);
|
|
3145
2389
|
this.workingTimer = undefined;
|
|
3146
2390
|
}
|
|
3147
|
-
|
|
3148
|
-
// gets its own one-second clock rather than riding the animation timer's eight frames a second
|
|
3149
|
-
// for a string that is not changing. Only a visible panel arms it, and only while a displayed
|
|
3150
|
-
// session runs.
|
|
3151
|
-
const ages = this.panelColumns(columns, height) > 0 && (this.status.terminals?.some(session => session.running) ?? false);
|
|
2391
|
+
const ages = ((this.status.terminals?.some(session => session.running) ?? false) || this.subagents.running()) && (this.panelColumns(columns, height) > 0 || this.subagents.running());
|
|
3152
2392
|
if (ages && !this.panelTimer) {
|
|
3153
2393
|
this.panelTimer = setInterval(() => this.scheduleRender(), 1_000);
|
|
3154
2394
|
this.panelTimer.unref?.();
|
|
@@ -3158,23 +2398,12 @@ export class TerminalUI extends EventEmitter {
|
|
|
3158
2398
|
this.panelTimer = undefined;
|
|
3159
2399
|
}
|
|
3160
2400
|
if (this.modal) {
|
|
3161
|
-
// A modal screen takes the frame, so the panel is hidden for as long as it is open - and a
|
|
3162
|
-
// render that returns here never reaches the visibility bookkeeping below. Recording it here
|
|
3163
|
-
// is what lets the render after the modal closes announce the panel's return, so its data is
|
|
3164
|
-
// read again instead of showing what was true before the screen opened.
|
|
3165
2401
|
this.panelWasHidden = true;
|
|
3166
2402
|
this.expandedPromptVisible = false;
|
|
3167
2403
|
this.renderModal(columns, height);
|
|
3168
2404
|
return;
|
|
3169
2405
|
}
|
|
3170
|
-
// The panel is composed alongside the chat column rather than reflowing it: everything
|
|
3171
|
-
// below keeps its own arithmetic at the reduced chat width, and the frame carries both
|
|
3172
|
-
// columns once the rows are built (composePanel). One more column is the gutter that
|
|
3173
|
-
// keeps the chat column's own frame - the composer's border, the header's right edge -
|
|
3174
|
-
// from touching the divider.
|
|
3175
2406
|
const panelColumns = this.panelColumns(columns, height);
|
|
3176
|
-
// A resize or a closed screen can bring the panel back: tell the embedder so a summary it
|
|
3177
|
-
// skipped while nothing could show it is read now instead of at the next run boundary.
|
|
3178
2407
|
if (panelColumns > 0 && this.panelWasHidden) {
|
|
3179
2408
|
this.panelWasHidden = false;
|
|
3180
2409
|
this.emit('panel');
|
|
@@ -3201,21 +2430,18 @@ export class TerminalUI extends EventEmitter {
|
|
|
3201
2430
|
const firstInput = Math.max(0, Math.min((choices ? choiceIndex : cursor.row) - inputRows + 1, (choices?.length ?? layout.lines.length) - inputRows));
|
|
3202
2431
|
const completion = this.commandMatches();
|
|
3203
2432
|
const popupRows = completion ? commandPopupRows(width, height, inputRows, completion.options.length) : 0;
|
|
3204
|
-
const popupHeight = popupRows ? popupRows + 2 : 0;
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
const
|
|
2433
|
+
const popupHeight = popupRows ? popupRows + 2 : 0;
|
|
2434
|
+
const goalLines = this.goalLines(width - 2, height - inputRows - fixedRows - 3 - popupHeight);
|
|
2435
|
+
const todoLines = [...goalLines, ...(this.dashboard || panelColumns ? [] : this.todoLines(Math.max(0, height - inputRows - fixedRows - 3 - popupHeight - goalLines.length)))];
|
|
2436
|
+
const agentLines = this.dashboard || panelColumns ? [] : this.agentLines(width - 2, Math.max(0, height - inputRows - fixedRows - 3 - popupHeight - todoLines.length));
|
|
3208
2437
|
const elapsed = this.workingElapsed + (this.workingSince === undefined ? 0 : Date.now() - this.workingSince);
|
|
3209
2438
|
const seconds = Math.floor(elapsed / 1000);
|
|
3210
|
-
const thinkingLines = this.dashboard ? [] : this.thinkingLines(width, seconds, this.thinkingActive ? Math.max(1, Math.min(THINKING_ROWS + 1, height - inputRows - fixedRows - 1 - popupHeight - todoLines.length)) : 0);
|
|
3211
|
-
const transcriptHeight = height - inputRows - fixedRows - popupHeight - todoLines.length - thinkingLines.length;
|
|
2439
|
+
const thinkingLines = this.dashboard ? [] : this.thinkingLines(width, seconds, this.thinkingActive ? Math.max(1, Math.min(THINKING_ROWS + 1, height - inputRows - fixedRows - 1 - popupHeight - todoLines.length - agentLines.length)) : 0);
|
|
2440
|
+
const transcriptHeight = height - inputRows - fixedRows - popupHeight - todoLines.length - agentLines.length - thinkingLines.length;
|
|
3212
2441
|
const prefix = [...(this.selectionCard(transcriptHeight) ?? this.welcome(width, transcriptHeight)), ...(this.transcript.diagnostics.omitted ? ['Some transcript entries are unavailable because session storage failed.'] : [])].flatMap(text => this.wrapTranscript(text, width));
|
|
3213
2442
|
const page = this.transcript.window({ prefix, height: transcriptHeight, scroll: this.scroll,
|
|
3214
2443
|
key: `${width}:${this.expandedTranscript}`, render: entry => this.transcriptRows(entry, width),
|
|
3215
2444
|
revision: entry => entry.timing ? formatDuration(this.toolClock.elapsed(entry.timing)) ?? ''
|
|
3216
|
-
// The effective state, not just the explicit set: a box expanded by Ctrl+O and then
|
|
3217
|
-
// collapsed by hand must invalidate the cached row count, or the window would slice
|
|
3218
|
-
// against the taller expanded rendering and drop the box entirely.
|
|
3219
2445
|
: entry.promptDisclosure ? (this.promptExpanded(entry.promptDisclosure.id) ? 'expanded' : 'collapsed') : '' });
|
|
3220
2446
|
this.scroll = page.scroll;
|
|
3221
2447
|
const visible = this.dashboard ? dashboardRows({ metrics: this.dashboardMetrics.snapshot(), selectedModel: this.dashboardModel, provider: this.status.provider, model: this.status.model, graph: this.status.graph, providerModels: this.status.providerModels, activeNodes: [...this.activeNodes.keys()], nodeModels: this.nodeModels, todos: this.todos, todoOffset: this.todoOffset, onTodoOffset: offset => { this.todoOffset = offset; }, graphOffset: this.dashboardGraphOffset, notices: this.dashboardNotices, question: this.pending && !this.pending.conversationPrompt ? this.pending.dashboardQuestion ?? this.pending.choiceTitle ?? this.pending.title ?? this.pending.label : undefined }, Math.max(2, width - 4), transcriptHeight).map(line => ({ text: panelRowText(line), color: DIM, segments: line.segments })) : page.rows;
|
|
@@ -3237,7 +2463,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
3237
2463
|
const workingLabel = clip(workingText, Math.max(0, width - 6));
|
|
3238
2464
|
const wave = Math.floor(elapsed / 120) % 11;
|
|
3239
2465
|
const topBorder = working && workingLabel ? paint('╭ ', GRAY) + [...workingLabel].map((character, index) => paint(character, index < 7 && Math.abs(index - wave) <= 1 ? 255 : GRAY)).join('') + paint(' ' + '─'.repeat(Math.max(0, width - 4 - stringWidth(workingLabel))) + '╮', GRAY) : paint('╭' + borderLabel + '─'.repeat(Math.max(0, width - 2 - stringWidth(borderLabel))) + '╮', GRAY);
|
|
3240
|
-
const lines = [header, paint(clip(` ${status.account ? `Account: ${oneLine(status.account.label)} | ` : ''}${oneLine(this.workspace)}`, width), FAINT), ...visible.map(line => line.segments ? ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join('') : paint(' ' + clip(line.text, width - 2), line.color)), ...thinkingLines.map(line => paint(' ' + pad(line, width - 4), GRAY)), ...todoLines.map(line => paint(' ' + clip(line, width - 2), GRAY))];
|
|
2466
|
+
const lines = [header, paint(clip(` ${status.account ? `Account: ${oneLine(status.account.label)} | ` : ''}${oneLine(this.workspace)}`, width), FAINT), ...visible.map(line => line.segments ? ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join('') : paint(' ' + clip(line.text, width - 2), line.color)), ...thinkingLines.map(line => paint(' ' + pad(line, width - 4), GRAY)), ...agentLines, ...todoLines.map(line => paint(' ' + clip(line, width - 2), GRAY))];
|
|
3241
2467
|
if (completion && popupRows) {
|
|
3242
2468
|
const cardWidth = width - 4;
|
|
3243
2469
|
const popupTitle = clip(' Commands · ↑↓ move · Enter runs · Tab completes ', cardWidth - 2);
|
|
@@ -3283,14 +2509,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
3283
2509
|
const activeWindow = active.contextWindow;
|
|
3284
2510
|
const context = activeWindow && Number.isFinite(activeWindow) && activeWindow > 0 ? ` · context: ${Math.floor((count(status.contextUsed) / activeWindow) * 100)}% (${compactTokens.format(count(status.contextUsed))}/${compactTokens.format(activeWindow)})` : '';
|
|
3285
2511
|
const rate = this.displayRate();
|
|
3286
|
-
// The reading is the cumulative average decoding speed of the node currently shown:
|
|
3287
|
-
// totals only grow, so it holds unchanged between calls, across a pause, and after the
|
|
3288
|
-
// run ends - and it is drawn only while the model row names the model the average was
|
|
3289
|
-
// measured under. A session that has not finished one measured request reads 0 and the
|
|
3290
|
-
// row stays byte for byte the footer it was before this segment existed. The usage row
|
|
3291
|
-
// has one fixed allowance, and a permanent zero would spend it on a number that carries
|
|
3292
|
-
// no information - and it is what pushes the context percentage out of the row on an
|
|
3293
|
-
// 80-column terminal.
|
|
3294
2512
|
const measured = rate > 0 ? ` · ${compactTokens.format(rate)} tok/s` : '';
|
|
3295
2513
|
const counts = `${count(status.requests)} req · ${count(status.inputTokens)} in · ${count(status.outputTokens)} out`;
|
|
3296
2514
|
const usage = `${counts}${measured}${context}`;
|
|
@@ -3298,12 +2516,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
3298
2516
|
const approval = compactFooter ? `${graph} · ${permission}` : `Permissions: ${permission}`;
|
|
3299
2517
|
const footerWidth = width - 1;
|
|
3300
2518
|
const branchLead = compactFooter ? `⎇ ${branch} · ` : '';
|
|
3301
|
-
// Under width pressure the optional tail is dropped first - the context segment, as
|
|
3302
|
-
// documented. But the cumulative counts are unbounded and can spend the whole allowance
|
|
3303
|
-
// before the speed segment even starts, clipping it mid-word (`1K to`). While a speed is
|
|
3304
|
-
// being shown, the counts switch to the compact whole-number form the context segment
|
|
3305
|
-
// already uses so the complete `N tok/s` segment keeps its room; without a speed the
|
|
3306
|
-
// row behaves exactly as it did before this segment existed.
|
|
3307
2519
|
const wholeTokens = Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 0 });
|
|
3308
2520
|
const compactCounts = `${wholeTokens.format(count(status.requests))} req · ${wholeTokens.format(count(status.inputTokens))} in · ${wholeTokens.format(count(status.outputTokens))} out`;
|
|
3309
2521
|
const usageCap = Math.floor(footerWidth * 0.6);
|
|
@@ -3321,8 +2533,6 @@ export class TerminalUI extends EventEmitter {
|
|
|
3321
2533
|
}
|
|
3322
2534
|
else
|
|
3323
2535
|
usageWidth = Math.min(stringWidth(usage), usageCap);
|
|
3324
|
-
// On the compact row the graph name outranks the usage readout: it lost its own row, and the
|
|
3325
|
-
// counts are also in the side panel and the dashboard.
|
|
3326
2536
|
if (compactFooter) {
|
|
3327
2537
|
usageWidth = Math.max(0, Math.min(usageWidth, footerWidth - stringWidth(`${graph} · `)));
|
|
3328
2538
|
if (stringWidth(usageText) > usageWidth && branchLead && usageText.startsWith(branchLead))
|
|
@@ -3333,13 +2543,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
3333
2543
|
const restWidth = approvalWidth - stringWidth(leadText);
|
|
3334
2544
|
const usagePart = branchLead && usageText.startsWith(branchLead) ? paint(branchLead, GRAY) + paint(usageText.slice(branchLead.length), WHITE) : paint(clip(usageText, usageWidth), WHITE);
|
|
3335
2545
|
lines.push((leadText ? paint(leadText, GRAY) : '') + paint(clip(pad(compactFooter ? permission : approval, restWidth), restWidth), status.yolo ? ATTENTION : GRAY) + usagePart);
|
|
3336
|
-
|
|
3337
|
-
// would put an absolute cursor move and a show-cursor sequence on the wire every 120 ms
|
|
3338
|
-
// for the whole of an interactive run (cli.ts keeps steering on), and terminals that clear
|
|
3339
|
-
// or move a selection on cursor traffic would lose a drag over an otherwise untouched
|
|
3340
|
-
// frame. As a frame input it is suppressed whenever nothing was painted and the caret has
|
|
3341
|
-
// not moved, and re-emitted whenever a row repaint hid it.
|
|
3342
|
-
const caret = (this.pending || this.steering) && !choices ? `\x1b[${transcriptHeight + todoLines.length + popupHeight + thinkingLines.length + 4 + cursor.row - firstInput};${3 + cursor.column}H\x1b[?25h` : '';
|
|
2546
|
+
const caret = (this.pending || this.steering) && !choices ? `\x1b[${transcriptHeight + todoLines.length + agentLines.length + popupHeight + thinkingLines.length + 4 + cursor.row - firstInput};${3 + cursor.column}H\x1b[?25h` : '';
|
|
3343
2547
|
this.writeFrame(this.composePanel(lines, this.panelRows(panelColumns, height), panelColumns, width), caret);
|
|
3344
2548
|
}
|
|
3345
2549
|
}
|