@andorra-labs/code 0.1.11 → 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/README.md +8 -2
- package/THIRD_PARTY_NOTICES.md +15 -0
- 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 +59 -414
- 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 +14 -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 +19 -244
- 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 +33 -918
- package/dist/src/app-server.js +608 -2984
- 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 +10 -25
- package/dist/src/browser-panel-tool.js +64 -60
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +7 -46
- package/dist/src/browser-server.d.ts +0 -6
- package/dist/src/browser-server.js +6 -229
- package/dist/src/browser-session.d.ts +0 -25
- package/dist/src/browser-session.js +1 -71
- package/dist/src/browser-stealth.d.ts +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 +52 -290
- package/dist/src/browser-view.js +354 -567
- 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 +166 -61
- 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 +3 -56
- package/dist/src/cli.js +193 -702
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +27 -100
- 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 +1 -26
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +6 -27
- package/dist/src/coding-tools.js +193 -205
- 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 +2 -58
- package/dist/src/completion.js +90 -186
- package/dist/src/config.d.ts +12 -116
- package/dist/src/config.js +41 -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 +1 -11
- 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 +15 -124
- package/dist/src/diff-preview.d.ts +1 -1
- package/dist/src/diff-preview.js +4 -12
- 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 +13 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +76 -37
- 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 +1 -0
- package/dist/src/file-read-key.js +5 -0
- 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 +1 -3
- package/dist/src/graph-health.d.ts +7 -49
- package/dist/src/graph-health.js +35 -46
- package/dist/src/graph-manager-chat.d.ts +27 -128
- package/dist/src/graph-manager-chat.js +36 -166
- 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 +47 -387
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +0 -14
- package/dist/src/graph-server.d.ts +3 -11
- package/dist/src/graph-server.js +70 -111
- 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 +229 -498
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +47 -43
- 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 +2 -7
- package/dist/src/graph-ui/index.html +2 -2
- 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 +110 -49
- package/dist/src/graph-ui/manager.css +2 -20
- package/dist/src/graph-ui/manager.js +251 -166
- package/dist/src/graph-ui/model-picker.js +250 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- 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 +7 -156
- package/dist/src/graphs.js +72 -273
- 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 +21 -82
- package/dist/src/mcp.js +228 -237
- 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 +42 -0
- package/dist/src/memory/ProjectMemory.js +285 -0
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- 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 +6 -22
- package/dist/src/package-name.d.ts +1 -0
- package/dist/src/package-name.js +1 -0
- 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 +3 -98
- 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 +2 -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 +106 -418
- 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 +1 -19
- package/dist/src/remote/cert.js +2 -51
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +2 -117
- 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 +2 -0
- package/dist/src/remote/pem.js +7 -0
- 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 +44 -678
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +11 -227
- 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 -120
- package/dist/src/sessions.js +9 -178
- package/dist/src/shell.d.ts +3 -20
- package/dist/src/shell.js +8 -72
- package/dist/src/side-panel.d.ts +5 -99
- package/dist/src/side-panel.js +76 -133
- package/dist/src/sign-in-detection.d.ts +43 -0
- package/dist/src/sign-in-detection.js +154 -0
- package/dist/src/sign-in-offer.d.ts +17 -0
- package/dist/src/sign-in-offer.js +103 -0
- package/dist/src/skill-commands.d.ts +0 -1
- package/dist/src/skill-commands.js +1 -4
- package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +22 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- 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 +1 -8
- package/dist/src/skills/runtime-skills.js +8 -32
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +5 -0
- package/dist/src/stray-files.js +65 -0
- 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 +10 -374
- 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 +15 -524
- package/dist/src/terminal-ui.js +80 -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 +1 -8
- 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 +1 -2
- package/dist/src/tool-schema-compatibility.js +2 -7
- 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 +1 -37
- package/dist/src/transcript.js +11 -61
- package/dist/src/types.d.ts +2 -167
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +105 -0
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +2 -16
- package/dist/src/update.d.ts +4 -29
- package/dist/src/update.js +20 -98
- 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 +4 -5
- package/dist/src/workspace-git-metadata.js +37 -9
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +7 -20
- package/package.json +2 -2
package/dist/src/coding-tools.js
CHANGED
|
@@ -6,43 +6,52 @@ import { promisify } from 'node:util';
|
|
|
6
6
|
import { StringDecoder } from 'node:string_decoder';
|
|
7
7
|
import { andorraCreateReadTool, andorraCreateWriteTool, andorraCreateEditTool, andorraCreateFindTool, andorraCreateGrepTool, andorraCreateLsTool, andorraCreateBashTool, andorraCreatePowerShellTool, } from '../vendor/engine/runtime/coding-agent/core/tools/index.js';
|
|
8
8
|
import { andorraGetToolPath } from '../vendor/engine/runtime/coding-agent/utils/tools-manager.js';
|
|
9
|
+
import { registerEditArgumentPreparer } from './diff-preview.js';
|
|
10
|
+
import { stateKey } from './file-read-key.js';
|
|
9
11
|
import { defaultShellKind, runShell, runNativeProcess } from './shell.js';
|
|
10
12
|
import { commandTimingSummary } from './command-metrics.js';
|
|
11
13
|
import { runPooledPowerShell } from './powershell-pool.js';
|
|
14
|
+
import { withStrayFileNotice } from './stray-files.js';
|
|
12
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';
|
|
13
18
|
import { getQaProcessManager, PERSISTENT_JOBS_SUPPORTED } from './qa/runtime/ProcessManager.js';
|
|
14
19
|
import { clipText } from './text.js';
|
|
15
20
|
import { matchesFileRead, storeFileRead } from './file-read-state.js';
|
|
16
|
-
import { FileReadRequiredError } from './tool-errors.js';
|
|
21
|
+
import { CommandExitError, FileReadRequiredError } from './tool-errors.js';
|
|
17
22
|
import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
|
|
18
23
|
import { withGrepRegex } from './grep-regex.js';
|
|
19
24
|
import { claimReadImages, readImageObservation } from './read-image.js';
|
|
20
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
|
+
}
|
|
21
34
|
const execFileAsync = promisify(execFile);
|
|
35
|
+
registerEditArgumentPreparer(andorraCreateEditTool('.').prepareArguments);
|
|
22
36
|
const excluded = new Set(['.git', 'node_modules', '.andorracode']);
|
|
23
37
|
const MAX_MODEL_OUTPUT = 24_000;
|
|
24
|
-
/** Lines returned by one Read call: both the default and the accepted maximum for `limit`. */
|
|
25
38
|
const READ_MAX_LINES = 2000;
|
|
26
|
-
/** A single line longer than this is truncated, so one minified line cannot fill the window. */
|
|
27
39
|
const READ_MAX_LINE_CHARS = 2000;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
};
|
|
37
53
|
export const SHELL_DEFAULT_TIMEOUT_MS = 120_000;
|
|
38
54
|
export const SHELL_MAX_TIMEOUT_MS = 600_000;
|
|
39
|
-
/**
|
|
40
|
-
* What a timed-out command's error tells the model to do next.
|
|
41
|
-
*
|
|
42
|
-
* The bare "timed out after N ms" says the command was stopped but not that the work is lost, nor
|
|
43
|
-
* which of the two ways forward fits: a longer timeout while one is left to ask for, or a
|
|
44
|
-
* background job once the ceiling is reached.
|
|
45
|
-
*/
|
|
46
55
|
export function shellTimeoutGuidance(message, timeout) {
|
|
47
56
|
const marker = /^Shell command timed out after \d+ ms/;
|
|
48
57
|
if (!marker.test(message))
|
|
@@ -67,16 +76,12 @@ async function shellPermission(policy, name, args, context) {
|
|
|
67
76
|
const mode = permissionMode(context);
|
|
68
77
|
let explicitlyApproved = false;
|
|
69
78
|
let escalationAuthorized = false;
|
|
70
|
-
// Plan mode researches read-only: an escalation (host and network access) would be a change no
|
|
71
|
-
// plan has been approved for, so it is refused with the same guidance as a file mutation.
|
|
72
79
|
if (mode === 'plan' && requested === 'require_escalated')
|
|
73
80
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
74
81
|
if (!mode || mode === 'full-access' || requested === 'require_escalated') {
|
|
75
82
|
await policy.authorize(name, { ...args, warning: 'UNSANDBOXED: entire host and network access.' }, {
|
|
76
83
|
...context, approve: async (...approval) => {
|
|
77
84
|
const approved = await context.approve(...approval);
|
|
78
|
-
// A live permission switch settles outstanding prompts with policy-changed. Never
|
|
79
|
-
// allow an old escalation request to be re-approved after the run enters Plan.
|
|
80
85
|
if (requested === 'require_escalated' && permissionMode(context) === 'plan')
|
|
81
86
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
82
87
|
if (approved === true)
|
|
@@ -84,31 +89,18 @@ async function shellPermission(policy, name, args, context) {
|
|
|
84
89
|
return approved;
|
|
85
90
|
},
|
|
86
91
|
});
|
|
87
|
-
// Authorization may have awaited other hooks while the run switched modes.
|
|
88
92
|
if (requested === 'require_escalated' && permissionMode(context) === 'plan')
|
|
89
93
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
90
94
|
escalationAuthorized = requested === 'require_escalated';
|
|
91
95
|
}
|
|
92
|
-
// Evaluate synchronously at spawn, after filesystem/launcher discovery awaits.
|
|
93
|
-
// Only a real per-call user grant can preserve unsandboxed execution when a
|
|
94
|
-
// previously automatic Full Access grant has since been revoked.
|
|
95
96
|
return () => {
|
|
96
97
|
const live = permissionMode(context);
|
|
97
|
-
// Spawn-time recheck is essential: even a previously granted escalation cannot
|
|
98
|
-
// escape the read-only boundary if the run switched into Plan in the meantime.
|
|
99
98
|
if (requested === 'require_escalated' && live === 'plan')
|
|
100
99
|
throw new Error(PLAN_MODE_MUTATION_ERROR);
|
|
101
100
|
if (explicitlyApproved)
|
|
102
101
|
return undefined;
|
|
103
|
-
// An escalation this call's own authorization granted is an audited host grant: a shell is never a
|
|
104
|
-
// workspace-policy mutation, so without an explicit answer the journaled decision was Full Access
|
|
105
|
-
// policy — typically the user switching the run to Full Access while this prompt was open. It holds
|
|
106
|
-
// while Full Access is still in force at spawn; a revocation since then falls through below.
|
|
107
102
|
if (escalationAuthorized && live === 'full-access')
|
|
108
103
|
return undefined;
|
|
109
|
-
// A later Full Access selection cannot create an unaudited host grant.
|
|
110
|
-
// Keep an initially restricted call restricted; a subsequent call can
|
|
111
|
-
// acquire Full Access through authorize and its journal events.
|
|
112
104
|
if (mode && mode !== 'full-access' && live === 'full-access')
|
|
113
105
|
return mode === 'read-only' || mode === 'plan' ? 'read-only' : 'workspace-write';
|
|
114
106
|
if (!live || live === 'full-access')
|
|
@@ -171,17 +163,7 @@ const boolArg = (args, key) => {
|
|
|
171
163
|
throw new Error(`${key} must be a boolean`);
|
|
172
164
|
return value;
|
|
173
165
|
};
|
|
174
|
-
|
|
175
|
-
* Key for the per-context file-read state.
|
|
176
|
-
*
|
|
177
|
-
* Exported so other producers of the same state (the CodeGraph complete-source seed) store
|
|
178
|
-
* entries under the key the canonical tools look up. It must be applied to a path normalized
|
|
179
|
-
* the same way the policy's safePath normalizes it, or the entries never match.
|
|
180
|
-
*/
|
|
181
|
-
export function stateKey(resolved) {
|
|
182
|
-
const key = path.resolve(resolved);
|
|
183
|
-
return process.platform === 'win32' ? key.toLowerCase() : key;
|
|
184
|
-
}
|
|
166
|
+
export { stateKey };
|
|
185
167
|
function state(context) {
|
|
186
168
|
context.toolState ??= { fileReads: new Map() };
|
|
187
169
|
return context.toolState;
|
|
@@ -198,9 +180,6 @@ async function remember(context, resolved, content, complete, source) {
|
|
|
198
180
|
async function rememberReadRange(context, resolved, content, start, end, lineCount) {
|
|
199
181
|
const key = stateKey(resolved);
|
|
200
182
|
const prior = state(context).fileReads.get(key);
|
|
201
|
-
// Successful mutations and complete CodeGraph source are also full snapshots.
|
|
202
|
-
// A narrow Read of identical content must not revoke their existing coverage.
|
|
203
|
-
// Changed bytes invalidate all prior ranges, regardless of snapshot origin.
|
|
204
183
|
const ranges = prior && matchesFileRead(prior, content) ? (prior.complete ? [{ start: 1, end: lineCount }] : [...(prior.ranges ?? [])]) : [];
|
|
205
184
|
if (lineCount === 0) {
|
|
206
185
|
await remember(context, resolved, content, true, 'Read');
|
|
@@ -227,7 +206,6 @@ async function rememberReadRange(context, resolved, content, start, end, lineCou
|
|
|
227
206
|
source: 'Read',
|
|
228
207
|
});
|
|
229
208
|
}
|
|
230
|
-
/** First unread stretch of the file, for a partial observation. */
|
|
231
209
|
function firstUnreadRange(previous) {
|
|
232
210
|
if (previous.complete)
|
|
233
211
|
return undefined;
|
|
@@ -245,12 +223,7 @@ function firstUnreadRange(previous) {
|
|
|
245
223
|
async function requireFreshRead(policy, context, resolved, action) {
|
|
246
224
|
const previous = state(context).fileReads.get(stateKey(resolved));
|
|
247
225
|
if (!previous?.complete) {
|
|
248
|
-
// A suggested offset is only meaningful for the content the model last saw. Re-read first so
|
|
249
|
-
// a file that changed (or shrank) since that page cannot send the model past its end.
|
|
250
226
|
if (!previous) {
|
|
251
|
-
// A file the text tools cannot hold (a document, an image, text in another encoding) can be
|
|
252
|
-
// looked at with Read but never becomes a recorded read, so "Read it first" would send the
|
|
253
|
-
// model round in a circle. The strict reader's own refusal is the true answer for those.
|
|
254
227
|
await policy.read(context, resolved);
|
|
255
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.`);
|
|
256
229
|
}
|
|
@@ -268,7 +241,6 @@ async function requireFreshRead(policy, context, resolved, action) {
|
|
|
268
241
|
throw new FileReadRequiredError(`${action} refused a stale file: it changed since the last Read/CodeGraph snapshot. Read it again before modifying.`);
|
|
269
242
|
return current;
|
|
270
243
|
}
|
|
271
|
-
/** A replacement whose old text the current file does not hold exactly as the call needs. */
|
|
272
244
|
class EditMatchError extends Error {
|
|
273
245
|
summary;
|
|
274
246
|
constructor(message, summary) {
|
|
@@ -277,15 +249,7 @@ class EditMatchError extends Error {
|
|
|
277
249
|
this.name = 'EditMatchError';
|
|
278
250
|
}
|
|
279
251
|
}
|
|
280
|
-
/** The runtime prefixes a failed call's message with this before clipping it at MAX_MODEL_OUTPUT. */
|
|
281
252
|
const TOOL_ERROR_PREFIX = 'Tool error: ';
|
|
282
|
-
/**
|
|
283
|
-
* A failure message that carries the whole file, or undefined when it cannot.
|
|
284
|
-
*
|
|
285
|
-
* Stricter than Read: a clipped line, a second page, or a message the runtime would clip leaves
|
|
286
|
-
* text the model has not seen, and the caller records the file as completely read on the strength
|
|
287
|
-
* of this message. The budget is measured on the complete message, not the file alone.
|
|
288
|
-
*/
|
|
289
253
|
function messageWithWholeFile(explanation, content) {
|
|
290
254
|
const lines = content.split('\n');
|
|
291
255
|
if (content.endsWith('\n') || content === '')
|
|
@@ -296,7 +260,6 @@ function messageWithWholeFile(explanation, content) {
|
|
|
296
260
|
const message = `${explanation}\n${page}`;
|
|
297
261
|
return TOOL_ERROR_PREFIX.length + message.length <= MAX_MODEL_OUTPUT ? message : undefined;
|
|
298
262
|
}
|
|
299
|
-
/** The old texts an Edit call names, or undefined when the call is not a well-formed edit. */
|
|
300
263
|
function editOldTexts(args) {
|
|
301
264
|
if (args.edits === undefined)
|
|
302
265
|
return typeof args.old_string === 'string' && args.old_string ? [args.old_string] : undefined;
|
|
@@ -325,14 +288,6 @@ function editOldTexts(args) {
|
|
|
325
288
|
}
|
|
326
289
|
return texts;
|
|
327
290
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Why an Edit's old text is not literally in the file, or undefined when every one is.
|
|
330
|
-
*
|
|
331
|
-
* The edit matcher also accepts near matches (Unicode and whitespace normalization). That is safe
|
|
332
|
-
* for a file the model has read, and is exactly what must not stand in for the read: only a
|
|
333
|
-
* literal occurrence shows the model knows the text it is replacing. Line endings are the one
|
|
334
|
-
* difference allowed, because models write LF for files stored with CRLF.
|
|
335
|
-
*/
|
|
336
291
|
function unseenEditMismatch(args, content) {
|
|
337
292
|
const texts = editOldTexts(args);
|
|
338
293
|
if (!texts)
|
|
@@ -349,20 +304,6 @@ function unseenEditMismatch(args, content) {
|
|
|
349
304
|
}
|
|
350
305
|
return undefined;
|
|
351
306
|
}
|
|
352
|
-
/**
|
|
353
|
-
* Edit without the separate Read the gate would otherwise ask the model for.
|
|
354
|
-
*
|
|
355
|
-
* The gate exists so a mutation never rests on text the model did not see. For an Edit, old_string
|
|
356
|
-
* occurring literally in the current file is that evidence, so a file that was never (or only
|
|
357
|
-
* partly) Read is read here: a literal match applies the edit, and a miss returns the file in the
|
|
358
|
-
* failure so the next call is the corrected Edit. Either way the model does not spend a call on
|
|
359
|
-
* Read and another on resending the same Edit. A file that changed since the model last saw it is
|
|
360
|
-
* still refused, with its current content when one message holds it. Write keeps the plain gate:
|
|
361
|
-
* a full overwrite carries no evidence that the model knows what it replaces.
|
|
362
|
-
*
|
|
363
|
-
* The file counts as Read only when the edit applied or its whole content was returned; every
|
|
364
|
-
* other outcome leaves or puts back the previous read state.
|
|
365
|
-
*/
|
|
366
307
|
async function editWithoutPriorRead(policy, args, context, execute) {
|
|
367
308
|
const filePath = args.file_path;
|
|
368
309
|
if (typeof filePath !== 'string' || !filePath || filePath.includes('\0'))
|
|
@@ -371,7 +312,6 @@ async function editWithoutPriorRead(policy, args, context, execute) {
|
|
|
371
312
|
const reads = state(context).fileReads, key = stateKey(resolved);
|
|
372
313
|
const previous = reads.get(key);
|
|
373
314
|
let content;
|
|
374
|
-
// A missing, binary or oversized target is the tool's own error to report.
|
|
375
315
|
try {
|
|
376
316
|
content = await policy.read(context, resolved);
|
|
377
317
|
}
|
|
@@ -388,14 +328,12 @@ async function editWithoutPriorRead(policy, args, context, execute) {
|
|
|
388
328
|
}
|
|
389
329
|
if (previous?.complete)
|
|
390
330
|
return execute(args, context);
|
|
391
|
-
// Not a well-formed edit: the gate refuses it as it always has.
|
|
392
331
|
if (!editOldTexts(args))
|
|
393
332
|
return execute(args, context);
|
|
394
333
|
const restore = () => { if (previous)
|
|
395
334
|
reads.set(key, previous);
|
|
396
335
|
else
|
|
397
336
|
reads.delete(key); };
|
|
398
|
-
/** The edit cannot apply: hand the model the file, or the paged-read refusal when it is too long. */
|
|
399
337
|
const missed = async (summary) => {
|
|
400
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);
|
|
401
339
|
if (message !== undefined) {
|
|
@@ -489,13 +427,9 @@ export function createCodingTools(policy) {
|
|
|
489
427
|
const limit = intArg(args, 'limit', { min: 1, max: READ_MAX_LINES }) ?? READ_MAX_LINES;
|
|
490
428
|
const pages = stringArg(args, 'pages', true), render = boolArg(args, 'render') ?? false;
|
|
491
429
|
const resolved = await policy.safePath(context, filePath);
|
|
492
|
-
// An image is recognized by its signature and shown as pixels. It is not recorded as a
|
|
493
|
-
// text read: Write and Edit cannot faithfully rewrite a file they only saw as a picture.
|
|
494
430
|
const image = await policy.readImage?.(context, resolved);
|
|
495
431
|
if (image)
|
|
496
432
|
return readImageObservation(context, filePath, image);
|
|
497
|
-
// A PDF or Word file is likewise recognized by its leading bytes and returned as what it
|
|
498
|
-
// says: its text, or for a PDF its pages as images. Neither is recorded as a text read.
|
|
499
433
|
const documentOptions = { offset, limit, ...(pages === undefined ? {} : { pages }), render, maxOutput: MAX_MODEL_OUTPUT, maxLineChars: READ_MAX_LINE_CHARS };
|
|
500
434
|
const documentBytes = await policy.readDocument?.(context, resolved);
|
|
501
435
|
if (documentBytes) {
|
|
@@ -508,8 +442,6 @@ export function createCodingTools(policy) {
|
|
|
508
442
|
content = await policy.read(context, resolved);
|
|
509
443
|
}
|
|
510
444
|
catch (error) {
|
|
511
|
-
// Text in an older encoding (UTF-16, Windows-1252) fails the strict UTF-8 reader that
|
|
512
|
-
// Edit depends on. It is still text a model can read, so it is shown decoded, read-only.
|
|
513
445
|
if (!(error instanceof Error) || !/not valid UTF-8|Binary files are not supported/.test(error.message))
|
|
514
446
|
throw error;
|
|
515
447
|
const decoded = await policy.readLegacyText?.(context, resolved);
|
|
@@ -530,9 +462,6 @@ export function createCodingTools(policy) {
|
|
|
530
462
|
if (first > lines.length)
|
|
531
463
|
throw new Error(`Offset ${first} is beyond end of file (${lines.length} lines total)`);
|
|
532
464
|
const lastRequested = Math.min(lines.length, first + limit - 1);
|
|
533
|
-
// The runtime clips every tool result at MAX_MODEL_OUTPUT before the model sees it, so a
|
|
534
|
-
// page that overflows would lose its tail and the continuation footer while still being
|
|
535
|
-
// recorded as read. Stop on the last whole line that fits, and record only that line.
|
|
536
465
|
const budget = MAX_MODEL_OUTPUT - 200;
|
|
537
466
|
let rendered = '';
|
|
538
467
|
let emittedLast = first - 1;
|
|
@@ -546,7 +475,6 @@ export function createCodingTools(policy) {
|
|
|
546
475
|
emittedLast = line;
|
|
547
476
|
}
|
|
548
477
|
if (emittedLast < first) {
|
|
549
|
-
// A truncated line always fits this budget, so this is a defensive guard, not a path.
|
|
550
478
|
rendered = `${first}\t${(lines[first - 1] ?? '').slice(0, READ_MAX_LINE_CHARS)}`;
|
|
551
479
|
emittedLast = first;
|
|
552
480
|
}
|
|
@@ -607,10 +535,6 @@ export function createCodingTools(policy) {
|
|
|
607
535
|
await remember(context, resolved, updated, true, 'mutation');
|
|
608
536
|
return `Replaced ${count} occurrence(s) in ${path.relative(context.workspace, resolved) || resolved}. File state is current; no Read-back is needed.`;
|
|
609
537
|
}
|
|
610
|
-
// Models sometimes send `edits` as a JSON string, or a single edit object where the
|
|
611
|
-
// contract asks for a one-element array, so coerce before validating. The engine edit
|
|
612
|
-
// adapter tolerated both; dropping the tolerance would turn recoverable calls into
|
|
613
|
-
// hard failures on a path that previously worked.
|
|
614
538
|
const coerceEdits = (value) => {
|
|
615
539
|
let parsed = value;
|
|
616
540
|
if (typeof parsed === 'string') {
|
|
@@ -669,8 +593,6 @@ export function createCodingTools(policy) {
|
|
|
669
593
|
catch (error) {
|
|
670
594
|
if (!(error instanceof Error) || !/Could not find|Found \d+ occurrences|overlap/i.test(error.message))
|
|
671
595
|
throw error;
|
|
672
|
-
// Matcher failures occur before the native atomic write. Do not imply
|
|
673
|
-
// partial batch progress, or echo the entire generated patch as feedback.
|
|
674
596
|
const failedIndex = Number(error.message.match(/edits\[(\d+)\]/)?.[1] ?? 0);
|
|
675
597
|
const failed = edits[failedIndex];
|
|
676
598
|
const lines = before.split(/\r?\n/);
|
|
@@ -686,8 +608,6 @@ export function createCodingTools(policy) {
|
|
|
686
608
|
const upstream = result.content.filter(part => part.type === 'text').map(part => part.text).join('\n');
|
|
687
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.`);
|
|
688
610
|
});
|
|
689
|
-
// Advertise the focused single replacement contract. Older saved calls
|
|
690
|
-
// retain batch compatibility, validated separately after normalization.
|
|
691
611
|
const editSeenFile = Edit.execute;
|
|
692
612
|
Edit.execute = (args, context) => editWithoutPriorRead(policy, args, context, editSeenFile);
|
|
693
613
|
Edit.validationParameters = Edit.parameters;
|
|
@@ -725,7 +645,7 @@ export function createCodingTools(policy) {
|
|
|
725
645
|
});
|
|
726
646
|
return args;
|
|
727
647
|
};
|
|
728
|
-
const Glob = zTool('Glob', 'Find files by glob pattern inside the workspace. This replaces Andorra list_files and Pi find/ls with one bounded discovery tool.', { type: 'object', properties: {
|
|
648
|
+
const Glob = zTool('Glob', 'Find files by glob pattern inside the workspace. This replaces Andorra list_files and Pi find/ls with one bounded discovery tool. It matches names, not contents, so use it to find something by name (for example *deploy*) before searching file contents; raise head_limit when the result reaches the limit.', { type: 'object', properties: {
|
|
729
649
|
pattern: { type: 'string', description: 'Glob pattern such as **/*.ts or src/**/*.spec.ts' },
|
|
730
650
|
path: { type: 'string', description: 'Directory inside the workspace; defaults to .' },
|
|
731
651
|
head_limit: { type: 'integer', minimum: 1, maximum: 1000, description: 'Maximum paths; default 100' },
|
|
@@ -739,7 +659,7 @@ export function createCodingTools(policy) {
|
|
|
739
659
|
const result = await current.execute(randomUUID(), { pattern, path: resolved, limit }, context.signal);
|
|
740
660
|
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'));
|
|
741
661
|
});
|
|
742
|
-
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: {
|
|
743
663
|
pattern: { type: 'string', description: 'Regular expression to search for' },
|
|
744
664
|
path: { type: 'string', description: 'File or directory inside the workspace; defaults to .' },
|
|
745
665
|
glob: { type: 'string', description: 'Optional glob filter such as *.{ts,tsx}' },
|
|
@@ -771,85 +691,136 @@ export function createCodingTools(policy) {
|
|
|
771
691
|
const limit = requestedLimit === 0 ? 2000 : requestedLimit ?? 250;
|
|
772
692
|
const offset = intArg(args, 'offset', { min: 0, max: 100000 }) ?? 0;
|
|
773
693
|
const resolved = await policy.safePath(context, searchPath);
|
|
774
|
-
// Resolving rg probes PATH by executing it. Restricted searches must never
|
|
775
|
-
// enter that resolver (or a vendor helper that downloads/spawns binaries).
|
|
776
694
|
const restricted = context.pinFilePaths || (permissionMode(context) !== undefined && permissionMode(context) !== 'full-access');
|
|
777
695
|
const rg = restricted ? null : andorraGetToolPath('rg');
|
|
778
696
|
if (!rg) {
|
|
779
|
-
if (
|
|
697
|
+
if (multiline || only)
|
|
780
698
|
throw new Error(restricted
|
|
781
699
|
? 'This Grep option requires ripgrep, which is unavailable to restricted searches. Use glob and a single-line pattern instead.'
|
|
782
|
-
: 'This Grep
|
|
783
|
-
|
|
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) => {
|
|
784
705
|
const searchContext = { ...context, signal: searchSignal };
|
|
785
706
|
const info = await stat(resolved);
|
|
786
707
|
searchSignal.throwIfAborted();
|
|
787
|
-
const candidates = [];
|
|
788
|
-
if (info.isFile())
|
|
789
|
-
candidates.push(resolved);
|
|
790
|
-
else
|
|
791
|
-
for await (const candidate of policy.files(searchContext, resolved)) {
|
|
792
|
-
searchSignal.throwIfAborted();
|
|
793
|
-
candidates.push(candidate);
|
|
794
|
-
}
|
|
795
708
|
const rows = [];
|
|
796
|
-
let scannedFiles = 0, scannedBytes = 0;
|
|
797
|
-
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`;
|
|
798
714
|
const contextBefore = around ?? before ?? 0, contextAfter = around ?? after ?? 0;
|
|
799
|
-
|
|
800
|
-
searchSignal.throwIfAborted();
|
|
715
|
+
const searchFile = async (candidate) => {
|
|
801
716
|
const relative = path.relative(resolved, candidate).split(path.sep).join('/') || path.basename(candidate);
|
|
802
717
|
if (glob && !path.matchesGlob(relative, glob) && !path.matchesGlob(path.basename(relative), glob))
|
|
803
|
-
|
|
804
|
-
if (
|
|
805
|
-
|
|
806
|
-
|
|
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;
|
|
807
728
|
}
|
|
808
729
|
let source;
|
|
809
730
|
try {
|
|
810
|
-
// Discovery is not a snapshot: builds/cleanup can remove or revoke a
|
|
811
|
-
// candidate before either stat or read. Skip it just like a failed read.
|
|
812
731
|
const candidateInfo = await stat(candidate);
|
|
813
732
|
searchSignal.throwIfAborted();
|
|
814
|
-
if (candidateInfo.size >
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
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;
|
|
819
740
|
}
|
|
820
741
|
source = await policy.read(searchContext, candidate);
|
|
742
|
+
scannedBytes += candidateInfo.size;
|
|
821
743
|
}
|
|
822
|
-
catch {
|
|
744
|
+
catch (error) {
|
|
823
745
|
searchSignal.throwIfAborted();
|
|
824
|
-
|
|
746
|
+
if (!(error instanceof Error) || !/Binary files are not supported|not valid UTF-8/.test(error.message))
|
|
747
|
+
unreadable++;
|
|
748
|
+
return true;
|
|
825
749
|
}
|
|
826
750
|
searchSignal.throwIfAborted();
|
|
751
|
+
scannedFiles++;
|
|
752
|
+
progress();
|
|
827
753
|
const lines = source.replace(/\r\n/g, '\n').replace(/\r/g, '\n').split('\n');
|
|
828
|
-
let matches = 0;
|
|
829
|
-
for (
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
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
|
+
}
|
|
842
779
|
}
|
|
843
|
-
|
|
844
|
-
|
|
780
|
+
from = to;
|
|
781
|
+
progress();
|
|
845
782
|
}
|
|
846
783
|
if (mode === 'count' && matches)
|
|
847
784
|
rows.push(`${relative}:${matches}`);
|
|
848
|
-
|
|
849
|
-
|
|
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
|
+
}
|
|
850
808
|
}
|
|
851
809
|
const selected = rows.slice(offset, offset + limit);
|
|
852
|
-
|
|
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'));
|
|
853
824
|
});
|
|
854
825
|
}
|
|
855
826
|
const cwd = await policy.safePath(context, '.');
|
|
@@ -896,7 +867,9 @@ export function createCodingTools(policy) {
|
|
|
896
867
|
else
|
|
897
868
|
throw new Error(`Grep failed: ${String(failure.stderr ?? failure.message).trim().slice(0, 1000)}`);
|
|
898
869
|
}
|
|
899
|
-
|
|
870
|
+
let all = stdout.split(/\r?\n/).filter(Boolean);
|
|
871
|
+
if (guardsHarnessHome(context))
|
|
872
|
+
all = withoutHarnessHomeLines(all, cwd);
|
|
900
873
|
const selected = all.slice(offset, offset + limit).map(line => line.length > 800 ? clipText(line, 800) + ' [line clipped]' : line);
|
|
901
874
|
const truncated = offset + selected.length < all.length || stdout.length > 24_000;
|
|
902
875
|
const body = selected.join('\n') || 'No matches';
|
|
@@ -906,9 +879,9 @@ export function createCodingTools(policy) {
|
|
|
906
879
|
const canonicalShell = (name, kind) => {
|
|
907
880
|
const actual = kind === 'powershell' ? 'PowerShell' : 'Bash';
|
|
908
881
|
const syntax = kind === 'powershell'
|
|
909
|
-
? '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. 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".'
|
|
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".'
|
|
910
883
|
: 'Bash syntax (Git Bash on Windows).';
|
|
911
|
-
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: {
|
|
912
885
|
command: { type: 'string', description: 'Command to execute' },
|
|
913
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` },
|
|
914
887
|
description: { type: 'string', description: 'Short active-voice description of what the command does' },
|
|
@@ -919,16 +892,12 @@ export function createCodingTools(policy) {
|
|
|
919
892
|
const command = stringArg(args, 'command'), timeout = intArg(args, 'timeout', { min: 1, max: SHELL_MAX_TIMEOUT_MS }) ?? SHELL_DEFAULT_TIMEOUT_MS;
|
|
920
893
|
if (args.description !== undefined)
|
|
921
894
|
stringArg(args, 'description', true);
|
|
922
|
-
// Before any approval is asked for: no permission mode, full access included, makes ending
|
|
923
|
-
// the app that hosts this run a thing to approve. Read by the rules of the shell that runs it.
|
|
924
895
|
assertNotHostKill(command, hostShellOf(kind));
|
|
896
|
+
assertNotGitIdentityOverride(command);
|
|
897
|
+
assertCommandAvoidsHarnessHome(command, context);
|
|
925
898
|
const launchPolicy = await shellPermission(policy, name, args, context);
|
|
926
899
|
const cwd = await policy.safePath(context, '.');
|
|
927
900
|
const operations = { exec: async (value, directory, options) => {
|
|
928
|
-
// The same chunks that feed the vendored tool's accumulator also feed the live transcript:
|
|
929
|
-
// a reader who expands the running call sees the command's output as it prints. The
|
|
930
|
-
// decoder keeps a chunk boundary from splitting a multi-byte character on the way
|
|
931
|
-
// through; the observation the tool builds remains the authoritative text.
|
|
932
901
|
const decoder = new StringDecoder('utf8');
|
|
933
902
|
const report = options.onData;
|
|
934
903
|
const onData = (data) => {
|
|
@@ -955,35 +924,34 @@ export function createCodingTools(policy) {
|
|
|
955
924
|
const current = kind === 'powershell'
|
|
956
925
|
? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
|
|
957
926
|
: andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
927
|
+
return auditedCommand(cwd, command, launchPolicy, async () => {
|
|
928
|
+
try {
|
|
929
|
+
const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
|
|
930
|
+
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
|
|
931
|
+
}
|
|
932
|
+
catch (error) {
|
|
933
|
+
if (!(error instanceof Error))
|
|
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]));
|
|
938
|
+
const message = shellTimeoutGuidance(error.message, timeout);
|
|
939
|
+
if (message.length > MAX_MODEL_OUTPUT)
|
|
940
|
+
throw new Error(nativeObservation(message, true));
|
|
941
|
+
if (message !== error.message)
|
|
942
|
+
throw new Error(message);
|
|
964
943
|
throw error;
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
throw new Error(nativeObservation(message, true));
|
|
968
|
-
if (message !== error.message)
|
|
969
|
-
throw new Error(message);
|
|
970
|
-
throw error;
|
|
971
|
-
}
|
|
944
|
+
}
|
|
945
|
+
});
|
|
972
946
|
});
|
|
973
|
-
// The vendored shell throws on any exit other than 0, so a return is a clean exit.
|
|
974
947
|
return { ...tool, exitZeroOnReturn: true };
|
|
975
948
|
};
|
|
976
|
-
// Keep imported Pi spellings executable for old tests/configuration, but never
|
|
977
|
-
// advertise them to providers. capabilityTools maps legacy graph allowlists to
|
|
978
|
-
// the canonical surface above.
|
|
979
949
|
const definitions = [andorraCreateReadTool('.'), andorraCreateWriteTool('.'), andorraCreateEditTool('.'), andorraCreateLsTool('.'), andorraCreateFindTool('.'), andorraCreateGrepTool('.')];
|
|
980
950
|
const legacyNative = definitions.map(definition => ({
|
|
981
951
|
name: definition.name,
|
|
982
952
|
providerVisible: false,
|
|
983
953
|
prepareArguments: definition.prepareArguments,
|
|
984
954
|
executionMode: definition.name === 'write' || definition.name === 'edit' ? 'sequential' : 'parallel',
|
|
985
|
-
// Preserve the Andorra wording over the imported Pi descriptions: the read tool must
|
|
986
|
-
// not advertise image attachments, and traversal/limits are workspace-bounded.
|
|
987
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.`,
|
|
988
956
|
parameters: definition.parameters,
|
|
989
957
|
execute: async (args, context) => {
|
|
@@ -1018,7 +986,6 @@ export function createCodingTools(policy) {
|
|
|
1018
986
|
const actual = kind === 'powershell' ? 'PowerShell (PowerShell syntax)' : kind === 'bash' ? 'Bash' : '/bin/sh';
|
|
1019
987
|
return {
|
|
1020
988
|
name, providerVisible: false, executionMode: 'sequential',
|
|
1021
|
-
// 'shell' prints its own `Exit code:` line; the vendored powershell/bash throw on a non-zero exit.
|
|
1022
989
|
exitZeroOnReturn: name !== 'shell',
|
|
1023
990
|
description: `Legacy compatibility shell using ${actual}.`,
|
|
1024
991
|
parameters: { type: 'object', properties: { command: { type: 'string' }, timeout_ms: { type: 'integer', minimum: 1, maximum: 120000 }, ...sandboxFields }, required: ['command'], additionalProperties: false },
|
|
@@ -1031,12 +998,13 @@ export function createCodingTools(policy) {
|
|
|
1031
998
|
if (typeof timeout !== 'number' || !Number.isInteger(timeout) || timeout < 1 || timeout > 120000)
|
|
1032
999
|
throw new Error('timeout_ms must be an integer from 1 to 120000');
|
|
1033
1000
|
assertNotHostKill(args.command, hostShellOf(kind));
|
|
1001
|
+
assertNotGitIdentityOverride(args.command);
|
|
1002
|
+
assertCommandAvoidsHarnessHome(args.command, context);
|
|
1034
1003
|
const launchPolicy = await shellPermission(policy, name, args, context);
|
|
1035
1004
|
const cwd = await policy.safePath(context, '.');
|
|
1036
|
-
|
|
1037
|
-
// while explicit 'powershell'/'bash' use native tail truncation and errors.
|
|
1005
|
+
const command = args.command;
|
|
1038
1006
|
if (name === 'shell')
|
|
1039
|
-
return nativeObservation(await runShell(
|
|
1007
|
+
return auditedCommand(cwd, command, launchPolicy, async () => nativeObservation(await runShell(command, cwd, timeout, context.signal, kind, undefined, undefined, launchPolicy), true));
|
|
1040
1008
|
const operations = { exec: async (value, directory, options) => {
|
|
1041
1009
|
try {
|
|
1042
1010
|
await runShell(value, directory, timeout, context.signal, kind, options.onData, undefined, launchPolicy);
|
|
@@ -1053,15 +1021,17 @@ export function createCodingTools(policy) {
|
|
|
1053
1021
|
const current = kind === 'powershell'
|
|
1054
1022
|
? andorraCreatePowerShellTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false })
|
|
1055
1023
|
: andorraCreateBashTool(cwd, { operations, persistOutput: false, exposeSessionEnvironment: false });
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1024
|
+
return auditedCommand(cwd, command, launchPolicy, async () => {
|
|
1025
|
+
try {
|
|
1026
|
+
const result = await current.execute(randomUUID(), { command, timeout: timeout / 1000 }, context.signal);
|
|
1027
|
+
return nativeObservation(result.content.filter(part => part.type === 'text').map(part => part.text).join('\n'), true);
|
|
1028
|
+
}
|
|
1029
|
+
catch (error) {
|
|
1030
|
+
if (error instanceof Error && error.message.length > 24_000)
|
|
1031
|
+
throw new Error(nativeObservation(error.message, true));
|
|
1032
|
+
throw error;
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1065
1035
|
},
|
|
1066
1036
|
};
|
|
1067
1037
|
});
|
|
@@ -1079,14 +1049,27 @@ export function createCodingTools(policy) {
|
|
|
1079
1049
|
throw new Error('args must be an array of at most 128 strings (4096 chars each, no NUL)');
|
|
1080
1050
|
}
|
|
1081
1051
|
const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
|
|
1082
|
-
// The array is judged as an array: there is no shell here to read an argument as syntax.
|
|
1083
1052
|
assertNotHostKillArgv(program, argv);
|
|
1053
|
+
assertNotGitIdentityOverrideArgv(program, argv);
|
|
1054
|
+
assertCommandAvoidsHarnessHome(argv.join(' '), context);
|
|
1084
1055
|
const launchPolicy = await shellPermission(policy, 'NativeExec', args, context);
|
|
1085
1056
|
const cwd = await policy.safePath(context, '.');
|
|
1086
1057
|
const executable = program === 'node' ? process.execPath : program === 'git' ? 'git' : andorraGetToolPath('rg');
|
|
1087
1058
|
if (!executable)
|
|
1088
|
-
throw new Error(
|
|
1089
|
-
|
|
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
|
+
});
|
|
1090
1073
|
});
|
|
1091
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
|
|
1092
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.'
|
|
@@ -1107,6 +1090,9 @@ export function createCodingTools(policy) {
|
|
|
1107
1090
|
if (command.length > 32000)
|
|
1108
1091
|
throw new Error('Command is too long');
|
|
1109
1092
|
assertNotHostKill(command, hostShellOf(defaultShellKind));
|
|
1093
|
+
assertNotGitIdentityOverride(command);
|
|
1094
|
+
await assertNoHoldEscape(command);
|
|
1095
|
+
assertCommandAvoidsHarnessHome(command, context);
|
|
1110
1096
|
const launchPolicy = await shellPermission(policy, 'AsyncProcess', args, context);
|
|
1111
1097
|
const id = `agent-${randomUUID()}`;
|
|
1112
1098
|
const persist = boolArg(args, 'persist') === true;
|
|
@@ -1139,10 +1125,12 @@ export function createCodingTools(policy) {
|
|
|
1139
1125
|
}, required: ['command'], additionalProperties: false }, 'sequential', async (args, context) => {
|
|
1140
1126
|
const command = stringArg(args, 'command');
|
|
1141
1127
|
assertNotHostKill(command, 'powershell');
|
|
1128
|
+
assertNotGitIdentityOverride(command);
|
|
1129
|
+
assertCommandAvoidsHarnessHome(command, context);
|
|
1142
1130
|
const timeout = intArg(args, 'timeout', { min: 1, max: 600000 }) ?? 30000;
|
|
1143
1131
|
const launchPolicy = await shellPermission(policy, 'PowerShellFast', args, context);
|
|
1144
1132
|
const cwd = await policy.safePath(context, '.');
|
|
1145
|
-
return nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy, context.onCommandOutput), true);
|
|
1133
|
+
return auditedCommand(cwd, command, launchPolicy, async () => nativeObservation(await runPooledPowerShell(command, cwd, timeout, context.signal, launchPolicy, context.onCommandOutput), true));
|
|
1146
1134
|
});
|
|
1147
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()));
|
|
1148
1136
|
const platformShell = process.platform === 'win32' ? canonicalShell('PowerShell', 'powershell') : canonicalShell('Bash', 'bash');
|