@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
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
// Git operations behind Orchestrator delegation: snapshot the working folder, give a writing
|
|
2
|
-
// subagent a worktree that starts from that snapshot, collect what it changed, and land the
|
|
3
|
-
// change back as uncommitted edits with a three-way merge.
|
|
4
|
-
//
|
|
5
|
-
// Every operation here works on private objects. The user's index, refs, stash and branches are
|
|
6
|
-
// never read for state or written: snapshots use a temporary index file and dangling commits, and
|
|
7
|
-
// landing writes nothing but working-tree files, and puts every one of them back if it fails partway.
|
|
8
1
|
import { execFile } from 'node:child_process';
|
|
9
2
|
import { promisify } from 'node:util';
|
|
10
3
|
import { chmod, copyFile, lstat, mkdir, mkdtemp, readFile, readdir, readlink, realpath, rm, rmdir, symlink, writeFile } from 'node:fs/promises';
|
|
@@ -12,31 +5,15 @@ import { tmpdir } from 'node:os';
|
|
|
12
5
|
import { basename, dirname, join } from 'node:path';
|
|
13
6
|
import { isWindowsDeviceName } from './stray-files.js';
|
|
14
7
|
const exec = promisify(execFile);
|
|
15
|
-
/** Characters of a change's diff that are inlined into the spawn observation. */
|
|
16
8
|
export const DELEGATION_DIFF_LIMIT = 20_000;
|
|
17
9
|
const WORKTREE_PREFIX = 'andorra-subagent-';
|
|
18
10
|
const GIT_TIMEOUT_MS = 15_000;
|
|
19
|
-
// Snapshotting and diffing a whole working folder is bounded by its size, not by a single status.
|
|
20
11
|
const BULK_TIMEOUT_MS = 120_000;
|
|
21
12
|
const DIFF_MAX_BUFFER = 256 * 1024 * 1024;
|
|
22
|
-
// `git add -A` over a whole folder can print a warning per file (line-ending conversion notices).
|
|
23
13
|
const ADD_MAX_BUFFER = 64 * 1024 * 1024;
|
|
24
|
-
// A process a subagent started may still be letting go of a file when its worktree is removed.
|
|
25
14
|
const REMOVE_RETRIES = { maxRetries: 5, retryDelay: 100 };
|
|
26
|
-
// The hooks and fsmonitor settings are the same hardening the existing worktree path applies: a
|
|
27
|
-
// repository must not get to run its own programs because a subagent was spawned. safecrlf is off
|
|
28
|
-
// because a snapshot takes the files as they are: with `core.safecrlf=true` Git refuses to add a
|
|
29
|
-
// file whose line endings its own conversion would change, and the snapshot would fail.
|
|
30
|
-
// longpaths is on because one file whose path is over Windows' 260 characters would otherwise fail
|
|
31
|
-
// the snapshot, and with it every delegation, until the user removed the file by hand.
|
|
32
15
|
const HARDENED = ['-c', 'core.hooksPath=', '-c', 'core.fsmonitor=false', '-c', 'core.safecrlf=false', '-c', 'core.longpaths=true'];
|
|
33
|
-
// Patches are made with the diff-tree plumbing, not porcelain `git diff`: porcelain honours the
|
|
34
|
-
// user's diff.noprefix, diff.external, colour and textconv settings, any of which turns a clean
|
|
35
|
-
// merge into a patch `git apply` rejects or rewrites. Plumbing ignores them by default; the
|
|
36
|
-
// switches make that explicit.
|
|
37
16
|
const PATCH = ['diff-tree', '-r', '--no-color', '--no-ext-diff', '--no-textconv'];
|
|
38
|
-
// Snapshot commits are private, so they carry a fixed identity rather than requiring the user to
|
|
39
|
-
// have configured one.
|
|
40
17
|
const SNAPSHOT_IDENTITY = {
|
|
41
18
|
GIT_AUTHOR_NAME: 'Andorra', GIT_AUTHOR_EMAIL: 'andorra@localhost',
|
|
42
19
|
GIT_COMMITTER_NAME: 'Andorra', GIT_COMMITTER_EMAIL: 'andorra@localhost',
|
|
@@ -48,14 +25,12 @@ async function git(cwd, args, options = {}) {
|
|
|
48
25
|
});
|
|
49
26
|
return stdout;
|
|
50
27
|
}
|
|
51
|
-
/** Removes a temporary directory this module made. A failure here never replaces the error that led to it. */
|
|
52
28
|
async function removeQuietly(directory) {
|
|
53
29
|
try {
|
|
54
30
|
await rm(directory, { recursive: true, force: true, ...REMOVE_RETRIES });
|
|
55
31
|
}
|
|
56
|
-
catch {
|
|
32
|
+
catch { }
|
|
57
33
|
}
|
|
58
|
-
/** Runs the callback with a temporary index file that is removed afterwards. */
|
|
59
34
|
async function withTemporaryIndex(callback) {
|
|
60
35
|
const directory = await mkdtemp(join(tmpdir(), 'andorra-index-'));
|
|
61
36
|
try {
|
|
@@ -65,17 +40,7 @@ async function withTemporaryIndex(callback) {
|
|
|
65
40
|
await removeQuietly(directory);
|
|
66
41
|
}
|
|
67
42
|
}
|
|
68
|
-
// Andorra's own runtime files (job logs of AsyncProcess, QA run output) are written under
|
|
69
|
-
// `.andorra/runtime` of whichever folder a tool ran in, which for a writing subagent is inside its
|
|
70
|
-
// worktree. They are by-products of running, not work: left in, a job that printed one line would
|
|
71
|
-
// add its log to the change and land it in the user's folder. The same exclusion applies to every
|
|
72
|
-
// tree made here (the snapshot, the change, the folder at landing), so the path never differs
|
|
73
|
-
// between them. The glob form matches the folder at any depth, for a subfolder workspace.
|
|
74
43
|
const RUNTIME_FILES = ':(exclude,glob)**/.andorra/runtime/**';
|
|
75
|
-
/**
|
|
76
|
-
* Writes a tree of the folder's files as they stand: the tracked files of `start` updated from disk,
|
|
77
|
-
* plus untracked files that are not ignored, without Andorra's runtime files. The real index is not involved.
|
|
78
|
-
*/
|
|
79
44
|
async function writeWorkingTree(root, start, signal) {
|
|
80
45
|
return withTemporaryIndex(async (env) => {
|
|
81
46
|
await git(root, ['read-tree', start], { signal, env });
|
|
@@ -84,27 +49,19 @@ async function writeWorkingTree(root, start, signal) {
|
|
|
84
49
|
return (await git(root, ['write-tree'], { signal, env })).trim();
|
|
85
50
|
});
|
|
86
51
|
}
|
|
87
|
-
// More names than this are left in: the exclusions travel on the command line, which Windows bounds.
|
|
88
52
|
const DEVICE_NAMED_LIMIT = 100;
|
|
89
|
-
/**
|
|
90
|
-
* Untracked files Windows reads as a device (`nul`, `con`), which Git cannot open there: adding one
|
|
91
|
-
* fails the whole `git add`. Such a file is a shell accident, never work, and nothing on Windows can
|
|
92
|
-
* write one through an ordinary path, so every tree made here leaves it out the same way.
|
|
93
|
-
*/
|
|
94
53
|
async function deviceNamedFiles(root, env, signal) {
|
|
95
54
|
if (process.platform !== 'win32')
|
|
96
55
|
return [];
|
|
97
56
|
const untracked = await git(root, ['ls-files', '-o', '--exclude-standard', '-z', '--', '.', RUNTIME_FILES], { signal, env, timeout: BULK_TIMEOUT_MS, maxBuffer: ADD_MAX_BUFFER });
|
|
98
57
|
return untracked.split('\0').filter(path => path && path.split('/').some(isWindowsDeviceName)).slice(0, DEVICE_NAMED_LIMIT);
|
|
99
58
|
}
|
|
100
|
-
/** A dangling commit holding `tree`; it is never referenced by a ref. */
|
|
101
59
|
async function commitTree(root, tree, parent, message, signal) {
|
|
102
60
|
return (await git(root, ['commit-tree', tree, '-p', parent, '-m', message], { signal, env: SNAPSHOT_IDENTITY })).trim();
|
|
103
61
|
}
|
|
104
62
|
function isGitFailure(error, code) {
|
|
105
63
|
return error instanceof Error && error.code === code && typeof error.stdout === 'string';
|
|
106
64
|
}
|
|
107
|
-
/** The repository toplevel for a workspace, which may be a subfolder of the repository. */
|
|
108
65
|
export async function repositoryRoot(workspace, signal) {
|
|
109
66
|
let toplevel;
|
|
110
67
|
try {
|
|
@@ -119,11 +76,9 @@ export async function repositoryRoot(workspace, signal) {
|
|
|
119
76
|
throw new Error('Delegated writing needs the workspace to be a Git repository.');
|
|
120
77
|
return realpath(toplevel);
|
|
121
78
|
}
|
|
122
|
-
/** Checks the Git the delegation path depends on before any worktree is created. */
|
|
123
79
|
export async function assertDelegationGit(workspace, signal) {
|
|
124
80
|
const version = /git version (\d+)\.(\d+)/.exec(await git(workspace, ['--version'], { signal }));
|
|
125
81
|
const [major, minor] = version ? [Number(version[1]), Number(version[2])] : [0, 0];
|
|
126
|
-
// `merge-tree --write-tree --merge-base` is what lands a change; it arrived in 2.40.
|
|
127
82
|
if (major < 2 || (major === 2 && minor < 40))
|
|
128
83
|
throw new Error('Delegated writing needs Git 2.40 or newer.');
|
|
129
84
|
const root = await repositoryRoot(workspace, signal);
|
|
@@ -136,16 +91,11 @@ export async function assertDelegationGit(workspace, signal) {
|
|
|
136
91
|
throw error;
|
|
137
92
|
}
|
|
138
93
|
}
|
|
139
|
-
/**
|
|
140
|
-
* A commit whose tree is the working folder as it stands (tracked plus untracked non-ignored files)
|
|
141
|
-
* and whose parent is HEAD. It is the base a writing subagent starts from and is diffed against.
|
|
142
|
-
*/
|
|
143
94
|
export async function snapshotWorkspace(workspace, signal) {
|
|
144
95
|
const root = await repositoryRoot(workspace, signal);
|
|
145
96
|
const tree = await writeWorkingTree(root, 'HEAD', signal);
|
|
146
97
|
return commitTree(root, tree, 'HEAD', 'Andorra delegation snapshot', signal);
|
|
147
98
|
}
|
|
148
|
-
/** A detached worktree at `commit` under a fresh temporary directory. */
|
|
149
99
|
export async function addChangeWorktree(workspace, commit, signal) {
|
|
150
100
|
const directory = await mkdtemp(join(tmpdir(), WORKTREE_PREFIX));
|
|
151
101
|
const worktree = join(directory, 'worktree');
|
|
@@ -158,10 +108,6 @@ export async function addChangeWorktree(workspace, commit, signal) {
|
|
|
158
108
|
}
|
|
159
109
|
return worktree;
|
|
160
110
|
}
|
|
161
|
-
/**
|
|
162
|
-
* The worktree's final files against the snapshot it started from. Commits the subagent made inside
|
|
163
|
-
* the worktree do not matter: the tree is taken from disk, the way the snapshot was.
|
|
164
|
-
*/
|
|
165
111
|
export async function collectChange(worktree, base, signal) {
|
|
166
112
|
const tree = await writeWorkingTree(worktree, base, signal);
|
|
167
113
|
const range = [`${base}^{tree}`, tree];
|
|
@@ -172,7 +118,6 @@ export async function collectChange(worktree, base, signal) {
|
|
|
172
118
|
const fields = status.split('\0');
|
|
173
119
|
for (let index = 0; index + 1 < fields.length; index += 2) {
|
|
174
120
|
const kind = fields[index][0];
|
|
175
|
-
// A rename record carries the old path before the new one; the change is reported at its new path.
|
|
176
121
|
if (kind === 'R') {
|
|
177
122
|
files.push({ path: fields[index + 2], status: 'R' });
|
|
178
123
|
paths.push(fields[index + 1], fields[index + 2]);
|
|
@@ -184,10 +129,6 @@ export async function collectChange(worktree, base, signal) {
|
|
|
184
129
|
}
|
|
185
130
|
return { tree, files, diff, paths };
|
|
186
131
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Landing wrote part of a change and could not put the working folder back. The message names the
|
|
189
|
-
* snapshot commit that holds the folder as it was and the paths that were not restored.
|
|
190
|
-
*/
|
|
191
132
|
export class LandingRestoreError extends Error {
|
|
192
133
|
snapshot;
|
|
193
134
|
paths;
|
|
@@ -201,14 +142,7 @@ export class LandingRestoreError extends Error {
|
|
|
201
142
|
const missing = (error) => ['ENOENT', 'ENOTDIR'].includes(error.code ?? '');
|
|
202
143
|
const present = (target) => lstat(target).catch((error) => { if (missing(error))
|
|
203
144
|
return undefined; throw error; });
|
|
204
|
-
/** How many folders deep a repository path is; Git prints paths with forward slashes. */
|
|
205
145
|
const depth = (path) => path.split('/').length;
|
|
206
|
-
/**
|
|
207
|
-
* Copies the files a patch is about to touch into `directory`, byte for byte. The copies, not the
|
|
208
|
-
* snapshot's blobs, are what a failed landing restores: a blob went through Git's line-ending and
|
|
209
|
-
* filter conversion on the way in, so checking it out again is not guaranteed to give the same bytes.
|
|
210
|
-
* Also records the directories the patch would have to create, so a restore can remove them again.
|
|
211
|
-
*/
|
|
212
146
|
async function saveTouched(root, paths, directory) {
|
|
213
147
|
const saved = [];
|
|
214
148
|
const created = new Set();
|
|
@@ -226,18 +160,12 @@ async function saveTouched(root, paths, directory) {
|
|
|
226
160
|
const copy = join(directory, String(index));
|
|
227
161
|
await copyFile(target, copy);
|
|
228
162
|
saved.push({ path, kind: 'file', copy, mode: info.mode & 0o777 });
|
|
229
|
-
// A directory where the patch puts a file: the files under it are saved under their own paths.
|
|
230
163
|
}
|
|
231
164
|
else
|
|
232
165
|
saved.push({ path, kind: info.isDirectory() ? 'directory' : 'other' });
|
|
233
166
|
}
|
|
234
|
-
// Deepest first, which is the order a restore removes them in.
|
|
235
167
|
return { saved, created: [...created].sort((left, right) => right.length - left.length) };
|
|
236
168
|
}
|
|
237
|
-
/**
|
|
238
|
-
* Removes a directory that holds nothing but empty directories. A file in it was not put there by
|
|
239
|
-
* the landing (what the landing added is removed before this runs), so it stops the removal.
|
|
240
|
-
*/
|
|
241
169
|
async function removeEmptyTree(directory) {
|
|
242
170
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
243
171
|
if (!entry.isDirectory())
|
|
@@ -246,16 +174,7 @@ async function removeEmptyTree(directory) {
|
|
|
246
174
|
}
|
|
247
175
|
await rmdir(directory);
|
|
248
176
|
}
|
|
249
|
-
/** Takes away what stands at a path so that what was saved can go back there. */
|
|
250
177
|
const clear = (target, info) => info.isDirectory() ? removeEmptyTree(target) : rm(target, { force: true });
|
|
251
|
-
/**
|
|
252
|
-
* Puts every saved path back as it was. Returns the paths that could not be restored, with the reason.
|
|
253
|
-
*
|
|
254
|
-
* A patch can change what kind of thing a path is: a file becomes a directory with files under it,
|
|
255
|
-
* or a directory becomes a file. So the order matters. What the patch added goes first, deepest
|
|
256
|
-
* first, together with the directories it made; only then are saved files put back, shallowest
|
|
257
|
-
* first, each one replacing a directory that the patch left in its place.
|
|
258
|
-
*/
|
|
259
178
|
async function restoreTouched(root, state) {
|
|
260
179
|
const failed = new Map();
|
|
261
180
|
const attempt = async (entry, action) => {
|
|
@@ -269,16 +188,13 @@ async function restoreTouched(root, state) {
|
|
|
269
188
|
};
|
|
270
189
|
const deepestFirst = [...state.saved].sort((left, right) => depth(right.path) - depth(left.path));
|
|
271
190
|
for (const entry of deepestFirst) {
|
|
272
|
-
// Nothing stood here: whatever is here now is the patch's.
|
|
273
191
|
if (entry.kind === 'absent')
|
|
274
192
|
await attempt(entry, async (target) => { const info = await present(target); if (info)
|
|
275
193
|
await clear(target, info); });
|
|
276
|
-
// A directory stood here: a file here now is the patch's, and the directory comes back below.
|
|
277
194
|
if (entry.kind === 'directory')
|
|
278
195
|
await attempt(entry, async (target) => { const info = await present(target); if (info && !info.isDirectory())
|
|
279
196
|
await rm(target, { force: true }); });
|
|
280
197
|
}
|
|
281
|
-
// Only a directory the patch made, and only once it is empty again.
|
|
282
198
|
for (const directory of state.created)
|
|
283
199
|
await rmdir(directory).catch(() => { });
|
|
284
200
|
for (const entry of deepestFirst.reverse()) {
|
|
@@ -297,7 +213,6 @@ async function restoreTouched(root, state) {
|
|
|
297
213
|
if (entry.kind === 'file')
|
|
298
214
|
await attempt(entry, async (target) => {
|
|
299
215
|
const info = await present(target);
|
|
300
|
-
// A file the patch never reached is left alone: rewriting it could only fail for no gain.
|
|
301
216
|
if (info?.isFile() && (await readFile(target)).equals(await readFile(entry.copy))) {
|
|
302
217
|
if ((info.mode & 0o777) !== entry.mode)
|
|
303
218
|
await chmod(target, entry.mode);
|
|
@@ -312,25 +227,15 @@ async function restoreTouched(root, state) {
|
|
|
312
227
|
}
|
|
313
228
|
return [...failed].map(([path, reason]) => ({ path, reason }));
|
|
314
229
|
}
|
|
315
|
-
/**
|
|
316
|
-
* Merges `tree` (a change collected against `base`) with the working folder as it stands, which is
|
|
317
|
-
* "ours", so edits the user made since the snapshot are merged with the change rather than
|
|
318
|
-
* overwritten. Nothing in the working folder is written: the result is the patch `applyLanding`
|
|
319
|
-
* would apply and the paths it touches, so a caller can decide whether those paths may be written
|
|
320
|
-
* before any of them is.
|
|
321
|
-
*/
|
|
322
230
|
export async function prepareLanding(workspace, base, tree, signal) {
|
|
323
231
|
const root = await repositoryRoot(workspace, signal);
|
|
324
232
|
const ours = await snapshotWorkspace(root, signal);
|
|
325
|
-
// Git 2.40's merge-tree takes commits for the sides it merges (later versions accept trees), so
|
|
326
|
-
// the change is wrapped in a throwaway commit on its base.
|
|
327
233
|
const theirs = await commitTree(root, tree, base, 'Andorra delegated change', signal);
|
|
328
234
|
let merged;
|
|
329
235
|
try {
|
|
330
236
|
merged = (await git(root, ['merge-tree', '--write-tree', `--merge-base=${base}`, '--name-only', ours, theirs], { signal, timeout: BULK_TIMEOUT_MS, maxBuffer: DIFF_MAX_BUFFER })).trim();
|
|
331
237
|
}
|
|
332
238
|
catch (error) {
|
|
333
|
-
// Exit 1 is a conflict, with the merged tree, the conflicted paths and a blank line before the messages.
|
|
334
239
|
if (!isGitFailure(error, 1))
|
|
335
240
|
throw error;
|
|
336
241
|
const [, ...rest] = error.stdout.split('\n');
|
|
@@ -343,11 +248,9 @@ export async function prepareLanding(workspace, base, tree, signal) {
|
|
|
343
248
|
return { ready: false, conflicts, detail: error.stdout.trim() };
|
|
344
249
|
}
|
|
345
250
|
const patch = await exec('git', [...HARDENED, ...PATCH, '-p', '--binary', ours, merged], { cwd: root, signal, windowsHide: true, timeout: BULK_TIMEOUT_MS, maxBuffer: DIFF_MAX_BUFFER, encoding: 'buffer' });
|
|
346
|
-
// Without rename detection a moved file is listed at both of its paths: one is removed, one written.
|
|
347
251
|
const files = (await git(root, [...PATCH, '--name-only', '-z', '--no-renames', ours, merged], { signal, timeout: BULK_TIMEOUT_MS, maxBuffer: DIFF_MAX_BUFFER })).split('\0').filter(Boolean);
|
|
348
252
|
return { ready: true, landing: { root, ours, files, patch: patch.stdout } };
|
|
349
253
|
}
|
|
350
|
-
/** Whether the working folder no longer holds the files the snapshot commit `ours` recorded. */
|
|
351
254
|
async function folderMoved(root, ours, signal) {
|
|
352
255
|
try {
|
|
353
256
|
return await writeWorkingTree(root, 'HEAD', signal) !== (await git(root, ['rev-parse', `${ours}^{tree}`], { signal })).trim();
|
|
@@ -356,34 +259,14 @@ async function folderMoved(root, ours, signal) {
|
|
|
356
259
|
return false;
|
|
357
260
|
}
|
|
358
261
|
}
|
|
359
|
-
/**
|
|
360
|
-
* Writes a prepared landing to the working folder as uncommitted edits. Only the paths in
|
|
361
|
-
* `landing.files` are written or removed: the patch is fixed, and `git apply` refuses it as a whole
|
|
362
|
-
* when the folder no longer matches what it was made against.
|
|
363
|
-
*
|
|
364
|
-
* Landing is all or nothing. `git apply` checks a patch before it writes, but the writing itself is
|
|
365
|
-
* not atomic: a file another program holds open, a full disk or a cancelled run stops it with some
|
|
366
|
-
* files rewritten and others already removed. So the files the patch touches are copied aside
|
|
367
|
-
* first, and any failure of the apply puts them back, removes what the patch added, and reports the
|
|
368
|
-
* landing as not done, with `stale` set when the folder changed after the landing was prepared (a
|
|
369
|
-
* new preparation may then work). If the folder cannot be put back, a `LandingRestoreError` names
|
|
370
|
-
* the snapshot commit holding the folder as it was. The hooks exist for tests: `applied` runs after
|
|
371
|
-
* an apply that worked, and a throw from it is handled as the apply failing once its writes were
|
|
372
|
-
* made; `applyFailed` runs between a failed apply and the restore.
|
|
373
|
-
*/
|
|
374
262
|
export async function applyLanding(landing, signal, hooks = {}) {
|
|
375
263
|
const { root, ours, files, patch } = landing;
|
|
376
264
|
if (patch.length === 0)
|
|
377
265
|
return { landed: true, files };
|
|
378
|
-
// The patch goes through a file rather than stdin so Git sees the exact bytes; `git apply` without
|
|
379
|
-
// `--index` touches only the working tree, which is the snapshot's "ours" and so passes the check
|
|
380
|
-
// `git apply` makes before it writes. `--whitespace=nowarn` overrides an apply.whitespace setting
|
|
381
|
-
// that would strip or reject what the merge produced.
|
|
382
266
|
const directory = await mkdtemp(join(tmpdir(), 'andorra-land-'));
|
|
383
267
|
try {
|
|
384
268
|
const file = join(directory, 'change.patch');
|
|
385
269
|
await writeFile(file, patch);
|
|
386
|
-
// Nothing is written to the folder yet, so failing to copy the files aside just fails the landing.
|
|
387
270
|
const state = await saveTouched(root, files, directory);
|
|
388
271
|
signal.throwIfAborted();
|
|
389
272
|
try {
|
|
@@ -396,12 +279,11 @@ export async function applyLanding(landing, signal, hooks = {}) {
|
|
|
396
279
|
try {
|
|
397
280
|
await hooks.applyFailed?.();
|
|
398
281
|
}
|
|
399
|
-
catch {
|
|
282
|
+
catch { }
|
|
400
283
|
const failed = await restoreTouched(root, state);
|
|
401
284
|
if (failed.length) {
|
|
402
285
|
throw new LandingRestoreError(`Landing failed partway and the working folder could not be put back. The folder as it was before the landing is in Git commit ${ours}; recover a file with: git show ${ours}:<path>. Not restored: ${failed.map(entry => `${entry.path} (${entry.reason})`).join('; ')}. The landing failed with: ${detail}`, ours, failed.map(entry => entry.path));
|
|
403
286
|
}
|
|
404
|
-
// The folder is as it was. A cancelled run still ends as a cancellation, not as a conflict.
|
|
405
287
|
if (signal.aborted)
|
|
406
288
|
throw error;
|
|
407
289
|
return { landed: false, conflicts: [], detail, ...(await folderMoved(root, ours, signal) ? { stale: true } : {}) };
|
|
@@ -412,18 +294,12 @@ export async function applyLanding(landing, signal, hooks = {}) {
|
|
|
412
294
|
}
|
|
413
295
|
return { landed: true, files };
|
|
414
296
|
}
|
|
415
|
-
/**
|
|
416
|
-
* Lands `tree` (a change collected against `base`) on the working folder as uncommitted edits:
|
|
417
|
-
* `prepareLanding`, then `applyLanding`. On a conflict nothing is written. A caller that must
|
|
418
|
-
* authorize the paths a landing writes uses the two steps itself.
|
|
419
|
-
*/
|
|
420
297
|
export async function landChange(workspace, base, tree, signal, hooks = {}) {
|
|
421
298
|
const prepared = await prepareLanding(workspace, base, tree, signal);
|
|
422
299
|
if (!prepared.ready)
|
|
423
300
|
return { landed: false, conflicts: prepared.conflicts, detail: prepared.detail };
|
|
424
301
|
return applyLanding(prepared.landing, signal, hooks);
|
|
425
302
|
}
|
|
426
|
-
/** Removes a worktree made by `addChangeWorktree` and its temporary directory. Best effort; never throws. */
|
|
427
303
|
export async function removeChangeWorktree(workspace, worktree) {
|
|
428
304
|
let removed = true;
|
|
429
305
|
try {
|
|
@@ -432,17 +308,15 @@ export async function removeChangeWorktree(workspace, worktree) {
|
|
|
432
308
|
catch {
|
|
433
309
|
removed = false;
|
|
434
310
|
}
|
|
435
|
-
// Only a directory this module created is deleted wholesale; anything else loses just the worktree.
|
|
436
311
|
const parent = dirname(worktree);
|
|
437
312
|
try {
|
|
438
313
|
await rm(basename(parent).startsWith(WORKTREE_PREFIX) ? parent : worktree, { recursive: true, force: true, ...REMOVE_RETRIES });
|
|
439
314
|
}
|
|
440
|
-
catch {
|
|
441
|
-
// Git forgets the worktree itself when the removal works; only a failed one leaves a record to prune.
|
|
315
|
+
catch { }
|
|
442
316
|
if (!removed) {
|
|
443
317
|
try {
|
|
444
318
|
await git(workspace, ['worktree', 'prune']);
|
|
445
319
|
}
|
|
446
|
-
catch {
|
|
320
|
+
catch { }
|
|
447
321
|
}
|
|
448
322
|
}
|
|
@@ -3,5 +3,4 @@ export interface FileChangePreview {
|
|
|
3
3
|
detail?: string;
|
|
4
4
|
}
|
|
5
5
|
export declare function registerEditArgumentPreparer(prepare: ((args: Record<string, unknown>) => unknown) | undefined): void;
|
|
6
|
-
/** Proposed tool arguments only: writes may overwrite an existing file. */
|
|
7
6
|
export declare function formatFileChange(name: string, args: Record<string, unknown>): FileChangePreview | undefined;
|
package/dist/src/diff-preview.js
CHANGED
|
@@ -4,19 +4,10 @@ import { canonicalToolName } from './tool-names.js';
|
|
|
4
4
|
const PREVIEW_LINES = 12;
|
|
5
5
|
const DETAIL_LINES = 200;
|
|
6
6
|
const LINE_WIDTH = 300;
|
|
7
|
-
/**
|
|
8
|
-
* The edit tool's own argument normalizer, registered by the coding tools when they load.
|
|
9
|
-
*
|
|
10
|
-
* Importing the vendored edit tool here would load its schema library with every transcript
|
|
11
|
-
* renderer, including the first terminal frame. An `edit` call only exists once the coding tools
|
|
12
|
-
* have been created, and they register the normalizer as they load, so a preview never needs it
|
|
13
|
-
* earlier; a call rendered before that (a resumed transcript) previews its arguments as written.
|
|
14
|
-
*/
|
|
15
7
|
let prepareEditArguments;
|
|
16
8
|
export function registerEditArgumentPreparer(prepare) {
|
|
17
9
|
prepareEditArguments = prepare;
|
|
18
10
|
}
|
|
19
|
-
/** Keep file content from controlling the terminal or disguising diff markers. */
|
|
20
11
|
function printable(value) {
|
|
21
12
|
return stripVTControlCharacters(value)
|
|
22
13
|
.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, '')
|
|
@@ -26,7 +17,6 @@ function numbered(value, marker) {
|
|
|
26
17
|
if (!value)
|
|
27
18
|
return [];
|
|
28
19
|
const lines = value.replace(/\r\n/g, '\n').split('\n');
|
|
29
|
-
// A final line terminator does not introduce an extra content line.
|
|
30
20
|
if (lines.at(-1) === '')
|
|
31
21
|
lines.pop();
|
|
32
22
|
const width = String(lines.length).length;
|
|
@@ -36,7 +26,6 @@ function numbered(value, marker) {
|
|
|
36
26
|
return `${marker} ${String(index + 1).padStart(width)} | ${shown}`;
|
|
37
27
|
});
|
|
38
28
|
}
|
|
39
|
-
/** Shared snippet rendering for every edit contract (canonical and adopted). */
|
|
40
29
|
function renderEdits(edits) {
|
|
41
30
|
return edits.flatMap((edit, index) => {
|
|
42
31
|
const replacement = [...numbered(edit.oldText, '-'), ...numbered(edit.newText, '+')];
|
|
@@ -52,12 +41,10 @@ function render(header, lines, limit) {
|
|
|
52
41
|
shown.push(`… ${lines.length - limit} more lines (preview truncated)`);
|
|
53
42
|
return [header, ...shown].join('\n');
|
|
54
43
|
}
|
|
55
|
-
/** Proposed tool arguments only: writes may overwrite an existing file. */
|
|
56
44
|
export function formatFileChange(name, args) {
|
|
57
45
|
const canonical = canonicalToolName(name);
|
|
58
46
|
if (canonical !== 'Write' && canonical !== 'Edit')
|
|
59
47
|
return undefined;
|
|
60
|
-
// Canonical tool spelling carries file_path; every adopted Pi/Andorra spelling carries path.
|
|
61
48
|
const usesFilePath = name === 'Write' || name === 'Edit';
|
|
62
49
|
const rawPath = usesFilePath ? args.file_path : args.path;
|
|
63
50
|
if (typeof rawPath !== 'string')
|
|
@@ -76,8 +63,6 @@ export function formatFileChange(name, args) {
|
|
|
76
63
|
else if (usesFilePath) {
|
|
77
64
|
let edits = [];
|
|
78
65
|
if (Array.isArray(args.edits)) {
|
|
79
|
-
// The canonical Edit rejects an empty batch and an empty old_string, so previewing one
|
|
80
|
-
// would advertise a call that can only fail.
|
|
81
66
|
if (!args.edits.length)
|
|
82
67
|
return undefined;
|
|
83
68
|
for (const edit of args.edits) {
|
|
@@ -98,8 +83,6 @@ export function formatFileChange(name, args) {
|
|
|
98
83
|
lines = renderEdits(edits);
|
|
99
84
|
}
|
|
100
85
|
else if (name === 'edit') {
|
|
101
|
-
// Started events contain raw provider arguments. Use the executor's normalizer,
|
|
102
|
-
// but copy the envelope because it can replace edits while parsing JSON input.
|
|
103
86
|
if (prepareEditArguments)
|
|
104
87
|
args = prepareEditArguments({ ...args });
|
|
105
88
|
if (!Array.isArray(args.edits) || !args.edits.length)
|
package/dist/src/duration.d.ts
CHANGED
|
@@ -1,55 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Timing helpers for tool-call telemetry and user-facing surfaces (transcripts, status lines).
|
|
3
|
-
*
|
|
4
|
-
* Dependency-free and defensive by design: callers append the rendered suffix only when it is
|
|
5
|
-
* defined, so missing or unusable input degrades to byte-identical prior output instead of
|
|
6
|
-
* printing `NaN` or `undefined`.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* A non-negative finite duration in milliseconds, or `undefined` when the value cannot be
|
|
10
|
-
* trusted (missing, non-numeric, `NaN`, infinite or negative).
|
|
11
|
-
*
|
|
12
|
-
* The runtime emits a duration beside the identity of the call it belongs to, so a value that
|
|
13
|
-
* cannot be trusted must be dropped rather than coerced: `durationMs` returns `undefined` and the
|
|
14
|
-
* event carries no `durationMs`, which keeps consumers from pairing a fabricated duration with a
|
|
15
|
-
* real tool call. Only a number or a numeric string is accepted; other types are rejected instead
|
|
16
|
-
* of being coerced through `Number()`, which would silently turn `[]` into a `0ms` reading.
|
|
17
|
-
*/
|
|
18
1
|
export declare function durationMs(ms: unknown): number | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Whole seconds as spaced elapsed units: `45s`, `2m 3s`, `1h 2m 3s`.
|
|
21
|
-
*
|
|
22
|
-
* Every duration the terminal prints past a minute takes this one form: largest unit first, a
|
|
23
|
-
* space between units, and every unit below the largest carried down to the second so a boundary
|
|
24
|
-
* never hides where the figure stands (`1h 0m 5s`, not `1h 5s`). Minutes never run past 59 — a
|
|
25
|
-
* stretch of 105 minutes reads `1h 45m 18s`. Fractions floor and negatives clamp to `0s`.
|
|
26
|
-
*/
|
|
27
2
|
export declare function formatHms(totalSeconds: number): string;
|
|
28
|
-
/**
|
|
29
|
-
* Renders a duration for display: whole milliseconds below one second (`123ms`, `0ms`),
|
|
30
|
-
* one-decimal seconds below a minute (`1.2s`, `59.4s`), then {@link formatHms} (`1m 5s`,
|
|
31
|
-
* `1h 45m 18s`).
|
|
32
|
-
*
|
|
33
|
-
* The minute cutoff is taken on the rounded figure, so 59.96 s reads `1m 0s` rather than `60.0s`.
|
|
34
|
-
* Returns `undefined` for anything `durationMs` rejects so the caller can omit the suffix
|
|
35
|
-
* entirely; this function never returns `NaN` or `undefined` as text.
|
|
36
|
-
*/
|
|
37
3
|
export declare function formatDuration(ms: unknown): string | undefined;
|
|
38
|
-
/** Monotonic clock source for a per-call start reading. */
|
|
39
4
|
export declare const monotonicNow: () => number;
|
|
40
|
-
/**
|
|
41
|
-
* Elapsed milliseconds between a monotonic start reading and now, or `undefined` when the start
|
|
42
|
-
* cannot be trusted.
|
|
43
|
-
*
|
|
44
|
-
* `performance.now()` is monotonic, so a per-call reading cannot go negative if the system wall
|
|
45
|
-
* clock is adjusted mid-run. The span is rounded to whole milliseconds: the value is rendered to
|
|
46
|
-
* whole milliseconds or one-decimal seconds, and a raw `performance.now()` difference carries
|
|
47
|
-
* float noise ("17.22060000000056") that a duration was never measured to. The emitted event is
|
|
48
|
-
* what a run record persists, so the reading is fixed here rather than at each consumer. A host
|
|
49
|
-
* that lacks `performance` yields `undefined` instead of throwing inside a tool-call event
|
|
50
|
-
* emitter.
|
|
51
|
-
*
|
|
52
|
-
* Each call reads the clock independently, so concurrent branches of one batch can hold their own
|
|
53
|
-
* reader while the events they emit stay paired with the right `toolCallId`.
|
|
54
|
-
*/
|
|
55
5
|
export declare function elapsedMs(startedAt: number | undefined): number | undefined;
|
package/dist/src/duration.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
|
-
/**
|
|
3
|
-
* Timing helpers for tool-call telemetry and user-facing surfaces (transcripts, status lines).
|
|
4
|
-
*
|
|
5
|
-
* Dependency-free and defensive by design: callers append the rendered suffix only when it is
|
|
6
|
-
* defined, so missing or unusable input degrades to byte-identical prior output instead of
|
|
7
|
-
* printing `NaN` or `undefined`.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* A non-negative finite duration in milliseconds, or `undefined` when the value cannot be
|
|
11
|
-
* trusted (missing, non-numeric, `NaN`, infinite or negative).
|
|
12
|
-
*
|
|
13
|
-
* The runtime emits a duration beside the identity of the call it belongs to, so a value that
|
|
14
|
-
* cannot be trusted must be dropped rather than coerced: `durationMs` returns `undefined` and the
|
|
15
|
-
* event carries no `durationMs`, which keeps consumers from pairing a fabricated duration with a
|
|
16
|
-
* real tool call. Only a number or a numeric string is accepted; other types are rejected instead
|
|
17
|
-
* of being coerced through `Number()`, which would silently turn `[]` into a `0ms` reading.
|
|
18
|
-
*/
|
|
19
2
|
export function durationMs(ms) {
|
|
20
3
|
if (typeof ms !== 'number' && typeof ms !== 'string')
|
|
21
4
|
return undefined;
|
|
@@ -26,14 +9,6 @@ export function durationMs(ms) {
|
|
|
26
9
|
return undefined;
|
|
27
10
|
return value;
|
|
28
11
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Whole seconds as spaced elapsed units: `45s`, `2m 3s`, `1h 2m 3s`.
|
|
31
|
-
*
|
|
32
|
-
* Every duration the terminal prints past a minute takes this one form: largest unit first, a
|
|
33
|
-
* space between units, and every unit below the largest carried down to the second so a boundary
|
|
34
|
-
* never hides where the figure stands (`1h 0m 5s`, not `1h 5s`). Minutes never run past 59 — a
|
|
35
|
-
* stretch of 105 minutes reads `1h 45m 18s`. Fractions floor and negatives clamp to `0s`.
|
|
36
|
-
*/
|
|
37
12
|
export function formatHms(totalSeconds) {
|
|
38
13
|
const seconds = Math.max(0, Math.floor(totalSeconds));
|
|
39
14
|
const hours = Math.floor(seconds / 3600);
|
|
@@ -45,15 +20,6 @@ export function formatHms(totalSeconds) {
|
|
|
45
20
|
return `${minutes}m ${rest}s`;
|
|
46
21
|
return `${rest}s`;
|
|
47
22
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Renders a duration for display: whole milliseconds below one second (`123ms`, `0ms`),
|
|
50
|
-
* one-decimal seconds below a minute (`1.2s`, `59.4s`), then {@link formatHms} (`1m 5s`,
|
|
51
|
-
* `1h 45m 18s`).
|
|
52
|
-
*
|
|
53
|
-
* The minute cutoff is taken on the rounded figure, so 59.96 s reads `1m 0s` rather than `60.0s`.
|
|
54
|
-
* Returns `undefined` for anything `durationMs` rejects so the caller can omit the suffix
|
|
55
|
-
* entirely; this function never returns `NaN` or `undefined` as text.
|
|
56
|
-
*/
|
|
57
23
|
export function formatDuration(ms) {
|
|
58
24
|
const value = durationMs(ms);
|
|
59
25
|
if (value === undefined)
|
|
@@ -65,23 +31,7 @@ export function formatDuration(ms) {
|
|
|
65
31
|
return `${seconds}s`;
|
|
66
32
|
return formatHms(Math.round(value / 1000));
|
|
67
33
|
}
|
|
68
|
-
/** Monotonic clock source for a per-call start reading. */
|
|
69
34
|
export const monotonicNow = () => performance.now();
|
|
70
|
-
/**
|
|
71
|
-
* Elapsed milliseconds between a monotonic start reading and now, or `undefined` when the start
|
|
72
|
-
* cannot be trusted.
|
|
73
|
-
*
|
|
74
|
-
* `performance.now()` is monotonic, so a per-call reading cannot go negative if the system wall
|
|
75
|
-
* clock is adjusted mid-run. The span is rounded to whole milliseconds: the value is rendered to
|
|
76
|
-
* whole milliseconds or one-decimal seconds, and a raw `performance.now()` difference carries
|
|
77
|
-
* float noise ("17.22060000000056") that a duration was never measured to. The emitted event is
|
|
78
|
-
* what a run record persists, so the reading is fixed here rather than at each consumer. A host
|
|
79
|
-
* that lacks `performance` yields `undefined` instead of throwing inside a tool-call event
|
|
80
|
-
* emitter.
|
|
81
|
-
*
|
|
82
|
-
* Each call reads the clock independently, so concurrent branches of one batch can hold their own
|
|
83
|
-
* reader while the events they emit stay paired with the right `toolCallId`.
|
|
84
|
-
*/
|
|
85
35
|
export function elapsedMs(startedAt) {
|
|
86
36
|
if (typeof startedAt !== 'number' || !Number.isFinite(startedAt))
|
|
87
37
|
return undefined;
|
package/dist/src/efficiency.d.ts
CHANGED
|
@@ -1,75 +1,39 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Independent controls for the efficiency optimizations layered on the agent runtime.
|
|
3
|
-
*
|
|
4
|
-
* Every switch here is off unless the configuration turns it on, so a configuration that names
|
|
5
|
-
* none of them runs the shipped behavior byte for byte. Each feature is evaluated on its own
|
|
6
|
-
* (`scripts/jev-efficiency-eval.mjs`), and the switches are independent so a feature whose
|
|
7
|
-
* evaluation does not justify it can stay off while the others ship.
|
|
8
|
-
*
|
|
9
|
-
* None of the switches widens what the hosted decision service receives: the deterministic paths
|
|
10
|
-
* run locally, and a semantic selection that would need excerpts the service is not contracted to
|
|
11
|
-
* receive stays disabled rather than sending them (see `docs/concepts/jev-efficiency.md`).
|
|
12
|
-
* @module efficiency
|
|
13
|
-
*/
|
|
14
|
-
/** A model the adaptive router may select; it must name a configured provider and model. */
|
|
15
1
|
export interface ModelTierTarget {
|
|
16
2
|
provider: string;
|
|
17
3
|
model?: string;
|
|
18
4
|
}
|
|
19
|
-
/**
|
|
20
|
-
* User-supplied prices for cost reporting. Nothing here is invented by the runtime: a model
|
|
21
|
-
* without an entry reports "cost unavailable", never zero.
|
|
22
|
-
*/
|
|
23
5
|
export interface ModelPricing {
|
|
24
6
|
inputPerMillionUsd: number;
|
|
25
7
|
outputPerMillionUsd: number;
|
|
26
8
|
cacheReadPerMillionUsd?: number;
|
|
27
9
|
}
|
|
28
10
|
export interface AdaptiveRoutingConfig {
|
|
29
|
-
/** Off unless true; the tiers alone do not enable routing. */
|
|
30
11
|
enabled?: boolean;
|
|
31
12
|
tiers?: {
|
|
32
13
|
economy?: ModelTierTarget;
|
|
33
14
|
balanced?: ModelTierTarget;
|
|
34
15
|
premium?: ModelTierTarget;
|
|
35
16
|
};
|
|
36
|
-
/** Upward re-tiering after a defined failure; 0 disables escalation. Default 1. */
|
|
37
17
|
maxEscalations?: number;
|
|
38
|
-
/** Prices keyed by `<provider>/<model>`, for reports only. */
|
|
39
18
|
pricing?: Record<string, ModelPricing>;
|
|
40
19
|
}
|
|
41
|
-
/** Tool-menu routing is independently opt-in; shadow measures without trimming. */
|
|
42
20
|
export interface ToolMenuRoutingConfig {
|
|
43
21
|
mode?: 'off' | 'shadow' | 'lean';
|
|
44
22
|
topK?: number;
|
|
45
23
|
minSavingsChars?: number;
|
|
46
|
-
/** Explicit host/node tools remain exposed. These names never grant permissions. */
|
|
47
24
|
pinnedTools?: string[];
|
|
48
25
|
}
|
|
49
26
|
export interface EfficiencyConfig {
|
|
50
|
-
/** Independent local finish/check machinery. Omission preserves the existing JEV-facts default. */
|
|
51
27
|
deterministicContinuations?: boolean;
|
|
52
|
-
/** False disables remote fact interpretation without disabling local continuations. */
|
|
53
28
|
jevFactInterpretation?: boolean;
|
|
54
|
-
/** Skip legacy preflight entirely without disabling fact or tool-menu decisions. */
|
|
55
29
|
jevPreflight?: boolean;
|
|
56
|
-
/** Pin project skill discovery independently of JEV. Undefined preserves the existing behavior. */
|
|
57
30
|
projectSkillDiscovery?: boolean;
|
|
58
31
|
toolMenuRouting?: ToolMenuRoutingConfig;
|
|
59
|
-
/**
|
|
60
|
-
* Prepared steps may declare `when: 'success' | 'failure' | 'always'`; a declared step runs
|
|
61
|
-
* deterministically after the batch it followed, without a decision request.
|
|
62
|
-
*/
|
|
63
32
|
preparedContinuations?: boolean;
|
|
64
|
-
/** Skip the post-tool decision round when no prepared candidate could change execution. */
|
|
65
33
|
postflightOnlyWithCandidates?: boolean;
|
|
66
|
-
/** Parse bulky tool results before they enter the model-visible conversation. */
|
|
67
34
|
toolResultFiltering?: boolean;
|
|
68
|
-
/** Minimum output size, in characters, before a result is a filtering candidate. Default 6000. */
|
|
69
35
|
toolResultFilterThresholdChars?: number;
|
|
70
|
-
/** Workspace-fact gating of automatic retrieval and relevance selection of retrieved context. */
|
|
71
36
|
contextSelection?: boolean;
|
|
72
|
-
/** Deterministic task-appropriate tool catalog and lazy skill catalog ordering. */
|
|
73
37
|
catalogSelection?: boolean;
|
|
74
38
|
adaptiveRouting?: AdaptiveRoutingConfig;
|
|
75
39
|
}
|
|
@@ -79,7 +43,6 @@ export declare const DEFAULT_TOOL_RESULT_FILTER_THRESHOLD = 6000;
|
|
|
79
43
|
declare const TIERS: readonly ["economy", "balanced", "premium"];
|
|
80
44
|
export type ModelTier = typeof TIERS[number];
|
|
81
45
|
export declare const MODEL_TIERS: readonly ModelTier[];
|
|
82
|
-
/** Fail closed on shape: a mistyped switch is an error, not a silently ignored optimization. */
|
|
83
46
|
export declare function validateEfficiencyConfig(value: unknown): void;
|
|
84
47
|
export interface ResolvedEfficiency {
|
|
85
48
|
preparedContinuations: boolean;
|
|
@@ -93,9 +56,7 @@ export interface ResolvedEfficiency {
|
|
|
93
56
|
maxEscalations: number;
|
|
94
57
|
};
|
|
95
58
|
}
|
|
96
|
-
/** The effective switches; every absent value is the shipped behavior. */
|
|
97
59
|
export declare function resolveEfficiency(config: EfficiencyConfig | undefined): ResolvedEfficiency;
|
|
98
|
-
/** Fixed reason codes shared by every `efficiency.*` event; free text never rides an event. */
|
|
99
60
|
export declare const EFFICIENCY_REASONS: readonly ["deterministic_continuation", "jev_selected", "no_candidates", "no_actionable_decision", "stale_task", "stale_permissions", "catalog_mismatch", "blocked", "denied", "invalid_arguments", "automatic_limit", "batch_failed", "batch_succeeded", "filtered", "below_threshold", "unknown_format", "protected_tool", "error_output", "expanded", "expansion_rejected", "empty_workspace", "index_unavailable", "memory_unavailable", "selected", "duplicate", "changed", "fallback", "economy", "balanced", "premium", "baseline", "pinned", "unconfigured", "low_confidence", "risk", "escalated", "escalation_limit", "omitted", "restored", "historical", "explicit"];
|
|
100
61
|
export type EfficiencyReason = typeof EFFICIENCY_REASONS[number];
|
|
101
62
|
export {};
|