@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/side-panel.js
CHANGED
|
@@ -2,52 +2,14 @@ import stringWidth from 'string-width';
|
|
|
2
2
|
import { stripVTControlCharacters } from 'node:util';
|
|
3
3
|
import { ATTENTION, FAINT, GRAY, STATUS, SUBTLE, WHITE, accentSgr } from './palette.js';
|
|
4
4
|
import { formatHms } from './duration.js';
|
|
5
|
-
|
|
5
|
+
import { subagentChangeWord, subagentRunning, subagentStatusWord } from './subagent-tree.js';
|
|
6
6
|
export const panelRowText = (row) => row.segments.map(segment => segment.text).join('');
|
|
7
|
-
/**
|
|
8
|
-
* Visible columns the terminal needs before the panel is worth drawing.
|
|
9
|
-
*
|
|
10
|
-
* The panel claims roughly a third of the width, so below this the chat column would drop
|
|
11
|
-
* under about 77 columns: narrow enough that the transcript's own wrapping and the command
|
|
12
|
-
* popup degrade, which is a worse trade than losing the panel.
|
|
13
|
-
*/
|
|
14
7
|
export const PANEL_MIN_COLUMNS = 110;
|
|
15
|
-
/**
|
|
16
|
-
* Rows the panel needs before it is drawn.
|
|
17
|
-
*
|
|
18
|
-
* The floor is the tallest fixed stack the panel can reach - the Git section's four rows,
|
|
19
|
-
* the Node section's four, and the progress summary's three, plus the rules between them -
|
|
20
|
-
* so a terminal that shows the panel always has room for every section that cannot shrink.
|
|
21
|
-
*/
|
|
22
8
|
export const PANEL_MIN_ROWS = 14;
|
|
23
|
-
/**
|
|
24
|
-
* Total columns the panel occupies at a given terminal width, divider included.
|
|
25
|
-
*
|
|
26
|
-
* A fixed share keeps the panel's measurements stable as the terminal grows while the clamps
|
|
27
|
-
* stop it from becoming a second chat column on very wide terminals or a sliver on the
|
|
28
|
-
* narrowest ones that still show it.
|
|
29
|
-
*/
|
|
30
9
|
export const panelWidth = (columns) => Math.min(44, Math.max(28, Math.floor(columns * 0.3)));
|
|
31
|
-
/**
|
|
32
|
-
* Whether the selected graph is a custom one.
|
|
33
|
-
*
|
|
34
|
-
* The built-in Andorra Agent harness is stored under `'default'` (and answers to its own
|
|
35
|
-
* id when a graph file was never written), so both spell the default; anything else is a
|
|
36
|
-
* user-authored graph, which is what the zoom section exists for.
|
|
37
|
-
*/
|
|
38
10
|
export const isCustomGraph = (selection, graph) => (selection ?? (graph?.id === 'software-engineer' ? 'default' : graph?.id)) !== 'default';
|
|
39
11
|
const compact = Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 });
|
|
40
12
|
const count = (value) => compact.format(Math.max(0, Math.round(value)));
|
|
41
|
-
/**
|
|
42
|
-
* Flatten one value to a single paintable line.
|
|
43
|
-
*
|
|
44
|
-
* Panel values come from outside the render pass: a `qa.terminal` command, a graph node name,
|
|
45
|
-
* a plan item, a branch. A newline or an escape sequence in any of them would otherwise be
|
|
46
|
-
* written into the full-screen frame as itself - breaking the row arithmetic at best, driving
|
|
47
|
-
* the terminal at worst - so every value is stripped of control characters and flattened
|
|
48
|
-
* before it is measured, clipped or painted. Spacing is preserved: the panel's own alignment
|
|
49
|
-
* is made of it.
|
|
50
|
-
*/
|
|
51
13
|
const flat = (text) => stripVTControlCharacters(String(text))
|
|
52
14
|
.replace(/[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, ' ');
|
|
53
15
|
function clip(text, width) {
|
|
@@ -69,14 +31,6 @@ function clip(text, width) {
|
|
|
69
31
|
const row = (...segments) => ({
|
|
70
32
|
segments: segments.map(segment => typeof segment === 'string' ? { text: flat(segment) } : { text: flat(segment.text), ...(segment.color === undefined ? {} : { color: segment.color }) }),
|
|
71
33
|
});
|
|
72
|
-
/**
|
|
73
|
-
* A row with a label on the left and a value or values right-aligned against the panel edge.
|
|
74
|
-
*
|
|
75
|
-
* The value keeps its own segments, so a row can pair a green `+120` with a red `-8`. When
|
|
76
|
-
* the two cannot both fit, the row degrades to one clipped line rather than letting the value
|
|
77
|
-
* run under the panel's edge: the panel is a fixed width, so a row that cannot fit is a row
|
|
78
|
-
* that must lose something.
|
|
79
|
-
*/
|
|
80
34
|
function pair(label, values, width) {
|
|
81
35
|
const valueWidth = values.reduce((total, segment) => total + stringWidth(flat(segment.text)), 0);
|
|
82
36
|
const gap = width - stringWidth(flat(label.text)) - valueWidth;
|
|
@@ -84,9 +38,7 @@ function pair(label, values, width) {
|
|
|
84
38
|
return row({ text: clip([label.text, ...values.map(value => value.text)].join(' '), width), color: label.color });
|
|
85
39
|
return values.length ? row(label, { text: ' '.repeat(gap) }, ...values) : row(label);
|
|
86
40
|
}
|
|
87
|
-
/** A section heading with an optional right-aligned value, e.g. `Plan 6/14`. */
|
|
88
41
|
const heading = (title, width, right = []) => pair({ text: title, color: SUBTLE }, right, width);
|
|
89
|
-
/** The faint rule that separates one section from the one above it. */
|
|
90
42
|
const rule = (width) => row({ text: '─'.repeat(Math.max(1, width)), color: FAINT });
|
|
91
43
|
const plural = (value, word) => `${value} ${word}${value === 1 ? '' : 's'}`;
|
|
92
44
|
function gitSection(data, width) {
|
|
@@ -97,8 +49,6 @@ function gitSection(data, width) {
|
|
|
97
49
|
body.push(row({ text: 'Reading working tree…', color: FAINT }));
|
|
98
50
|
else if (!changes.isGit)
|
|
99
51
|
body.push(row({ text: 'Not a Git repository', color: FAINT }));
|
|
100
|
-
// A withheld reading comes first: its counts are zero because nothing was measured, and the
|
|
101
|
-
// clean-tree branch below would turn that into the one thing it is not.
|
|
102
52
|
else if (changes.skipped || changes.unavailable)
|
|
103
53
|
body.push(pair(label, [{ text: 'no counts', color: FAINT }], width));
|
|
104
54
|
else if (!changes.files && !changes.untracked && !changes.insertions && !changes.deletions)
|
|
@@ -110,8 +60,6 @@ function gitSection(data, width) {
|
|
|
110
60
|
{ text: `-${count(changes.deletions)}`, color: changes.deletions ? STATUS.error : GRAY },
|
|
111
61
|
], width));
|
|
112
62
|
if (changes?.isGit) {
|
|
113
|
-
// The summary's own read names the branch, so the row and the counts always describe the
|
|
114
|
-
// same repository; a read that could not name one falls back to the session's reader.
|
|
115
63
|
const branch = changes.branch ?? data.branch;
|
|
116
64
|
body.push(row({ text: '⎇ ', color: SUBTLE }, { text: clip(branch ?? 'detached', width - 2), color: GRAY }));
|
|
117
65
|
if (changes.skipped)
|
|
@@ -138,9 +86,6 @@ function nodeSection(data, width) {
|
|
|
138
86
|
body.push(row({ text: clip(` ${focus.detail}`, width), color: GRAY }));
|
|
139
87
|
if (focus.model)
|
|
140
88
|
body.push(row({ text: clip(` ${focus.model}`, width), color: FAINT }));
|
|
141
|
-
// A parallel run can have several nodes working at once, but the section keeps a fixed
|
|
142
|
-
// height so the packing above it can promise the panel never outgrows the terminal: the
|
|
143
|
-
// follower nodes are worth one line together, not one line each.
|
|
144
89
|
if (rest.length)
|
|
145
90
|
body.push(row({ text: clip(` +${rest.length} more running: ${rest.map(node => node.name).join(', ')}`, width), color: FAINT }));
|
|
146
91
|
return [heading('Step', width), ...body];
|
|
@@ -153,32 +98,15 @@ function progressSection(data, width) {
|
|
|
153
98
|
const active = data.todos.filter(todo => todo.status === 'in_progress').length;
|
|
154
99
|
const waiting = total - done - active;
|
|
155
100
|
const share = done / total;
|
|
156
|
-
// The bar is sized from the row it shares with the percentage, so the pair always fits one
|
|
157
|
-
// row; a single filled cell still shows at least one percent of movement.
|
|
158
101
|
const label = `${Math.round(share * 100)}%`;
|
|
159
102
|
const barWidth = Math.max(3, width - stringWidth(label) - 1);
|
|
160
|
-
// A nonzero share fills at least one cell: `floor` rounds a small plan's first step (1 of 100) to
|
|
161
|
-
// nothing, which drew an empty bar beside a percentage that says otherwise.
|
|
162
103
|
const filled = share >= 1 ? barWidth : share > 0 ? Math.max(1, Math.min(barWidth, Math.floor(share * barWidth))) : 0;
|
|
163
104
|
return [
|
|
164
105
|
heading('Progress', width),
|
|
165
|
-
// Progress is neutral, as the window draws it: the accent fill on a faint track. Green is a
|
|
166
|
-
// passed check, and a plan two-thirds done has passed nothing yet.
|
|
167
106
|
row({ text: '█'.repeat(filled), color: accentSgr() }, { text: '░'.repeat(barWidth - filled), color: FAINT }, { text: ' ' }, { text: label, color: GRAY }),
|
|
168
107
|
row({ text: clip(`${done} done · ${active} active · ${waiting} waiting`, width), color: GRAY }),
|
|
169
108
|
];
|
|
170
109
|
}
|
|
171
|
-
/**
|
|
172
|
-
* The current plan: its completed count, the items in progress, what comes next, and a count
|
|
173
|
-
* of whatever did not fit.
|
|
174
|
-
*
|
|
175
|
-
* The list is the elastic section - it absorbs whatever the fixed sections leave - so the
|
|
176
|
-
* rows are ordered by importance rather than by position in the plan: the item being worked
|
|
177
|
-
* on is what the reader checks, while the completed and waiting lines are context. Items fill
|
|
178
|
-
* every row the budget allows; only a plan longer than that is cut, and the cut is named on
|
|
179
|
-
* its own line. `rows` is the whole section's budget, heading included; below two rows
|
|
180
|
-
* nothing is worth drawing.
|
|
181
|
-
*/
|
|
182
110
|
function planSection(data, width, rows) {
|
|
183
111
|
if (rows < 2 || !data.todos.length)
|
|
184
112
|
return [];
|
|
@@ -188,13 +116,8 @@ function planSection(data, width, rows) {
|
|
|
188
116
|
const pending = data.todos.filter(todo => todo.status === 'pending');
|
|
189
117
|
const budget = rows - 1;
|
|
190
118
|
const doneRow = done ? 1 : 0;
|
|
191
|
-
// A plan that fits is listed whole. One that does not gives a row to the line naming the cut,
|
|
192
|
-
// unless that row is the only one there is: a single item says more than a count does.
|
|
193
119
|
const fits = active.length + doneRow + pending.length <= budget;
|
|
194
120
|
const room = fits ? budget : Math.max(1, budget - 1);
|
|
195
|
-
// The completed count shares the items' room, so it is taken out before any item is placed:
|
|
196
|
-
// appended afterwards it would land on the row the cut line needs. A cut list keeps it only
|
|
197
|
-
// beside at least one item - the heading already carries the same count.
|
|
198
121
|
const doneShown = fits || room >= 2 ? doneRow : 0;
|
|
199
122
|
const shownActive = active.slice(0, Math.max(0, room - doneShown));
|
|
200
123
|
for (const todo of shownActive)
|
|
@@ -204,37 +127,25 @@ function planSection(data, width, rows) {
|
|
|
204
127
|
const shownPending = pending.slice(0, Math.max(0, room - shownActive.length - doneShown));
|
|
205
128
|
for (const todo of shownPending)
|
|
206
129
|
body.push(row({ text: '○ ', color: SUBTLE }, { text: clip(todo.text, width - 2), color: GRAY }));
|
|
207
|
-
// Every item the budget left out is named, active ones included: the Progress row above counts all of
|
|
208
|
-
// them, so a list that showed two of three active items and said only "1 waiting" would hide the
|
|
209
|
-
// third entirely.
|
|
210
130
|
const omitted = [
|
|
211
131
|
active.length > shownActive.length ? `${active.length - shownActive.length} more active` : '',
|
|
212
132
|
pending.length > shownPending.length ? `${pending.length - shownPending.length} waiting` : '',
|
|
213
133
|
].filter(Boolean);
|
|
214
|
-
// Clipped like every other row: the line can now name two omissions, and a narrow panel must not
|
|
215
|
-
// overflow on it.
|
|
216
134
|
if (omitted.length)
|
|
217
135
|
body.push(row({ text: clip(`… ${omitted.join(' · ')}`, width), color: FAINT }));
|
|
218
136
|
if (!body.length)
|
|
219
137
|
body.push(row({ text: `${done}/${data.todos.length} done`, color: GRAY }));
|
|
220
138
|
return [heading('Plan', width, [{ text: `${done}/${data.todos.length}`, color: GRAY }]), ...body.slice(0, budget)];
|
|
221
139
|
}
|
|
222
|
-
/** `12s`, `5m 20s`, `1h 4m 9s` - the age a background terminal has been running. */
|
|
223
140
|
export function panelDuration(milliseconds) {
|
|
224
141
|
return formatHms(milliseconds / 1000);
|
|
225
142
|
}
|
|
226
143
|
function terminalSection(data, width) {
|
|
227
144
|
if (!data.terminals.length)
|
|
228
145
|
return [];
|
|
229
|
-
// Running sessions come first: the manager keeps a naturally exited session until it is
|
|
230
|
-
// stopped explicitly, so insertion order would let three finished sessions hide the one
|
|
231
|
-
// process that is still alive - the row a reader actually needs - behind `+N more`.
|
|
232
146
|
const ordered = [...data.terminals].sort((left, right) => Number(right.running) - Number(left.running));
|
|
233
147
|
const body = ordered.slice(0, 3).map(session => {
|
|
234
148
|
const age = session.running && session.startedAt !== undefined ? ` · ${panelDuration(data.now - session.startedAt)}` : '';
|
|
235
|
-
// The age is what the row exists for, so it is reserved before the command is clipped: a
|
|
236
|
-
// long test-runner invocation must lose its own tail, not the elapsed time a reader is
|
|
237
|
-
// watching while the row keeps repainting for it.
|
|
238
149
|
const life = clip(`${session.id} · ${session.command}`, Math.max(1, width - 2 - stringWidth(age)));
|
|
239
150
|
return row({ text: session.running ? '● ' : '○ ', color: session.running ? accentSgr() : FAINT }, { text: life, color: session.running ? GRAY : FAINT }, { text: age, color: session.running ? GRAY : FAINT });
|
|
240
151
|
});
|
|
@@ -242,15 +153,69 @@ function terminalSection(data, width) {
|
|
|
242
153
|
body.push(row({ text: ` +${ordered.length - body.length} more`, color: FAINT }));
|
|
243
154
|
return [heading('Terminals', width), ...body];
|
|
244
155
|
}
|
|
156
|
+
function agentMark(entry) {
|
|
157
|
+
if (subagentRunning(entry))
|
|
158
|
+
return { text: '● ', color: accentSgr() };
|
|
159
|
+
if (entry.status === 'succeeded')
|
|
160
|
+
return { text: '✓ ', color: SUBTLE };
|
|
161
|
+
if (entry.status === 'stopped' || entry.status === 'cancelled')
|
|
162
|
+
return { text: '■ ', color: FAINT };
|
|
163
|
+
return { text: '✗ ', color: STATUS.error };
|
|
164
|
+
}
|
|
165
|
+
export const AGENT_SECTION_MAX_ROWS = 10;
|
|
166
|
+
export const agentTreeNaturalRows = (groups) => groups?.length ? 1 + groups.length + groups.reduce((sum, group) => sum + group.agents.length, 0) : 0;
|
|
167
|
+
export function subagentTreeRows(groups, width, rows, now) {
|
|
168
|
+
const all = groups.flatMap(group => group.agents);
|
|
169
|
+
if (!all.length || rows < 2)
|
|
170
|
+
return [];
|
|
171
|
+
const settled = all.filter(entry => !subagentRunning(entry)).length;
|
|
172
|
+
const head = heading('Agents', width, [{ text: `${settled}/${all.length}`, color: GRAY }]);
|
|
173
|
+
const hidden = new Set();
|
|
174
|
+
const visibleGroups = () => groups.filter(group => group.agents.some(entry => !hidden.has(entry)));
|
|
175
|
+
const natural = () => 1 + visibleGroups().length + all.length - hidden.size;
|
|
176
|
+
if (natural() > rows) {
|
|
177
|
+
const budget = rows - 1;
|
|
178
|
+
const finished = all.filter(entry => !subagentRunning(entry));
|
|
179
|
+
const working = all.filter(subagentRunning).reverse();
|
|
180
|
+
for (const entry of [...finished, ...working]) {
|
|
181
|
+
if (natural() <= budget)
|
|
182
|
+
break;
|
|
183
|
+
hidden.add(entry);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const body = [];
|
|
187
|
+
for (const group of visibleGroups()) {
|
|
188
|
+
const shown = group.agents.filter(entry => !hidden.has(entry));
|
|
189
|
+
const working = group.agents.some(subagentRunning);
|
|
190
|
+
body.push(row({ text: working ? '● ' : '✓ ', color: working ? accentSgr() : SUBTLE }, { text: clip(group.name, width - 2), color: working ? WHITE : GRAY }));
|
|
191
|
+
shown.forEach((entry, index) => {
|
|
192
|
+
const connector = `${index === shown.length - 1 ? '└─' : '├─'}${' '.repeat(Math.max(0, entry.depth - 1))}`;
|
|
193
|
+
const mark = agentMark(entry);
|
|
194
|
+
const elapsed = formatHms(((subagentRunning(entry) ? now : entry.endedAt ?? now) - entry.startedAt) / 1000);
|
|
195
|
+
const word = subagentStatusWord(entry);
|
|
196
|
+
const change = subagentChangeWord(entry.change);
|
|
197
|
+
const lead = stringWidth(connector) + stringWidth(mark.text);
|
|
198
|
+
const tails = [
|
|
199
|
+
[elapsed, word, change].filter(Boolean).join(' '),
|
|
200
|
+
[elapsed, change].filter(Boolean).join(' '),
|
|
201
|
+
elapsed,
|
|
202
|
+
'',
|
|
203
|
+
];
|
|
204
|
+
const nameFloor = Math.min(6, stringWidth(entry.label));
|
|
205
|
+
const tail = tails.find(text => !text || lead + nameFloor + 1 + stringWidth(text) <= width) ?? '';
|
|
206
|
+
const nameRoom = Math.max(1, width - lead - (tail ? stringWidth(tail) + 1 : 0));
|
|
207
|
+
const name = clip(entry.label, nameRoom);
|
|
208
|
+
const gap = Math.max(tail ? 1 : 0, width - lead - stringWidth(name) - stringWidth(tail));
|
|
209
|
+
body.push(row({ text: connector, color: FAINT }, mark, { text: name, color: subagentRunning(entry) ? WHITE : GRAY }, ...(tail ? [{ text: ' '.repeat(gap) }, { text: tail, color: subagentRunning(entry) ? GRAY : FAINT }] : [])));
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (hidden.size) {
|
|
213
|
+
const running = [...hidden].filter(subagentRunning).length;
|
|
214
|
+
body.push(row({ text: clip(`… +${hidden.size} more${running ? ` · ${running} running` : ''}`, width), color: FAINT }));
|
|
215
|
+
}
|
|
216
|
+
return [head, ...body].slice(0, rows);
|
|
217
|
+
}
|
|
245
218
|
const MARK = (visited, active, id) => active.has(id) ? { glyph: '●', color: accentSgr() } : visited.has(id) ? { glyph: '✓', color: SUBTLE } : { glyph: '○', color: FAINT };
|
|
246
|
-
/**
|
|
247
|
-
* The zoomed view of the graph section the run is in: what leads into the current node and
|
|
248
|
-
* what it hands off to, with every node marked as visited, current, or not yet reached.
|
|
249
|
-
*
|
|
250
|
-
* Only a custom graph gets this: the built-in harness is a single agent node, and a zoom of
|
|
251
|
-
* it would say nothing a `Step` row does not already say. Neighbours are capped so a hub node
|
|
252
|
-
* cannot push the panel's other sections off the screen.
|
|
253
|
-
*/
|
|
254
219
|
function graphSection(data, width) {
|
|
255
220
|
const graph = data.graph;
|
|
256
221
|
if (!data.customGraph || !graph)
|
|
@@ -260,39 +225,24 @@ function graphSection(data, width) {
|
|
|
260
225
|
const focusOf = (id) => graph.nodes[id]?.name ?? id;
|
|
261
226
|
const focus = data.nodes[0]?.id ?? data.stoppedNode ?? [...data.visited].at(-1) ?? graph.entry;
|
|
262
227
|
const incoming = [...new Set(graph.edges.filter(edge => edge.target === focus && edge.source !== focus).map(edge => edge.source))];
|
|
263
|
-
// Self-targeting edges are hand-offs too: a bounded retry (a node with `maxNodeVisits` routing
|
|
264
|
-
// back to itself) is an outcome of this node, and dropping it would present the node as having
|
|
265
|
-
// no such route at all.
|
|
266
228
|
const outgoing = graph.edges.filter(edge => edge.source === focus);
|
|
267
229
|
const body = [];
|
|
268
|
-
// A join node can have more inputs than the cap shows; the hidden remainder is reported
|
|
269
|
-
// before the rows it was cut from, so a five-input join does not read as a two-input one.
|
|
270
230
|
if (incoming.length > 2)
|
|
271
231
|
body.push(row({ text: ` +${incoming.length - 2} more upstream`, color: FAINT }));
|
|
272
232
|
for (const id of incoming.slice(-2)) {
|
|
273
233
|
const mark = MARK(visited, active, id);
|
|
274
234
|
body.push(row({ text: '▲ ', color: FAINT }, { text: `${mark.glyph} `, color: mark.color }, { text: clip(focusOf(id), width - 4), color: GRAY }));
|
|
275
235
|
}
|
|
276
|
-
// The focus row is the marker the whole zoom is read against: `●` while a node is running,
|
|
277
|
-
// where a run ended (completed or stopped mid-node), and the same `○` an unreached node
|
|
278
|
-
// carries while the panel is idle and the focus is only the graph's entry - the row must not
|
|
279
|
-
// claim a position nothing has reached yet.
|
|
280
236
|
const stopped = data.stoppedNode === focus;
|
|
281
237
|
const focusGlyph = active.has(focus) || visited.has(focus) || stopped ? '●' : '○';
|
|
282
|
-
// A run that stopped on a node it had visited earlier is a stopped position, not a completed
|
|
283
|
-
// one: the bold stopped marker outranks the historical visit.
|
|
284
238
|
const focusColor = active.has(focus) ? accentSgr() : stopped ? ATTENTION : visited.has(focus) ? SUBTLE : FAINT;
|
|
285
239
|
body.push(row({ text: `${focusGlyph} `, color: focusColor }, { text: clip(focusOf(focus), width - 2), color: active.has(focus) ? WHITE : GRAY }));
|
|
286
|
-
// Distinct routes are distinct rows even when they lead to the same node: a QA node can hand off
|
|
287
|
-
// to one End through `pass` and through `fail`, and collapsing them by target would hide one.
|
|
288
240
|
const routes = [...new Map(outgoing.map(edge => [`${edge.target}\u0000${edge.outcome ?? ''}`, edge])).values()];
|
|
289
241
|
const unique = routes.slice(0, 3);
|
|
290
242
|
unique.forEach((edge, index) => {
|
|
291
243
|
const mark = MARK(visited, active, edge.target);
|
|
292
244
|
const loop = edge.target === focus;
|
|
293
245
|
const label = edge.outcome ? `${focusOf(edge.target)} · ${edge.outcome}` : focusOf(edge.target);
|
|
294
|
-
// A loop is drawn with its own arrow so a retry back to this node is not mistaken for a
|
|
295
|
-
// hand-off to a neighbour that happens to share its name.
|
|
296
246
|
body.push(row({ text: `${index === unique.length - 1 ? '└─' : '├─'}${loop ? '↻' : '▶'} `, color: FAINT }, { text: `${mark.glyph} `, color: mark.color }, { text: clip(label, width - 6), color: GRAY }));
|
|
297
247
|
});
|
|
298
248
|
const hidden = routes.length - unique.length;
|
|
@@ -300,18 +250,6 @@ function graphSection(data, width) {
|
|
|
300
250
|
body.push(row({ text: ` +${hidden} more`, color: FAINT }));
|
|
301
251
|
return [heading('Graph', width, [{ text: `${visited.size}/${Object.keys(graph.nodes).length}`, color: GRAY }]), ...body];
|
|
302
252
|
}
|
|
303
|
-
/**
|
|
304
|
-
* The panel's rows, top to bottom, for a terminal of `columns` x `height`.
|
|
305
|
-
*
|
|
306
|
-
* Sections are anchored: Git tools, Step, Progress and the plan read from the top, while the
|
|
307
|
-
* terminal list and the graph zoom are held against the bottom - the reader asked for the graph
|
|
308
|
-
* section to be at the bottom of the panel - with whatever rows the top sections leave as blank
|
|
309
|
-
* space between them, so a tall terminal does not park the zoom in the middle of the screen.
|
|
310
|
-
* The panel never outgrows the terminal: the plan list is elastic and takes only what the fixed
|
|
311
|
-
* sections leave, and when even those overflow, whole sections are given up from the bottom
|
|
312
|
-
* upward - the zoom first, then the terminal list - because the sections above them are read on
|
|
313
|
-
* every run while those two describe states that come and go.
|
|
314
|
-
*/
|
|
315
253
|
export function sidePanelRows(data, columns, height) {
|
|
316
254
|
const width = Math.max(8, Math.floor(columns));
|
|
317
255
|
if (height < PANEL_MIN_ROWS || width < 8)
|
|
@@ -321,14 +259,14 @@ export function sidePanelRows(data, columns, height) {
|
|
|
321
259
|
const progress = progressSection(data, width);
|
|
322
260
|
let terminals = terminalSection(data, width);
|
|
323
261
|
let graph = graphSection(data, width);
|
|
262
|
+
let agentBudget = Math.min(AGENT_SECTION_MAX_ROWS, agentTreeNaturalRows(data.agents));
|
|
263
|
+
let agents = data.agents?.length ? subagentTreeRows(data.agents, width, agentBudget, data.now) : [];
|
|
324
264
|
let plan = [];
|
|
325
|
-
// Total rows a set of sections occupies once the rules between them are counted.
|
|
326
265
|
const total = (sections) => sections.reduce((sum, rows) => sum + rows.length, 0)
|
|
327
266
|
+ Math.max(0, sections.length - 1);
|
|
328
|
-
// The plan's own rule and heading, before it can show a single item.
|
|
329
267
|
const PLAN_OVERHEAD = 2;
|
|
330
268
|
for (;;) {
|
|
331
|
-
const anchored = [git, node, progress, terminals, graph].filter(rows => rows.length);
|
|
269
|
+
const anchored = [git, node, progress, agents, terminals, graph].filter(rows => rows.length);
|
|
332
270
|
const room = height - total(anchored) - (data.todos.length ? PLAN_OVERHEAD : 0);
|
|
333
271
|
if (room >= 0) {
|
|
334
272
|
plan = data.todos.length && room >= 1 ? planSection(data, width, room + 1) : [];
|
|
@@ -342,12 +280,19 @@ export function sidePanelRows(data, columns, height) {
|
|
|
342
280
|
terminals = [];
|
|
343
281
|
continue;
|
|
344
282
|
}
|
|
345
|
-
|
|
346
|
-
|
|
283
|
+
if (agents.length > 2) {
|
|
284
|
+
agentBudget = Math.max(2, agents.length + room);
|
|
285
|
+
agents = subagentTreeRows(data.agents ?? [], width, agentBudget, data.now);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (agents.length) {
|
|
289
|
+
agents = [];
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
347
292
|
plan = [];
|
|
348
293
|
break;
|
|
349
294
|
}
|
|
350
|
-
const top = [git, node, progress, plan].filter(rows => rows.length);
|
|
295
|
+
const top = [git, node, progress, agents, plan].filter(rows => rows.length);
|
|
351
296
|
const bottom = [terminals, graph].filter(rows => rows.length);
|
|
352
297
|
const assemble = (groups) => groups.filter(rows => rows.length)
|
|
353
298
|
.flatMap((rows, index) => index === 0 ? rows : [rule(width), ...rows]);
|
|
@@ -355,8 +300,6 @@ export function sidePanelRows(data, columns, height) {
|
|
|
355
300
|
const bottomRows = bottom.length ? [rule(width), ...assemble(bottom)] : [];
|
|
356
301
|
if (!bottomRows.length)
|
|
357
302
|
return topRows;
|
|
358
|
-
// The rows nobody claimed sit between the two groups; without them the bottom sections would
|
|
359
|
-
// simply follow the plan, which is where they already were before they were anchored.
|
|
360
303
|
const gap = Array.from({ length: Math.max(0, height - topRows.length - bottomRows.length) }, () => ({ segments: [] }));
|
|
361
304
|
return [...topRows, ...gap, ...bottomRows];
|
|
362
305
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Config } from './config.js';
|
|
2
|
+
import type { ProviderConfig } from './providers.js';
|
|
3
|
+
export declare const DETECTABLE_SIGN_IN_TYPES: readonly ["claude", "codex", "grok", "opencode"];
|
|
4
|
+
export type DetectableSignInType = typeof DETECTABLE_SIGN_IN_TYPES[number];
|
|
5
|
+
export declare function isDetectableSignInType(value: unknown): value is DetectableSignInType;
|
|
6
|
+
export interface DetectedSignIn {
|
|
7
|
+
type: DetectableSignInType;
|
|
8
|
+
email?: string;
|
|
9
|
+
planType?: string;
|
|
10
|
+
detail?: string;
|
|
11
|
+
models: string[];
|
|
12
|
+
model?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SignInProbe {
|
|
15
|
+
signedIn: boolean;
|
|
16
|
+
email?: string;
|
|
17
|
+
planType?: string;
|
|
18
|
+
detail?: string;
|
|
19
|
+
models: string[];
|
|
20
|
+
defaultModel?: string;
|
|
21
|
+
}
|
|
22
|
+
export type SignInProbes = Record<DetectableSignInType, (signal: AbortSignal) => Promise<SignInProbe>>;
|
|
23
|
+
export interface DetectOptions {
|
|
24
|
+
skip?: readonly string[];
|
|
25
|
+
probes?: Partial<SignInProbes>;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface DetectionResult {
|
|
29
|
+
signIns: DetectedSignIn[];
|
|
30
|
+
timedOut: DetectableSignInType[];
|
|
31
|
+
}
|
|
32
|
+
export declare function defaultSignInProbes(): SignInProbes;
|
|
33
|
+
export declare function detectSignIns(config: Pick<Config, 'providers'>, signal: AbortSignal, options?: DetectOptions): Promise<DetectionResult>;
|
|
34
|
+
export interface SignInImport {
|
|
35
|
+
type: DetectableSignInType;
|
|
36
|
+
model: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function importedProvider(detected: DetectedSignIn, model: string, taken: (id: string) => boolean): ProviderConfig;
|
|
39
|
+
export declare function providerCanRun(config: Pick<Config, 'provider' | 'providers'>, env?: NodeJS.ProcessEnv): boolean;
|
|
40
|
+
export declare function applySignInImports(config: Config, detected: readonly DetectedSignIn[], imports: readonly SignInImport[], env?: NodeJS.ProcessEnv): {
|
|
41
|
+
config: Config;
|
|
42
|
+
added: string[];
|
|
43
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { resolveClaudeExecutable } from './claude-executable.js';
|
|
2
|
+
import { readClaudeCatalog, readClaudeSignIn } from './claude-provider.js';
|
|
3
|
+
import { resolveCliExecutable } from './cli-executable.js';
|
|
4
|
+
import { readCodexModels } from './codex-auth.js';
|
|
5
|
+
import { resolveCodexExecutable } from './codex-executable.js';
|
|
6
|
+
import { connectCodex } from './codex-rpc.js';
|
|
7
|
+
import { GROK_BASE_URL, GROK_EXECUTABLE, readGrokCatalog } from './grok-provider.js';
|
|
8
|
+
import { OPENCODE_BASE_URL, OPENCODE_EXECUTABLE, readOpenCodeCatalog, sharedOpenCodeServer } from './opencode-cli-provider.js';
|
|
9
|
+
import { uniqueProviderId } from './provider-import.js';
|
|
10
|
+
export const DETECTABLE_SIGN_IN_TYPES = ['claude', 'codex', 'grok', 'opencode'];
|
|
11
|
+
export function isDetectableSignInType(value) {
|
|
12
|
+
return DETECTABLE_SIGN_IN_TYPES.includes(value);
|
|
13
|
+
}
|
|
14
|
+
const SIGNED_OUT = { signedIn: false, models: [] };
|
|
15
|
+
const MAX_MODELS = 5000;
|
|
16
|
+
const FIXED_BASE_URL = {
|
|
17
|
+
claude: 'https://api.anthropic.com', codex: 'https://chatgpt.com/backend-api/codex', grok: GROK_BASE_URL, opencode: OPENCODE_BASE_URL,
|
|
18
|
+
};
|
|
19
|
+
const DISPLAY_NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
|
|
20
|
+
export function defaultSignInProbes() {
|
|
21
|
+
const present = async (resolve) => { try {
|
|
22
|
+
await resolve();
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
} };
|
|
28
|
+
return {
|
|
29
|
+
claude: async (signal) => {
|
|
30
|
+
if (!await present(() => resolveClaudeExecutable()))
|
|
31
|
+
return SIGNED_OUT;
|
|
32
|
+
const [account, catalog] = await Promise.all([readClaudeSignIn(signal), readClaudeCatalog(signal)]);
|
|
33
|
+
if (!account.signedIn || !catalog.signedIn)
|
|
34
|
+
return SIGNED_OUT;
|
|
35
|
+
const { models } = catalog;
|
|
36
|
+
return { signedIn: true, models, ...(account.email ? { email: account.email } : {}), ...(account.planType ? { planType: account.planType } : {}) };
|
|
37
|
+
},
|
|
38
|
+
codex: async (signal) => {
|
|
39
|
+
if (!await present(() => resolveCodexExecutable({ signal })))
|
|
40
|
+
return SIGNED_OUT;
|
|
41
|
+
const rpc = await connectCodex(signal);
|
|
42
|
+
try {
|
|
43
|
+
const account = (await rpc.request('account/read', { refreshToken: false }))?.account;
|
|
44
|
+
if (account?.type !== 'chatgpt')
|
|
45
|
+
return SIGNED_OUT;
|
|
46
|
+
const models = await readCodexModels(rpc);
|
|
47
|
+
signal.throwIfAborted();
|
|
48
|
+
const preferred = models.find(model => model.isDefault)?.id;
|
|
49
|
+
return { signedIn: true, models: models.map(model => model.id), ...(preferred ? { defaultModel: preferred } : {}),
|
|
50
|
+
...(typeof account.email === 'string' ? { email: account.email } : {}), ...(typeof account.planType === 'string' ? { planType: account.planType } : {}) };
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
rpc.close();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
grok: async (signal) => {
|
|
57
|
+
if (!await present(() => resolveCliExecutable(GROK_EXECUTABLE)))
|
|
58
|
+
return SIGNED_OUT;
|
|
59
|
+
const catalog = await readGrokCatalog(signal);
|
|
60
|
+
return { signedIn: catalog.signedIn, models: catalog.models, ...(catalog.email ? { email: catalog.email } : {}) };
|
|
61
|
+
},
|
|
62
|
+
opencode: async (signal) => {
|
|
63
|
+
if (!await present(() => resolveCliExecutable(OPENCODE_EXECUTABLE)))
|
|
64
|
+
return SIGNED_OUT;
|
|
65
|
+
const catalog = await readOpenCodeCatalog(signal, sharedOpenCodeServer());
|
|
66
|
+
const count = catalog.connected.length;
|
|
67
|
+
return { signedIn: count > 0, models: catalog.models.map(model => model.id), detail: `${count} provider${count === 1 ? '' : 's'} connected` };
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function displayText(value, max) {
|
|
72
|
+
return typeof value === 'string' && value.trim() && value.length <= max && !/[\u0000-\u001f\u007f]/.test(value) ? value : undefined;
|
|
73
|
+
}
|
|
74
|
+
function usableModels(models) {
|
|
75
|
+
const kept = [];
|
|
76
|
+
if (!Array.isArray(models))
|
|
77
|
+
return kept;
|
|
78
|
+
for (const model of models) {
|
|
79
|
+
if (kept.length >= MAX_MODELS)
|
|
80
|
+
break;
|
|
81
|
+
if (typeof model === 'string' && model.trim() && model.length <= 500 && !/[\u0000-\u001f\u007f]/.test(model) && !kept.includes(model))
|
|
82
|
+
kept.push(model);
|
|
83
|
+
}
|
|
84
|
+
return kept;
|
|
85
|
+
}
|
|
86
|
+
function describe(type, probe) {
|
|
87
|
+
if (probe.signedIn !== true)
|
|
88
|
+
return undefined;
|
|
89
|
+
const models = usableModels(probe.models);
|
|
90
|
+
if (!models.length)
|
|
91
|
+
return undefined;
|
|
92
|
+
const email = displayText(probe.email, 320);
|
|
93
|
+
const planType = displayText(probe.planType, 100);
|
|
94
|
+
const detail = displayText(probe.detail, 200);
|
|
95
|
+
const model = type === 'opencode' ? undefined : probe.defaultModel !== undefined && models.includes(probe.defaultModel) ? probe.defaultModel : models[0];
|
|
96
|
+
return { type, ...(email ? { email } : {}), ...(planType ? { planType } : {}), ...(detail ? { detail } : {}), models, ...(model ? { model } : {}) };
|
|
97
|
+
}
|
|
98
|
+
export async function detectSignIns(config, signal, options = {}) {
|
|
99
|
+
const probes = { ...(options.probes && DETECTABLE_SIGN_IN_TYPES.every(type => options.probes?.[type]) ? {} : defaultSignInProbes()), ...options.probes };
|
|
100
|
+
const timeoutMs = options.timeoutMs ?? 45_000;
|
|
101
|
+
const timedOut = [];
|
|
102
|
+
const wanted = DETECTABLE_SIGN_IN_TYPES.filter(type => !options.skip?.includes(type) && !config.providers.some(provider => provider.type === type));
|
|
103
|
+
const found = await Promise.all(wanted.map(async (type) => {
|
|
104
|
+
const deadline = AbortSignal.timeout(timeoutMs);
|
|
105
|
+
const bounded = AbortSignal.any([signal, deadline]);
|
|
106
|
+
try {
|
|
107
|
+
const probe = await new Promise((resolve, reject) => {
|
|
108
|
+
bounded.addEventListener('abort', () => reject(new Error('aborted')), { once: true });
|
|
109
|
+
if (bounded.aborted) {
|
|
110
|
+
reject(new Error('aborted'));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
probes[type](bounded).then(resolve, reject);
|
|
114
|
+
});
|
|
115
|
+
return describe(type, probe);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
if (deadline.aborted && !signal.aborted)
|
|
119
|
+
timedOut.push(type);
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
return { signIns: found.filter((item) => item !== undefined), timedOut: DETECTABLE_SIGN_IN_TYPES.filter(type => timedOut.includes(type)) };
|
|
124
|
+
}
|
|
125
|
+
export function importedProvider(detected, model, taken) {
|
|
126
|
+
if (!detected.models.includes(model))
|
|
127
|
+
throw new Error(`${model} is not one of the models ${DISPLAY_NAME[detected.type]} lists.`);
|
|
128
|
+
const models = detected.type === 'opencode' ? [model] : [model, ...detected.models.filter(item => item !== model)];
|
|
129
|
+
return { id: uniqueProviderId(taken, detected.type), type: detected.type, baseUrl: FIXED_BASE_URL[detected.type], model, models, name: DISPLAY_NAME[detected.type] };
|
|
130
|
+
}
|
|
131
|
+
export function providerCanRun(config, env = process.env) {
|
|
132
|
+
const active = config.providers.find(provider => provider.id === config.provider);
|
|
133
|
+
if (!active)
|
|
134
|
+
return false;
|
|
135
|
+
return !(active.apiKeyEnv && !env[active.apiKeyEnv] && !active.apiKey);
|
|
136
|
+
}
|
|
137
|
+
export function applySignInImports(config, detected, imports, env = process.env) {
|
|
138
|
+
const providers = [...config.providers];
|
|
139
|
+
const added = [];
|
|
140
|
+
for (const choice of imports) {
|
|
141
|
+
const found = detected.find(item => item.type === choice.type);
|
|
142
|
+
if (!found)
|
|
143
|
+
throw new Error(`${DISPLAY_NAME[choice.type] ?? 'That tool'} was not detected as signed in.`);
|
|
144
|
+
const entry = importedProvider(found, choice.model, id => providers.some(provider => provider.id === id));
|
|
145
|
+
if (providers.some(provider => provider.type === choice.type))
|
|
146
|
+
continue;
|
|
147
|
+
providers.push(entry);
|
|
148
|
+
added.push(entry.id);
|
|
149
|
+
}
|
|
150
|
+
const next = { ...config, providers };
|
|
151
|
+
if (added.length && !providerCanRun(config, env))
|
|
152
|
+
next.provider = added[0];
|
|
153
|
+
return { config: next, added };
|
|
154
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type DetectionResult } from './sign-in-detection.js';
|
|
2
|
+
export interface SignInOfferState {
|
|
3
|
+
done?: boolean;
|
|
4
|
+
attempts?: number;
|
|
5
|
+
answered?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function readSignInOfferState(home?: string): Promise<SignInOfferState>;
|
|
8
|
+
export declare function writeSignInOfferState(state: SignInOfferState, home?: string): Promise<void>;
|
|
9
|
+
export declare function parseSignInAnswer(answer: string, count: number): number[] | 'none' | undefined;
|
|
10
|
+
export interface SignInOfferOptions {
|
|
11
|
+
home?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
ask: (question: string) => Promise<string>;
|
|
14
|
+
write: (text: string) => void;
|
|
15
|
+
detect?: (home: string, signal: AbortSignal, skip: readonly string[]) => Promise<DetectionResult>;
|
|
16
|
+
}
|
|
17
|
+
export declare function offerSignInImport(options: SignInOfferOptions): Promise<string[]>;
|