@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
package/dist/src/graph-sync.js
CHANGED
|
@@ -27,15 +27,9 @@ function parseSnapshot(raw, hash) {
|
|
|
27
27
|
const REFUSED_FILE = /^(?:graphs\/[A-Za-z0-9][A-Za-z0-9_-]{0,79}\/\d+\.json|graph-drafts\/[a-f0-9]{64}\.json)$/;
|
|
28
28
|
class SyncPaused extends Error {
|
|
29
29
|
}
|
|
30
|
-
/** The account service refused one snapshot under the free allowance; the rest of the pass goes on. */
|
|
31
30
|
class SnapshotRefused extends Error {
|
|
32
31
|
}
|
|
33
32
|
const defaults = {
|
|
34
|
-
// Token acquisition may have to rotate the stored refresh token; only the sync pass itself
|
|
35
|
-
// is short-lived, so it waits for that rotation instead of abandoning it (see AuthManager).
|
|
36
|
-
// The caller's signal (the sync's close signal) cancels the wait for the auth lock and any
|
|
37
|
-
// pre-exchange work, but never a rotation already in flight: closing the graph editor must not
|
|
38
|
-
// hang on a background sync, and the session still lands.
|
|
39
33
|
token: signal => getAccessToken(AbortSignal.any([...(signal ? [signal] : []), AbortSignal.timeout(AUTH_REFRESH_BUDGET_MS)])),
|
|
40
34
|
subject: async () => (await getAuthStatus(AbortSignal.timeout(5000))).subject,
|
|
41
35
|
baseUrl: getAuthConfiguration().apiBaseUrl,
|
|
@@ -55,8 +49,6 @@ async function atomic(path, raw) {
|
|
|
55
49
|
const temp = `${path}.${randomUUID()}.tmp`;
|
|
56
50
|
await writeFile(temp, raw, { flag: 'wx', mode: 0o600 });
|
|
57
51
|
try {
|
|
58
|
-
// Replacing a file another reader or a scanner still holds open is refused for a moment on
|
|
59
|
-
// Windows; the replacement is the same content, so a retry lands rather than failing a pass.
|
|
60
52
|
for (let attempt = 0;; attempt++) {
|
|
61
53
|
try {
|
|
62
54
|
await rename(temp, path);
|
|
@@ -74,7 +66,6 @@ async function atomic(path, raw) {
|
|
|
74
66
|
await unlink(temp).catch(() => { });
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
|
-
/** Publish complete immutable content without rewriting an existing matching file. */
|
|
78
69
|
async function immutable(path, raw) {
|
|
79
70
|
const same = async () => {
|
|
80
71
|
try {
|
|
@@ -114,7 +105,6 @@ function envelope(kind, content) {
|
|
|
114
105
|
parseSnapshot(raw, digest(raw));
|
|
115
106
|
return raw;
|
|
116
107
|
}
|
|
117
|
-
/** Local immutable snapshots are the durable queue; network failures never roll back local writes. */
|
|
118
108
|
export class GraphSync {
|
|
119
109
|
directory;
|
|
120
110
|
subject;
|
|
@@ -122,7 +112,6 @@ export class GraphSync {
|
|
|
122
112
|
accessDenied = false;
|
|
123
113
|
status = { state: 'pending', detail: 'Saved locally; cloud sync pending' };
|
|
124
114
|
running;
|
|
125
|
-
/** Aborted by `close()`: cancels waiting for the auth lock without cancelling a rotation. */
|
|
126
115
|
closer = new AbortController();
|
|
127
116
|
timer;
|
|
128
117
|
stopped = false;
|
|
@@ -151,18 +140,12 @@ export class GraphSync {
|
|
|
151
140
|
const original = envelope('draft', content);
|
|
152
141
|
if (this.lastDraft.get(content.id) === digest(original))
|
|
153
142
|
return;
|
|
154
|
-
// A deleted graph's drafts die with it: a write that races the deletion's cleanup must not
|
|
155
|
-
// recreate one, or the tombstone's promise that no trace of the graph survives is broken
|
|
156
|
-
// while the machine is offline and no pruning pass removes it.
|
|
157
143
|
if ((await this.readDeletedGraphs()).has(content.id))
|
|
158
144
|
return;
|
|
159
145
|
const raw = envelope('draft', { ...content, metadata: { ...content.metadata, updatedAt: new Date().toISOString() } });
|
|
160
146
|
const path = join(this.directory, 'graph-drafts', `${digest(raw)}.json`);
|
|
161
147
|
await mkdir(join(this.directory, 'graph-drafts'), { recursive: true });
|
|
162
148
|
await atomic(path, raw);
|
|
163
|
-
// The tombstone can land while this write is in flight: forgetGraph prunes drafts only
|
|
164
|
-
// after its own cleanup, so a write that read the tombstone before the deletion must not
|
|
165
|
-
// outlive it either. The file is dropped when the graph is tombstoned by the time it landed.
|
|
166
149
|
if ((await this.readDeletedGraphs()).has(content.id)) {
|
|
167
150
|
await unlink(path).catch(() => { });
|
|
168
151
|
return;
|
|
@@ -194,18 +177,6 @@ export class GraphSync {
|
|
|
194
177
|
}
|
|
195
178
|
return result.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
196
179
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Draft snapshots are immutable, and every sweep restores the ones the account holds, so a draft
|
|
199
|
-
* the user cleared cannot be unlinked: it would come back. Each cleared graph instead has its own
|
|
200
|
-
* marker file under `graph-drafts-cleared/`, naming the instant up to which its drafts are
|
|
201
|
-
* cleared and any snapshot dated after that instant (saved under a clock that ran ahead) that
|
|
202
|
-
* was cleared with them. The listing leaves those out; a later autosave is a new snapshot, newer
|
|
203
|
-
* than the mark, and is listed again. A cleared snapshot stays on disk and still opens by hash.
|
|
204
|
-
*
|
|
205
|
-
* One file per graph, replaced whole, so two editors sharing this folder cannot drop each
|
|
206
|
-
* other's clears: clears of different graphs touch different files, and two clears of the same
|
|
207
|
-
* graph each record every draft that graph had.
|
|
208
|
-
*/
|
|
209
180
|
async readClearedDrafts() {
|
|
210
181
|
const cleared = new Map();
|
|
211
182
|
for (const entry of await entries(join(this.directory, 'graph-drafts-cleared'))) {
|
|
@@ -218,11 +189,10 @@ export class GraphSync {
|
|
|
218
189
|
const snapshots = Array.isArray(saved.snapshots) ? saved.snapshots.filter((hash) => typeof hash === 'string' && /^[a-f0-9]{64}$/.test(hash)) : [];
|
|
219
190
|
cleared.set(saved.graphId, { at: saved.at, snapshots: new Set(snapshots) });
|
|
220
191
|
}
|
|
221
|
-
catch {
|
|
192
|
+
catch { }
|
|
222
193
|
}
|
|
223
194
|
return cleared;
|
|
224
195
|
}
|
|
225
|
-
/** Clear every draft the named graphs have right now, whatever clock dated them. */
|
|
226
196
|
async clearDrafts(graphIds) {
|
|
227
197
|
if (!Array.isArray(graphIds) || !graphIds.length || graphIds.length > 500 || graphIds.some(id => !safeId(id)))
|
|
228
198
|
throw new Error('Invalid draft');
|
|
@@ -230,8 +200,6 @@ export class GraphSync {
|
|
|
230
200
|
const [listed, cleared] = [await this.drafts(), await this.readClearedDrafts()];
|
|
231
201
|
await mkdir(join(this.directory, 'graph-drafts-cleared'), { recursive: true });
|
|
232
202
|
for (const id of wanted) {
|
|
233
|
-
// A snapshot dated at or before now is covered by the instant; only one dated later needs
|
|
234
|
-
// naming. Earlier names are kept while they stay ahead of the instant, newest 500 at most.
|
|
235
203
|
const ahead = listed.filter(item => item.graphId === id && item.updatedAt > now).map(item => item.snapshot);
|
|
236
204
|
const snapshots = [...new Set([...ahead, ...(cleared.get(id)?.snapshots ?? [])])].slice(0, 500);
|
|
237
205
|
await atomic(join(this.directory, 'graph-drafts-cleared', `${digest(id)}.json`), JSON.stringify({ graphId: id, at: now, snapshots }));
|
|
@@ -243,17 +211,10 @@ export class GraphSync {
|
|
|
243
211
|
throw new Error('Invalid draft');
|
|
244
212
|
return parseSnapshot(await readFile(join(this.directory, 'graph-drafts', `${hash}.json`), 'utf8'), hash).content;
|
|
245
213
|
}
|
|
246
|
-
/**
|
|
247
|
-
* The tombstones and their lineage floors are one durable record. Keeping them in one atomic
|
|
248
|
-
* replacement means a crash cannot publish a deletion without its floor (or vice versa).
|
|
249
|
-
* The legacy split files are read only for migration; the next mutation writes the combined file.
|
|
250
|
-
*/
|
|
251
214
|
async readDeletionState() {
|
|
252
215
|
const parse = (value) => {
|
|
253
216
|
const deleted = new Set();
|
|
254
217
|
const floors = Object.create(null);
|
|
255
|
-
// "pending" holds the head at deletion, not the historic cloud floor. It is paired
|
|
256
|
-
// with a marker in the old folder to distinguish interrupted removal from a new save.
|
|
257
218
|
const pending = Object.create(null);
|
|
258
219
|
if (Array.isArray(value)) {
|
|
259
220
|
for (const id of value)
|
|
@@ -286,7 +247,6 @@ export class GraphSync {
|
|
|
286
247
|
if (error.code !== 'ENOENT')
|
|
287
248
|
throw error;
|
|
288
249
|
}
|
|
289
|
-
// Upgrade older installations that persisted the two parts separately.
|
|
290
250
|
let deleted;
|
|
291
251
|
let floors;
|
|
292
252
|
try {
|
|
@@ -317,13 +277,6 @@ export class GraphSync {
|
|
|
317
277
|
}
|
|
318
278
|
async readDeletedGraphs() { return (await this.readDeletionState()).deleted; }
|
|
319
279
|
async readDeletedRevisions() { return (await this.readDeletionState()).floors; }
|
|
320
|
-
/**
|
|
321
|
-
* Read-modify-write the deletion state under one account-wide lock. Two editors deleting
|
|
322
|
-
* different graphs hold different graphs' save locks, so only a lock across the account stops
|
|
323
|
-
* one replacement from dropping the other's deletion; reviveGraph is serialized by it too.
|
|
324
|
-
* A deletion records its floor in the same lock hold, so a revival can never inherit a floor
|
|
325
|
-
* without the tombstone that justifies it.
|
|
326
|
-
*/
|
|
327
280
|
async updateDeletionState(mutate, maxAttempts = 80) {
|
|
328
281
|
const release = await this.acquireAccountLock(maxAttempts);
|
|
329
282
|
try {
|
|
@@ -336,12 +289,6 @@ export class GraphSync {
|
|
|
336
289
|
await release();
|
|
337
290
|
}
|
|
338
291
|
}
|
|
339
|
-
/**
|
|
340
|
-
* The account-wide lock every tombstone change and deletion tail runs under: two editors
|
|
341
|
-
* deleting different graphs hold different graphs' save locks, so only a lock across the
|
|
342
|
-
* account stops one replacement from dropping the other's deletion, and reviveGraph is
|
|
343
|
-
* serialized by it too.
|
|
344
|
-
*/
|
|
345
292
|
async acquireAccountLock(maxAttempts = 80) {
|
|
346
293
|
for (let attempt = 0;; attempt++) {
|
|
347
294
|
try {
|
|
@@ -356,18 +303,9 @@ export class GraphSync {
|
|
|
356
303
|
}
|
|
357
304
|
}
|
|
358
305
|
}
|
|
359
|
-
/**
|
|
360
|
-
* The user deleted a graph. Record that before removing anything: the tombstone is written under
|
|
361
|
-
* the graph's save lock, and every later cloud restore re-reads it under the same lock, so a pass
|
|
362
|
-
* running while the delete lands cannot write the graph back. The graph's drafts die with it —
|
|
363
|
-
* each draft snapshot names a graph, and none is left to open. The newest revision the folder had
|
|
364
|
-
* reached is recorded with the tombstone: it is the floor a later revival needs to keep the old
|
|
365
|
-
* lineage's cloud revisions from advancing a replacement.
|
|
366
|
-
*/
|
|
367
306
|
async forgetGraph(id) {
|
|
368
307
|
if (!safeId(id) || id === 'default')
|
|
369
308
|
throw new Error('Invalid graph id');
|
|
370
|
-
// Built in: there is no stored graph to remove, and a tombstone would outlive a delete that removed nothing.
|
|
371
309
|
if (id === GRAPH_MANAGER_GRAPH_ID)
|
|
372
310
|
throw reservedGraphId(id);
|
|
373
311
|
await mkdir(this.folder, { recursive: true });
|
|
@@ -385,14 +323,9 @@ export class GraphSync {
|
|
|
385
323
|
await delay(25);
|
|
386
324
|
}
|
|
387
325
|
}
|
|
388
|
-
// Acquire the account lock once and keep it continuously from the tombstone/floor commit
|
|
389
|
-
// through folder removal and draft pruning. This blocks a concurrent revival from clearing
|
|
390
|
-
// the tombstone between those steps, and every failure path releases both locks.
|
|
391
326
|
let accountRelease;
|
|
392
327
|
try {
|
|
393
328
|
accountRelease = await this.acquireAccountLock();
|
|
394
|
-
// Read while the storage is still there: after the removal the folder no longer says how
|
|
395
|
-
// far the deleted graph had come.
|
|
396
329
|
let newest = 0;
|
|
397
330
|
try {
|
|
398
331
|
const value = JSON.parse(await readFile(join(folder, 'latest.json'), 'utf8'));
|
|
@@ -403,9 +336,6 @@ export class GraphSync {
|
|
|
403
336
|
if (error.code !== 'ENOENT')
|
|
404
337
|
throw error;
|
|
405
338
|
}
|
|
406
|
-
// Publish the old folder's identity before the tombstone: a crash after the tombstone
|
|
407
|
-
// but before detach leaves proof that even an uncached graph is deletion residue.
|
|
408
|
-
// A newly-created folder lacks this marker; a save to this same folder advances its head.
|
|
409
339
|
await writeFile(join(folder, DELETION_MARKER), JSON.stringify({ head: newest }), { mode: 0o600 });
|
|
410
340
|
const { deleted, floors, pending } = await this.readDeletionState();
|
|
411
341
|
let changed = false;
|
|
@@ -413,7 +343,6 @@ export class GraphSync {
|
|
|
413
343
|
deleted.add(id);
|
|
414
344
|
changed = true;
|
|
415
345
|
}
|
|
416
|
-
// A re-created id can be deleted again: never lower a previous lineage's floor.
|
|
417
346
|
if (newest >= 1 && newest > (floors[id] ?? 0)) {
|
|
418
347
|
floors[id] = newest;
|
|
419
348
|
changed = true;
|
|
@@ -424,8 +353,6 @@ export class GraphSync {
|
|
|
424
353
|
}
|
|
425
354
|
if (changed)
|
|
426
355
|
await atomic(join(this.folder, 'deletion-state.json'), JSON.stringify({ deleted: [...deleted], floors, pending }));
|
|
427
|
-
// The graph lock prevents restores/saves to this id; the account lock prevents revival and
|
|
428
|
-
// concurrent tombstone mutations until both the folder and drafts are gone.
|
|
429
356
|
await removeLockedFolder(folder);
|
|
430
357
|
await release();
|
|
431
358
|
await this.pruneDrafts(id);
|
|
@@ -438,7 +365,6 @@ export class GraphSync {
|
|
|
438
365
|
this.status = { state: 'pending', detail: 'Graph deleted; cloud sync pending' };
|
|
439
366
|
void this.sync();
|
|
440
367
|
}
|
|
441
|
-
/** Remove every draft that names the graph: its drafts die with it. The caller holds the account lock. */
|
|
442
368
|
async pruneDrafts(id) {
|
|
443
369
|
for (const entry of await entries(join(this.directory, 'graph-drafts'))) {
|
|
444
370
|
if (!entry.isFile() || !/^[a-f0-9]{64}\.json$/.test(entry.name))
|
|
@@ -455,17 +381,9 @@ export class GraphSync {
|
|
|
455
381
|
}
|
|
456
382
|
this.lastDraft.delete(id);
|
|
457
383
|
}
|
|
458
|
-
/**
|
|
459
|
-
* A graph with this id was saved again: its cloud snapshots may restore once more. The floor
|
|
460
|
-
* recorded at the deletion stays — it is what keeps the old lineage's revisions from advancing
|
|
461
|
-
* the replacement's latest pointer.
|
|
462
|
-
*/
|
|
463
384
|
async reviveGraph(id) {
|
|
464
385
|
if (!safeId(id) || id === 'default' || id === GRAPH_MANAGER_GRAPH_ID)
|
|
465
386
|
return;
|
|
466
|
-
// A slow draft prune can hold the account lock past the normal two-second budget.
|
|
467
|
-
// A successful save must not return while its tombstone remains: keep retrying the
|
|
468
|
-
// durable revival, and propagate a real failure instead of silently swallowing it.
|
|
469
387
|
await this.updateDeletionState((deleted, _floors, pending) => {
|
|
470
388
|
const changed = deleted.delete(id) || Object.hasOwn(pending, id);
|
|
471
389
|
delete pending[id];
|
|
@@ -505,15 +423,6 @@ export class GraphSync {
|
|
|
505
423
|
throw error;
|
|
506
424
|
}
|
|
507
425
|
}
|
|
508
|
-
/**
|
|
509
|
-
* A committed tombstone has two possible local folders: the old folder an interrupted
|
|
510
|
-
* delete did not detach, or a replacement published while revival waited for the account
|
|
511
|
-
* lock. The deletion marker and head at deletion identify only the former. Legacy
|
|
512
|
-
* tombstones have no marker, so retain the existing conservative cached-head check.
|
|
513
|
-
*
|
|
514
|
-
* Lock order matches forgetGraph (graph, then account); inspect fresh state only while
|
|
515
|
-
* holding both locks, so a concurrent save/revival cannot be removed by a stale pass.
|
|
516
|
-
*/
|
|
517
426
|
async reconcileDeletedFolders(deleted) {
|
|
518
427
|
for (const id of deleted) {
|
|
519
428
|
const folder = join(this.directory, 'graphs', id);
|
|
@@ -563,14 +472,12 @@ export class GraphSync {
|
|
|
563
472
|
if (object(value) && Number.isSafeInteger(value.head) && value.head >= 0)
|
|
564
473
|
marker = value.head;
|
|
565
474
|
}
|
|
566
|
-
catch {
|
|
475
|
+
catch { }
|
|
567
476
|
if (marker === pending && head === pending) {
|
|
568
477
|
await removeLockedFolder(folder);
|
|
569
478
|
await this.pruneDrafts(id);
|
|
570
479
|
}
|
|
571
480
|
else if (head >= 1) {
|
|
572
|
-
// A new folder (no marker) or an advanced head is a save performed after the
|
|
573
|
-
// tombstone. Complete its interrupted revival while preserving the old floor.
|
|
574
481
|
state.deleted.delete(id);
|
|
575
482
|
delete state.pending[id];
|
|
576
483
|
await atomic(join(this.folder, 'deletion-state.json'), JSON.stringify({ deleted: [...state.deleted], floors: state.floors, pending: state.pending }));
|
|
@@ -578,8 +485,6 @@ export class GraphSync {
|
|
|
578
485
|
}
|
|
579
486
|
}
|
|
580
487
|
else if (head >= 1) {
|
|
581
|
-
// Legacy interrupted deletes have no marker. Only an uploaded, cached head
|
|
582
|
-
// demonstrates the old lineage, so never destroy an uncached legacy folder.
|
|
583
488
|
const hash = digest(envelope('revision', JSON.parse(await readFile(join(folder, `${head}.json`), 'utf8'))));
|
|
584
489
|
if (await this.cached(hash)) {
|
|
585
490
|
await removeLockedFolder(folder);
|
|
@@ -591,7 +496,7 @@ export class GraphSync {
|
|
|
591
496
|
await accountRelease();
|
|
592
497
|
}
|
|
593
498
|
}
|
|
594
|
-
catch {
|
|
499
|
+
catch { }
|
|
595
500
|
finally {
|
|
596
501
|
await release?.();
|
|
597
502
|
}
|
|
@@ -613,7 +518,6 @@ export class GraphSync {
|
|
|
613
518
|
await response.body?.cancel();
|
|
614
519
|
if (response.status === 401 || response.status === 403)
|
|
615
520
|
this.accessDenied = true;
|
|
616
|
-
// The account service refuses a snapshot the free allowance does not cover; the account keeps its access.
|
|
617
521
|
if (response.status === 422 && body !== undefined)
|
|
618
522
|
throw new SnapshotRefused();
|
|
619
523
|
throw new Error('Cloud sync failed');
|
|
@@ -642,20 +546,11 @@ export class GraphSync {
|
|
|
642
546
|
}
|
|
643
547
|
async perform() {
|
|
644
548
|
this.deadline = this.now() + 20_000;
|
|
645
|
-
// The timer re-checks an account that is already in sync every 30 seconds, and the local sweep
|
|
646
|
-
// takes several passes to visit every file. Saying "Saving…" and then "will resume" for each of
|
|
647
|
-
// them would take back a verdict nothing has changed: while a pass sends nothing, the account
|
|
648
|
-
// stays synced. A save or delete replaces this object, and so does the first upload of the pass
|
|
649
|
-
// (a revision save marks nothing pending), so a change during the pass is reported.
|
|
650
549
|
const recheck = this.status.state === 'synced' ? this.status : undefined;
|
|
651
550
|
this.status = recheck ?? { state: 'syncing', detail: 'Saving graphs to your account…' };
|
|
652
|
-
// Repair interrupted local deletions before network authorization: even an offline machine
|
|
653
|
-
// must not show a graph whose tombstone was committed before a crash. A save that landed
|
|
654
|
-
// after that tombstone is revived rather than removed.
|
|
655
551
|
await mkdir(join(this.folder, 'snapshots'), { recursive: true });
|
|
656
552
|
await this.reconcileDeletedFolders(await this.readDeletedGraphs());
|
|
657
553
|
const deleted = await this.readDeletedGraphs();
|
|
658
|
-
// Token acquisition may wait for a refresh rotation; check the account afterwards.
|
|
659
554
|
const token = await this.deps.token(this.closer.signal);
|
|
660
555
|
if (!token)
|
|
661
556
|
throw new Error('Sign in required');
|
|
@@ -666,15 +561,11 @@ export class GraphSync {
|
|
|
666
561
|
let receipts = {};
|
|
667
562
|
try {
|
|
668
563
|
const saved = JSON.parse(await readFile(join(this.folder, 'receipts.json'), 'utf8'));
|
|
669
|
-
// A receipt names the exact bytes that were uploaded; a damaged entry would let an upload be
|
|
670
|
-
// skipped, so the whole file is dropped and the immutable snapshots are offered again.
|
|
671
564
|
if (!object(saved) || !Object.values(saved).every(value => typeof value === 'string'))
|
|
672
565
|
throw new Error('Invalid receipts');
|
|
673
566
|
receipts = saved;
|
|
674
567
|
}
|
|
675
|
-
catch {
|
|
676
|
-
// Reserve most of the pass for remote traversal. Checkpoint each local file so
|
|
677
|
-
// large histories do not restart their body reads after every timeout/restart.
|
|
568
|
+
catch { }
|
|
678
569
|
const localPath = join(this.folder, 'local-progress.json');
|
|
679
570
|
let local = {};
|
|
680
571
|
try {
|
|
@@ -689,24 +580,11 @@ export class GraphSync {
|
|
|
689
580
|
local = saved;
|
|
690
581
|
}
|
|
691
582
|
catch {
|
|
692
|
-
// The checkpoint only remembers how far a pass got, so a file a killed pass or a failed
|
|
693
|
-
// replacement left behind must not stop every later pass: starting the local history again
|
|
694
|
-
// re-uploads the same immutable snapshots, which are receipts and cost a file read each.
|
|
695
583
|
}
|
|
696
584
|
const localDeadline = Math.min(this.deadline, this.now() + 5000);
|
|
697
585
|
let processed = 0, localComplete = false;
|
|
698
586
|
const refused = new Set(local.refused ?? []);
|
|
699
|
-
/** Upload one local file; whether a request was sent, so a receipt costs no budget. */
|
|
700
|
-
// Set once the kept graph is known: re-sends its latest revision with the pin request, at most once
|
|
701
|
-
// a pass. Called on a refusal, because a refusal is the service saying the account is free and the
|
|
702
|
-
// pin may be missing — a graph uploaded on a paid plan never set it, and its cached revision is not
|
|
703
|
-
// sent again otherwise. A paid account is never refused, so it never pays for the request.
|
|
704
587
|
let confirmKept;
|
|
705
|
-
/**
|
|
706
|
-
* `pin` names this revision's graph as the one a free account keeps (the service ignores it for a
|
|
707
|
-
* paid account); `confirm` sends it even when a receipt or the cache says it was uploaded, because
|
|
708
|
-
* an upload made on a paid plan never set the free pin.
|
|
709
|
-
*/
|
|
710
588
|
const upload = async (path, kind, filename, options = {}) => {
|
|
711
589
|
let raw;
|
|
712
590
|
try {
|
|
@@ -722,8 +600,6 @@ export class GraphSync {
|
|
|
722
600
|
}
|
|
723
601
|
const hash = digest(raw);
|
|
724
602
|
if (options.confirm || !await this.cached(hash)) {
|
|
725
|
-
// A refused snapshot stays on this machine and is offered again on a later sweep, so an
|
|
726
|
-
// upgraded account uploads it then.
|
|
727
603
|
if (this.status === recheck)
|
|
728
604
|
this.status = { state: 'syncing', detail: 'Saving graphs to your account…' };
|
|
729
605
|
try {
|
|
@@ -732,7 +608,6 @@ export class GraphSync {
|
|
|
732
608
|
catch (error) {
|
|
733
609
|
if (!(error instanceof SnapshotRefused))
|
|
734
610
|
throw error;
|
|
735
|
-
// Saved with the checkpoint the caller writes next, so a later pass of this sweep still knows.
|
|
736
611
|
refused.add(relative(this.directory, path).replace(/\\/g, '/'));
|
|
737
612
|
local.refused = [...refused];
|
|
738
613
|
await confirmKept?.();
|
|
@@ -745,20 +620,7 @@ export class GraphSync {
|
|
|
745
620
|
};
|
|
746
621
|
const exhausted = () => processed >= 32 || this.now() >= localDeadline || this.stopped;
|
|
747
622
|
if (!local.drafts) {
|
|
748
|
-
// A folder a tombstone still names is either deletion residue (reconciled above) or a
|
|
749
|
-
// replacement whose revival has not landed yet: uploading either would put a deleted
|
|
750
|
-
// graph's revisions back into the cloud. The revival clears the tombstone, and the next
|
|
751
|
-
// sweep then uploads the replacement.
|
|
752
623
|
const dirs = (await entries(join(this.directory, 'graphs'))).filter(dir => dir.isDirectory() && safeId(dir.name) && !deleted.has(dir.name)).sort((a, b) => a.name < b.name ? -1 : 1);
|
|
753
|
-
// A free account's cloud allowance is pinned to the first graph whose revision arrives, and the
|
|
754
|
-
// graph it keeps here is its oldest. One revision of the kept graph therefore goes first in every
|
|
755
|
-
// sweep, so the two agree whatever the ids' order; one is enough to set the pin. The checkpoint
|
|
756
|
-
// below is untouched: that upload is a receipt when the sweep reaches the graph.
|
|
757
|
-
// The service pins a free account's allowance only to a revision sent with the pin request, so the
|
|
758
|
-
// graph it keeps here — its oldest — names itself: its revisions carry the request, and no other
|
|
759
|
-
// graph's upload can take the pin whatever order the sweep visits them in. Its latest revision is
|
|
760
|
-
// the one that claims the pin: it is what the user edits, so it is the revision the allowance
|
|
761
|
-
// accepts once the graph is within it, where an older one may still carry an Orchestrator.
|
|
762
624
|
const kept = (await readGraphQuota(this.directory).catch(() => undefined))?.freeGraphId;
|
|
763
625
|
const latest = kept && dirs.some(dir => dir.name === kept)
|
|
764
626
|
? (await entries(join(this.directory, 'graphs', kept))).filter(file => file.isFile() && /^\d+\.json$/.test(file.name))
|
|
@@ -772,8 +634,6 @@ export class GraphSync {
|
|
|
772
634
|
confirmed = true;
|
|
773
635
|
await upload(join(this.directory, 'graphs', kept, latest.name), 'revision', latest.name, { pin: true, confirm: true });
|
|
774
636
|
};
|
|
775
|
-
// First in a sweep, so the pin is in place before the kept graph's older revisions arrive. A
|
|
776
|
-
// request it sends takes a slot of the batch, which bounds the requests of a pass.
|
|
777
637
|
if (!local.directory && await upload(join(this.directory, 'graphs', kept, latest.name), 'revision', latest.name, { pin: true }))
|
|
778
638
|
processed++;
|
|
779
639
|
}
|
|
@@ -808,8 +668,6 @@ export class GraphSync {
|
|
|
808
668
|
localComplete = false;
|
|
809
669
|
break;
|
|
810
670
|
}
|
|
811
|
-
// A draft of a deleted graph is residue from a restore that raced the delete; prune it so
|
|
812
|
-
// the graph's tombstone keeps every trace of the graph off this machine.
|
|
813
671
|
if (deleted.size) {
|
|
814
672
|
try {
|
|
815
673
|
const raw = await readFile(join(this.directory, 'graph-drafts', file.name), 'utf8');
|
|
@@ -821,7 +679,7 @@ export class GraphSync {
|
|
|
821
679
|
continue;
|
|
822
680
|
}
|
|
823
681
|
}
|
|
824
|
-
catch {
|
|
682
|
+
catch { }
|
|
825
683
|
}
|
|
826
684
|
await upload(join(this.directory, 'graph-drafts', file.name), 'draft', file.name);
|
|
827
685
|
local.file = file.name;
|
|
@@ -849,12 +707,7 @@ export class GraphSync {
|
|
|
849
707
|
progress = saved;
|
|
850
708
|
}
|
|
851
709
|
catch {
|
|
852
|
-
// Same as the local checkpoint: a damaged one restarts this sweep rather than failing the
|
|
853
|
-
// sync on every pass until someone deletes the file.
|
|
854
710
|
}
|
|
855
|
-
// Checkpoint both the page and each completed hash so even a single slow page can
|
|
856
|
-
// finish over multiple bounded passes and process restarts. A completed sweep
|
|
857
|
-
// resets to the beginning: hash ordering is not a chronological change feed.
|
|
858
711
|
for (;;) {
|
|
859
712
|
this.checkBudget();
|
|
860
713
|
if (!progress.page) {
|
|
@@ -872,9 +725,6 @@ export class GraphSync {
|
|
|
872
725
|
const raw = await this.cached(hash)
|
|
873
726
|
? await readFile(join(this.folder, 'snapshots', `${hash}.json`), 'utf8')
|
|
874
727
|
: await this.request(`/${hash}`, token);
|
|
875
|
-
// A cloud receipt proves upload, not that its user-visible copy still exists.
|
|
876
|
-
// A graph another window's sweep or a save is writing right now is not a sync failure:
|
|
877
|
-
// the checkpoint keeps this snapshot first, and the next pass restores it.
|
|
878
728
|
try {
|
|
879
729
|
await this.restoreSnapshot(raw, hash, receipts, deleted);
|
|
880
730
|
}
|
|
@@ -906,7 +756,6 @@ export class GraphSync {
|
|
|
906
756
|
const previous = await readFile(path, 'utf8');
|
|
907
757
|
if (previous === raw)
|
|
908
758
|
return;
|
|
909
|
-
// Preserve damaged bytes before making the verified cached draft recoverable.
|
|
910
759
|
await rename(path, `${path}.${randomUUID()}.damaged`);
|
|
911
760
|
}
|
|
912
761
|
catch (error) {
|
|
@@ -915,13 +764,6 @@ export class GraphSync {
|
|
|
915
764
|
}
|
|
916
765
|
await immutable(path, raw);
|
|
917
766
|
}
|
|
918
|
-
/**
|
|
919
|
-
* Whether this exact snapshot is already published here, read without the save lock. Revision
|
|
920
|
-
* files are immutable, so a published one cannot change under the read; anything less than a
|
|
921
|
-
* published copy with these exact contents — a missing or different file, an unpublished one past
|
|
922
|
-
* the latest pointer, a conflict — is left to the locked restore, which decides it. The conflict
|
|
923
|
-
* copy's id is derived from this snapshot's hash, so its receipt can only be this snapshot's.
|
|
924
|
-
*/
|
|
925
767
|
async alreadyRestored(graph, hash, receipts) {
|
|
926
768
|
const published = async (id, matches) => {
|
|
927
769
|
try {
|
|
@@ -943,14 +785,10 @@ export class GraphSync {
|
|
|
943
785
|
}
|
|
944
786
|
async restoreSnapshot(raw, hash, receipts, deleted) {
|
|
945
787
|
const value = parseSnapshot(raw, hash);
|
|
946
|
-
// A graph deleted on this machine stays deleted: its snapshots stay cached but restore no
|
|
947
|
-
// more. A draft restored in the window between a delete and this verdict is pruned by the
|
|
948
|
-
// next pass over the local drafts; the revision path below closes its own race under the lock.
|
|
949
788
|
if (deleted.has(value.graphId)) {
|
|
950
789
|
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
951
790
|
return;
|
|
952
791
|
}
|
|
953
|
-
// Never overwrite a local graph. Stable recovery IDs retain conflicting versions.
|
|
954
792
|
if (value.kind === 'revision') {
|
|
955
793
|
let graph;
|
|
956
794
|
try {
|
|
@@ -961,24 +799,15 @@ export class GraphSync {
|
|
|
961
799
|
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
962
800
|
return;
|
|
963
801
|
}
|
|
964
|
-
// Every sweep visits every snapshot the account holds, and a restore takes the graph's save
|
|
965
|
-
// lock. A revision this machine already holds needs no restore, so it must not take the lock:
|
|
966
|
-
// each window's engine runs its own sweep, and hundreds of needless locks per pass made the
|
|
967
|
-
// sweeps collide with each other and with the user's saves until no pass could finish.
|
|
968
802
|
if (await this.alreadyRestored(graph, hash, receipts)) {
|
|
969
803
|
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
970
804
|
return;
|
|
971
805
|
}
|
|
972
|
-
// The guard re-reads the tombstone file under the graph's save lock, so a delete that landed
|
|
973
|
-
// while this pass was running is honored even though this pass read an older verdict.
|
|
974
806
|
let restored = true;
|
|
975
807
|
try {
|
|
976
808
|
({ restored } = await restoreGraphRevision(graph, this.directory, async (candidate) => (await this.readDeletedGraphs()).has(candidate.id), async (candidate) => (await this.readDeletedRevisions())[candidate.id]));
|
|
977
809
|
}
|
|
978
810
|
catch (error) {
|
|
979
|
-
// Never overwrite a local graph: a conflicting revision is kept beside the original under
|
|
980
|
-
// a stable recovery id. The recovery copy is a graph like any other, so the same deletion
|
|
981
|
-
// guard applies to it: a recovery id the user deleted is not written back either.
|
|
982
811
|
if (!(error instanceof GraphConflictError))
|
|
983
812
|
throw error;
|
|
984
813
|
graph = { ...graph, id: `cloud-${hash.slice(0, 40)}`, name: `${graph.name} (conflict r${graph.revision})`.slice(0, 120) };
|
|
@@ -1000,45 +829,29 @@ export class GraphSync {
|
|
|
1000
829
|
await immutable(join(this.folder, 'snapshots', `${hash}.json`), raw);
|
|
1001
830
|
}
|
|
1002
831
|
}
|
|
1003
|
-
/** How long a first listing waits for the account's graphs; a pass over a whole account outlasts it. */
|
|
1004
832
|
const FIRST_PASS_WAIT_MS = 5_000;
|
|
1005
833
|
export class GraphAccessSync {
|
|
1006
834
|
factory;
|
|
1007
835
|
firstPassWaitMs;
|
|
1008
836
|
onSynced;
|
|
1009
837
|
current;
|
|
1010
|
-
/**
|
|
1011
|
-
* `onSynced` is called when a first pass finishes after a listing answered from the copy that was
|
|
1012
|
-
* already on disk: that listing described a state the pass has since changed, so the surface behind
|
|
1013
|
-
* it has to read again.
|
|
1014
|
-
*/
|
|
1015
838
|
constructor(factory = (directory, subject) => new GraphSync(directory, subject), firstPassWaitMs = FIRST_PASS_WAIT_MS, onSynced = () => { }) {
|
|
1016
839
|
this.factory = factory;
|
|
1017
840
|
this.firstPassWaitMs = firstPassWaitMs;
|
|
1018
841
|
this.onSynced = onSynced;
|
|
1019
842
|
}
|
|
1020
|
-
/**
|
|
1021
|
-
* Tell whoever is showing a listing that this account's first pass has changed the copy on disk.
|
|
1022
|
-
*
|
|
1023
|
-
* Only listings that answered before the pass finished need this, and only one announcement per pass
|
|
1024
|
-
* is made: a window that lists twice during startup sees both answers from the pre-sync copy, and one
|
|
1025
|
-
* re-read serves both.
|
|
1026
|
-
*/
|
|
1027
843
|
announceWhenSettled(entry) {
|
|
1028
844
|
if (entry.settled || entry.announced)
|
|
1029
845
|
return;
|
|
1030
846
|
entry.announced = true;
|
|
1031
847
|
void entry.ready.then(() => this.onSynced(), () => { });
|
|
1032
848
|
}
|
|
1033
|
-
/** Start (or switch to) the sync for this account's storage and wait a bounded first pass. */
|
|
1034
849
|
async ensure(directory, subject) {
|
|
1035
850
|
const key = `${directory}\0${subject}`;
|
|
1036
851
|
if (this.current?.key !== key) {
|
|
1037
852
|
const previous = this.current?.sync;
|
|
1038
853
|
const sync = this.factory(directory, subject);
|
|
1039
854
|
const current = { key, sync, ready: Promise.resolve(), settled: false, waited: false, announced: false };
|
|
1040
|
-
// Published before the first await, because the startup below has to be able to find and drop
|
|
1041
|
-
// its own entry.
|
|
1042
855
|
this.current = current;
|
|
1043
856
|
current.ready = (async () => {
|
|
1044
857
|
await previous?.close().catch(() => { });
|
|
@@ -1046,9 +859,6 @@ export class GraphAccessSync {
|
|
|
1046
859
|
await sync.start();
|
|
1047
860
|
}
|
|
1048
861
|
catch (error) {
|
|
1049
|
-
// A startup that failed — a transient failure creating the account directory, say — must not
|
|
1050
|
-
// disable the account for the rest of the process: this entry remembers that it waited, so
|
|
1051
|
-
// leaving it in place would answer every later listing without ever trying again.
|
|
1052
862
|
await sync.close().catch(() => { });
|
|
1053
863
|
if (this.current === current)
|
|
1054
864
|
this.current = undefined;
|
|
@@ -1061,9 +871,6 @@ export class GraphAccessSync {
|
|
|
1061
871
|
}
|
|
1062
872
|
const current = this.current;
|
|
1063
873
|
if (current.waited) {
|
|
1064
|
-
// A listing that arrives while the first one's pass is still running answers from the copy on
|
|
1065
|
-
// disk without waiting again — and the listing that did wait may already be obsolete on the
|
|
1066
|
-
// client, so this one has to carry the notice the waiting one could not.
|
|
1067
874
|
this.announceWhenSettled(current);
|
|
1068
875
|
return;
|
|
1069
876
|
}
|
|
@@ -1074,8 +881,6 @@ export class GraphAccessSync {
|
|
|
1074
881
|
current.ready.then(() => false, () => false),
|
|
1075
882
|
new Promise(resolve => { timer = setTimeout(() => resolve(true), this.firstPassWaitMs); timer.unref?.(); }),
|
|
1076
883
|
]);
|
|
1077
|
-
// The listing this waits for answers from the copy already on disk, so whoever asked is told
|
|
1078
|
-
// when the pass it could not wait for has changed that copy.
|
|
1079
884
|
if (stillRunning)
|
|
1080
885
|
this.announceWhenSettled(current);
|
|
1081
886
|
}
|
|
@@ -1084,7 +889,6 @@ export class GraphAccessSync {
|
|
|
1084
889
|
clearTimeout(timer);
|
|
1085
890
|
}
|
|
1086
891
|
}
|
|
1087
|
-
/** Stop syncing for the account this caller served. */
|
|
1088
892
|
async close() {
|
|
1089
893
|
const current = this.current;
|
|
1090
894
|
this.current = undefined;
|
package/dist/src/graph-tool.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Tool } from './types.js';
|
|
2
|
-
/** What the tool needs from the graph backend; `AgentMcpBackend` in production. */
|
|
3
2
|
export interface GraphBackend {
|
|
4
3
|
call(name: string, args: unknown, options?: {
|
|
5
4
|
beforeSave?: () => void;
|
|
@@ -12,14 +11,6 @@ export interface GraphBackend {
|
|
|
12
11
|
}>;
|
|
13
12
|
close(): Promise<void>;
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
16
|
-
* One graph backend per installation directory, created on the first graph action and closed after
|
|
17
|
-
* an idle hour.
|
|
18
|
-
*
|
|
19
|
-
* Shared across the tasks of one process so a draft begun in one task survives into the next, and so
|
|
20
|
-
* at most one cloud-sync loop runs per home however many tasks touch graphs. Nothing is loaded until
|
|
21
|
-
* a graph action runs: the backend module pulls in graph sync, membership and the subagent runner.
|
|
22
|
-
*/
|
|
23
14
|
export declare class GraphBackendPool {
|
|
24
15
|
private readonly options;
|
|
25
16
|
private readonly entries;
|
|
@@ -36,17 +27,8 @@ export declare class GraphBackendPool {
|
|
|
36
27
|
ok: false;
|
|
37
28
|
error: unknown;
|
|
38
29
|
}>;
|
|
39
|
-
/** Close every backend (tests, shutdown). A later action opens a fresh one. */
|
|
40
30
|
close(): Promise<void>;
|
|
41
|
-
/** Open backends, by directory; for tests that prove laziness and idle closing. */
|
|
42
31
|
get size(): number;
|
|
43
32
|
private closeEntry;
|
|
44
33
|
}
|
|
45
|
-
/**
|
|
46
|
-
* The engine's built-in graph authoring tool: the graph MCP server's graph actions, in process.
|
|
47
|
-
*
|
|
48
|
-
* Agents inside Andorra get graph authoring without a configured MCP server, a child process or an
|
|
49
|
-
* `andorra` command on PATH. One tool with an `action` keeps every request's schema small; the action
|
|
50
|
-
* names are the MCP tool names, so the guide, the graph-manager skill and the error codes apply as-is.
|
|
51
|
-
*/
|
|
52
34
|
export declare function createGraphTool(pool?: GraphBackendPool): Tool;
|