@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/coding-tools.js
CHANGED
|
@@ -13,42 +13,45 @@ import { commandTimingSummary } from './command-metrics.js';
|
|
|
13
13
|
import { runPooledPowerShell } from './powershell-pool.js';
|
|
14
14
|
import { withStrayFileNotice } from './stray-files.js';
|
|
15
15
|
import { assertNotHostKill, assertNotHostKillArgv, hostShellOf } from './host-process-guard.js';
|
|
16
|
+
import { assertNotGitIdentityOverride, assertNotGitIdentityOverrideArgv } from './git-identity-guard.js';
|
|
17
|
+
import { assertNoHoldEscape, withIdentityAudit } from './git-identity-audit.js';
|
|
16
18
|
import { getQaProcessManager, PERSISTENT_JOBS_SUPPORTED } from './qa/runtime/ProcessManager.js';
|
|
17
19
|
import { clipText } from './text.js';
|
|
18
20
|
import { matchesFileRead, storeFileRead } from './file-read-state.js';
|
|
19
|
-
import { FileReadRequiredError } from './tool-errors.js';
|
|
21
|
+
import { CommandExitError, FileReadRequiredError } from './tool-errors.js';
|
|
20
22
|
import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
|
|
21
23
|
import { withGrepRegex } from './grep-regex.js';
|
|
22
24
|
import { claimReadImages, readImageObservation } from './read-image.js';
|
|
23
25
|
import { READ_PDF_RENDER_PAGES, legacyTextObservation, readDocumentObservation } from './read-document-tool.js';
|
|
26
|
+
import { assertCommandAvoidsHarnessHome, guardsHarnessHome, withoutHarnessHomeLines } from './harness-home.js';
|
|
27
|
+
import { privateRunTemp } from './run-temp.js';
|
|
28
|
+
// Runs an agent command with the stray-file notice and, around it, the commit identity audit. The audit
|
|
29
|
+
// starts git on the host, so it runs only when the command itself runs unrestricted on the host; a
|
|
30
|
+
// restricted profile starts nothing it did not approve.
|
|
31
|
+
function auditedCommand(cwd, commandText, launchPolicy, run) {
|
|
32
|
+
return withIdentityAudit(cwd, commandText, () => withStrayFileNotice(cwd, run), () => launchPolicy() === undefined);
|
|
33
|
+
}
|
|
24
34
|
const execFileAsync = promisify(execFile);
|
|
25
|
-
// Edit previews use the executor's own argument normalizer. Construction only defines metadata;
|
|
26
|
-
// previewing never invokes the tool executor.
|
|
27
35
|
registerEditArgumentPreparer(andorraCreateEditTool('.').prepareArguments);
|
|
28
36
|
const excluded = new Set(['.git', 'node_modules', '.andorracode']);
|
|
29
37
|
const MAX_MODEL_OUTPUT = 24_000;
|
|
30
|
-
/** Lines returned by one Read call: both the default and the accepted maximum for `limit`. */
|
|
31
38
|
const READ_MAX_LINES = 2000;
|
|
32
|
-
/** A single line longer than this is truncated, so one minified line cannot fill the window. */
|
|
33
39
|
const READ_MAX_LINE_CHARS = 2000;
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const GREP_FALLBACK_FILE_LIMIT = 20_000;
|
|
41
|
+
const GREP_FALLBACK_BYTE_LIMIT = 256 * 1024 * 1024;
|
|
42
|
+
const GREP_FALLBACK_ENTRY_LIMIT = 200_000;
|
|
43
|
+
const GREP_FALLBACK_TIME_MS = 30_000;
|
|
44
|
+
const GREP_FALLBACK_CHUNK_LINES = 20_000;
|
|
45
|
+
const GREP_FALLBACK_CHUNK_CHARS = 1_000_000;
|
|
46
|
+
const GREP_FALLBACK_TYPES = {
|
|
47
|
+
py: ['.py', '.pyi'], python: ['.py', '.pyi'], js: ['.js', '.jsx', '.mjs', '.cjs'], ts: ['.ts', '.tsx', '.mts', '.cts'],
|
|
48
|
+
rust: ['.rs'], go: ['.go'], java: ['.java'], c: ['.c', '.h'], cpp: ['.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx', '.h'],
|
|
49
|
+
cs: ['.cs'], rb: ['.rb'], ruby: ['.rb'], php: ['.php'], swift: ['.swift'], kotlin: ['.kt', '.kts'], sh: ['.sh', '.bash', '.zsh'],
|
|
50
|
+
md: ['.md', '.markdown'], json: ['.json'], yaml: ['.yaml', '.yml'], toml: ['.toml'], html: ['.html', '.htm'], css: ['.css', '.scss', '.less'],
|
|
51
|
+
txt: ['.txt'], rst: ['.rst'], cfg: ['.cfg', '.ini'], sql: ['.sql'], xml: ['.xml'],
|
|
52
|
+
};
|
|
43
53
|
export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
|
|
44
54
|
export const SHELL_MAX_TIMEOUT_MS = 600_000;
|
|
45
|
-
/**
|
|
46
|
-
* What a timed-out command's error tells the model to do next.
|
|
47
|
-
*
|
|
48
|
-
* The bare "timed out after N ms" says the command was stopped but not that the work is lost, nor
|
|
49
|
-
* which of the two ways forward fits: a longer timeout while one is left to ask for, or a
|
|
50
|
-
* background job once the ceiling is reached.
|
|
51
|
-
*/
|
|
52
55
|
export function shellTimeoutGuidance(message, timeout) {
|
|
53
56
|
const marker = /^Shell command timed out after \d+ ms/;
|
|
54
57
|
if (!marker.test(message))
|
|
@@ -73,16 +76,12 @@ async function shellPermission(policy, name, args, context) {
|
|
|
73
76
|
const mode = permissionMode(context);
|
|
74
77
|
let explicitlyApproved = false;
|
|
75
78
|
let escalationAuthorized = false;
|
|
76
|
-
// Plan mode researches read-only: an escalation (host and network access) would be a change no
|
|
77
|
-
// plan has been approved for, so it is refused with the same guidance as a file mutation.
|
|
78
79
|
if (mode === 'plan' && requested === 'require_escalated')
|
|
79
80
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
80
81
|
if (!mode || mode === 'full-access' || requested === 'require_escalated') {
|
|
81
82
|
await policy.authorize(name, { ...args, warning: 'UNSANDBOXED: entire host and network access.' }, {
|
|
82
83
|
...context, approve: async (...approval) => {
|
|
83
84
|
const approved = await context.approve(...approval);
|
|
84
|
-
// A live permission switch settles outstanding prompts with policy-changed. Never
|
|
85
|
-
// allow an old escalation request to be re-approved after the run enters Plan.
|
|
86
85
|
if (requested === 'require_escalated' && permissionMode(context) === 'plan')
|
|
87
86
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
88
87
|
if (approved === true)
|
|
@@ -90,31 +89,18 @@ async function shellPermission(policy, name, args, context) {
|
|
|
90
89
|
return approved;
|
|
91
90
|
},
|
|
92
91
|
});
|
|
93
|
-
// Authorization may have awaited other hooks while the run switched modes.
|
|
94
92
|
if (requested === 'require_escalated' && permissionMode(context) === 'plan')
|
|
95
93
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
96
94
|
escalationAuthorized = requested === 'require_escalated';
|
|
97
95
|
}
|
|
98
|
-
// Evaluate synchronously at spawn, after filesystem/launcher discovery awaits.
|
|
99
|
-
// Only a real per-call user grant can preserve unsandboxed execution when a
|
|
100
|
-
// previously automatic Full Access grant has since been revoked.
|
|
101
96
|
return () => {
|
|
102
97
|
const live = permissionMode(context);
|
|
103
|
-
// Spawn-time recheck is essential: even a previously granted escalation cannot
|
|
104
|
-
// escape the read-only boundary if the run switched into Plan in the meantime.
|
|
105
98
|
if (requested === 'require_escalated' && live === 'plan')
|
|
106
99
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
107
100
|
if (explicitlyApproved)
|
|
108
101
|
return undefined;
|
|
109
|
-
// An escalation this call's own authorization granted is an audited host grant: a shell is never a
|
|
110
|
-
// workspace-policy mutation, so without an explicit answer the journaled decision was Full Access
|
|
111
|
-
// policy — typically the user switching the run to Full Access while this prompt was open. It holds
|
|
112
|
-
// while Full Access is still in force at spawn; a revocation since then falls through below.
|
|
113
102
|
if (escalationAuthorized && live === 'full-access')
|
|
114
103
|
return undefined;
|
|
115
|
-
// A later Full Access selection cannot create an unaudited host grant.
|
|
116
|
-
// Keep an initially restricted call restricted; a subsequent call can
|
|
117
|
-
// acquire Full Access through authorize and its journal events.
|
|
118
104
|
if (mode && mode !== 'full-access' && live === 'full-access')
|
|
119
105
|
return mode === 'read-only' || mode === 'plan' ? 'read-only' : 'workspace-write';
|
|
120
106
|
if (!live || live === 'full-access')
|
|
@@ -177,13 +163,6 @@ const boolArg = (args, key) => {
|
|
|
177
163
|
throw new Error(`${key} must be a boolean`);
|
|
178
164
|
return value;
|
|
179
165
|
};
|
|
180
|
-
/**
|
|
181
|
-
* Key for the per-context file-read state.
|
|
182
|
-
*
|
|
183
|
-
* Exported so other producers of the same state (the CodeGraph complete-source seed) store
|
|
184
|
-
* entries under the key the canonical tools look up. It must be applied to a path normalized
|
|
185
|
-
* the same way the policy's safePath normalizes it, or the entries never match.
|
|
186
|
-
*/
|
|
187
166
|
export { stateKey };
|
|
188
167
|
function state(context) {
|
|
189
168
|
context.toolState ??= { fileReads: new Map() };
|
|
@@ -201,9 +180,6 @@ async function remember(context, resolved, content, complete, source) {
|
|
|
201
180
|
async function rememberReadRange(context, resolved, content, start, end, lineCount) {
|
|
202
181
|
const key = stateKey(resolved);
|
|
203
182
|
const prior = state(context).fileReads.get(key);
|
|
204
|
-
// Successful mutations and complete CodeGraph source are also full snapshots.
|
|
205
|
-
// A narrow Read of identical content must not revoke their existing coverage.
|
|
206
|
-
// Changed bytes invalidate all prior ranges, regardless of snapshot origin.
|
|
207
183
|
const ranges = prior && matchesFileRead(prior, content) ? (prior.complete ? [{ start: 1, end: lineCount }] : [...(prior.ranges ?? [])]) : [];
|
|
208
184
|
if (lineCount === 0) {
|
|
209
185
|
await remember(context, resolved, content, true, 'Read');
|
|
@@ -230,7 +206,6 @@ async function rememberReadRange(context, resolved, content, start, end, lineCou
|
|
|
230
206
|
source: 'Read',
|
|
231
207
|
});
|
|
232
208
|
}
|
|
233
|
-
/** First unread stretch of the file, for a partial observation. */
|
|
234
209
|
function firstUnreadRange(previous) {
|
|
235
210
|
if (previous.complete)
|
|
236
211
|
return undefined;
|
|
@@ -248,12 +223,7 @@ function firstUnreadRange(previous) {
|
|
|
248
223
|
async function requireFreshRead(policy, context, resolved, action) {
|
|
249
224
|
const previous = state(context).fileReads.get(stateKey(resolved));
|
|
250
225
|
if (!previous?.complete) {
|
|
251
|
-
// A suggested offset is only meaningful for the content the model last saw. Re-read first so
|
|
252
|
-
// a file that changed (or shrank) since that page cannot send the model past its end.
|
|
253
226
|
if (!previous) {
|
|
254
|
-
// A file the text tools cannot hold (a document, an image, text in another encoding) can be
|
|
255
|
-
// looked at with Read but never becomes a recorded read, so "Read it first" would send the
|
|
256
|
-
// model round in a circle. The strict reader's own refusal is the true answer for those.
|
|
257
227
|
await policy.read(context, resolved);
|
|
258
228
|
throw new FileReadRequiredError(`${action} requires a complete Read (or complete CodeGraph source) of the existing file first. Read ${path.relative(context.workspace, resolved) || resolved} before modifying it.`);
|
|
259
229
|
}
|
|
@@ -271,7 +241,6 @@ async function requireFreshRead(policy, context, resolved, action) {
|
|
|
271
241
|
throw new FileReadRequiredError(`${action} refused a stale file: it changed since the last Read/CodeGraph snapshot. Read it again before modifying.`);
|
|
272
242
|
return current;
|
|
273
243
|
}
|
|
274
|
-
/** A replacement whose old text the current file does not hold exactly as the call needs. */
|
|
275
244
|
class EditMatchError extends Error {
|
|
276
245
|
summary;
|
|
277
246
|
constructor(message, summary) {
|
|
@@ -280,15 +249,7 @@ class EditMatchError extends Error {
|
|
|
280
249
|
this.name = 'EditMatchError';
|
|
281
250
|
}
|
|
282
251
|
}
|
|
283
|
-
/** The runtime prefixes a failed call's message with this before clipping it at MAX_MODEL_OUTPUT. */
|
|
284
252
|
const TOOL_ERROR_PREFIX = 'Tool error: ';
|
|
285
|
-
/**
|
|
286
|
-
* A failure message that carries the whole file, or undefined when it cannot.
|
|
287
|
-
*
|
|
288
|
-
* Stricter than Read: a clipped line, a second page, or a message the runtime would clip leaves
|
|
289
|
-
* text the model has not seen, and the caller records the file as completely read on the strength
|
|
290
|
-
* of this message. The budget is measured on the complete message, not the file alone.
|
|
291
|
-
*/
|
|
292
253
|
function messageWithWholeFile(explanation, content) {
|
|
293
254
|
const lines = content.split('\n');
|
|
294
255
|
if (content.endsWith('\n') || content === '')
|
|
@@ -299,7 +260,6 @@ function messageWithWholeFile(explanation, content) {
|
|
|
299
260
|
const message = `${explanation}\n${page}`;
|
|
300
261
|
return TOOL_ERROR_PREFIX.length + message.length <= MAX_MODEL_OUTPUT ? message : undefined;
|
|
301
262
|
}
|
|
302
|
-
/** The old texts an Edit call names, or undefined when the call is not a well-formed edit. */
|
|
303
263
|
function editOldTexts(args) {
|
|
304
264
|
if (args.edits === undefined)
|
|
305
265
|
return typeof args.old_string === 'string' && args.old_string ? [args.old_string] : undefined;
|
|
@@ -328,14 +288,6 @@ function editOldTexts(args) {
|
|
|
328
288
|
}
|
|
329
289
|
return texts;
|
|
330
290
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Why an Edit's old text is not literally in the file, or undefined when every one is.
|
|
333
|
-
*
|
|
334
|
-
* The edit matcher also accepts near matches (Unicode and whitespace normalization). That is safe
|
|
335
|
-
* for a file the model has read, and is exactly what must not stand in for the read: only a
|
|
336
|
-
* literal occurrence shows the model knows the text it is replacing. Line endings are the one
|
|
337
|
-
* difference allowed, because models write LF for files stored with CRLF.
|
|
338
|
-
*/
|
|
339
291
|
function unseenEditMismatch(args, content) {
|
|
340
292
|
const texts = editOldTexts(args);
|
|
341
293
|
if (!texts)
|
|
@@ -352,20 +304,6 @@ function unseenEditMismatch(args, content) {
|
|
|
352
304
|
}
|
|
353
305
|
return undefined;
|
|
354
306
|
}
|
|
355
|
-
/**
|
|
356
|
-
* Edit without the separate Read the gate would otherwise ask the model for.
|
|
357
|
-
*
|
|
358
|
-
* The gate exists so a mutation never rests on text the model did not see. For an Edit, old_string
|
|
359
|
-
* occurring literally in the current file is that evidence, so a file that was never (or only
|
|
360
|
-
* partly) Read is read here: a literal match applies the edit, and a miss returns the file in the
|
|
361
|
-
* failure so the next call is the corrected Edit. Either way the model does not spend a call on
|
|
362
|
-
* Read and another on resending the same Edit. A file that changed since the model last saw it is
|
|
363
|
-
* still refused, with its current content when one message holds it. Write keeps the plain gate:
|
|
364
|
-
* a full overwrite carries no evidence that the model knows what it replaces.
|
|
365
|
-
*
|
|
366
|
-
* The file counts as Read only when the edit applied or its whole content was returned; every
|
|
367
|
-
* other outcome leaves or puts back the previous read state.
|
|
368
|
-
*/
|
|
369
307
|
async function editWithoutPriorRead(policy, args, context, execute) {
|
|
370
308
|
const filePath = args.file_path;
|
|
371
309
|
if (typeof filePath !== 'string' || !filePath || filePath.includes('\0'))
|
|
@@ -374,7 +312,6 @@ async function editWithoutPriorRead(policy, args, context, execute) {
|
|
|
374
312
|
const reads = state(context).fileReads, key = stateKey(resolved);
|
|
375
313
|
const previous = reads.get(key);
|
|
376
314
|
let content;
|
|
377
|
-
// A missing, binary or oversized target is the tool's own error to report.
|
|
378
315
|
try {
|
|
379
316
|
content = await policy.read(context, resolved);
|
|
380
317
|
}
|
|
@@ -391,14 +328,12 @@ async function editWithoutPriorRead(policy, args, context, execute) {
|
|
|
391
328
|
}
|
|
392
329
|
if (previous?.complete)
|
|
393
330
|
return execute(args, context);
|
|
394
|
-
// Not a well-formed edit: the gate refuses it as it always has.
|
|
395
331
|
if (!editOldTexts(args))
|
|
396
332
|
return execute(args, context);
|
|
397
333
|
const restore = () => { if (previous)
|
|
398
334
|
reads.set(key, previous);
|
|
399
335
|
else
|
|
400
336
|
reads.delete(key); };
|
|
401
|
-
/** The edit cannot apply: hand the model the file, or the paged-read refusal when it is too long. */
|
|
402
337
|
const missed = async (summary) => {
|
|
403
338
|
const message = messageWithWholeFile(`${summary}\nFile unchanged; no replacements were applied. ${name} had not been completely Read, so it was read for this call: it is shown in full below and now counts as Read. Copy old_string from it and retry; no separate Read is needed.`, content);
|
|
404
339
|
if (message !== undefined) {
|
|
@@ -492,13 +427,9 @@ export function createCodingTools(policy) {
|
|
|
492
427
|
const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
|
|
493
428
|
const pages = stringArg(args, 'pages', true), render = boolArg(args, 'render') ?? false;
|
|
494
429
|
const resolved = await policy.safePath(context, filePath);
|
|
495
|
-
// An image is recognized by its signature and shown as pixels. It is not recorded as a
|
|
496
|
-
// text read: Write and Edit cannot faithfully rewrite a file they only saw as a picture.
|
|
497
430
|
const image = await policy.readImage?.(context, resolved);
|
|
498
431
|
if (image)
|
|
499
432
|
return readImageObservation(context, filePath, image);
|
|
500
|
-
// A PDF or Word file is likewise recognized by its leading bytes and returned as what it
|
|
501
|
-
// says: its text, or for a PDF its pages as images. Neither is recorded as a text read.
|
|
502
433
|
const documentOptions = { offset, limit, ...(pages === undefined ? {} : { pages }), render, maxOutput: MAX_MODEL_OUTPUT, maxLineChars: READ_MAX_LINE_CHARS };
|
|
503
434
|
const documentBytes = await policy.readDocument?.(context, resolved);
|
|
504
435
|
if (documentBytes) {
|
|
@@ -511,8 +442,6 @@ export function createCodingTools(policy) {
|
|
|
511
442
|
content = await policy.read(context, resolved);
|
|
512
443
|
}
|
|
513
444
|
catch (error) {
|
|
514
|
-
// Text in an older encoding (UTF-16, Windows-1252) fails the strict UTF-8 reader that
|
|
515
|
-
// Edit depends on. It is still text a model can read, so it is shown decoded, read-only.
|
|
516
445
|
if (!(error instanceof Error) || !/not valid UTF-8|Binary files are not supported/.test(error.message))
|
|
517
446
|
throw error;
|
|
518
447
|
const decoded = await policy.readLegacyText?.(context, resolved);
|
|
@@ -533,9 +462,6 @@ export function createCodingTools(policy) {
|
|
|
533
462
|
if (first > lines.length)
|
|
534
463
|
throw new Error(`Offset ${first} is beyond end of file (${lines.length} lines total)`);
|
|
535
464
|
const lastRequested = Math.min(lines.length, first + limit - 1);
|
|
536
|
-
// The runtime clips every tool result at MAX_MODEL_OUTPUT before the model sees it, so a
|
|
537
|
-
// page that overflows would lose its tail and the continuation footer while still being
|
|
538
|
-
// recorded as read. Stop on the last whole line that fits, and record only that line.
|
|
539
465
|
const budget = MAX_MODEL_OUTPUT - 200;
|
|
540
466
|
let rendered = '';
|
|
541
467
|
let emittedLast = first - 1;
|
|
@@ -549,7 +475,6 @@ export function createCodingTools(policy) {
|
|
|
549
475
|
emittedLast = line;
|
|
550
476
|
}
|
|
551
477
|
if (emittedLast < first) {
|
|
552
|
-
// A truncated line always fits this budget, so this is a defensive guard, not a path.
|
|
553
478
|
rendered = `${first}\t${(lines[first - 1] ?? '').slice(0, READ_MAX_LINE_CHARS)}`;
|
|
554
479
|
emittedLast = first;
|
|
555
480
|
}
|
|
@@ -610,10 +535,6 @@ export function createCodingTools(policy) {
|
|
|
610
535
|
await remember(context, resolved, updated, true, 'mutation');
|
|
611
536
|
return `Replaced ${count} occurrence(s) in ${path.relative(context.workspace, resolved) || resolved}. File state is current; no Read-back is needed.`;
|
|
612
537
|
}
|
|
613
|
-
// Models sometimes send `edits` as a JSON string, or a single edit object where the
|
|
614
|
-
// contract asks for a one-element array, so coerce before validating. The engine edit
|
|
615
|
-
// adapter tolerated both; dropping the tolerance would turn recoverable calls into
|
|
616
|
-
// hard failures on a path that previously worked.
|
|
617
538
|
const coerceEdits = (value) => {
|
|
618
539
|
let parsed = value;
|
|
619
540
|
if (typeof parsed === 'string') {
|
|
@@ -672,8 +593,6 @@ export function createCodingTools(policy) {
|
|
|
672
593
|
catch (error) {
|
|
673
594
|
if (!(error instanceof Error) || !/Could not find|Found \d+ occurrences|overlap/i.test(error.message))
|
|
674
595
|
throw error;
|
|
675
|
-
// Matcher failures occur before the native atomic write. Do not imply
|
|
676
|
-
// partial batch progress, or echo the entire generated patch as feedback.
|
|
677
596
|
const failedIndex = Number(error.message.match(/edits\[(\d+)\]/)?.[1] ?? 0);
|
|
678
597
|
const failed = edits[failedIndex];
|
|
679
598
|
const lines = before.split(/\r?\n/);
|
|
@@ -689,8 +608,6 @@ export function createCodingTools(policy) {
|
|
|
689
608
|
const upstream = result.content.filter(part => part.type === 'text').map(part => part.text).join('\n');
|
|
690
609
|
return nativeObservation(upstream || `Successfully replaced ${edits.length} block(s) in ${path.relative(context.workspace, resolved) || resolved}. File state is current; no Read-back is needed.`);
|
|
691
610
|
});
|
|
692
|
-
// Advertise the focused single replacement contract. Older saved calls
|
|
693
|
-
// retain batch compatibility, validated separately after normalization.
|
|
694
611
|
const editSeenFile = Edit.execute;
|
|
695
612
|
Edit.execute = (args, context) => editWithoutPriorRead(policy, args, context, editSeenFile);
|
|
696
613
|
Edit.validationParameters = Edit.parameters;
|
|
@@ -742,7 +659,7 @@ export function createCodingTools(policy) {
|
|
|
742
659
|
const result = await current.execute(randomUUID(), { pattern, path: resolved, limit }, context.signal);
|
|
743
660
|
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'));
|
|
744
661
|
});
|
|
745
|
-
const Grep = zTool('Grep', 'Search file contents with file-name, count or content results.
|
|
662
|
+
const Grep = zTool('Grep', 'Search file contents with file-name, count or content results. Uses ripgrep when it is installed. Without it, and in restricted modes, a built-in search runs instead: JavaScript single-line regular expressions, glob and common type filters, context lines and offsets; multiline and only-matching need ripgrep. A result that could not cover every file starts with INCOMPLETE SEARCH and is never a plain "No matches": narrow path or glob and search again.', { type: 'object', properties: {
|
|
746
663
|
pattern: { type: 'string', description: 'Regular expression to search for' },
|
|
747
664
|
path: { type: 'string', description: 'File or directory inside the workspace; defaults to .' },
|
|
748
665
|
glob: { type: 'string', description: 'Optional glob filter such as *.{ts,tsx}' },
|
|
@@ -774,85 +691,136 @@ export function createCodingTools(policy) {
|
|
|
774
691
|
const limit = requestedLimit === 0 ? 2000 : requestedLimit ?? 250;
|
|
775
692
|
const offset = intArg(args, 'offset', { min: 0, max: 100000 }) ?? 0;
|
|
776
693
|
const resolved = await policy.safePath(context, searchPath);
|
|
777
|
-
// Resolving rg probes PATH by executing it. Restricted searches must never
|
|
778
|
-
// enter that resolver (or a vendor helper that downloads/spawns binaries).
|
|
779
694
|
const restricted = context.pinFilePaths || (permissionMode(context) !== undefined && permissionMode(context) !== 'full-access');
|
|
780
695
|
const rg = restricted ? null : andorraGetToolPath('rg');
|
|
781
696
|
if (!rg) {
|
|
782
|
-
if (
|
|
697
|
+
if (multiline || only)
|
|
783
698
|
throw new Error(restricted
|
|
784
699
|
? 'This Grep option requires ripgrep, which is unavailable to restricted searches. Use glob and a single-line pattern instead.'
|
|
785
|
-
: 'This Grep
|
|
786
|
-
|
|
700
|
+
: 'This Grep option (multiline or -o) requires ripgrep (rg), which is not available. Use a single-line pattern in content mode; glob, type, context lines, -i, head_limit and offset all work without ripgrep.');
|
|
701
|
+
const typeExtensions = type === undefined ? undefined : GREP_FALLBACK_TYPES[type.toLowerCase()];
|
|
702
|
+
if (type !== undefined && !typeExtensions)
|
|
703
|
+
throw new Error(`Grep type "${clipText(type, 40)}" needs ripgrep (rg), which is not available. Without ripgrep, type supports: ${Object.keys(GREP_FALLBACK_TYPES).join(', ')}. Use glob for anything else, for example glob "*.${clipText(type, 20)}".`);
|
|
704
|
+
return withGrepRegex(pattern, (ignoreCase ? 'i' : '') + (mode === 'count' ? 'g' : ''), context.signal, async (scan, searchSignal, progress) => {
|
|
787
705
|
const searchContext = { ...context, signal: searchSignal };
|
|
788
706
|
const info = await stat(resolved);
|
|
789
707
|
searchSignal.throwIfAborted();
|
|
790
|
-
const candidates = [];
|
|
791
|
-
if (info.isFile())
|
|
792
|
-
candidates.push(resolved);
|
|
793
|
-
else
|
|
794
|
-
for await (const candidate of policy.files(searchContext, resolved)) {
|
|
795
|
-
searchSignal.throwIfAborted();
|
|
796
|
-
candidates.push(candidate);
|
|
797
|
-
}
|
|
798
708
|
const rows = [];
|
|
799
|
-
let scannedFiles = 0, scannedBytes = 0;
|
|
800
|
-
let
|
|
709
|
+
let scannedFiles = 0, scannedBytes = 0, unreadable = 0;
|
|
710
|
+
let incomplete, moreRows = false;
|
|
711
|
+
const oversized = [];
|
|
712
|
+
const deadline = Date.now() + GREP_FALLBACK_TIME_MS;
|
|
713
|
+
const scanned = () => `${scannedFiles.toLocaleString('en-US')} file${scannedFiles === 1 ? '' : 's'} scanned`;
|
|
801
714
|
const contextBefore = around ?? before ?? 0, contextAfter = around ?? after ?? 0;
|
|
802
|
-
|
|
803
|
-
searchSignal.throwIfAborted();
|
|
715
|
+
const searchFile = async (candidate) => {
|
|
804
716
|
const relative = path.relative(resolved, candidate).split(path.sep).join('/') || path.basename(candidate);
|
|
805
717
|
if (glob && !path.matchesGlob(relative, glob) && !path.matchesGlob(path.basename(relative), glob))
|
|
806
|
-
|
|
807
|
-
if (
|
|
808
|
-
|
|
809
|
-
|
|
718
|
+
return true;
|
|
719
|
+
if (typeExtensions && !typeExtensions.some(extension => relative.toLowerCase().endsWith(extension)))
|
|
720
|
+
return true;
|
|
721
|
+
if (scannedFiles >= GREP_FALLBACK_FILE_LIMIT) {
|
|
722
|
+
incomplete = `stopped at the ${GREP_FALLBACK_FILE_LIMIT.toLocaleString('en-US')}-file scan limit`;
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
if (Date.now() > deadline) {
|
|
726
|
+
incomplete = `stopped after ${GREP_FALLBACK_TIME_MS / 1000} seconds with ${scanned()}`;
|
|
727
|
+
return false;
|
|
810
728
|
}
|
|
811
729
|
let source;
|
|
812
730
|
try {
|
|
813
|
-
// Discovery is not a snapshot: builds/cleanup can remove or revoke a
|
|
814
|
-
// candidate before either stat or read. Skip it just like a failed read.
|
|
815
731
|
const candidateInfo = await stat(candidate);
|
|
816
732
|
searchSignal.throwIfAborted();
|
|
817
|
-
if (candidateInfo.size >
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
733
|
+
if (candidateInfo.size > policy.fileLimit) {
|
|
734
|
+
oversized.push(relative);
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
if (scannedBytes + candidateInfo.size > GREP_FALLBACK_BYTE_LIMIT) {
|
|
738
|
+
incomplete = `stopped at the ${GREP_FALLBACK_BYTE_LIMIT / (1024 * 1024)} MiB scan limit with ${scanned()}`;
|
|
739
|
+
return false;
|
|
822
740
|
}
|
|
823
741
|
source = await policy.read(searchContext, candidate);
|
|
742
|
+
scannedBytes += candidateInfo.size;
|
|
824
743
|
}
|
|
825
|
-
catch {
|
|
744
|
+
catch (error) {
|
|
826
745
|
searchSignal.throwIfAborted();
|
|
827
|
-
|
|
746
|
+
if (!(error instanceof Error) || !/Binary files are not supported|not valid UTF-8/.test(error.message))
|
|
747
|
+
unreadable++;
|
|
748
|
+
return true;
|
|
828
749
|
}
|
|
829
750
|
searchSignal.throwIfAborted();
|
|
751
|
+
scannedFiles++;
|
|
752
|
+
progress();
|
|
830
753
|
const lines = source.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
831
|
-
let matches = 0;
|
|
832
|
-
for (
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
754
|
+
let matches = 0, settled = false;
|
|
755
|
+
for (let from = 0; from < lines.length && !settled;) {
|
|
756
|
+
let to = from, chars = 0;
|
|
757
|
+
while (to < lines.length && to - from < GREP_FALLBACK_CHUNK_LINES && (to === from || chars + lines[to].length <= GREP_FALLBACK_CHUNK_CHARS))
|
|
758
|
+
chars += lines[to++].length;
|
|
759
|
+
for (const match of await scan(lines.slice(from, to), mode === 'count')) {
|
|
760
|
+
const index = match.index + from;
|
|
761
|
+
matches += match.count;
|
|
762
|
+
if (mode === 'files_with_matches') {
|
|
763
|
+
rows.push(relative);
|
|
764
|
+
settled = true;
|
|
765
|
+
break;
|
|
766
|
+
}
|
|
767
|
+
if (mode === 'count')
|
|
768
|
+
continue;
|
|
769
|
+
if (rows.length >= offset + limit) {
|
|
770
|
+
moreRows = true;
|
|
771
|
+
settled = true;
|
|
772
|
+
break;
|
|
773
|
+
}
|
|
774
|
+
const start = Math.max(0, index - contextBefore), end = Math.min(lines.length - 1, index + contextAfter);
|
|
775
|
+
for (let cursor = start; cursor <= end; cursor++) {
|
|
776
|
+
const marker = cursor === index ? ':' : '-';
|
|
777
|
+
rows.push(lineNumbers ? `${relative}${marker}${cursor + 1}${marker}${clipText(lines[cursor], 800)}` : `${relative}${marker}${clipText(lines[cursor], 800)}`);
|
|
778
|
+
}
|
|
845
779
|
}
|
|
846
|
-
|
|
847
|
-
|
|
780
|
+
from = to;
|
|
781
|
+
progress();
|
|
848
782
|
}
|
|
849
783
|
if (mode === 'count' && matches)
|
|
850
784
|
rows.push(`${relative}:${matches}`);
|
|
851
|
-
|
|
852
|
-
|
|
785
|
+
return true;
|
|
786
|
+
};
|
|
787
|
+
if (info.isFile())
|
|
788
|
+
await searchFile(resolved);
|
|
789
|
+
else {
|
|
790
|
+
try {
|
|
791
|
+
for await (const candidate of policy.files(searchContext, resolved, 0, { entries: 0, limit: GREP_FALLBACK_ENTRY_LIMIT })) {
|
|
792
|
+
searchSignal.throwIfAborted();
|
|
793
|
+
progress();
|
|
794
|
+
if (rows.length >= offset + limit) {
|
|
795
|
+
moreRows = true;
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
if (!await searchFile(candidate))
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
catch (error) {
|
|
803
|
+
searchSignal.throwIfAborted();
|
|
804
|
+
if (!(error instanceof Error) || !/^Directory scan limit reached/.test(error.message))
|
|
805
|
+
throw error;
|
|
806
|
+
incomplete = `stopped at the ${GREP_FALLBACK_ENTRY_LIMIT.toLocaleString('en-US')}-entry directory scan limit with ${scanned()}`;
|
|
807
|
+
}
|
|
853
808
|
}
|
|
854
809
|
const selected = rows.slice(offset, offset + limit);
|
|
855
|
-
|
|
810
|
+
const more = moreRows || rows.length > offset + limit;
|
|
811
|
+
const narrow = `Narrow the search with path (a subdirectory or one file) or glob (for example "*.py")${restricted ? '' : `, or run ${process.platform === 'win32' ? 'Select-String' : 'grep -rn'} through the shell`}.`;
|
|
812
|
+
const notices = [];
|
|
813
|
+
if (incomplete)
|
|
814
|
+
notices.push(`[INCOMPLETE SEARCH: ${incomplete}. Files that were not scanned may contain matches, so this result does not show that the pattern is absent. ${narrow}]`);
|
|
815
|
+
if (oversized.length)
|
|
816
|
+
notices.push(`[Not searched, larger than ${policy.fileLimit / (1024 * 1024)} MiB: ${oversized.slice(0, 5).join(', ')}${oversized.length > 5 ? `, and ${oversized.length - 5} more` : ''}.]`);
|
|
817
|
+
if (unreadable)
|
|
818
|
+
notices.push(`[${unreadable} file${unreadable === 1 ? '' : 's'} could not be read and ${unreadable === 1 ? 'was' : 'were'} skipped.]`);
|
|
819
|
+
const body = selected.length ? selected.join('\n')
|
|
820
|
+
: incomplete ? 'No matches in the files scanned before the search stopped.'
|
|
821
|
+
: offset && rows.length ? `No matches at offset ${offset}; ${rows.length} precede it.` : 'No matches';
|
|
822
|
+
const meta = `[Grep ${mode} fallback: ${selected.length} returned${offset ? `, offset ${offset}` : ''}${more ? `, more may be available: raise head_limit or continue with offset ${offset + selected.length}` : ''}; ${scanned()}${incomplete ? ', INCOMPLETE' : ''}; ${restricted ? 'native restricted search' : 'ripgrep unavailable'}]`;
|
|
823
|
+
return nativeObservation([...notices, body, meta].join('\n'));
|
|
856
824
|
});
|
|
857
825
|
}
|
|
858
826
|
const cwd = await policy.safePath(context, '.');
|
|
@@ -899,7 +867,9 @@ export function createCodingTools(policy) {
|
|
|
899
867
|
else
|
|
900
868
|
throw new Error(`Grep failed: ${String(failure.stderr ?? failure.message).trim().slice(0, 1000)}`);
|
|
901
869
|
}
|
|
902
|
-
|
|
870
|
+
let all = stdout.split(/\r?\n/).filter(Boolean);
|
|
871
|
+
if (guardsHarnessHome(context))
|
|
872
|
+
all = withoutHarnessHomeLines(all, cwd);
|
|
903
873
|
const selected = all.slice(offset, offset + limit).map(line => line.length > 800 ? clipText(line, 800) + ' [line clipped]' : line);
|
|
904
874
|
const truncated = offset + selected.length < all.length || stdout.length > 24_000;
|
|
905
875
|
const body = selected.join('\n') || 'No matches';
|
|
@@ -911,7 +881,7 @@ export function createCodingTools(policy) {
|
|
|
911
881
|
const syntax = kind === 'powershell'
|
|
912
882
|
? 'PowerShell syntax; use & before a quoted executable path. No cmd.exe substitution. Do not pipe a running child into Select-Object -First: it terminates the pipeline before the child completes and can cause exit 4294967295. Host output is already tail-bounded; use Select-Object -Last if further filtering is needed. Prefer file-written scripts over nested quoting for multiline Python/JavaScript. Prefer direct invocation (& $exe @args) for child processes: Windows PowerShell Start-Process -ArgumentList flattens arrays and can split a multi-word argument unless it is quoted manually. Windows PowerShell also alters what it hands a native program: piping a string into one (ssh, wsl, bash -s, docker exec) appends CRLF after the last line, so a remote shell runs that line with a stray \r, and double quotes inside a native argument are dropped. Windows PowerShell binds the content of Set-Content or Add-Content as the file name when a switch such as -NoNewline comes before a positional path: name -Path and -Value, or use Write. Send a multi-line script to a remote or POSIX shell as base64 instead: $b = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($script -replace "`r", "") + "`n")); & ssh host "echo $b | base64 -d | bash".'
|
|
913
883
|
: 'Bash syntax (Git Bash on Windows).';
|
|
914
|
-
const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}
|
|
884
|
+
const tool = zTool(name, `Execute a foreground ${actual} command in the workspace. The working directory is the workspace; ${syntax} Output is tail-bounded. Commands follow the current workspace permissions. Restricted modes use the Codex OS sandbox and block network/outside writes; explicit escalation requires justification and approval. Credential environment variables are excluded; credential files remain accessible. This uses the compact command/timeout/description contract while retaining Pi/Andorra process-tree cleanup. Background execution is not exposed${kind === 'powershell' ? '' : ': a command that leaves a job running (cmd &) waits for that job, and the timeout then stops it'}. Start long-running work with AsyncProcess instead${PERSISTENT_JOBS_SUPPORTED ? ', with persist: true for a service the user needs left running after you finish' : ''}.${privateRunTemp() ? ` Put scratch files in ${kind === 'powershell' ? '$env:TEMP' : '"$TMPDIR"'}, a private directory that is removed when the run ends, not in the shared system temporary directory.` : ''}`, { type: 'object', properties: {
|
|
915
885
|
command: { type: 'string', description: 'Command to execute' },
|
|
916
886
|
timeout: { type: 'integer', minimum: 1, maximum: SHELL_MAX_TIMEOUT_MS, description: `Timeout in milliseconds; default ${SHELL_DEFAULT_TIMEOUT_MS}, at most ${SHELL_MAX_TIMEOUT_MS}. Set it for a build, install, download or test run you expect to take longer than the default` },
|
|
917
887
|
description: { type: 'string', description: 'Short active-voice description of what the command does' },
|
|
@@ -922,16 +892,12 @@ export function createCodingTools(policy) {
|
|
|
922
892
|
const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max: SHELL_MAX_TIMEOUT_MS }) ?? SHELL_DEFAULT_TIMEOUT_MS;
|
|
923
893
|
if (args.description !== undefined)
|
|
924
894
|
stringArg(args, 'description', true);
|
|
925
|
-
// Before any approval is asked for: no permission mode, full access included, makes ending
|
|
926
|
-
// the app that hosts this run a thing to approve. Read by the rules of the shell that runs it.
|
|
927
895
|
assertNotHostKill(command, hostShellOf(kind));
|
|
896
|
+
assertNotGitIdentityOverride(command);
|
|
897
|
+
assertCommandAvoidsHarnessHome(command, context);
|
|
928
898
|
const launchPolicy = await shellPermission(policy, name, args, context);
|
|
929
899
|
const cwd = await policy.safePath(context, '.');
|
|
930
900
|
const operations = { exec: async (value, directory, options) => {
|
|
931
|
-
// The same chunks that feed the vendored tool's accumulator also feed the live transcript:
|
|
932
|
-
// a reader who expands the running call sees the command's output as it prints. The
|
|
933
|
-
// decoder keeps a chunk boundary from splitting a multi-byte character on the way
|
|
934
|
-
// through; the observation the tool builds remains the authoritative text.
|
|
935
901
|
const decoder = new StringDecoder('utf8');
|
|
936
902
|
const report = options.onData;
|
|
937
903
|
const onData = (data) => {
|
|
@@ -958,7 +924,7 @@ export function createCodingTools(policy) {
|
|
|
958
924
|
const current = kind === 'powershell'
|
|
959
925
|
? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
|
|
960
926
|
: andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
|
|
961
|
-
return
|
|
927
|
+
return auditedCommand(cwd, command, launchPolicy, async () => {
|
|
962
928
|
try {
|
|
963
929
|
const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
|
|
964
930
|
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
|
|
@@ -966,6 +932,9 @@ export function createCodingTools(policy) {
|
|
|
966
932
|
catch (error) {
|
|
967
933
|
if (!(error instanceof Error))
|
|
968
934
|
throw error;
|
|
935
|
+
const exited = /(?:^|\n\n)Command exited with code (\d+)$/.exec(error.message);
|
|
936
|
+
if (exited)
|
|
937
|
+
throw new CommandExitError(nativeObservation(error.message, true), Number(exited[1]));
|
|
969
938
|
const message = shellTimeoutGuidance(error.message, timeout);
|
|
970
939
|
if (message.length > MAX_MODEL_OUTPUT)
|
|
971
940
|
throw new Error(nativeObservation(message, true));
|
|
@@ -975,20 +944,14 @@ export function createCodingTools(policy) {
|
|
|
975
944
|
}
|
|
976
945
|
});
|
|
977
946
|
});
|
|
978
|
-
// The vendored shell throws on any exit other than 0, so a return is a clean exit.
|
|
979
947
|
return { ...tool, exitZeroOnReturn: true };
|
|
980
948
|
};
|
|
981
|
-
// Keep imported Pi spellings executable for old tests/configuration, but never
|
|
982
|
-
// advertise them to providers. capabilityTools maps legacy graph allowlists to
|
|
983
|
-
// the canonical surface above.
|
|
984
949
|
const definitions = [andorraCreateReadTool('.'), andorraCreateWriteTool('.'), andorraCreateEditTool('.'), andorraCreateLsTool('.'), andorraCreateFindTool('.'), andorraCreateGrepTool('.')];
|
|
985
950
|
const legacyNative = definitions.map(definition => ({
|
|
986
951
|
name: definition.name,
|
|
987
952
|
providerVisible: false,
|
|
988
953
|
prepareArguments: definition.prepareArguments,
|
|
989
954
|
executionMode: definition.name === 'write' || definition.name === 'edit' ? 'sequential' : 'parallel',
|
|
990
|
-
// Preserve the Andorra wording over the imported Pi descriptions: the read tool must
|
|
991
|
-
// not advertise image attachments, and traversal/limits are workspace-bounded.
|
|
992
955
|
description: `${(definition.name === 'read' ? 'Read UTF-8 text files. Binary files and image attachments are unsupported. Output is bounded; use offset (1-based line number) and limit to read specific portions of large files.' : definition.description).replace('Respects .gitignore.', definition.name === 'find' ? 'Uses a bounded workspace traversal (1,000 results, depth 20).' : 'Respects .gitignore.')} Workspace-only; .git, node_modules and .andorracode are excluded from directory traversal. Text reads/writes have an 8 MiB file limit; observations remain bounded.`,
|
|
993
956
|
parameters: definition.parameters,
|
|
994
957
|
execute: async (args, context) => {
|
|
@@ -1023,7 +986,6 @@ export function createCodingTools(policy) {
|
|
|
1023
986
|
const actual = kind === 'powershell' ? 'PowerShell (PowerShell syntax)' : kind === 'bash' ? 'Bash' : '/bin/sh';
|
|
1024
987
|
return {
|
|
1025
988
|
name, providerVisible: false, executionMode: 'sequential',
|
|
1026
|
-
// 'shell' prints its own `Exit code:` line; the vendored powershell/bash throw on a non-zero exit.
|
|
1027
989
|
exitZeroOnReturn: name !== 'shell',
|
|
1028
990
|
description: `Legacy compatibility shell using ${actual}.`,
|
|
1029
991
|
parameters: { type: 'object', properties: { command: { type: 'string' }, timeout_ms: { type: 'integer', minimum: 1, maximum: 120000 }, ...sandboxFields }, required: ['command'], additionalProperties: false },
|
|
@@ -1036,13 +998,13 @@ export function createCodingTools(policy) {
|
|
|
1036
998
|
if (typeof timeout !== 'number' || !Number.isInteger(timeout) || timeout < 1 || timeout > 120000)
|
|
1037
999
|
throw new Error('timeout_ms must be an integer from 1 to 120000');
|
|
1038
1000
|
assertNotHostKill(args.command, hostShellOf(kind));
|
|
1001
|
+
assertNotGitIdentityOverride(args.command);
|
|
1002
|
+
assertCommandAvoidsHarnessHome(args.command, context);
|
|
1039
1003
|
const launchPolicy = await shellPermission(policy, name, args, context);
|
|
1040
1004
|
const cwd = await policy.safePath(context, '.');
|
|
1041
|
-
// Preserve the legacy observation formats: 'shell' keeps the runShell observation,
|
|
1042
|
-
// while explicit 'powershell'/'bash' use native tail truncation and errors.
|
|
1043
1005
|
const command = args.command;
|
|
1044
1006
|
if (name === 'shell')
|
|
1045
|
-
return
|
|
1007
|
+
return auditedCommand(cwd, command, launchPolicy, async () => nativeObservation(await runShell(command, cwd, timeout, context.signal, kind, undefined, undefined, launchPolicy), true));
|
|
1046
1008
|
const operations = { exec: async (value, directory, options) => {
|
|
1047
1009
|
try {
|
|
1048
1010
|
await runShell(value, directory, timeout, context.signal, kind, options.onData, undefined, launchPolicy);
|
|
@@ -1059,7 +1021,7 @@ export function createCodingTools(policy) {
|
|
|
1059
1021
|
const current = kind === 'powershell'
|
|
1060
1022
|
? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
|
|
1061
1023
|
: andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
|
|
1062
|
-
return
|
|
1024
|
+
return auditedCommand(cwd, command, launchPolicy, async () => {
|
|
1063
1025
|
try {
|
|
1064
1026
|
const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
|
|
1065
1027
|
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
|
|
@@ -1087,14 +1049,27 @@ export function createCodingTools(policy) {
|
|
|
1087
1049
|
throw new Error('args must be an array of at most 128 strings (4096 chars each, no NUL)');
|
|
1088
1050
|
}
|
|
1089
1051
|
const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
|
|
1090
|
-
// The array is judged as an array: there is no shell here to read an argument as syntax.
|
|
1091
1052
|
assertNotHostKillArgv(program, argv);
|
|
1053
|
+
assertNotGitIdentityOverrideArgv(program, argv);
|
|
1054
|
+
assertCommandAvoidsHarnessHome(argv.join(' '), context);
|
|
1092
1055
|
const launchPolicy = await shellPermission(policy, 'NativeExec', args, context);
|
|
1093
1056
|
const cwd = await policy.safePath(context, '.');
|
|
1094
1057
|
const executable = program === 'node' ? process.execPath : program === 'git' ? 'git' : andorraGetToolPath('rg');
|
|
1095
1058
|
if (!executable)
|
|
1096
|
-
throw new Error(
|
|
1097
|
-
|
|
1059
|
+
throw new Error(program === 'rg'
|
|
1060
|
+
? `ripgrep (rg) is not installed on this machine. Use the Grep tool instead: it searches without ripgrep. ${process.platform === 'win32' ? 'Select-String through PowerShell' : 'grep -rn through Bash'} also works.`
|
|
1061
|
+
: 'Native executable is not installed');
|
|
1062
|
+
return auditedCommand(cwd, [program, ...argv].join(' '), launchPolicy, async () => {
|
|
1063
|
+
try {
|
|
1064
|
+
return nativeObservation(await runNativeProcess(executable, argv, cwd, timeout, context.signal, launchPolicy), true);
|
|
1065
|
+
}
|
|
1066
|
+
catch (error) {
|
|
1067
|
+
const exited = error instanceof Error ? /^Exit code: (\d+)\n/.exec(error.message) : null;
|
|
1068
|
+
if (exited)
|
|
1069
|
+
throw new CommandExitError(nativeObservation(error.message, true), Number(exited[1]));
|
|
1070
|
+
throw error;
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1098
1073
|
});
|
|
1099
1074
|
const AsyncProcess = zTool('AsyncProcess', `Start a shell command in the background and return immediately; inspect status/logs, wait for completion without polling, or stop it. Use for independent builds, test suites, and dev servers so other agent work can continue. Each job has a generated ID. ${PERSISTENT_JOBS_SUPPORTED
|
|
1100
1075
|
? 'Jobs are killed when the owning CLI exits unless started with persist: true. When the task is to leave a service running for the user (a web server, daemon or listener they will use after you finish), start it with persist: true and do not stop it before you finish.'
|
|
@@ -1115,6 +1090,9 @@ export function createCodingTools(policy) {
|
|
|
1115
1090
|
if (command.length > 32000)
|
|
1116
1091
|
throw new Error('Command is too long');
|
|
1117
1092
|
assertNotHostKill(command, hostShellOf(defaultShellKind));
|
|
1093
|
+
assertNotGitIdentityOverride(command);
|
|
1094
|
+
await assertNoHoldEscape(command);
|
|
1095
|
+
assertCommandAvoidsHarnessHome(command, context);
|
|
1118
1096
|
const launchPolicy = await shellPermission(policy, 'AsyncProcess', args, context);
|
|
1119
1097
|
const id = `agent-${randomUUID()}`;
|
|
1120
1098
|
const persist = boolArg(args, 'persist') === true;
|
|
@@ -1147,10 +1125,12 @@ export function createCodingTools(policy) {
|
|
|
1147
1125
|
}, required: ['command'], additionalProperties: false }, 'sequential', async (args, context) => {
|
|
1148
1126
|
const command = stringArg(args, 'command');
|
|
1149
1127
|
assertNotHostKill(command, 'powershell');
|
|
1128
|
+
assertNotGitIdentityOverride(command);
|
|
1129
|
+
assertCommandAvoidsHarnessHome(command, context);
|
|
1150
1130
|
const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
|
|
1151
1131
|
const launchPolicy = await shellPermission(policy, 'PowerShellFast', args, context);
|
|
1152
1132
|
const cwd = await policy.safePath(context, '.');
|
|
1153
|
-
return
|
|
1133
|
+
return auditedCommand(cwd, command, launchPolicy, async () => nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy, context.onCommandOutput), true));
|
|
1154
1134
|
});
|
|
1155
1135
|
const ShellMetrics = zTool('ShellMetrics', 'Return bounded per-process command timing statistics (p50/p95/p99), startup/validation, execution, first-output and cleanup phases without leaking command arguments.', { type: 'object', properties: {}, additionalProperties: false }, 'parallel', async () => JSON.stringify(commandTimingSummary()));
|
|
1156
1136
|
const platformShell = process.platform === 'win32' ? canonicalShell('PowerShell', 'powershell') : canonicalShell('Bash', 'bash');
|