@sema-ai/core 1.275.1
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/CHANGELOG.md +5433 -0
- package/LICENSE +27 -0
- package/NOTICE.md +30 -0
- package/README.md +1040 -0
- package/dist/agents/agent-definition.d.ts +10 -0
- package/dist/agents/agent-definition.d.ts.map +1 -0
- package/dist/agents/agent-definition.js +18 -0
- package/dist/agents/agent-definition.js.map +1 -0
- package/dist/agents/builtin-agents.d.ts +69 -0
- package/dist/agents/builtin-agents.d.ts.map +1 -0
- package/dist/agents/builtin-agents.js +177 -0
- package/dist/agents/builtin-agents.js.map +1 -0
- package/dist/agents/cascade.d.ts +101 -0
- package/dist/agents/cascade.d.ts.map +1 -0
- package/dist/agents/cascade.js +189 -0
- package/dist/agents/cascade.js.map +1 -0
- package/dist/agents/observer.d.ts +209 -0
- package/dist/agents/observer.d.ts.map +1 -0
- package/dist/agents/observer.js +495 -0
- package/dist/agents/observer.js.map +1 -0
- package/dist/agents/repair-loop.d.ts +236 -0
- package/dist/agents/repair-loop.d.ts.map +1 -0
- package/dist/agents/repair-loop.js +293 -0
- package/dist/agents/repair-loop.js.map +1 -0
- package/dist/agents/session-util.d.ts +8 -0
- package/dist/agents/session-util.d.ts.map +1 -0
- package/dist/agents/session-util.js +9 -0
- package/dist/agents/session-util.js.map +1 -0
- package/dist/agents/subagent-steps.d.ts +93 -0
- package/dist/agents/subagent-steps.d.ts.map +1 -0
- package/dist/agents/subagent-steps.js +206 -0
- package/dist/agents/subagent-steps.js.map +1 -0
- package/dist/agents/subagent.d.ts +441 -0
- package/dist/agents/subagent.d.ts.map +1 -0
- package/dist/agents/subagent.js +2492 -0
- package/dist/agents/subagent.js.map +1 -0
- package/dist/agents/suspend-guard.d.ts +35 -0
- package/dist/agents/suspend-guard.d.ts.map +1 -0
- package/dist/agents/suspend-guard.js +48 -0
- package/dist/agents/suspend-guard.js.map +1 -0
- package/dist/agents/teacher.d.ts +137 -0
- package/dist/agents/teacher.d.ts.map +1 -0
- package/dist/agents/teacher.js +575 -0
- package/dist/agents/teacher.js.map +1 -0
- package/dist/agents/team.d.ts +211 -0
- package/dist/agents/team.d.ts.map +1 -0
- package/dist/agents/team.js +293 -0
- package/dist/agents/team.js.map +1 -0
- package/dist/agents/tool-filter.d.ts +29 -0
- package/dist/agents/tool-filter.d.ts.map +1 -0
- package/dist/agents/tool-filter.js +50 -0
- package/dist/agents/tool-filter.js.map +1 -0
- package/dist/agents/verify.d.ts +177 -0
- package/dist/agents/verify.d.ts.map +1 -0
- package/dist/agents/verify.js +305 -0
- package/dist/agents/verify.js.map +1 -0
- package/dist/bench/metrics.d.ts +714 -0
- package/dist/bench/metrics.d.ts.map +1 -0
- package/dist/bench/metrics.js +618 -0
- package/dist/bench/metrics.js.map +1 -0
- package/dist/bin/sema-tb.d.ts +3 -0
- package/dist/bin/sema-tb.d.ts.map +1 -0
- package/dist/bin/sema-tb.js +516 -0
- package/dist/bin/sema-tb.js.map +1 -0
- package/dist/bin/tb-env.d.ts +13 -0
- package/dist/bin/tb-env.d.ts.map +1 -0
- package/dist/bin/tb-env.js +26 -0
- package/dist/bin/tb-env.js.map +1 -0
- package/dist/brain/anthropic.d.ts +46 -0
- package/dist/brain/anthropic.d.ts.map +1 -0
- package/dist/brain/anthropic.js +830 -0
- package/dist/brain/anthropic.js.map +1 -0
- package/dist/brain/circuit-breaker.d.ts +46 -0
- package/dist/brain/circuit-breaker.d.ts.map +1 -0
- package/dist/brain/circuit-breaker.js +173 -0
- package/dist/brain/circuit-breaker.js.map +1 -0
- package/dist/brain/degrading.d.ts +98 -0
- package/dist/brain/degrading.d.ts.map +1 -0
- package/dist/brain/degrading.js +249 -0
- package/dist/brain/degrading.js.map +1 -0
- package/dist/brain/errors.d.ts +31 -0
- package/dist/brain/errors.d.ts.map +1 -0
- package/dist/brain/errors.js +58 -0
- package/dist/brain/errors.js.map +1 -0
- package/dist/brain/failover.d.ts +18 -0
- package/dist/brain/failover.d.ts.map +1 -0
- package/dist/brain/failover.js +118 -0
- package/dist/brain/failover.js.map +1 -0
- package/dist/brain/model-presets.d.ts +36 -0
- package/dist/brain/model-presets.d.ts.map +1 -0
- package/dist/brain/model-presets.js +54 -0
- package/dist/brain/model-presets.js.map +1 -0
- package/dist/brain/openai.d.ts +43 -0
- package/dist/brain/openai.d.ts.map +1 -0
- package/dist/brain/openai.js +784 -0
- package/dist/brain/openai.js.map +1 -0
- package/dist/brain/reasoning.d.ts +138 -0
- package/dist/brain/reasoning.d.ts.map +1 -0
- package/dist/brain/reasoning.js +146 -0
- package/dist/brain/reasoning.js.map +1 -0
- package/dist/brain/repetition.d.ts +60 -0
- package/dist/brain/repetition.d.ts.map +1 -0
- package/dist/brain/repetition.js +121 -0
- package/dist/brain/repetition.js.map +1 -0
- package/dist/brain/request-params.d.ts +29 -0
- package/dist/brain/request-params.d.ts.map +1 -0
- package/dist/brain/request-params.js +78 -0
- package/dist/brain/request-params.js.map +1 -0
- package/dist/brain/retry.d.ts +18 -0
- package/dist/brain/retry.d.ts.map +1 -0
- package/dist/brain/retry.js +42 -0
- package/dist/brain/retry.js.map +1 -0
- package/dist/brain/routing.d.ts +19 -0
- package/dist/brain/routing.d.ts.map +1 -0
- package/dist/brain/routing.js +44 -0
- package/dist/brain/routing.js.map +1 -0
- package/dist/brain/status-sink.d.ts +46 -0
- package/dist/brain/status-sink.d.ts.map +1 -0
- package/dist/brain/status-sink.js +36 -0
- package/dist/brain/status-sink.js.map +1 -0
- package/dist/brain/stream-engine.d.ts +85 -0
- package/dist/brain/stream-engine.d.ts.map +1 -0
- package/dist/brain/stream-engine.js +391 -0
- package/dist/brain/stream-engine.js.map +1 -0
- package/dist/brain/timeout.d.ts +44 -0
- package/dist/brain/timeout.d.ts.map +1 -0
- package/dist/brain/timeout.js +41 -0
- package/dist/brain/timeout.js.map +1 -0
- package/dist/brain/tool-call-repair.d.ts +15 -0
- package/dist/brain/tool-call-repair.d.ts.map +1 -0
- package/dist/brain/tool-call-repair.js +67 -0
- package/dist/brain/tool-call-repair.js.map +1 -0
- package/dist/brain/walltime.d.ts +14 -0
- package/dist/brain/walltime.d.ts.map +1 -0
- package/dist/brain/walltime.js +14 -0
- package/dist/brain/walltime.js.map +1 -0
- package/dist/core/arg-summary.d.ts +19 -0
- package/dist/core/arg-summary.d.ts.map +1 -0
- package/dist/core/arg-summary.js +96 -0
- package/dist/core/arg-summary.js.map +1 -0
- package/dist/core/ask-question.d.ts +113 -0
- package/dist/core/ask-question.d.ts.map +1 -0
- package/dist/core/ask-question.js +246 -0
- package/dist/core/ask-question.js.map +1 -0
- package/dist/core/auto-compaction.d.ts +341 -0
- package/dist/core/auto-compaction.d.ts.map +1 -0
- package/dist/core/auto-compaction.js +495 -0
- package/dist/core/auto-compaction.js.map +1 -0
- package/dist/core/auto-promote.d.ts +126 -0
- package/dist/core/auto-promote.d.ts.map +1 -0
- package/dist/core/auto-promote.js +171 -0
- package/dist/core/auto-promote.js.map +1 -0
- package/dist/core/background-shell.d.ts +128 -0
- package/dist/core/background-shell.d.ts.map +1 -0
- package/dist/core/background-shell.js +42 -0
- package/dist/core/background-shell.js.map +1 -0
- package/dist/core/cache-break-detector.d.ts +63 -0
- package/dist/core/cache-break-detector.d.ts.map +1 -0
- package/dist/core/cache-break-detector.js +0 -0
- package/dist/core/cache-break-detector.js.map +1 -0
- package/dist/core/canonical-json.d.ts +45 -0
- package/dist/core/canonical-json.d.ts.map +1 -0
- package/dist/core/canonical-json.js +132 -0
- package/dist/core/canonical-json.js.map +1 -0
- package/dist/core/checkpoint-store.d.ts +1101 -0
- package/dist/core/checkpoint-store.d.ts.map +1 -0
- package/dist/core/checkpoint-store.js +514 -0
- package/dist/core/checkpoint-store.js.map +1 -0
- package/dist/core/consolidate-scope.d.ts +94 -0
- package/dist/core/consolidate-scope.d.ts.map +1 -0
- package/dist/core/consolidate-scope.js +158 -0
- package/dist/core/consolidate-scope.js.map +1 -0
- package/dist/core/context-edit.d.ts +82 -0
- package/dist/core/context-edit.d.ts.map +1 -0
- package/dist/core/context-edit.js +149 -0
- package/dist/core/context-edit.js.map +1 -0
- package/dist/core/context-guard.d.ts +43 -0
- package/dist/core/context-guard.d.ts.map +1 -0
- package/dist/core/context-guard.js +171 -0
- package/dist/core/context-guard.js.map +1 -0
- package/dist/core/dynamic-recall.d.ts +100 -0
- package/dist/core/dynamic-recall.d.ts.map +1 -0
- package/dist/core/dynamic-recall.js +108 -0
- package/dist/core/dynamic-recall.js.map +1 -0
- package/dist/core/exec-gate.d.ts +74 -0
- package/dist/core/exec-gate.d.ts.map +1 -0
- package/dist/core/exec-gate.js +143 -0
- package/dist/core/exec-gate.js.map +1 -0
- package/dist/core/exec-output-tail.d.ts +37 -0
- package/dist/core/exec-output-tail.d.ts.map +1 -0
- package/dist/core/exec-output-tail.js +63 -0
- package/dist/core/exec-output-tail.js.map +1 -0
- package/dist/core/file-snapshot-store.d.ts +137 -0
- package/dist/core/file-snapshot-store.d.ts.map +1 -0
- package/dist/core/file-snapshot-store.js +319 -0
- package/dist/core/file-snapshot-store.js.map +1 -0
- package/dist/core/git-worktree-env.d.ts +41 -0
- package/dist/core/git-worktree-env.d.ts.map +1 -0
- package/dist/core/git-worktree-env.js +64 -0
- package/dist/core/git-worktree-env.js.map +1 -0
- package/dist/core/hooks.d.ts +372 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +269 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/lsp-diagnostics.d.ts +74 -0
- package/dist/core/lsp-diagnostics.d.ts.map +1 -0
- package/dist/core/lsp-diagnostics.js +125 -0
- package/dist/core/lsp-diagnostics.js.map +1 -0
- package/dist/core/lsp-protocol.d.ts +28 -0
- package/dist/core/lsp-protocol.d.ts.map +1 -0
- package/dist/core/lsp-protocol.js +179 -0
- package/dist/core/lsp-protocol.js.map +1 -0
- package/dist/core/lsp-session.d.ts +56 -0
- package/dist/core/lsp-session.d.ts.map +1 -0
- package/dist/core/lsp-session.js +185 -0
- package/dist/core/lsp-session.js.map +1 -0
- package/dist/core/lsp.d.ts +132 -0
- package/dist/core/lsp.d.ts.map +1 -0
- package/dist/core/lsp.js +147 -0
- package/dist/core/lsp.js.map +1 -0
- package/dist/core/mcp.d.ts +294 -0
- package/dist/core/mcp.d.ts.map +1 -0
- package/dist/core/mcp.js +992 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/media-byte-cap.d.ts +34 -0
- package/dist/core/media-byte-cap.d.ts.map +1 -0
- package/dist/core/media-byte-cap.js +76 -0
- package/dist/core/media-byte-cap.js.map +1 -0
- package/dist/core/memory-engine/data-plane.d.ts +103 -0
- package/dist/core/memory-engine/data-plane.d.ts.map +1 -0
- package/dist/core/memory-engine/data-plane.js +272 -0
- package/dist/core/memory-engine/data-plane.js.map +1 -0
- package/dist/core/memory-engine/dual-root.d.ts +40 -0
- package/dist/core/memory-engine/dual-root.d.ts.map +1 -0
- package/dist/core/memory-engine/dual-root.js +95 -0
- package/dist/core/memory-engine/dual-root.js.map +1 -0
- package/dist/core/memory-engine/engine.d.ts +161 -0
- package/dist/core/memory-engine/engine.d.ts.map +1 -0
- package/dist/core/memory-engine/engine.js +1110 -0
- package/dist/core/memory-engine/engine.js.map +1 -0
- package/dist/core/memory-engine/file-backend.d.ts +162 -0
- package/dist/core/memory-engine/file-backend.d.ts.map +1 -0
- package/dist/core/memory-engine/file-backend.js +948 -0
- package/dist/core/memory-engine/file-backend.js.map +1 -0
- package/dist/core/memory-engine/frontmatter.d.ts +24 -0
- package/dist/core/memory-engine/frontmatter.d.ts.map +1 -0
- package/dist/core/memory-engine/frontmatter.js +135 -0
- package/dist/core/memory-engine/frontmatter.js.map +1 -0
- package/dist/core/memory-engine/index.d.ts +13 -0
- package/dist/core/memory-engine/index.d.ts.map +1 -0
- package/dist/core/memory-engine/index.js +28 -0
- package/dist/core/memory-engine/index.js.map +1 -0
- package/dist/core/memory-engine/layout.d.ts +123 -0
- package/dist/core/memory-engine/layout.d.ts.map +1 -0
- package/dist/core/memory-engine/layout.js +643 -0
- package/dist/core/memory-engine/layout.js.map +1 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts +22 -0
- package/dist/core/memory-engine/memory-backend-contract.d.ts.map +1 -0
- package/dist/core/memory-engine/memory-backend-contract.js +271 -0
- package/dist/core/memory-engine/memory-backend-contract.js.map +1 -0
- package/dist/core/memory-engine/migrate.d.ts +17 -0
- package/dist/core/memory-engine/migrate.d.ts.map +1 -0
- package/dist/core/memory-engine/migrate.js +35 -0
- package/dist/core/memory-engine/migrate.js.map +1 -0
- package/dist/core/memory-engine/scan.d.ts +20 -0
- package/dist/core/memory-engine/scan.d.ts.map +1 -0
- package/dist/core/memory-engine/scan.js +84 -0
- package/dist/core/memory-engine/scan.js.map +1 -0
- package/dist/core/memory-engine/scope-contract.d.ts +104 -0
- package/dist/core/memory-engine/scope-contract.d.ts.map +1 -0
- package/dist/core/memory-engine/scope-contract.js +288 -0
- package/dist/core/memory-engine/scope-contract.js.map +1 -0
- package/dist/core/memory-engine/sync-client.d.ts +100 -0
- package/dist/core/memory-engine/sync-client.d.ts.map +1 -0
- package/dist/core/memory-engine/sync-client.js +328 -0
- package/dist/core/memory-engine/sync-client.js.map +1 -0
- package/dist/core/memory-engine/sync.d.ts +97 -0
- package/dist/core/memory-engine/sync.d.ts.map +1 -0
- package/dist/core/memory-engine/sync.js +91 -0
- package/dist/core/memory-engine/sync.js.map +1 -0
- package/dist/core/memory-engine/types.d.ts +279 -0
- package/dist/core/memory-engine/types.d.ts.map +1 -0
- package/dist/core/memory-engine/types.js +9 -0
- package/dist/core/memory-engine/types.js.map +1 -0
- package/dist/core/memory-recall.d.ts +261 -0
- package/dist/core/memory-recall.d.ts.map +1 -0
- package/dist/core/memory-recall.js +600 -0
- package/dist/core/memory-recall.js.map +1 -0
- package/dist/core/memory-vector.d.ts +24 -0
- package/dist/core/memory-vector.d.ts.map +1 -0
- package/dist/core/memory-vector.js +51 -0
- package/dist/core/memory-vector.js.map +1 -0
- package/dist/core/memory.d.ts +502 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +881 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/message-utils.d.ts +7 -0
- package/dist/core/message-utils.d.ts.map +1 -0
- package/dist/core/message-utils.js +10 -0
- package/dist/core/message-utils.js.map +1 -0
- package/dist/core/oracle-isolation.d.ts +85 -0
- package/dist/core/oracle-isolation.d.ts.map +1 -0
- package/dist/core/oracle-isolation.js +121 -0
- package/dist/core/oracle-isolation.js.map +1 -0
- package/dist/core/permission-rules.d.ts +102 -0
- package/dist/core/permission-rules.d.ts.map +1 -0
- package/dist/core/permission-rules.js +357 -0
- package/dist/core/permission-rules.js.map +1 -0
- package/dist/core/present-plan-tool.d.ts +28 -0
- package/dist/core/present-plan-tool.d.ts.map +1 -0
- package/dist/core/present-plan-tool.js +119 -0
- package/dist/core/present-plan-tool.js.map +1 -0
- package/dist/core/pricing.d.ts +48 -0
- package/dist/core/pricing.d.ts.map +1 -0
- package/dist/core/pricing.js +46 -0
- package/dist/core/pricing.js.map +1 -0
- package/dist/core/property-harness.d.ts +126 -0
- package/dist/core/property-harness.d.ts.map +1 -0
- package/dist/core/property-harness.js +192 -0
- package/dist/core/property-harness.js.map +1 -0
- package/dist/core/push-queue.d.ts +10 -0
- package/dist/core/push-queue.d.ts.map +1 -0
- package/dist/core/push-queue.js +42 -0
- package/dist/core/push-queue.js.map +1 -0
- package/dist/core/remote-env.d.ts +432 -0
- package/dist/core/remote-env.d.ts.map +1 -0
- package/dist/core/remote-env.js +77 -0
- package/dist/core/remote-env.js.map +1 -0
- package/dist/core/roles.d.ts +74 -0
- package/dist/core/roles.d.ts.map +1 -0
- package/dist/core/roles.js +272 -0
- package/dist/core/roles.js.map +1 -0
- package/dist/core/runner/active-skill-scope.d.ts +64 -0
- package/dist/core/runner/active-skill-scope.d.ts.map +1 -0
- package/dist/core/runner/active-skill-scope.js +197 -0
- package/dist/core/runner/active-skill-scope.js.map +1 -0
- package/dist/core/runner/assemble-result.d.ts +191 -0
- package/dist/core/runner/assemble-result.d.ts.map +1 -0
- package/dist/core/runner/assemble-result.js +250 -0
- package/dist/core/runner/assemble-result.js.map +1 -0
- package/dist/core/runner/call-cap.d.ts +130 -0
- package/dist/core/runner/call-cap.d.ts.map +1 -0
- package/dist/core/runner/call-cap.js +151 -0
- package/dist/core/runner/call-cap.js.map +1 -0
- package/dist/core/runner/grounding-signal.d.ts +12 -0
- package/dist/core/runner/grounding-signal.d.ts.map +1 -0
- package/dist/core/runner/grounding-signal.js +94 -0
- package/dist/core/runner/grounding-signal.js.map +1 -0
- package/dist/core/runner/image.d.ts +23 -0
- package/dist/core/runner/image.d.ts.map +1 -0
- package/dist/core/runner/image.js +151 -0
- package/dist/core/runner/image.js.map +1 -0
- package/dist/core/runner/memory-consolidation.d.ts +112 -0
- package/dist/core/runner/memory-consolidation.d.ts.map +1 -0
- package/dist/core/runner/memory-consolidation.js +372 -0
- package/dist/core/runner/memory-consolidation.js.map +1 -0
- package/dist/core/runner/prepare-task.d.ts +583 -0
- package/dist/core/runner/prepare-task.d.ts.map +1 -0
- package/dist/core/runner/prepare-task.js +3612 -0
- package/dist/core/runner/prepare-task.js.map +1 -0
- package/dist/core/runner/prompt-suggestions.d.ts +33 -0
- package/dist/core/runner/prompt-suggestions.d.ts.map +1 -0
- package/dist/core/runner/prompt-suggestions.js +116 -0
- package/dist/core/runner/prompt-suggestions.js.map +1 -0
- package/dist/core/runner/runtask.d.ts +274 -0
- package/dist/core/runner/runtask.d.ts.map +1 -0
- package/dist/core/runner/runtask.js +4606 -0
- package/dist/core/runner/runtask.js.map +1 -0
- package/dist/core/runner/session-rule-policy.d.ts +28 -0
- package/dist/core/runner/session-rule-policy.d.ts.map +1 -0
- package/dist/core/runner/session-rule-policy.js +110 -0
- package/dist/core/runner/session-rule-policy.js.map +1 -0
- package/dist/core/runner/strict-output-schema.d.ts +36 -0
- package/dist/core/runner/strict-output-schema.d.ts.map +1 -0
- package/dist/core/runner/strict-output-schema.js +365 -0
- package/dist/core/runner/strict-output-schema.js.map +1 -0
- package/dist/core/runner/synthetic-tools.d.ts +72 -0
- package/dist/core/runner/synthetic-tools.d.ts.map +1 -0
- package/dist/core/runner/synthetic-tools.js +203 -0
- package/dist/core/runner/synthetic-tools.js.map +1 -0
- package/dist/core/runner/tool-disclosure.d.ts +117 -0
- package/dist/core/runner/tool-disclosure.d.ts.map +1 -0
- package/dist/core/runner/tool-disclosure.js +0 -0
- package/dist/core/runner/tool-disclosure.js.map +1 -0
- package/dist/core/runner/turn-attachments.d.ts +381 -0
- package/dist/core/runner/turn-attachments.d.ts.map +1 -0
- package/dist/core/runner/turn-attachments.js +596 -0
- package/dist/core/runner/turn-attachments.js.map +1 -0
- package/dist/core/runner/usage-accounting.d.ts +35 -0
- package/dist/core/runner/usage-accounting.d.ts.map +1 -0
- package/dist/core/runner/usage-accounting.js +45 -0
- package/dist/core/runner/usage-accounting.js.map +1 -0
- package/dist/core/runtime.d.ts +9 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +17 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/safety-axis-vocab.d.ts +33 -0
- package/dist/core/safety-axis-vocab.d.ts.map +1 -0
- package/dist/core/safety-axis-vocab.js +35 -0
- package/dist/core/safety-axis-vocab.js.map +1 -0
- package/dist/core/safety-merge-corpus.d.ts +48 -0
- package/dist/core/safety-merge-corpus.d.ts.map +1 -0
- package/dist/core/safety-merge-corpus.js +203 -0
- package/dist/core/safety-merge-corpus.js.map +1 -0
- package/dist/core/scheduler.d.ts +126 -0
- package/dist/core/scheduler.d.ts.map +1 -0
- package/dist/core/scheduler.js +54 -0
- package/dist/core/scheduler.js.map +1 -0
- package/dist/core/secret-env.d.ts +23 -0
- package/dist/core/secret-env.d.ts.map +1 -0
- package/dist/core/secret-env.js +35 -0
- package/dist/core/secret-env.js.map +1 -0
- package/dist/core/select-model.d.ts +26 -0
- package/dist/core/select-model.d.ts.map +1 -0
- package/dist/core/select-model.js +58 -0
- package/dist/core/select-model.js.map +1 -0
- package/dist/core/sensitive-path-policy.d.ts +24 -0
- package/dist/core/sensitive-path-policy.d.ts.map +1 -0
- package/dist/core/sensitive-path-policy.js +96 -0
- package/dist/core/sensitive-path-policy.js.map +1 -0
- package/dist/core/session-policy-store.d.ts +102 -0
- package/dist/core/session-policy-store.d.ts.map +1 -0
- package/dist/core/session-policy-store.js +177 -0
- package/dist/core/session-policy-store.js.map +1 -0
- package/dist/core/session-reconcile.d.ts +63 -0
- package/dist/core/session-reconcile.d.ts.map +1 -0
- package/dist/core/session-reconcile.js +71 -0
- package/dist/core/session-reconcile.js.map +1 -0
- package/dist/core/session-store.d.ts +99 -0
- package/dist/core/session-store.d.ts.map +1 -0
- package/dist/core/session-store.js +298 -0
- package/dist/core/session-store.js.map +1 -0
- package/dist/core/session.d.ts +144 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +56 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/spec-contract.d.ts +147 -0
- package/dist/core/spec-contract.d.ts.map +1 -0
- package/dist/core/spec-contract.js +340 -0
- package/dist/core/spec-contract.js.map +1 -0
- package/dist/core/strategy-store.d.ts +50 -0
- package/dist/core/strategy-store.d.ts.map +1 -0
- package/dist/core/strategy-store.js +100 -0
- package/dist/core/strategy-store.js.map +1 -0
- package/dist/core/stub-env.d.ts +35 -0
- package/dist/core/stub-env.d.ts.map +1 -0
- package/dist/core/stub-env.js +69 -0
- package/dist/core/stub-env.js.map +1 -0
- package/dist/core/task-notification.d.ts +115 -0
- package/dist/core/task-notification.d.ts.map +1 -0
- package/dist/core/task-notification.js +247 -0
- package/dist/core/task-notification.js.map +1 -0
- package/dist/core/task-outcome.d.ts +80 -0
- package/dist/core/task-outcome.d.ts.map +1 -0
- package/dist/core/task-outcome.js +40 -0
- package/dist/core/task-outcome.js.map +1 -0
- package/dist/core/task-registry.d.ts +349 -0
- package/dist/core/task-registry.d.ts.map +1 -0
- package/dist/core/task-registry.js +1751 -0
- package/dist/core/task-registry.js.map +1 -0
- package/dist/core/tighten-task-spec.d.ts +27 -0
- package/dist/core/tighten-task-spec.d.ts.map +1 -0
- package/dist/core/tighten-task-spec.js +95 -0
- package/dist/core/tighten-task-spec.js.map +1 -0
- package/dist/core/tool-detach.d.ts +31 -0
- package/dist/core/tool-detach.d.ts.map +1 -0
- package/dist/core/tool-detach.js +62 -0
- package/dist/core/tool-detach.js.map +1 -0
- package/dist/core/tool-errors.d.ts +72 -0
- package/dist/core/tool-errors.d.ts.map +1 -0
- package/dist/core/tool-errors.js +194 -0
- package/dist/core/tool-errors.js.map +1 -0
- package/dist/core/tool-name-aliases.d.ts +5 -0
- package/dist/core/tool-name-aliases.d.ts.map +1 -0
- package/dist/core/tool-name-aliases.js +130 -0
- package/dist/core/tool-name-aliases.js.map +1 -0
- package/dist/core/tool-policy.d.ts +295 -0
- package/dist/core/tool-policy.d.ts.map +1 -0
- package/dist/core/tool-policy.js +567 -0
- package/dist/core/tool-policy.js.map +1 -0
- package/dist/core/tool-result-budget.d.ts +44 -0
- package/dist/core/tool-result-budget.d.ts.map +1 -0
- package/dist/core/tool-result-budget.js +140 -0
- package/dist/core/tool-result-budget.js.map +1 -0
- package/dist/core/tool-result-store.d.ts +136 -0
- package/dist/core/tool-result-store.d.ts.map +1 -0
- package/dist/core/tool-result-store.js +219 -0
- package/dist/core/tool-result-store.js.map +1 -0
- package/dist/core/tools.d.ts +14 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/tools.js +98 -0
- package/dist/core/tools.js.map +1 -0
- package/dist/core/trace.d.ts +340 -0
- package/dist/core/trace.d.ts.map +1 -0
- package/dist/core/trace.js +12 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/core/types.d.ts +2828 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/untrusted-egress.d.ts +32 -0
- package/dist/core/untrusted-egress.d.ts.map +1 -0
- package/dist/core/untrusted-egress.js +49 -0
- package/dist/core/untrusted-egress.js.map +1 -0
- package/dist/core/untrusted-text.d.ts +64 -0
- package/dist/core/untrusted-text.d.ts.map +1 -0
- package/dist/core/untrusted-text.js +119 -0
- package/dist/core/untrusted-text.js.map +1 -0
- package/dist/core/warm-resume.d.ts +23 -0
- package/dist/core/warm-resume.d.ts.map +1 -0
- package/dist/core/warm-resume.js +28 -0
- package/dist/core/warm-resume.js.map +1 -0
- package/dist/core/with-retry.d.ts +43 -0
- package/dist/core/with-retry.d.ts.map +1 -0
- package/dist/core/with-retry.js +59 -0
- package/dist/core/with-retry.js.map +1 -0
- package/dist/core/workflow-journal-store.d.ts +44 -0
- package/dist/core/workflow-journal-store.d.ts.map +1 -0
- package/dist/core/workflow-journal-store.js +47 -0
- package/dist/core/workflow-journal-store.js.map +1 -0
- package/dist/core/workflow-run-store-contract.d.ts +31 -0
- package/dist/core/workflow-run-store-contract.d.ts.map +1 -0
- package/dist/core/workflow-run-store-contract.js +191 -0
- package/dist/core/workflow-run-store-contract.js.map +1 -0
- package/dist/core/workflow-run-store.d.ts +149 -0
- package/dist/core/workflow-run-store.d.ts.map +1 -0
- package/dist/core/workflow-run-store.js +110 -0
- package/dist/core/workflow-run-store.js.map +1 -0
- package/dist/engine/compaction/compaction.d.ts +139 -0
- package/dist/engine/compaction/compaction.d.ts.map +1 -0
- package/dist/engine/compaction/compaction.js +1030 -0
- package/dist/engine/compaction/compaction.js.map +1 -0
- package/dist/engine/compaction/utils.d.ts +45 -0
- package/dist/engine/compaction/utils.d.ts.map +1 -0
- package/dist/engine/compaction/utils.js +203 -0
- package/dist/engine/compaction/utils.js.map +1 -0
- package/dist/engine/execution-env/kill-tree.d.ts +20 -0
- package/dist/engine/execution-env/kill-tree.d.ts.map +1 -0
- package/dist/engine/execution-env/kill-tree.js +183 -0
- package/dist/engine/execution-env/kill-tree.js.map +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +133 -0
- package/dist/engine/execution-env/node-execution-env.d.ts.map +1 -0
- package/dist/engine/execution-env/node-execution-env.js +1031 -0
- package/dist/engine/execution-env/node-execution-env.js.map +1 -0
- package/dist/engine/harness/agent-harness.d.ts +174 -0
- package/dist/engine/harness/agent-harness.d.ts.map +1 -0
- package/dist/engine/harness/agent-harness.js +1053 -0
- package/dist/engine/harness/agent-harness.js.map +1 -0
- package/dist/engine/harness/messages.d.ts +17 -0
- package/dist/engine/harness/messages.d.ts.map +1 -0
- package/dist/engine/harness/messages.js +122 -0
- package/dist/engine/harness/messages.js.map +1 -0
- package/dist/engine/harness/types.d.ts +713 -0
- package/dist/engine/harness/types.d.ts.map +1 -0
- package/dist/engine/harness/types.js +100 -0
- package/dist/engine/harness/types.js.map +1 -0
- package/dist/engine/llm/diagnostics.d.ts +23 -0
- package/dist/engine/llm/diagnostics.d.ts.map +1 -0
- package/dist/engine/llm/diagnostics.js +32 -0
- package/dist/engine/llm/diagnostics.js.map +1 -0
- package/dist/engine/llm/event-stream.d.ts +25 -0
- package/dist/engine/llm/event-stream.d.ts.map +1 -0
- package/dist/engine/llm/event-stream.js +103 -0
- package/dist/engine/llm/event-stream.js.map +1 -0
- package/dist/engine/llm/index.d.ts +12 -0
- package/dist/engine/llm/index.d.ts.map +1 -0
- package/dist/engine/llm/index.js +12 -0
- package/dist/engine/llm/index.js.map +1 -0
- package/dist/engine/llm/types.d.ts +753 -0
- package/dist/engine/llm/types.d.ts.map +1 -0
- package/dist/engine/llm/types.js +2 -0
- package/dist/engine/llm/types.js.map +1 -0
- package/dist/engine/llm/validation.d.ts +8 -0
- package/dist/engine/llm/validation.d.ts.map +1 -0
- package/dist/engine/llm/validation.js +318 -0
- package/dist/engine/llm/validation.js.map +1 -0
- package/dist/engine/loop/agent-loop.d.ts +74 -0
- package/dist/engine/loop/agent-loop.d.ts.map +1 -0
- package/dist/engine/loop/agent-loop.js +1490 -0
- package/dist/engine/loop/agent-loop.js.map +1 -0
- package/dist/engine/loop/runtime-deps.d.ts +17 -0
- package/dist/engine/loop/runtime-deps.d.ts.map +1 -0
- package/dist/engine/loop/runtime-deps.js +21 -0
- package/dist/engine/loop/runtime-deps.js.map +1 -0
- package/dist/engine/loop/types.d.ts +609 -0
- package/dist/engine/loop/types.d.ts.map +1 -0
- package/dist/engine/loop/types.js +2 -0
- package/dist/engine/loop/types.js.map +1 -0
- package/dist/engine/lsp/frame-decoder.d.ts +16 -0
- package/dist/engine/lsp/frame-decoder.d.ts.map +1 -0
- package/dist/engine/lsp/frame-decoder.js +53 -0
- package/dist/engine/lsp/frame-decoder.js.map +1 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts +105 -0
- package/dist/engine/lsp/node-lsp-manager.d.ts.map +1 -0
- package/dist/engine/lsp/node-lsp-manager.js +343 -0
- package/dist/engine/lsp/node-lsp-manager.js.map +1 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts +37 -0
- package/dist/engine/lsp/stdio-lsp-transport.d.ts.map +1 -0
- package/dist/engine/lsp/stdio-lsp-transport.js +185 -0
- package/dist/engine/lsp/stdio-lsp-transport.js.map +1 -0
- package/dist/engine/session/import-validate.d.ts +44 -0
- package/dist/engine/session/import-validate.d.ts.map +1 -0
- package/dist/engine/session/import-validate.js +92 -0
- package/dist/engine/session/import-validate.js.map +1 -0
- package/dist/engine/session/memory-repo.d.ts +25 -0
- package/dist/engine/session/memory-repo.d.ts.map +1 -0
- package/dist/engine/session/memory-repo.js +59 -0
- package/dist/engine/session/memory-repo.js.map +1 -0
- package/dist/engine/session/memory-storage.d.ts +14 -0
- package/dist/engine/session/memory-storage.d.ts.map +1 -0
- package/dist/engine/session/memory-storage.js +17 -0
- package/dist/engine/session/memory-storage.js.map +1 -0
- package/dist/engine/session/repo-utils.d.ts +11 -0
- package/dist/engine/session/repo-utils.d.ts.map +1 -0
- package/dist/engine/session/repo-utils.js +40 -0
- package/dist/engine/session/repo-utils.js.map +1 -0
- package/dist/engine/session/session.d.ts +34 -0
- package/dist/engine/session/session.d.ts.map +1 -0
- package/dist/engine/session/session.js +227 -0
- package/dist/engine/session/session.js.map +1 -0
- package/dist/engine/session/storage-base.d.ts +38 -0
- package/dist/engine/session/storage-base.d.ts.map +1 -0
- package/dist/engine/session/storage-base.js +157 -0
- package/dist/engine/session/storage-base.js.map +1 -0
- package/dist/engine/session/timestamps.d.ts +3 -0
- package/dist/engine/session/timestamps.d.ts.map +1 -0
- package/dist/engine/session/timestamps.js +15 -0
- package/dist/engine/session/timestamps.js.map +1 -0
- package/dist/engine/session/uuid.d.ts +2 -0
- package/dist/engine/session/uuid.d.ts.map +1 -0
- package/dist/engine/session/uuid.js +50 -0
- package/dist/engine/session/uuid.js.map +1 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +374 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/harness.d.ts +26 -0
- package/dist/internal/harness.d.ts.map +1 -0
- package/dist/internal/harness.js +24 -0
- package/dist/internal/harness.js.map +1 -0
- package/dist/internal/llm.d.ts +9 -0
- package/dist/internal/llm.d.ts.map +1 -0
- package/dist/internal/llm.js +8 -0
- package/dist/internal/llm.js.map +1 -0
- package/dist/orchestration/builtin-workflows.d.ts +44 -0
- package/dist/orchestration/builtin-workflows.d.ts.map +1 -0
- package/dist/orchestration/builtin-workflows.js +165 -0
- package/dist/orchestration/builtin-workflows.js.map +1 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts +24 -0
- package/dist/orchestration/dev-vm-script-runner.d.ts.map +1 -0
- package/dist/orchestration/dev-vm-script-runner.js +106 -0
- package/dist/orchestration/dev-vm-script-runner.js.map +1 -0
- package/dist/orchestration/goal.d.ts +97 -0
- package/dist/orchestration/goal.d.ts.map +1 -0
- package/dist/orchestration/goal.js +248 -0
- package/dist/orchestration/goal.js.map +1 -0
- package/dist/orchestration/run-spec.d.ts +63 -0
- package/dist/orchestration/run-spec.d.ts.map +1 -0
- package/dist/orchestration/run-spec.js +274 -0
- package/dist/orchestration/run-spec.js.map +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +187 -0
- package/dist/orchestration/run-workflow-tool.d.ts.map +1 -0
- package/dist/orchestration/run-workflow-tool.js +612 -0
- package/dist/orchestration/run-workflow-tool.js.map +1 -0
- package/dist/orchestration/workflow-governance.d.ts +70 -0
- package/dist/orchestration/workflow-governance.d.ts.map +1 -0
- package/dist/orchestration/workflow-governance.js +176 -0
- package/dist/orchestration/workflow-governance.js.map +1 -0
- package/dist/orchestration/workflow-meta.d.ts +41 -0
- package/dist/orchestration/workflow-meta.d.ts.map +1 -0
- package/dist/orchestration/workflow-meta.js +426 -0
- package/dist/orchestration/workflow-meta.js.map +1 -0
- package/dist/orchestration/workflow-observe.d.ts +77 -0
- package/dist/orchestration/workflow-observe.d.ts.map +1 -0
- package/dist/orchestration/workflow-observe.js +177 -0
- package/dist/orchestration/workflow-observe.js.map +1 -0
- package/dist/orchestration/workflow-primitives.d.ts +31 -0
- package/dist/orchestration/workflow-primitives.d.ts.map +1 -0
- package/dist/orchestration/workflow-primitives.js +104 -0
- package/dist/orchestration/workflow-primitives.js.map +1 -0
- package/dist/orchestration/workflow-sandbox-conformance.d.ts +34 -0
- package/dist/orchestration/workflow-sandbox-conformance.d.ts.map +1 -0
- package/dist/orchestration/workflow-sandbox-conformance.js +301 -0
- package/dist/orchestration/workflow-sandbox-conformance.js.map +1 -0
- package/dist/orchestration/workflow-script-runner.d.ts +127 -0
- package/dist/orchestration/workflow-script-runner.d.ts.map +1 -0
- package/dist/orchestration/workflow-script-runner.js +48 -0
- package/dist/orchestration/workflow-script-runner.js.map +1 -0
- package/dist/orchestration/workflow-script-store.d.ts +99 -0
- package/dist/orchestration/workflow-script-store.d.ts.map +1 -0
- package/dist/orchestration/workflow-script-store.js +133 -0
- package/dist/orchestration/workflow-script-store.js.map +1 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +50 -0
- package/dist/orchestration/workflow-size-guideline.d.ts.map +1 -0
- package/dist/orchestration/workflow-size-guideline.js +78 -0
- package/dist/orchestration/workflow-size-guideline.js.map +1 -0
- package/dist/orchestration/workflow.d.ts +624 -0
- package/dist/orchestration/workflow.d.ts.map +1 -0
- package/dist/orchestration/workflow.js +1596 -0
- package/dist/orchestration/workflow.js.map +1 -0
- package/dist/prompts/default.d.ts +474 -0
- package/dist/prompts/default.d.ts.map +1 -0
- package/dist/prompts/default.js +676 -0
- package/dist/prompts/default.js.map +1 -0
- package/dist/prompts/supervisor.d.ts +60 -0
- package/dist/prompts/supervisor.d.ts.map +1 -0
- package/dist/prompts/supervisor.js +162 -0
- package/dist/prompts/supervisor.js.map +1 -0
- package/dist/scenarios/env.d.ts +41 -0
- package/dist/scenarios/env.d.ts.map +1 -0
- package/dist/scenarios/env.js +65 -0
- package/dist/scenarios/env.js.map +1 -0
- package/dist/scenarios/full-body.d.ts +47 -0
- package/dist/scenarios/full-body.d.ts.map +1 -0
- package/dist/scenarios/full-body.js +36 -0
- package/dist/scenarios/full-body.js.map +1 -0
- package/dist/scenarios/scenario-registry.d.ts +107 -0
- package/dist/scenarios/scenario-registry.d.ts.map +1 -0
- package/dist/scenarios/scenario-registry.js +192 -0
- package/dist/scenarios/scenario-registry.js.map +1 -0
- package/dist/scenarios/teacher-quickstart.d.ts +41 -0
- package/dist/scenarios/teacher-quickstart.d.ts.map +1 -0
- package/dist/scenarios/teacher-quickstart.js +32 -0
- package/dist/scenarios/teacher-quickstart.js.map +1 -0
- package/dist/server/http.d.ts +36 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +144 -0
- package/dist/server/http.js.map +1 -0
- package/dist/stores/file/checkpoint-store.d.ts +62 -0
- package/dist/stores/file/checkpoint-store.d.ts.map +1 -0
- package/dist/stores/file/checkpoint-store.js +250 -0
- package/dist/stores/file/checkpoint-store.js.map +1 -0
- package/dist/stores/file/file-snapshot-store.d.ts +43 -0
- package/dist/stores/file/file-snapshot-store.d.ts.map +1 -0
- package/dist/stores/file/file-snapshot-store.js +374 -0
- package/dist/stores/file/file-snapshot-store.js.map +1 -0
- package/dist/stores/file/fs-atomic.d.ts +95 -0
- package/dist/stores/file/fs-atomic.d.ts.map +1 -0
- package/dist/stores/file/fs-atomic.js +415 -0
- package/dist/stores/file/fs-atomic.js.map +1 -0
- package/dist/stores/file/index.d.ts +98 -0
- package/dist/stores/file/index.d.ts.map +1 -0
- package/dist/stores/file/index.js +109 -0
- package/dist/stores/file/index.js.map +1 -0
- package/dist/stores/file/memory-store.d.ts +95 -0
- package/dist/stores/file/memory-store.d.ts.map +1 -0
- package/dist/stores/file/memory-store.js +393 -0
- package/dist/stores/file/memory-store.js.map +1 -0
- package/dist/stores/file/session-policy-store.d.ts +24 -0
- package/dist/stores/file/session-policy-store.d.ts.map +1 -0
- package/dist/stores/file/session-policy-store.js +123 -0
- package/dist/stores/file/session-policy-store.js.map +1 -0
- package/dist/stores/file/session-store.d.ts +34 -0
- package/dist/stores/file/session-store.d.ts.map +1 -0
- package/dist/stores/file/session-store.js +175 -0
- package/dist/stores/file/session-store.js.map +1 -0
- package/dist/stores/file/tool-result-store.d.ts +23 -0
- package/dist/stores/file/tool-result-store.d.ts.map +1 -0
- package/dist/stores/file/tool-result-store.js +61 -0
- package/dist/stores/file/tool-result-store.js.map +1 -0
- package/dist/stores/file/workflow-journal-store.d.ts +36 -0
- package/dist/stores/file/workflow-journal-store.d.ts.map +1 -0
- package/dist/stores/file/workflow-journal-store.js +157 -0
- package/dist/stores/file/workflow-journal-store.js.map +1 -0
- package/dist/stores/file/workflow-run-store.d.ts +58 -0
- package/dist/stores/file/workflow-run-store.d.ts.map +1 -0
- package/dist/stores/file/workflow-run-store.js +178 -0
- package/dist/stores/file/workflow-run-store.js.map +1 -0
- package/dist/stores/pg.d.ts +210 -0
- package/dist/stores/pg.d.ts.map +1 -0
- package/dist/stores/pg.js +652 -0
- package/dist/stores/pg.js.map +1 -0
- package/dist/tools/fs/encoding.d.ts +51 -0
- package/dist/tools/fs/encoding.d.ts.map +1 -0
- package/dist/tools/fs/encoding.js +74 -0
- package/dist/tools/fs/encoding.js.map +1 -0
- package/dist/tools/fs/gh-rate-limit.d.ts +19 -0
- package/dist/tools/fs/gh-rate-limit.d.ts.map +1 -0
- package/dist/tools/fs/gh-rate-limit.js +35 -0
- package/dist/tools/fs/gh-rate-limit.js.map +1 -0
- package/dist/tools/fs/index.d.ts +246 -0
- package/dist/tools/fs/index.d.ts.map +1 -0
- package/dist/tools/fs/index.js +2130 -0
- package/dist/tools/fs/index.js.map +1 -0
- package/dist/tools/fs/pdf.d.ts +106 -0
- package/dist/tools/fs/pdf.d.ts.map +1 -0
- package/dist/tools/fs/pdf.js +178 -0
- package/dist/tools/fs/pdf.js.map +1 -0
- package/dist/tools/fs/repo-map.d.ts +15 -0
- package/dist/tools/fs/repo-map.d.ts.map +1 -0
- package/dist/tools/fs/repo-map.js +251 -0
- package/dist/tools/fs/repo-map.js.map +1 -0
- package/dist/tools/fs/safety.d.ts +168 -0
- package/dist/tools/fs/safety.d.ts.map +1 -0
- package/dist/tools/fs/safety.js +479 -0
- package/dist/tools/fs/safety.js.map +1 -0
- package/dist/tools/fs/search.d.ts +118 -0
- package/dist/tools/fs/search.d.ts.map +1 -0
- package/dist/tools/fs/search.js +650 -0
- package/dist/tools/fs/search.js.map +1 -0
- package/dist/tools/gitea-issue.d.ts +39 -0
- package/dist/tools/gitea-issue.d.ts.map +1 -0
- package/dist/tools/gitea-issue.js +91 -0
- package/dist/tools/gitea-issue.js.map +1 -0
- package/dist/tools/monitor.d.ts +64 -0
- package/dist/tools/monitor.d.ts.map +1 -0
- package/dist/tools/monitor.js +135 -0
- package/dist/tools/monitor.js.map +1 -0
- package/dist/tools/scheduler-tools.d.ts +48 -0
- package/dist/tools/scheduler-tools.d.ts.map +1 -0
- package/dist/tools/scheduler-tools.js +449 -0
- package/dist/tools/scheduler-tools.js.map +1 -0
- package/dist/tools/sql-adapters.d.ts +32 -0
- package/dist/tools/sql-adapters.d.ts.map +1 -0
- package/dist/tools/sql-adapters.js +31 -0
- package/dist/tools/sql-adapters.js.map +1 -0
- package/dist/tools/sql.d.ts +36 -0
- package/dist/tools/sql.d.ts.map +1 -0
- package/dist/tools/sql.js +131 -0
- package/dist/tools/sql.js.map +1 -0
- package/dist/tools/task-list.d.ts +26 -0
- package/dist/tools/task-list.d.ts.map +1 -0
- package/dist/tools/task-list.js +352 -0
- package/dist/tools/task-list.js.map +1 -0
- package/dist/tools/todo.d.ts +11 -0
- package/dist/tools/todo.d.ts.map +1 -0
- package/dist/tools/todo.js +126 -0
- package/dist/tools/todo.js.map +1 -0
- package/dist/tools/web.d.ts +59 -0
- package/dist/tools/web.d.ts.map +1 -0
- package/dist/tools/web.js +607 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/tools/worktree.d.ts +88 -0
- package/dist/tools/worktree.d.ts.map +1 -0
- package/dist/tools/worktree.js +434 -0
- package/dist/tools/worktree.js.map +1 -0
- package/docs/A1-ATTRIBUTION-ROUND1-2026-07-09.md +181 -0
- package/docs/AB-ORACLE-GATE-VERDICT-2026-07-10.md +100 -0
- package/docs/ANCHOR-GAP-INVENTORY-2026-07-09.md +143 -0
- package/docs/ARCHITECTURE.md +125 -0
- package/docs/BUGHUNT-2026-07-05-NIGHT.md +98 -0
- package/docs/BUILD.md +63 -0
- package/docs/CANCEL-ASYNC-ATTRIBUTION-2026-07-09.md +98 -0
- package/docs/CC-198-VS-201-DRIFT-2026-07-09.md +70 -0
- package/docs/CC-BASELINE-FAKE-ZERO-AUDIT-2026-07-09.md +51 -0
- package/docs/CC-DRIFT-198-206-AGENT-TYPES-2026-07-10.md +82 -0
- package/docs/CC-DRIFT-198-206-CHANGELOG-2026-07-10.md +82 -0
- package/docs/CC-DRIFT-198-206-REMINDERS-2026-07-10.md +96 -0
- package/docs/CC-DRIFT-198-206-ROADMAP-2026-07-10.md +110 -0
- package/docs/CC-DRIFT-198-206-TOOL-INVENTORY-2026-07-10.md +53 -0
- package/docs/CC-DRIFT-198-206-USAGE-CONSTANTS-2026-07-10.md +64 -0
- package/docs/CC-DRIFT-198-206-WORKFLOW-2026-07-10.md +83 -0
- package/docs/CC-PARITY-CHECKLIST.md +220 -0
- package/docs/CC-PARITY-DEEP-SWEEP-2026-07-07.md +149 -0
- package/docs/CC-SUBAGENT-PROMPT-STUDY-2026-07-09.md +219 -0
- package/docs/CC-TASK-REMINDER-CADENCE-STUDY-2026-07-09.md +396 -0
- package/docs/CC-TOOL-PARITY-SWEEP-2026-07.md +56 -0
- package/docs/CC-TOOL-PROMPT-DEEP-DIFF-2026-07-08.md +274 -0
- package/docs/CC-TOOLSURFACE-DEEP-DIVE-2026-07-07.md +197 -0
- package/docs/CC206-OBSERVER-ANCHORS-2026-07-11.md +463 -0
- package/docs/CC207-CORE-SWEEP-BACKLOG-2026-07-12.md +155 -0
- package/docs/CENTER-CONTROL-PLANE-SEAM.md +86 -0
- package/docs/CLEANUP-CONTRACT-ANCHOR-2026-07-09.md +83 -0
- package/docs/COLD-START-RSI-2026-07-09.md +72 -0
- package/docs/COMPACTION-LIVE-AUDIT-2026-07-09.md +114 -0
- package/docs/CONTEXT-lifecycle-extension-points-and-stop-attribution.md +71 -0
- package/docs/COREWARS-POLYGLOT-TRIAGE-2026-07-09.md +85 -0
- package/docs/DEADTARGET-OVERFULL-HBOX-2026-07-10.md +92 -0
- package/docs/DEADTARGET-PATH-TRACING-REVERSE-2026-07-10.md +87 -0
- package/docs/DEADTARGET-WINNING-AVG-COREWARS-2026-07-10.md +96 -0
- package/docs/DEEPSEEK-API-LIMITS-PROBE-2026-07-09.md +118 -0
- package/docs/DESIGN-140-MOCK-VERIFY-2026-07-11.md +79 -0
- package/docs/DESIGN-140-VERIFICATION-2026-07-11.md +43 -0
- package/docs/DESIGN-DRAFT-workflow-collab-2026-07-11.md +56 -0
- package/docs/DESIGN-ORACLE-GROUNDING-GATE-2026-07-10.md +167 -0
- package/docs/DESIGN-TFRAG-RECONCILE-SCAFFOLD-2026-07-09.md +102 -0
- package/docs/EXP-PA2-PE-DESIGN-2026-07-11.md +220 -0
- package/docs/EXT-DOGFOOD-2026-07-12.md +50 -0
- package/docs/FINAL-VERIFY-SURFACE-AUDIT-2026-07-09.md +44 -0
- package/docs/FRAG-RECON-INVESTIGATION-2026-07-09.md +183 -0
- package/docs/HANDOFF.md +121 -0
- package/docs/KNOWN-ISSUES.md +96 -0
- package/docs/LEGW-WINDOW-TAX-2026-07-10.md +82 -0
- package/docs/LIVE-PROBE-BATCH-2026-07-11.md +207 -0
- package/docs/M2-CERT-ATTRIBUTION-2026-07-10.md +61 -0
- package/docs/M25-LEG-VARIANCE-ATTRIBUTION-2026-07-10.md +81 -0
- package/docs/MAILMAN-TIMEOUT-ATTRIBUTION-2026-07-10.md +88 -0
- package/docs/MEMORY-BACKEND-DIALECT-NOTES.md +69 -0
- package/docs/MTEB-ESCAPE-HATCH-ATTRIBUTION-2026-07-09.md +57 -0
- package/docs/MTEB-LEADERBOARD-ATTRIBUTION-2026-07-10.md +134 -0
- package/docs/ORACLE-GATE-NEGATIVE-SAMPLE-2026-07-11.md +28 -0
- package/docs/PARITY-CONTEXT-TRANSACTIONS-2026-07-10.md +67 -0
- package/docs/PARITY-PROGRESS-MATRIX-2026-07-10.md +37 -0
- package/docs/PARITY-SPOT-AGENT-TYPES-2026-07-10.md +70 -0
- package/docs/PARITY-SPOT-REMINDERS-2026-07-10.md +144 -0
- package/docs/PARITY-SPOT-TOOL-INVENTORY-2026-07-10.md +61 -0
- package/docs/PARITY-SPOT-USAGE-CONSTANTS-2026-07-10.md +95 -0
- package/docs/PARITY-SPOT-WORKFLOW-2026-07-10.md +93 -0
- package/docs/PASSWORD-RECOVERY-PANEL-VERDICT-2026-07-10.md +62 -0
- package/docs/R8-R9-FINALIZE-COORDINATION-2026-07-09.md +124 -0
- package/docs/REPL-CODE-MODE-EVALUATION-2026-07-10.md +187 -0
- package/docs/REPORT-1249-TARGETED.md +48 -0
- package/docs/RESEARCH-3P-MEMORY-SWAP-2026-07-12.md +273 -0
- package/docs/ROADMAP.md +111 -0
- package/docs/RSI-CLOUD-DEPLOY-2026-07-06.md +289 -0
- package/docs/RSI-PROCESS-AI-COLDSTART-2026-07-11.md +68 -0
- package/docs/S18-THOROUGHNESS-AUDIT-2026-07-09.md +113 -0
- package/docs/SERVICE-INTEGRATION-GUIDE.md +298 -0
- package/docs/SUBAGENT-STREAM-RESILIENCE-PARITY-2026-07-10.md +118 -0
- package/docs/SWEBENCH-PRO-RECON-2026-07-11.md +31 -0
- package/docs/TB-EFFICIENCY-TELEMETRY-2026-07-08.md +114 -0
- package/docs/TB-FAILURE-AUTOPSY-2026-07-05-RERUN.md +67 -0
- package/docs/TB-FAIRNESS-AUDIT-2026-07-08.md +141 -0
- package/docs/TB-FULL-1257-2026-07-08.md +77 -0
- package/docs/TB-LEG-GAP-ATTRIBUTION-1261-1263-2026-07-11.md +154 -0
- package/docs/TB-REGRESSION-DAEMON-KILL-2026-07-08.md +58 -0
- package/docs/TB-RSI-CROSSCHECK-2026-07-06.md +68 -0
- package/docs/TB-RSI-LEDGER.md +30 -0
- package/docs/TB-STABLE-SET-2026-07-08.md +127 -0
- package/docs/TB21-RECON-2026-07-11.md +28 -0
- package/docs/TEST-DESIGN-BATCH-1-2-3.md +97 -0
- package/docs/THIRD-PARTY-INTEGRATION.md +45 -0
- package/docs/TOKEN-ESTIMATE-CALIBRATION-LIVE-2026-07-09.md +102 -0
- package/docs/audit-2026-06-10-/347/254/254/344/272/214/350/275/256-/347/251/272/347/231/275/345/214/272/344/270/216/345/277/230/346/216/245/347/272/277.md +147 -0
- package/docs/audit-2026-06-10-/350/256/241/347/256/227bug/346/211/253/346/217/217.md +163 -0
- package/docs/audit-2026-06-11-/344/277/256/345/244/215/345/244/215/345/256/241/344/270/216/345/233/236/345/275/222/344/270/223/346/211/253.md +95 -0
- package/docs/audit-2026-06-12-design71-P1/346/275/234/344/274/217/351/235/242/350/243/201/345/206/263/344/270/216/345/220/236/351/224/231/345/256/241/350/256/241.md +45 -0
- package/docs/audit-2026-06-12-/345/205/254/345/274/200/346/227/213/351/222/256/346/264/273/346/200/247/344/270/216vendored/346/255/273/350/267/257.md +63 -0
- package/docs/audit-2026-06-15/ADDENDUM-second-pass.md +88 -0
- package/docs/audit-2026-06-15/ARCHITECTURE-AND-ROADMAP.md +187 -0
- package/docs/audit-2026-06-15/DOC-CORRECTIONS.md +105 -0
- package/docs/audit-2026-06-15/INDEX.md +49 -0
- package/docs/audit-2026-06-15/ORCHESTRATION-STATUS.md +98 -0
- package/docs/audit-2026-06-15/PRODUCTION-ISSUES.md +189 -0
- package/docs/audit-2026-06-15/REFERENCES-literature.md +139 -0
- package/docs/audit-2026-06-15/VENDOR-REFACTOR-PLAN.md +96 -0
- package/docs/cc-probe-198/README.md +72 -0
- package/docs/cc-probe-198/STABILITY-AUDIT.md +118 -0
- package/docs/cc-probe-198/live-schema-monitor-worktree-2026-07-09.json +56 -0
- package/docs/cc-probe-198/mount-variants.json +536 -0
- package/docs/cc-probe-198/plan-mode-run.json +1 -0
- package/docs/cc-probe-198/probe-bash-bg.json +224 -0
- package/docs/cc-probe-198/probe-edit-mismatch.json +120 -0
- package/docs/cc-probe-198/probe-read-missing.json +62 -0
- package/docs/cc-probe-198/probe-search-empty.json +127 -0
- package/docs/cc-probe-198/probe-task-family.json +227 -0
- package/docs/cc-probe-198/probes.status +6 -0
- package/docs/cc-probe-198/raw-capture-interactive.json +948 -0
- package/docs/cc-probe-198/raw-capture-print.json +787 -0
- package/docs/cc-probe-198/raw-capture2-interactive.json +948 -0
- package/docs/cc-probe-198/raw-capture2-print.json +787 -0
- package/docs/cc-probe-198/system-prompt.txt +135 -0
- package/docs/cc-probe-198/tools-array.json +962 -0
- package/docs/durability-boundary.md +63 -0
- package/docs/fix-2026-06-10-/350/256/241/347/256/227bug/344/277/256/345/244/215-search/346/211/271.md +75 -0
- package/docs/fix-2026-06-11-/347/254/254/344/272/214/350/275/256-/344/277/256/345/244/215-search/346/211/271.md +62 -0
- package/docs/parity-sweep/REPORT-DYNAMIC.md +97 -0
- package/docs/parity-sweep/REPORT-STATIC-GGB.md +127 -0
- package/docs/parity-sweep/REPORT-STATIC-RWE.md +133 -0
- package/docs/vendor-history.md +385 -0
- package/docs/vendored-upstream-diff-2026-07.md +83 -0
- package/package.json +70 -0
|
@@ -0,0 +1,1031 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { closeSync, constants, createReadStream, mkdtempSync, openSync, readSync, statSync } from "node:fs";
|
|
4
|
+
import { access, appendFile, lstat, mkdir, mkdtemp, readdir, readFile, readlink, realpath, rm, writeFile, } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
7
|
+
import { createInterface } from "node:readline";
|
|
8
|
+
import { ExecutionError, err, FileError, ok, toError, } from "../harness/types.js";
|
|
9
|
+
import { killProcessTree } from "./kill-tree.js";
|
|
10
|
+
// Naturalized (design/71 P2, design/103): the secret-env scrubber + the exec output-tail bound are first-party
|
|
11
|
+
// (src/core/{secret-env,exec-output-tail}.ts) — the canonical homes. This naturalized env consumes them (single source).
|
|
12
|
+
import { scrubSecretEnv } from "../../core/secret-env.js";
|
|
13
|
+
import { RollingTailBuffer, markTruncated } from "../../core/exec-output-tail.js";
|
|
14
|
+
import { BackgroundShellError } from "../../core/background-shell.js";
|
|
15
|
+
import { SchedulerError } from "../../core/scheduler.js";
|
|
16
|
+
const MAX_TIMER_TIMEOUT_MS = 2_147_000_000;
|
|
17
|
+
function resolvePath(cwd, path) {
|
|
18
|
+
return isAbsolute(path) ? path : resolve(cwd, path);
|
|
19
|
+
}
|
|
20
|
+
/** Convert user-facing timeout seconds into a positive, timer-safe millisecond delay. */
|
|
21
|
+
export function resolveExecTimeoutMs(timeoutSeconds) {
|
|
22
|
+
if (typeof timeoutSeconds !== "number" ||
|
|
23
|
+
!Number.isFinite(timeoutSeconds) ||
|
|
24
|
+
timeoutSeconds <= 0) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const milliseconds = Math.floor(timeoutSeconds * 1000);
|
|
28
|
+
if (!Number.isFinite(milliseconds) || milliseconds <= 0) {
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
return Math.min(milliseconds, MAX_TIMER_TIMEOUT_MS);
|
|
32
|
+
}
|
|
33
|
+
function fileKindFromStats(stats) {
|
|
34
|
+
if (stats.isFile()) {
|
|
35
|
+
return "file";
|
|
36
|
+
}
|
|
37
|
+
if (stats.isDirectory()) {
|
|
38
|
+
return "directory";
|
|
39
|
+
}
|
|
40
|
+
if (stats.isSymbolicLink()) {
|
|
41
|
+
return "symlink";
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
function fileInfoFromStats(path, stats) {
|
|
46
|
+
const kind = fileKindFromStats(stats);
|
|
47
|
+
if (!kind) {
|
|
48
|
+
return err(new FileError("invalid", "Unsupported file type", path));
|
|
49
|
+
}
|
|
50
|
+
return ok({
|
|
51
|
+
// [K-PLATFORM-SWEEP] MAJOR#4: dual-family basename — a win32 native path is backslash-form, and the
|
|
52
|
+
// "/"-only split returned the WHOLE absolute path as `name` (ignoreDirs/name matching all broke).
|
|
53
|
+
name: (() => {
|
|
54
|
+
const t = path.replace(/[\\/]+$/, "");
|
|
55
|
+
return t.slice(Math.max(t.lastIndexOf("/"), t.lastIndexOf("\\")) + 1) || path;
|
|
56
|
+
})(),
|
|
57
|
+
path,
|
|
58
|
+
kind,
|
|
59
|
+
size: stats.size,
|
|
60
|
+
mtimeMs: stats.mtimeMs,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function isNodeError(error) {
|
|
64
|
+
return error instanceof Error && "code" in error;
|
|
65
|
+
}
|
|
66
|
+
function toFileError(error, path) {
|
|
67
|
+
if (error instanceof FileError) {
|
|
68
|
+
return error;
|
|
69
|
+
}
|
|
70
|
+
const cause = toError(error);
|
|
71
|
+
if (isNodeError(error)) {
|
|
72
|
+
const message = error.message;
|
|
73
|
+
switch (error.code) {
|
|
74
|
+
case "ABORT_ERR":
|
|
75
|
+
return new FileError("aborted", message, path, cause);
|
|
76
|
+
case "ENOENT":
|
|
77
|
+
return new FileError("not_found", message, path, cause);
|
|
78
|
+
case "EACCES":
|
|
79
|
+
case "EPERM":
|
|
80
|
+
return new FileError("permission_denied", message, path, cause);
|
|
81
|
+
case "ENOTDIR":
|
|
82
|
+
return new FileError("not_directory", message, path, cause);
|
|
83
|
+
case "EISDIR":
|
|
84
|
+
return new FileError("is_directory", message, path, cause);
|
|
85
|
+
case "EINVAL":
|
|
86
|
+
return new FileError("invalid", message, path, cause);
|
|
87
|
+
default:
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return new FileError("unknown", cause.message, path, cause);
|
|
92
|
+
}
|
|
93
|
+
function abortResult(signal, path) {
|
|
94
|
+
return signal?.aborted ? err(new FileError("aborted", "aborted", path)) : undefined;
|
|
95
|
+
}
|
|
96
|
+
async function pathExists(path) {
|
|
97
|
+
try {
|
|
98
|
+
await access(path, constants.F_OK);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function runCommand(command, args, timeoutMs) {
|
|
106
|
+
return await new Promise((resolveLocal) => {
|
|
107
|
+
let stdout = "";
|
|
108
|
+
let child;
|
|
109
|
+
try {
|
|
110
|
+
child = spawn(command, args, {
|
|
111
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
112
|
+
windowsHide: true,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
resolveLocal({ stdout: "", status: null });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const timeout = setTimeout(() => {
|
|
120
|
+
if (child.pid) {
|
|
121
|
+
killProcessTree(child.pid, { force: true });
|
|
122
|
+
}
|
|
123
|
+
}, timeoutMs);
|
|
124
|
+
child.stdout?.setEncoding("utf8");
|
|
125
|
+
child.stdout?.on("data", (chunk) => {
|
|
126
|
+
stdout += chunk;
|
|
127
|
+
});
|
|
128
|
+
// Upstream-parity fix (2026-07 diff, openclaw e779abf70e class): a stream-level error (e.g. EPIPE)
|
|
129
|
+
// on an un-listened stdio stream is an UNCAUGHT exception that crashes the host process. Swallow it;
|
|
130
|
+
// the child's own error/close handlers still settle the promise.
|
|
131
|
+
child.stdout?.on("error", () => { });
|
|
132
|
+
child.on("error", () => {
|
|
133
|
+
clearTimeout(timeout);
|
|
134
|
+
resolveLocal({ stdout: "", status: null });
|
|
135
|
+
});
|
|
136
|
+
child.on("close", (status) => {
|
|
137
|
+
clearTimeout(timeout);
|
|
138
|
+
resolveLocal({ stdout, status });
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/** service [377] review finding (win32): `where bash.exe` can resolve to `System32\bash.exe` — the
|
|
143
|
+
* WSL LAUNCHER, not a native shell. Running it drops into a Linux subsystem where Windows cwd/paths
|
|
144
|
+
* do not exist; silently adopting it is exactly the "wrong shell, false green" failure D1 forbids.
|
|
145
|
+
* Filter it (and the WindowsApps alias) out of PATH discovery; Git-Bash candidates are tried first. */
|
|
146
|
+
export function isWslBashLauncher(p) {
|
|
147
|
+
return /[/\\](system32|windowsapps)[/\\]bash\.exe$/i.test(p);
|
|
148
|
+
}
|
|
149
|
+
async function findBashOnPath() {
|
|
150
|
+
const result = process.platform === "win32"
|
|
151
|
+
? await runCommand("where", ["bash.exe"], 5000)
|
|
152
|
+
: await runCommand("which", ["bash"], 5000);
|
|
153
|
+
if (result.status !== 0 || !result.stdout) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const lines = result.stdout.trim().split(/\r?\n/);
|
|
157
|
+
const firstMatch = process.platform === "win32" ? lines.find((l) => !isWslBashLauncher(l)) : lines[0];
|
|
158
|
+
return firstMatch && (await pathExists(firstMatch)) ? firstMatch : null;
|
|
159
|
+
}
|
|
160
|
+
/** Shell discovery for the platform (service [377] ask ①: exported as the single SDK source so a host
|
|
161
|
+
* adapter does not mirror the platform logic). Explicit `customShellPath` wins (missing → err);
|
|
162
|
+
* win32 = Git-Bash discovery (ProgramFiles → PATH, WSL launcher filtered) with fail-loud
|
|
163
|
+
* `shell_unavailable` (never a silent cmd.exe fallback); POSIX = /bin/bash → PATH bash → sh. */
|
|
164
|
+
export async function getShellConfig(customShellPath) {
|
|
165
|
+
if (customShellPath) {
|
|
166
|
+
if (await pathExists(customShellPath)) {
|
|
167
|
+
return ok({ shell: customShellPath, args: ["-c"] });
|
|
168
|
+
}
|
|
169
|
+
return err(new ExecutionError("shell_unavailable", `Custom shell path not found: ${customShellPath}`));
|
|
170
|
+
}
|
|
171
|
+
if (process.platform === "win32") {
|
|
172
|
+
const candidates = [];
|
|
173
|
+
const programFiles = process.env.ProgramFiles;
|
|
174
|
+
if (programFiles) {
|
|
175
|
+
candidates.push(`${programFiles}\\Git\\bin\\bash.exe`);
|
|
176
|
+
}
|
|
177
|
+
const programFilesX86 = process.env["ProgramFiles(x86)"];
|
|
178
|
+
if (programFilesX86) {
|
|
179
|
+
candidates.push(`${programFilesX86}\\Git\\bin\\bash.exe`);
|
|
180
|
+
}
|
|
181
|
+
for (const candidate of candidates) {
|
|
182
|
+
if (await pathExists(candidate)) {
|
|
183
|
+
return ok({ shell: candidate, args: ["-c"] });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const bashOnPath = await findBashOnPath();
|
|
187
|
+
if (bashOnPath) {
|
|
188
|
+
return ok({ shell: bashOnPath, args: ["-c"] });
|
|
189
|
+
}
|
|
190
|
+
return err(new ExecutionError("shell_unavailable", "No bash shell found"));
|
|
191
|
+
}
|
|
192
|
+
if (await pathExists("/bin/bash")) {
|
|
193
|
+
return ok({ shell: "/bin/bash", args: ["-c"] });
|
|
194
|
+
}
|
|
195
|
+
const bashOnPath = await findBashOnPath();
|
|
196
|
+
if (bashOnPath) {
|
|
197
|
+
return ok({ shell: bashOnPath, args: ["-c"] });
|
|
198
|
+
}
|
|
199
|
+
return ok({ shell: "sh", args: ["-c"] });
|
|
200
|
+
}
|
|
201
|
+
// VENDORED EDIT (D2, naturalized): the per-stream rolling-TAIL output bound was extracted to the first-party
|
|
202
|
+
// `src/core/exec-output-tail.ts` (canonical, vendor-independent — OUR robustness invariant, shared with a
|
|
203
|
+
// downstream exec adapter [267], survives de-vendoring). This (temporary) vendored env CONSUMES it. The first-
|
|
204
|
+
// party `bash` tool calls `exec` with NO onStdout/onStderr, so a `cat big.bin | base64` / `yes` would otherwise
|
|
205
|
+
// grow the durable worker heap to the full output within the 120s/600s timeout — RollingTailBuffer keeps the tail.
|
|
206
|
+
/** VENDORED EDIT (D5): grace window to FORCE-settle an exec whose `close` never fires after a kill (a re-parented
|
|
207
|
+
* grandchild holding the stdout pipe / a D-state process) so an abort/timeout the engine requested can finalize. */
|
|
208
|
+
const EXEC_FORCE_SETTLE_GRACE_MS = 3000;
|
|
209
|
+
/** VENDORED EDIT (sema vendored bug-hunt D1, security): env keys whose VALUE is a secret a model-driven shell
|
|
210
|
+
* must not read. Matched on the trailing segment so `DEEPSEEK_API_KEY`/`GIT_API_TOKEN`/`AWS_SECRET_ACCESS_KEY`/
|
|
211
|
+
* `*_PASSWORD` are dropped while `API_BASE_URL`/`ANDROID_HOME`/`NODE_ENV`/`SSH_AUTH_SOCK` are kept (low breakage). */
|
|
212
|
+
// VENDORED EDIT (D1, naturalized): the secret-env PATTERN + scrubber were extracted to the first-party
|
|
213
|
+
// `src/core/secret-env.ts` (the canonical, vendor-independent home — it is OUR security invariant, shared with a
|
|
214
|
+
// downstream host adapter [265], and must survive the planned de-vendoring). This (temporary) vendored env just
|
|
215
|
+
// CONSUMES it, so there is a single source of the pattern with zero drift.
|
|
216
|
+
/**
|
|
217
|
+
* VENDORED EDIT (sema vendored bug-hunt D1, security/DRAG): the harness was distilled from CC's INTERACTIVE model
|
|
218
|
+
* where the human owns the env; in our AUTONOMOUS model a model-chosen `printenv DEEPSEEK_API_KEY` via the `bash`
|
|
219
|
+
* tool would otherwise exfiltrate the orchestrator's brain key / git token / DB creds (the gate authorizes WHICH
|
|
220
|
+
* tool runs, NOT isolation). So the shell child's env is FAIL-CLOSED by default: `scrub` drops secret-pattern keys
|
|
221
|
+
* (keeps PATH/build/locale vars → low breakage). `inheritEnv:"all"` is the explicit opt-out (e.g. a trusted local
|
|
222
|
+
* dev); a `string[]` is a strict allowlist. `baseEnv`/`extraEnv` (caller-supplied) always pass through verbatim.
|
|
223
|
+
*/
|
|
224
|
+
function getShellEnv(inheritEnv, baseEnv, extraEnv) {
|
|
225
|
+
let inherited;
|
|
226
|
+
if (inheritEnv === "all") {
|
|
227
|
+
inherited = process.env;
|
|
228
|
+
}
|
|
229
|
+
else if (Array.isArray(inheritEnv)) {
|
|
230
|
+
inherited = {};
|
|
231
|
+
for (const k of inheritEnv)
|
|
232
|
+
if (process.env[k] !== undefined)
|
|
233
|
+
inherited[k] = process.env[k];
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
inherited = scrubSecretEnv(process.env); // default "scrub"
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
...inherited,
|
|
240
|
+
...baseEnv,
|
|
241
|
+
...extraEnv,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** Node-backed execution environment for agent harness filesystem and shell operations. */
|
|
245
|
+
/** Signal name → number, to encode a signal-terminated exit as 128+signum (shell convention; shared with exec). */
|
|
246
|
+
const SIGNUM = { SIGHUP: 1, SIGINT: 2, SIGQUIT: 3, SIGABRT: 6, SIGKILL: 9, SIGSEGV: 11, SIGPIPE: 13, SIGTERM: 15 };
|
|
247
|
+
/** design/128 T1-1 / codex 1.236 复审 R2: open the spool file pair ALL-OR-NOTHING — a failure opening the
|
|
248
|
+
* second file must close the first fd before rethrowing (the caller's catch only clears its references, so
|
|
249
|
+
* a half-open pair would leak fdOut for the env's lifetime). `wx` + 0600 (never follow / never reuse an
|
|
250
|
+
* existing path). Exported for direct fault-injection tests (pre-create a path → EEXIST). */
|
|
251
|
+
export function openSpoolPair(base) {
|
|
252
|
+
const outPath = `${base}.out.log`;
|
|
253
|
+
const errPath = `${base}.err.log`;
|
|
254
|
+
const fdOut = openSync(outPath, "wx", 0o600);
|
|
255
|
+
let fdErr;
|
|
256
|
+
try {
|
|
257
|
+
fdErr = openSync(errPath, "wx", 0o600);
|
|
258
|
+
}
|
|
259
|
+
catch (e) {
|
|
260
|
+
try {
|
|
261
|
+
closeSync(fdOut);
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
/* best-effort */
|
|
265
|
+
}
|
|
266
|
+
throw e;
|
|
267
|
+
}
|
|
268
|
+
return { outPath, errPath, fds: [fdOut, fdErr] };
|
|
269
|
+
}
|
|
270
|
+
export class NodeExecutionEnv {
|
|
271
|
+
cwd;
|
|
272
|
+
shellPath;
|
|
273
|
+
shellEnv;
|
|
274
|
+
inheritEnv;
|
|
275
|
+
// design/105: optional injected scheduler daemon backend (the flywheel's shell daemon). Absent ⇒ INERT.
|
|
276
|
+
scheduler;
|
|
277
|
+
// design/103: background-shell registry — env-local, non-durable. The shellId is opaque; poll/kill only accept ids
|
|
278
|
+
// THIS env minted (越权隔离 = Map membership; a forged/cross-tenant id resolves to not_found).
|
|
279
|
+
bgShells = new Map();
|
|
280
|
+
bgCounter = 0;
|
|
281
|
+
retainBackgroundProcesses;
|
|
282
|
+
/** design/128 T1-1: lazily-created env-owned spool dir (mkdtemp under os tmp — unpredictable, never the cwd). */
|
|
283
|
+
bgSpoolDir;
|
|
284
|
+
// Assigned in the constructor (not a field literal) so the T1-1 retain declaration can surface on the
|
|
285
|
+
// capability face — the registry's teardown sweeps gate their kills on it (TB 2026-07-08 regression).
|
|
286
|
+
backgroundCapabilities;
|
|
287
|
+
constructor(options) {
|
|
288
|
+
this.cwd = options.cwd;
|
|
289
|
+
this.shellPath = options.shellPath;
|
|
290
|
+
this.shellEnv = options.shellEnv;
|
|
291
|
+
this.inheritEnv = options.inheritEnv ?? "scrub";
|
|
292
|
+
this.scheduler = options.scheduler;
|
|
293
|
+
this.retainBackgroundProcesses = options.retainBackgroundProcesses ?? false;
|
|
294
|
+
this.backgroundCapabilities = {
|
|
295
|
+
supported: true,
|
|
296
|
+
maxConcurrent: 8,
|
|
297
|
+
defaultBgTimeoutSec: 30 * 60, // 30 min
|
|
298
|
+
maxBgTimeoutSec: 2 * 60 * 60, // 2h hard ceiling — never unbounded (design/103 §3.6)
|
|
299
|
+
supportsDetach: true, // design/116 detach: a running foreground exec can be adopted as a background shell
|
|
300
|
+
retainBackgroundProcesses: this.retainBackgroundProcesses, // design/128 T1-1 — see BackgroundShellCapability
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
// ── design/105 SchedulerCapability: pure delegation to the injected daemon backend (core holds no scheduler
|
|
304
|
+
// state — no store, no clock, no trigger). No backend ⇒ supported:false ⇒ `hasScheduler` false ⇒ tools unmounted.
|
|
305
|
+
get schedulerCapabilities() {
|
|
306
|
+
return (this.scheduler?.schedulerCapabilities ?? {
|
|
307
|
+
supported: false,
|
|
308
|
+
maxScheduledPerScope: 0,
|
|
309
|
+
minDelaySec: 0,
|
|
310
|
+
minCronIntervalSec: 0,
|
|
311
|
+
maxScheduledHorizonSec: 0,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
async schedule(intent, ctx) {
|
|
315
|
+
if (!this.scheduler)
|
|
316
|
+
return err(new SchedulerError("unsupported", "No scheduler backend wired on this environment."));
|
|
317
|
+
return this.scheduler.schedule(intent, ctx);
|
|
318
|
+
}
|
|
319
|
+
async cancel(id, ctx) {
|
|
320
|
+
if (!this.scheduler)
|
|
321
|
+
return err(new SchedulerError("unsupported", "No scheduler backend wired on this environment."));
|
|
322
|
+
return this.scheduler.cancel(id, ctx);
|
|
323
|
+
}
|
|
324
|
+
async list(ctx) {
|
|
325
|
+
if (!this.scheduler)
|
|
326
|
+
return err(new SchedulerError("unsupported", "No scheduler backend wired on this environment."));
|
|
327
|
+
return this.scheduler.list(ctx);
|
|
328
|
+
}
|
|
329
|
+
async absolutePath(path) {
|
|
330
|
+
return ok(resolvePath(this.cwd, path));
|
|
331
|
+
}
|
|
332
|
+
async joinPath(parts) {
|
|
333
|
+
return ok(join(...parts));
|
|
334
|
+
}
|
|
335
|
+
async exec(command, options) {
|
|
336
|
+
if (options?.abortSignal?.aborted) {
|
|
337
|
+
return err(new ExecutionError("aborted", "aborted"));
|
|
338
|
+
}
|
|
339
|
+
const cwd = options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd;
|
|
340
|
+
const shellConfig = await getShellConfig(this.shellPath);
|
|
341
|
+
if (!shellConfig.ok) {
|
|
342
|
+
return shellConfig;
|
|
343
|
+
}
|
|
344
|
+
return await new Promise((resolvePromise) => {
|
|
345
|
+
const stdoutTail = new RollingTailBuffer(); // D2: bounded rolling tail (first-party src/core/exec-output-tail)
|
|
346
|
+
const stderrTail = new RollingTailBuffer();
|
|
347
|
+
let settled = false;
|
|
348
|
+
let timedOut = false;
|
|
349
|
+
let callbackError;
|
|
350
|
+
let child;
|
|
351
|
+
const timeoutRef = {};
|
|
352
|
+
const forceSettleRef = {}; // D5
|
|
353
|
+
// D5: after a kill (abort/timeout), `close` may never fire (a re-parented grandchild holds the pipe). Arm a
|
|
354
|
+
// bounded fallback that force-settles + tears down the pipes so the engine's requested abort/timeout always
|
|
355
|
+
// finalizes. Idempotent: `settle` guards `settled`, so a real `close` arriving first wins.
|
|
356
|
+
const armForceSettle = (result) => {
|
|
357
|
+
if (forceSettleRef.current || settled)
|
|
358
|
+
return;
|
|
359
|
+
forceSettleRef.current = setTimeout(() => {
|
|
360
|
+
try {
|
|
361
|
+
child?.stdout?.destroy();
|
|
362
|
+
child?.stderr?.destroy();
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
/* best-effort pipe teardown */
|
|
366
|
+
}
|
|
367
|
+
settle(result);
|
|
368
|
+
}, EXEC_FORCE_SETTLE_GRACE_MS);
|
|
369
|
+
forceSettleRef.current.unref?.();
|
|
370
|
+
};
|
|
371
|
+
const onAbort = () => {
|
|
372
|
+
if (child?.pid) {
|
|
373
|
+
killProcessTree(child.pid, { force: true });
|
|
374
|
+
}
|
|
375
|
+
armForceSettle(err(new ExecutionError("aborted", "aborted")));
|
|
376
|
+
};
|
|
377
|
+
const settle = (result) => {
|
|
378
|
+
if (timeoutRef.current) {
|
|
379
|
+
clearTimeout(timeoutRef.current);
|
|
380
|
+
}
|
|
381
|
+
if (forceSettleRef.current) {
|
|
382
|
+
clearTimeout(forceSettleRef.current);
|
|
383
|
+
}
|
|
384
|
+
if (options?.abortSignal) {
|
|
385
|
+
options.abortSignal.removeEventListener("abort", onAbort);
|
|
386
|
+
}
|
|
387
|
+
if (settled) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
settled = true;
|
|
391
|
+
resolvePromise(result);
|
|
392
|
+
};
|
|
393
|
+
try {
|
|
394
|
+
child = spawn(shellConfig.value.shell, [...shellConfig.value.args, command], {
|
|
395
|
+
cwd,
|
|
396
|
+
detached: process.platform !== "win32",
|
|
397
|
+
env: getShellEnv(this.inheritEnv, this.shellEnv, options?.env),
|
|
398
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
399
|
+
windowsHide: true,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
const cause = toError(error);
|
|
404
|
+
settle(err(new ExecutionError("spawn_error", cause.message, cause)));
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const timeoutMs = resolveExecTimeoutMs(options?.timeout);
|
|
408
|
+
timeoutRef.current =
|
|
409
|
+
timeoutMs === undefined
|
|
410
|
+
? undefined
|
|
411
|
+
: setTimeout(() => {
|
|
412
|
+
timedOut = true;
|
|
413
|
+
if (child?.pid) {
|
|
414
|
+
killProcessTree(child.pid, { force: true });
|
|
415
|
+
}
|
|
416
|
+
armForceSettle(err(new ExecutionError("timeout", `timeout:${options?.timeout}`))); // D5
|
|
417
|
+
}, timeoutMs);
|
|
418
|
+
if (options?.abortSignal) {
|
|
419
|
+
if (options.abortSignal.aborted) {
|
|
420
|
+
onAbort();
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
options.abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// design/116 detach (飞轮 [C] gap ③): mid-flight ctrl+b — ADOPT the running child as a background
|
|
427
|
+
// shell instead of killing it. The exec settles with a `detached` marker (already-captured output
|
|
428
|
+
// included); ownership (data listeners → bg tails, close handling, bg timeout, kill) moves to the
|
|
429
|
+
// bgShells entry. The child handle NEVER leaves this env. Fired after `settled` → ignored (too late).
|
|
430
|
+
const onDetach = () => {
|
|
431
|
+
if (settled || !child)
|
|
432
|
+
return;
|
|
433
|
+
const shellId = this.adoptRunningChild(child, stdoutTail.result().text, stderrTail.result().text);
|
|
434
|
+
if (shellId === undefined)
|
|
435
|
+
return; // over the live-shell limit — detach refused, exec keeps running
|
|
436
|
+
// Exec's kill paths must no longer touch the adopted process: drop timeout + abort ownership.
|
|
437
|
+
if (timeoutRef.current)
|
|
438
|
+
clearTimeout(timeoutRef.current);
|
|
439
|
+
settle(ok({ stdout: stdoutTail.result().text, stderr: stderrTail.result().text, exitCode: 0, detached: { shellId } }));
|
|
440
|
+
};
|
|
441
|
+
if (options?.detachSignal) {
|
|
442
|
+
if (options.detachSignal.aborted)
|
|
443
|
+
onDetach();
|
|
444
|
+
else {
|
|
445
|
+
const dl = () => onDetach();
|
|
446
|
+
options.detachSignal.addEventListener("abort", dl, { once: true });
|
|
447
|
+
// remove on settle happens implicitly: a once listener on a signal that never fires is harmless.
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// Keep `setEncoding("utf8")` so the streaming onStdout/onStderr callbacks still get correctly-decoded
|
|
451
|
+
// STRING chunks (Node's StringDecoder buffers incomplete sequences across data events); feed the byte form
|
|
452
|
+
// to the rolling tail (D2). `Buffer.from(completeString)` is split-safe — each `chunk` is already a whole
|
|
453
|
+
// decoded string, so the only multi-byte split is at the tail-trim boundary (harmless, marked truncated).
|
|
454
|
+
child.stdout?.setEncoding("utf8");
|
|
455
|
+
child.stderr?.setEncoding("utf8");
|
|
456
|
+
child.stdout?.on("data", (chunk) => {
|
|
457
|
+
stdoutTail.push(Buffer.from(chunk, "utf8")); // D2: keep a rolling TAIL, never OOM
|
|
458
|
+
try {
|
|
459
|
+
options?.onStdout?.(chunk);
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
const cause = toError(error);
|
|
463
|
+
callbackError = new ExecutionError("callback_error", cause.message, cause);
|
|
464
|
+
onAbort();
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
child.stderr?.on("data", (chunk) => {
|
|
468
|
+
stderrTail.push(Buffer.from(chunk, "utf8"));
|
|
469
|
+
try {
|
|
470
|
+
options?.onStderr?.(chunk);
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
const cause = toError(error);
|
|
474
|
+
callbackError = new ExecutionError("callback_error", cause.message, cause);
|
|
475
|
+
onAbort();
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
// Upstream-parity fix (2026-07 diff, openclaw e779abf70e class): child.stdout/stderr are streams
|
|
479
|
+
// with their OWN error events (e.g. EPIPE) — without a listener a stream error is an uncaught
|
|
480
|
+
// exception that crashes the host process. Swallow: the child's close event still settles the exec
|
|
481
|
+
// with whatever output was captured (and a signal-encoded exit code when the child died).
|
|
482
|
+
child.stdout?.on("error", () => { });
|
|
483
|
+
child.stderr?.on("error", () => { });
|
|
484
|
+
child.on("error", (error) => {
|
|
485
|
+
settle(err(new ExecutionError("spawn_error", error.message, error)));
|
|
486
|
+
});
|
|
487
|
+
child.on("close", (code, signal) => {
|
|
488
|
+
if (callbackError) {
|
|
489
|
+
settle(err(callbackError));
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (timedOut) {
|
|
493
|
+
settle(err(new ExecutionError("timeout", `timeout:${options?.timeout}`)));
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (options?.abortSignal?.aborted) {
|
|
497
|
+
settle(err(new ExecutionError("aborted", "aborted")));
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
// VENDORED EDIT (audit round-2 A-3): a signal-terminated child (OOM SIGKILL, SIGSEGV, external
|
|
501
|
+
// kill) reports `(code=null, signal=...)` — the old `code ?? 0` translated that into a SUCCESS
|
|
502
|
+
// with half an output, and the model advanced on a fake green (e.g. "tests passed"). Report the
|
|
503
|
+
// conventional shell encoding instead: 128 + signal number (best-effort 137 for unknown names),
|
|
504
|
+
// with the signal name appended to stderr so the model sees WHY.
|
|
505
|
+
const so = stdoutTail.result();
|
|
506
|
+
const se = stderrTail.result();
|
|
507
|
+
if (code === null && signal) {
|
|
508
|
+
const signum = { SIGHUP: 1, SIGINT: 2, SIGQUIT: 3, SIGABRT: 6, SIGKILL: 9, SIGSEGV: 11, SIGPIPE: 13, SIGTERM: 15 };
|
|
509
|
+
settle(ok({
|
|
510
|
+
stdout: markTruncated(so.text, so.droppedBytes),
|
|
511
|
+
stderr: `${markTruncated(se.text, se.droppedBytes)}${se.text.endsWith("\n") || se.text === "" ? "" : "\n"}[process terminated by ${signal}]`,
|
|
512
|
+
exitCode: 128 + (signum[signal] ?? 9),
|
|
513
|
+
}));
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
settle(ok({ stdout: markTruncated(so.text, so.droppedBytes), stderr: markTruncated(se.text, se.droppedBytes), exitCode: code ?? 0 }));
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
async readTextFile(path, abortSignal) {
|
|
521
|
+
const resolved = resolvePath(this.cwd, path);
|
|
522
|
+
const aborted = abortResult(abortSignal, resolved);
|
|
523
|
+
if (aborted) {
|
|
524
|
+
return aborted;
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
return ok(await readFile(resolved, { encoding: "utf8", signal: abortSignal }));
|
|
528
|
+
}
|
|
529
|
+
catch (error) {
|
|
530
|
+
return err(toFileError(error, resolved));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
async readTextLines(path, options) {
|
|
534
|
+
const resolved = resolvePath(this.cwd, path);
|
|
535
|
+
const aborted = abortResult(options?.abortSignal, resolved);
|
|
536
|
+
if (aborted) {
|
|
537
|
+
return aborted;
|
|
538
|
+
}
|
|
539
|
+
if (options?.maxLines !== undefined && options.maxLines <= 0) {
|
|
540
|
+
return ok([]);
|
|
541
|
+
}
|
|
542
|
+
let stream;
|
|
543
|
+
let lineReader;
|
|
544
|
+
try {
|
|
545
|
+
stream = createReadStream(resolved, { encoding: "utf8", signal: options?.abortSignal });
|
|
546
|
+
lineReader = createInterface({ input: stream, crlfDelay: Infinity });
|
|
547
|
+
const lines = [];
|
|
548
|
+
for await (const line of lineReader) {
|
|
549
|
+
const loopAbort = abortResult(options?.abortSignal, resolved);
|
|
550
|
+
if (loopAbort) {
|
|
551
|
+
return loopAbort;
|
|
552
|
+
}
|
|
553
|
+
lines.push(line);
|
|
554
|
+
if (options?.maxLines !== undefined && lines.length >= options.maxLines) {
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
const afterReadAbort = abortResult(options?.abortSignal, resolved);
|
|
559
|
+
if (afterReadAbort) {
|
|
560
|
+
return afterReadAbort;
|
|
561
|
+
}
|
|
562
|
+
return ok(lines);
|
|
563
|
+
}
|
|
564
|
+
catch (error) {
|
|
565
|
+
return err(toFileError(error, resolved));
|
|
566
|
+
}
|
|
567
|
+
finally {
|
|
568
|
+
lineReader?.close();
|
|
569
|
+
stream?.destroy();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
async readBinaryFile(path, abortSignal) {
|
|
573
|
+
const resolved = resolvePath(this.cwd, path);
|
|
574
|
+
const aborted = abortResult(abortSignal, resolved);
|
|
575
|
+
if (aborted) {
|
|
576
|
+
return aborted;
|
|
577
|
+
}
|
|
578
|
+
try {
|
|
579
|
+
return ok(await readFile(resolved, { signal: abortSignal }));
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
return err(toFileError(error, resolved));
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
async writeFile(path, content, abortSignal) {
|
|
586
|
+
const resolved = resolvePath(this.cwd, path);
|
|
587
|
+
const aborted = abortResult(abortSignal, resolved);
|
|
588
|
+
if (aborted) {
|
|
589
|
+
return aborted;
|
|
590
|
+
}
|
|
591
|
+
try {
|
|
592
|
+
await mkdir(resolve(resolved, ".."), { recursive: true });
|
|
593
|
+
const afterMkdirAbort = abortResult(abortSignal, resolved);
|
|
594
|
+
if (afterMkdirAbort) {
|
|
595
|
+
return afterMkdirAbort;
|
|
596
|
+
}
|
|
597
|
+
await writeFile(resolved, content, { signal: abortSignal });
|
|
598
|
+
return ok(undefined);
|
|
599
|
+
}
|
|
600
|
+
catch (error) {
|
|
601
|
+
return err(toFileError(error, resolved));
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
async appendFile(path, content) {
|
|
605
|
+
const resolved = resolvePath(this.cwd, path);
|
|
606
|
+
try {
|
|
607
|
+
await mkdir(resolve(resolved, ".."), { recursive: true });
|
|
608
|
+
await appendFile(resolved, content);
|
|
609
|
+
return ok(undefined);
|
|
610
|
+
}
|
|
611
|
+
catch (error) {
|
|
612
|
+
return err(toFileError(error, resolved));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
async fileInfo(path) {
|
|
616
|
+
const resolved = resolvePath(this.cwd, path);
|
|
617
|
+
try {
|
|
618
|
+
return fileInfoFromStats(resolved, await lstat(resolved));
|
|
619
|
+
}
|
|
620
|
+
catch (error) {
|
|
621
|
+
return err(toFileError(error, resolved));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
async listDir(path, abortSignal) {
|
|
625
|
+
const resolved = resolvePath(this.cwd, path);
|
|
626
|
+
const aborted = abortResult(abortSignal, resolved);
|
|
627
|
+
if (aborted) {
|
|
628
|
+
return aborted;
|
|
629
|
+
}
|
|
630
|
+
try {
|
|
631
|
+
const entries = await readdir(resolved, { withFileTypes: true });
|
|
632
|
+
const infos = [];
|
|
633
|
+
for (const entry of entries) {
|
|
634
|
+
const loopAbort = abortResult(abortSignal, resolved);
|
|
635
|
+
if (loopAbort) {
|
|
636
|
+
return loopAbort;
|
|
637
|
+
}
|
|
638
|
+
const entryPath = resolve(resolved, entry.name);
|
|
639
|
+
try {
|
|
640
|
+
const info = fileInfoFromStats(entryPath, await lstat(entryPath));
|
|
641
|
+
if (info.ok) {
|
|
642
|
+
infos.push(info.value);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
return err(toFileError(error, entryPath));
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return ok(infos);
|
|
650
|
+
}
|
|
651
|
+
catch (error) {
|
|
652
|
+
return err(toFileError(error, resolved));
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
async canonicalPath(path) {
|
|
656
|
+
const resolved = resolvePath(this.cwd, path);
|
|
657
|
+
try {
|
|
658
|
+
return ok(await realpath(resolved));
|
|
659
|
+
}
|
|
660
|
+
catch (error) {
|
|
661
|
+
return err(toFileError(error, resolved));
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
// VENDORED EDIT (design/72 §2.1): one-hop symlink target read (raw, not followed), so a guard can
|
|
665
|
+
// resolve a DANGLING leaf symlink that `realpath`/`canonicalPath` cannot.
|
|
666
|
+
async readLink(path) {
|
|
667
|
+
const resolved = resolvePath(this.cwd, path);
|
|
668
|
+
try {
|
|
669
|
+
return ok(await readlink(resolved));
|
|
670
|
+
}
|
|
671
|
+
catch (error) {
|
|
672
|
+
return err(toFileError(error, resolved));
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
async exists(path) {
|
|
676
|
+
const result = await this.fileInfo(path);
|
|
677
|
+
if (result.ok) {
|
|
678
|
+
return ok(true);
|
|
679
|
+
}
|
|
680
|
+
if (result.error.code === "not_found") {
|
|
681
|
+
return ok(false);
|
|
682
|
+
}
|
|
683
|
+
return err(result.error);
|
|
684
|
+
}
|
|
685
|
+
async createDir(path, options) {
|
|
686
|
+
const resolved = resolvePath(this.cwd, path);
|
|
687
|
+
try {
|
|
688
|
+
await mkdir(resolved, { recursive: options?.recursive ?? true });
|
|
689
|
+
return ok(undefined);
|
|
690
|
+
}
|
|
691
|
+
catch (error) {
|
|
692
|
+
return err(toFileError(error, resolved));
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
async remove(path, options) {
|
|
696
|
+
const resolved = resolvePath(this.cwd, path);
|
|
697
|
+
try {
|
|
698
|
+
await rm(resolved, {
|
|
699
|
+
recursive: options?.recursive ?? false,
|
|
700
|
+
force: options?.force ?? false,
|
|
701
|
+
});
|
|
702
|
+
return ok(undefined);
|
|
703
|
+
}
|
|
704
|
+
catch (error) {
|
|
705
|
+
return err(toFileError(error, resolved));
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
async createTempDir(prefix = "tmp-") {
|
|
709
|
+
try {
|
|
710
|
+
return ok(await mkdtemp(join(tmpdir(), prefix)));
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
return err(toFileError(error));
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
async createTempFile(options) {
|
|
717
|
+
const dir = await this.createTempDir("tmp-");
|
|
718
|
+
if (!dir.ok) {
|
|
719
|
+
return dir;
|
|
720
|
+
}
|
|
721
|
+
const filePath = join(dir.value, `${options?.prefix ?? ""}${randomUUID()}${options?.suffix ?? ""}`);
|
|
722
|
+
try {
|
|
723
|
+
await writeFile(filePath, "");
|
|
724
|
+
return ok(filePath);
|
|
725
|
+
}
|
|
726
|
+
catch (error) {
|
|
727
|
+
return err(toFileError(error, filePath));
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
// ─── design/103 background-shell capability ─────────────────────────────────────────────────────────────────
|
|
731
|
+
/** design/116 detach: adopt a RUNNING foreground child as a background shell. Pre-fills the bg tails with
|
|
732
|
+
* the output captured so far (so TaskOutput's first read has the full history), attaches fresh data/close
|
|
733
|
+
* handlers, and arms the default bg timeout. Returns undefined when the live-shell limit is hit (detach
|
|
734
|
+
* refused; the exec keeps running in the foreground). */
|
|
735
|
+
adoptRunningChild(child, stdoutSoFar, stderrSoFar) {
|
|
736
|
+
const liveCount = [...this.bgShells.values()].filter((e) => e.status === "running").length;
|
|
737
|
+
if (liveCount >= this.backgroundCapabilities.maxConcurrent)
|
|
738
|
+
return undefined;
|
|
739
|
+
const shellId = `bg_${++this.bgCounter}_${randomUUID()}`;
|
|
740
|
+
const entry = {
|
|
741
|
+
child,
|
|
742
|
+
stdout: { tail: new RollingTailBuffer(), totalBytes: 0, cursorBytes: 0 },
|
|
743
|
+
stderr: { tail: new RollingTailBuffer(), totalBytes: 0, cursorBytes: 0 },
|
|
744
|
+
status: "running",
|
|
745
|
+
};
|
|
746
|
+
const seedOut = Buffer.from(stdoutSoFar, "utf8");
|
|
747
|
+
const seedErr = Buffer.from(stderrSoFar, "utf8");
|
|
748
|
+
entry.stdout.tail.push(seedOut);
|
|
749
|
+
entry.stdout.totalBytes += seedOut.length;
|
|
750
|
+
entry.stderr.tail.push(seedErr);
|
|
751
|
+
entry.stderr.totalBytes += seedErr.length;
|
|
752
|
+
child.stdout?.on("data", (chunk) => {
|
|
753
|
+
const buf = typeof chunk === "string" ? Buffer.from(chunk, "utf8") : chunk;
|
|
754
|
+
entry.stdout.tail.push(buf);
|
|
755
|
+
entry.stdout.totalBytes += buf.length;
|
|
756
|
+
});
|
|
757
|
+
child.stderr?.on("data", (chunk) => {
|
|
758
|
+
const buf = typeof chunk === "string" ? Buffer.from(chunk, "utf8") : chunk;
|
|
759
|
+
entry.stderr.tail.push(buf);
|
|
760
|
+
entry.stderr.totalBytes += buf.length;
|
|
761
|
+
});
|
|
762
|
+
child.on("error", () => {
|
|
763
|
+
if (entry.timer)
|
|
764
|
+
clearTimeout(entry.timer);
|
|
765
|
+
if (entry.status === "running")
|
|
766
|
+
entry.status = "failed";
|
|
767
|
+
});
|
|
768
|
+
child.on("close", (code, signal) => {
|
|
769
|
+
if (entry.timer)
|
|
770
|
+
clearTimeout(entry.timer);
|
|
771
|
+
if (entry.status === "killed")
|
|
772
|
+
return;
|
|
773
|
+
entry.status = "exited";
|
|
774
|
+
entry.exitCode = code === null && signal ? 128 + (SIGNUM[signal] ?? 9) : (code ?? 0);
|
|
775
|
+
});
|
|
776
|
+
// Race guard: the child may have ALREADY exited between the detach request and adoption.
|
|
777
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
778
|
+
entry.status = "exited";
|
|
779
|
+
entry.exitCode = child.exitCode ?? (child.signalCode ? 128 + (SIGNUM[child.signalCode] ?? 9) : 0);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
// Default bg timeout takes over from the (cleared) exec timeout — never unbounded (design/103 §3.6).
|
|
783
|
+
const timeoutSec = this.backgroundCapabilities.defaultBgTimeoutSec;
|
|
784
|
+
entry.timer = setTimeout(() => {
|
|
785
|
+
entry.status = "killed";
|
|
786
|
+
if (child.pid)
|
|
787
|
+
killProcessTree(child.pid, { force: true });
|
|
788
|
+
}, timeoutSec * 1000);
|
|
789
|
+
entry.timer.unref?.();
|
|
790
|
+
}
|
|
791
|
+
this.bgShells.set(shellId, entry);
|
|
792
|
+
return shellId;
|
|
793
|
+
}
|
|
794
|
+
async spawnBackground(command, options) {
|
|
795
|
+
// Count only LIVE (running) shells against the limit — terminal entries are KEPT for post-exit polling but must
|
|
796
|
+
// NOT wedge the limit (review: maxConcurrent 终态占槽). TaskStop flips a shell to "killed" → frees its slot, so
|
|
797
|
+
// the "TaskStop one first" guidance is actionable.
|
|
798
|
+
const liveCount = [...this.bgShells.values()].filter((e) => e.status === "running").length;
|
|
799
|
+
if (liveCount >= this.backgroundCapabilities.maxConcurrent) {
|
|
800
|
+
return err(new BackgroundShellError("limit_exceeded", `Too many running background shells (max ${this.backgroundCapabilities.maxConcurrent}); TaskStop one first.`));
|
|
801
|
+
}
|
|
802
|
+
const shellConfig = await getShellConfig(this.shellPath);
|
|
803
|
+
if (!shellConfig.ok) {
|
|
804
|
+
return err(new BackgroundShellError("spawn_failed", shellConfig.error.message, shellConfig.error));
|
|
805
|
+
}
|
|
806
|
+
// design/128 T1-1 (retain): spool stdio to env-owned temp files so the child never depends on a host
|
|
807
|
+
// pipe (host exit ⇒ no EPIPE). Unpredictable mkdtemp path + `wx` + 0600 (never the cwd — a workspace
|
|
808
|
+
// symlink must not redirect the spool; same posture as the frozen-path restore hardening). On any spool
|
|
809
|
+
// failure fall back to pipes: the process still won't be disposed, just with best-effort stdio.
|
|
810
|
+
let spool;
|
|
811
|
+
let spoolFds;
|
|
812
|
+
if (this.retainBackgroundProcesses) {
|
|
813
|
+
try {
|
|
814
|
+
if (!this.bgSpoolDir)
|
|
815
|
+
this.bgSpoolDir = mkdtempSync(join(tmpdir(), "sema-bg-"));
|
|
816
|
+
const pair = openSpoolPair(join(this.bgSpoolDir, `bg_${this.bgCounter + 1}_${randomUUID()}`));
|
|
817
|
+
spool = { outPath: pair.outPath, errPath: pair.errPath };
|
|
818
|
+
spoolFds = pair.fds;
|
|
819
|
+
}
|
|
820
|
+
catch {
|
|
821
|
+
spool = undefined; // fall back to pipes: still not disposed, just best-effort stdio
|
|
822
|
+
spoolFds = undefined;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
let child;
|
|
826
|
+
try {
|
|
827
|
+
child = spawn(shellConfig.value.shell, [...shellConfig.value.args, command], {
|
|
828
|
+
// Resolve a relative cwd against the env root, same as exec (review: cwd parity) — the Bash tool passes an
|
|
829
|
+
// absolute cwdRef.current, but a direct API caller may pass a relative path.
|
|
830
|
+
cwd: options?.cwd ? resolvePath(this.cwd, options.cwd) : this.cwd,
|
|
831
|
+
// detached:true (own process group on Unix) so disposeBackgroundShells' killProcessTree group-kills the whole
|
|
832
|
+
// tree — the dev-server's esbuild/worker grandchildren die too (design/103 §5.1; same as exec's spawn).
|
|
833
|
+
detached: process.platform !== "win32",
|
|
834
|
+
// SAME secret-scrub as exec (design/103 §3.1 red line): the background child must NOT read SECRET_* keys.
|
|
835
|
+
env: getShellEnv(this.inheritEnv, this.shellEnv, options?.env),
|
|
836
|
+
stdio: spoolFds ? ["ignore", spoolFds[0], spoolFds[1]] : ["ignore", "pipe", "pipe"],
|
|
837
|
+
windowsHide: true,
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
catch (error) {
|
|
841
|
+
if (spoolFds) {
|
|
842
|
+
for (const fd of spoolFds) {
|
|
843
|
+
try {
|
|
844
|
+
closeSync(fd);
|
|
845
|
+
}
|
|
846
|
+
catch {
|
|
847
|
+
/* best-effort */
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
const cause = toError(error);
|
|
852
|
+
return err(new BackgroundShellError("spawn_failed", cause.message, cause));
|
|
853
|
+
}
|
|
854
|
+
// The child holds its own dup of the spool fds — release the parent's handles immediately.
|
|
855
|
+
if (spoolFds) {
|
|
856
|
+
for (const fd of spoolFds) {
|
|
857
|
+
try {
|
|
858
|
+
closeSync(fd);
|
|
859
|
+
}
|
|
860
|
+
catch {
|
|
861
|
+
/* best-effort */
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
const shellId = `bg_${++this.bgCounter}_${randomUUID()}`;
|
|
866
|
+
const entry = {
|
|
867
|
+
child,
|
|
868
|
+
stdout: { tail: new RollingTailBuffer(), totalBytes: 0, cursorBytes: 0 },
|
|
869
|
+
stderr: { tail: new RollingTailBuffer(), totalBytes: 0, cursorBytes: 0 },
|
|
870
|
+
status: "running",
|
|
871
|
+
...(spool ? { spool } : {}),
|
|
872
|
+
};
|
|
873
|
+
child.stdout?.setEncoding("utf8");
|
|
874
|
+
child.stderr?.setEncoding("utf8");
|
|
875
|
+
child.stdout?.on("data", (chunk) => {
|
|
876
|
+
const buf = Buffer.from(chunk, "utf8");
|
|
877
|
+
entry.stdout.tail.push(buf);
|
|
878
|
+
entry.stdout.totalBytes += buf.length;
|
|
879
|
+
});
|
|
880
|
+
child.stderr?.on("data", (chunk) => {
|
|
881
|
+
const buf = Buffer.from(chunk, "utf8");
|
|
882
|
+
entry.stderr.tail.push(buf);
|
|
883
|
+
entry.stderr.totalBytes += buf.length;
|
|
884
|
+
});
|
|
885
|
+
// Upstream-parity fix (2026-07 diff, openclaw e779abf70e class, swept to the bg-shell pipe path):
|
|
886
|
+
// un-listened stream errors (EPIPE) crash the host — swallow; close still classifies the entry.
|
|
887
|
+
child.stdout?.on("error", () => { });
|
|
888
|
+
child.stderr?.on("error", () => { });
|
|
889
|
+
child.on("error", () => {
|
|
890
|
+
if (entry.timer)
|
|
891
|
+
clearTimeout(entry.timer);
|
|
892
|
+
if (entry.status === "running")
|
|
893
|
+
entry.status = "failed";
|
|
894
|
+
});
|
|
895
|
+
// Drive terminal status off "close" (fires AFTER all stdio EOF), NOT "exit" — so the final buffered output has
|
|
896
|
+
// landed in the tail before the model is told the process ended (review: exit 先于 stdout drain 漏残余).
|
|
897
|
+
child.on("close", (code, signal) => {
|
|
898
|
+
if (entry.timer)
|
|
899
|
+
clearTimeout(entry.timer);
|
|
900
|
+
if (entry.status === "killed")
|
|
901
|
+
return; // killBackground / timeout already classified it
|
|
902
|
+
entry.status = "exited";
|
|
903
|
+
entry.exitCode = code === null && signal ? 128 + (SIGNUM[signal] ?? 9) : (code ?? 0);
|
|
904
|
+
});
|
|
905
|
+
// BG timeout is a HARD wall (design/103 §3.6): bounded to maxBgTimeoutSec, never unbounded.
|
|
906
|
+
const timeoutSec = Math.min(options?.timeout ?? this.backgroundCapabilities.defaultBgTimeoutSec, this.backgroundCapabilities.maxBgTimeoutSec);
|
|
907
|
+
entry.timer = setTimeout(() => {
|
|
908
|
+
if (child.pid && entry.status === "running") {
|
|
909
|
+
entry.status = "killed";
|
|
910
|
+
killProcessTree(child.pid, { force: true });
|
|
911
|
+
}
|
|
912
|
+
}, timeoutSec * 1000);
|
|
913
|
+
entry.timer.unref?.();
|
|
914
|
+
this.bgShells.set(shellId, entry);
|
|
915
|
+
return ok({ shellId });
|
|
916
|
+
}
|
|
917
|
+
async pollBackground(shellId) {
|
|
918
|
+
const entry = this.bgShells.get(shellId);
|
|
919
|
+
if (!entry) {
|
|
920
|
+
// unknown / cross-env id → not_found (never leak whether another env's id exists, design/103 §3.8).
|
|
921
|
+
return err(new BackgroundShellError("not_found", `Unknown background shell: ${shellId}`));
|
|
922
|
+
}
|
|
923
|
+
this.syncSpool(entry); // design/128 T1-1: retain mode — fold spool-file increments into the tails first
|
|
924
|
+
// Cursor over ABSOLUTE byte offsets. The tail retains bytes [droppedBytes, totalBytes); return [cursor, total).
|
|
925
|
+
// NOTE: the tail is decoded to text then re-encoded for the byte slice, so if a head-evict split a multi-byte char
|
|
926
|
+
// the orphan bytes decode to U+FFFD (3 bytes each) — the single poll spanning that evict may show a few garbled or
|
|
927
|
+
// duplicated bytes at its head. Only when output exceeds the 8MB tail; bounded + rare (honest-marked downstream).
|
|
928
|
+
const slice = (s) => {
|
|
929
|
+
const { text, droppedBytes } = s.tail.result();
|
|
930
|
+
const droppedBeforeCursor = Math.max(0, droppedBytes - s.cursorBytes);
|
|
931
|
+
const startByte = Math.max(s.cursorBytes, droppedBytes);
|
|
932
|
+
const startInTail = startByte - droppedBytes;
|
|
933
|
+
const inc = startInTail <= 0 ? text : Buffer.from(text, "utf8").subarray(startInTail).toString("utf8");
|
|
934
|
+
s.cursorBytes = s.totalBytes;
|
|
935
|
+
return { inc, droppedBeforeCursor };
|
|
936
|
+
};
|
|
937
|
+
const out = slice(entry.stdout);
|
|
938
|
+
const er = slice(entry.stderr);
|
|
939
|
+
const droppedBeforeCursor = out.droppedBeforeCursor + er.droppedBeforeCursor;
|
|
940
|
+
return ok({
|
|
941
|
+
stdout: out.inc,
|
|
942
|
+
stderr: er.inc,
|
|
943
|
+
status: entry.status,
|
|
944
|
+
...(entry.exitCode !== undefined ? { exitCode: entry.exitCode } : {}),
|
|
945
|
+
...(droppedBeforeCursor > 0 ? { truncated: true, bytesDroppedBeforeCursor: droppedBeforeCursor } : {}),
|
|
946
|
+
bytesFromStart: entry.stdout.totalBytes + entry.stderr.totalBytes,
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
async killBackground(shellId) {
|
|
950
|
+
const entry = this.bgShells.get(shellId);
|
|
951
|
+
if (!entry) {
|
|
952
|
+
return err(new BackgroundShellError("not_found", `Unknown background shell: ${shellId}`));
|
|
953
|
+
}
|
|
954
|
+
if (entry.status === "running" && entry.child.pid) {
|
|
955
|
+
entry.status = "killed";
|
|
956
|
+
if (entry.timer)
|
|
957
|
+
clearTimeout(entry.timer);
|
|
958
|
+
killProcessTree(entry.child.pid, { force: true }); // group-kill the whole tree (detached → own pgid)
|
|
959
|
+
}
|
|
960
|
+
return ok(undefined); // idempotent: killing an already-dead shell is a no-op success
|
|
961
|
+
}
|
|
962
|
+
/** design/128 T1-1: incrementally read a retained shell's spool files into the in-memory tails, so
|
|
963
|
+
* pollBackground serves the same cursor semantics whether stdio came over pipes or spool files.
|
|
964
|
+
* Bounded single read per stream per poll (the tail keeps only its rolling window anyway). */
|
|
965
|
+
syncSpool(entry) {
|
|
966
|
+
if (!entry.spool)
|
|
967
|
+
return;
|
|
968
|
+
const streams = [
|
|
969
|
+
[entry.stdout, entry.spool.outPath],
|
|
970
|
+
[entry.stderr, entry.spool.errPath],
|
|
971
|
+
];
|
|
972
|
+
for (const [stream, path] of streams) {
|
|
973
|
+
try {
|
|
974
|
+
const size = statSync(path).size;
|
|
975
|
+
if (size <= stream.totalBytes)
|
|
976
|
+
continue;
|
|
977
|
+
const fd = openSync(path, "r");
|
|
978
|
+
try {
|
|
979
|
+
const want = Math.min(size - stream.totalBytes, 8 * 1024 * 1024 + 4096); // ≥ tail window per poll
|
|
980
|
+
const buf = Buffer.alloc(want);
|
|
981
|
+
const got = readSync(fd, buf, 0, want, stream.totalBytes);
|
|
982
|
+
if (got > 0) {
|
|
983
|
+
stream.tail.push(buf.subarray(0, got));
|
|
984
|
+
stream.totalBytes += got;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
finally {
|
|
988
|
+
closeSync(fd);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
catch {
|
|
992
|
+
// spool unreadable (deleted / permissions) — the poll serves whatever the tail already has
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
async disposeBackgroundShells(opts) {
|
|
997
|
+
// design/128 T1-1: a retain-declared env NEVER auto-reaps — the runner's every-exit-path dispose and
|
|
998
|
+
// cleanup() both land here, so this single gate is the whole retain semantic. Explicit killBackground
|
|
999
|
+
// and the per-shell bg-timeout reaper still work while the host lives.
|
|
1000
|
+
if (this.retainBackgroundProcesses)
|
|
1001
|
+
return;
|
|
1002
|
+
// 飞轮 [492]②: `except` shells (session-resident persistent Monitors) survive the run teardown —
|
|
1003
|
+
// entry AND timer kept intact so pollBackground/killBackground/the bg-timeout reaper keep working.
|
|
1004
|
+
const keep = opts?.except !== undefined && opts.except.length > 0 ? new Set(opts.except) : undefined;
|
|
1005
|
+
for (const [id, entry] of this.bgShells) {
|
|
1006
|
+
if (keep?.has(id))
|
|
1007
|
+
continue;
|
|
1008
|
+
try {
|
|
1009
|
+
if (entry.timer)
|
|
1010
|
+
clearTimeout(entry.timer);
|
|
1011
|
+
if (entry.status === "running" && entry.child.pid) {
|
|
1012
|
+
entry.status = "killed";
|
|
1013
|
+
killProcessTree(entry.child.pid, { force: true });
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
catch {
|
|
1017
|
+
// best-effort; disposeBackgroundShells MUST never throw (design/103 §3.7).
|
|
1018
|
+
}
|
|
1019
|
+
if (keep !== undefined)
|
|
1020
|
+
this.bgShells.delete(id);
|
|
1021
|
+
}
|
|
1022
|
+
if (keep === undefined)
|
|
1023
|
+
this.bgShells.clear();
|
|
1024
|
+
}
|
|
1025
|
+
async cleanup() {
|
|
1026
|
+
// Release any still-running background processes. The Runner also disposes on every exit path (design/103 §3.7),
|
|
1027
|
+
// but cleanup is ExecutionEnv's resource-release contract, so honour it here too (idempotent backstop).
|
|
1028
|
+
await this.disposeBackgroundShells();
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
//# sourceMappingURL=node-execution-env.js.map
|