@andorra-labs/code 0.1.12 → 0.1.14
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/dist/src/account-presentation.d.ts +1 -37
- package/dist/src/account-presentation.js +6 -43
- 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 +347 -554
- 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 +11 -155
- 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/andorra/endpoint.d.ts +7 -0
- package/dist/src/andorra/endpoint.js +46 -0
- package/dist/src/andorra/entry.d.ts +21 -0
- package/dist/src/andorra/entry.js +100 -0
- package/dist/src/andorra/errors.d.ts +2 -0
- package/dist/src/andorra/errors.js +39 -0
- package/dist/src/andorra/hosted.d.ts +52 -0
- package/dist/src/andorra/hosted.js +126 -0
- package/dist/src/andorra/monitor.d.ts +151 -0
- package/dist/src/andorra/monitor.js +393 -0
- package/dist/src/andorra/notices.d.ts +7 -0
- package/dist/src/andorra/notices.js +15 -0
- package/dist/src/andorra/opt-in.d.ts +58 -0
- package/dist/src/andorra/opt-in.js +112 -0
- package/dist/src/andorra/request-watch.d.ts +6 -0
- package/dist/src/andorra/request-watch.js +10 -0
- package/dist/src/andorra/state.d.ts +86 -0
- package/dist/src/andorra/state.js +238 -0
- package/dist/src/andorra/terminal.d.ts +68 -0
- package/dist/src/andorra/terminal.js +125 -0
- package/dist/src/andorra/usage-format.d.ts +9 -0
- package/dist/src/andorra/usage-format.js +19 -0
- 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 +9 -29
- package/dist/src/app-server/protocol.d.ts +18 -246
- 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 +52 -925
- package/dist/src/app-server.js +828 -3076
- 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 +9 -93
- package/dist/src/auth/AuthManager.js +164 -186
- 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 +1 -16
- package/dist/src/auth/deployment.js +1 -16
- package/dist/src/auth/index.d.ts +1 -12
- package/dist/src/auth/index.js +1 -12
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +33 -108
- package/dist/src/auth/store.js +55 -130
- 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 +1 -37
- package/dist/src/browser-panel-tool.js +3 -73
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +5 -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 +19 -13
- package/dist/src/browser-stealth.js +22 -38
- 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 +15 -97
- package/dist/src/browser-view.d.ts +106 -295
- package/dist/src/browser-view.js +551 -587
- 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 +155 -63
- 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 +1 -55
- package/dist/src/cli.js +118 -742
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
- 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 +0 -28
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +4 -26
- package/dist/src/coding-tools.js +161 -181
- 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 +41 -1
- package/dist/src/command-screens.js +316 -113
- package/dist/src/commands.d.ts +12 -63
- package/dist/src/commands.js +98 -127
- package/dist/src/completion-gates.d.ts +0 -47
- package/dist/src/completion-gates.js +0 -14
- package/dist/src/completion.d.ts +0 -98
- package/dist/src/completion.js +2 -239
- package/dist/src/config.d.ts +15 -115
- package/dist/src/config.js +123 -172
- 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 +2 -2
- package/dist/src/dashboard-view.js +11 -37
- 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 +2 -6
- 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 +1 -2
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +1 -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 +4 -130
- package/dist/src/diff-preview.d.ts +0 -1
- package/dist/src/diff-preview.js +0 -17
- 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 +0 -9
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +63 -35
- 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 +0 -7
- package/dist/src/file-read-key.js +0 -7
- 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 +0 -3
- package/dist/src/graph-health.d.ts +9 -61
- package/dist/src/graph-health.js +34 -59
- package/dist/src/graph-manager-chat.d.ts +36 -153
- package/dist/src/graph-manager-chat.js +161 -182
- 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 +58 -391
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +2 -15
- package/dist/src/graph-server.d.ts +2 -10
- package/dist/src/graph-server.js +39 -101
- 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 +176 -492
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +0 -48
- 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 +0 -8
- 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 +1 -78
- package/dist/src/graph-ui/manager.css +0 -18
- package/dist/src/graph-ui/manager.js +43 -185
- package/dist/src/graph-ui/model-picker.js +0 -29
- 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 +16 -136
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +19 -118
- package/dist/src/graphs.d.ts +6 -157
- package/dist/src/graphs.js +66 -269
- 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 +9 -47
- 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 +0 -99
- package/dist/src/mcp.js +4 -170
- package/dist/src/membership-errors.d.ts +0 -14
- package/dist/src/membership-errors.js +1 -14
- package/dist/src/membership.d.ts +9 -59
- package/dist/src/membership.js +20 -91
- 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 +5 -40
- package/dist/src/memory/ProjectMemory.js +22 -47
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- 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-context-windows.d.ts +2 -0
- package/dist/src/model-context-windows.js +24 -0
- package/dist/src/model-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +2 -50
- package/dist/src/model-metadata.d.ts +1 -18
- package/dist/src/model-metadata.js +42 -45
- 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 +1 -16
- package/dist/src/package-name.d.ts +0 -2
- package/dist/src/package-name.js +0 -2
- package/dist/src/paged-transcript.d.ts +0 -11
- package/dist/src/paged-transcript.js +2 -20
- package/dist/src/palette.d.ts +1 -63
- package/dist/src/palette.js +1 -64
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +17 -21
- 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 +15 -39
- package/dist/src/provider-engine.d.ts +0 -21
- package/dist/src/provider-engine.js +1 -96
- 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 +16 -3
- package/dist/src/provider-settings.js +36 -52
- package/dist/src/providers.d.ts +14 -219
- package/dist/src/providers.js +69 -326
- 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 +1 -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 +107 -422
- 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 +0 -18
- package/dist/src/remote/cert.js +0 -44
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +1 -116
- 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 +22 -339
- 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 +0 -4
- package/dist/src/remote/pem.js +0 -4
- 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 +2 -9
- package/dist/src/run-control.js +9 -13
- 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 +14 -687
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +12 -228
- package/dist/src/runtime.js +2 -128
- 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 +3 -122
- 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 +0 -39
- package/dist/src/sign-in-detection.js +0 -43
- package/dist/src/sign-in-offer.d.ts +1 -19
- package/dist/src/sign-in-offer.js +0 -13
- 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/errors.md +1 -1
- package/dist/src/skills/bundled/provenance.json +738 -738
- 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 +0 -13
- package/dist/src/skills/runtime-skills.js +0 -37
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +0 -9
- package/dist/src/stray-files.js +0 -16
- package/dist/src/structured-step.d.ts +0 -22
- package/dist/src/structured-step.js +0 -22
- package/dist/src/subagent-run.d.ts +2 -163
- package/dist/src/subagent-run.js +18 -376
- 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 +3 -84
- 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 +33 -521
- package/dist/src/terminal-ui.js +145 -884
- 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 +0 -7
- 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 +0 -6
- package/dist/src/tool-schema-compatibility.js +0 -9
- 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 +0 -41
- package/dist/src/transcript.js +5 -60
- package/dist/src/types.d.ts +4 -168
- package/dist/src/untracked-file-removal.js +0 -20
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +1 -15
- package/dist/src/update.d.ts +0 -35
- package/dist/src/update.js +0 -100
- 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 +0 -16
- package/dist/src/workspace-git-metadata.js +0 -21
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +6 -19
- package/package.json +13 -2
|
@@ -4,147 +4,60 @@ import { loadConfig } from '../config.js';
|
|
|
4
4
|
import { reconcileInterruptedRuns } from '../run-records.js';
|
|
5
5
|
import { configuredSurface, reportInterruptedRuns } from '../telemetry/surface.js';
|
|
6
6
|
import { authorizedRoots } from './roots.js';
|
|
7
|
-
/**
|
|
8
|
-
* The engine relay: the host side of full-owner remote access.
|
|
9
|
-
*
|
|
10
|
-
* A paired window is a full client of this machine's engine surface, so someone has to stand between
|
|
11
|
-
* the pairing listener and the engine pool the product describes (ADR 0017): a browsing engine that
|
|
12
|
-
* answers sessions, run records, workspace reads and terminals, plus one child engine per concurrent
|
|
13
|
-
* task. That coordinator is this module, and it lives in the process that owns the listener — the
|
|
14
|
-
* desktop's primary engine, or a standalone `andorra remote serve`. It spawns its own children with
|
|
15
|
-
* the same `app-server --stdio` wire every other client speaks, so a headless host and a desktop host
|
|
16
|
-
* serve the identical surface.
|
|
17
|
-
*
|
|
18
|
-
* Nothing here decides authority: the endpoints in `server.ts` admit a request only for a full-grant
|
|
19
|
-
* device over TLS, and this module assumes that check has run. Revocation is still enforced live — a
|
|
20
|
-
* poller re-reads the device table and cuts a revoked device's event stream and terminals, because a
|
|
21
|
-
* long-lived stream is exactly the resource a per-request authentication check cannot see.
|
|
22
|
-
*
|
|
23
|
-
* Client-lifetime resources are namespaced per connection: terminal ids are prefixed with the
|
|
24
|
-
* connection that opened them, their output is delivered only to that connection, and a closeAll from
|
|
25
|
-
* one connection sweeps only its own shells. Run ownership is host-wide (the runs belong to this
|
|
26
|
-
* machine), so run and prompt routing is by runId and engine id across all children.
|
|
27
|
-
*/
|
|
28
|
-
/** The engine a paired client addresses for everything that is not one task's run. */
|
|
29
7
|
export const REMOTE_PRIMARY_ENGINE = 'remote-primary';
|
|
30
|
-
/**
|
|
31
|
-
* The capability that says this relay understands a capability requirement.
|
|
32
|
-
*
|
|
33
|
-
* It lives here, with the implementation that honours it, and not in the app-server's shared
|
|
34
|
-
* capability list: the server loads that list lazily, so a build whose files were replaced under
|
|
35
|
-
* a running relay would advertise a capability the relay in memory does not have — and a client
|
|
36
|
-
* that trusted it would send a requirement the old relay forwards to a child that ignores it.
|
|
37
|
-
*/
|
|
38
8
|
export const RELAY_CAPABILITY_REQUIREMENT = 'remote.engine.relay.capability';
|
|
39
9
|
const TASK_PREFIX = 'remote-task-';
|
|
40
|
-
/** How many task engines the relay will run at once, besides the browsing engine. */
|
|
41
10
|
const MAX_RELAY_ENGINES = 9;
|
|
42
|
-
/** How many of a child's newest stderr lines are kept, for the message when it dies. */
|
|
43
11
|
const CHILD_STDERR_LINES = 50;
|
|
44
|
-
/** A child that never completes its handshake is not an engine; the start fails after this. */
|
|
45
12
|
const CHILD_READY_TIMEOUT_MS = 60_000;
|
|
46
|
-
/** How long a graceful child stop may take before the kill backstop fires. */
|
|
47
13
|
const CHILD_STOP_GRACE_MS = 20_000;
|
|
48
|
-
/**
|
|
49
|
-
* The wall-clock a relayed request gives the child, over what the viewer asked for.
|
|
50
|
-
*
|
|
51
|
-
* The viewer's own client times out at exactly the deadline it sent; this slack is what keeps the
|
|
52
|
-
* relay from racing that timer, so the failure the desktop reports is its own timeout with its own
|
|
53
|
-
* pending-entry cleanup, not a second, earlier one from under the link.
|
|
54
|
-
*/
|
|
55
14
|
const CHILD_DEADLINE_SLACK_MS = 5_000;
|
|
56
15
|
const MAX_CHILD_DEADLINE_MS = 300_000;
|
|
57
|
-
/**
|
|
58
|
-
* The ceiling for methods whose own work is allowed to be slow. The browser installer is bounded by
|
|
59
|
-
* its own twenty-minute timer and the viewer grants it 21 minutes; the short ceiling would cut that
|
|
60
|
-
* budget off under the link and fail a call the peer was still completing.
|
|
61
|
-
*/
|
|
62
16
|
const LONG_DEADLINE_METHODS = new Set(['browser.runtime.install']);
|
|
63
17
|
const MAX_LONG_CHILD_DEADLINE_MS = 1_260_000;
|
|
64
|
-
/** How often a live connection's device is re-checked against the configuration. */
|
|
65
18
|
const REVOCATION_POLL_MS = 5_000;
|
|
66
|
-
/**
|
|
67
|
-
* How long a connection may exist with no event stream before the relay retires it.
|
|
68
|
-
*
|
|
69
|
-
* `remote.engine.connect` answers before its SSE GET lands, and a viewer can unload in between: a
|
|
70
|
-
* connection created only by requests would otherwise keep its terminals and never be swept, since
|
|
71
|
-
* the response-close callback that ends it exists only on the stream. The same TTL now also bounds
|
|
72
|
-
* a retryable stream loss: the shells survive the seconds a reconnect takes, and only an abandoned
|
|
73
|
-
* connection reaches the poller's sweep.
|
|
74
|
-
*/
|
|
75
19
|
const SINKLESS_CONNECTION_TTL_MS = 30_000;
|
|
76
|
-
/**
|
|
77
|
-
* How long a run's completion is kept for a reconnecting viewer.
|
|
78
|
-
*
|
|
79
|
-
* A run that finished while its viewer's stream was down is not active any more — replaying its
|
|
80
|
-
* start would show it working forever — so the completion itself is what the replacement stream
|
|
81
|
-
* receives, for as long as a viewer that saw the start could still be reconnecting.
|
|
82
|
-
*/
|
|
83
20
|
const FINISHED_RUN_TTL_MS = 5 * 60_000;
|
|
84
|
-
/** How many recent completions are kept, per the TTL above. */
|
|
85
21
|
const FINISHED_RUNS_REMEMBERED = 8;
|
|
86
|
-
/**
|
|
87
|
-
* What a relayed response may weigh. The viewer's transport caps at 2 MiB by default; the methods a
|
|
88
|
-
* local window displays in megabytes — a journal tail, a diff — get the larger bound the product
|
|
89
|
-
* contract asks for, and anything past its bound is an error the window can name.
|
|
90
|
-
*/
|
|
91
22
|
const MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
92
23
|
const MAX_LARGE_RESPONSE_BYTES = 12 * 1024 * 1024;
|
|
93
24
|
const LARGE_RESPONSE_METHODS = new Set(['runs.get', 'workspace.diff', 'workspace.git', 'sessions.trajectory', 'browser.view.selection', 'attachments.read', 'sessions.changes.list', 'sessions.changes.get']);
|
|
94
|
-
/** Methods a paired client may ask the browsing engine (and only the browsing engine). */
|
|
95
25
|
const PRIMARY_METHODS = new Set([
|
|
96
|
-
'sessions.list', 'sessions.get', 'sessions.create', 'sessions.rename', 'sessions.setArchived', 'sessions.delete',
|
|
26
|
+
'sessions.list', 'sessions.get', 'sessions.create', 'sessions.rename', 'sessions.setJev', 'sessions.setArchived', 'sessions.delete',
|
|
97
27
|
'sessions.trajectory',
|
|
98
|
-
// The skill a slash invocation left active on that machine's session: the Plan card shows it and
|
|
99
|
-
// pauses, resumes or removes it there, since the session's later runs start there too.
|
|
100
28
|
'sessions.skill.get', 'sessions.skill.update',
|
|
101
|
-
|
|
102
|
-
// stored originals are on that machine, and every engine sharing its home can read and change the record.
|
|
29
|
+
'sessions.pullRequest.list',
|
|
103
30
|
'sessions.changes.list', 'sessions.changes.get', 'sessions.changes.keep', 'sessions.changes.undo',
|
|
104
31
|
'runs.list', 'runs.get', 'timers.list',
|
|
105
32
|
'workspace.tree', 'workspace.read', 'workspace.git', 'workspace.branches', 'workspace.checkout', 'workspace.diff',
|
|
106
33
|
'graphs.list', 'graphs.get', 'graphs.select',
|
|
107
|
-
// The attachment chips of a browsed session name files spooled on the machine that owns the
|
|
108
|
-
// session, so the preview asks that machine's engine for the bytes.
|
|
109
34
|
'attachments.read',
|
|
110
|
-
'config.get', 'projects.list', 'projects.add', 'projects.remove',
|
|
111
|
-
|
|
112
|
-
'extensions.list',
|
|
113
|
-
// The session browser panel lives on the machine that owns the session, so a
|
|
114
|
-
// paired window's pane asks that machine's browsing engine for both the
|
|
115
|
-
// runtime and the pages. Without these entries a full-grant link refuses
|
|
116
|
-
// every panel call as unknown-method.
|
|
35
|
+
'config.get', 'projects.list', 'projects.add', 'projects.remove', 'projects.relink',
|
|
36
|
+
'extensions.list', 'project.extensions',
|
|
117
37
|
'browser.runtime.status', 'browser.runtime.install',
|
|
118
38
|
'browser.view.status', 'browser.view.open', 'browser.view.navigate', 'browser.view.go', 'browser.view.activate',
|
|
119
|
-
'browser.view.closeTab', 'browser.view.stream', 'browser.view.input', 'browser.view.selection',
|
|
39
|
+
'browser.view.closeTab', 'browser.view.show', 'browser.view.hide', 'browser.view.stream', 'browser.view.input', 'browser.view.selection',
|
|
120
40
|
'browser.view.release', 'browser.view.cursor',
|
|
121
|
-
// A paired window's import reads the Firefox of the machine that owns the browser.
|
|
122
41
|
'browser.cookies.sources', 'browser.cookies.import',
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
42
|
+
'browser.extensions.list', 'browser.extensions.sources', 'browser.extensions.prepare', 'browser.extensions.commit',
|
|
43
|
+
'browser.extensions.discard', 'browser.extensions.remove', 'browser.extensions.setEnabled', 'browser.extensions.reload',
|
|
44
|
+
'browser.extensions.restart',
|
|
126
45
|
'browser.panel.op', 'browser.panel.cancel',
|
|
127
46
|
]);
|
|
128
|
-
/** Methods that start a run, on an engine of the pool's choosing. */
|
|
129
47
|
const RUN_START_METHODS = new Set(['run.start', 'run.resume']);
|
|
130
|
-
/** Methods that answer for one run, addressed to the child that owns it. */
|
|
131
48
|
const RUN_TARGET_METHODS = new Set(['run.setModel', 'run.setPermissions', 'run.cancel', 'run.steer', 'run.approve', 'run.answer', 'browser.panel.result']);
|
|
132
|
-
/** Methods handled by the namespacing layer rather than forwarded verbatim. */
|
|
133
49
|
const TERMINAL_METHODS = new Set(['terminal.open', 'terminal.write', 'terminal.resize', 'terminal.close', 'terminal.closeAll']);
|
|
134
50
|
const ALLOWED_METHODS = new Set([...PRIMARY_METHODS, ...RUN_START_METHODS, ...RUN_TARGET_METHODS, ...TERMINAL_METHODS]);
|
|
135
|
-
|
|
136
|
-
const SESSION_MUTATION_METHODS = new Set(['sessions.rename', 'sessions.setArchived', 'sessions.delete']);
|
|
137
|
-
/** Calls whose effect must land inside the caller's own deadline, not past it. */
|
|
51
|
+
const SESSION_MUTATION_METHODS = new Set(['sessions.rename', 'sessions.setJev', 'sessions.setArchived', 'sessions.delete']);
|
|
138
52
|
const MUTATING_METHODS = new Set([
|
|
139
53
|
...RUN_START_METHODS, ...RUN_TARGET_METHODS, ...SESSION_MUTATION_METHODS, 'sessions.skill.update', 'sessions.changes.keep', 'sessions.changes.undo',
|
|
140
|
-
'terminal.open', 'terminal.write', 'terminal.close', 'terminal.closeAll', 'workspace.checkout', 'projects.add', 'projects.remove',
|
|
141
|
-
// Panel calls act on the peer's browser immediately; an install outlives the
|
|
142
|
-
// relay's default child deadline, so it keeps the caller's own budget.
|
|
54
|
+
'terminal.open', 'terminal.write', 'terminal.close', 'terminal.closeAll', 'workspace.checkout', 'projects.add', 'projects.remove', 'projects.relink',
|
|
143
55
|
'browser.runtime.install', 'browser.view.open', 'browser.view.navigate', 'browser.view.go', 'browser.view.activate',
|
|
144
|
-
'browser.view.closeTab', 'browser.view.stream', 'browser.view.input', 'browser.cookies.import',
|
|
56
|
+
'browser.view.closeTab', 'browser.view.show', 'browser.view.hide', 'browser.view.stream', 'browser.view.input', 'browser.cookies.import',
|
|
145
57
|
'browser.panel.op', 'browser.panel.cancel',
|
|
58
|
+
'browser.extensions.commit', 'browser.extensions.discard', 'browser.extensions.remove', 'browser.extensions.setEnabled',
|
|
59
|
+
'browser.extensions.reload', 'browser.extensions.restart',
|
|
146
60
|
]);
|
|
147
|
-
/** A child's failure, with the wire code it answered with — `engine-busy` decides pool selection. */
|
|
148
61
|
class ChildError extends Error {
|
|
149
62
|
code;
|
|
150
63
|
constructor(code, message) {
|
|
@@ -152,11 +65,6 @@ class ChildError extends Error {
|
|
|
152
65
|
this.code = code;
|
|
153
66
|
}
|
|
154
67
|
}
|
|
155
|
-
/**
|
|
156
|
-
* The only refusal type the relay raises on its own. A code from the engine's vocabulary survives
|
|
157
|
-
* the trip (the desktop branches on `engine-busy`, `nothing-to-continue`); an unrecognized peer
|
|
158
|
-
* string is never rethrown as a code.
|
|
159
|
-
*/
|
|
160
68
|
class RelayRefusal extends Error {
|
|
161
69
|
code;
|
|
162
70
|
constructor(code, message) {
|
|
@@ -172,7 +80,6 @@ function relayError(error) {
|
|
|
172
80
|
}
|
|
173
81
|
return { code: 'remote', message: error instanceof Error ? error.message : String(error) };
|
|
174
82
|
}
|
|
175
|
-
/** One spawned `app-server`, speaking the newline JSON wire. */
|
|
176
83
|
class ChildEngine {
|
|
177
84
|
id;
|
|
178
85
|
onEvent;
|
|
@@ -184,11 +91,8 @@ class ChildEngine {
|
|
|
184
91
|
resolveReady;
|
|
185
92
|
rejectReady;
|
|
186
93
|
stopped = false;
|
|
187
|
-
/** Whether a run owns this child; learned from its own run lifecycle events. */
|
|
188
94
|
busy = false;
|
|
189
|
-
/** The capabilities the child advertised in its handshake. */
|
|
190
95
|
advertised = [];
|
|
191
|
-
/** The child's newest stderr lines: an engine that dies should say what it last said. */
|
|
192
96
|
stderrTail = [];
|
|
193
97
|
constructor(id, command, home, onEvent, onExit) {
|
|
194
98
|
this.id = id;
|
|
@@ -197,7 +101,6 @@ class ChildEngine {
|
|
|
197
101
|
this.child = spawn(command[0], command.slice(1), {
|
|
198
102
|
windowsHide: true,
|
|
199
103
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
200
|
-
// The relayed child cannot see the window that drives it, so it is told which surface it is.
|
|
201
104
|
env: { ...process.env, ANDORRACODE_HOME: home, ANDORRA_SURFACE: 'remote' },
|
|
202
105
|
});
|
|
203
106
|
this.ready = new Promise((resolve, reject) => {
|
|
@@ -210,8 +113,6 @@ class ChildEngine {
|
|
|
210
113
|
const last = this.stderrTail[this.stderrTail.length - 1];
|
|
211
114
|
this.fail(new Error(`Engine ${id} exited.${last !== undefined ? ` Last output: ${last.slice(0, 300)}` : ''}`));
|
|
212
115
|
});
|
|
213
|
-
// A child's stderr must be drained even though nothing forwards it yet: an unread pipe fills,
|
|
214
|
-
// and a task that writes enough diagnostics would then block on its own logging and hang.
|
|
215
116
|
if (this.child.stderr) {
|
|
216
117
|
createInterface({ input: this.child.stderr }).on('line', line => {
|
|
217
118
|
if (!line.trim())
|
|
@@ -227,9 +128,6 @@ class ChildEngine {
|
|
|
227
128
|
this.fail(new Error(`Engine ${id} started without a usable pipe.`));
|
|
228
129
|
return;
|
|
229
130
|
}
|
|
230
|
-
// A write that fails asynchronously — EPIPE after the child died between the liveness check and
|
|
231
|
-
// the write — is emitted as an 'error' event on stdin, not thrown; unhandled it would terminate
|
|
232
|
-
// the whole relay process instead of failing this engine.
|
|
233
131
|
stdin.on('error', error => this.fail(new Error(`Engine ${id} lost its input: ${error.message}`)));
|
|
234
132
|
createInterface({ input: stdout }).on('line', line => {
|
|
235
133
|
if (!line.trim())
|
|
@@ -243,8 +141,6 @@ class ChildEngine {
|
|
|
243
141
|
}
|
|
244
142
|
if (typeof parsed.event === 'string') {
|
|
245
143
|
if (parsed.event === 'ready') {
|
|
246
|
-
// The handshake is what says what this child can do, and the pool routes by it: a child
|
|
247
|
-
// that predates a feature answers the request and silently ignores the parameter.
|
|
248
144
|
const capabilities = parsed.data?.capabilities;
|
|
249
145
|
this.advertised = Array.isArray(capabilities) ? capabilities.filter((entry) => typeof entry === 'string') : [];
|
|
250
146
|
this.resolveReady?.();
|
|
@@ -280,7 +176,6 @@ class ChildEngine {
|
|
|
280
176
|
this.child.kill();
|
|
281
177
|
this.onExit(this.id);
|
|
282
178
|
}
|
|
283
|
-
/** Whether this child advertised a capability in its handshake. */
|
|
284
179
|
supports(capability) {
|
|
285
180
|
return this.advertised.includes(capability);
|
|
286
181
|
}
|
|
@@ -298,8 +193,6 @@ class ChildEngine {
|
|
|
298
193
|
this.pending.set(id, { resolve, reject, timer });
|
|
299
194
|
try {
|
|
300
195
|
stdin.write(`${JSON.stringify({ id, method, params })}\n`, error => {
|
|
301
|
-
// The same failure surfacing on the write's own callback: the request cannot be answered,
|
|
302
|
-
// so it is rejected now rather than left to its deadline.
|
|
303
196
|
if (!error)
|
|
304
197
|
return;
|
|
305
198
|
const entry = this.pending.get(id);
|
|
@@ -317,7 +210,6 @@ class ChildEngine {
|
|
|
317
210
|
}
|
|
318
211
|
});
|
|
319
212
|
}
|
|
320
|
-
/** Close stdin (the engine's graceful shutdown signal) with a kill backstop. */
|
|
321
213
|
stop() {
|
|
322
214
|
if (this.stopped)
|
|
323
215
|
return Promise.resolve();
|
|
@@ -338,7 +230,6 @@ class ChildEngine {
|
|
|
338
230
|
});
|
|
339
231
|
}
|
|
340
232
|
}
|
|
341
|
-
/** How this process spawns another engine of its own CLI. */
|
|
342
233
|
export function relayEngineCommand() {
|
|
343
234
|
const override = process.env.ANDORRA_REMOTE_ENGINE_COMMAND;
|
|
344
235
|
if (override) {
|
|
@@ -347,11 +238,9 @@ export function relayEngineCommand() {
|
|
|
347
238
|
if (Array.isArray(parsed) && parsed.length)
|
|
348
239
|
return parsed.map(String);
|
|
349
240
|
}
|
|
350
|
-
catch {
|
|
241
|
+
catch { }
|
|
351
242
|
return [override];
|
|
352
243
|
}
|
|
353
|
-
// This process is the CLI (`node …/cli.js app-server|remote …`), so its own entry is the engine
|
|
354
|
-
// entry: the relay's children are the same `app-server --stdio` wire the desktop's shell spawns.
|
|
355
244
|
const entry = process.argv[1];
|
|
356
245
|
if (!entry)
|
|
357
246
|
throw new RelayRefusal('remote', 'The engine relay cannot locate its own CLI entry.');
|
|
@@ -361,7 +250,6 @@ const REMOTE_PROJECT_PREFIX = 'rw:';
|
|
|
361
250
|
function isRemoteProjectSpelling(value) {
|
|
362
251
|
return value.startsWith(REMOTE_PROJECT_PREFIX);
|
|
363
252
|
}
|
|
364
|
-
/** The root id part of an `rw:` spelling: everything after the viewer workspace segment. */
|
|
365
253
|
function rootPartOf(value) {
|
|
366
254
|
const rest = value.slice(REMOTE_PROJECT_PREFIX.length);
|
|
367
255
|
const colon = rest.indexOf(':');
|
|
@@ -369,45 +257,25 @@ function rootPartOf(value) {
|
|
|
369
257
|
return undefined;
|
|
370
258
|
return rest.slice(colon + 1);
|
|
371
259
|
}
|
|
372
|
-
/**
|
|
373
|
-
* The coordinator. One instance per listener, created by the server alongside it.
|
|
374
|
-
*/
|
|
375
260
|
export class RemoteEngineRelay {
|
|
376
261
|
directory;
|
|
377
262
|
children = new Map();
|
|
378
|
-
/**
|
|
379
|
-
* The children this relay is stopping, so no start takes one that is on its way out.
|
|
380
|
-
*
|
|
381
|
-
* It belongs to the relay: two relays in one process allocate the same child ids, and one
|
|
382
|
-
* relay's reservation would hide another's idle child.
|
|
383
|
-
*/
|
|
384
263
|
retiringChildren = new Set();
|
|
385
264
|
taskSeq = 0;
|
|
386
265
|
connections = new Map();
|
|
387
|
-
/** Real (child-side) terminal id → the connection that opened it. */
|
|
388
266
|
terminalOwner = new Map();
|
|
389
|
-
/** Session id → the connections whose panels are watching it (a stream they share). */
|
|
390
267
|
browserViewers = new Map();
|
|
391
|
-
/** runId / sessionId → the child that owns it, learned from run lifecycle events. */
|
|
392
268
|
runEngine = new Map();
|
|
393
269
|
sessionEngine = new Map();
|
|
394
|
-
/** The `run.started` payload of each live run, keyed by its child — replayed to new connections. */
|
|
395
270
|
activeRuns = new Map();
|
|
396
|
-
/** The completions that landed with no stream attached, kept briefly for the reconnect replay. */
|
|
397
271
|
finishedRuns = new Map();
|
|
398
|
-
/** Translations by viewer workspace id, each cached briefly (a rebuild realpath-walks the roots). */
|
|
399
272
|
translations = new Map();
|
|
400
273
|
revocationTimer;
|
|
401
|
-
/** Event delivery is queued: a stream's frames must land in the order the children emitted them. */
|
|
402
274
|
delivery = Promise.resolve();
|
|
403
275
|
closed = false;
|
|
404
276
|
constructor(directory) {
|
|
405
277
|
this.directory = directory;
|
|
406
278
|
}
|
|
407
|
-
/**
|
|
408
|
-
* One relayed request. Throws nothing: every failure is the answer's `error`, because the caller is
|
|
409
|
-
* an HTTP handler whose status code cannot say what went wrong inside the engine pool.
|
|
410
|
-
*/
|
|
411
279
|
async request(deviceId, body) {
|
|
412
280
|
try {
|
|
413
281
|
const { method, params } = this.validate(body);
|
|
@@ -442,10 +310,6 @@ export class RemoteEngineRelay {
|
|
|
442
310
|
const asked = typeof body.deadlineMs === 'number' && body.deadlineMs > 0 ? body.deadlineMs : 120_000;
|
|
443
311
|
const ceiling = LONG_DEADLINE_METHODS.has(body.method) ? MAX_LONG_CHILD_DEADLINE_MS : MAX_CHILD_DEADLINE_MS;
|
|
444
312
|
const bounded = Math.min(Math.max(asked, 5_000), ceiling);
|
|
445
|
-
// A mutation runs inside the caller's own budget: the viewer's client fails the call at the
|
|
446
|
-
// deadline it sent, and a start, prompt answer, session change, or shell open that committed
|
|
447
|
-
// after that would surprise a user who already retried or moved on. Reads keep the small slack
|
|
448
|
-
// that lets the engine decide its own timeout rather than racing the viewer's.
|
|
449
313
|
if (MUTATING_METHODS.has(body.method))
|
|
450
314
|
return bounded;
|
|
451
315
|
return bounded + CHILD_DEADLINE_SLACK_MS;
|
|
@@ -459,8 +323,6 @@ export class RemoteEngineRelay {
|
|
|
459
323
|
return this.startRequest(body, method, params, deadline);
|
|
460
324
|
if (RUN_TARGET_METHODS.has(method))
|
|
461
325
|
return this.runTargetRequest(body, method, params, deadline);
|
|
462
|
-
// A run owns its session's record while it executes, so a mutation belongs to the engine running
|
|
463
|
-
// it — the same refusal-and-perform rule a local window's routing follows.
|
|
464
326
|
if (SESSION_MUTATION_METHODS.has(method) && typeof params.id === 'string') {
|
|
465
327
|
const owner = this.sessionEngine.get(params.id);
|
|
466
328
|
if (owner)
|
|
@@ -470,9 +332,6 @@ export class RemoteEngineRelay {
|
|
|
470
332
|
if (target !== REMOTE_PRIMARY_ENGINE && !this.children.has(target)) {
|
|
471
333
|
throw new RelayRefusal('not-found', `No engine ${target} is serving this machine's remote surface.`);
|
|
472
334
|
}
|
|
473
|
-
// A session's panel stream is one switch on the hosting engine, so several paired viewers
|
|
474
|
-
// watching the same session share it: it is turned off only when the last of them leaves, and
|
|
475
|
-
// the other viewers' panes keep receiving frames until then.
|
|
476
335
|
if (method === 'browser.view.stream' && typeof params.sessionId === 'string') {
|
|
477
336
|
const sessionId = params.sessionId;
|
|
478
337
|
if (params.enabled === false) {
|
|
@@ -492,50 +351,25 @@ export class RemoteEngineRelay {
|
|
|
492
351
|
}
|
|
493
352
|
const engine = await this.engine(target);
|
|
494
353
|
const answer = await engine.request(method, await this.translateParams(body.viewerWorkspaceId, params), deadline);
|
|
495
|
-
// The session listing echoes each requested spelling back; the viewer files its groups by its
|
|
496
|
-
// own, so the echo is restored here rather than left in this machine's terms.
|
|
497
354
|
if (method === 'sessions.list' && Array.isArray(params.workspaces)) {
|
|
498
355
|
return this.restoreRequestedEcho(answer, params.workspaces, body.viewerWorkspaceId);
|
|
499
356
|
}
|
|
500
|
-
// A trajectory page names the log it is showing, and that name is a path on this machine: the
|
|
501
|
-
// viewer's own home is not this one, and it cannot use the name anyway. It is left out rather
|
|
502
|
-
// than sent, so the host's layout is not handed to a paired client.
|
|
503
357
|
if (method === 'sessions.trajectory' && answer !== null && typeof answer === 'object' && !Array.isArray(answer)) {
|
|
504
358
|
const { path: _hostPath, ...page } = answer;
|
|
505
359
|
return page;
|
|
506
360
|
}
|
|
507
361
|
return answer;
|
|
508
362
|
}
|
|
509
|
-
/**
|
|
510
|
-
* run.start / run.resume: pick a free task engine, spawning one when every child is busy.
|
|
511
|
-
*
|
|
512
|
-
* The browsing engine never takes a run (ADR 0017), the busy refusal is the engine's own, and the
|
|
513
|
-
* answer names the engine that took the run so the viewer can address its prompts directly.
|
|
514
|
-
*/
|
|
515
363
|
async startRequest(body, method, params, deadline) {
|
|
516
|
-
// The capability the answering child must advertise, asked for by the viewer: the browsing
|
|
517
|
-
// engine's handshake says what the machine can do, not what every task engine on it can, and a
|
|
518
|
-
// child that predates a feature answers the request and ignores the parameter. The requirement
|
|
519
|
-
// travels with the request so the pool picks a child that honours it — and it is stripped here,
|
|
520
|
-
// because it is the pool's own routing rule and not the engine's parameter.
|
|
521
364
|
const { requireCapability, ...rest } = params;
|
|
522
365
|
const required = typeof requireCapability === 'string' && requireCapability.length > 0 ? requireCapability : undefined;
|
|
523
366
|
const translated = await this.translateParams(body.viewerWorkspaceId, rest);
|
|
524
|
-
// A resume may address the engine that owns the session's scheduled wake (the desktop learned
|
|
525
|
-
// the id from the wake's own events): routing it by pool selection could wake the session in a
|
|
526
|
-
// second process while the first still holds the timer, and the two would overwrite each
|
|
527
|
-
// other's persisted turns. The addressed engine decides; its own busy refusal is the answer.
|
|
528
367
|
if (body.engine !== '' && body.engine !== REMOTE_PRIMARY_ENGINE) {
|
|
529
368
|
const addressed = this.children.get(body.engine);
|
|
530
369
|
if (addressed !== undefined) {
|
|
531
|
-
// A child this relay is stopping is on its way out: a request addressed to it would be
|
|
532
|
-
// accepted and then lose the engine under it.
|
|
533
370
|
if (this.retiringChildren.has(addressed.id)) {
|
|
534
371
|
throw new RelayRefusal('busy', 'That engine is being stopped; try again.');
|
|
535
372
|
}
|
|
536
|
-
// The addressed engine owns the session's wake, so it is the one that has to answer. A child
|
|
537
|
-
// that cannot honour the requirement is refused rather than rerouted: another engine would
|
|
538
|
-
// wake the session in a second process.
|
|
539
373
|
if (required !== undefined && !addressed.supports(required)) {
|
|
540
374
|
throw new RelayRefusal('invalid-params', `The engine that would answer does not support ${required}.`);
|
|
541
375
|
}
|
|
@@ -543,22 +377,15 @@ export class RemoteEngineRelay {
|
|
|
543
377
|
return { ...result, engine: addressed.id };
|
|
544
378
|
}
|
|
545
379
|
}
|
|
546
|
-
// A child that does not advertise the capability is not asked at all: it would answer and
|
|
547
|
-
// ignore the parameter, which is exactly the silence the requirement exists to prevent. An idle
|
|
548
|
-
// one is retired rather than merely skipped: the pool's cap counts every child, and a pool full
|
|
549
|
-
// of children that cannot answer would refuse the run as busy while nothing was running.
|
|
550
380
|
const incompatible = [];
|
|
551
381
|
for (const [id, engine] of [...this.children]) {
|
|
552
382
|
if (id === REMOTE_PRIMARY_ENGINE)
|
|
553
383
|
continue;
|
|
554
384
|
if (required !== undefined && !engine.supports(required)) {
|
|
555
|
-
// A child another request is already retiring is not a candidate: two scans would pick the
|
|
556
|
-
// same one, and only one slot would be freed.
|
|
557
385
|
if (!engine.busy && !this.retiringChildren.has(id))
|
|
558
386
|
incompatible.push(engine);
|
|
559
387
|
continue;
|
|
560
388
|
}
|
|
561
|
-
// A child this relay is stopping is on its way out: a start must not take it.
|
|
562
389
|
if (this.retiringChildren.has(id))
|
|
563
390
|
continue;
|
|
564
391
|
try {
|
|
@@ -571,22 +398,13 @@ export class RemoteEngineRelay {
|
|
|
571
398
|
throw error;
|
|
572
399
|
}
|
|
573
400
|
}
|
|
574
|
-
// A child that finished its run but still owns a self-wake timer is not idle in the sense that
|
|
575
|
-
// matters: stopping it would destroy the pending wake, which is the session's own work. The
|
|
576
|
-
// scan looks for a child that can be stopped — one may hold a wake while the next cannot.
|
|
577
401
|
for (const child of incompatible) {
|
|
578
|
-
// Reserved before the first check, and only if another request has not claimed this child
|
|
579
|
-
// already: two claims would retire one child and free one slot, and the second request
|
|
580
|
-
// would be refused as busy while another incompatible idle child remained.
|
|
581
402
|
if (this.retiringChildren.has(child.id))
|
|
582
403
|
continue;
|
|
583
404
|
this.retiringChildren.add(child.id);
|
|
584
405
|
try {
|
|
585
406
|
if (await this.childHoldsWake(child))
|
|
586
407
|
continue;
|
|
587
|
-
// The child's own answer is the authority on whether it is free: the busy flag is set when
|
|
588
|
-
// a run starts, which is after the child has accepted the request, so a child that is still
|
|
589
|
-
// preparing one looks idle here and must not be stopped under it.
|
|
590
408
|
if (!await this.childIsIdle(child))
|
|
591
409
|
continue;
|
|
592
410
|
await this.retireChild(child.id);
|
|
@@ -598,8 +416,6 @@ export class RemoteEngineRelay {
|
|
|
598
416
|
}
|
|
599
417
|
const spawned = await this.spawnChild(`${TASK_PREFIX}${++this.taskSeq}`);
|
|
600
418
|
try {
|
|
601
|
-
// A fresh child comes from the machine's current install, so it advertises what the browsing
|
|
602
|
-
// engine advertised; a machine whose install cannot honour the requirement says so instead.
|
|
603
419
|
if (required !== undefined && !spawned.supports(required)) {
|
|
604
420
|
throw new RelayRefusal('invalid-params', `This machine's engine does not support ${required}.`);
|
|
605
421
|
}
|
|
@@ -607,20 +423,11 @@ export class RemoteEngineRelay {
|
|
|
607
423
|
return { ...result, engine: spawned.id };
|
|
608
424
|
}
|
|
609
425
|
catch (error) {
|
|
610
|
-
// A child that took no run is an idle process the pool does not need; retiring it keeps a
|
|
611
|
-
// refused start from spending a slot. A child whose run began keeps the slot — its events are
|
|
612
|
-
// still owed to the streams.
|
|
613
426
|
if (!spawned.busy && !this.engineOwnsRun(spawned.id))
|
|
614
427
|
await this.retireChild(spawned.id);
|
|
615
428
|
throw error;
|
|
616
429
|
}
|
|
617
430
|
}
|
|
618
|
-
/**
|
|
619
|
-
* run.cancel / run.approve / run.answer: a prompt belongs to the child that raised it.
|
|
620
|
-
*
|
|
621
|
-
* The viewer addresses these by the engine id it learned from `run.started`, which is authoritative
|
|
622
|
-
* here as well; a cancel names its run id, and the ownership map answers that on its own.
|
|
623
|
-
*/
|
|
624
431
|
async runTargetRequest(body, method, params, deadline) {
|
|
625
432
|
let owner;
|
|
626
433
|
if (typeof params.runId === 'string')
|
|
@@ -635,11 +442,6 @@ export class RemoteEngineRelay {
|
|
|
635
442
|
}
|
|
636
443
|
return (await this.engine(owner)).request(method, params, deadline);
|
|
637
444
|
}
|
|
638
|
-
/**
|
|
639
|
-
* Terminal calls: ids are prefixed with the connection, output goes only to that connection, and a
|
|
640
|
-
* closeAll sweeps only the shells that connection opened. The browsing engine hosts the PTYs — a
|
|
641
|
-
* shell outlives any one task and belongs to no run.
|
|
642
|
-
*/
|
|
643
445
|
async terminalRequest(connection, method, params, deadline) {
|
|
644
446
|
const primary = await this.engine(REMOTE_PRIMARY_ENGINE);
|
|
645
447
|
const real = (prefixed) => {
|
|
@@ -659,8 +461,6 @@ export class RemoteEngineRelay {
|
|
|
659
461
|
const id = real(params.id);
|
|
660
462
|
if (id === undefined)
|
|
661
463
|
throw new RelayRefusal('not-found', 'That terminal was not opened on this connection.');
|
|
662
|
-
// `cwd` on these calls is the VIEWER's routing hint (which machine owns the shell); the
|
|
663
|
-
// engine's own write/resize/close take no folder, so it is not forwarded.
|
|
664
464
|
const { cwd: _routing, ...forwarded } = params;
|
|
665
465
|
const answer = await primary.request(method, { ...forwarded, id }, deadline);
|
|
666
466
|
if (method === 'terminal.close') {
|
|
@@ -669,8 +469,6 @@ export class RemoteEngineRelay {
|
|
|
669
469
|
}
|
|
670
470
|
return answer;
|
|
671
471
|
}
|
|
672
|
-
// terminal.closeAll: only the shells this connection opened — the desktop's own closeAll from a
|
|
673
|
-
// reattach is the one call that cannot name ids, and here it stays scoped to the issuer.
|
|
674
472
|
const opened = [...connection.terminals.entries()];
|
|
675
473
|
connection.terminals.clear();
|
|
676
474
|
for (const [, id] of opened)
|
|
@@ -681,19 +479,15 @@ export class RemoteEngineRelay {
|
|
|
681
479
|
await primary.request('terminal.close', { id }, 5_000);
|
|
682
480
|
closed += 1;
|
|
683
481
|
}
|
|
684
|
-
catch {
|
|
482
|
+
catch { }
|
|
685
483
|
}
|
|
686
484
|
return { closed };
|
|
687
485
|
}
|
|
688
|
-
/**
|
|
689
|
-
* Translate the viewer's project spellings inside request params. Only the fields that NAME a
|
|
690
|
-
* workspace folder carry one, so the walk is over those fields, not the whole payload — a task
|
|
691
|
-
* prompt may legitimately contain the literal text "rw:".
|
|
692
|
-
*/
|
|
693
486
|
async translateParams(viewerWorkspaceId, params) {
|
|
694
487
|
const workspaces = Array.isArray(params.workspaces) ? params.workspaces : undefined;
|
|
695
488
|
const needs = (typeof params.workspace === 'string' && isRemoteProjectSpelling(params.workspace))
|
|
696
489
|
|| (typeof params.cwd === 'string' && isRemoteProjectSpelling(params.cwd))
|
|
490
|
+
|| (typeof params.path === 'string' && isRemoteProjectSpelling(params.path))
|
|
697
491
|
|| (workspaces !== undefined && workspaces.some(value => typeof value === 'string' && isRemoteProjectSpelling(value)));
|
|
698
492
|
if (!needs)
|
|
699
493
|
return params;
|
|
@@ -703,10 +497,9 @@ export class RemoteEngineRelay {
|
|
|
703
497
|
next.workspace = translation.toHost(next.workspace);
|
|
704
498
|
if (typeof next.cwd === 'string' && isRemoteProjectSpelling(next.cwd))
|
|
705
499
|
next.cwd = translation.toHost(next.cwd);
|
|
500
|
+
if (typeof next.path === 'string' && isRemoteProjectSpelling(next.path))
|
|
501
|
+
next.path = translation.toHost(next.path);
|
|
706
502
|
if (workspaces !== undefined) {
|
|
707
|
-
// A listing tolerates one untranslatable spelling: a hashed pick (a folder chosen inside a
|
|
708
|
-
// root) has no host path, but refusing the WHOLE listing for it would blank every registered
|
|
709
|
-
// row beside it. It passes through verbatim; the host answers that group empty.
|
|
710
503
|
next.workspaces = workspaces.map(value => {
|
|
711
504
|
if (typeof value !== 'string' || !isRemoteProjectSpelling(value))
|
|
712
505
|
return value;
|
|
@@ -720,7 +513,6 @@ export class RemoteEngineRelay {
|
|
|
720
513
|
}
|
|
721
514
|
return next;
|
|
722
515
|
}
|
|
723
|
-
/** Put each listing group back under the spelling the viewer asked with. */
|
|
724
516
|
async restoreRequestedEcho(answer, original, viewerWorkspaceId) {
|
|
725
517
|
const groups = answer?.groups;
|
|
726
518
|
if (!Array.isArray(groups))
|
|
@@ -735,7 +527,6 @@ export class RemoteEngineRelay {
|
|
|
735
527
|
});
|
|
736
528
|
return answer;
|
|
737
529
|
}
|
|
738
|
-
/** The connection record, created on first sight. */
|
|
739
530
|
connection(deviceId, connectionId, viewerWorkspaceId) {
|
|
740
531
|
let found = this.connections.get(connectionId);
|
|
741
532
|
if (!found) {
|
|
@@ -748,18 +539,12 @@ export class RemoteEngineRelay {
|
|
|
748
539
|
found.viewerWorkspaceId = viewerWorkspaceId;
|
|
749
540
|
return found;
|
|
750
541
|
}
|
|
751
|
-
/**
|
|
752
|
-
* End one connection outright: its streams are closed (not merely starved), its terminals swept.
|
|
753
|
-
*
|
|
754
|
-
* Revocation and shutdown both go through here, so a connection never survives either — the
|
|
755
|
-
* viewer observes the stream end and the host keeps no orphaned shells or half-dead sockets.
|
|
756
|
-
*/
|
|
757
542
|
sever(connection) {
|
|
758
543
|
for (const cut of [...connection.cuts]) {
|
|
759
544
|
try {
|
|
760
545
|
cut();
|
|
761
546
|
}
|
|
762
|
-
catch {
|
|
547
|
+
catch { }
|
|
763
548
|
}
|
|
764
549
|
connection.sinks.clear();
|
|
765
550
|
connection.cuts.clear();
|
|
@@ -768,9 +553,6 @@ export class RemoteEngineRelay {
|
|
|
768
553
|
void this.engine(REMOTE_PRIMARY_ENGINE).then(primary => primary.request('terminal.close', { id: real }, 5_000)).catch(() => undefined);
|
|
769
554
|
}
|
|
770
555
|
connection.terminals.clear();
|
|
771
|
-
// Turning the stream off hands the browser back to the idle reaper, which
|
|
772
|
-
// closes it a while later; the viewer that owned it is gone either way — but
|
|
773
|
-
// only when no other connection is still watching that session's panel.
|
|
774
556
|
for (const sessionId of connection.browserStreams) {
|
|
775
557
|
const viewers = this.browserViewers.get(sessionId);
|
|
776
558
|
viewers?.delete(connection.id);
|
|
@@ -784,41 +566,20 @@ export class RemoteEngineRelay {
|
|
|
784
566
|
connection.browserStreams.clear();
|
|
785
567
|
this.connections.delete(connection.id);
|
|
786
568
|
}
|
|
787
|
-
/**
|
|
788
|
-
* Register one connection's event stream. The returned stop function ends delivery; the server
|
|
789
|
-
* calls it when the HTTP response closes, and it sweeps that connection's terminals with it — a
|
|
790
|
-
* window that is gone cannot name its shells any more, and the host's slots are not a graveyard.
|
|
791
|
-
*/
|
|
792
569
|
events(deviceId, connectionId, viewerWorkspaceId, sink, cut) {
|
|
793
570
|
const connection = this.connection(deviceId, connectionId, viewerWorkspaceId);
|
|
794
571
|
connection.sinks.add(sink);
|
|
795
572
|
connection.cuts.add(cut);
|
|
796
573
|
connection.sinklessSince = 0;
|
|
797
|
-
// A window that reconnects while work is still live has never seen what happened since its last
|
|
798
|
-
// stream ended: the active run's `run.started`, the completions that landed in the gap, and the
|
|
799
|
-
// timers an idle engine still holds. These are delivered TO THIS SINK alone — the other, healthy
|
|
800
|
-
// viewers already saw them, and replaying start frames at them would reset live tracking.
|
|
801
574
|
this.replayTo(connection, viewerWorkspaceId, sink);
|
|
802
575
|
return () => {
|
|
803
576
|
connection.sinks.delete(sink);
|
|
804
577
|
connection.cuts.delete(cut);
|
|
805
578
|
if (connection.sinks.size > 0)
|
|
806
579
|
return;
|
|
807
|
-
// A stream that closed may be a retryable one (a network blip, backpressure): its viewer
|
|
808
|
-
// reconnects with the same connection id within seconds. The shells stay — they are the
|
|
809
|
-
// connection's until either an explicit stream returns (sinklessSince resets) or the poller's
|
|
810
|
-
// abandonment TTL ends the connection for good.
|
|
811
580
|
connection.sinklessSince = Date.now();
|
|
812
581
|
};
|
|
813
582
|
}
|
|
814
|
-
/**
|
|
815
|
-
* Deliver the reconnect snapshot to one stream, in emission order with everything else.
|
|
816
|
-
*
|
|
817
|
-
* Active runs first (the replacement client must register them), then the completions that landed
|
|
818
|
-
* while no stream was attached (so a run that finished in a reconnect gap is not shown as working
|
|
819
|
-
* forever), then each idle engine's outstanding timers (so a scheduled wake is adopted by the new
|
|
820
|
-
* client rather than firing unseen).
|
|
821
|
-
*/
|
|
822
583
|
replayTo(connection, viewerWorkspaceId, sink) {
|
|
823
584
|
void (async () => {
|
|
824
585
|
const now = Date.now();
|
|
@@ -853,7 +614,6 @@ export class RemoteEngineRelay {
|
|
|
853
614
|
}
|
|
854
615
|
})().catch(() => undefined);
|
|
855
616
|
}
|
|
856
|
-
/** One queued frame for one sink: the reconnect replay shares the queue, not the broadcast. */
|
|
857
617
|
enqueueTo(sink, translation, engineId, event, data) {
|
|
858
618
|
this.delivery = this.delivery.then(() => {
|
|
859
619
|
if (this.closed)
|
|
@@ -861,15 +621,9 @@ export class RemoteEngineRelay {
|
|
|
861
621
|
try {
|
|
862
622
|
sink({ engine: engineId, event, data: translation.rewrite(data) });
|
|
863
623
|
}
|
|
864
|
-
catch {
|
|
624
|
+
catch { }
|
|
865
625
|
}).catch(() => undefined);
|
|
866
626
|
}
|
|
867
|
-
/**
|
|
868
|
-
* One child event, in emission order.
|
|
869
|
-
*
|
|
870
|
-
* The queue is the ordering guarantee a stream needs — `run.started` must reach the viewer before
|
|
871
|
-
* the run's first events whatever the translation cache is doing between them.
|
|
872
|
-
*/
|
|
873
627
|
enqueue(engineId, event, data) {
|
|
874
628
|
this.delivery = this.delivery.then(() => this.deliverEvent(engineId, event, data)).catch(() => undefined);
|
|
875
629
|
}
|
|
@@ -887,7 +641,6 @@ export class RemoteEngineRelay {
|
|
|
887
641
|
this.runEngine.set(runId, engineId);
|
|
888
642
|
if (typeof data.sessionId === 'string')
|
|
889
643
|
this.sessionEngine.set(data.sessionId, engineId);
|
|
890
|
-
// A task engine runs one task at a time: this frame is the run a reconnecting window adopts.
|
|
891
644
|
if (engineId !== REMOTE_PRIMARY_ENGINE)
|
|
892
645
|
this.activeRuns.set(engineId, data);
|
|
893
646
|
}
|
|
@@ -901,8 +654,6 @@ export class RemoteEngineRelay {
|
|
|
901
654
|
child.busy = false;
|
|
902
655
|
if (engineId !== REMOTE_PRIMARY_ENGINE) {
|
|
903
656
|
this.activeRuns.delete(engineId);
|
|
904
|
-
// A viewer whose stream is down saw the start but will miss this: the completion is kept
|
|
905
|
-
// for the reconnect replay, so the run does not stay on screen as working forever.
|
|
906
657
|
this.finishedRuns.set(engineId, { event, data, at: Date.now() });
|
|
907
658
|
if (this.finishedRuns.size > FINISHED_RUNS_REMEMBERED) {
|
|
908
659
|
const oldest = this.finishedRuns.keys().next().value;
|
|
@@ -912,8 +663,6 @@ export class RemoteEngineRelay {
|
|
|
912
663
|
}
|
|
913
664
|
}
|
|
914
665
|
if ((event === 'terminal.data' || event === 'terminal.exit') && typeof data.id === 'string') {
|
|
915
|
-
// Terminal output belongs to the connection that opened the shell; every other stream — and
|
|
916
|
-
// every other device — never sees it.
|
|
917
666
|
const ownerId = this.terminalOwner.get(data.id);
|
|
918
667
|
if (ownerId === undefined)
|
|
919
668
|
return;
|
|
@@ -926,7 +675,7 @@ export class RemoteEngineRelay {
|
|
|
926
675
|
try {
|
|
927
676
|
sink(frame);
|
|
928
677
|
}
|
|
929
|
-
catch {
|
|
678
|
+
catch { }
|
|
930
679
|
}
|
|
931
680
|
return;
|
|
932
681
|
}
|
|
@@ -939,18 +688,10 @@ export class RemoteEngineRelay {
|
|
|
939
688
|
try {
|
|
940
689
|
sink(frame);
|
|
941
690
|
}
|
|
942
|
-
catch {
|
|
691
|
+
catch { }
|
|
943
692
|
}
|
|
944
693
|
}
|
|
945
694
|
}
|
|
946
|
-
/**
|
|
947
|
-
* One event's data for one viewer, with its project paths translated.
|
|
948
|
-
*
|
|
949
|
-
* A panel operation's arguments are the browser's own input, not paths: a `fill` value that
|
|
950
|
-
* happens to equal a shared root is a form value the page must receive verbatim, and rewriting it
|
|
951
|
-
* into the viewer's project id would type that id into the page instead. Only the routing fields
|
|
952
|
-
* around them are translated.
|
|
953
|
-
*/
|
|
954
695
|
rewriteEventData(translation, event, data) {
|
|
955
696
|
if (event !== 'browser.panel.request' || data.arguments === undefined)
|
|
956
697
|
return translation.rewrite(data);
|
|
@@ -958,14 +699,8 @@ export class RemoteEngineRelay {
|
|
|
958
699
|
return { ...translation.rewrite(rest), arguments: verbatim };
|
|
959
700
|
}
|
|
960
701
|
onChildExit(engineId) {
|
|
961
|
-
// A child that dies mid-run leaves the persisted session claiming the run is still live (the
|
|
962
|
-
// reconciliation a healthy engine performs at startup never runs for it): mark it interrupted
|
|
963
|
-
// here, so listings and reloads do not show a working task that no process is driving.
|
|
964
702
|
const interrupted = this.activeRuns.get(engineId);
|
|
965
703
|
if (interrupted !== undefined && typeof interrupted.runId === 'string') {
|
|
966
|
-
// The child queued a start for this run, so the reconciliation owes the matching finish;
|
|
967
|
-
// dropping the returned records would leave that start unmatched, because a replacement
|
|
968
|
-
// app-server skips records no longer marked running.
|
|
969
704
|
void reconcileInterruptedRuns(this.directory, new Set([interrupted.runId]), { includePending: true })
|
|
970
705
|
.then(recovered => reportInterruptedRuns({ home: this.directory, surface: configuredSurface('remote') }, recovered.interrupted))
|
|
971
706
|
.catch(() => undefined);
|
|
@@ -978,8 +713,6 @@ export class RemoteEngineRelay {
|
|
|
978
713
|
for (const [sessionId, owner] of [...this.sessionEngine])
|
|
979
714
|
if (owner === engineId)
|
|
980
715
|
this.sessionEngine.delete(sessionId);
|
|
981
|
-
// The viewer learns the engine is gone as an event, so its remote client for it can be retired
|
|
982
|
-
// the way a dead process's client is.
|
|
983
716
|
this.enqueue(engineId, 'engine.exited', { engine: engineId });
|
|
984
717
|
}
|
|
985
718
|
engineOwnsRun(engineId) {
|
|
@@ -1002,9 +735,6 @@ export class RemoteEngineRelay {
|
|
|
1002
735
|
return existing;
|
|
1003
736
|
if (this.closed)
|
|
1004
737
|
throw new RelayRefusal('remote', 'The remote engine relay is shutting down.');
|
|
1005
|
-
// The cap counts task engines, and the browsing engine is exempt from it — its slot is the one
|
|
1006
|
-
// the cap exists to protect, so nine busy tasks never leave the primary surface (sessions,
|
|
1007
|
-
// workspace reads, terminals) unspawnable.
|
|
1008
738
|
if (id !== REMOTE_PRIMARY_ENGINE) {
|
|
1009
739
|
const taskEngines = [...this.children.keys()].filter(childId => childId !== REMOTE_PRIMARY_ENGINE).length;
|
|
1010
740
|
if (taskEngines >= MAX_RELAY_ENGINES) {
|
|
@@ -1023,18 +753,6 @@ export class RemoteEngineRelay {
|
|
|
1023
753
|
}
|
|
1024
754
|
return created;
|
|
1025
755
|
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Whether a child still owns a scheduled wake.
|
|
1028
|
-
*
|
|
1029
|
-
* A child that cannot answer is treated as holding one: stopping it could destroy a wake that
|
|
1030
|
-
* is still owed, and a refused start is a visible failure while a lost wake is not.
|
|
1031
|
-
*/
|
|
1032
|
-
/**
|
|
1033
|
-
* Whether a child is free of a run.
|
|
1034
|
-
*
|
|
1035
|
-
* A child that cannot answer is not known to be free, and stopping one that is preparing a run
|
|
1036
|
-
* would abort the task it accepted.
|
|
1037
|
-
*/
|
|
1038
756
|
async childIsIdle(child) {
|
|
1039
757
|
try {
|
|
1040
758
|
const info = await child.request('host.info', {}, 5_000);
|
|
@@ -1060,14 +778,6 @@ export class RemoteEngineRelay {
|
|
|
1060
778
|
this.children.delete(id);
|
|
1061
779
|
await child.stop().catch(() => undefined);
|
|
1062
780
|
}
|
|
1063
|
-
/**
|
|
1064
|
-
* The bidirectional project-spelling translation for one viewer.
|
|
1065
|
-
*
|
|
1066
|
-
* Cached briefly per viewer workspace id: building it realpath-walks every authorized root, and a
|
|
1067
|
-
* sessions listing or an event burst would otherwise pay that per call. The cache never outlives a
|
|
1068
|
-
* pairing change by long — five seconds — so a newly registered project is executable almost
|
|
1069
|
-
* immediately.
|
|
1070
|
-
*/
|
|
1071
781
|
async translation(viewerWorkspaceId) {
|
|
1072
782
|
const cached = this.translations.get(viewerWorkspaceId);
|
|
1073
783
|
const now = Date.now();
|
|
@@ -1090,8 +800,6 @@ export class RemoteEngineRelay {
|
|
|
1090
800
|
const mapped = toHostMap.get(value);
|
|
1091
801
|
if (mapped !== undefined)
|
|
1092
802
|
return mapped;
|
|
1093
|
-
// A folder picked inside a root was hashed with a relative path only the viewer knows, so no
|
|
1094
|
-
// host-side table can reverse it. Refusing with the fix is the answer that can be acted on.
|
|
1095
803
|
throw new RelayRefusal('not-found', 'That folder was picked inside a shared root. Register the folder itself on this machine (Add on the rail, or a project on this host) to run tasks in it.');
|
|
1096
804
|
},
|
|
1097
805
|
toViewer: value => toViewerMap.get(value) ?? value,
|
|
@@ -1100,12 +808,6 @@ export class RemoteEngineRelay {
|
|
|
1100
808
|
this.translations.set(viewerWorkspaceId, { at: now, translation });
|
|
1101
809
|
return translation;
|
|
1102
810
|
}
|
|
1103
|
-
/**
|
|
1104
|
-
* Cut every live stream and terminal of devices that no longer hold full authority.
|
|
1105
|
-
*
|
|
1106
|
-
* Per-request authentication already refuses a revoked device's next call; this poller is for the
|
|
1107
|
-
* resource a request never re-checks — the open event stream, and the shells its connection owns.
|
|
1108
|
-
*/
|
|
1109
811
|
startRevocationPoll() {
|
|
1110
812
|
if (this.revocationTimer !== undefined)
|
|
1111
813
|
return;
|
|
@@ -1115,9 +817,6 @@ export class RemoteEngineRelay {
|
|
|
1115
817
|
const valid = new Set((config.remote?.hosting?.devices ?? []).filter(device => device.grant === 'full').map(device => device.id));
|
|
1116
818
|
for (const [, connection] of [...this.connections]) {
|
|
1117
819
|
if (valid.has(connection.deviceId)) {
|
|
1118
|
-
// A connection made by requests whose stream never arrived (the viewer unloaded between
|
|
1119
|
-
// `remote.engine.connect` and its SSE GET) has no response-close callback to end it:
|
|
1120
|
-
// the poller retires it, sweeping the terminals it opened.
|
|
1121
820
|
if (connection.sinks.size === 0 && connection.sinklessSince !== 0 && Date.now() - connection.sinklessSince > SINKLESS_CONNECTION_TTL_MS) {
|
|
1122
821
|
this.sever(connection);
|
|
1123
822
|
}
|
|
@@ -1130,7 +829,6 @@ export class RemoteEngineRelay {
|
|
|
1130
829
|
this.revocationTimer = setInterval(sweep, REVOCATION_POLL_MS);
|
|
1131
830
|
this.revocationTimer.unref?.();
|
|
1132
831
|
}
|
|
1133
|
-
/** Stop the pool: every child gets the graceful close, and no stream outlives the listener. */
|
|
1134
832
|
async close() {
|
|
1135
833
|
if (this.closed)
|
|
1136
834
|
return;
|
|
@@ -1144,15 +842,7 @@ export class RemoteEngineRelay {
|
|
|
1144
842
|
await Promise.all(children.map(child => child.stop().catch(() => undefined)));
|
|
1145
843
|
}
|
|
1146
844
|
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Fields whose value is a file's own text wherever it appears: a completed call's `fileDiff` on
|
|
1149
|
-
* `node.tool.completed`, which reaches a viewer live inside `run.event` and again in the journal a
|
|
1150
|
-
* `runs.get` or a trajectory read returns. A diff line that reads exactly like a host project folder is
|
|
1151
|
-
* still a line of the file, and rewriting it would show the viewer a change the file never had. Only the
|
|
1152
|
-
* routing fields around such a value are translated.
|
|
1153
|
-
*/
|
|
1154
845
|
const VERBATIM_FIELDS = new Set(['fileDiff']);
|
|
1155
|
-
/** Rewrite every known host path inside an arbitrary payload, structurally, leaving file text alone. */
|
|
1156
846
|
function rewritePaths(value, paths) {
|
|
1157
847
|
if (typeof value === 'string')
|
|
1158
848
|
return paths.get(value) ?? value;
|
|
@@ -1166,12 +856,5 @@ function rewritePaths(value, paths) {
|
|
|
1166
856
|
}
|
|
1167
857
|
return value;
|
|
1168
858
|
}
|
|
1169
|
-
/**
|
|
1170
|
-
* Answers that are the page's own data, not file-system answers. A selection that happens to read
|
|
1171
|
-
* exactly like one of the host's shared-root paths is the user's text — rewriting it would put an
|
|
1172
|
-
* `rw:` project identifier on the viewer's clipboard and, for a cut, delete the original from the
|
|
1173
|
-
* page with only the identifier surviving. A pending change's diff is the same: the file's own text,
|
|
1174
|
-
* whose paths are workspace-relative, and a line that reads like a host path is still a line.
|
|
1175
|
-
*/
|
|
1176
859
|
const OPAQUE_RESPONSE_METHODS = new Set(['browser.view.selection', 'browser.view.cursor', 'sessions.changes.list', 'sessions.changes.get']);
|
|
1177
860
|
export { REMOTE_PROJECT_PREFIX, isRemoteProjectSpelling, rootPartOf };
|