@andorra-labs/code 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/account-presentation.d.ts +1 -37
- package/dist/src/account-presentation.js +2 -42
- package/dist/src/activity.d.ts +0 -25
- package/dist/src/activity.js +1 -23
- package/dist/src/agent-definitions.d.ts +0 -26
- package/dist/src/agent-definitions.js +0 -43
- package/dist/src/agent-execution.d.ts +0 -2
- package/dist/src/agent-execution.js +49 -416
- 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 +9 -153
- package/dist/src/agent-modifiers.d.ts +0 -1
- package/dist/src/agent-modifiers.js +25 -68
- package/dist/src/analytics.d.ts +0 -66
- package/dist/src/analytics.js +0 -45
- package/dist/src/anthropic-console-auth.d.ts +0 -24
- package/dist/src/anthropic-console-auth.js +0 -37
- package/dist/src/anthropic-credentials.d.ts +0 -25
- package/dist/src/anthropic-credentials.js +0 -28
- package/dist/src/app-server/protocol.d.ts +13 -245
- 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 +27 -927
- package/dist/src/app-server.js +537 -2992
- package/dist/src/artifacts.d.ts +0 -10
- package/dist/src/artifacts.js +1 -11
- package/dist/src/attachments.d.ts +4 -98
- package/dist/src/attachments.js +10 -130
- package/dist/src/auth/AuthManager.d.ts +0 -93
- package/dist/src/auth/AuthManager.js +3 -165
- package/dist/src/auth/callback-page.d.ts +0 -1
- package/dist/src/auth/callback-page.js +0 -4
- package/dist/src/auth/callback.d.ts +0 -25
- package/dist/src/auth/callback.js +1 -29
- package/dist/src/auth/deployment.d.ts +0 -16
- package/dist/src/auth/deployment.js +0 -16
- package/dist/src/auth/index.d.ts +0 -11
- package/dist/src/auth/index.js +0 -11
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +7 -108
- package/dist/src/auth/store.js +21 -129
- package/dist/src/auth/types.d.ts +0 -8
- package/dist/src/auth-commands.d.ts +0 -5
- package/dist/src/auth-commands.js +0 -1
- package/dist/src/automation-runner.d.ts +0 -9
- package/dist/src/automation-runner.js +0 -11
- package/dist/src/automation-service.d.ts +0 -10
- package/dist/src/automation-service.js +3 -17
- package/dist/src/automation-tool.js +0 -5
- package/dist/src/automation-worker-shutdown.d.ts +0 -1
- package/dist/src/automation-worker-shutdown.js +0 -3
- package/dist/src/automations.d.ts +23 -2
- package/dist/src/automations.js +91 -12
- package/dist/src/background-tasks.d.ts +0 -23
- package/dist/src/background-tasks.js +0 -11
- package/dist/src/boot-trace.d.ts +0 -13
- package/dist/src/boot-trace.js +1 -14
- package/dist/src/browser-activity.js +0 -2
- package/dist/src/browser-bridge.d.ts +0 -2
- package/dist/src/browser-bridge.js +0 -27
- package/dist/src/browser-captcha-tool.d.ts +0 -13
- package/dist/src/browser-captcha-tool.js +3 -35
- package/dist/src/browser-extensions-tool.d.ts +24 -0
- package/dist/src/browser-extensions-tool.js +137 -0
- package/dist/src/browser-extensions.d.ts +127 -0
- package/dist/src/browser-extensions.js +729 -0
- package/dist/src/browser-observation.d.ts +0 -15
- package/dist/src/browser-observation.js +1 -22
- package/dist/src/browser-panel-tool.d.ts +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 +4 -45
- package/dist/src/browser-server.d.ts +0 -6
- package/dist/src/browser-server.js +6 -229
- package/dist/src/browser-session.d.ts +0 -25
- package/dist/src/browser-session.js +1 -71
- package/dist/src/browser-stealth.d.ts +0 -12
- package/dist/src/browser-stealth.js +0 -36
- package/dist/src/browser-ui/app.js +7 -174
- package/dist/src/browser-ui/style.css +0 -68
- package/dist/src/browser-ui/tokens.css +11 -93
- package/dist/src/browser-view.d.ts +47 -301
- package/dist/src/browser-view.js +333 -582
- 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 +80 -721
- 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 +24 -0
- package/dist/src/command-screens.js +132 -100
- package/dist/src/commands.d.ts +6 -63
- package/dist/src/commands.js +20 -100
- package/dist/src/completion-gates.d.ts +0 -47
- package/dist/src/completion-gates.js +0 -14
- package/dist/src/completion.d.ts +0 -98
- package/dist/src/completion.js +2 -239
- package/dist/src/config.d.ts +11 -116
- package/dist/src/config.js +39 -171
- package/dist/src/context-budget.d.ts +0 -22
- package/dist/src/context-budget.js +0 -44
- package/dist/src/context-compaction.d.ts +29 -6
- package/dist/src/context-compaction.js +94 -25
- package/dist/src/context-selection.d.ts +0 -24
- package/dist/src/context-selection.js +0 -34
- package/dist/src/dashboard-view.d.ts +0 -2
- package/dist/src/dashboard-view.js +0 -35
- package/dist/src/dashboard.d.ts +0 -2
- package/dist/src/dashboard.js +0 -9
- package/dist/src/deadline.d.ts +0 -45
- package/dist/src/deadline.js +0 -54
- package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
- package/dist/src/decision/ContinuationAdapter.js +0 -5
- package/dist/src/decision/DecisionEngine.d.ts +0 -4
- package/dist/src/decision/DecisionManager.d.ts +0 -1
- package/dist/src/decision/DecisionManager.js +2 -7
- package/dist/src/decision/DecisionPolicy.d.ts +0 -1
- package/dist/src/decision/DecisionPolicy.js +0 -1
- package/dist/src/decision/FactContinuations.d.ts +11 -43
- package/dist/src/decision/FactContinuations.js +126 -95
- package/dist/src/decision/FactServiceGate.d.ts +0 -1
- package/dist/src/decision/FactServiceGate.js +0 -4
- package/dist/src/decision/PreparedSteps.d.ts +0 -15
- package/dist/src/decision/PreparedSteps.js +0 -10
- package/dist/src/decision/applyToolMenu.d.ts +0 -1
- package/dist/src/decision/applyToolMenu.js +1 -5
- package/dist/src/decision/checks.d.ts +15 -28
- package/dist/src/decision/checks.js +118 -49
- package/dist/src/decision/facts.d.ts +0 -16
- package/dist/src/decision/facts.js +0 -30
- package/dist/src/decision/guidancePolicy.js +0 -1
- package/dist/src/decision/hostedPolicy.d.ts +0 -6
- package/dist/src/decision/hostedPolicy.js +0 -7
- package/dist/src/decision/hostedSkills.d.ts +0 -19
- package/dist/src/decision/hostedSkills.js +0 -19
- package/dist/src/decision/optimizationPolicy.d.ts +0 -3
- package/dist/src/decision/optimizationPolicy.js +1 -4
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
- package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
- package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
- package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
- package/dist/src/decision/routeTools.d.ts +0 -8
- package/dist/src/decision/routeTools.js +1 -8
- package/dist/src/decision/toolFamilies.d.ts +0 -1
- package/dist/src/decision/toolFamilies.js +0 -1
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +0 -6
- package/dist/src/default-graph.d.ts +0 -9
- package/dist/src/default-graph.js +0 -9
- package/dist/src/delegation-changes.d.ts +0 -56
- package/dist/src/delegation-changes.js +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 +0 -63
- package/dist/src/graph-health.js +0 -57
- package/dist/src/graph-manager-chat.d.ts +5 -155
- package/dist/src/graph-manager-chat.js +2 -177
- 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 +31 -391
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +0 -14
- 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 +152 -491
- 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 +3 -180
- 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 +11 -134
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +15 -114
- package/dist/src/graphs.d.ts +6 -157
- package/dist/src/graphs.js +65 -266
- package/dist/src/grep-regex-worker.js +0 -2
- package/dist/src/grep-regex.d.ts +1 -5
- package/dist/src/grep-regex.js +6 -8
- package/dist/src/grok-provider.d.ts +0 -17
- package/dist/src/grok-provider.js +1 -26
- package/dist/src/handoffs.d.ts +0 -11
- package/dist/src/handoffs.js +0 -13
- package/dist/src/hardened-runtime.d.ts +0 -10
- package/dist/src/hardened-runtime.js +8 -46
- package/dist/src/harness-home.d.ts +21 -0
- package/dist/src/harness-home.js +87 -0
- package/dist/src/host-process-guard.d.ts +0 -50
- package/dist/src/host-process-guard.js +0 -641
- package/dist/src/limits.d.ts +0 -64
- package/dist/src/limits.js +0 -62
- package/dist/src/managed-sign-in.d.ts +0 -12
- package/dist/src/managed-sign-in.js +0 -16
- package/dist/src/markdown.d.ts +0 -28
- package/dist/src/markdown.js +1 -175
- package/dist/src/mcp.d.ts +0 -99
- package/dist/src/mcp.js +4 -170
- package/dist/src/membership-errors.d.ts +0 -14
- package/dist/src/membership-errors.js +0 -13
- package/dist/src/membership.d.ts +2 -60
- package/dist/src/membership.js +0 -85
- package/dist/src/memory/LocalToolMemory.d.ts +0 -1
- package/dist/src/memory/LocalToolMemory.js +2 -7
- package/dist/src/memory/MemoryDistiller.js +0 -15
- package/dist/src/memory/MemoryManager.d.ts +0 -3
- package/dist/src/memory/MemoryManager.js +6 -18
- package/dist/src/memory/MemoryPolicy.d.ts +0 -2
- package/dist/src/memory/MemoryPolicy.js +0 -2
- package/dist/src/memory/MemoryProvider.d.ts +0 -6
- package/dist/src/memory/MemoryRetriever.js +0 -7
- package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
- package/dist/src/memory/PermissionMemoryProvider.js +0 -1
- package/dist/src/memory/ProjectMemory.d.ts +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-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +1 -49
- package/dist/src/model-metadata.d.ts +0 -18
- package/dist/src/model-metadata.js +2 -42
- package/dist/src/model-override.d.ts +0 -36
- package/dist/src/model-override.js +0 -43
- package/dist/src/model-tiers.d.ts +0 -13
- package/dist/src/model-tiers.js +0 -23
- package/dist/src/opencode-catalog.d.ts +0 -2
- package/dist/src/opencode-catalog.js +0 -11
- package/dist/src/opencode-cli-provider.d.ts +0 -35
- package/dist/src/opencode-cli-provider.js +1 -44
- package/dist/src/opencode-provider.d.ts +0 -2
- package/dist/src/opencode-provider.js +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 +0 -63
- package/dist/src/palette.js +0 -63
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +0 -17
- package/dist/src/powershell-pool.d.ts +0 -9
- package/dist/src/powershell-pool.js +3 -26
- package/dist/src/process-warnings.d.ts +4 -0
- package/dist/src/process-warnings.js +103 -0
- package/dist/src/profile.d.ts +0 -43
- package/dist/src/profile.js +0 -43
- package/dist/src/project-reservation.d.ts +11 -0
- package/dist/src/project-reservation.js +143 -0
- package/dist/src/provider-connection.d.ts +0 -18
- package/dist/src/provider-connection.js +0 -39
- package/dist/src/provider-engine.d.ts +0 -21
- package/dist/src/provider-engine.js +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 +0 -2
- package/dist/src/provider-settings.js +0 -32
- package/dist/src/providers.d.ts +0 -217
- package/dist/src/providers.js +0 -315
- package/dist/src/pull-requests.d.ts +0 -173
- package/dist/src/pull-requests.js +5 -195
- package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
- package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
- package/dist/src/qa/command-policy.d.ts +0 -23
- package/dist/src/qa/command-policy.js +0 -30
- package/dist/src/qa/guidance.d.ts +0 -21
- package/dist/src/qa/guidance.js +0 -20
- package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
- package/dist/src/qa/profile/ProjectInspector.js +0 -6
- package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
- package/dist/src/qa/profile/QaConfigLoader.js +0 -6
- package/dist/src/qa/profile/QaProfile.d.ts +0 -7
- package/dist/src/qa/profile/QaProfile.js +0 -7
- package/dist/src/qa/profile/yaml.d.ts +0 -9
- package/dist/src/qa/profile/yaml.js +0 -13
- package/dist/src/qa/qa-authorize.d.ts +0 -19
- package/dist/src/qa/qa-authorize.js +4 -11
- package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
- package/dist/src/qa/runtime/ProcessManager.js +4 -41
- package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
- package/dist/src/qa/runtime/PtyManager.js +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 +95 -415
- 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 +17 -335
- package/dist/src/remote/errors.d.ts +0 -15
- package/dist/src/remote/errors.js +0 -7
- package/dist/src/remote/network.d.ts +0 -26
- package/dist/src/remote/network.js +1 -34
- package/dist/src/remote/pairing.d.ts +16 -51
- package/dist/src/remote/pairing.js +50 -57
- package/dist/src/remote/pem.d.ts +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 +0 -7
- package/dist/src/run-control.js +0 -7
- package/dist/src/run-progress.d.ts +0 -170
- package/dist/src/run-progress.js +0 -285
- package/dist/src/run-records.d.ts +0 -443
- package/dist/src/run-records.js +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 +10 -228
- package/dist/src/runtime.js +0 -127
- package/dist/src/sandbox-child.js +0 -1
- package/dist/src/save-lock.d.ts +0 -12
- package/dist/src/save-lock.js +0 -28
- package/dist/src/screen-selection.d.ts +0 -23
- package/dist/src/screen-selection.js +0 -22
- package/dist/src/secret-redaction.d.ts +0 -12
- package/dist/src/secret-redaction.js +0 -45
- package/dist/src/session-changes.d.ts +4 -80
- package/dist/src/session-changes.js +25 -130
- package/dist/src/session-goal.d.ts +129 -0
- package/dist/src/session-goal.js +230 -0
- package/dist/src/session-monitor.d.ts +1 -10
- package/dist/src/session-monitor.js +2 -39
- package/dist/src/session-reaper.d.ts +0 -15
- package/dist/src/session-reaper.js +0 -14
- package/dist/src/session-skills.d.ts +15 -44
- package/dist/src/session-skills.js +75 -60
- package/dist/src/session-summary.d.ts +0 -26
- package/dist/src/session-summary.js +0 -32
- package/dist/src/session-title.d.ts +0 -1
- package/dist/src/session-title.js +0 -2
- package/dist/src/sessions.d.ts +2 -122
- package/dist/src/sessions.js +7 -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/provenance.json +1 -1
- 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 +0 -163
- package/dist/src/subagent-run.js +4 -373
- package/dist/src/subagent-tree.d.ts +32 -0
- package/dist/src/subagent-tree.js +128 -0
- package/dist/src/telemetry/aggregate.d.ts +0 -37
- package/dist/src/telemetry/aggregate.js +0 -40
- package/dist/src/telemetry/capture-core.d.ts +0 -87
- package/dist/src/telemetry/capture-core.js +0 -67
- package/dist/src/telemetry/capture.d.ts +0 -1
- package/dist/src/telemetry/capture.js +0 -3
- package/dist/src/telemetry/classify.d.ts +0 -58
- package/dist/src/telemetry/classify.js +0 -60
- package/dist/src/telemetry/decision-capture.d.ts +0 -1
- package/dist/src/telemetry/emitter.d.ts +0 -30
- package/dist/src/telemetry/emitter.js +1 -62
- package/dist/src/telemetry/gate.d.ts +0 -29
- package/dist/src/telemetry/gate.js +0 -22
- package/dist/src/telemetry/identity.d.ts +0 -13
- package/dist/src/telemetry/identity.js +0 -29
- package/dist/src/telemetry/outbox.d.ts +0 -64
- package/dist/src/telemetry/outbox.js +1 -108
- package/dist/src/telemetry/schema.d.ts +1 -49
- package/dist/src/telemetry/schema.js +1 -82
- package/dist/src/telemetry/state.d.ts +0 -53
- package/dist/src/telemetry/state.js +0 -64
- package/dist/src/telemetry/surface.d.ts +0 -31
- package/dist/src/telemetry/surface.js +1 -39
- package/dist/src/telemetry/uploader.d.ts +0 -11
- package/dist/src/telemetry/uploader.js +0 -46
- package/dist/src/telemetry/uploads.d.ts +0 -11
- package/dist/src/telemetry/uploads.js +0 -11
- package/dist/src/telemetry/version.d.ts +0 -4
- package/dist/src/telemetry/version.js +0 -14
- package/dist/src/telemetry/workspace.d.ts +0 -7
- package/dist/src/telemetry/workspace.js +1 -22
- package/dist/src/terminal-ui.d.ts +14 -523
- package/dist/src/terminal-ui.js +74 -876
- package/dist/src/test-edit-guard.d.ts +74 -0
- package/dist/src/test-edit-guard.js +269 -0
- package/dist/src/text.d.ts +0 -1
- package/dist/src/text.js +0 -1
- package/dist/src/time-limit.d.ts +0 -36
- package/dist/src/time-limit.js +0 -37
- package/dist/src/timers.d.ts +0 -161
- package/dist/src/timers.js +0 -126
- package/dist/src/todos.d.ts +0 -1
- package/dist/src/todos.js +0 -3
- package/dist/src/token-rate.d.ts +0 -94
- package/dist/src/token-rate.js +0 -154
- package/dist/src/tool-activity.d.ts +0 -6
- package/dist/src/tool-activity.js +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 +2 -60
- package/dist/src/types.d.ts +1 -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 +2 -2
package/dist/src/token-rate.js
CHANGED
|
@@ -1,60 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cumulative token speed meter.
|
|
3
|
-
*
|
|
4
|
-
* Providers report a request's tokens only when that request finishes. Each finished request
|
|
5
|
-
* is folded into running totals - sum of output tokens over sum of decoding time - so the
|
|
6
|
-
* reading is the *average* decoding speed across every request measured since the last
|
|
7
|
-
* reset, not the newest request alone. One fast call does not swing the footer: a 900-token
|
|
8
|
-
* request over 3 seconds and a later 2,000-token request over 10 seconds average to about
|
|
9
|
-
* 208 tok/s, and the average converges toward the provider's steady state as more land.
|
|
10
|
-
*
|
|
11
|
-
* The time a request is credited with is its decode window - first generated fragment to
|
|
12
|
-
* last - whenever the streaming adapter measured one (`Usage.decodeMs`). Prompt processing,
|
|
13
|
-
* the network and the runtime's own pre-request work all happen before the first fragment, so
|
|
14
|
-
* they stay out: a short answer to a 10K-token prompt is not read as a slow model. A request
|
|
15
|
-
* without a decode window falls back to the window between its start marker and its usage,
|
|
16
|
-
* and once any request was decode-measured those coarser readings no longer dilute the
|
|
17
|
-
* average.
|
|
18
|
-
*
|
|
19
|
-
* While a request is still streaming, its fragments are estimated into the reading live
|
|
20
|
-
* ({@link TokenRateMeter.stream}), so a long thinking stream moves the footer instead of
|
|
21
|
-
* holding the previous number until it completes. The provider's count replaces the estimate
|
|
22
|
-
* the moment the request's usage lands. Between LLM calls nothing changes and nothing decays.
|
|
23
|
-
* A completion that finished without usage still closes its request window but keeps the
|
|
24
|
-
* totals: the average it leaves on screen is a measurement of the requests that did report.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Window assumed when a request finished without one being opened.
|
|
28
|
-
*
|
|
29
|
-
* Both executors emit a start event before every model call, so this only happens for an
|
|
30
|
-
* embedder that reports usage on its own. Crediting those tokens one synthetic second of
|
|
31
|
-
* generating time keeps them in the average at a plausible speed; crediting them to a
|
|
32
|
-
* zero-length instant would divide by (near) zero and spike the whole average.
|
|
33
|
-
*/
|
|
34
1
|
const UNKNOWN_WINDOW_MS = 1_000;
|
|
35
|
-
/**
|
|
36
|
-
* How many requests may be in flight at once.
|
|
37
|
-
*
|
|
38
|
-
* Branch workers, parallel copies and delegated subagents each open their own request, and a
|
|
39
|
-
* start whose request never reports (aborted mid-call, or a run stopped between the start and
|
|
40
|
-
* its usage) would otherwise hold its slot forever and pair with a later completion. The
|
|
41
|
-
* runtime never runs more than a handful of model calls at a time, so this is a leak valve:
|
|
42
|
-
* the oldest in-flight window is dropped, and a completion that has lost its window falls back
|
|
43
|
-
* to {@link UNKNOWN_WINDOW_MS}.
|
|
44
|
-
*/
|
|
45
2
|
const MAX_IN_FLIGHT = 64;
|
|
46
|
-
/**
|
|
47
|
-
* Streamed decode time a live estimate needs before it joins the reading.
|
|
48
|
-
*
|
|
49
|
-
* The first fragments of a stream arrive in bursts a few milliseconds apart; dividing their
|
|
50
|
-
* characters by that sliver would flash an absurd speed before the window settles.
|
|
51
|
-
*/
|
|
52
3
|
const LIVE_MIN_WINDOW_MS = 1_000;
|
|
53
|
-
/**
|
|
54
|
-
* Estimate the tokens in a streamed fragment: four ASCII characters to a token, the common
|
|
55
|
-
* rate for English prose and code, and one token per character outside ASCII, which CJK text
|
|
56
|
-
* comes close to. Only a live reading uses it; the provider's count replaces it on completion.
|
|
57
|
-
*/
|
|
58
4
|
export function estimateStreamedTokens(text) {
|
|
59
5
|
let ascii = 0, other = 0;
|
|
60
6
|
for (const character of text) {
|
|
@@ -67,41 +13,16 @@ export function estimateStreamedTokens(text) {
|
|
|
67
13
|
}
|
|
68
14
|
export class TokenRateMeter {
|
|
69
15
|
clock;
|
|
70
|
-
/** When each in-flight model request began, oldest first; the pairing fallback for starts and completions that carry no id. See {@link MAX_IN_FLIGHT}. */
|
|
71
16
|
open = [];
|
|
72
|
-
/**
|
|
73
|
-
* In-flight requests that arrived with the executor's `invocationId`, keyed by it.
|
|
74
|
-
*
|
|
75
|
-
* Concurrent requests - branch workers, parallel graph copies, subagents - finish in an
|
|
76
|
-
* order no queue can predict: a later start can complete first. Keying by the id the
|
|
77
|
-
* executor stamps on both the start event and the usage delta pairs each completion with
|
|
78
|
-
* the window its own request opened.
|
|
79
|
-
*/
|
|
80
17
|
openById = new Map();
|
|
81
|
-
/** Output tokens summed over every request measured by its request window since the last reset. */
|
|
82
18
|
tokens = 0;
|
|
83
|
-
/** Request-window time summed over the same requests, in milliseconds. */
|
|
84
19
|
milliseconds = 0;
|
|
85
|
-
/** Output tokens summed over every request whose adapter measured a decode window. */
|
|
86
20
|
decodedTokens = 0;
|
|
87
|
-
/** Decode windows summed over the same requests, in milliseconds. */
|
|
88
21
|
decodeMilliseconds = 0;
|
|
89
|
-
/**
|
|
90
|
-
* Requests streaming right now, keyed by `invocationId` (`''` without one): the estimated
|
|
91
|
-
* tokens so far and the arrival times of the first and the latest fragment.
|
|
92
|
-
*/
|
|
93
22
|
live = new Map();
|
|
94
23
|
constructor(clock = () => Date.now()) {
|
|
95
24
|
this.clock = clock;
|
|
96
25
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Mark the start of a model request, so its eventual tokens are measured over this window.
|
|
99
|
-
*
|
|
100
|
-
* Every concurrent request gets its own entry: `src/graph-runner.ts` runs branch workers
|
|
101
|
-
* side by side, and a single slot would have a later start overwrite the first request's
|
|
102
|
-
* timestamp and the first completion clear it, leaving every later completion without a
|
|
103
|
-
* window of its own.
|
|
104
|
-
*/
|
|
105
26
|
beginRequest(invocationId) {
|
|
106
27
|
const at = this.clock();
|
|
107
28
|
if (invocationId) {
|
|
@@ -118,71 +39,27 @@ export class TokenRateMeter {
|
|
|
118
39
|
if (this.open.length > MAX_IN_FLIGHT)
|
|
119
40
|
this.open.shift();
|
|
120
41
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Record provider-reported tokens for one finished model request.
|
|
123
|
-
*
|
|
124
|
-
* A completion carrying the executor's `invocationId` closes exactly the window that id's
|
|
125
|
-
* start opened, so concurrent requests finishing out of order each measure over their own
|
|
126
|
-
* generation. Without an id on either side, each completion is paired with the oldest
|
|
127
|
-
* request still in flight - the one that has been generating longest - which is the best a
|
|
128
|
-
* start with no identity allows; what matters is that every completion gets a real window
|
|
129
|
-
* rather than the synthetic fallback.
|
|
130
|
-
*
|
|
131
|
-
* Only a delta that carries tokens closes a window. The adapters also report pure transport
|
|
132
|
-
* bookkeeping through this callback - the HTTP adapter counts every attempt, retries
|
|
133
|
-
* included, as `requests: 1` with zero tokens - and pairing a completion with the *wrong*
|
|
134
|
-
* window is worse than the synthetic fallback: an attempt delta popping a window would leave
|
|
135
|
-
* the real completion to pair with an older request's start or with none at all. A window
|
|
136
|
-
* whose call never reports tokens (a request that failed or was aborted) is dropped by the
|
|
137
|
-
* {@link MAX_IN_FLIGHT} valve instead.
|
|
138
|
-
*
|
|
139
|
-
* The delta that closes a request arrives flagged `final`. A final delta without tokens is
|
|
140
|
-
* an unmeasured completion - a provider that omits usage - and it closes its request all
|
|
141
|
-
* the same, but the cumulative totals stay: they describe the requests that did report, and
|
|
142
|
-
* the average on screen remains their measurement until the next completion or a reset.
|
|
143
|
-
* An attempt delta keeps its early return: it reports zero tokens by design, and it must
|
|
144
|
-
* neither steal a window nor disturb the average the real completion will extend.
|
|
145
|
-
* @param tokens - output tokens the provider reported for that one request.
|
|
146
|
-
* @param invocationId - request identity from the executor, when the caller has one.
|
|
147
|
-
* @param final - true when this delta closes its request (the response accounting), as
|
|
148
|
-
* opposed to per-attempt transport bookkeeping.
|
|
149
|
-
* @param decodeMs - the adapter's measured decode window for the request, when it has one;
|
|
150
|
-
* it replaces the request window as the time the tokens are credited with.
|
|
151
|
-
*/
|
|
152
42
|
report(tokens, invocationId, final, decodeMs) {
|
|
153
43
|
const count = Number.isFinite(tokens) && tokens > 0 ? Math.floor(tokens) : 0;
|
|
154
44
|
if (!count) {
|
|
155
45
|
if (!final)
|
|
156
46
|
return;
|
|
157
|
-
// An unmeasured completion still closes the request it belongs to, so its window is
|
|
158
|
-
// consumed here - leaving it open would make the next measured completion pair with
|
|
159
|
-
// this request's start instead of its own. The cumulative average stays as it is.
|
|
160
47
|
this.takeWindow(invocationId);
|
|
161
48
|
this.endStream(invocationId);
|
|
162
49
|
return;
|
|
163
50
|
}
|
|
164
51
|
const at = this.clock();
|
|
165
52
|
const started = this.takeWindow(invocationId);
|
|
166
|
-
// The provider's count supersedes the live estimate of the same request.
|
|
167
53
|
this.endStream(invocationId);
|
|
168
54
|
if (decodeMs !== undefined && Number.isFinite(decodeMs) && decodeMs > 0) {
|
|
169
55
|
this.decodedTokens += count;
|
|
170
56
|
this.decodeMilliseconds += decodeMs;
|
|
171
57
|
return;
|
|
172
58
|
}
|
|
173
|
-
// A request that starts and completes inside one clock tick (a cached answer, an
|
|
174
|
-
// in-process or test adapter) has no measurable duration. Crediting its tokens against
|
|
175
|
-
// even one real millisecond would spike the cumulative average to an absurd speed, so an
|
|
176
|
-
// unmeasurable window takes the same synthetic second an unknown window does.
|
|
177
59
|
const duration = started !== undefined && at > started ? at - started : UNKNOWN_WINDOW_MS;
|
|
178
60
|
this.tokens += count;
|
|
179
61
|
this.milliseconds += duration;
|
|
180
62
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Take the window a completion closes: the one its `invocationId` opened, or - when the
|
|
183
|
-
* request carried no id, or the id never opened one - the oldest still in flight. Returns
|
|
184
|
-
* undefined when nothing is in flight and the caller falls back to the synthetic window.
|
|
185
|
-
*/
|
|
186
63
|
takeWindow(invocationId) {
|
|
187
64
|
if (invocationId !== undefined) {
|
|
188
65
|
const started = this.openById.get(invocationId);
|
|
@@ -193,13 +70,6 @@ export class TokenRateMeter {
|
|
|
193
70
|
}
|
|
194
71
|
return this.open.length ? this.open.shift() : undefined;
|
|
195
72
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Credit a streamed fragment of a request that has not finished yet.
|
|
198
|
-
*
|
|
199
|
-
* The estimate counts toward the reading over the stream's own decode window - first
|
|
200
|
-
* fragment to latest - so a pause in the stream (a tool call's arguments, which do not
|
|
201
|
-
* stream as text) holds the reading rather than decaying it.
|
|
202
|
-
*/
|
|
203
73
|
stream(text, invocationId) {
|
|
204
74
|
const tokens = estimateStreamedTokens(text);
|
|
205
75
|
if (!tokens)
|
|
@@ -220,19 +90,9 @@ export class TokenRateMeter {
|
|
|
220
90
|
this.live.delete(oldest.value);
|
|
221
91
|
}
|
|
222
92
|
}
|
|
223
|
-
/** Drop a request's live estimate: its attempt failed, was retried, or was aborted. */
|
|
224
93
|
endStream(invocationId) {
|
|
225
94
|
this.live.delete(invocationId ?? '');
|
|
226
95
|
}
|
|
227
|
-
/**
|
|
228
|
-
* The tokens per second the footer shows: the average decoding speed over every request
|
|
229
|
-
* measured since the last reset, with any request still streaming blended in.
|
|
230
|
-
*
|
|
231
|
-
* Decode-measured requests and live streams are preferred; the request-window totals answer
|
|
232
|
-
* only when neither exists. Between completions the reading holds - no window drains and
|
|
233
|
-
* nothing decays. It moves as a stream grows or a completion lands, and resets to 0 with
|
|
234
|
-
* {@link reset}.
|
|
235
|
-
*/
|
|
236
96
|
rate() {
|
|
237
97
|
let tokens = this.decodedTokens, milliseconds = this.decodeMilliseconds;
|
|
238
98
|
for (const entry of this.live.values()) {
|
|
@@ -248,13 +108,8 @@ export class TokenRateMeter {
|
|
|
248
108
|
}
|
|
249
109
|
if (tokens <= 0 || milliseconds <= 0)
|
|
250
110
|
return 0;
|
|
251
|
-
// A positive reading never rounds away. A very slow cumulative average (say 1 token
|
|
252
|
-
// over several seconds) is a real measurement, and the footer gates the segment on
|
|
253
|
-
// `> 0`: rounding it to 0 would silently drop finished requests, reading like "nothing
|
|
254
|
-
// measured" when exactly the opposite happened.
|
|
255
111
|
return Math.max(1, Math.round(tokens / (milliseconds / 1_000)));
|
|
256
112
|
}
|
|
257
|
-
/** Forget everything measured so far; the caller resets it when the graph switches nodes. */
|
|
258
113
|
reset() {
|
|
259
114
|
this.open = [];
|
|
260
115
|
this.openById.clear();
|
|
@@ -265,15 +120,6 @@ export class TokenRateMeter {
|
|
|
265
120
|
this.decodeMilliseconds = 0;
|
|
266
121
|
}
|
|
267
122
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Route a model request's streamed fragments into the speed readout, keeping the caller's hooks.
|
|
270
|
-
*
|
|
271
|
-
* Only a request carrying the executor's `invocationId` is metered: its usage delta reports under
|
|
272
|
-
* the same id and replaces the estimate. A call made outside the runtime - a graph health probe,
|
|
273
|
-
* whose usage only feeds the probe bookkeeping - has no completion that would ever retire its
|
|
274
|
-
* estimate, which would then blend into every later reading, so it passes through untouched.
|
|
275
|
-
* Each new attempt drops the estimate the previous one left.
|
|
276
|
-
*/
|
|
277
123
|
export function meterStreamedRequest(request, sink) {
|
|
278
124
|
const invocationId = request.context?.invocationId;
|
|
279
125
|
if (invocationId === undefined)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RuntimeEvent } from './types.js';
|
|
2
|
-
/** Tracks tool calls that are currently executing across concurrent graph invocations. */
|
|
3
2
|
export declare class ToolActivity {
|
|
4
3
|
private readonly active;
|
|
5
4
|
private readonly retries;
|
|
@@ -12,9 +11,4 @@ export declare class ToolActivity {
|
|
|
12
11
|
private invocationKey;
|
|
13
12
|
private key;
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Converts runtime events that affect the single-slot CLI activity label into the correct label.
|
|
17
|
-
* Iteration events intentionally derive from the tracker, so one parallel invocation cannot replace
|
|
18
|
-
* a sibling's still-running tool with "Thinking".
|
|
19
|
-
*/
|
|
20
14
|
export declare function activityForRuntimeEvent(event: RuntimeEvent, activity: ToolActivity): string | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** Tracks tool calls that are currently executing across concurrent graph invocations. */
|
|
2
1
|
export class ToolActivity {
|
|
3
2
|
active = new Map();
|
|
4
3
|
retries = new Map();
|
|
@@ -55,11 +54,6 @@ export class ToolActivity {
|
|
|
55
54
|
: `${invocation}\u0000name:${String(data.name ?? '')}`;
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Converts runtime events that affect the single-slot CLI activity label into the correct label.
|
|
60
|
-
* Iteration events intentionally derive from the tracker, so one parallel invocation cannot replace
|
|
61
|
-
* a sibling's still-running tool with "Thinking".
|
|
62
|
-
*/
|
|
63
57
|
export function activityForRuntimeEvent(event, activity) {
|
|
64
58
|
if (event.type === 'node.tool.started')
|
|
65
59
|
return activity.start(event.data);
|
|
@@ -67,7 +61,6 @@ export function activityForRuntimeEvent(event, activity) {
|
|
|
67
61
|
return activity.finish(event.data);
|
|
68
62
|
if (event.type === 'agent.model.retry')
|
|
69
63
|
return event.data.quiet === true ? undefined : activity.retry(event.data);
|
|
70
|
-
// Session completion also covers exhausted retries, failed requests and cancellation.
|
|
71
64
|
if (event.type === 'agent.model.completed' || event.type === 'agent.session.completed')
|
|
72
65
|
return activity.finishModel(event.data);
|
|
73
66
|
if (event.type === 'agent.iteration.started')
|
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
import type { Tool } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Ask each tool that can tell whether it is usable here, once, as a run starts. A tool that is not
|
|
4
|
-
* is marked `unavailable` for the run: the model is not shown it, so it does not spend a turn
|
|
5
|
-
* calling something that can only answer "not configured".
|
|
6
|
-
*
|
|
7
|
-
* Availability is not permission. An unavailable tool stays in every permission catalog, so a
|
|
8
|
-
* graph node or subagent role that names it is still valid, and a call that reaches it anyway
|
|
9
|
-
* still runs and reports the real problem. `providerVisible: false` is the different, permanent
|
|
10
|
-
* case of a legacy tool that no node is ever granted.
|
|
11
|
-
*
|
|
12
|
-
* A check that throws leaves the tool available: the call itself then reports what is wrong.
|
|
13
|
-
*/
|
|
14
2
|
export declare function advertiseAvailableTools<T extends Tool>(tools: readonly T[]): Promise<T[]>;
|
|
15
|
-
/** Whether the model is shown this tool: not a hidden legacy tool, and usable in this run. */
|
|
16
3
|
export declare function advertisable(tool: Pick<Tool, 'providerVisible' | 'unavailable'>): boolean;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ask each tool that can tell whether it is usable here, once, as a run starts. A tool that is not
|
|
3
|
-
* is marked `unavailable` for the run: the model is not shown it, so it does not spend a turn
|
|
4
|
-
* calling something that can only answer "not configured".
|
|
5
|
-
*
|
|
6
|
-
* Availability is not permission. An unavailable tool stays in every permission catalog, so a
|
|
7
|
-
* graph node or subagent role that names it is still valid, and a call that reaches it anyway
|
|
8
|
-
* still runs and reports the real problem. `providerVisible: false` is the different, permanent
|
|
9
|
-
* case of a legacy tool that no node is ever granted.
|
|
10
|
-
*
|
|
11
|
-
* A check that throws leaves the tool available: the call itself then reports what is wrong.
|
|
12
|
-
*/
|
|
13
1
|
export async function advertiseAvailableTools(tools) {
|
|
14
2
|
return Promise.all(tools.map(async (tool) => {
|
|
15
3
|
if (!tool.available || tool.unavailable === true)
|
|
@@ -18,11 +6,10 @@ export async function advertiseAvailableTools(tools) {
|
|
|
18
6
|
try {
|
|
19
7
|
available = await tool.available();
|
|
20
8
|
}
|
|
21
|
-
catch {
|
|
9
|
+
catch { }
|
|
22
10
|
return available ? tool : { ...tool, unavailable: true };
|
|
23
11
|
}));
|
|
24
12
|
}
|
|
25
|
-
/** Whether the model is shown this tool: not a hidden legacy tool, and usable in this run. */
|
|
26
13
|
export function advertisable(tool) {
|
|
27
14
|
return tool.providerVisible !== false && tool.unavailable !== true;
|
|
28
15
|
}
|
|
@@ -9,11 +9,10 @@ export interface ToolCallTiming extends ToolCallStamp {
|
|
|
9
9
|
copy: unknown;
|
|
10
10
|
subagentId: unknown;
|
|
11
11
|
startedAt: number;
|
|
12
|
-
elapsedMs?: number;
|
|
12
|
+
elapsedMs?: number;
|
|
13
13
|
pausedSince?: number;
|
|
14
14
|
}
|
|
15
15
|
export declare function toolCallStamp(event: RuntimeEvent): ToolCallStamp;
|
|
16
|
-
/** UI-only state. Completed entries retain their frozen object after leaving the active map. */
|
|
17
16
|
export declare class ToolCallClock {
|
|
18
17
|
private readonly now;
|
|
19
18
|
private readonly active;
|
|
@@ -21,12 +20,10 @@ export declare class ToolCallClock {
|
|
|
21
20
|
get running(): boolean;
|
|
22
21
|
get(key: string): ToolCallTiming | undefined;
|
|
23
22
|
elapsed(timing: ToolCallTiming): number;
|
|
24
|
-
/** Hold the displayed reading while a human decides; the wait is not the call running. */
|
|
25
23
|
private pause;
|
|
26
24
|
private resume;
|
|
27
25
|
stop(runId?: unknown): void;
|
|
28
26
|
accept(event: RuntimeEvent): void;
|
|
29
27
|
}
|
|
30
|
-
/** Keep the complete header; reserve a right column when it fits, otherwise wrap the clock. */
|
|
31
28
|
export declare function toolHeaderRows(header: string, right: string, width: number): string[];
|
|
32
29
|
export declare function staticToolTimestamp(text: string, stamp?: ToolCallStamp): string;
|
|
@@ -9,7 +9,6 @@ export function toolCallStamp(event) {
|
|
|
9
9
|
? [date.getHours(), date.getMinutes(), date.getSeconds()].map(value => String(value).padStart(2, '0')).join(':') : undefined;
|
|
10
10
|
return { key, ...(timestamp ? { timestamp } : {}) };
|
|
11
11
|
}
|
|
12
|
-
/** UI-only state. Completed entries retain their frozen object after leaving the active map. */
|
|
13
12
|
export class ToolCallClock {
|
|
14
13
|
now;
|
|
15
14
|
active = new Map();
|
|
@@ -19,7 +18,6 @@ export class ToolCallClock {
|
|
|
19
18
|
get running() { return this.active.size > 0; }
|
|
20
19
|
get(key) { return this.active.get(key); }
|
|
21
20
|
elapsed(timing) { return timing.elapsedMs ?? Math.max(0, (timing.pausedSince ?? this.now()) - timing.startedAt); }
|
|
22
|
-
/** Hold the displayed reading while a human decides; the wait is not the call running. */
|
|
23
21
|
pause(timing) { if (timing.elapsedMs === undefined && timing.pausedSince === undefined)
|
|
24
22
|
timing.pausedSince = this.now(); }
|
|
25
23
|
resume(timing) {
|
|
@@ -56,8 +54,6 @@ export class ToolCallClock {
|
|
|
56
54
|
}
|
|
57
55
|
return;
|
|
58
56
|
}
|
|
59
|
-
// A human decision inside a call — an approval prompt or a clarification question — is not
|
|
60
|
-
// execution time: freeze the clock for the affected call for as long as the wait lasts.
|
|
61
57
|
if (event.type === 'node.tool.approval.requested' || event.type === 'node.tool.approval.decided') {
|
|
62
58
|
if (typeof event.data.toolCallId !== 'string' || !event.data.toolCallId.trim())
|
|
63
59
|
return;
|
|
@@ -71,11 +67,6 @@ export class ToolCallClock {
|
|
|
71
67
|
return;
|
|
72
68
|
}
|
|
73
69
|
if (event.type === 'agent.clarification.requested' || event.type === 'agent.clarification.answered') {
|
|
74
|
-
// Clarification events carry no call id, so they pair by the invocation they belong to.
|
|
75
|
-
// `ask_user` is sequential only inside one invocation: concurrent copies of a node, and a
|
|
76
|
-
// node's subagents, ask and answer apart, so the pairing must match every stamp an active
|
|
77
|
-
// call carries — otherwise one copy's question freezes a sibling still at work, and one
|
|
78
|
-
// answer resumes a clock whose own question nobody has answered.
|
|
79
70
|
for (const timing of this.active.values()) {
|
|
80
71
|
if (timing.runId !== event.data.runId || timing.nodeId !== event.data.nodeId)
|
|
81
72
|
continue;
|
|
@@ -90,13 +81,10 @@ export class ToolCallClock {
|
|
|
90
81
|
}
|
|
91
82
|
if (!['node.tool.started', 'node.tool.completed', 'node.tool.failed'].includes(event.type))
|
|
92
83
|
return;
|
|
93
|
-
// Legacy events without a call ID get a static timestamp; guessing by name
|
|
94
|
-
// would pair concurrent calls incorrectly.
|
|
95
84
|
if (typeof event.data.toolCallId !== 'string' || !event.data.toolCallId.trim())
|
|
96
85
|
return;
|
|
97
86
|
const stamp = toolCallStamp(event);
|
|
98
87
|
if (event.type === 'node.tool.started') {
|
|
99
|
-
// Duplicate start delivery must not restart a timer already on screen.
|
|
100
88
|
if (!this.active.has(stamp.key))
|
|
101
89
|
this.active.set(stamp.key, { ...stamp, runId: event.data.runId,
|
|
102
90
|
nodeId: event.data.nodeId, copy: event.data.copy, subagentId: event.data.subagentId, startedAt: this.now() });
|
|
@@ -131,7 +119,6 @@ function splitWidth(text, width) {
|
|
|
131
119
|
rows.push(row);
|
|
132
120
|
return rows;
|
|
133
121
|
}
|
|
134
|
-
/** Keep the complete header; reserve a right column when it fits, otherwise wrap the clock. */
|
|
135
122
|
export function toolHeaderRows(header, right, width) {
|
|
136
123
|
width = Math.max(1, Math.floor(width));
|
|
137
124
|
if (!right)
|
|
@@ -4,9 +4,7 @@ export interface CatalogSelectionInput {
|
|
|
4
4
|
tools: Tool[];
|
|
5
5
|
task: string;
|
|
6
6
|
facts?: WorkspaceFacts;
|
|
7
|
-
/** Tools the node configuration names explicitly; always kept when permitted. */
|
|
8
7
|
explicitTools?: readonly string[];
|
|
9
|
-
/** Tool names called in an inherited conversation; always kept. */
|
|
10
8
|
historicalToolNames?: readonly string[];
|
|
11
9
|
codeGraphAvailable?: boolean;
|
|
12
10
|
memoryAvailable?: boolean;
|
|
@@ -19,21 +17,12 @@ export interface CatalogSelection {
|
|
|
19
17
|
schemaCharsAfter: number;
|
|
20
18
|
}
|
|
21
19
|
export declare function schemaChars(tools: readonly Tool[]): number;
|
|
22
|
-
/**
|
|
23
|
-
* Select the catalog. The order of the kept tools is the order of the input, so a stable input
|
|
24
|
-
* yields a byte-stable schema list.
|
|
25
|
-
*/
|
|
26
20
|
export declare function selectToolCatalog(input: CatalogSelectionInput): CatalogSelection;
|
|
27
21
|
export interface SkillSummary {
|
|
28
22
|
id: string;
|
|
29
23
|
description: string;
|
|
30
24
|
unavailable?: string;
|
|
31
25
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Order the skill catalog by lexical relevance to the task and fit it into a budget, keeping
|
|
34
|
-
* explicitly requested and inherited skills first and whole. Entries that do not fit are named
|
|
35
|
-
* without their descriptions so they stay loadable.
|
|
36
|
-
*/
|
|
37
26
|
export declare function orderSkillCatalog(skills: readonly SkillSummary[], task: string, required: readonly string[], budgetChars: number): {
|
|
38
27
|
entries: SkillSummary[];
|
|
39
28
|
namedOnly: string[];
|
package/dist/src/tool-catalog.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic, task-appropriate tool catalog built from the tools a node is already permitted
|
|
3
|
-
* to use, and lazy ordering of the skill catalog.
|
|
4
|
-
*
|
|
5
|
-
* Nothing here grants authority: the input is the capability-filtered catalog, the output is a
|
|
6
|
-
* subset of it, and every omitted tool stays restorable through `restore_tools` with the same
|
|
7
|
-
* permission checks. Only certainties omit a family (no repository, no index, an empty folder);
|
|
8
|
-
* unknown families are kept, protected tools are kept, tools the node names explicitly are kept,
|
|
9
|
-
* and a tool that an inherited transcript already called is kept so providers that require the
|
|
10
|
-
* schema of a historical call still see it. The selection is a pure function of its inputs, so
|
|
11
|
-
* the same node state yields the same ordered catalog and the same serialized schemas.
|
|
12
|
-
* @module tool-catalog
|
|
13
|
-
*/
|
|
14
1
|
import { toolFamily } from './decision/toolFamilies.js';
|
|
15
2
|
import { canonicalToolName } from './tool-names.js';
|
|
16
3
|
import { identifierTokens } from './context-selection.js';
|
|
@@ -23,7 +10,6 @@ const DELEGATION_WORDS = /\b(delegate|subagent|parallel|in parallel|research)\b/
|
|
|
23
10
|
export function schemaChars(tools) {
|
|
24
11
|
return JSON.stringify(tools.map(({ name, description, parameters }) => ({ name, description, parameters }))).length;
|
|
25
12
|
}
|
|
26
|
-
/** Families that facts can rule out, and the condition that rules each out. */
|
|
27
13
|
function omissionReason(family, input) {
|
|
28
14
|
const facts = input.facts;
|
|
29
15
|
const task = input.task;
|
|
@@ -37,10 +23,6 @@ function omissionReason(family, input) {
|
|
|
37
23
|
default: return undefined;
|
|
38
24
|
}
|
|
39
25
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Select the catalog. The order of the kept tools is the order of the input, so a stable input
|
|
42
|
-
* yields a byte-stable schema list.
|
|
43
|
-
*/
|
|
44
26
|
export function selectToolCatalog(input) {
|
|
45
27
|
const explicit = new Set((input.explicitTools ?? []).map(canonicalToolName));
|
|
46
28
|
const historical = new Set((input.historicalToolNames ?? []).map(canonicalToolName));
|
|
@@ -63,11 +45,6 @@ export function selectToolCatalog(input) {
|
|
|
63
45
|
});
|
|
64
46
|
return { tools, omitted, reasons, schemaCharsBefore: schemaChars(input.tools), schemaCharsAfter: schemaChars(tools) };
|
|
65
47
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Order the skill catalog by lexical relevance to the task and fit it into a budget, keeping
|
|
68
|
-
* explicitly requested and inherited skills first and whole. Entries that do not fit are named
|
|
69
|
-
* without their descriptions so they stay loadable.
|
|
70
|
-
*/
|
|
71
48
|
export function orderSkillCatalog(skills, task, required, budgetChars) {
|
|
72
49
|
const tokens = identifierTokens(task);
|
|
73
50
|
const score = (skill) => {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Order tools by their actual side effects, not by the most restrictive tool in
|
|
3
|
-
* a whole model response. Every barrier waits for outstanding reads. A read after
|
|
4
|
-
* a barrier waits for it, but independent reads within each segment can overlap.
|
|
5
|
-
*/
|
|
6
1
|
export interface PlannedToolCall {
|
|
7
2
|
id: string;
|
|
8
3
|
name: string;
|
|
@@ -6,12 +6,8 @@ const SEQUENTIAL = new Set([
|
|
|
6
6
|
]);
|
|
7
7
|
const READ_CAPABILITIES = new Set(['git.read', 'github.read']);
|
|
8
8
|
export function requiresToolBarrier(name, tool) {
|
|
9
|
-
// AsyncProcess status/logs/wait do not mutate the job and may overlap reads.
|
|
10
|
-
// The caller must explicitly classify only those actions as parallel.
|
|
11
9
|
if (name === 'AsyncProcess' && tool?.executionMode === 'parallel')
|
|
12
10
|
return false;
|
|
13
|
-
// web_search rides the browser capability for policy, but only sends a query to a search service:
|
|
14
|
-
// it changes no page, file or session, so independent searches may overlap each other and reads.
|
|
15
11
|
if (name === 'web_search' && tool?.executionMode === 'parallel')
|
|
16
12
|
return false;
|
|
17
13
|
if (tool?.executionMode === 'sequential' || SEQUENTIAL.has(name))
|
|
@@ -3,31 +3,8 @@ export interface LineDiffStats {
|
|
|
3
3
|
linesAdded: number;
|
|
4
4
|
linesRemoved: number;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
7
|
-
* The file a mutating call will change, resolved inside the workspace, or null for anything else.
|
|
8
|
-
*
|
|
9
|
-
* Canonical spelling names the file `file_path` and every adopted spelling names it `path`; both are
|
|
10
|
-
* read so a legacy journal replayed through the same runtime gets the same figures as a live call.
|
|
11
|
-
* A path that leaves the workspace resolves to nothing: the tools refuse such a call, and reporting
|
|
12
|
-
* stats for a file the sandbox forbids would measure what was never written.
|
|
13
|
-
*/
|
|
14
6
|
export declare function fileDiffTarget(name: string, args: Record<string, unknown>, workspace: string): string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Read a snapshot for the diff, answering the three states apart.
|
|
17
|
-
*
|
|
18
|
-
* `null` is an absent file — the before-half of a newly created file, every line of which counts as
|
|
19
|
-
* added. `undefined` is "not measurable": a directory, a file over the size ceiling, or any read the
|
|
20
|
-
* file system refused for a reason the transcript cannot explain. A caller holding `undefined` for
|
|
21
|
-
* either half reports no stats rather than inventing them.
|
|
22
|
-
*/
|
|
23
7
|
export declare function readFileSnapshot(target: string): Promise<string | null | undefined>;
|
|
24
|
-
/** The added/removed line counts for a snapshot pair; nothing when either half was unmeasurable. */
|
|
25
8
|
export declare function diffLineStats(before: string | null | undefined, after: string | null | undefined): LineDiffStats | undefined;
|
|
26
|
-
/** Diff lines a completed call's event carries: a row shows the start and says how many more there are. */
|
|
27
9
|
export declare const CALL_DIFF_LINES = 200;
|
|
28
|
-
/**
|
|
29
|
-
* One call's change to its file as numbered hunks, for the `fileDiff` of its `node.tool.completed` event: what
|
|
30
|
-
* the file held before the call against what it holds after, so a Write over an existing file shows the lines
|
|
31
|
-
* it really changed and every line carries its number. Nothing for a call that changed nothing.
|
|
32
|
-
*/
|
|
33
10
|
export declare function callFileDiff(before: string | null, after: string | null): Pick<FileDiff, 'hunks' | 'hiddenLines'> | undefined;
|
|
@@ -2,29 +2,8 @@ import * as fs from 'node:fs/promises';
|
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { canonicalCodingToolName } from './tool-names.js';
|
|
4
4
|
import { textDiff } from './file-diff.js';
|
|
5
|
-
/**
|
|
6
|
-
* The line counts behind a successful file mutation, reported on its `node.tool.completed` event.
|
|
7
|
-
*
|
|
8
|
-
* The transcript shows `+N -M` beside an Edit or Write the way a diff stat does: what the call added
|
|
9
|
-
* and removed, counted against the file's real content. The runtime is the only place both halves
|
|
10
|
-
* exist — the tool's arguments say what was asked, but the before-and-after on disk says what
|
|
11
|
-
* happened (a Write over an existing file changes fewer lines than it carries). So the runtime
|
|
12
|
-
* snapshots the target file before execution and re-reads it on success, and this module turns the
|
|
13
|
-
* pair into counts. A call whose file cannot be read at one of those moments reports nothing: the
|
|
14
|
-
* row then shows the change without figures rather than figures about a file no one measured.
|
|
15
|
-
*/
|
|
16
|
-
/** Files past this size are skipped rather than measured; the same ceiling the read path enforces. */
|
|
17
5
|
const MAX_STAT_BYTES = 2_000_000;
|
|
18
|
-
/** The changed middle is diffed exactly up to this many lines per side; beyond it the whole span counts. */
|
|
19
6
|
const LCS_LINE_LIMIT = 4_000;
|
|
20
|
-
/**
|
|
21
|
-
* The file a mutating call will change, resolved inside the workspace, or null for anything else.
|
|
22
|
-
*
|
|
23
|
-
* Canonical spelling names the file `file_path` and every adopted spelling names it `path`; both are
|
|
24
|
-
* read so a legacy journal replayed through the same runtime gets the same figures as a live call.
|
|
25
|
-
* A path that leaves the workspace resolves to nothing: the tools refuse such a call, and reporting
|
|
26
|
-
* stats for a file the sandbox forbids would measure what was never written.
|
|
27
|
-
*/
|
|
28
7
|
export function fileDiffTarget(name, args, workspace) {
|
|
29
8
|
const canonical = canonicalCodingToolName(name);
|
|
30
9
|
if (canonical !== 'Write' && canonical !== 'Edit')
|
|
@@ -40,14 +19,6 @@ export function fileDiffTarget(name, args, workspace) {
|
|
|
40
19
|
return null;
|
|
41
20
|
return resolved;
|
|
42
21
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Read a snapshot for the diff, answering the three states apart.
|
|
45
|
-
*
|
|
46
|
-
* `null` is an absent file — the before-half of a newly created file, every line of which counts as
|
|
47
|
-
* added. `undefined` is "not measurable": a directory, a file over the size ceiling, or any read the
|
|
48
|
-
* file system refused for a reason the transcript cannot explain. A caller holding `undefined` for
|
|
49
|
-
* either half reports no stats rather than inventing them.
|
|
50
|
-
*/
|
|
51
22
|
export async function readFileSnapshot(target) {
|
|
52
23
|
try {
|
|
53
24
|
const stat = await fs.stat(target);
|
|
@@ -62,14 +33,12 @@ export async function readFileSnapshot(target) {
|
|
|
62
33
|
return undefined;
|
|
63
34
|
}
|
|
64
35
|
}
|
|
65
|
-
/** The added/removed line counts for a snapshot pair; nothing when either half was unmeasurable. */
|
|
66
36
|
export function diffLineStats(before, after) {
|
|
67
37
|
if (before === undefined || after === undefined)
|
|
68
38
|
return undefined;
|
|
69
39
|
const [linesAdded, linesRemoved] = countDiff(contentLines(before ?? ''), contentLines(after ?? ''));
|
|
70
40
|
return { linesAdded, linesRemoved };
|
|
71
41
|
}
|
|
72
|
-
/** A file's content as counted lines: no trailing empty line, CRLF and bare CR folded to LF. */
|
|
73
42
|
function contentLines(content) {
|
|
74
43
|
if (content === '')
|
|
75
44
|
return [];
|
|
@@ -78,15 +47,6 @@ function contentLines(content) {
|
|
|
78
47
|
lines.pop();
|
|
79
48
|
return lines;
|
|
80
49
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Count the lines a diff would mark added and removed between two line arrays.
|
|
83
|
-
*
|
|
84
|
-
* The shared head and tail are trimmed first — a change in the middle of a file has nothing to do
|
|
85
|
-
* with its unchanged ends — and what is left of the change is matched with a longest-common-
|
|
86
|
-
* subsequence count, the figure a diff tool marks as changed lines. Past the guard the middle is
|
|
87
|
-
* counted whole: a file whose changed span exceeds it is a rewrite, where every middle line really
|
|
88
|
-
* is different for the reader's purposes.
|
|
89
|
-
*/
|
|
90
50
|
function countDiff(oldLines, newLines) {
|
|
91
51
|
let low = 0;
|
|
92
52
|
while (low < oldLines.length && low < newLines.length && oldLines[low] === newLines[low])
|
|
@@ -104,7 +64,6 @@ function countDiff(oldLines, newLines) {
|
|
|
104
64
|
return [0, midOld.length];
|
|
105
65
|
if (midOld.length > LCS_LINE_LIMIT || midNew.length > LCS_LINE_LIMIT)
|
|
106
66
|
return [midNew.length, midOld.length];
|
|
107
|
-
// Row-by-row LCS over the changed span, two rolling rows: the counts are all that survive.
|
|
108
67
|
let previous = new Uint32Array(midOld.length + 1);
|
|
109
68
|
let current = new Uint32Array(midOld.length + 1);
|
|
110
69
|
for (let i = 1; i <= midNew.length; i++) {
|
|
@@ -121,18 +80,10 @@ function countDiff(oldLines, newLines) {
|
|
|
121
80
|
const common = previous[midOld.length];
|
|
122
81
|
return [midNew.length - common, midOld.length - common];
|
|
123
82
|
}
|
|
124
|
-
/** Diff lines a completed call's event carries: a row shows the start and says how many more there are. */
|
|
125
83
|
export const CALL_DIFF_LINES = 200;
|
|
126
|
-
/** Characters of diff text a completed call's event carries, so one minified line cannot fill the journal. */
|
|
127
84
|
const CALL_DIFF_CHARS = 24_000;
|
|
128
85
|
const CALL_DIFF_LINE_CHARS = 400;
|
|
129
|
-
/**
|
|
130
|
-
* One call's change to its file as numbered hunks, for the `fileDiff` of its `node.tool.completed` event: what
|
|
131
|
-
* the file held before the call against what it holds after, so a Write over an existing file shows the lines
|
|
132
|
-
* it really changed and every line carries its number. Nothing for a call that changed nothing.
|
|
133
|
-
*/
|
|
134
86
|
export function callFileDiff(before, after) {
|
|
135
|
-
// A NUL byte is a binary file read as text: its "lines" are not something a reader can check.
|
|
136
87
|
if (before?.includes('\0') || after?.includes('\0'))
|
|
137
88
|
return undefined;
|
|
138
89
|
const diff = textDiff(before ?? '', after ?? '', { maxLines: CALL_DIFF_LINES, maxChars: CALL_DIFF_CHARS, lineChars: CALL_DIFF_LINE_CHARS });
|