@sema-agent/core 7.72.0 → 7.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/permission-rules.js +4 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +42 -30
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -6,10 +6,11 @@ import { callKeyOrdinal, readWorkflowJournalEntry, launchRecordToKeepOrThrow, re
|
|
|
6
6
|
import { processCensus, processFingerprint } from "../../core/process-identity.js";
|
|
7
7
|
import { AppendLog, readJsonlRecords } from "./fs-atomic.js";
|
|
8
8
|
import { guardCorruptSink } from "./corrupt-read-sink.js";
|
|
9
|
-
import { BootLock, canonicalStoreKey, FileStoreLockError, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
|
|
9
|
+
import { atomicWriteFile, BootLock, canonicalStoreKey, FileStoreLockError, sanitizePathComponent, writeThenLink } from "./fs-atomic.js";
|
|
10
10
|
import { assertAdoptionBootGate } from "./adoption/marker.js";
|
|
11
11
|
import { optionKeys, receiveOptions } from "../../core/own-property-receipt.js";
|
|
12
12
|
import { assertJournalEntryFits } from "../../core/workflow-journal-store.js";
|
|
13
|
+
const TOMBSTONE_CLAIM_HOLDER = "workflow:stopped";
|
|
13
14
|
function holderProcessOf(v) {
|
|
14
15
|
if (v === null || typeof v !== "object" || Array.isArray(v))
|
|
15
16
|
return undefined;
|
|
@@ -26,12 +27,14 @@ function holderProcessOf(v) {
|
|
|
26
27
|
return { pid: r.pid, startedAtMs, startedSinceBootMs, host: r.host, ...(typeof r.pidNs === "string" ? { pidNs: r.pidNs } : {}) };
|
|
27
28
|
}
|
|
28
29
|
function claimBinds(claim, now) {
|
|
30
|
+
if (claim.stopped !== undefined)
|
|
31
|
+
return true;
|
|
29
32
|
if (claim.rec.expiresAt <= now)
|
|
30
33
|
return false;
|
|
31
34
|
return claim.process === undefined || processCensus().verdict(claim.process).state !== "gone";
|
|
32
35
|
}
|
|
33
36
|
function heldHere(claim, newRunId) {
|
|
34
|
-
if (claim.rec.holder !== newRunId || claim.process === undefined)
|
|
37
|
+
if (claim.stopped !== undefined || claim.rec.holder !== newRunId || claim.process === undefined)
|
|
35
38
|
return false;
|
|
36
39
|
const me = processFingerprint();
|
|
37
40
|
return claim.process.pid === me.pid && claim.process.host === me.host && claim.process.pidNs === me.pidNs;
|
|
@@ -298,7 +301,8 @@ export class FileWorkflowJournalStore {
|
|
|
298
301
|
if (typeof rec.holder !== "string" || typeof rec.expiresAt !== "number" || !Number.isFinite(rec.expiresAt)) {
|
|
299
302
|
return { raw, claim: undefined };
|
|
300
303
|
}
|
|
301
|
-
|
|
304
|
+
const stopped = typeof rec.stoppedBy === "string" && rec.stoppedBy.length > 0 ? { by: rec.stoppedBy } : undefined;
|
|
305
|
+
return { raw, claim: { rec, process: holderProcessOf(rec.holderProcess), stopped } };
|
|
302
306
|
}
|
|
303
307
|
catch {
|
|
304
308
|
return { raw, claim: undefined };
|
|
@@ -335,6 +339,35 @@ export class FileWorkflowJournalStore {
|
|
|
335
339
|
gate.release();
|
|
336
340
|
}
|
|
337
341
|
}
|
|
342
|
+
replaceIfUnchanged(path, judged, payload) {
|
|
343
|
+
const gate = this.gateAt(path, judged);
|
|
344
|
+
try {
|
|
345
|
+
gate.acquire();
|
|
346
|
+
}
|
|
347
|
+
catch (err) {
|
|
348
|
+
if (err instanceof FileStoreLockError && (err.code === "store.dir_in_use" || err.code === "store.dir_claiming"))
|
|
349
|
+
return "contended";
|
|
350
|
+
throw err;
|
|
351
|
+
}
|
|
352
|
+
try {
|
|
353
|
+
let now;
|
|
354
|
+
try {
|
|
355
|
+
now = readFileSync(path, "utf8");
|
|
356
|
+
}
|
|
357
|
+
catch (err) {
|
|
358
|
+
if (err.code === "ENOENT")
|
|
359
|
+
return "changed";
|
|
360
|
+
throw err;
|
|
361
|
+
}
|
|
362
|
+
if (now !== judged)
|
|
363
|
+
return "changed";
|
|
364
|
+
atomicWriteFile(this.claimsDir, path, payload);
|
|
365
|
+
return "replaced";
|
|
366
|
+
}
|
|
367
|
+
finally {
|
|
368
|
+
gate.release();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
338
371
|
gateAt(path, judged) {
|
|
339
372
|
const gatePath = judged === undefined ? path : join(this.claimsDir, `${createHash("sha256").update(`${basename(path)}\n${judged}`).digest("hex").slice(0, 32)}.takeover`);
|
|
340
373
|
return new BootLock(gatePath, RESUME_CLAIM_TTL_MS);
|
|
@@ -358,7 +391,9 @@ export class FileWorkflowJournalStore {
|
|
|
358
391
|
const read = this.readClaimAt(path);
|
|
359
392
|
if (read === undefined)
|
|
360
393
|
continue;
|
|
361
|
-
if (read.claim !== undefined
|
|
394
|
+
if (read.claim !== undefined
|
|
395
|
+
? read.claim.stopped !== undefined || read.claim.rec.expiresAt + RESUME_CLAIM_REAP_GRACE_MS > now
|
|
396
|
+
: now - statSync(path).mtimeMs <= RESUME_CLAIM_TTL_MS) {
|
|
362
397
|
continue;
|
|
363
398
|
}
|
|
364
399
|
this.removeIfUnchanged(path, read.raw);
|
|
@@ -399,6 +434,9 @@ export class FileWorkflowJournalStore {
|
|
|
399
434
|
if (read === undefined)
|
|
400
435
|
continue;
|
|
401
436
|
const existing = read.claim;
|
|
437
|
+
if (existing !== undefined && existing.stopped !== undefined) {
|
|
438
|
+
return { granted: false, stopped: existing.stopped };
|
|
439
|
+
}
|
|
402
440
|
const now = Date.now();
|
|
403
441
|
if (existing !== undefined && claimBinds(existing, now)) {
|
|
404
442
|
const left = resumeClaimRemainingMember(existing.rec.expiresAt, now);
|
|
@@ -409,6 +447,9 @@ export class FileWorkflowJournalStore {
|
|
|
409
447
|
this.removeIfUnchanged(path, read.raw);
|
|
410
448
|
}
|
|
411
449
|
const winner = this.readClaimAt(path)?.claim;
|
|
450
|
+
if (winner !== undefined && winner.stopped !== undefined) {
|
|
451
|
+
return { granted: false, stopped: winner.stopped };
|
|
452
|
+
}
|
|
412
453
|
const lastLook = Date.now();
|
|
413
454
|
const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
|
|
414
455
|
if (bound !== undefined && heldHere(bound, newRunId))
|
|
@@ -425,7 +466,7 @@ export class FileWorkflowJournalStore {
|
|
|
425
466
|
return;
|
|
426
467
|
}
|
|
427
468
|
const existing = read?.claim;
|
|
428
|
-
if (read === undefined || existing === undefined || !heldHere(existing, input.newRunId))
|
|
469
|
+
if (read === undefined || existing === undefined || existing.stopped !== undefined || !heldHere(existing, input.newRunId))
|
|
429
470
|
return;
|
|
430
471
|
if (existing.rec.expiresAt - Date.now() <= RESUME_CLAIM_RELEASE_GRACE_MS)
|
|
431
472
|
return;
|
|
@@ -435,6 +476,53 @@ export class FileWorkflowJournalStore {
|
|
|
435
476
|
catch {
|
|
436
477
|
}
|
|
437
478
|
}
|
|
479
|
+
async stopResumeClaim(input) {
|
|
480
|
+
if (typeof input.stoppedBy !== "string" || input.stoppedBy === "") {
|
|
481
|
+
throw new TypeError("workflow journal: stopResumeClaim requires a non-empty stoppedBy string");
|
|
482
|
+
}
|
|
483
|
+
const { sourceRunId, scope, stoppedBy, holder } = input;
|
|
484
|
+
const path = this.claimPathFor(sourceRunId, scope);
|
|
485
|
+
mkdirSync(this.claimsDir, { recursive: true, mode: 0o700 });
|
|
486
|
+
const record = {
|
|
487
|
+
sourceRunId,
|
|
488
|
+
holder: TOMBSTONE_CLAIM_HOLDER,
|
|
489
|
+
expiresAt: Number.MAX_SAFE_INTEGER,
|
|
490
|
+
stoppedBy,
|
|
491
|
+
stoppedAt: Date.now(),
|
|
492
|
+
};
|
|
493
|
+
const payload = JSON.stringify(record);
|
|
494
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
495
|
+
try {
|
|
496
|
+
writeThenLink(path, payload);
|
|
497
|
+
return { stopped: true };
|
|
498
|
+
}
|
|
499
|
+
catch (err) {
|
|
500
|
+
if (err.code !== "EEXIST")
|
|
501
|
+
throw err;
|
|
502
|
+
}
|
|
503
|
+
const read = this.readClaimAt(path);
|
|
504
|
+
if (read === undefined)
|
|
505
|
+
continue;
|
|
506
|
+
const existing = read.claim;
|
|
507
|
+
if (existing !== undefined && existing.stopped !== undefined) {
|
|
508
|
+
return { stopped: true };
|
|
509
|
+
}
|
|
510
|
+
const now = Date.now();
|
|
511
|
+
const binds = existing !== undefined && claimBinds(existing, now);
|
|
512
|
+
if (binds && (holder === undefined || existing.rec.holder !== holder)) {
|
|
513
|
+
return { stopped: false, holder: existing.rec.holder };
|
|
514
|
+
}
|
|
515
|
+
const replaced = this.replaceIfUnchanged(path, read.raw, payload);
|
|
516
|
+
if (replaced === "replaced")
|
|
517
|
+
return { stopped: true };
|
|
518
|
+
}
|
|
519
|
+
const winner = this.readClaimAt(path)?.claim;
|
|
520
|
+
if (winner !== undefined && winner.stopped !== undefined)
|
|
521
|
+
return { stopped: true };
|
|
522
|
+
const lastLook = Date.now();
|
|
523
|
+
const bound = winner !== undefined && claimBinds(winner, lastLook) ? winner : undefined;
|
|
524
|
+
return { stopped: false, ...(bound !== undefined ? { holder: bound.rec.holder } : {}) };
|
|
525
|
+
}
|
|
438
526
|
dispose() {
|
|
439
527
|
if (this.closed)
|
|
440
528
|
return;
|
|
@@ -95,7 +95,7 @@ export declare class FileWorkflowRunStore implements WorkflowRunStore {
|
|
|
95
95
|
/** The end of a batch of {@link deleteRun} calls (interface: {@link WorkflowRunStore.settleErasure}): the ledger compacted once. */
|
|
96
96
|
settleErasure(): Promise<void>;
|
|
97
97
|
/** The session's terminal runs, deleted each under its own id lock with the selection re-checked against the live row (interface:
|
|
98
|
-
* {@link WorkflowRunStore.deleteBySession}) — a run
|
|
98
|
+
* {@link WorkflowRunStore.deleteBySession}) — a run removed or replaced by a new running run is skipped, as `reap` skips one. */
|
|
99
99
|
deleteBySession(sessionId: string, scope: string): Promise<string[]>;
|
|
100
100
|
/** Force a compaction now (test/inspection): rewrite the snapshot from the authoritative map and
|
|
101
101
|
* truncate the live ledger (RB-167's closeForSwap recipe lives in the base). */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ExecutionEnv } from "../../internal/harness.js";
|
|
2
|
+
import type { ExecutionEnvExecOptions, ReadFloor } from "../../internal/harness-types.js";
|
|
3
|
+
import { modelShellOf, startsInBackground } from "../../core/model-shell.js";
|
|
4
|
+
export { modelShellOf, startsInBackground };
|
|
5
|
+
/** The one result a background command gets where none can run here (`BASH_BACKGROUND_UNAVAILABLE`, a module constant). */
|
|
6
|
+
export declare function bashBackgroundUnavailable(): {
|
|
7
|
+
content: string;
|
|
8
|
+
isError: true;
|
|
9
|
+
};
|
|
10
|
+
/** What both Bash faces answer, first of all, on an environment that declares no start for model text — before any admission, probe
|
|
11
|
+
* or start: a background command the background-unavailable result; a foreground one the never-started failure, thrown. `undefined`
|
|
12
|
+
* when the environment declares a start. */
|
|
13
|
+
export declare function refuseWithoutModelShell(env: ExecutionEnv, background: boolean): {
|
|
14
|
+
content: string;
|
|
15
|
+
isError: true;
|
|
16
|
+
} | undefined;
|
|
17
|
+
/** The foreground start for model text, with the call's byte floor (`readFloor`, a parameter every caller gives — `undefined` when the
|
|
18
|
+
* call carries none — written into the start's options here, where the start is made): the start's `exec`, called on the start — or,
|
|
19
|
+
* on an environment that declares none, the never-started failure (`shell_unavailable`), nothing started. */
|
|
20
|
+
export declare function modelShellExec(env: ExecutionEnv, command: string, readFloor: ReadFloor | undefined, options: ExecutionEnvExecOptions): ReturnType<ExecutionEnv["exec"]>;
|
|
21
|
+
/** Whether a background command can run here: the environment runs background processes and its start for model text has a
|
|
22
|
+
* background face (a background command is model text too). */
|
|
23
|
+
export declare function startsModelTextInBackground(env: ExecutionEnv): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { errorResult } from "../../core/tools.js";
|
|
2
|
+
import { ExecutionError } from "../../internal/harness.js";
|
|
3
|
+
import { MODEL_SHELL_UNDECLARED_REFUSAL, modelShellOf, startsInBackground } from "../../core/model-shell.js";
|
|
4
|
+
import { hasBackgroundShell } from "../../core/background-shell.js";
|
|
5
|
+
import { BASH_BACKGROUND_UNAVAILABLE } from "./fs-bash-background-text.js";
|
|
6
|
+
export { modelShellOf, startsInBackground };
|
|
7
|
+
export function bashBackgroundUnavailable() {
|
|
8
|
+
return errorResult(BASH_BACKGROUND_UNAVAILABLE);
|
|
9
|
+
}
|
|
10
|
+
export function refuseWithoutModelShell(env, background) {
|
|
11
|
+
if (modelShellOf(env) !== undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (background)
|
|
14
|
+
return bashBackgroundUnavailable();
|
|
15
|
+
throw new Error(`Error (Bash): command did not run: ${MODEL_SHELL_UNDECLARED_REFUSAL}`);
|
|
16
|
+
}
|
|
17
|
+
export function modelShellExec(env, command, readFloor, options) {
|
|
18
|
+
const start = modelShellOf(env);
|
|
19
|
+
if (start === undefined)
|
|
20
|
+
return Promise.resolve({ ok: false, error: new ExecutionError("shell_unavailable", MODEL_SHELL_UNDECLARED_REFUSAL) });
|
|
21
|
+
return start.exec(command, { ...options, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
22
|
+
}
|
|
23
|
+
export function startsModelTextInBackground(env) {
|
|
24
|
+
return hasBackgroundShell(env) && startsInBackground(modelShellOf(env));
|
|
25
|
+
}
|
|
@@ -468,6 +468,12 @@ export declare function expansionInWord(w: {
|
|
|
468
468
|
export declare function globInWord(w: {
|
|
469
469
|
readonly pieces: readonly WordPiece[];
|
|
470
470
|
}): boolean;
|
|
471
|
+
/** Does this word carry a BRACKET expression the shell forms — a pathname-expansion piece the lexer carved from an unquoted `[`
|
|
472
|
+
* with an unquoted `]` after it (the one such piece with a `body`; `*` and `?` have none)? Where the class closes is the
|
|
473
|
+
* lexer's business, not this answer's: a collating symbol by name (`[[.period.]]`) is one too. */
|
|
474
|
+
export declare function bracketInWord(w: {
|
|
475
|
+
readonly pieces: readonly WordPiece[];
|
|
476
|
+
}): boolean;
|
|
471
477
|
/**
|
|
472
478
|
* Read ONE sed script and answer whether it can name a file or run a command.
|
|
473
479
|
*
|
|
@@ -287,6 +287,9 @@ export function globInWord(w) {
|
|
|
287
287
|
}
|
|
288
288
|
return false;
|
|
289
289
|
}
|
|
290
|
+
export function bracketInWord(w) {
|
|
291
|
+
return w.pieces.some((p) => isGlobPiece(p) && p.expansion?.body !== undefined);
|
|
292
|
+
}
|
|
290
293
|
const SED_READONLY_SCRIPT_PIECE = /^(?:\d+|\d+,\d+)?p$/;
|
|
291
294
|
const SED_FILE_OR_EXEC_COMMANDS = new Set(["r", "R", "w", "W", "e"]);
|
|
292
295
|
const SED_PLAIN_COMMANDS = new Set(["=", "d", "D", "F", "g", "G", "h", "H", "n", "N", "p", "P", "x", "z"]);
|
|
@@ -23,10 +23,16 @@ export function createFileWriteStation(opts) {
|
|
|
23
23
|
return null;
|
|
24
24
|
return (async () => {
|
|
25
25
|
const r = await opts.contain(spelled, signal, callOpts.toolCallId);
|
|
26
|
-
if (r.ok
|
|
26
|
+
if (r.ok)
|
|
27
27
|
return VOUCH;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (r.violation.code === "path_not_in_root") {
|
|
29
|
+
const details = violationDetails(r.violation);
|
|
30
|
+
return { disposition: "refuse", finding: "outside_roots", face: "write", sentence: violationText(call.toolName, r.violation), ...(details !== undefined ? { details } : {}) };
|
|
31
|
+
}
|
|
32
|
+
if (r.violation.code === "write_path_denied") {
|
|
33
|
+
return { disposition: "refuse", finding: "deny_hit", face: "write", sentence: violationText(call.toolName, r.violation), ...(r.violation.echoed !== undefined ? { echoed: r.violation.echoed } : {}) };
|
|
34
|
+
}
|
|
35
|
+
return VOUCH;
|
|
30
36
|
})();
|
|
31
37
|
},
|
|
32
38
|
unanswered: () => VOUCH,
|
package/dist/tools/fs/fs-bash.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { defineTool, errorResult } from "../../core/tools.js";
|
|
4
|
+
import { bashBackgroundUnavailable, modelShellExec, modelShellOf, refuseWithoutModelShell, startsInBackground, startsModelTextInBackground } from "./bash-model-shell.js";
|
|
4
5
|
import { callOccupant } from "../../core/task-registry-shared.js";
|
|
5
6
|
import { markTruncated, RollingTailBuffer } from "../../core/exec-output-tail.js";
|
|
6
7
|
import { BACKGROUND_START_FAILURE_KINDS, createBackgroundOutputFile, envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "../../core/background-shell.js";
|
|
@@ -11,7 +12,7 @@ import { admitImageBytes, sniffImageMime } from "../../core/image-admission.js";
|
|
|
11
12
|
import { isDeadCwd, diagnoseDeadCwd } from "./dead-cwd.js";
|
|
12
13
|
import { boundaryIsTheSandbox, hasDestroy, isIsolated } from "../../core/remote-env.js";
|
|
13
14
|
import { ghRateLimitHint } from "./gh-rate-limit.js";
|
|
14
|
-
import { backgroundLifetimeNote, backgroundOutputFileNote,
|
|
15
|
+
import { backgroundLifetimeNote, backgroundOutputFileNote, ONE_SHOT_BACKGROUND_COMMAND_NOTE } from "./fs-bash-background-text.js";
|
|
15
16
|
import { admitsBackgroundLaunch, resolveCompletionSink } from "../../core/task-notification.js";
|
|
16
17
|
import { resolveBashTimeoutCaps, bashTimeoutCapsSec, bashTimeoutArgRefusal, bashTimeoutParamDescription, bashMaxOutputChars, clipShellOutput, writeShellOverflowFile, shellRecoveryHint, zeroOutputSentence, targetUnavailableCard, targetUnavailableSentence, bashFailureCard, CWD_SENTINEL, stripCwdSentinel, } from "./fs-shared.js";
|
|
17
18
|
import { envErrorDetail, failureMessageOnce } from "./env-error-detail.js";
|
|
@@ -323,13 +324,12 @@ async function runShell(env, cwd, toolName, command, timeoutSec, caps, signal, c
|
|
|
323
324
|
const live = onTick === undefined ? undefined : startLivenessTicks(onTick, cwdRef ? createEpilogueFilter(cwdMarker) : undefined);
|
|
324
325
|
let res;
|
|
325
326
|
try {
|
|
326
|
-
res = await env
|
|
327
|
+
res = await modelShellExec(env, toRun, readFloor, {
|
|
327
328
|
cwd: effectiveCwd,
|
|
328
329
|
timeout,
|
|
329
330
|
abortSignal: signal,
|
|
330
331
|
...execEnv,
|
|
331
332
|
...(live !== undefined ? { onStdout: live.onStdout, onStderr: live.onStderr } : {}),
|
|
332
|
-
...(readFloor !== undefined ? { readFloor } : {}),
|
|
333
333
|
...(sandboxStart?.ok === true && sandboxStart.sandbox !== undefined ? { sandbox: sandboxStart.sandbox } : {}),
|
|
334
334
|
...(detach
|
|
335
335
|
? {
|
|
@@ -557,8 +557,9 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
|
|
|
557
557
|
const timeoutCapsSecView = bashTimeoutCapsSec(timeoutCaps);
|
|
558
558
|
const refusalTold = new Set();
|
|
559
559
|
const breachLedger = execFailureBreachLedger();
|
|
560
|
-
const
|
|
561
|
-
const
|
|
560
|
+
const bgStarts = startsModelTextInBackground(env);
|
|
561
|
+
const bgOffered = bgStarts && taskOpts.taskRegistry !== undefined;
|
|
562
|
+
const bgRetained = bgStarts && retainsBackgroundProcesses({ env: envDeclaresRetain(env), task: taskOpts.retainBackgroundProcesses === true });
|
|
562
563
|
const bgSessionScoped = taskOpts.sessionId !== undefined && taskOpts.taskRegistry !== undefined;
|
|
563
564
|
const bgEnvIsolatedOwned = hasDestroy(env) && isIsolated(env);
|
|
564
565
|
const cardOf = (shellFirst) => bashDescription(coAuthor, timeoutCaps, bgOffered, bgRetained, bgSessionScoped, bgEnvIsolatedOwned, taskOpts.commandSandbox !== undefined ? "command" : isIsolated(env) ? "env" : "none", shellFirst);
|
|
@@ -605,14 +606,15 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
|
|
|
605
606
|
const timeoutRefusal = bashTimeoutArgRefusal(timeout, timeoutCaps);
|
|
606
607
|
if (timeoutRefusal !== undefined)
|
|
607
608
|
return errorResult(timeoutRefusal, { type: "bash_invalid_timeout", code: "bash_invalid_timeout" });
|
|
608
|
-
const refused = (await taskOpts.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal)) ?? (await patternKillRefusal(command, env, cwdRef.current, ctx.signal));
|
|
609
|
+
const refused = refuseWithoutModelShell(env, run_in_background === true) ?? (await taskOpts.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal)) ?? (await patternKillRefusal(command, env, cwdRef.current, ctx.signal));
|
|
609
610
|
if (refused !== undefined)
|
|
610
611
|
return refused;
|
|
611
612
|
if (run_in_background) {
|
|
612
613
|
const registry = taskOpts.taskRegistry;
|
|
613
614
|
const onNotify = resolveCompletionSink(ctx.onTaskNotification, taskOpts.onTaskNotification);
|
|
614
|
-
|
|
615
|
-
|
|
615
|
+
const start = modelShellOf(env);
|
|
616
|
+
if (!hasBackgroundShell(env) || !startsInBackground(start) || registry === undefined || !admitsBackgroundLaunch(onNotify))
|
|
617
|
+
return bashBackgroundUnavailable();
|
|
616
618
|
if (cwdRef && (await isDeadCwd(env, cwdRef.current, ctx.signal))) {
|
|
617
619
|
const diagnosis = await diagnoseDeadCwd(env, "Bash", cwdRef.current, rootCanonical, cwdRef, ctx.signal);
|
|
618
620
|
if (diagnosis !== undefined)
|
|
@@ -625,7 +627,7 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
|
|
|
625
627
|
const sandbox = taskOpts.commandSandbox?.start();
|
|
626
628
|
if (sandbox !== undefined && !sandbox.ok)
|
|
627
629
|
return errorResult(sandboxRefusalText("Bash", { by: "plan", reason: sandbox.reason }), { type: "bash", sandboxUnavailable: true });
|
|
628
|
-
const r = await
|
|
630
|
+
const r = await start.spawnBackground(command, {
|
|
629
631
|
cwd: cwdRef.current,
|
|
630
632
|
...(requestedTimeoutSec !== undefined ? { timeout: requestedTimeoutSec } : {}),
|
|
631
633
|
...(readFloor !== undefined ? { readFloor } : {}),
|
|
@@ -706,7 +708,7 @@ export function createBashTool(env, rootCanonical, coAuthor = false, cwdRef = {
|
|
|
706
708
|
backgroundedForQueuedMessage = true;
|
|
707
709
|
detachHub.request(ctx.toolCallId);
|
|
708
710
|
};
|
|
709
|
-
const detachEnv = hasBackgroundShell(env) ? env : undefined;
|
|
711
|
+
const detachEnv = bgStarts && hasBackgroundShell(env) ? env : undefined;
|
|
710
712
|
const detachSink = resolveCompletionSink(ctx.onTaskNotification, taskOpts.onTaskNotification);
|
|
711
713
|
const detachChain = detachHub !== undefined && detachRegistry !== undefined && detachEnv !== undefined && admitsBackgroundLaunch(detachSink) && detachEnv.backgroundCapabilities.supportsDetach === true
|
|
712
714
|
? {
|
|
@@ -844,7 +846,7 @@ export function createBashReadonlyTool(env, rootCanonical, allow, opts) {
|
|
|
844
846
|
const reason = readOnlyFaceRefusal(command, allow);
|
|
845
847
|
if (reason)
|
|
846
848
|
return errorResult(`Error (Bash): ${reason}`);
|
|
847
|
-
const refused = await opts?.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal);
|
|
849
|
+
const refused = refuseWithoutModelShell(env, false) ?? (await opts?.shellReadAdmission?.("Bash", ctx.toolCallId, command, ctx.signal));
|
|
848
850
|
if (refused !== undefined)
|
|
849
851
|
return refused;
|
|
850
852
|
const readOnlyTick = opts?.onToolProgress === undefined ? undefined : (t) => describeSafely(opts.onToolProgress, { toolCallId: ctx.toolCallId, toolName: "Bash", ...t });
|
package/dist/tools/fs/index.d.ts
CHANGED
|
@@ -180,13 +180,14 @@ export interface HandsToolkitOptions {
|
|
|
180
180
|
* roster (the Runner mounts Monitor, this band never does). `false` drops the gh rate-limit hint's
|
|
181
181
|
* Monitor clause; absent ⇒ the full wording. */
|
|
182
182
|
monitorToolActive?: boolean;
|
|
183
|
-
/** ADDITIONS to the
|
|
184
|
-
* (
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
183
|
+
/** ADDITIONS to the sensitive-path deny set ({@link import("./read-deny.js").READ_FACE_DEFAULT_DENY_ENTRIES}):
|
|
184
|
+
* judged on BOTH the read faces (Read/Grep/Glob/RepoMap and their traversals) and the write faces
|
|
185
|
+
* (Write/Edit/NotebookEdit/SaveToolResult; this band's Bash meets them only through a caller-supplied shell
|
|
186
|
+
* station, which judges literal write operands) in every containment mode. Built-in tiers
|
|
187
|
+
* stay read-only (their write side is the write-protection table). Add-only: additions union with the active
|
|
188
|
+
* built-ins, `[]` ≡ absent (union identity), and additions never remove a built-in — the one removal channel
|
|
189
|
+
* is the deployment's built-in configuration ({@link readDenyBuiltinTiers} / {@link readDenyBuiltinExclude}).
|
|
190
|
+
* Bad entry shapes throw at wiring time. */
|
|
190
191
|
readDenyPatterns?: readonly ReadDenyEntry[];
|
|
191
192
|
/** The deployment's built-in-table TIER selection ({@link import("./read-deny.js").ReadDenyBuiltinConfig}
|
|
192
193
|
* `tiers` key) — the switch for the built-in table:
|
package/dist/tools/fs/index.js
CHANGED
|
@@ -91,12 +91,12 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
|
|
|
91
91
|
afterPlacement(createReadFileTool(env, readFileState, rootCanonical, readCwd, readFaceRoots, opts.imageProcessor, opts.pdfModelCapabilities, bgOutputReadExemption, readDeny, readFace, opts.reminderMark, opts.reminderDisclosureCounts, reader)),
|
|
92
92
|
];
|
|
93
93
|
if (handsWriteHalfMounts({ readOnly })) {
|
|
94
|
-
tools.push(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, readDeny, opts.readFirstWaiver), createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, opts.readFirstWaiver), createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
94
|
+
tools.push(afterPlacement(createEditFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, readDeny, opts.readFirstWaiver)), afterPlacement(createWriteFileTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny, opts.readFirstWaiver)), afterPlacement(createNotebookEditTool(env, readFileState, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny)));
|
|
95
95
|
const keptBytes = opts.toolResultBytes;
|
|
96
96
|
if (opts.writeContainmentSeat !== undefined)
|
|
97
97
|
opts.writeContainmentSeat.current = writeContainmentOf(env, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, writeDeny, writeFaceOf);
|
|
98
98
|
if (keptBytes?.bytesOf !== undefined)
|
|
99
|
-
tools.push(createSaveToolResultTool(env, keptBytes, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
|
|
99
|
+
tools.push(afterPlacement(createSaveToolResultTool(env, keptBytes, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny)));
|
|
100
100
|
}
|
|
101
101
|
tools.push(afterPlacement(createGrepTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)), afterPlacement(createGlobTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)), afterPlacement(createRepoMapTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)));
|
|
102
102
|
if (includeShell) {
|
|
@@ -171,7 +171,7 @@ function bandOwnTables(env, opts) {
|
|
|
171
171
|
return await tool.execute(...args);
|
|
172
172
|
},
|
|
173
173
|
};
|
|
174
|
-
const writeDenyCompiled = compileWriteDeny(
|
|
175
|
-
const writeDeny = writeDenyCompiled.
|
|
174
|
+
const writeDenyCompiled = compileWriteDeny(readDeny);
|
|
175
|
+
const writeDeny = writeDenyCompiled.hasRows ? carryHomeViews(writeDenyCompiled, readDeny.homeViews) : undefined;
|
|
176
176
|
return { readDeny, writeDeny, afterPlacement };
|
|
177
177
|
}
|
|
@@ -171,7 +171,7 @@ export declare function homeViewsAt(env: HomeViewEnv, homes: readonly string[]):
|
|
|
171
171
|
/** The home views of one judgment, off the judge it judges with: the views of the judge's placement. A judge that
|
|
172
172
|
* carries none (one built outside a mount) reads the declared home alone. */
|
|
173
173
|
export declare function homeViewsOf(env: HomeViewEnv, judge: HomeViewsCarrier | undefined, signal?: AbortSignal): HomeViews;
|
|
174
|
-
/** A judge with the home views `source` gives it. */
|
|
174
|
+
/** A judge with the home views `source` gives it, preserving getters (live projections) and non-enumerable identity (`id`). */
|
|
175
175
|
export declare function carryHomeViews<T extends object>(judge: T, source: HomeViewSource): T & {
|
|
176
176
|
readonly homeViews: HomeViewSource;
|
|
177
177
|
};
|
|
@@ -397,6 +397,9 @@ export function readDenyOver(current, homeViews) {
|
|
|
397
397
|
get compiledSegments() {
|
|
398
398
|
return current().compiledSegments;
|
|
399
399
|
},
|
|
400
|
+
get tableRows() {
|
|
401
|
+
return current().tableRows;
|
|
402
|
+
},
|
|
400
403
|
homeViews: homeViews ?? { views: (signal) => current().homeViews.views(signal) },
|
|
401
404
|
};
|
|
402
405
|
}
|
|
@@ -418,11 +421,8 @@ export function homeViewsOf(env, judge, signal) {
|
|
|
418
421
|
return (judge?.homeViews ?? homeViewsAt(env, [])).views(signal, env);
|
|
419
422
|
}
|
|
420
423
|
export function carryHomeViews(judge, source) {
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
if (typeof id === "string")
|
|
424
|
-
Object.defineProperty(carried, "id", { value: id, enumerable: false });
|
|
425
|
-
return carried;
|
|
424
|
+
const descriptors = Object.getOwnPropertyDescriptors(judge);
|
|
425
|
+
return Object.defineProperties({}, { ...descriptors, homeViews: { value: source, enumerable: true, writable: true, configurable: true } });
|
|
426
426
|
}
|
|
427
427
|
export async function placeReadDenyAtHome(env, compile, homes, signal, places) {
|
|
428
428
|
const entries = compile([]).entries;
|
|
@@ -152,13 +152,17 @@ export declare function segmentGuardRow(pat: CompiledSegmentPattern, columns: {
|
|
|
152
152
|
readonly tier?: string;
|
|
153
153
|
}): PathGuardRow;
|
|
154
154
|
/**
|
|
155
|
-
* The WRITE face of the deny table: the
|
|
156
|
-
*
|
|
157
|
-
*
|
|
155
|
+
* The WRITE face of the deny table: every row of the one deny table whose faces include `write` — deployment / task
|
|
156
|
+
* `readDenyPatterns` additions (`faces: ["read", "write"]`) and `Read(…)` / `Edit(…)` rule rows — judged for
|
|
157
|
+
* file write tools (`Write`, `Edit`, `NotebookEdit`, `SaveToolResult`) and shell write targets (a redirection, `tee`,
|
|
158
|
+
* `sed -i`, `cp` / `mv` / `touch` / `mkdir` / `rm` operands). Built-in read-deny tiers stay `faces: ["read"]`. Same row
|
|
159
|
+
* type and judgment ({@link judgePathRows}) as the read face.
|
|
158
160
|
*/
|
|
159
161
|
export interface WriteDenyMatcher {
|
|
160
162
|
/** Which face this judge is — the write tools' path resolution reads it to word and code the refusal as a write. */
|
|
161
163
|
readonly face: "write";
|
|
164
|
+
/** True iff the write projection holds at least one row (a `readDenyPatterns` addition or a write-facing rule row). */
|
|
165
|
+
readonly hasRows: boolean;
|
|
162
166
|
readonly ruleRows: readonly PathRuleDenyRow[];
|
|
163
167
|
matchPath(path: string): ReadDenyHit | null;
|
|
164
168
|
/** The target judgment the read face makes, on this face's rows: canonical key, lexical view, the leaf chain's hops. */
|
|
@@ -168,13 +172,26 @@ export interface WriteDenyMatcher {
|
|
|
168
172
|
}): ReadDenyHit | null;
|
|
169
173
|
/** The table ONE call judges with ({@link ReadDenyMatcher.forCall}). */
|
|
170
174
|
forCall?(toolCallId: string | undefined): WriteDenyMatcher;
|
|
171
|
-
/** Is the row a hit named (its rule text) a row that guards the READ face too — a `
|
|
172
|
-
* paths are not written because their reads are denied — rather than a
|
|
173
|
-
* says which of the two refused ({@link readDenySentence}'s `readRow`). Absent ⇒
|
|
175
|
+
/** Is the row a hit named (its pattern or rule text) a row that guards the READ face too — a `readDenyPatterns` addition
|
|
176
|
+
* or a `Read(…)` rule, whose paths are not written because their reads are denied — rather than a write-only row (`Edit(…)`)?
|
|
177
|
+
* The refusal's sentence says which of the two refused ({@link readDenySentence}'s `readRow`). Absent ⇒ none. */
|
|
174
178
|
guardsReads?(pattern: string): boolean;
|
|
179
|
+
/** The write-facing segment row the absolute directory `scope` names or contains ({@link ReadDenyMatcher.rowUnderRoot}),
|
|
180
|
+
* judged on locations alone without enumerating disk (used for subtree removal / rename operations). */
|
|
181
|
+
rowUnderRoot?(scope: string): ReadDenyRootHit | null;
|
|
182
|
+
/** A write-facing row that lies AT or BELOW `path` ({@link ReadDenyMatcher.rowAtOrBelow}): segment rows are judged per row;
|
|
183
|
+
* non-enumerable rule rows answer for any path. */
|
|
184
|
+
rowAtOrBelow?(path: string): ReadDenyHit | null;
|
|
185
|
+
/** The write-facing segment rows no location places (an unanchored row: its match may start in any folder), in table order —
|
|
186
|
+
* the rows a recursive removal's subtree is searched for by name, since {@link rowUnderRoot} cannot place them below an
|
|
187
|
+
* operand that does not spell them. */
|
|
188
|
+
readonly unanchoredRows?: readonly string[];
|
|
189
|
+
/** The first {@link unanchoredRows} row whose leading named segment (its first segment that is not stars only) the ONE
|
|
190
|
+
* directory entry name `name` matches, folded as that row folds; null where none. */
|
|
191
|
+
rowLedByName?(name: string): string | null;
|
|
175
192
|
}
|
|
176
|
-
/**
|
|
177
|
-
export declare function compileWriteDeny(
|
|
193
|
+
/** Project the write face (`faces.includes("write")`) out of one compiled deny table ({@link compileReadDeny}). */
|
|
194
|
+
export declare function compileWriteDeny(table: ReadDenyMatcher): WriteDenyMatcher;
|
|
178
195
|
/** One compiled ripgrep glob flag for the traversal legs (`--iglob` = case-insensitive entry). */
|
|
179
196
|
export interface ReadDenyRgGlob {
|
|
180
197
|
flag: "--glob" | "--iglob";
|
|
@@ -243,6 +260,9 @@ export interface ReadDenyMatcher {
|
|
|
243
260
|
* OS confinement translates the table from (read-floor.ts); the rule rows are {@link ruleRows}. Absent on a hand-built
|
|
244
261
|
* matcher: such a table has no confinement. */
|
|
245
262
|
readonly compiledSegments?: readonly CompiledSegmentPattern[];
|
|
263
|
+
/** Every compiled row of this table (built-in tiers, additions, placements, and rule rows across both faces),
|
|
264
|
+
* each carrying its `faces` column — the one source {@link compileWriteDeny} projects the write face from. */
|
|
265
|
+
readonly tableRows?: readonly PathGuardRow[];
|
|
246
266
|
/** The table's identity, minted once where {@link compileReadDeny} compiles it: a compiled table never changes its
|
|
247
267
|
* judgment, so two tables with one `id` judge every path alike. Not enumerable: a spread copy (which may replace the
|
|
248
268
|
* judgment) has none; the copy that only carries other home views (`carryHomeViews`) keeps it. Absent on a hand-built
|
|
@@ -326,6 +346,11 @@ export interface ReadDenyFinding {
|
|
|
326
346
|
* alone. The sentence then says the search below the folder is refused for a location it holds, and that no file need be
|
|
327
347
|
* there — naming a row as what "the target matches" would send the reader looking for a file that may not exist. */
|
|
328
348
|
readonly under?: true;
|
|
349
|
+
/** On the write face, a recursive REMOVAL whose subtree was searched by name for an unanchored row
|
|
350
|
+
* ({@link WriteDenyMatcher.rowLedByName}) and FOUND below it: `found` — the entry the search found, which the sentence names. */
|
|
351
|
+
readonly lookup?: {
|
|
352
|
+
readonly found: string;
|
|
353
|
+
};
|
|
329
354
|
}
|
|
330
355
|
/**
|
|
331
356
|
* The deny finding minted ONCE as both of its faces: the sentence ({@link readDenySentence}) and the literals that sentence
|