@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
|
@@ -7,39 +7,21 @@ import { runRecordPath, runRecordsDirectory, sessionHasOpenRun } from '../run-re
|
|
|
7
7
|
import { validSavedSession } from '../sessions.js';
|
|
8
8
|
import { listBundles } from '../extensions.js';
|
|
9
9
|
import { builtinSkillEntries } from '../skills/invocable-skills.js';
|
|
10
|
-
/**
|
|
11
|
-
* Inspection of a workspace and of this installation's run records.
|
|
12
|
-
*
|
|
13
|
-
* Only one function here (`checkoutBranch`) changes anything, and it changes the branch the working
|
|
14
|
-
* tree is on — never its contents. Everything else answers a panel in the desktop client: paths from
|
|
15
|
-
* the client are resolved inside the workspace root and refused when they leave it, so a crafted
|
|
16
|
-
* request cannot read arbitrary files through the engine.
|
|
17
|
-
*/
|
|
18
|
-
/** The same skip list the agent's `list_files` tool uses, so the tree matches what the agent sees. */
|
|
19
10
|
const SKIP_NAMES = new Set(['.git', 'node_modules', '.andorracode']);
|
|
20
11
|
const MAX_TREE_ENTRIES = 5_000;
|
|
21
12
|
const MAX_TREE_DEPTH = 12;
|
|
22
13
|
const MAX_FILE_BYTES = 512 * 1024;
|
|
23
14
|
const MAX_DIFF_BYTES = 2 * 1024 * 1024;
|
|
24
|
-
/** Enough for a working tree of ordinary size; a repository past this is reported as cut. */
|
|
25
15
|
const MAX_STATUS_BYTES = 8 * 1024 * 1024;
|
|
26
16
|
const GIT_TIMEOUT_MS = 15_000;
|
|
27
17
|
const MAX_RUNS = 200;
|
|
28
18
|
const MAX_RUN_EVENTS = 5_000;
|
|
29
|
-
/** How many session snapshots may be opened to title a page of runs; the newest are examined. */
|
|
30
19
|
const MAX_SESSION_SCAN = 500;
|
|
31
20
|
function message(error) { return error instanceof Error ? error.message : String(error); }
|
|
32
21
|
function inside(root, target) {
|
|
33
22
|
const suffix = relative(root, target);
|
|
34
23
|
return suffix === '' || (!isAbsolute(suffix) && suffix !== '..' && !suffix.startsWith(`..${sep}`));
|
|
35
24
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Resolve a client-supplied relative path inside the workspace, without following the final component.
|
|
38
|
-
*
|
|
39
|
-
* The containment check is the same lexical one `resolveInside` starts with; what is left out is the
|
|
40
|
-
* canonicalization, for the callers that need the name the client chose rather than the file it points
|
|
41
|
-
* at (a Git pathspec, for one).
|
|
42
|
-
*/
|
|
43
25
|
export async function resolveLexicalInside(root, name) {
|
|
44
26
|
if (name !== undefined && (typeof name !== 'string' || name.length > 4096 || name.includes('\0')))
|
|
45
27
|
throw new Error('A workspace path must be a string of up to 4096 characters');
|
|
@@ -48,13 +30,6 @@ export async function resolveLexicalInside(root, name) {
|
|
|
48
30
|
throw new Error('The path is outside the project');
|
|
49
31
|
return candidate;
|
|
50
32
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Resolve a client-supplied relative path inside the workspace.
|
|
53
|
-
*
|
|
54
|
-
* The lexical check runs before `realpath`, so a path that escapes through `..` never reaches the
|
|
55
|
-
* filesystem, and the canonical check runs after, so a symlink or junction that leaves the
|
|
56
|
-
* workspace is refused even when its name looked local.
|
|
57
|
-
*/
|
|
58
33
|
export async function resolveInside(root, name) {
|
|
59
34
|
if (name !== undefined && (typeof name !== 'string' || name.length > 4096 || name.includes('\0')))
|
|
60
35
|
throw new Error('A workspace path must be a string of up to 4096 characters');
|
|
@@ -78,13 +53,6 @@ export async function workspaceRoot(value) {
|
|
|
78
53
|
throw new Error('The project path is not a folder');
|
|
79
54
|
return root;
|
|
80
55
|
}
|
|
81
|
-
/**
|
|
82
|
-
* List one directory level or a bounded subtree.
|
|
83
|
-
*
|
|
84
|
-
* A tree panel asks for one level at a time, so the default walk stops at the requested directory
|
|
85
|
-
* and only the opt-in deep form recurses; either way directories come before files and both sort
|
|
86
|
-
* by name, which keeps a level stable between refreshes.
|
|
87
|
-
*/
|
|
88
56
|
export async function readTree(root, options = {}) {
|
|
89
57
|
const start = await resolveInside(root, options.path);
|
|
90
58
|
const deep = options.depth !== undefined;
|
|
@@ -96,10 +64,6 @@ export async function readTree(root, options = {}) {
|
|
|
96
64
|
for await (const entry of await opendir(directory)) {
|
|
97
65
|
if (entry.isSymbolicLink() || SKIP_NAMES.has(entry.name))
|
|
98
66
|
continue;
|
|
99
|
-
// The bound is applied while reading the directory, not after: a folder with far more children
|
|
100
|
-
// than this cap would otherwise be accumulated and sorted in full before the cap could apply,
|
|
101
|
-
// and a stat per file would make listing a large generated directory very slow. Sizes are not
|
|
102
|
-
// reported for that reason; nothing in the client renders them.
|
|
103
67
|
if (entries.length + found.length >= MAX_TREE_ENTRIES) {
|
|
104
68
|
truncated = true;
|
|
105
69
|
break;
|
|
@@ -125,13 +89,6 @@ export async function readTree(root, options = {}) {
|
|
|
125
89
|
await walk(start, 1);
|
|
126
90
|
return { path: relative(root, start).split(sep).join('/'), entries, truncated };
|
|
127
91
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Read one text file with a byte cap.
|
|
130
|
-
*
|
|
131
|
-
* The cap is enforced on the read, not after it: stat gives the size, and a large file is read
|
|
132
|
-
* through a bounded handle so opening a multi-gigabyte artifact cannot allocate it in full just to
|
|
133
|
-
* hand back its first half megabyte. Binary detection keeps a NUL byte from reaching a text view.
|
|
134
|
-
*/
|
|
135
92
|
export async function readWorkspaceFile(root, name) {
|
|
136
93
|
const path = await resolveInside(root, name);
|
|
137
94
|
const info = await stat(path);
|
|
@@ -143,9 +100,6 @@ export async function readWorkspaceFile(root, name) {
|
|
|
143
100
|
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
144
101
|
const head = buffer.subarray(0, bytesRead);
|
|
145
102
|
const binary = head.subarray(0, Math.min(head.length, 8000)).includes(0);
|
|
146
|
-
// The cap can fall inside a multi-byte character, which no character encoding can represent
|
|
147
|
-
// faithfully; the decoder keeps the incomplete tail out of the text instead of ending the preview
|
|
148
|
-
// with a replacement character. A file within the cap is unaffected: its bytes are complete.
|
|
149
103
|
const content = new StringDecoder('utf8').write(head.subarray(0, MAX_FILE_BYTES));
|
|
150
104
|
return { content: binary ? '' : content, truncated: info.size > MAX_FILE_BYTES, binary, size: info.size };
|
|
151
105
|
}
|
|
@@ -153,22 +107,6 @@ export async function readWorkspaceFile(root, name) {
|
|
|
153
107
|
await handle.close();
|
|
154
108
|
}
|
|
155
109
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Whether Git may be consulted about a workspace folder, and which repository that is: a `.git`
|
|
158
|
-
* sits at the folder itself or at its immediate parent, and the repository Git actually resolves
|
|
159
|
-
* to is one of those two.
|
|
160
|
-
*
|
|
161
|
-
* Git's own discovery never stops at the folder it is given — it walks every ancestor to the drive
|
|
162
|
-
* root — so on a machine whose home directory is itself a repository, a blank folder registered as
|
|
163
|
-
* a project is answered with that ancestor's branches and status, and a checkout would act on the
|
|
164
|
-
* ancestor's working tree. The parent stays in scope because a folder added directly inside a
|
|
165
|
-
* repository's root is still part of that repository's tree to the person who added it; nothing
|
|
166
|
-
* further up is. Presence is checked on the filesystem first, so a folder out of scope costs no
|
|
167
|
-
* process: `status --untracked-files=all` against an accidental ancestor of a large home directory
|
|
168
|
-
* would spend the whole timeout walking it. A `.git` that exists but is not a repository is
|
|
169
|
-
* skipped by Git, which then keeps walking — so the repository the folder resolves to is verified
|
|
170
|
-
* against this scope directly rather than assumed from what the filesystem happens to hold.
|
|
171
|
-
*/
|
|
172
110
|
async function gitInScope(root) {
|
|
173
111
|
const parent = dirname(root);
|
|
174
112
|
const holds = async (folder) => stat(join(folder, '.git')).then(() => true, () => false);
|
|
@@ -179,42 +117,20 @@ async function gitInScope(root) {
|
|
|
179
117
|
return false;
|
|
180
118
|
return inside(root, top.text.trim()) || inside(parent, top.text.trim());
|
|
181
119
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Working-tree status through the `git` executable.
|
|
184
|
-
*
|
|
185
|
-
* Startup metadata deliberately avoids running workspace-controlled helpers; a user-opened Changes
|
|
186
|
-
* panel is the opposite case, where the repository's own Git is the authority and the call is
|
|
187
|
-
* explicit. Arguments are fixed (no shell, no interpolation) and the call is time bounded.
|
|
188
|
-
*
|
|
189
|
-
* Paths come from `-z` output rather than the default: porcelain quotes names containing non-ASCII
|
|
190
|
-
* or control characters in C style, and a client that treated the quoted form as a path could not
|
|
191
|
-
* open the file it names. With `-z` each record is NUL terminated and renames carry the source in a
|
|
192
|
-
* following field, so no path has to be decoded.
|
|
193
|
-
*/
|
|
194
120
|
export async function gitStatus(root, options = {}) {
|
|
195
121
|
if (!(await gitInScope(root)))
|
|
196
122
|
return { repository: false, files: [] };
|
|
197
123
|
let collected;
|
|
198
124
|
try {
|
|
199
|
-
// Streamed and capped, like the diff path: `execFile` fails the whole call once a repository's
|
|
200
|
-
// status passes its buffer, and the catch below would then report a large generated tree as not
|
|
201
|
-
// being a repository at all. A capped read is reported as such instead.
|
|
202
125
|
collected = await collectCapped('git', ['-C', root, 'status', '--porcelain=v1', '-z', '--branch', '--untracked-files=all'], options.maxBytes ?? MAX_STATUS_BYTES, GIT_TIMEOUT_MS);
|
|
203
126
|
}
|
|
204
127
|
catch {
|
|
205
|
-
// Git that cannot be started, a timeout, or an unreadable tree are all "no changes to show"; the
|
|
206
|
-
// panel says so rather than failing the request.
|
|
207
128
|
return { repository: false, files: [] };
|
|
208
129
|
}
|
|
209
|
-
// A capped read was killed rather than exited, so its code says nothing about the repository: the
|
|
210
|
-
// records it did collect are a partial listing, which the flag reports. Only a command that ran to a
|
|
211
|
-
// nonzero exit is a folder with nothing to show.
|
|
212
130
|
if (!collected.truncated && collected.code !== 0)
|
|
213
131
|
return { repository: false, files: [] };
|
|
214
132
|
{
|
|
215
133
|
const records = collected.text.split('\0');
|
|
216
|
-
// A capped read can end in the middle of a record, so the last one is dropped rather than parsed
|
|
217
|
-
// into a path with no file behind it; the flag tells the pane the list is incomplete.
|
|
218
134
|
if (collected.truncated)
|
|
219
135
|
records.pop();
|
|
220
136
|
const files = [];
|
|
@@ -231,7 +147,6 @@ export async function gitStatus(root, options = {}) {
|
|
|
231
147
|
if (record.length < 4)
|
|
232
148
|
continue;
|
|
233
149
|
const index_ = record.slice(0, 1).trim(), worktree = record.slice(1, 2).trim();
|
|
234
|
-
// A rename or copy entry names the destination here and the source in the next record.
|
|
235
150
|
const renamed = index_ === 'R' || index_ === 'C';
|
|
236
151
|
files.push({ path: record.slice(3), index: index_, worktree });
|
|
237
152
|
if (renamed)
|
|
@@ -240,50 +155,25 @@ export async function gitStatus(root, options = {}) {
|
|
|
240
155
|
return { repository: true, branch, files, truncated: collected.truncated };
|
|
241
156
|
}
|
|
242
157
|
}
|
|
243
|
-
/** Which Git failures mean "there is nothing to compare" rather than "this could not be read". */
|
|
244
158
|
const NOTHING_TO_COMPARE = /not a git repository|bad revision 'HEAD'|ambiguous argument 'HEAD'|does not have any commits/i;
|
|
245
|
-
/** Which of those mean the comparison has no first commit to name, which `--cached` can still answer. */
|
|
246
159
|
const NO_FIRST_COMMIT = /bad revision 'HEAD'|ambiguous argument 'HEAD'|does not have any commits/i;
|
|
247
|
-
/** The first line of a Git diagnostic, for an error a person can act on. */
|
|
248
160
|
function firstLine(text) { return text.trim().split('\n')[0]?.slice(0, 200) ?? ''; }
|
|
249
|
-
/** How many branch names one answer carries; a repository past this is listed up to the bound. */
|
|
250
161
|
const MAX_BRANCHES = 1_000;
|
|
251
162
|
const MAX_BRANCH_BYTES = 256 * 1024;
|
|
252
163
|
const MAX_BRANCH_NAME_CHARS = 200;
|
|
253
|
-
/**
|
|
254
|
-
* The local branches of a repository, and the one the working tree is on.
|
|
255
|
-
*
|
|
256
|
-
* `refs/heads` is read directly rather than through `git branch`, whose listing in a detached HEAD
|
|
257
|
-
* also contains a pseudo-entry naming the commit — a name no client could check out. The branch the
|
|
258
|
-
* working tree is on is asked separately because a detached HEAD has none, and "absent from the
|
|
259
|
-
* listing" would otherwise be indistinguishable from a branch that only does not exist yet.
|
|
260
|
-
* Remote-tracking refs are left out: landing on one needs a tracking decision — which local branch
|
|
261
|
-
* follows it — that this request cannot express. The repository has to be the workspace folder
|
|
262
|
-
* itself or its immediate parent (`gitInScope`); a repository Git would only reach further up the
|
|
263
|
-
* tree is not this folder's to offer.
|
|
264
|
-
*/
|
|
265
164
|
export async function listBranches(root) {
|
|
266
165
|
if (!(await gitInScope(root)))
|
|
267
166
|
return { repository: false, branches: [] };
|
|
268
167
|
let collected;
|
|
269
168
|
try {
|
|
270
|
-
// `:lstrip=2` removes the fixed `refs/heads/` prefix instead of asking for an abbreviation:
|
|
271
|
-
// `:short` has to stay unambiguous, so a repository with a tag of the same name would list
|
|
272
|
-
// `heads/foo`, and checking that name out later would land on the tag rather than the branch.
|
|
273
169
|
collected = await collectCapped('git', ['-C', root, 'for-each-ref', '--format=%(refname:lstrip=2)', 'refs/heads'], MAX_BRANCH_BYTES, GIT_TIMEOUT_MS);
|
|
274
170
|
}
|
|
275
171
|
catch {
|
|
276
|
-
// Git that cannot be started, a timeout, and an unreadable folder all read as "nothing to offer".
|
|
277
172
|
return { repository: false, branches: [] };
|
|
278
173
|
}
|
|
279
|
-
// A capped read was killed rather than exited, so its code says nothing about the repository: the
|
|
280
|
-
// names it did collect are a prefix of the listing, which the flag reports. Only a command that ran
|
|
281
|
-
// to a nonzero exit is a folder with no branches to show.
|
|
282
174
|
if (!collected.truncated && collected.code !== 0)
|
|
283
175
|
return { repository: false, branches: [] };
|
|
284
176
|
const records = collected.text.split('\n');
|
|
285
|
-
// A capped read can end in the middle of a name, so the last record is dropped rather than offered
|
|
286
|
-
// as a branch that does not exist.
|
|
287
177
|
if (collected.truncated)
|
|
288
178
|
records.pop();
|
|
289
179
|
const branches = [];
|
|
@@ -295,11 +185,6 @@ export async function listBranches(root) {
|
|
|
295
185
|
if (branches.length < MAX_BRANCHES)
|
|
296
186
|
branches.push(record);
|
|
297
187
|
}
|
|
298
|
-
// `-q` makes a detached HEAD an empty answer with a nonzero exit rather than a diagnostic; a Git
|
|
299
|
-
// that cannot be started at all is the same absence, and the listing above already answered.
|
|
300
|
-
// The full ref is read and the prefix stripped by hand: `--short` has to stay unambiguous, so with
|
|
301
|
-
// a tag of the same name it answers `heads/feature/one` — a name that would then neither match the
|
|
302
|
-
// listing below nor be a branch the caller can switch to.
|
|
303
188
|
const head = await collectCapped('git', ['-C', root, 'symbolic-ref', '-q', 'HEAD'], 4 * 1024, GIT_TIMEOUT_MS).catch(() => undefined);
|
|
304
189
|
const current = head && head.code === 0 ? head.text.trim().replace(/^refs\/heads\//, '') || undefined : undefined;
|
|
305
190
|
return {
|
|
@@ -309,20 +194,6 @@ export async function listBranches(root) {
|
|
|
309
194
|
...(collected.truncated || listed > branches.length ? { truncated: true } : {}),
|
|
310
195
|
};
|
|
311
196
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Switch the working tree to a branch, creating it when asked.
|
|
314
|
-
*
|
|
315
|
-
* The name is a Git ref name and Git judges it, after the cases that would make it mean something
|
|
316
|
-
* other than the branch typed are refused here: a leading dash would reach the command as an option,
|
|
317
|
-
* and `@{` is resolved by `check-ref-format --branch` against the reflog — a way to name a different
|
|
318
|
-
* branch than the one in the request. Nothing else about the name is guessed; Git's own refusal is
|
|
319
|
-
* what the caller reports, because it names the reason (no such branch, a working tree that would
|
|
320
|
-
* lose changes) better than a rule kept in sync here could.
|
|
321
|
-
*
|
|
322
|
-
* The repository has to be the workspace folder itself or its immediate parent (`gitInScope`): a
|
|
323
|
-
* switch Git would only reach by walking further up the tree would move some ancestor repository's
|
|
324
|
-
* working tree, not this folder's.
|
|
325
|
-
*/
|
|
326
197
|
export async function checkoutBranch(root, options) {
|
|
327
198
|
if (!(await gitInScope(root)))
|
|
328
199
|
throw new Error('The project folder is not a Git repository');
|
|
@@ -336,70 +207,34 @@ export async function checkoutBranch(root, options) {
|
|
|
336
207
|
const checked = await collectCapped('git', ['-C', root, 'check-ref-format', '--branch', name], 4 * 1024, GIT_TIMEOUT_MS);
|
|
337
208
|
if (checked.code !== 0)
|
|
338
209
|
throw new Error(firstLine(checked.failure) || `Not a valid branch name: ${name}`);
|
|
339
|
-
// `switch` cannot restore paths, and `--no-guess` refuses to invent a local branch from a
|
|
340
|
-
// remote-tracking one: plain `checkout <name>` selects its path-restoration mode when no branch
|
|
341
|
-
// matches, which exits successfully after discarding unstaged changes to a path of that name and
|
|
342
|
-
// would leave this function reporting a branch switch that never happened.
|
|
343
210
|
const switched = await collectCapped('git', ['-C', root, 'switch', '--no-guess', ...(options.create === true ? ['-c'] : []), name], 64 * 1024, GIT_TIMEOUT_MS);
|
|
344
211
|
if (switched.code !== 0)
|
|
345
212
|
throw new Error(firstLine(switched.failure) || 'The branch could not be checked out');
|
|
346
213
|
return { branch: name };
|
|
347
214
|
}
|
|
348
|
-
/**
|
|
349
|
-
* A diff for one path or the whole tree.
|
|
350
|
-
*
|
|
351
|
-
* `base` names what the diff is taken against: the working tree alone (unstaged changes, Git's
|
|
352
|
-
* default) or `head`, which is what a per-file view wants because it includes staged and unstaged
|
|
353
|
-
* changes together. Untracked files have no diff at all and are read as content by the client.
|
|
354
|
-
* A folder out of Git scope (`gitInScope`) has nothing to compare, answered without running Git.
|
|
355
|
-
*/
|
|
356
215
|
export async function gitDiff(root, options = {}) {
|
|
357
216
|
if (!(await gitInScope(root)))
|
|
358
217
|
return { diff: '', truncated: false };
|
|
359
|
-
// The pathspec keeps the name that was asked for. `resolveInside` follows the final component with
|
|
360
|
-
// `realpath`, which is what a *read* needs — a link that leaves the project must be refused — but a
|
|
361
|
-
// diff is addressed by Git: canonicalizing a tracked symlink would ask for its target's diff, which
|
|
362
|
-
// usually reads as "no changes", instead of the change to the link itself.
|
|
363
218
|
const target = options.path !== undefined && options.path !== '' ? relative(root, await resolveLexicalInside(root, options.path)).split(sep).join('/') || '.' : undefined;
|
|
364
219
|
const head = options.base === 'head' && options.staged !== true;
|
|
365
|
-
// `--no-ext-diff` covers an external *diff* driver; a diff driver's `textconv` command is a separate
|
|
366
|
-
// helper that Git runs by default, and it is a configured program run with this process's privileges.
|
|
367
220
|
const args = ['-C', root, 'diff', '--no-color', '--no-ext-diff', '--no-textconv', ...(options.staged === true ? ['--staged'] : head ? ['HEAD'] : []), ...(target === undefined ? [] : ['--', target])];
|
|
368
|
-
// The diff is streamed and the collection stops at the cap: `execFile`'s buffer would reject a
|
|
369
|
-
// large-but-valid diff before this code could truncate it, reporting a readable change as
|
|
370
|
-
// unreadable, and collecting it whole would hold the entire diff in memory.
|
|
371
221
|
let collected = await collectCapped('git', args, MAX_DIFF_BYTES, GIT_TIMEOUT_MS).catch((error) => {
|
|
372
|
-
// A Git that cannot be started reads as nothing to compare, exactly as it did before it was
|
|
373
|
-
// streamed; a timeout is reported, because an empty answer would say a changed file has no changes.
|
|
374
222
|
if (/ENOENT/.test(message(error)))
|
|
375
223
|
return { text: '', truncated: false, code: 0, failure: '' };
|
|
376
224
|
throw error;
|
|
377
225
|
});
|
|
378
226
|
if (head && !collected.truncated && collected.code !== 0 && NO_FIRST_COMMIT.test(collected.failure)) {
|
|
379
|
-
// A repository whose first commit has not happened has no HEAD to compare against, and Git offers
|
|
380
|
-
// `--cached` there: it shows the staged snapshot the Changes list is already displaying. Without
|
|
381
|
-
// this, opening a staged file in a fresh repository read as "no changes".
|
|
382
227
|
const staged = args.filter(argument => argument !== 'HEAD');
|
|
383
228
|
staged.splice(staged.indexOf('--no-ext-diff') + 1, 0, '--cached');
|
|
384
229
|
collected = await collectCapped('git', staged, MAX_DIFF_BYTES, GIT_TIMEOUT_MS);
|
|
385
230
|
}
|
|
386
231
|
if (collected.truncated)
|
|
387
232
|
return { diff: collected.text, truncated: true };
|
|
388
|
-
// "Not a repository" and "no commits yet" are empty comparisons; any other nonzero exit is a real
|
|
389
|
-
// failure, and returning its empty stdout would tell the Code view that a changed file has no changes.
|
|
390
233
|
if (collected.code !== 0 && !NOTHING_TO_COMPARE.test(collected.failure)) {
|
|
391
234
|
throw new Error(`The Git output could not be read${collected.failure ? `: ${firstLine(collected.failure)}` : ''}`);
|
|
392
235
|
}
|
|
393
236
|
return { diff: collected.code === 0 ? collected.text : '', truncated: false };
|
|
394
237
|
}
|
|
395
|
-
/**
|
|
396
|
-
* The timestamp of a journal's first event.
|
|
397
|
-
*
|
|
398
|
-
* The first line is `graph.started`, which serializes the whole pinned graph, so it can be far larger
|
|
399
|
-
* than a small fixed prefix: the read continues to the first newline, up to a bound at which a single
|
|
400
|
-
* record stops being credible. A record that still cannot be parsed has its timestamp extracted by
|
|
401
|
-
* pattern, since the rest of that payload is not wanted here.
|
|
402
|
-
*/
|
|
403
238
|
async function firstEventTime(journal) {
|
|
404
239
|
const LIMIT = 256 * 1024;
|
|
405
240
|
const CHUNK = 16 * 1024;
|
|
@@ -429,7 +264,7 @@ async function firstEventTime(journal) {
|
|
|
429
264
|
if (typeof event.time === 'string')
|
|
430
265
|
return event.time;
|
|
431
266
|
}
|
|
432
|
-
catch {
|
|
267
|
+
catch { }
|
|
433
268
|
return /"time":"([^"]+)"/.exec(first)?.[1];
|
|
434
269
|
}
|
|
435
270
|
catch {
|
|
@@ -439,21 +274,9 @@ async function firstEventTime(journal) {
|
|
|
439
274
|
await handle.close();
|
|
440
275
|
}
|
|
441
276
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Run a command, keeping at most `cap` bytes of its standard output.
|
|
444
|
-
*
|
|
445
|
-
* Exported for the streaming test: the split it guards against is a property of pipe reads, which a
|
|
446
|
-
* test can only produce by driving this collector directly. Rejection is reserved for a command that
|
|
447
|
-
* never ran or never finished; what it exited with is the caller's business, because the same exit is
|
|
448
|
-
* an empty answer for one command and a real failure for another.
|
|
449
|
-
*/
|
|
450
277
|
export function collectCapped(program, args, cap, timeoutMs) {
|
|
451
278
|
return new Promise((resolve, reject) => {
|
|
452
279
|
const child = spawn(program, args, { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
453
|
-
// A pipe delivers bytes, and a multi-byte character can be divided between two reads: decoding
|
|
454
|
-
// each chunk on its own would replace both halves with replacement characters, corrupting the file
|
|
455
|
-
// contents and paths the Code view shows even though Git emitted valid UTF-8. One decoder per
|
|
456
|
-
// stream carries the unfinished character over to the chunk that completes it.
|
|
457
280
|
const stdout = new StringDecoder('utf8');
|
|
458
281
|
const stderr = new StringDecoder('utf8');
|
|
459
282
|
let text = '';
|
|
@@ -467,8 +290,6 @@ export function collectCapped(program, args, cap, timeoutMs) {
|
|
|
467
290
|
timer.unref?.();
|
|
468
291
|
const finish = (code) => {
|
|
469
292
|
clearTimeout(timer);
|
|
470
|
-
// Flush the decoder unless the tail was cut: a stream that ended mid-character has nothing more
|
|
471
|
-
// coming, while a cap that cut one has deliberately dropped those bytes.
|
|
472
293
|
if (!truncated)
|
|
473
294
|
text += stdout.end();
|
|
474
295
|
resolve({ text, truncated, code, failure });
|
|
@@ -477,12 +298,8 @@ export function collectCapped(program, args, cap, timeoutMs) {
|
|
|
477
298
|
if (truncated)
|
|
478
299
|
return;
|
|
479
300
|
if (bytes + chunk.length > cap) {
|
|
480
|
-
// The cap is a byte count and it is applied before decoding, so the retained text cannot
|
|
481
|
-
// exceed it. A character the boundary cuts in half is left to the decoder rather than shown
|
|
482
|
-
// as a replacement character; the output is marked truncated either way.
|
|
483
301
|
text += stdout.write(chunk.subarray(0, Math.max(0, cap - bytes)));
|
|
484
302
|
truncated = true;
|
|
485
|
-
// Nothing more is wanted: stop the producer instead of reading a large output to the end.
|
|
486
303
|
child.kill();
|
|
487
304
|
return;
|
|
488
305
|
}
|
|
@@ -497,13 +314,6 @@ export function collectCapped(program, args, cap, timeoutMs) {
|
|
|
497
314
|
child.once('close', code => { finish(code); });
|
|
498
315
|
});
|
|
499
316
|
}
|
|
500
|
-
/**
|
|
501
|
-
* The newest `keep` entries of a directory, by modification time.
|
|
502
|
-
*
|
|
503
|
-
* Directory order is arbitrary, so a cap applied before timestamps are read can hide a just-written
|
|
504
|
-
* file behind older ones. The scan runs at bounded concurrency and retains only `keep` entries, so a
|
|
505
|
-
* directory with tens of thousands of files costs a fixed number of in-flight stats and fixed memory.
|
|
506
|
-
*/
|
|
507
317
|
async function newestByMtime(folder, names, keep) {
|
|
508
318
|
const newest = [];
|
|
509
319
|
let next = 0;
|
|
@@ -528,14 +338,6 @@ async function newestByMtime(folder, names, keep) {
|
|
|
528
338
|
await Promise.all(Array.from({ length: Math.min(8, names.length) }, worker));
|
|
529
339
|
return newest;
|
|
530
340
|
}
|
|
531
|
-
/**
|
|
532
|
-
* Map run identity to the session turn that produced it, so a run list can name its task.
|
|
533
|
-
*
|
|
534
|
-
* Only the runs in `wanted` are looked up, and only the newest session files are opened, stopping as
|
|
535
|
-
* soon as every one of them is titled: a long-lived installation accumulates a snapshot per resumed
|
|
536
|
-
* task, each carrying accumulated history, and parsing the whole archive to title a page of runs
|
|
537
|
-
* would make opening the Runs view grow with everything the installation has ever done.
|
|
538
|
-
*/
|
|
539
341
|
async function runTitles(directory, wanted) {
|
|
540
342
|
const titles = new Map();
|
|
541
343
|
if (!wanted.size)
|
|
@@ -557,36 +359,19 @@ async function runTitles(directory, wanted) {
|
|
|
557
359
|
if (!validSavedSession(record))
|
|
558
360
|
continue;
|
|
559
361
|
for (const turn of record.history ?? []) {
|
|
560
|
-
// A continued turn is labelled by the message that continued it: the turn's own task is the
|
|
561
|
-
// stopped attempt's, so the Runs view and the search haystack would otherwise repeat the old
|
|
562
|
-
// prompt instead of the words the user last sent. The transcript's rule, applied to titles.
|
|
563
362
|
if (turn.runId && wanted.has(turn.runId) && !titles.has(turn.runId))
|
|
564
363
|
titles.set(turn.runId, { task: turn.direction ?? turn.task, session: record });
|
|
565
364
|
}
|
|
566
365
|
}
|
|
567
|
-
catch {
|
|
366
|
+
catch { }
|
|
568
367
|
}
|
|
569
368
|
return titles;
|
|
570
369
|
}
|
|
571
|
-
/** How deep a session's parent chain is walked to find the record that produced a run. */
|
|
572
370
|
const MAX_LINEAGE_WALK = 64;
|
|
573
|
-
/**
|
|
574
|
-
* The session that first produced a run, starting from a record that merely carries its turn.
|
|
575
|
-
*
|
|
576
|
-
* Continuation forks copy their parent's whole history, so an ancestor's run is commonly found in a
|
|
577
|
-
* newer child first — and a record's timestamp cannot tell the two apart, because a later save of
|
|
578
|
-
* the old session moves it the other way. `parentId` is the link that can: a record's own history
|
|
579
|
-
* is the only one that produced its turns, a fork merely inherits them, so walking up while the
|
|
580
|
-
* parent still carries the turn ends at the session that ran it. Taking the first match instead
|
|
581
|
-
* would attribute the run to a descendant — and `View trajectory` on the original would report that
|
|
582
|
-
* it has no run at all.
|
|
583
|
-
*/
|
|
584
371
|
async function originatingSession(directory, candidate, runId, cache) {
|
|
585
372
|
const carries = (record) => (record.history ?? []).some(turn => turn.runId === runId);
|
|
586
373
|
let origin = candidate;
|
|
587
374
|
const visited = new Set([candidate.id]);
|
|
588
|
-
// A damaged record can name a parent chain that loops back on itself; the set breaks that, and
|
|
589
|
-
// the depth cap keeps one listing from turning a pathological chain into unbounded reads.
|
|
590
375
|
for (let depth = 0; depth < MAX_LINEAGE_WALK && origin.parentId !== undefined; depth += 1) {
|
|
591
376
|
const parentId = origin.parentId;
|
|
592
377
|
if (visited.has(parentId))
|
|
@@ -616,18 +401,12 @@ export async function listRuns(directory, limit) {
|
|
|
616
401
|
return [];
|
|
617
402
|
throw error;
|
|
618
403
|
}
|
|
619
|
-
// Bodies are read only for the newest records, and titles only for those runs. The runs folder
|
|
620
|
-
// also holds resume claims and node checkpoints; only the `.json` result records are runs, and
|
|
621
|
-
// the legacy `.checkpoint.json` spelling is filtered too so an old file never shows as a second
|
|
622
|
-
// run of an id that never ran.
|
|
623
404
|
const stamped = await newestByMtime(runs, names.filter(name => name.endsWith('.json') && !name.endsWith('.checkpoint.json')), bound);
|
|
624
405
|
const records = await Promise.all(stamped.map(async ({ name, info }) => {
|
|
625
406
|
try {
|
|
626
407
|
const value = JSON.parse(await readFile(join(runs, name), 'utf8'));
|
|
627
408
|
const id = typeof value.id === 'string' ? value.id : name.slice(0, -5);
|
|
628
409
|
const usage = (value.usage ?? {});
|
|
629
|
-
// The result file is written when the run finishes, so its timestamp is an end time. The
|
|
630
|
-
// journal's first event is the start, which is what a duration is measured from.
|
|
631
410
|
const startedAt = await firstEventTime(join(runs, `${id}.jsonl`)) ?? info.mtime.toISOString();
|
|
632
411
|
return {
|
|
633
412
|
id, status: String(value.status ?? 'unknown'), graph: String(typeof value.graph === 'object' && value.graph ? value.graph.id ?? 'default' : value.graph ?? 'default'),
|
|
@@ -645,14 +424,9 @@ export async function listRuns(directory, limit) {
|
|
|
645
424
|
const selected = records.filter((value) => value !== undefined)
|
|
646
425
|
.sort((left, right) => Date.parse(right.updatedAt) - Date.parse(left.updatedAt));
|
|
647
426
|
const titles = await runTitles(directory, new Set(selected.map(run => run.id)));
|
|
648
|
-
// One walk cache for the whole listing: two legacy runs of one lineage share their ancestor reads.
|
|
649
427
|
const lineage = new Map();
|
|
650
428
|
return await Promise.all(selected.map(async (run) => {
|
|
651
429
|
const title = titles.get(run.id);
|
|
652
|
-
// Older records may not name their session; the session history does, which is also where the
|
|
653
|
-
// task title comes from. A record that names its own session is taken at its word — the fill is
|
|
654
|
-
// for records written before the field existed, and those get their owner from the lineage's
|
|
655
|
-
// originating record rather than from whichever copy of the history the scan reached first.
|
|
656
430
|
if (title === undefined)
|
|
657
431
|
return run;
|
|
658
432
|
if (run.sessionId !== undefined)
|
|
@@ -661,31 +435,8 @@ export async function listRuns(directory, limit) {
|
|
|
661
435
|
return { ...run, task: title.task, sessionId: origin.id };
|
|
662
436
|
}));
|
|
663
437
|
}
|
|
664
|
-
/**
|
|
665
|
-
* Bytes read per backward pass while looking for a journal's newest events.
|
|
666
|
-
*
|
|
667
|
-
* The slice a client wants is the end of the file, and a run can write a journal far larger than
|
|
668
|
-
* that slice: reading it forward to keep the last five thousand lines would cost latency, disk, and
|
|
669
|
-
* JSON parsing proportional to the whole file for every open of the run's detail. Blocks are read
|
|
670
|
-
* backwards from the end and concatenated as bytes, so a multi-byte character split across a block
|
|
671
|
-
* boundary is decoded once, after the window is assembled.
|
|
672
|
-
*/
|
|
673
438
|
const JOURNAL_TAIL_BLOCK_BYTES = 256 * 1024;
|
|
674
|
-
/**
|
|
675
|
-
* How many bytes of a journal's tail are assembled at most.
|
|
676
|
-
*
|
|
677
|
-
* The event count alone is not a bound: a tool event may carry up to 24,000 characters, so five
|
|
678
|
-
* thousand of them approach 120 MB of reads, concatenation, and parsing for one open of a run's
|
|
679
|
-
* detail. A byte budget is what keeps the work proportional to what a client can display, and a
|
|
680
|
-
* window that stops here is reported as truncated like any other.
|
|
681
|
-
*/
|
|
682
439
|
const JOURNAL_TAIL_MAX_BYTES = 8 * 1024 * 1024;
|
|
683
|
-
/**
|
|
684
|
-
* The newest `limit` lines of a journal, read from the end of the file.
|
|
685
|
-
*
|
|
686
|
-
* Returns the parsed lines in file order, plus whether older lines exist beyond the window. At most
|
|
687
|
-
* one block is read past what the limit needs, so the work follows the slice, not the file.
|
|
688
|
-
*/
|
|
689
440
|
async function readJournalTail(path, limit) {
|
|
690
441
|
let handle;
|
|
691
442
|
try {
|
|
@@ -693,8 +444,6 @@ async function readJournalTail(path, limit) {
|
|
|
693
444
|
const { size } = await handle.stat();
|
|
694
445
|
const blocks = [];
|
|
695
446
|
let position = size;
|
|
696
|
-
// Newlines seen in what has been read so far, which is what says whether the window already
|
|
697
|
-
// covers more lines than the limit.
|
|
698
447
|
let newlines = 0;
|
|
699
448
|
let bytes = 0;
|
|
700
449
|
while (position > 0 && newlines <= limit && bytes < JOURNAL_TAIL_MAX_BYTES) {
|
|
@@ -710,8 +459,6 @@ async function readJournalTail(path, limit) {
|
|
|
710
459
|
}
|
|
711
460
|
const text = Buffer.concat(blocks).toString('utf8');
|
|
712
461
|
const lines = text.split('\n');
|
|
713
|
-
// The window starts mid-file unless it reached byte zero, so its first line is a fragment of a
|
|
714
|
-
// line whose beginning was not read; it is not an event.
|
|
715
462
|
if (position > 0)
|
|
716
463
|
lines.shift();
|
|
717
464
|
return { lines, truncated: position > 0 || newlines > limit };
|
|
@@ -725,16 +472,6 @@ async function readJournalTail(path, limit) {
|
|
|
725
472
|
await handle?.close().catch(() => { });
|
|
726
473
|
}
|
|
727
474
|
}
|
|
728
|
-
/**
|
|
729
|
-
* Read one run's result and its journal.
|
|
730
|
-
*
|
|
731
|
-
* The slice returned is the *newest* part of the journal, because that is what a detail view is read
|
|
732
|
-
* for — the run's latest activity, with tool calls whose results arrived, rather than the opening
|
|
733
|
-
* events of a run whose outcome the record already reports. Reading starts at the end of the file, so
|
|
734
|
-
* a journal larger than the cap costs what the slice needs and not what the file holds, and
|
|
735
|
-
* `truncated` says older events exist beyond it so a client can label the slice instead of presenting
|
|
736
|
-
* it as the whole journal.
|
|
737
|
-
*/
|
|
738
475
|
export async function readRun(directory, id) {
|
|
739
476
|
const path = runRecordPath(directory, id, 'json');
|
|
740
477
|
const result = JSON.parse(await readFile(path, 'utf8'));
|
|
@@ -749,30 +486,11 @@ export async function readRun(directory, id) {
|
|
|
749
486
|
}
|
|
750
487
|
catch {
|
|
751
488
|
continue;
|
|
752
|
-
}
|
|
489
|
+
}
|
|
753
490
|
}
|
|
754
|
-
// The window may hold one block more than the limit, and a journal whose lines are short can hold
|
|
755
|
-
// many: the newest entries are the ones that stay.
|
|
756
491
|
return { result, events: events.slice(-MAX_RUN_EVENTS), truncated };
|
|
757
492
|
}
|
|
758
|
-
/**
|
|
759
|
-
* Where one run's stored result record lives, and whether it holds a finished trajectory.
|
|
760
|
-
*
|
|
761
|
-
* Saving a trajectory as JSON and showing it in the file manager both need the file itself rather than its
|
|
762
|
-
* contents, and this home is the only thing that knows where its records go — so the answer is the engine's
|
|
763
|
-
* own path plus whether it is actually there. A run whose record was never written, or has since been
|
|
764
|
-
* deleted, is answered with `exists: false` rather than a throw: "there is nothing to save yet" is a control
|
|
765
|
-
* the client holds back, not a failure it reports. The id is validated by the same rule every other run read
|
|
766
|
-
* uses, so a crafted id cannot name a file outside this home's `runs` directory.
|
|
767
|
-
*
|
|
768
|
-
* A running attempt's open record answers `exists: false` as well. The record is written the moment the run
|
|
769
|
-
* starts and finalization rewrites it in place, so its presence is not a trajectory being finished — a copy
|
|
770
|
-
* taken mid-rewrite can be half of two records. The stat alone used to call that file exportable; reading it
|
|
771
|
-
* is what lets the answer match what the document is.
|
|
772
|
-
*/
|
|
773
493
|
export async function runRecordFile(directory, id) {
|
|
774
|
-
// Resolved before it is answered: a home spelled relative to this process's working directory makes
|
|
775
|
-
// record paths only that process can use, and the shell that copies and reveals them is a different one.
|
|
776
494
|
const path = resolve(runRecordPath(directory, id, 'json'));
|
|
777
495
|
let raw;
|
|
778
496
|
try {
|
|
@@ -789,27 +507,13 @@ export async function runRecordFile(directory, id) {
|
|
|
789
507
|
return { path, exists: false };
|
|
790
508
|
}
|
|
791
509
|
catch {
|
|
792
|
-
// Unparsable bytes are a record caught mid-rewrite: not a document to offer, whichever run owns it.
|
|
793
510
|
return { path, exists: false };
|
|
794
511
|
}
|
|
795
512
|
return { path, exists: true };
|
|
796
513
|
}
|
|
797
|
-
/**
|
|
798
|
-
* Where a session's trajectory log lives — the per-session mirror of `runs.files`.
|
|
799
|
-
*
|
|
800
|
-
* A session trajectory is append-only, but an independent shell read while the engine is
|
|
801
|
-
* appending a large JSONL line can end mid-record. Withhold the export action while an open-run
|
|
802
|
-
* claim exists for this session, including a live run in another engine. Finalization flushes
|
|
803
|
-
* the trajectory before clearing the claim, so a finished session becomes available only after
|
|
804
|
-
* all its records are written. The shell additionally guards snapshots against an append that
|
|
805
|
-
* begins after this lookup. Missing files return `exists: false`; genuine I/O failures surface
|
|
806
|
-
* to the caller so it can keep the unrelated run-record controls usable.
|
|
807
|
-
*/
|
|
808
514
|
export async function sessionTrajectoryFile(directory, id) {
|
|
809
515
|
if (typeof id !== 'string' || id.trim() !== id || !/^[\w-]{1,64}$/.test(id))
|
|
810
516
|
throw new Error('Invalid session id');
|
|
811
|
-
// Resolved before it is answered, for the same reason the run record path is: the shell that
|
|
812
|
-
// copies and reveals the file is a different process from this one.
|
|
813
517
|
const path = resolve(join(directory, 'trajectories', `${id}.jsonl`));
|
|
814
518
|
try {
|
|
815
519
|
const info = await stat(path);
|
|
@@ -826,32 +530,10 @@ export async function sessionTrajectoryFile(directory, id) {
|
|
|
826
530
|
throw error;
|
|
827
531
|
}
|
|
828
532
|
}
|
|
829
|
-
/** How many records one page of a session's trajectory log carries. */
|
|
830
533
|
const MAX_TRAJECTORY_PAGE_RECORDS = 500;
|
|
831
|
-
/**
|
|
832
|
-
* How much record data one page carries.
|
|
833
|
-
*
|
|
834
|
-
* Every model request repeats the whole conversation history, so a page measured in records alone
|
|
835
|
-
* would carry the same prompt again and again and grow with the square of the session's length.
|
|
836
|
-
* The bound is under what a linked machine's relay carries, so a page always fits the transport.
|
|
837
|
-
*/
|
|
838
534
|
const MAX_TRAJECTORY_PAGE_BYTES = 8 * 1024 * 1024;
|
|
839
|
-
/**
|
|
840
|
-
* How much one record may carry.
|
|
841
|
-
*
|
|
842
|
-
* A record larger than this is carried as a marker instead of its own content: a page has to fit
|
|
843
|
-
* the transport that carries it, and one record must not be able to make a page that no transport
|
|
844
|
-
* will take.
|
|
845
|
-
*/
|
|
846
535
|
const MAX_TRAJECTORY_RECORD_BYTES = 4 * 1024 * 1024;
|
|
847
|
-
/** How much of the log one read may scan. */
|
|
848
536
|
const MAX_TRAJECTORY_SCAN_BYTES = 256 * 1024 * 1024;
|
|
849
|
-
/**
|
|
850
|
-
* A record's own fields, without the three the log writes on every line.
|
|
851
|
-
*
|
|
852
|
-
* The session id is the log's own name and says nothing about the record, and the type and time are
|
|
853
|
-
* lifted out so a reader can address them without digging through the payload.
|
|
854
|
-
*/
|
|
855
537
|
function normalizeTrajectoryRecord(record) {
|
|
856
538
|
const data = {};
|
|
857
539
|
for (const [key, value] of Object.entries(record)) {
|
|
@@ -861,12 +543,6 @@ function normalizeTrajectoryRecord(record) {
|
|
|
861
543
|
}
|
|
862
544
|
return { type: record.type, time: typeof record.time === 'string' ? record.time : '', data };
|
|
863
545
|
}
|
|
864
|
-
/**
|
|
865
|
-
* A record, with its content held to what a page may carry.
|
|
866
|
-
*
|
|
867
|
-
* A record larger than the page's own bound is carried as a marker: the reader is told a record of
|
|
868
|
-
* that size was there, and the log stays readable and the cursor still moves.
|
|
869
|
-
*/
|
|
870
546
|
function boundedRecord(record, size) {
|
|
871
547
|
const bounded = normalizeTrajectoryRecord(record);
|
|
872
548
|
if (size <= MAX_TRAJECTORY_RECORD_BYTES)
|
|
@@ -878,26 +554,13 @@ function boundedRecord(record, size) {
|
|
|
878
554
|
};
|
|
879
555
|
return bounded;
|
|
880
556
|
}
|
|
881
|
-
/** How much of a line's head is kept, to read the type and the time the line was written with. */
|
|
882
557
|
const MAX_TRAJECTORY_LINE_HEAD_BYTES = 4 * 1024;
|
|
883
|
-
/**
|
|
884
|
-
* A log's lines, read without holding a line that is over the bound.
|
|
885
|
-
*
|
|
886
|
-
* `readline` hands a reader the whole line at once, so a log holding one enormous record would
|
|
887
|
-
* have that record materialised before anything could refuse it. The bytes are counted as they
|
|
888
|
-
* stream by, and a line over the bound is measured and dropped rather than held whole: the reader
|
|
889
|
-
* is told how big the line was, and the log stays readable.
|
|
890
|
-
*/
|
|
891
558
|
async function* readTrajectoryLines(stream) {
|
|
892
|
-
/** The bytes of the line being read, while it is small enough to hold. */
|
|
893
559
|
let held = [];
|
|
894
560
|
let heldBytes = 0;
|
|
895
|
-
/** The head of the line: the type and the time are written first, and they are all that is kept. */
|
|
896
561
|
let head = '';
|
|
897
|
-
/** The size of the line being read. */
|
|
898
562
|
let size = 0;
|
|
899
563
|
let oversized = false;
|
|
900
|
-
/** Take a piece of the line being read. */
|
|
901
564
|
const take = (segment) => {
|
|
902
565
|
size += segment.length;
|
|
903
566
|
if (head.length < MAX_TRAJECTORY_LINE_HEAD_BYTES) {
|
|
@@ -913,7 +576,6 @@ async function* readTrajectoryLines(stream) {
|
|
|
913
576
|
}
|
|
914
577
|
held.push(segment);
|
|
915
578
|
};
|
|
916
|
-
/** The line as it stands; the next one starts empty. */
|
|
917
579
|
const takeLine = () => {
|
|
918
580
|
const line = { text: oversized ? '' : Buffer.concat(held).toString('utf8'), head, size, oversized };
|
|
919
581
|
held = [];
|
|
@@ -937,44 +599,12 @@ async function* readTrajectoryLines(stream) {
|
|
|
937
599
|
if (tail.length > 0)
|
|
938
600
|
take(tail);
|
|
939
601
|
}
|
|
940
|
-
// A last line the writer never ended is a torn record: the log is read while it is being
|
|
941
|
-
// appended to, and a record that is not terminated was not finished. It is left out rather than
|
|
942
|
-
// read as a record that may be removed a moment later.
|
|
943
602
|
}
|
|
944
|
-
/**
|
|
945
|
-
* A record too large to carry, told from the head of its line.
|
|
946
|
-
*
|
|
947
|
-
* The log writes the type and the time first, so the head of an enormous line still says what it
|
|
948
|
-
* was. A line that does not say is reported as an oversized record of its own.
|
|
949
|
-
*/
|
|
950
603
|
function oversizedRecord(head, size) {
|
|
951
604
|
const type = /^\s*\{\s*"type"\s*:\s*"([^"]*)"/.exec(head)?.[1] ?? 'oversized';
|
|
952
605
|
const time = /^\s*\{\s*"type"\s*:\s*"[^"]*"\s*,\s*"time"\s*:\s*"([^"]*)"/.exec(head)?.[1] ?? '';
|
|
953
606
|
return { type, time, data: { oversized: true, bytes: size, note: 'The record is larger than a page can carry, so only its size is shown.' } };
|
|
954
607
|
}
|
|
955
|
-
/**
|
|
956
|
-
* Read one page of a session's trajectory log.
|
|
957
|
-
*
|
|
958
|
-
* The log is the session's own debug file: every run and every resume appends to it, so it holds the
|
|
959
|
-
* whole conversation — each prompt, each model call, each runtime event, in the order they happened.
|
|
960
|
-
* A client reads it the way it reads a long document, one page at a time, and the page says how much
|
|
961
|
-
* of the log it did not carry so the reader can say so rather than present a slice as the whole.
|
|
962
|
-
*
|
|
963
|
-
* The records are read in the order the log wrote them, from the beginning: a debugging reader wants
|
|
964
|
-
* the first prompt as much as the last one. The scan continues past the page to count what the log
|
|
965
|
-
* holds, so the reader can say "record 200 of 3,412" instead of guessing.
|
|
966
|
-
*
|
|
967
|
-
* The page's position in the log is a **line**, and the page answers with the line the next one
|
|
968
|
-
* starts at. A reader that asked for a page past the end of what one read can cover is answered
|
|
969
|
-
* from where the last page stopped rather than from the beginning, so the rest of a long log stays
|
|
970
|
-
* reachable page by page.
|
|
971
|
-
*
|
|
972
|
-
* A log that is still being appended to is read as it stands. The engine never rewrites one, so a
|
|
973
|
-
* record that is half-written is a torn line and is skipped rather than guessed at.
|
|
974
|
-
*
|
|
975
|
-
* `folder` names which of the home's logs to read: the engine's `trajectories`, or the
|
|
976
|
-
* `browser-trajectories` the CLI's browser workspace records its own runs to.
|
|
977
|
-
*/
|
|
978
608
|
export async function readSessionTrajectory(directory, id, offset, limit, folder = 'trajectories') {
|
|
979
609
|
const path = resolve(join(directory, folder, `${id}.jsonl`));
|
|
980
610
|
const start = typeof offset === 'number' && Number.isInteger(offset) && offset > 0 ? offset : 0;
|
|
@@ -985,9 +615,7 @@ export async function readSessionTrajectory(directory, id, offset, limit, folder
|
|
|
985
615
|
let carried = 0;
|
|
986
616
|
let scanned = 0;
|
|
987
617
|
let line = 0;
|
|
988
|
-
/** The line the next page starts at: the line after the last record this page carries. */
|
|
989
618
|
let next = start;
|
|
990
|
-
/** The records the log holds past the page. */
|
|
991
619
|
let after = 0;
|
|
992
620
|
let full = false;
|
|
993
621
|
let truncated = false;
|
|
@@ -998,14 +626,6 @@ export async function readSessionTrajectory(directory, id, offset, limit, folder
|
|
|
998
626
|
for await (const entry of readTrajectoryLines(stream)) {
|
|
999
627
|
line += 1;
|
|
1000
628
|
const size = entry.size;
|
|
1001
|
-
// The budget covers the tail the reader asked for, not the way to it: a page past the
|
|
1002
|
-
// budget is still served, because the way to it has to be read either way. A budget that
|
|
1003
|
-
// stopped the scan before the cursor would leave the rest of the log unreachable.
|
|
1004
|
-
/**
|
|
1005
|
-
* Carry a record too large to hold as its size.
|
|
1006
|
-
*
|
|
1007
|
-
* The log stays readable and the cursor still moves, and the line was never held whole.
|
|
1008
|
-
*/
|
|
1009
629
|
const carryOversized = () => {
|
|
1010
630
|
total += 1;
|
|
1011
631
|
if (line <= start)
|
|
@@ -1028,9 +648,6 @@ export async function readSessionTrajectory(directory, id, offset, limit, folder
|
|
|
1028
648
|
if (line > start) {
|
|
1029
649
|
scanned += size;
|
|
1030
650
|
if (scanned > MAX_TRAJECTORY_SCAN_BYTES) {
|
|
1031
|
-
// The scan stopped here. The cursor moves past the line it stopped at, so the next
|
|
1032
|
-
// read starts after it instead of asking for the same place for ever. A record too
|
|
1033
|
-
// large to hold is still told about, so a large model request does not disappear.
|
|
1034
651
|
if (entry.oversized)
|
|
1035
652
|
carryOversized();
|
|
1036
653
|
truncated = true;
|
|
@@ -1052,23 +669,19 @@ export async function readSessionTrajectory(directory, id, offset, limit, folder
|
|
|
1052
669
|
}
|
|
1053
670
|
catch {
|
|
1054
671
|
continue;
|
|
1055
|
-
}
|
|
672
|
+
}
|
|
1056
673
|
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
1057
674
|
continue;
|
|
1058
675
|
const record = parsed;
|
|
1059
676
|
if (typeof record.type !== 'string')
|
|
1060
677
|
continue;
|
|
1061
678
|
total += 1;
|
|
1062
|
-
// Before the cursor the log is only counted, and past the page it is only counted: the
|
|
1063
|
-
// reader asked for a window, and the count is what tells it how much it left out.
|
|
1064
679
|
if (line <= start)
|
|
1065
680
|
continue;
|
|
1066
681
|
if (full) {
|
|
1067
682
|
after += 1;
|
|
1068
683
|
continue;
|
|
1069
684
|
}
|
|
1070
|
-
// A record larger than the page budget still goes on the page: a page that carried
|
|
1071
|
-
// nothing would leave the reader asking for the same offset for ever.
|
|
1072
685
|
if (records.length > 0 && carried + size > MAX_TRAJECTORY_PAGE_BYTES) {
|
|
1073
686
|
full = true;
|
|
1074
687
|
after += 1;
|
|
@@ -1094,20 +707,10 @@ export async function readSessionTrajectory(directory, id, offset, limit, folder
|
|
|
1094
707
|
}
|
|
1095
708
|
return {
|
|
1096
709
|
path, exists, offset: start, nextOffset: next, count: records.length, total, records,
|
|
1097
|
-
// The log holds more past this page when the scan found records there, or when the scan
|
|
1098
|
-
// stopped before it could say.
|
|
1099
710
|
hasMore: after > 0 || truncated,
|
|
1100
711
|
truncated,
|
|
1101
712
|
};
|
|
1102
713
|
}
|
|
1103
|
-
/**
|
|
1104
|
-
* One line describing a configured MCP server, without anything that authenticates it.
|
|
1105
|
-
*
|
|
1106
|
-
* A stdio command line can carry `--token <value>` and an HTTP URL can carry a query string; both are
|
|
1107
|
-
* permitted by the configuration schema, and both reach this renderer's Settings view. Only the
|
|
1108
|
-
* command itself and the URL's scheme, host, and path are reported, matching the deliberate omission
|
|
1109
|
-
* of MCP environment and header values.
|
|
1110
|
-
*/
|
|
1111
714
|
export function summarizeMcpServer(server) {
|
|
1112
715
|
if (server.transport === 'stdio')
|
|
1113
716
|
return server.command;
|
|
@@ -1119,11 +722,8 @@ export function summarizeMcpServer(server) {
|
|
|
1119
722
|
return '';
|
|
1120
723
|
}
|
|
1121
724
|
}
|
|
1122
|
-
/** Installed skills, plugins, and configured MCP servers. Secrets in env/headers are never included. */
|
|
1123
725
|
export async function listExtensions(config, signal, directory) {
|
|
1124
726
|
const map = (entry) => ({ id: entry.id, name: entry.name, description: entry.description, enabled: entry.enabled, ...(entry.unavailable ? { unavailable: true } : {}), ...(entry.repository ? { repository: entry.repository } : {}), ...(entry.relativePath === undefined ? {} : { relativePath: entry.relativePath }), ...(entry.command ? { command: entry.command } : {}) });
|
|
1125
|
-
// Discovery stops at its own bound, and the notice it produces is the only thing that says so: a
|
|
1126
|
-
// client that showed the list without it would present a capped catalogue as the whole installation.
|
|
1127
727
|
const notices = [];
|
|
1128
728
|
const [skills, plugins] = await Promise.all([
|
|
1129
729
|
listBundles('skills', config, { signal, notices, directory }),
|
|
@@ -1131,8 +731,6 @@ export async function listExtensions(config, signal, directory) {
|
|
|
1131
731
|
]);
|
|
1132
732
|
return {
|
|
1133
733
|
skills: skills.map(map),
|
|
1134
|
-
// Andorra's own skills, for the composer's slash menu only: Settings lists what is installed, and
|
|
1135
|
-
// these can be neither removed nor turned off.
|
|
1136
734
|
builtinSkills: builtinSkillEntries(skills).map(skill => ({ id: skill.id, name: skill.name, description: skill.description, enabled: true, command: skill.command,
|
|
1137
735
|
repository: { id: 'andorra', name: 'Built-in', source: 'andorra', path: '' } })),
|
|
1138
736
|
plugins: plugins.map(map),
|