@prestyj/cli 5.32.2 → 5.34.0
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 +16 -16
- package/assets/motion/skills/motion/SKILL.md +1 -1
- package/assets/skills/bulletproof/SKILL.md +72 -131
- package/assets/skills/bulletproof/references/agent-surface.md +22 -1
- package/assets/skills/bulletproof/references/audit-protocol.md +23 -6
- package/assets/skills/bulletproof/references/platform-playbooks.md +12 -0
- package/assets/skills/bulletproof/references/provenance.md +19 -2
- package/assets/skills/bulletproof/references/secure-defaults.md +13 -1
- package/assets/skills/bulletproof/references/supply-chain.md +8 -5
- package/assets/skills/bulletproof/references/threat-landscape.md +46 -57
- package/assets/skills/compliance-guard/SKILL.md +59 -212
- package/assets/skills/compliance-guard/references/artifacts.md +14 -1
- package/assets/skills/compliance-guard/references/eu-uk.md +17 -7
- package/assets/skills/compliance-guard/references/exposure-triage.md +16 -0
- package/assets/skills/compliance-guard/references/full-review.md +155 -0
- package/assets/skills/compliance-guard/references/lawsuit-vectors.md +14 -2
- package/assets/skills/compliance-guard/references/provenance.md +33 -2
- package/assets/skills/compliance-guard/references/sector-gates.md +15 -1
- package/assets/skills/compliance-guard/references/security-baseline.md +21 -34
- package/assets/skills/compliance-guard/references/trigger-map.md +15 -1
- package/assets/skills/compliance-guard/references/us.md +32 -8
- package/assets/skills/durable/SKILL.md +22 -29
- package/assets/skills/durable/references/agent-db-safety.md +2 -2
- package/assets/skills/durable/references/backups-and-runtime.md +6 -6
- package/assets/skills/durable/references/migrations-and-schema.md +5 -4
- package/assets/skills/lean/SKILL.md +36 -50
- package/assets/skills/lean/references/playbooks.md +9 -7
- package/dist/app-sidecar/app-settings.d.ts +5 -0
- package/dist/app-sidecar/app-settings.js +16 -0
- package/dist/app-sidecar/app-settings.js.map +1 -1
- package/dist/app-sidecar/auth-routes.js +45 -2
- package/dist/app-sidecar/auth-routes.js.map +1 -1
- package/dist/app-sidecar/autopilot-runner.d.ts +7 -0
- package/dist/app-sidecar/autopilot-runner.js +79 -19
- package/dist/app-sidecar/autopilot-runner.js.map +1 -1
- package/dist/app-sidecar/desktop-guidance.d.ts +1 -0
- package/dist/app-sidecar/desktop-guidance.js +27 -0
- package/dist/app-sidecar/desktop-guidance.js.map +1 -0
- package/dist/app-sidecar/history-routes.d.ts +6 -0
- package/dist/app-sidecar/history-routes.js +57 -2
- package/dist/app-sidecar/history-routes.js.map +1 -1
- package/dist/app-sidecar/history.d.ts +17 -0
- package/dist/app-sidecar/history.js.map +1 -1
- package/dist/app-sidecar/http.d.ts +1 -1
- package/dist/app-sidecar/http.js +2 -2
- package/dist/app-sidecar/http.js.map +1 -1
- package/dist/app-sidecar/integration-routes.js +4 -0
- package/dist/app-sidecar/integration-routes.js.map +1 -1
- package/dist/app-sidecar/live-preview/dev-url.d.ts +32 -0
- package/dist/app-sidecar/live-preview/dev-url.js +97 -0
- package/dist/app-sidecar/live-preview/dev-url.js.map +1 -0
- package/dist/app-sidecar/live-preview/frame-server.d.ts +31 -0
- package/dist/app-sidecar/live-preview/frame-server.js +193 -0
- package/dist/app-sidecar/live-preview/frame-server.js.map +1 -0
- package/dist/app-sidecar/live-preview/manager.d.ts +44 -0
- package/dist/app-sidecar/live-preview/manager.js +215 -0
- package/dist/app-sidecar/live-preview/manager.js.map +1 -0
- package/dist/app-sidecar/live-preview/proxy.d.ts +30 -0
- package/dist/app-sidecar/live-preview/proxy.js +235 -0
- package/dist/app-sidecar/live-preview/proxy.js.map +1 -0
- package/dist/app-sidecar/live-preview/routes.d.ts +4 -0
- package/dist/app-sidecar/live-preview/routes.js +52 -0
- package/dist/app-sidecar/live-preview/routes.js.map +1 -0
- package/dist/app-sidecar/live-preview/servers.d.ts +36 -0
- package/dist/app-sidecar/live-preview/servers.js +228 -0
- package/dist/app-sidecar/live-preview/servers.js.map +1 -0
- package/dist/app-sidecar/mcp-routes.js +9 -0
- package/dist/app-sidecar/mcp-routes.js.map +1 -1
- package/dist/app-sidecar/mcp-shell-command.d.ts +36 -0
- package/dist/app-sidecar/mcp-shell-command.js +302 -0
- package/dist/app-sidecar/mcp-shell-command.js.map +1 -0
- package/dist/app-sidecar/mcp-sync.d.ts +18 -0
- package/dist/app-sidecar/mcp-sync.js +38 -0
- package/dist/app-sidecar/mcp-sync.js.map +1 -0
- package/dist/app-sidecar/prompt-routes.js +58 -30
- package/dist/app-sidecar/prompt-routes.js.map +1 -1
- package/dist/app-sidecar/route-context.d.ts +13 -2
- package/dist/app-sidecar/run-control-routes.js +17 -3
- package/dist/app-sidecar/run-control-routes.js.map +1 -1
- package/dist/app-sidecar/session-routes.js +8 -0
- package/dist/app-sidecar/session-routes.js.map +1 -1
- package/dist/app-sidecar/shell-routes.d.ts +12 -0
- package/dist/app-sidecar/shell-routes.js +140 -0
- package/dist/app-sidecar/shell-routes.js.map +1 -0
- package/dist/app-sidecar/shell-runs.d.ts +103 -0
- package/dist/app-sidecar/shell-runs.js +268 -0
- package/dist/app-sidecar/shell-runs.js.map +1 -0
- package/dist/app-sidecar/shell-suggestions.d.ts +33 -0
- package/dist/app-sidecar/shell-suggestions.js +152 -0
- package/dist/app-sidecar/shell-suggestions.js.map +1 -0
- package/dist/app-sidecar/task-routes.js +1 -1
- package/dist/app-sidecar/task-routes.js.map +1 -1
- package/dist/app-sidecar/usage.js +26 -2
- package/dist/app-sidecar/usage.js.map +1 -1
- package/dist/app-sidecar/workspace-routes.js +35 -37
- package/dist/app-sidecar/workspace-routes.js.map +1 -1
- package/dist/app-sidecar-sessions.js +13 -3
- package/dist/app-sidecar-sessions.js.map +1 -1
- package/dist/app-sidecar.js +365 -96
- package/dist/app-sidecar.js.map +1 -1
- package/dist/chat-agents/index.d.ts +1 -1
- package/dist/chat-agents/index.js +1 -1
- package/dist/chat-agents/index.js.map +1 -1
- package/dist/chat-agents/shared.d.ts +4 -0
- package/dist/chat-agents/shared.js +8 -1
- package/dist/chat-agents/shared.js.map +1 -1
- package/dist/cli/mcp.js +19 -5
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/shared.js +4 -0
- package/dist/cli/shared.js.map +1 -1
- package/dist/cli.js +41 -9
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +22 -2
- package/dist/config.js +42 -97
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session/mcp-tools.d.ts +17 -0
- package/dist/core/agent-session/mcp-tools.js +31 -0
- package/dist/core/agent-session/mcp-tools.js.map +1 -1
- package/dist/core/agent-session/verification-tracker.js +2 -10
- package/dist/core/agent-session/verification-tracker.js.map +1 -1
- package/dist/core/agent-session.d.ts +129 -11
- package/dist/core/agent-session.js +925 -171
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agents.d.ts +0 -10
- package/dist/core/agents.js +5 -1
- package/dist/core/agents.js.map +1 -1
- package/dist/core/ask-user.d.ts +8 -0
- package/dist/core/ask-user.js +28 -6
- package/dist/core/ask-user.js.map +1 -1
- package/dist/core/autopilot-gate.js +2 -3
- package/dist/core/autopilot-gate.js.map +1 -1
- package/dist/core/bundled-agents.js +9 -29
- package/dist/core/bundled-agents.js.map +1 -1
- package/dist/core/cache-diagnostics.d.ts +4 -0
- package/dist/core/cache-diagnostics.js +4 -1
- package/dist/core/cache-diagnostics.js.map +1 -1
- package/dist/core/cache-expiry.d.ts +2 -0
- package/dist/core/cache-expiry.js +6 -0
- package/dist/core/cache-expiry.js.map +1 -1
- package/dist/core/checklist-items.d.ts +2 -10
- package/dist/core/checklist-items.js +14 -10
- package/dist/core/checklist-items.js.map +1 -1
- package/dist/core/checklist-prompt.d.ts +1 -1
- package/dist/core/checklist-prompt.js +1 -1
- package/dist/core/checkpoint-store.d.ts +17 -0
- package/dist/core/checkpoint-store.js +72 -0
- package/dist/core/checkpoint-store.js.map +1 -1
- package/dist/core/claude-code/complete.d.ts +35 -0
- package/dist/core/claude-code/complete.js +115 -0
- package/dist/core/claude-code/complete.js.map +1 -0
- package/dist/core/claude-code/events.d.ts +65 -0
- package/dist/core/claude-code/events.js +434 -0
- package/dist/core/claude-code/events.js.map +1 -0
- package/dist/core/claude-code/live-session.d.ts +92 -0
- package/dist/core/claude-code/live-session.js +519 -0
- package/dist/core/claude-code/live-session.js.map +1 -0
- package/dist/core/claude-code/loop.d.ts +9 -0
- package/dist/core/claude-code/loop.js +15 -0
- package/dist/core/claude-code/loop.js.map +1 -0
- package/dist/core/claude-code/session-sync.d.ts +28 -0
- package/dist/core/claude-code/session-sync.js +53 -0
- package/dist/core/claude-code/session-sync.js.map +1 -0
- package/dist/core/claude-code/tool-bridge.d.ts +49 -0
- package/dist/core/claude-code/tool-bridge.js +352 -0
- package/dist/core/claude-code/tool-bridge.js.map +1 -0
- package/dist/core/claude-code/transcripts.d.ts +29 -0
- package/dist/core/claude-code/transcripts.js +117 -0
- package/dist/core/claude-code/transcripts.js.map +1 -0
- package/dist/core/claude-code-version.d.ts +1 -1
- package/dist/core/claude-code-version.js +1 -1
- package/dist/core/claude-code-version.js.map +1 -1
- package/dist/core/code-retrieval.d.ts +1 -1
- package/dist/core/code-retrieval.js +2 -2
- package/dist/core/code-retrieval.js.map +1 -1
- package/dist/core/codex-request-shape.js +1 -1
- package/dist/core/compaction/compactor.d.ts +27 -1
- package/dist/core/compaction/compactor.js +143 -9
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/plan-step-policy.d.ts +1 -1
- package/dist/core/compaction/plan-step-policy.js +1 -1
- package/dist/core/compaction/policy.d.ts +18 -0
- package/dist/core/compaction/policy.js +27 -7
- package/dist/core/compaction/policy.js.map +1 -1
- package/dist/core/compaction/tool-result-pruner.d.ts +20 -0
- package/dist/core/compaction/tool-result-pruner.js +25 -0
- package/dist/core/compaction/tool-result-pruner.js.map +1 -1
- package/dist/core/env-delta.d.ts +3 -3
- package/dist/core/env-delta.js +4 -5
- package/dist/core/env-delta.js.map +1 -1
- package/dist/core/extensions/plugin-bundles.d.ts +0 -9
- package/dist/core/extensions/plugin-bundles.js +0 -185
- package/dist/core/extensions/plugin-bundles.js.map +1 -1
- package/dist/core/goals-store.d.ts +9 -2
- package/dist/core/goals-store.js +111 -55
- package/dist/core/goals-store.js.map +1 -1
- package/dist/core/internal-diagnostics.d.ts +17 -0
- package/dist/core/internal-diagnostics.js +45 -0
- package/dist/core/internal-diagnostics.js.map +1 -1
- package/dist/core/language-detector.d.ts +2 -3
- package/dist/core/language-detector.js.map +1 -1
- package/dist/core/live-preview.d.ts +24 -0
- package/dist/core/live-preview.js +76 -0
- package/dist/core/live-preview.js.map +1 -0
- package/dist/core/local-endpoint-store.d.ts +4 -0
- package/dist/core/local-endpoint-store.js +31 -15
- package/dist/core/local-endpoint-store.js.map +1 -1
- package/dist/core/logger.d.ts +5 -0
- package/dist/core/logger.js +10 -2
- package/dist/core/logger.js.map +1 -1
- package/dist/core/lsp/edit-telemetry.js +3 -1
- package/dist/core/lsp/edit-telemetry.js.map +1 -1
- package/dist/core/lsp/manager.d.ts +15 -0
- package/dist/core/lsp/manager.js +31 -0
- package/dist/core/lsp/manager.js.map +1 -1
- package/dist/core/mcp/client.d.ts +9 -0
- package/dist/core/mcp/client.js +58 -5
- package/dist/core/mcp/client.js.map +1 -1
- package/dist/core/mcp/deferred-catalog.d.ts +1 -1
- package/dist/core/mcp/deferred-catalog.js +1 -1
- package/dist/core/mcp/oauth-provider.d.ts +7 -1
- package/dist/core/mcp/oauth-provider.js +11 -4
- package/dist/core/mcp/oauth-provider.js.map +1 -1
- package/dist/core/mcp/oauth-store.d.ts +6 -0
- package/dist/core/mcp/oauth-store.js +14 -0
- package/dist/core/mcp/oauth-store.js.map +1 -1
- package/dist/core/mcp/parse-add-command.d.ts +29 -3
- package/dist/core/mcp/parse-add-command.js +196 -26
- package/dist/core/mcp/parse-add-command.js.map +1 -1
- package/dist/core/mcp/store.d.ts +16 -0
- package/dist/core/mcp/store.js +28 -0
- package/dist/core/mcp/store.js.map +1 -1
- package/dist/core/mcp/types.d.ts +9 -0
- package/dist/core/nolan-ask-answer.d.ts +24 -0
- package/dist/core/nolan-ask-answer.js +96 -0
- package/dist/core/nolan-ask-answer.js.map +1 -0
- package/dist/core/nolan-context.d.ts +20 -0
- package/dist/core/nolan-context.js +55 -0
- package/dist/core/nolan-context.js.map +1 -1
- package/dist/core/nolan-prompt.js +6 -0
- package/dist/core/nolan-prompt.js.map +1 -1
- package/dist/core/opencode-catalog-store.d.ts +20 -0
- package/dist/core/opencode-catalog-store.js +82 -0
- package/dist/core/opencode-catalog-store.js.map +1 -0
- package/dist/core/openrouter-catalog-store.d.ts +24 -0
- package/dist/core/openrouter-catalog-store.js +140 -0
- package/dist/core/openrouter-catalog-store.js.map +1 -0
- package/dist/core/package-cooldown.d.ts +0 -2
- package/dist/core/package-cooldown.js +0 -4
- package/dist/core/package-cooldown.js.map +1 -1
- package/dist/core/plan-delta.d.ts +23 -0
- package/dist/core/plan-delta.js +36 -0
- package/dist/core/plan-delta.js.map +1 -0
- package/dist/core/process-gate.d.ts +17 -0
- package/dist/core/process-gate.js +24 -0
- package/dist/core/process-gate.js.map +1 -1
- package/dist/core/process-manager.d.ts +1 -1
- package/dist/core/process-manager.js +1 -1
- package/dist/core/project-discovery.js +2 -2
- package/dist/core/project-discovery.js.map +1 -1
- package/dist/core/project-files.js +1 -1
- package/dist/core/project-files.js.map +1 -1
- package/dist/core/prompt-commands.js +106 -107
- package/dist/core/prompt-commands.js.map +1 -1
- package/dist/core/radio-players.d.ts +28 -0
- package/dist/core/radio-players.js +133 -0
- package/dist/core/radio-players.js.map +1 -0
- package/dist/core/radio.js +20 -3
- package/dist/core/radio.js.map +1 -1
- package/dist/core/runtime-mode.d.ts +9 -8
- package/dist/core/runtime-mode.js +26 -0
- package/dist/core/runtime-mode.js.map +1 -1
- package/dist/core/session-history.d.ts +7 -0
- package/dist/core/session-history.js +48 -4
- package/dist/core/session-history.js.map +1 -1
- package/dist/core/session-manager.d.ts +10 -1
- package/dist/core/session-manager.js +48 -14
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-preview.js +2 -2
- package/dist/core/session-preview.js.map +1 -1
- package/dist/core/session-storage.d.ts +0 -2
- package/dist/core/session-storage.js +0 -2
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/session-summary-index.d.ts +18 -4
- package/dist/core/session-summary-index.js +28 -8
- package/dist/core/session-summary-index.js.map +1 -1
- package/dist/core/settings-manager.d.ts +9 -0
- package/dist/core/settings-manager.js +56 -8
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/shell-path.d.ts +2 -0
- package/dist/core/shell-path.js +10 -1
- package/dist/core/shell-path.js.map +1 -1
- package/dist/core/shell.d.ts +4 -0
- package/dist/core/shell.js +15 -1
- package/dist/core/shell.js.map +1 -1
- package/dist/core/skills.d.ts +10 -0
- package/dist/core/skills.js +20 -5
- package/dist/core/skills.js.map +1 -1
- package/dist/core/steering.d.ts +4 -0
- package/dist/core/steering.js +8 -1
- package/dist/core/steering.js.map +1 -1
- package/dist/core/stream-diag-level.d.ts +3 -0
- package/dist/core/stream-diag-level.js +24 -0
- package/dist/core/stream-diag-level.js.map +1 -0
- package/dist/core/subagent-manager.d.ts +11 -0
- package/dist/core/subagent-manager.js +16 -4
- package/dist/core/subagent-manager.js.map +1 -1
- package/dist/core/subagent-policy.d.ts +6 -0
- package/dist/core/subagent-policy.js +22 -3
- package/dist/core/subagent-policy.js.map +1 -1
- package/dist/core/subagent-receipt.d.ts +3 -3
- package/dist/core/subagent-receipt.js +6 -9
- package/dist/core/subagent-receipt.js.map +1 -1
- package/dist/core/task-store.d.ts +0 -1
- package/dist/core/task-store.js +0 -3
- package/dist/core/task-store.js.map +1 -1
- package/dist/core/trophies/catalog-more.js +16 -36
- package/dist/core/trophies/catalog-more.js.map +1 -1
- package/dist/core/trophies/catalog.js +3 -3
- package/dist/core/trophies/catalog.js.map +1 -1
- package/dist/core/trophies/engine.js +0 -4
- package/dist/core/trophies/engine.js.map +1 -1
- package/dist/core/trophies/types.d.ts +1 -1
- package/dist/core/trophies/types.js +0 -2
- package/dist/core/trophies/types.js.map +1 -1
- package/dist/core/user-shell-context.d.ts +8 -0
- package/dist/core/user-shell-context.js +12 -0
- package/dist/core/user-shell-context.js.map +1 -0
- package/dist/core/verify-commands.d.ts +1 -1
- package/dist/goals-agent/goal-team.js +3 -4
- package/dist/goals-agent/goal-team.js.map +1 -1
- package/dist/goals-agent/goals-agent.d.ts +1 -1
- package/dist/goals-agent/goals-agent.js +4 -3
- package/dist/goals-agent/goals-agent.js.map +1 -1
- package/dist/modes/acp-mode.d.ts +2 -2
- package/dist/modes/acp-mode.js +4 -5
- package/dist/modes/acp-mode.js.map +1 -1
- package/dist/modes/agent-home-mode.js +5 -5
- package/dist/modes/agent-home-mode.js.map +1 -1
- package/dist/modes/json-mode.js +5 -0
- package/dist/modes/json-mode.js.map +1 -1
- package/dist/modes/serve-mode.js +5 -5
- package/dist/modes/serve-mode.js.map +1 -1
- package/dist/motion-agent/motion-agent.d.ts +12 -5
- package/dist/motion-agent/motion-agent.js +24 -9
- package/dist/motion-agent/motion-agent.js.map +1 -1
- package/dist/motion-agent/motion-review.d.ts +0 -75
- package/dist/motion-agent/motion-review.js +0 -189
- package/dist/motion-agent/motion-review.js.map +1 -1
- package/dist/subagent-entry.d.ts +1 -0
- package/dist/subagent-entry.js +50 -0
- package/dist/subagent-entry.js.map +1 -0
- package/dist/system-prompt.d.ts +11 -4
- package/dist/system-prompt.js +38 -22
- package/dist/system-prompt.js.map +1 -1
- package/dist/test-support/system-tools.d.ts +6 -0
- package/dist/test-support/system-tools.js +36 -0
- package/dist/test-support/system-tools.js.map +1 -0
- package/dist/tools/ask-user.js +5 -3
- package/dist/tools/ask-user.js.map +1 -1
- package/dist/tools/bash.d.ts +9 -2
- package/dist/tools/bash.js +382 -362
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/checklist.js +6 -11
- package/dist/tools/checklist.js.map +1 -1
- package/dist/tools/debug.js +6 -9
- package/dist/tools/debug.js.map +1 -1
- package/dist/tools/document-text.d.ts +6 -0
- package/dist/tools/document-text.js +154 -0
- package/dist/tools/document-text.js.map +1 -0
- package/dist/tools/enter-plan.js +4 -7
- package/dist/tools/enter-plan.js.map +1 -1
- package/dist/tools/find.d.ts +9 -0
- package/dist/tools/find.js +38 -1
- package/dist/tools/find.js.map +1 -1
- package/dist/tools/generate-image.d.ts +18 -0
- package/dist/tools/generate-image.js +208 -17
- package/dist/tools/generate-image.js.map +1 -1
- package/dist/tools/goals.d.ts +2 -2
- package/dist/tools/index.d.ts +5 -2
- package/dist/tools/index.js +5 -13
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/live-preview.d.ts +21 -0
- package/dist/tools/live-preview.js +37 -0
- package/dist/tools/live-preview.js.map +1 -0
- package/dist/tools/operations.js +1 -1
- package/dist/tools/operations.js.map +1 -1
- package/dist/tools/overflow.d.ts +2 -0
- package/dist/tools/overflow.js +10 -0
- package/dist/tools/overflow.js.map +1 -1
- package/dist/tools/path-utils.d.ts +0 -15
- package/dist/tools/path-utils.js +0 -17
- package/dist/tools/path-utils.js.map +1 -1
- package/dist/tools/prompt-hints.d.ts +2 -0
- package/dist/tools/prompt-hints.js +16 -9
- package/dist/tools/prompt-hints.js.map +1 -1
- package/dist/tools/read.js +25 -10
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/routine-output.d.ts +10 -1
- package/dist/tools/routine-output.js +79 -1
- package/dist/tools/routine-output.js.map +1 -1
- package/dist/tools/screenshot.js +6 -10
- package/dist/tools/screenshot.js.map +1 -1
- package/dist/tools/side-web-search.d.ts +35 -0
- package/dist/tools/side-web-search.js +147 -0
- package/dist/tools/side-web-search.js.map +1 -0
- package/dist/tools/skill.d.ts +2 -0
- package/dist/tools/skill.js +33 -6
- package/dist/tools/skill.js.map +1 -1
- package/dist/tools/steroids.d.ts +7 -6
- package/dist/tools/steroids.js +193 -87
- package/dist/tools/steroids.js.map +1 -1
- package/dist/tools/subagent-control.js +66 -10
- package/dist/tools/subagent-control.js.map +1 -1
- package/dist/tools/subagent-shared.d.ts +19 -2
- package/dist/tools/subagent-shared.js +35 -10
- package/dist/tools/subagent-shared.js.map +1 -1
- package/dist/tools/subagent.js +23 -7
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/tool-search.js +7 -1
- package/dist/tools/tool-search.js.map +1 -1
- package/dist/tools/tool-tiers.d.ts +3 -2
- package/dist/tools/tool-tiers.js +7 -5
- package/dist/tools/tool-tiers.js.map +1 -1
- package/dist/tools/truncate.d.ts +0 -2
- package/dist/tools/truncate.js +4 -10
- package/dist/tools/truncate.js.map +1 -1
- package/dist/tools/web-fetch.d.ts +15 -1
- package/dist/tools/web-fetch.js +138 -21
- package/dist/tools/web-fetch.js.map +1 -1
- package/dist/tools/web-search.d.ts +3 -2
- package/dist/tools/web-search.js +25 -1
- package/dist/tools/web-search.js.map +1 -1
- package/dist/ui/App.js +37 -38
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/app-items.d.ts +0 -2
- package/dist/ui/app-items.js +0 -2
- package/dist/ui/app-items.js.map +1 -1
- package/dist/ui/components/Footer.js +8 -5
- package/dist/ui/components/Footer.js.map +1 -1
- package/dist/ui/components/ModelSelector.js +2 -0
- package/dist/ui/components/ModelSelector.js.map +1 -1
- package/dist/ui/components/SkillsOverlay.js +2 -1
- package/dist/ui/components/SkillsOverlay.js.map +1 -1
- package/dist/ui/constants/figures.d.ts +0 -8
- package/dist/ui/constants/figures.js +0 -8
- package/dist/ui/constants/figures.js.map +1 -1
- package/dist/ui/hooks/useAgentLoop.d.ts +3 -0
- package/dist/ui/hooks/useAgentLoop.js +54 -4
- package/dist/ui/hooks/useAgentLoop.js.map +1 -1
- package/dist/ui/hooks/useContextCompaction.js +1 -0
- package/dist/ui/hooks/useContextCompaction.js.map +1 -1
- package/dist/ui/language-pack-update.d.ts +25 -0
- package/dist/ui/language-pack-update.js +19 -0
- package/dist/ui/language-pack-update.js.map +1 -0
- package/dist/ui/layout-decisions.d.ts +0 -5
- package/dist/ui/layout-decisions.js +1 -10
- package/dist/ui/layout-decisions.js.map +1 -1
- package/dist/ui/terminal-history-status-renderers.d.ts +0 -1
- package/dist/ui/terminal-history-status-renderers.js +0 -12
- package/dist/ui/terminal-history-status-renderers.js.map +1 -1
- package/dist/ui/terminal-history.js +3 -1
- package/dist/ui/terminal-history.js.map +1 -1
- package/dist/ui/transcript/presentation.d.ts +1 -2
- package/dist/ui/transcript/presentation.js +0 -4
- package/dist/ui/transcript/presentation.js.map +1 -1
- package/dist/utils/http-body.d.ts +5 -0
- package/dist/utils/http-body.js +5 -0
- package/dist/utils/http-body.js.map +1 -1
- package/dist/utils/image.d.ts +11 -4
- package/dist/utils/image.js +34 -11
- package/dist/utils/image.js.map +1 -1
- package/dist/utils/plan-steps.d.ts +1 -0
- package/dist/utils/plan-steps.js +10 -0
- package/dist/utils/plan-steps.js.map +1 -1
- package/dist/utils/prompt-enhancer.d.ts +3 -1
- package/dist/utils/prompt-enhancer.js +21 -16
- package/dist/utils/prompt-enhancer.js.map +1 -1
- package/dist/web.d.ts +5 -0
- package/dist/web.js +5 -0
- package/dist/web.js.map +1 -0
- package/package.json +27 -6
- package/assets/skills/clarify/SKILL.md +0 -39
- package/assets/skills/code-review/SKILL.md +0 -88
- package/assets/skills/code-review/references/agent-diffs.md +0 -27
- package/assets/skills/code-review/references/tests.md +0 -19
- package/assets/skills/evidence-led-ui/LICENSES.md +0 -80
- package/assets/skills/evidence-led-ui/SKILL.md +0 -100
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/LICENSE +0 -21
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/airbnb/DESIGN.md +0 -545
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/airtable/DESIGN.md +0 -554
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/apple/DESIGN.md +0 -562
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/binance/DESIGN.md +0 -634
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/bmw/DESIGN.md +0 -544
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/bmw-m/DESIGN.md +0 -503
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/bugatti/DESIGN.md +0 -454
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/cal/DESIGN.md +0 -542
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/claude/DESIGN.md +0 -589
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/clay/DESIGN.md +0 -541
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/clickhouse/DESIGN.md +0 -544
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/cohere/DESIGN.md +0 -451
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/coinbase/DESIGN.md +0 -570
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/composio/DESIGN.md +0 -506
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/cursor/DESIGN.md +0 -537
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/dell-1996/DESIGN.md +0 -632
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/elevenlabs/DESIGN.md +0 -504
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/expo/DESIGN.md +0 -526
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/ferrari/DESIGN.md +0 -531
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/figma/DESIGN.md +0 -578
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/framer/DESIGN.md +0 -544
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/hashicorp/DESIGN.md +0 -575
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/hp/DESIGN.md +0 -670
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/ibm/DESIGN.md +0 -550
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/intercom/DESIGN.md +0 -546
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/kraken/DESIGN.md +0 -125
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/lamborghini/DESIGN.md +0 -288
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/linear.app/DESIGN.md +0 -548
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/lovable/DESIGN.md +0 -298
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mastercard/DESIGN.md +0 -365
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/meta/DESIGN.md +0 -683
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/minimax/DESIGN.md +0 -746
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mintlify/DESIGN.md +0 -852
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/miro/DESIGN.md +0 -825
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mistral.ai/DESIGN.md +0 -773
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/mongodb/DESIGN.md +0 -767
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/nike/DESIGN.md +0 -575
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/nintendo-2001/DESIGN.md +0 -649
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/notion/DESIGN.md +0 -821
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/nvidia/DESIGN.md +0 -640
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/ollama/DESIGN.md +0 -539
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/opencode.ai/DESIGN.md +0 -521
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/pinterest/DESIGN.md +0 -597
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/playstation/DESIGN.md +0 -661
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/posthog/DESIGN.md +0 -690
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/raycast/DESIGN.md +0 -669
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/renault/DESIGN.md +0 -589
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/replicate/DESIGN.md +0 -616
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/resend/DESIGN.md +0 -585
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/revolut/DESIGN.md +0 -636
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/runwayml/DESIGN.md +0 -244
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/sanity/DESIGN.md +0 -357
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/sentry/DESIGN.md +0 -551
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/shopify/DESIGN.md +0 -516
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/slack/DESIGN.md +0 -482
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/spacex/DESIGN.md +0 -363
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/spotify/DESIGN.md +0 -246
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/starbucks/DESIGN.md +0 -580
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/stripe/DESIGN.md +0 -487
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/supabase/DESIGN.md +0 -462
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/superhuman/DESIGN.md +0 -448
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/tesla/DESIGN.md +0 -286
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/theverge/DESIGN.md +0 -339
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/together.ai/DESIGN.md +0 -633
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/uber/DESIGN.md +0 -636
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/vercel/DESIGN.md +0 -736
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/vodafone/DESIGN.md +0 -538
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/voltagent/DESIGN.md +0 -521
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/warp/DESIGN.md +0 -526
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/webflow/DESIGN.md +0 -588
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/wired/DESIGN.md +0 -497
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/wise/DESIGN.md +0 -544
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/x.ai/DESIGN.md +0 -465
- package/assets/skills/evidence-led-ui/corpus/awesome-design-md/design-md/zapier/DESIGN.md +0 -537
- package/assets/skills/evidence-led-ui/data/corpus-manifest.json +0 -768
- package/assets/skills/evidence-led-ui/data/observations.json +0 -47053
- package/assets/skills/evidence-led-ui/references/anti-defaults.md +0 -110
- package/assets/skills/evidence-led-ui/references/archetypes.md +0 -97
- package/assets/skills/evidence-led-ui/references/craft-rulings.md +0 -242
- package/assets/skills/evidence-led-ui/references/direction.md +0 -124
- package/assets/skills/evidence-led-ui/references/methodology.md +0 -72
- package/assets/skills/evidence-led-ui/references/observed-patterns.md +0 -68
- package/assets/skills/evidence-led-ui/references/production-contract.md +0 -148
- package/assets/skills/evidence-led-ui/references/provenance.md +0 -142
- package/assets/skills/evidence-led-ui/references/quality-rubric.md +0 -126
- package/assets/skills/evidence-led-ui/references/ui-libraries.md +0 -30
- package/assets/skills/refactoring/SKILL.md +0 -87
- package/assets/skills/refactoring/references/agent-pitfalls.md +0 -46
- package/assets/skills/refactoring/references/legacy.md +0 -70
- package/assets/skills/refactoring/references/smells.md +0 -71
- package/assets/skills/root-cause/SKILL.md +0 -46
- package/assets/skills/shared-language/SKILL.md +0 -32
- package/assets/skills/tdd/SKILL.md +0 -42
- package/dist/core/setup-history.d.ts +0 -6
- package/dist/core/setup-history.js +0 -55
- package/dist/core/setup-history.js.map +0 -1
- package/dist/core/style-packs/index.d.ts +0 -18
- package/dist/core/style-packs/index.js +0 -60
- package/dist/core/style-packs/index.js.map +0 -1
- package/dist/core/style-packs/packs.d.ts +0 -8
- package/dist/core/style-packs/packs.js +0 -188
- package/dist/core/style-packs/packs.js.map +0 -1
- package/dist/interactive.d.ts +0 -2
- package/dist/interactive.js +0 -257
- package/dist/interactive.js.map +0 -1
- package/dist/motion-agent/motion-review-coverage.d.ts +0 -12
- package/dist/motion-agent/motion-review-coverage.js +0 -33
- package/dist/motion-agent/motion-review-coverage.js.map +0 -1
- package/dist/motion-agent/motion-review-gate.d.ts +0 -48
- package/dist/motion-agent/motion-review-gate.js +0 -88
- package/dist/motion-agent/motion-review-gate.js.map +0 -1
- package/dist/motion-agent/motion-review-session.d.ts +0 -65
- package/dist/motion-agent/motion-review-session.js +0 -422
- package/dist/motion-agent/motion-review-session.js.map +0 -1
- package/dist/tools/code-nav.d.ts +0 -29
- package/dist/tools/code-nav.js +0 -299
- package/dist/tools/code-nav.js.map +0 -1
- package/dist/tools/code-skeleton.d.ts +0 -28
- package/dist/tools/code-skeleton.js +0 -115
- package/dist/tools/code-skeleton.js.map +0 -1
- package/dist/tools/search-code.d.ts +0 -10
- package/dist/tools/search-code.js +0 -90
- package/dist/tools/search-code.js.map +0 -1
- package/dist/ui/stores/index.d.ts +0 -2
- package/dist/ui/stores/index.js +0 -3
- package/dist/ui/stores/index.js.map +0 -1
- package/dist/utils/format.d.ts +0 -16
- package/dist/utils/format.js +0 -159
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/shell.d.ts +0 -2
- package/dist/utils/shell.js +0 -8
- package/dist/utils/shell.js.map +0 -1
package/dist/tools/bash.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { killProcessTree } from "../utils/process.js";
|
|
3
|
-
import { truncateTail,
|
|
3
|
+
import { truncateTail, MAX_LINES, describeCompressed } from "./truncate.js";
|
|
4
4
|
import { compressToolOutput } from "./compress.js";
|
|
5
|
-
import { compactRoutineOutput } from "./routine-output.js";
|
|
5
|
+
import { cleanTerminalOutput, compactProgressRuns, compactRoutineOutput, } from "./routine-output.js";
|
|
6
6
|
import { writeOverflow } from "./overflow.js";
|
|
7
7
|
import { localOperations } from "./operations.js";
|
|
8
8
|
import { getSafeToolEnv } from "./safe-env.js";
|
|
@@ -27,8 +27,8 @@ function sandboxAwareEnv(sandboxed, cooldown = {}) {
|
|
|
27
27
|
return sandboxed ? { ...env, ...SANDBOX_ENV_PATCH } : env;
|
|
28
28
|
}
|
|
29
29
|
const DEFAULT_TIMEOUT = 120_000; // 120 seconds
|
|
30
|
-
/**
|
|
31
|
-
export const
|
|
30
|
+
/** Appended when `review` was set on a command that cannot carry one; the command itself still ran. */
|
|
31
|
+
export const REVIEW_SKIPPED_NOTE = "Review skipped: it runs only after a command that is just the final check, in the foreground. The command above ran normally.";
|
|
32
32
|
const AUTO_BACKGROUND_RE = /^Still running after \d+(?:\.\d+)?s, so it was moved to the background\b/;
|
|
33
33
|
/**
|
|
34
34
|
* Background process id when a bash result reports that a foreground command
|
|
@@ -72,6 +72,13 @@ function killLeftoverGroup(pid) {
|
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Bash output over this many bytes is offloaded and shown compressed — Claude
|
|
77
|
+
* Code's inline limit (BASH_MAX_OUTPUT_LENGTH default 30,000). At the old 50KB,
|
|
78
|
+
* `cat` of whole source files came back verbatim and stayed in every later
|
|
79
|
+
* request (agent-race, 2026-11-04).
|
|
80
|
+
*/
|
|
81
|
+
export const BASH_INLINE_MAX_BYTES = 30_000;
|
|
75
82
|
/** A sleep at least this long is a guess at when something finishes, not a
|
|
76
83
|
* settle pause before poking a service that is already up. */
|
|
77
84
|
const GUESSED_WAIT_SECONDS = 10;
|
|
@@ -105,19 +112,24 @@ function isGoalModeRef(value) {
|
|
|
105
112
|
* paired trials, 2026-10-18).
|
|
106
113
|
*/
|
|
107
114
|
export async function renderBashOutput(rawOutput) {
|
|
108
|
-
|
|
115
|
+
// ANSI codes and \r redraws never mean anything in a tool result; runs of
|
|
116
|
+
// installer/build progress lines collapse to first + count + last. Error
|
|
117
|
+
// lines are never touched (routine-output.ts).
|
|
118
|
+
const cleaned = cleanTerminalOutput(rawOutput);
|
|
119
|
+
const shown = compactProgressRuns(cleaned);
|
|
120
|
+
const result = truncateTail(shown, MAX_LINES, BASH_INLINE_MAX_BYTES);
|
|
109
121
|
// Under the limit: drop routine boilerplate (git log/status labels, ls
|
|
110
122
|
// owner columns, green per-file test lines) — see routine-output.ts.
|
|
111
123
|
if (!result.truncated)
|
|
112
124
|
return compactRoutineOutput(result.content);
|
|
113
|
-
const overflowPath = Buffer.byteLength(
|
|
114
|
-
? await writeOverflow(
|
|
125
|
+
const overflowPath = Buffer.byteLength(shown, "utf-8") > BASH_INLINE_MAX_BYTES
|
|
126
|
+
? await writeOverflow(cleaned, "bash").catch(() => null)
|
|
115
127
|
: null;
|
|
116
128
|
const overflowNotice = overflowPath
|
|
117
129
|
? ` Full output saved to ${overflowPath} — read it with offset/limit if needed.`
|
|
118
130
|
: "";
|
|
119
|
-
const c = compressToolOutput(
|
|
120
|
-
const what = describeCompressed(
|
|
131
|
+
const c = compressToolOutput(shown);
|
|
132
|
+
const what = describeCompressed(shown, c.content);
|
|
121
133
|
return `[${c.notice}${what ? ` ${what}` : ""}${overflowNotice}]\n${c.content}`;
|
|
122
134
|
}
|
|
123
135
|
const BashParams = z.object({
|
|
@@ -170,377 +182,385 @@ getPackageCooldownDays = () => 2) {
|
|
|
170
182
|
? "Run a Windows cmd.exe command (no bash on this system) in the project root. Use cmd " +
|
|
171
183
|
"syntax (dir, findstr, type); POSIX commands and $(...) fail. Output tail is kept."
|
|
172
184
|
: "Run a non-interactive bash command (TERM=dumb, pipefail) in the project root.";
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
(persist ||
|
|
187
|
-
run_in_background ||
|
|
188
|
-
ops !== localOperations ||
|
|
189
|
-
!classifyVerificationCommand(command).accepted)) {
|
|
190
|
-
return REVIEW_REJECTED_BEFORE_START;
|
|
191
|
-
}
|
|
192
|
-
if (wake && !run_in_background) {
|
|
193
|
-
return "Error: wake conditions require run_in_background=true — there is nothing to watch on a foreground call.";
|
|
194
|
-
}
|
|
195
|
-
let wakeRules;
|
|
196
|
-
if (wake?.pattern) {
|
|
197
|
-
try {
|
|
198
|
-
// No flags: lastIndex-free exec/test keeps the watcher's scans pure.
|
|
199
|
-
wakeRules = { pattern: new RegExp(wake.pattern) };
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
return `Error: wake.pattern is not a valid regex (${error.message}). Fix the pattern and retry.`;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (wake?.silence_seconds) {
|
|
206
|
-
wakeRules = { ...wakeRules, silenceMs: wake.silence_seconds * 1000 };
|
|
207
|
-
}
|
|
208
|
-
// A long sleep-only foreground call while something runs in the
|
|
209
|
-
// background is a guessed wait: too short wastes a turn, too long wastes
|
|
210
|
-
// wall-clock. Redirect rather than run it — descriptions alone do not
|
|
211
|
-
// reliably beat the habit. Brief sleeps stay allowed, because letting a
|
|
212
|
-
// just-started dev server settle before curling it is legitimate and no
|
|
213
|
-
// exit is ever coming for it.
|
|
214
|
-
const napSeconds = run_in_background ? null : sleepOnlySeconds(command);
|
|
215
|
-
if (napSeconds !== null && napSeconds >= GUESSED_WAIT_SECONDS) {
|
|
216
|
-
const running = processManager.list().filter((proc) => proc.exitCode === null);
|
|
217
|
-
if (running.length > 0) {
|
|
218
|
-
const ids = running.map((proc) => proc.id).join(", ");
|
|
219
|
-
return (`Error: refusing to sleep ${napSeconds}s while ${running.length} background ` +
|
|
220
|
-
`process(es) are running (${ids}). Sleeping guesses at a finish time. Call ` +
|
|
221
|
-
`task_output with wait_ms instead \u2014 it returns on exit or a declared wake. ` +
|
|
222
|
-
`For something that never exits, such as a dev server, run it with a wake ` +
|
|
223
|
-
`pattern and wait for that line.`);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (isPlanModeActive(planModeRef) && !isReadOnlyCommand(command)) {
|
|
227
|
-
return planModeRestriction("bash");
|
|
228
|
-
}
|
|
229
|
-
// Catastrophic-command guard — enforced in code, before every execution
|
|
230
|
-
// path (persistent shell, background, and normal spawn).
|
|
231
|
-
const catastrophic = isCatastrophicCommand(command, cwd);
|
|
232
|
-
if (catastrophic) {
|
|
233
|
-
return `Error: ${catastrophic}`;
|
|
234
|
-
}
|
|
235
|
-
// Destructive-git guard — refuses reset --hard / checkout -- / restore /
|
|
236
|
-
// clean -f / stash drop / branch -D / force push when work would be lost.
|
|
237
|
-
// A persist:true call runs wherever the session shell last cd'd to.
|
|
238
|
-
const liveShell = persist && process.platform !== "win32" ? sessionShell : null;
|
|
239
|
-
const gitBlocked = await checkDestructiveGit(command, {
|
|
240
|
-
cwd,
|
|
241
|
-
resolveCwd: liveShell && !liveShell.isBusy
|
|
242
|
-
? async () => (await liveShell.run("pwd", 2_000, context.signal)).output.trim() || null
|
|
243
|
-
: undefined,
|
|
244
|
-
});
|
|
245
|
-
if (gitBlocked) {
|
|
246
|
-
return `Error: ${gitBlocked}`;
|
|
247
|
-
}
|
|
248
|
-
// Shell-threat guard — pipe-to-shell, reverse shells, secret exfiltration,
|
|
249
|
-
// lookalike hosts and terminal-escape tricks (core/shell-threats.ts).
|
|
250
|
-
const threatBlocked = shellThreatBlockMessage(command);
|
|
251
|
-
if (threatBlocked) {
|
|
252
|
-
return `Error: ${threatBlocked}`;
|
|
185
|
+
const runBash = async ({ command, timeout: timeoutMs, run_in_background, persist, wake, review }, context) => {
|
|
186
|
+
const goalModeRestriction = goalModeBashRestriction(getActiveGoalMode(goalModeRef), run_in_background === true);
|
|
187
|
+
if (goalModeRestriction) {
|
|
188
|
+
return goalModeRestriction;
|
|
189
|
+
}
|
|
190
|
+
if (wake && !run_in_background) {
|
|
191
|
+
return "Error: wake conditions require run_in_background=true — there is nothing to watch on a foreground call.";
|
|
192
|
+
}
|
|
193
|
+
let wakeRules;
|
|
194
|
+
if (wake?.pattern) {
|
|
195
|
+
try {
|
|
196
|
+
// No flags: lastIndex-free exec/test keeps the watcher's scans pure.
|
|
197
|
+
wakeRules = { pattern: new RegExp(wake.pattern) };
|
|
253
198
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// typosquats. A catch is a block; network only for installs, fail-open.
|
|
257
|
-
const cooldownDays = getPackageCooldownDays();
|
|
258
|
-
// Version detection starts now, in parallel with the check (shared, once per process).
|
|
259
|
-
const install = mayInstall(command);
|
|
260
|
-
const versionsReady = install
|
|
261
|
-
? detectMentionedVersions(command, cwd)
|
|
262
|
-
: Promise.resolve({});
|
|
263
|
-
const packageThreats = install
|
|
264
|
-
? await checkPackageInstall(command, { signal: context.signal, cwd, cooldownDays })
|
|
265
|
-
: [];
|
|
266
|
-
const packageBlocked = packageBlockMessage(packageThreats);
|
|
267
|
-
if (packageBlocked) {
|
|
268
|
-
// `details` carries the refused packages to the session, which records
|
|
269
|
-
// them in the project's "don't install" list (core/blocked-packages-file.ts).
|
|
270
|
-
const blocked = packageThreats.flatMap((t) => t.blocked ?? []);
|
|
271
|
-
return {
|
|
272
|
-
content: `Error: ${packageBlocked}`,
|
|
273
|
-
...(blocked.length > 0 ? { details: { safetyBlock: { packages: blocked } } } : {}),
|
|
274
|
-
};
|
|
199
|
+
catch (error) {
|
|
200
|
+
return `Error: wake.pattern is not a valid regex (${error.message}). Fix the pattern and retry.`;
|
|
275
201
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
|
|
202
|
+
}
|
|
203
|
+
if (wake?.silence_seconds) {
|
|
204
|
+
wakeRules = { ...wakeRules, silenceMs: wake.silence_seconds * 1000 };
|
|
205
|
+
}
|
|
206
|
+
// A long sleep-only foreground call while something runs in the
|
|
207
|
+
// background is a guessed wait: too short wastes a turn, too long wastes
|
|
208
|
+
// wall-clock. Redirect rather than run it — descriptions alone do not
|
|
209
|
+
// reliably beat the habit. Brief sleeps stay allowed, because letting a
|
|
210
|
+
// just-started dev server settle before curling it is legitimate and no
|
|
211
|
+
// exit is ever coming for it.
|
|
212
|
+
const napSeconds = run_in_background ? null : sleepOnlySeconds(command);
|
|
213
|
+
if (napSeconds !== null && napSeconds >= GUESSED_WAIT_SECONDS) {
|
|
214
|
+
const running = processManager.list().filter((proc) => proc.exitCode === null);
|
|
215
|
+
if (running.length > 0) {
|
|
216
|
+
const ids = running.map((proc) => proc.id).join(", ");
|
|
217
|
+
return (`Error: refusing to sleep ${napSeconds}s while ${running.length} background ` +
|
|
218
|
+
`process(es) are running (${ids}). Sleeping guesses at a finish time. Call ` +
|
|
219
|
+
`task_output with wait_ms instead \u2014 it returns on exit or a declared wake. ` +
|
|
220
|
+
`For something that never exits, such as a dev server, run it with a wake ` +
|
|
221
|
+
`pattern and wait for that line.`);
|
|
291
222
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
223
|
+
}
|
|
224
|
+
if (isPlanModeActive(planModeRef) && !isReadOnlyCommand(command)) {
|
|
225
|
+
return planModeRestriction("bash");
|
|
226
|
+
}
|
|
227
|
+
// Catastrophic-command guard — enforced in code, before every execution
|
|
228
|
+
// path (persistent shell, background, and normal spawn).
|
|
229
|
+
const catastrophic = isCatastrophicCommand(command, cwd);
|
|
230
|
+
if (catastrophic) {
|
|
231
|
+
return `Error: ${catastrophic}`;
|
|
232
|
+
}
|
|
233
|
+
// Destructive-git guard — refuses reset --hard / checkout -- / restore /
|
|
234
|
+
// clean -f / stash drop / branch -D / force push when work would be lost.
|
|
235
|
+
// A persist:true call runs wherever the session shell last cd'd to.
|
|
236
|
+
const liveShell = persist && process.platform !== "win32" ? sessionShell : null;
|
|
237
|
+
const gitBlocked = await checkDestructiveGit(command, {
|
|
238
|
+
cwd,
|
|
239
|
+
resolveCwd: liveShell && !liveShell.isBusy
|
|
240
|
+
? async () => (await liveShell.run("pwd", 2_000, context.signal)).output.trim() || null
|
|
241
|
+
: undefined,
|
|
242
|
+
});
|
|
243
|
+
if (gitBlocked) {
|
|
244
|
+
return `Error: ${gitBlocked}`;
|
|
245
|
+
}
|
|
246
|
+
// Shell-threat guard — pipe-to-shell, reverse shells, secret exfiltration,
|
|
247
|
+
// lookalike hosts and terminal-escape tricks (core/shell-threats.ts).
|
|
248
|
+
const threatBlocked = shellThreatBlockMessage(command);
|
|
249
|
+
if (threatBlocked) {
|
|
250
|
+
return `Error: ${threatBlocked}`;
|
|
251
|
+
}
|
|
252
|
+
// Package-install guard: known malware (local feed + version-aware OSV),
|
|
253
|
+
// lockfile contents, provenance downgrade, release age and precise
|
|
254
|
+
// typosquats. A catch is a block; network only for installs, fail-open.
|
|
255
|
+
const cooldownDays = getPackageCooldownDays();
|
|
256
|
+
// Version detection starts now, in parallel with the check (shared, once per process).
|
|
257
|
+
const install = mayInstall(command);
|
|
258
|
+
const versionsReady = install
|
|
259
|
+
? detectMentionedVersions(command, cwd)
|
|
260
|
+
: Promise.resolve({});
|
|
261
|
+
const packageThreats = install
|
|
262
|
+
? await checkPackageInstall(command, { signal: context.signal, cwd, cooldownDays })
|
|
263
|
+
: [];
|
|
264
|
+
const packageBlocked = packageBlockMessage(packageThreats);
|
|
265
|
+
if (packageBlocked) {
|
|
266
|
+
// `details` carries the refused packages to the session, which records
|
|
267
|
+
// them in the project's "don't install" list (core/blocked-packages-file.ts).
|
|
268
|
+
const blocked = packageThreats.flatMap((t) => t.blocked ?? []);
|
|
269
|
+
return {
|
|
270
|
+
content: `Error: ${packageBlocked}`,
|
|
271
|
+
...(blocked.length > 0 ? { details: { safetyBlock: { packages: blocked } } } : {}),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
// Native release-age cooldown for every install (transitive deps too).
|
|
275
|
+
const versions = await versionsReady;
|
|
276
|
+
const cooldownEnv = install
|
|
277
|
+
? packageCooldownEnv(command, { days: cooldownDays, now: Date.now(), cwd, versions })
|
|
278
|
+
: {};
|
|
279
|
+
// bun has no env setting: the cooldown goes in as a flag.
|
|
280
|
+
const runCommand = install
|
|
281
|
+
? bunCooldownCommand(command, cooldownDays, versions.bun ?? null)
|
|
282
|
+
: command;
|
|
283
|
+
// Network allowlist — defence in depth only. Recognises the common egress
|
|
284
|
+
// command shapes; an unrecognised command is never blocked (see
|
|
285
|
+
// core/network-guard.ts for why this is not a sandbox).
|
|
286
|
+
const networkBlocked = checkCommandPolicy(command, getNetworkPolicy);
|
|
287
|
+
if (networkBlocked) {
|
|
288
|
+
return `Error: ${networkBlocked}`;
|
|
289
|
+
}
|
|
290
|
+
const sandboxPolicy = getSandboxPolicy?.() ?? { mode: "off", allowedDomains: [] };
|
|
291
|
+
const prepareLaunch = async (shell) => prepareSandboxLaunch(shell, cwd, sandboxPolicy);
|
|
292
|
+
// Persistent session mode — POSIX only; Windows-without-bash falls through
|
|
293
|
+
// to the normal spawn path (cmd.exe fallback) below.
|
|
294
|
+
if (persist && !run_in_background && !resolveShell(command, shellOpts).isCmdFallback) {
|
|
295
|
+
const sandboxKey = JSON.stringify(sandboxPolicy);
|
|
296
|
+
if (sessionShell && sessionSandboxKey !== sandboxKey) {
|
|
297
|
+
sessionShell.kill();
|
|
298
|
+
sessionShell = null;
|
|
338
299
|
}
|
|
339
|
-
if (
|
|
340
|
-
let launch;
|
|
300
|
+
if (!sessionShell) {
|
|
341
301
|
try {
|
|
342
|
-
|
|
302
|
+
const shell = resolveShell("", shellOpts);
|
|
303
|
+
const launch = await prepareLaunch({
|
|
304
|
+
...shell,
|
|
305
|
+
args: ["--norc", "--noprofile", "-o", "pipefail"],
|
|
306
|
+
});
|
|
307
|
+
sessionShell = new PersistentShell(cwd,
|
|
308
|
+
// Env is fixed at shell start: only pip's (always safe) here;
|
|
309
|
+
// the others are scoped per command below.
|
|
310
|
+
sandboxAwareEnv(launch.sandboxed, cooldownDays > 0 ? { PIP_UPLOADED_PRIOR_TO: `P${cooldownDays}D` } : {}), MAX_OUTPUT_BYTES, shellOpts, launch);
|
|
311
|
+
sessionSandboxKey = sandboxKey;
|
|
312
|
+
sessionSandboxed = launch.sandboxed;
|
|
343
313
|
}
|
|
344
314
|
catch (error) {
|
|
345
315
|
return `Error: OS sandbox unavailable; command was not run: ${error.message}`;
|
|
346
316
|
}
|
|
347
|
-
if (context.signal.aborted)
|
|
348
|
-
return CANCELLED_BEFORE_START;
|
|
349
|
-
const result = await processManager.start(runCommand, cwd, launch, wakeRules, cooldownEnv);
|
|
350
|
-
const watchWarnings = backgroundWatchWarnings(command);
|
|
351
|
-
return (`Background process started.\n` +
|
|
352
|
-
`ID: ${result.id}\n` +
|
|
353
|
-
`PID: ${result.pid}\n` +
|
|
354
|
-
`Log: ${result.logFile}\n` +
|
|
355
|
-
(wakeRules
|
|
356
|
-
? result.wakeArmed
|
|
357
|
-
? `Wake rules armed: ${[
|
|
358
|
-
wakeRules.pattern ? `pattern /${wakeRules.pattern.source}/` : null,
|
|
359
|
-
wakeRules.silenceMs ? `silence ${wakeRules.silenceMs / 1000}s` : null,
|
|
360
|
-
]
|
|
361
|
-
.filter(Boolean)
|
|
362
|
-
.join(" + ")}. You will be notified automatically when one fires or the process exits.\n`
|
|
363
|
-
: `Wake conditions were NOT armed: this session has no notification path, so nothing will wake you automatically. Poll task_output periodically instead.\n`
|
|
364
|
-
: "") +
|
|
365
|
-
`Use task_output with id="${result.id}" to read output, ` +
|
|
366
|
-
`task_send to type input/answer prompts, task_stop to stop it.` +
|
|
367
|
-
watchWarnings.map((warning) => `\nWarning: ${warning}`).join(""));
|
|
368
317
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
318
|
+
if (context.signal.aborted)
|
|
319
|
+
return CANCELLED_BEFORE_START;
|
|
320
|
+
const res = await sessionShell.run(scopeCooldown(runCommand, cooldownEnv), timeoutMs ?? DEFAULT_TIMEOUT, context.signal, context.onUpdate
|
|
321
|
+
? (text) => context.onUpdate?.({ type: "bash_progress", output: text, totalBytes: 0 })
|
|
322
|
+
: undefined);
|
|
323
|
+
const hint = install && res.exitCode !== 0 ? cooldownFailureHint(res.output, cooldownDays) : null;
|
|
324
|
+
const output = (hint ? `[${hint}]\n` : "") + (await renderBashOutput(res.output));
|
|
325
|
+
const exitCode = res.exitCode === "TIMEOUT"
|
|
326
|
+
? `TIMEOUT (${timeoutMs ?? DEFAULT_TIMEOUT}ms)` +
|
|
327
|
+
(res.shellKept ? " — the command was stopped; the session shell kept its cwd/env" : "")
|
|
328
|
+
: String(res.exitCode);
|
|
329
|
+
// The restart note sits right under the exit code so output truncation
|
|
330
|
+
// can never drop it.
|
|
331
|
+
const restartNote = sessionShell.takeRestartNote();
|
|
332
|
+
const note = restartNote ? `${restartNote}\n` : "";
|
|
333
|
+
return annotateSandboxDenial(`Exit code: ${exitCode}\n${note}${output}`, sessionSandboxed);
|
|
334
|
+
}
|
|
335
|
+
if (run_in_background) {
|
|
373
336
|
let launch;
|
|
374
337
|
try {
|
|
375
|
-
launch = await prepareLaunch(
|
|
338
|
+
launch = await prepareLaunch(resolveShell(runCommand, shellOpts));
|
|
376
339
|
}
|
|
377
340
|
catch (error) {
|
|
378
|
-
return `
|
|
341
|
+
return `Error: OS sandbox unavailable; command was not run: ${error.message}`;
|
|
379
342
|
}
|
|
380
|
-
// Stop may have landed while the launch was being prepared. The abort
|
|
381
|
-
// listener below would never fire for an already-aborted signal.
|
|
382
343
|
if (context.signal.aborted)
|
|
383
344
|
return CANCELLED_BEFORE_START;
|
|
384
|
-
const result = await
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const moveToBackground = () => {
|
|
426
|
-
// The shell already exited and only leftovers hold the pipes; the
|
|
427
|
-
// drain path owns that case.
|
|
428
|
-
if (timeoutMs !== undefined || child.exitCode !== null || !child.pid)
|
|
429
|
-
return false;
|
|
430
|
-
child.stdout?.off("data", onData);
|
|
431
|
-
child.stderr?.off("data", onData);
|
|
432
|
-
let adopted;
|
|
433
|
-
try {
|
|
434
|
-
adopted = processManager.adopt(child, command, startedAt, Buffer.concat(chunks));
|
|
435
|
-
}
|
|
436
|
-
catch {
|
|
437
|
-
child.stdout?.on("data", onData);
|
|
438
|
-
child.stderr?.on("data", onData);
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
backgrounded = true;
|
|
442
|
-
context.signal.removeEventListener("abort", onAbort);
|
|
443
|
-
void (async () => {
|
|
444
|
-
const soFar = await renderBashOutput(Buffer.concat(chunks).toString("utf-8"));
|
|
445
|
-
resolve(`Still running after ${effectiveTimeout / 1000}s, so it was moved to the background ` +
|
|
446
|
-
`instead of being stopped. It keeps its working directory and output.\n` +
|
|
447
|
-
`ID: ${adopted.id}\n` +
|
|
448
|
-
`PID: ${adopted.pid}\n` +
|
|
449
|
-
`Log: ${adopted.logFile}\n` +
|
|
450
|
-
`You will be notified when it exits or prints a failure. Use task_output with id="${adopted.id}" ` +
|
|
451
|
-
`(wait_ms to block until it exits) to read output, task_stop to stop it. ` +
|
|
452
|
-
`Pass an explicit timeout to have a command stopped instead.\n` +
|
|
453
|
-
(soFar ? `Output so far:\n${soFar}` : "No output so far."));
|
|
454
|
-
})();
|
|
455
|
-
return true;
|
|
456
|
-
};
|
|
457
|
-
// Timeout handling
|
|
458
|
-
const timer = setTimeout(() => {
|
|
459
|
-
if (moveToBackground())
|
|
460
|
-
return;
|
|
461
|
-
timedOut = true;
|
|
462
|
-
killed = true;
|
|
463
|
-
if (child.pid)
|
|
464
|
-
killProcessTree(child.pid);
|
|
465
|
-
}, effectiveTimeout);
|
|
466
|
-
// Abort signal handling
|
|
467
|
-
const onAbort = () => {
|
|
468
|
-
killed = true;
|
|
469
|
-
if (child.pid)
|
|
470
|
-
killProcessTree(child.pid);
|
|
471
|
-
};
|
|
472
|
-
context.signal.addEventListener("abort", onAbort, { once: true });
|
|
473
|
-
// "close" waits for every holder of the stdout/stderr pipes, and a
|
|
474
|
-
// process the command left running (`cmd &`, `nohup cmd`) inherits them,
|
|
475
|
-
// so without this the call hangs until the timeout. Once the shell
|
|
476
|
-
// itself exits, let late output drain briefly, then stop the leftovers
|
|
477
|
-
// and release the pipes so "close" fires.
|
|
478
|
-
let leftover;
|
|
479
|
-
let drainTimer;
|
|
480
|
-
child.on("exit", () => {
|
|
481
|
-
drainTimer = setTimeout(() => {
|
|
482
|
-
leftover = child.pid && killLeftoverGroup(child.pid) ? "stopped" : "detached";
|
|
483
|
-
child.stdout?.destroy();
|
|
484
|
-
child.stderr?.destroy();
|
|
485
|
-
}, LEFTOVER_DRAIN_MS);
|
|
486
|
-
});
|
|
487
|
-
child.on("close", async (code) => {
|
|
488
|
-
clearTimeout(timer);
|
|
489
|
-
clearTimeout(drainTimer);
|
|
490
|
-
context.signal.removeEventListener("abort", onAbort);
|
|
491
|
-
// The process manager owns an adopted command's exit.
|
|
492
|
-
if (backgrounded)
|
|
493
|
-
return;
|
|
494
|
-
const rawOutput = Buffer.concat(chunks).toString("utf-8");
|
|
495
|
-
let output = await renderBashOutput(rawOutput);
|
|
496
|
-
if (outputCapped) {
|
|
497
|
-
output =
|
|
498
|
-
`[Output capped at ${MAX_OUTPUT_BYTES / 1024 / 1024} MB to prevent memory exhaustion]\n` +
|
|
499
|
-
output;
|
|
500
|
-
}
|
|
501
|
-
// Windows without Git Bash: commands ran under cmd.exe, NOT bash. Tell
|
|
502
|
-
// the model so it uses cmd syntax (no `ls`/`grep`/pipes/single-quotes)
|
|
503
|
-
// and doesn't misread failures as a wrong directory / environment.
|
|
504
|
-
if (shell.isCmdFallback) {
|
|
505
|
-
output =
|
|
506
|
-
"[Ran under Windows cmd.exe — bash is unavailable. Use cmd syntax " +
|
|
507
|
-
"(dir, findstr, type); POSIX commands and quoting will fail. " +
|
|
508
|
-
"Install Git for Windows to get bash.]\n" +
|
|
509
|
-
output;
|
|
510
|
-
}
|
|
511
|
-
const hint = install && code !== 0 && !killed ? cooldownFailureHint(rawOutput, cooldownDays) : null;
|
|
512
|
-
if (hint)
|
|
513
|
-
output = `[${hint}]\n` + output;
|
|
514
|
-
if (leftover && !killed) {
|
|
515
|
-
const fate = leftover === "stopped"
|
|
516
|
-
? "so it was stopped"
|
|
517
|
-
: "so its later output was not captured; it may still be running";
|
|
518
|
-
output =
|
|
519
|
-
`[The command exited, but a process it left running in the background ` +
|
|
520
|
-
`(& or nohup) still held its output ${LEFTOVER_DRAIN_MS / 1000}s later, ${fate}. ` +
|
|
521
|
-
`Use run_in_background=true for anything that should keep running.]\n` +
|
|
522
|
-
output;
|
|
523
|
-
}
|
|
524
|
-
const exitCode = timedOut
|
|
525
|
-
? `TIMEOUT (${effectiveTimeout}ms)`
|
|
526
|
-
: killed
|
|
527
|
-
? "KILLED"
|
|
528
|
-
: String(code ?? 1);
|
|
529
|
-
resolve(annotateSandboxDenial(`Exit code: ${exitCode}\n${output}`, launch.sandboxed));
|
|
530
|
-
});
|
|
531
|
-
child.on("error", (err) => {
|
|
532
|
-
if (backgrounded)
|
|
533
|
-
return;
|
|
534
|
-
clearTimeout(timer);
|
|
535
|
-
clearTimeout(drainTimer);
|
|
536
|
-
context.signal.removeEventListener("abort", onAbort);
|
|
537
|
-
reject(new Error(`Exit code: 1\nFailed to spawn: ${err.message}`));
|
|
538
|
-
});
|
|
345
|
+
const result = await processManager.start(runCommand, cwd, launch, wakeRules, cooldownEnv);
|
|
346
|
+
const watchWarnings = backgroundWatchWarnings(command);
|
|
347
|
+
return (`Background process started.\n` +
|
|
348
|
+
`ID: ${result.id}\n` +
|
|
349
|
+
`PID: ${result.pid}\n` +
|
|
350
|
+
`Log: ${result.logFile}\n` +
|
|
351
|
+
(wakeRules
|
|
352
|
+
? result.wakeArmed
|
|
353
|
+
? `Wake rules armed: ${[
|
|
354
|
+
wakeRules.pattern ? `pattern /${wakeRules.pattern.source}/` : null,
|
|
355
|
+
wakeRules.silenceMs ? `silence ${wakeRules.silenceMs / 1000}s` : null,
|
|
356
|
+
]
|
|
357
|
+
.filter(Boolean)
|
|
358
|
+
.join(" + ")}. You will be notified automatically when one fires or the process exits.\n`
|
|
359
|
+
: `Wake conditions were NOT armed: this session has no notification path, so nothing will wake you automatically. Poll task_output periodically instead.\n`
|
|
360
|
+
: "") +
|
|
361
|
+
`Use task_output with id="${result.id}" to read output, ` +
|
|
362
|
+
`task_send to type input/answer prompts, task_stop to stop it.` +
|
|
363
|
+
watchWarnings.map((warning) => `\nWarning: ${warning}`).join(""));
|
|
364
|
+
}
|
|
365
|
+
const effectiveTimeout = timeoutMs ?? defaultTimeoutMs;
|
|
366
|
+
// Cross-platform shell: bash on macOS/Linux, Git Bash on Windows (or
|
|
367
|
+
// cmd.exe fallback), wrapped by the OS sandbox before any child starts.
|
|
368
|
+
const shell = resolveShell(runCommand, shellOpts);
|
|
369
|
+
let launch;
|
|
370
|
+
try {
|
|
371
|
+
launch = await prepareLaunch(shell);
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
return `Exit code: 1\nOS sandbox unavailable; command was not run: ${error.message}`;
|
|
375
|
+
}
|
|
376
|
+
// Stop may have landed while the launch was being prepared. The abort
|
|
377
|
+
// listener below would never fire for an already-aborted signal.
|
|
378
|
+
if (context.signal.aborted)
|
|
379
|
+
return CANCELLED_BEFORE_START;
|
|
380
|
+
const result = await new Promise((resolve, reject) => {
|
|
381
|
+
const child = ops.spawn(launch.file, launch.args, {
|
|
382
|
+
cwd,
|
|
383
|
+
detached: true,
|
|
384
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
385
|
+
env: sandboxAwareEnv(launch.sandboxed, cooldownEnv),
|
|
539
386
|
});
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
387
|
+
const chunks = [];
|
|
388
|
+
let totalBytes = 0;
|
|
389
|
+
let outputCapped = false;
|
|
390
|
+
const onData = (data) => {
|
|
391
|
+
if (outputCapped)
|
|
392
|
+
return;
|
|
393
|
+
totalBytes += data.length;
|
|
394
|
+
if (totalBytes > MAX_OUTPUT_BYTES) {
|
|
395
|
+
outputCapped = true;
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
chunks.push(data);
|
|
399
|
+
// Stream progress to UI for live output display
|
|
400
|
+
if (context.onUpdate) {
|
|
401
|
+
context.onUpdate({
|
|
402
|
+
type: "bash_progress",
|
|
403
|
+
output: data.toString("utf-8"),
|
|
404
|
+
totalBytes,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
child.stdout?.on("data", onData);
|
|
409
|
+
child.stderr?.on("data", onData);
|
|
410
|
+
let killed = false;
|
|
411
|
+
let timedOut = false;
|
|
412
|
+
let backgrounded = false;
|
|
413
|
+
const startedAt = Date.now();
|
|
414
|
+
/**
|
|
415
|
+
* Hand a still-running command to the process manager instead of
|
|
416
|
+
* killing it, so a slow build or test run keeps going (same process,
|
|
417
|
+
* same cwd) while the agent moves on. Only for the default budget: an
|
|
418
|
+
* explicit `timeout` is the model saying when to give up. Returns
|
|
419
|
+
* false when adoption is not possible, leaving the kill path to run.
|
|
420
|
+
*/
|
|
421
|
+
const moveToBackground = () => {
|
|
422
|
+
// The shell already exited and only leftovers hold the pipes; the
|
|
423
|
+
// drain path owns that case.
|
|
424
|
+
if (timeoutMs !== undefined || child.exitCode !== null || !child.pid)
|
|
425
|
+
return false;
|
|
426
|
+
child.stdout?.off("data", onData);
|
|
427
|
+
child.stderr?.off("data", onData);
|
|
428
|
+
let adopted;
|
|
429
|
+
try {
|
|
430
|
+
adopted = processManager.adopt(child, command, startedAt, Buffer.concat(chunks));
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
child.stdout?.on("data", onData);
|
|
434
|
+
child.stderr?.on("data", onData);
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
backgrounded = true;
|
|
438
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
439
|
+
void (async () => {
|
|
440
|
+
const soFar = await renderBashOutput(Buffer.concat(chunks).toString("utf-8"));
|
|
441
|
+
resolve(`Still running after ${effectiveTimeout / 1000}s, so it was moved to the background ` +
|
|
442
|
+
`instead of being stopped. It keeps its working directory and output.\n` +
|
|
443
|
+
`ID: ${adopted.id}\n` +
|
|
444
|
+
`PID: ${adopted.pid}\n` +
|
|
445
|
+
`Log: ${adopted.logFile}\n` +
|
|
446
|
+
`You will be notified when it exits or prints a failure. Use task_output with id="${adopted.id}" ` +
|
|
447
|
+
`(wait_ms to block until it exits) to read output, task_stop to stop it. ` +
|
|
448
|
+
`Pass an explicit timeout to have a command stopped instead.\n` +
|
|
449
|
+
(soFar ? `Output so far:\n${soFar}` : "No output so far."));
|
|
450
|
+
})();
|
|
451
|
+
return true;
|
|
452
|
+
};
|
|
453
|
+
// Timeout handling
|
|
454
|
+
const timer = setTimeout(() => {
|
|
455
|
+
if (moveToBackground())
|
|
456
|
+
return;
|
|
457
|
+
timedOut = true;
|
|
458
|
+
killed = true;
|
|
459
|
+
if (child.pid)
|
|
460
|
+
killProcessTree(child.pid);
|
|
461
|
+
}, effectiveTimeout);
|
|
462
|
+
// Abort signal handling
|
|
463
|
+
const onAbort = () => {
|
|
464
|
+
killed = true;
|
|
465
|
+
if (child.pid)
|
|
466
|
+
killProcessTree(child.pid);
|
|
467
|
+
};
|
|
468
|
+
context.signal.addEventListener("abort", onAbort, { once: true });
|
|
469
|
+
// "close" waits for every holder of the stdout/stderr pipes, and a
|
|
470
|
+
// process the command left running (`cmd &`, `nohup cmd`) inherits them,
|
|
471
|
+
// so without this the call hangs until the timeout. Once the shell
|
|
472
|
+
// itself exits, let late output drain briefly, then stop the leftovers
|
|
473
|
+
// and release the pipes so "close" fires.
|
|
474
|
+
let leftover;
|
|
475
|
+
let drainTimer;
|
|
476
|
+
child.on("exit", () => {
|
|
477
|
+
drainTimer = setTimeout(() => {
|
|
478
|
+
leftover = child.pid && killLeftoverGroup(child.pid) ? "stopped" : "detached";
|
|
479
|
+
child.stdout?.destroy();
|
|
480
|
+
child.stderr?.destroy();
|
|
481
|
+
}, LEFTOVER_DRAIN_MS);
|
|
482
|
+
});
|
|
483
|
+
child.on("close", async (code) => {
|
|
484
|
+
clearTimeout(timer);
|
|
485
|
+
clearTimeout(drainTimer);
|
|
486
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
487
|
+
// The process manager owns an adopted command's exit.
|
|
488
|
+
if (backgrounded)
|
|
489
|
+
return;
|
|
490
|
+
const rawOutput = Buffer.concat(chunks).toString("utf-8");
|
|
491
|
+
let output = await renderBashOutput(rawOutput);
|
|
492
|
+
if (outputCapped) {
|
|
493
|
+
output =
|
|
494
|
+
`[Output capped at ${MAX_OUTPUT_BYTES / 1024 / 1024} MB to prevent memory exhaustion]\n` +
|
|
495
|
+
output;
|
|
496
|
+
}
|
|
497
|
+
// Windows without Git Bash: commands ran under cmd.exe, NOT bash. Tell
|
|
498
|
+
// the model so it uses cmd syntax (no `ls`/`grep`/pipes/single-quotes)
|
|
499
|
+
// and doesn't misread failures as a wrong directory / environment.
|
|
500
|
+
if (shell.isCmdFallback) {
|
|
501
|
+
output =
|
|
502
|
+
"[Ran under Windows cmd.exe — bash is unavailable. Use cmd syntax " +
|
|
503
|
+
"(dir, findstr, type); POSIX commands and quoting will fail. " +
|
|
504
|
+
"Install Git for Windows to get bash.]\n" +
|
|
505
|
+
output;
|
|
506
|
+
}
|
|
507
|
+
const hint = install && code !== 0 && !killed ? cooldownFailureHint(rawOutput, cooldownDays) : null;
|
|
508
|
+
if (hint)
|
|
509
|
+
output = `[${hint}]\n` + output;
|
|
510
|
+
if (leftover && !killed) {
|
|
511
|
+
const fate = leftover === "stopped"
|
|
512
|
+
? "so it was stopped"
|
|
513
|
+
: "so its later output was not captured; it may still be running";
|
|
514
|
+
output =
|
|
515
|
+
`[The command exited, but a process it left running in the background ` +
|
|
516
|
+
`(& or nohup) still held its output ${LEFTOVER_DRAIN_MS / 1000}s later, ${fate}. ` +
|
|
517
|
+
`Use run_in_background=true for anything that should keep running.]\n` +
|
|
518
|
+
output;
|
|
519
|
+
}
|
|
520
|
+
const exitCode = timedOut
|
|
521
|
+
? `TIMEOUT (${effectiveTimeout}ms)`
|
|
522
|
+
: killed
|
|
523
|
+
? "KILLED"
|
|
524
|
+
: String(code ?? 1);
|
|
525
|
+
resolve(annotateSandboxDenial(`Exit code: ${exitCode}\n${output}`, launch.sandboxed));
|
|
526
|
+
});
|
|
527
|
+
child.on("error", (err) => {
|
|
528
|
+
if (backgrounded)
|
|
529
|
+
return;
|
|
530
|
+
clearTimeout(timer);
|
|
531
|
+
clearTimeout(drainTimer);
|
|
532
|
+
context.signal.removeEventListener("abort", onAbort);
|
|
533
|
+
reject(new Error(`Exit code: 1\nFailed to spawn: ${err.message}`));
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
if (!review || context.signal.aborted || !/^Exit code: 0(?:\s|$)/.test(result))
|
|
537
|
+
return result;
|
|
538
|
+
const inspection = await collectVerificationReview(cwd, context.signal);
|
|
539
|
+
return `${result}\n\n--- Independent read-only review ---\n${await renderBashOutput(inspection)}`;
|
|
540
|
+
};
|
|
541
|
+
return {
|
|
542
|
+
name: "bash",
|
|
543
|
+
description: description +
|
|
544
|
+
" Servers/watchers/REPLs: run_in_background + wake.pattern, then task_output wait_ms; " +
|
|
545
|
+
// "Never by name or pattern" moved here from the lean skill, which only
|
|
546
|
+
// loads for perf work: a pattern kill took down the host daemon and every
|
|
547
|
+
// sibling session.
|
|
548
|
+
"never `&`, nohup or sleep. Leave servers running. Kill by exact PID, never by name or pattern (pkill, killall, taskkill /IM): you run inside a host process.",
|
|
549
|
+
parameters: BashParams,
|
|
550
|
+
executionMode: "sequential",
|
|
551
|
+
async execute(args, context) {
|
|
552
|
+
// Rejecting a review-flagged edit+test command threw the edits away, and the
|
|
553
|
+
// model re-sent them without review every time (24/24 bench cases), so run
|
|
554
|
+
// the command as asked and skip only the review.
|
|
555
|
+
const skipReview = args.review === true &&
|
|
556
|
+
(args.persist === true ||
|
|
557
|
+
args.run_in_background === true ||
|
|
558
|
+
ops !== localOperations ||
|
|
559
|
+
!classifyVerificationCommand(args.command).accepted);
|
|
560
|
+
if (!skipReview)
|
|
561
|
+
return runBash(args, context);
|
|
562
|
+
const result = await runBash({ ...args, review: false }, context);
|
|
563
|
+
return typeof result === "string" ? `${result}\n\n${REVIEW_SKIPPED_NOTE}` : result;
|
|
544
564
|
},
|
|
545
565
|
};
|
|
546
566
|
}
|