@sema-agent/core 7.57.0 → 7.59.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 +1161 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +89 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +20 -7
- package/dist/core/allow-entry.js +18 -9
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +2 -2
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-store.d.ts +85 -23
- package/dist/core/checkpoint-store.js +31 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +99 -9
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +7 -4
- package/dist/core/gate-lanes.js +19 -6
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +35 -4
- package/dist/core/hooks.js +17 -11
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +20 -3
- package/dist/core/locked-config.js +40 -3
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +117 -15
- package/dist/core/mcp-failure.js +71 -3
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +27 -3
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +16 -20
- package/dist/core/mcp.js +112 -55
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +12 -9
- package/dist/core/mods/kernel/events.d.ts +6 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +9 -1
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +33 -12
- package/dist/core/mods/stations.js +45 -11
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +13 -4
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +248 -0
- package/dist/core/peer-seat.js +439 -0
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +20 -3
- package/dist/core/present-plan-tool.js +48 -4
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +38 -0
- package/dist/core/rewrite-rejudge.js +42 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +33 -21
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +30 -8
- package/dist/core/runner/gate-exit.js +15 -8
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +14 -10
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
- package/dist/core/runner/prepare-delegation-surface.js +16 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
- package/dist/core/runner/prepare-hands-readface.js +9 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +26 -37
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +18 -15
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +11 -3
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +28 -13
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +5 -3
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +42 -29
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +2 -1
- package/dist/core/runner/tool-occurrence.d.ts +5 -2
- package/dist/core/runner/tool-occurrence.js +4 -3
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +3 -3
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +9 -10
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +86 -24
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +92 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +7 -1
- package/dist/core/task-spec.d.ts +49 -1
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +11 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +18 -6
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +24 -23
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +30 -2
- package/dist/engine/harness/agent-harness.js +43 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +56 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +30 -10
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +11 -22
- package/dist/index.d.ts +29 -16
- package/dist/index.js +21 -11
- package/dist/internal/harness-types.d.ts +2 -2
- package/dist/internal/harness.d.ts +3 -2
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +7 -3
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +61 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +26 -9
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +149 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isAbsolute, sep } from "node:path";
|
|
2
2
|
import { deliverEngineNotice } from "../types.js";
|
|
3
3
|
import { admitMemoryScopes } from "../memory-admission.js";
|
|
4
|
-
import { adoptLegacyRepoDirs, canonicalize, deriveRepoControlPlaneDir, deriveProjectControlDir, deriveProjectMemoryDir,
|
|
5
|
-
import {
|
|
4
|
+
import { adoptLegacyRepoDirs, canonicalize, deriveRepoControlPlaneDir, deriveProjectControlDir, deriveProjectMemoryDir, deriveRepoKey, deriveRepoMemoryDir, effectiveControlRootOf, isContainedIn, lookupProjectIdHint, recordProjectIdHint, resolveMemoryEngineRoot, transferMemoryAnnouncements } from "../memory-engine/layout.js";
|
|
5
|
+
import { derivePersonalControlDir, derivePersonalMemoryDir, directoryPinOf, memoryPlaneStore, mergeHarvestReports, mergeInjections, needsDualRoots, parsedProjectPlane, scopePlanesOf } from "../memory-engine/dual-root.js";
|
|
6
6
|
import { memoryProjectScopeAbsentNotice, normalizeMemorySpec } from "../memory.js";
|
|
7
7
|
import { deriveSupersededSet } from "../memory-engine/consolidation.js";
|
|
8
8
|
import { shadowNamesOf } from "../memory-engine/shadowing.js";
|
|
@@ -11,8 +11,7 @@ import { adjudicateCaptureOptOut, captureOptOutDeniedError, captureOptOutUnpersi
|
|
|
11
11
|
import { readSessionCaptureOptOut } from "../memory-engine/layout.js";
|
|
12
12
|
import { sessionIncarnationResolver } from "../memory-engine/session-incarnation.js";
|
|
13
13
|
import { createMemoryEngineTools } from "../memory-engine/tools.js";
|
|
14
|
-
import { assertScopeContractPlacement, parseScopeKey
|
|
15
|
-
import { FileMemoryEngineBackend } from "../memory-engine/file-backend.js";
|
|
14
|
+
import { assertScopeContractPlacement, parseScopeKey } from "../memory-engine/scope-contract.js";
|
|
16
15
|
import { writableRootOf } from "../memory-engine/types.js";
|
|
17
16
|
import { catalogText } from "../../prompt-assembly/catalog/index.js";
|
|
18
17
|
import { asThrownError, thrownText } from "../thrown-value.js";
|
|
@@ -101,7 +100,7 @@ export async function prepareMemory(input) {
|
|
|
101
100
|
const backend = deps.memoryBackend;
|
|
102
101
|
const lineageTokens = new Map(input.captureForkOrigin !== undefined && input.captureForkOriginIncarnation !== undefined ? [[input.captureForkOrigin, input.captureForkOriginIncarnation]] : []);
|
|
103
102
|
const incarnationOpt = { sessionIncarnation: sessionIncarnationResolver(sessionId, input.sessionIncarnation, lineageTokens) };
|
|
104
|
-
const pinned = backend
|
|
103
|
+
const pinned = directoryPinOf(backend);
|
|
105
104
|
const engineRoot = resolveMemoryEngineRoot(deps.memoryEngineDir);
|
|
106
105
|
const repoRoot = deps.rootPath ?? taskRootPath;
|
|
107
106
|
if (repoRoot) {
|
|
@@ -112,30 +111,12 @@ export async function prepareMemory(input) {
|
|
|
112
111
|
const consumesProjectIdentity = [...memorySpec.scopes, ...(memorySpec.writeScope !== null ? [memorySpec.writeScope] : [])]
|
|
113
112
|
.map(parseScopeKey)
|
|
114
113
|
.some((k) => k.kind === "proj" || k.kind === "userproj");
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
catch (err) {
|
|
120
|
-
if (consumesProjectIdentity)
|
|
121
|
-
throw err;
|
|
122
|
-
deps.onError?.(asThrownError(err), { phase: "config", sessionId });
|
|
123
|
-
}
|
|
114
|
+
if (input.sessionProject.markerFault !== undefined && consumesProjectIdentity)
|
|
115
|
+
throw input.sessionProject.markerFault;
|
|
116
|
+
const marker = input.sessionProject.project?.source === "marker" ? { projectId: input.sessionProject.project.id } : undefined;
|
|
117
|
+
const verdictOnPartitionRoot = deriveRepoKey(input.sessionProject.root) === deriveRepoKey(repoRoot);
|
|
124
118
|
if (marker) {
|
|
125
119
|
identityKey = marker.projectId;
|
|
126
|
-
const firstSwitch = lookupProjectIdHint(engineRoot, repoRoot) !== marker.projectId;
|
|
127
|
-
recordProjectIdHint(engineRoot, repoRoot, marker.projectId);
|
|
128
|
-
if (firstSwitch) {
|
|
129
|
-
try {
|
|
130
|
-
const oldCtl = deriveRepoControlPlaneDir(engineRoot, repoRoot);
|
|
131
|
-
const newCtl = deriveProjectControlDir(engineRoot, marker.projectId);
|
|
132
|
-
const drained = drainMemoryAnnouncements(oldCtl);
|
|
133
|
-
for (const ann of drained.queue)
|
|
134
|
-
enqueueMemoryAnnouncement(newCtl, ann);
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
120
|
if (memorySpec.writeScope !== null) {
|
|
140
121
|
const w = parseScopeKey(memorySpec.writeScope);
|
|
141
122
|
if ((w.kind === "proj" || w.kind === "userproj") && w.projectId !== marker.projectId) {
|
|
@@ -145,8 +126,21 @@ export async function prepareMemory(input) {
|
|
|
145
126
|
throw e;
|
|
146
127
|
}
|
|
147
128
|
}
|
|
129
|
+
const firstSwitch = verdictOnPartitionRoot && lookupProjectIdHint(engineRoot, repoRoot) !== marker.projectId;
|
|
130
|
+
if (verdictOnPartitionRoot)
|
|
131
|
+
recordProjectIdHint(engineRoot, repoRoot, marker.projectId);
|
|
132
|
+
if (firstSwitch) {
|
|
133
|
+
try {
|
|
134
|
+
const oldCtl = deriveRepoControlPlaneDir(engineRoot, repoRoot);
|
|
135
|
+
const newCtl = deriveProjectControlDir(engineRoot, marker.projectId);
|
|
136
|
+
transferMemoryAnnouncements(oldCtl, newCtl);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
deps.onError?.(asThrownError(err), { phase: "config", sessionId });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
148
142
|
}
|
|
149
|
-
else {
|
|
143
|
+
else if (verdictOnPartitionRoot) {
|
|
150
144
|
const hint = lookupProjectIdHint(engineRoot, repoRoot);
|
|
151
145
|
if (hint !== undefined) {
|
|
152
146
|
deps.onError?.(new Error(`memory project marker missing but recoverable: ${repoRoot} previously carried projectId ${hint} ` +
|
|
@@ -155,13 +149,9 @@ export async function prepareMemory(input) {
|
|
|
155
149
|
}
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
|
-
const memoryDir =
|
|
159
|
-
? pinned
|
|
160
|
-
: identityKey !== undefined
|
|
161
|
-
? deriveProjectMemoryDir(engineRoot, identityKey)
|
|
162
|
-
: deriveRepoMemoryDir(engineRoot, repoRoot);
|
|
152
|
+
const memoryDir = pinned ?? (identityKey !== undefined ? deriveProjectMemoryDir(engineRoot, identityKey) : deriveRepoMemoryDir(engineRoot, repoRoot));
|
|
163
153
|
const projectControlDir = identityKey !== undefined ? deriveProjectControlDir(engineRoot, identityKey) : deriveRepoControlPlaneDir(engineRoot, repoRoot);
|
|
164
|
-
const planes = memorySpec.
|
|
154
|
+
const planes = scopePlanesOf(memorySpec.scopes, memorySpec.writeScope, memorySpec.scopeContract);
|
|
165
155
|
const dual = planes !== undefined && needsDualRoots(planes);
|
|
166
156
|
const personalOnly = planes !== undefined && !dual && planes.project.length === 0 && planes.writePlane !== "project" && (planes.personal.length > 0 || planes.writePlane === "personal");
|
|
167
157
|
if (memorySpec.scopeContract === "v2" && !personalOnly) {
|
|
@@ -176,7 +166,6 @@ export async function prepareMemory(input) {
|
|
|
176
166
|
const personalMemoryDir = derivePersonalMemoryDir(engineRoot);
|
|
177
167
|
const personalControlDir = derivePersonalControlDir(engineRoot);
|
|
178
168
|
const captureStoreOpt = (dir, b, configured) => deps.memoryCaptureRecordStore !== undefined ? { captureRecordStore: deps.memoryCaptureRecordStore({ controlDir: effectiveControlRootOf(dir, { pinnedBy: b, controlDir: configured }) }) } : {};
|
|
179
|
-
const choosePersonalBackend = () => typeof pinned === "string" && pinned ? new FileMemoryEngineBackend(personalMemoryDir, { controlDir: personalControlDir }) : backend;
|
|
180
169
|
const createPersonalEngine = (personalBackend) => {
|
|
181
170
|
return {
|
|
182
171
|
engine: new MemoryEngine({ backend: personalBackend, memoryDir: personalMemoryDir, controlDir: personalControlDir, onIncident: onEngineIncident, provenance: input.memoryProvenance, ...captureStoreOpt(personalMemoryDir, personalBackend, personalControlDir), ...incarnationOpt, ...(input.deps.memoryConsolidation !== undefined ? { consolidation: input.deps.memoryConsolidation } : {}) }),
|
|
@@ -340,7 +329,7 @@ export async function prepareMemory(input) {
|
|
|
340
329
|
return {};
|
|
341
330
|
};
|
|
342
331
|
if (dual) {
|
|
343
|
-
const personalBackendChosen =
|
|
332
|
+
const personalBackendChosen = memoryPlaneStore("personal", backend, engineRoot);
|
|
344
333
|
{
|
|
345
334
|
const projCtl = effectiveControlRootOf(memoryDir, { pinnedBy: backend, controlDir: projectControlDir });
|
|
346
335
|
const persCtl = effectiveControlRootOf(personalMemoryDir, { pinnedBy: personalBackendChosen, controlDir: personalControlDir });
|
|
@@ -447,7 +436,7 @@ export async function prepareMemory(input) {
|
|
|
447
436
|
};
|
|
448
437
|
}
|
|
449
438
|
else if (personalOnly) {
|
|
450
|
-
const personal = createPersonalEngine(
|
|
439
|
+
const personal = createPersonalEngine(memoryPlaneStore("personal", backend, engineRoot));
|
|
451
440
|
const personalEngine = personal.engine;
|
|
452
441
|
await armCaptureOptOut(personalEngine);
|
|
453
442
|
const handle = await personalEngine.materialize(memorySpec.scopes, memorySpec.writeScope, { adoptionRestricted: adoptionRestricted || captureOptedOut || captureIndeterminate, sessionId });
|
|
@@ -23,7 +23,7 @@ import type { AgentHarness, AgentMessage, AgentTool, ExecutionEnv } from "../../
|
|
|
23
23
|
import { type CallTargetStamp } from "../effective-path-target.js";
|
|
24
24
|
import { type OnQuestion } from "../ask-question.js";
|
|
25
25
|
import { type CheckpointStore } from "../checkpoint-store.js";
|
|
26
|
-
import type
|
|
26
|
+
import { type GrantBindingOf } from "../skill-grant-binding.js";
|
|
27
27
|
import type { SessionStore } from "../session.js";
|
|
28
28
|
import { type OnAsk, type ToolCallRequest, type ToolPolicy } from "../tool-policy.js";
|
|
29
29
|
import { type ToolResultStore } from "../tool-result-store.js";
|
|
@@ -8,6 +8,7 @@ import { boundInputHashOf, exactBoundInputHashOf } from "../canonical-json.js";
|
|
|
8
8
|
import { buildRiskDescriptor, debitLedger, encodeAtFidelity, mintCheckpointId, mintCheckpointToken, resolveDeclaredFidelity, } from "../checkpoint-store.js";
|
|
9
9
|
import { pauseOf } from "../pause-registry.js";
|
|
10
10
|
import { samePlainValue } from "../same-plain-value.js";
|
|
11
|
+
import { requestGrantBinding } from "../skill-grant-binding.js";
|
|
11
12
|
import { askCarryRowMembers } from "../hooks.js";
|
|
12
13
|
import { askMandateMember, ownedClearanceFacts } from "../ask-origin.js";
|
|
13
14
|
import { defaultTaskRegistry } from "../task-registry.js";
|
|
@@ -171,7 +172,7 @@ export function prepareParkAsk(input) {
|
|
|
171
172
|
...callFaceSeat(req.face),
|
|
172
173
|
...(handsCwdRef !== undefined ? { cwd: handsCwdRef.current } : {}), ...(handsRoot !== undefined ? { root: handsRoot } : {}),
|
|
173
174
|
...advertisedWritableRootsSeat(advertisedWritableDirs),
|
|
174
|
-
...exemptRootsSeat(exemptRoots),
|
|
175
|
+
...exemptRootsSeat(exemptRoots), ...requestGrantBinding(grantBindingOf, req, presented.value),
|
|
175
176
|
});
|
|
176
177
|
const withReading = stampCallTarget?.(reprojectedReq(), cutSignal);
|
|
177
178
|
const reprojectedRaced = await raceSettlementAgainstSignal(withReading === undefined ? Promise.resolve(basePolicyForResumeEdit.check(reprojectedReq(), cutSignal)) : withReading.then((r) => basePolicyForResumeEdit.check(r, cutSignal)), cutSignal);
|
|
@@ -33,7 +33,7 @@ import type { RunnerDeps, RuntimeCaps, TaskSpec, ToolEffect } from "../types.js"
|
|
|
33
33
|
import type { CwdRef } from "../../tools/fs/fs-shared.js";
|
|
34
34
|
import type { ReadDenyMatcher } from "../../tools/fs/read-deny.js";
|
|
35
35
|
import { type SkillGrantLane, type SkillGrantSource, type SkillGrantTable } from "../skill-grant.js";
|
|
36
|
-
import type
|
|
36
|
+
import { type GrantBindingOf } from "../skill-grant-binding.js";
|
|
37
37
|
import type { ToolSelector } from "../tool-face.js";
|
|
38
38
|
import { type AllowEntryLane, type AllowEntryTable } from "../allow-entry.js";
|
|
39
39
|
import type { InheritedGate, IrreversibilityTier, PrepareResume, RunInternals, StopForDenialLimit } from "./contracts.js";
|
|
@@ -48,8 +48,8 @@ export interface PreparePolicyChainInput {
|
|
|
48
48
|
hostFloor: HostFloor | undefined;
|
|
49
49
|
/** borrowed-readonly — the REBOUND spec. Read: `sessionId` / `principal` (the session-rule read and the lanes' identity),
|
|
50
50
|
* `durableApproval` / `checkpointStore` (the mandate-park facility test and the sandbox arming's park prerequisites), `taskId` (the late-ask observer's detail),
|
|
51
|
-
* `tools` (the names the caller mounted, for the name audit). Never mutated. */
|
|
52
|
-
spec: Pick<TaskSpec, "sessionId" | "principal" | "durableApproval" | "taskId" | "checkpointStore" | "tools" | "excludeAllTools">;
|
|
51
|
+
* `tools` (the names the caller mounted, for the name audit), `classifyAllShell` (every allow member's auto strip). Never mutated. */
|
|
52
|
+
spec: Pick<TaskSpec, "sessionId" | "principal" | "durableApproval" | "taskId" | "checkpointStore" | "tools" | "excludeAllTools" | "classifyAllShell">;
|
|
53
53
|
/** borrowed-readonly — the deployment seats: `sessionPolicyStore` (the rule reads),
|
|
54
54
|
* `permissionRuleStore` / `localOwnerRules` (the lanes and the offer factory), `onError` / `onNotice` (the advisories,
|
|
55
55
|
* the refusal disclosures, the late-ask observer), `tracer` (the admission and rule-store frames), `checkpointStore` (the park facility). Receiver preserved;
|
|
@@ -66,9 +66,11 @@ export interface PreparePolicyChainInput {
|
|
|
66
66
|
hostTaskId: string;
|
|
67
67
|
/** borrowed-readonly — the FINAL task root (path rules resolve against it; the lanes' and the offers' root). */
|
|
68
68
|
taskRootFinal: string;
|
|
69
|
-
/** borrowed-readonly — the leg's canonical write roots beyond
|
|
70
|
-
* dirs): the `acceptEdits` mode gate allows writes inside the
|
|
69
|
+
/** borrowed-readonly — the leg's canonical write roots beyond its write location (`additionalDirectories` + advertised writable
|
|
70
|
+
* dirs): the `acceptEdits` mode gate allows writes inside the write location and these, and asks outside them all. */
|
|
71
71
|
additionalRootsCanonical: readonly string[];
|
|
72
|
+
/** borrowed-readonly — the leg's ONE write-location reader (`writeLocationOf`), read per call by the `acceptEdits` gate. */
|
|
73
|
+
writeLocation: () => string;
|
|
72
74
|
/** borrowed-readonly — the run's resolved env (path rules resolve in it; the sandbox declaration is read off it). */
|
|
73
75
|
executionEnv: ExecutionEnv;
|
|
74
76
|
/** borrowed-readonly — the frozen preflight as installed on this leg: `toolPolicy` (the caller slot) and
|
|
@@ -166,8 +168,6 @@ export interface PreparePolicyChainInput {
|
|
|
166
168
|
/** borrowed-readonly — the leg's live permission-mode seat: the mode gate policy layer and the inherited stations' arbitration
|
|
167
169
|
* read `current` per call. */
|
|
168
170
|
permissionMode: PermissionModeController;
|
|
169
|
-
/** borrowed-readonly — the task's scratchpad directory (the mode write gate's one exemption), or undefined. */
|
|
170
|
-
scratchpadDir: string | undefined;
|
|
171
171
|
/** borrowed-readonly — the leg's live roster seat; the mode write gate reads `current` per call. */ toolRosterDeltas: NonNullable<ModeGateSeats["roster"]>;
|
|
172
172
|
/** borrowed-readonly — the run's ONE typed stop for a denial-limit bound (the fallback settlements call it). */
|
|
173
173
|
stopForDenialLimit: StopForDenialLimit;
|
|
@@ -15,10 +15,11 @@ import { approvalCardMemberOf } from "../tool-roster.js";
|
|
|
15
15
|
import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
|
|
16
16
|
import { emitTrace } from "../trace.js";
|
|
17
17
|
import { skillGrantBindingMembers } from "../skill-grant.js";
|
|
18
|
+
import { withArgsBinding } from "../skill-grant-binding.js";
|
|
18
19
|
import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
|
|
19
|
-
import { delegationPoolReading } from "./sub-agent-deny-lists.js";
|
|
20
|
+
import { delegationPoolReading, policyNameRefusal, POLICY_NAME_REFUSAL_CODE } from "./sub-agent-deny-lists.js";
|
|
20
21
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
21
|
-
import { autoStrippedRule, cardDisclosureOf, rootFacingToolNames } from "../allow-entry.js";
|
|
22
|
+
import { autoStrippedRule, cardDisclosureOf, classifiesAllShell, rootFacingToolNames } from "../allow-entry.js";
|
|
22
23
|
import { arbitrateByMode, askClassMembersOf, askFaceOf, askMandateMember } from "../ask-origin.js";
|
|
23
24
|
import { createModeGatePolicy, mountedToolDeclaresReadOnly } from "../mode-policy.js";
|
|
24
25
|
const ancestorFacts = (ask) => ({ ...(ask ?? {}), ancestorResolved: true });
|
|
@@ -32,7 +33,7 @@ import { policyThrowLine, reportPolicyThrow } from "./policy-throw.js";
|
|
|
32
33
|
import { heldBy, heldValues, seatOf, wireOf } from "../tool-name-readings.js";
|
|
33
34
|
import { hostFloorPolicy } from "../host-floor.js";
|
|
34
35
|
export async function preparePolicyChain(input) {
|
|
35
|
-
const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode,
|
|
36
|
+
const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, writeLocation, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus, ownModChain, autoModeDecider, readFace, permissionMode, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef, hostFloor } = input;
|
|
36
37
|
const ancestorArbitrations = new Map();
|
|
37
38
|
const arbitrateInherited = (ask, toolCallId, judged) => {
|
|
38
39
|
const verdict = arbitrateByMode(permissionMode.current, judged.classification, { origin: judged.origin, ...askMandateMember(ancestorFacts(judged.ask.action === "ask" ? judged.ask : undefined)) });
|
|
@@ -44,7 +45,8 @@ export async function preparePolicyChain(input) {
|
|
|
44
45
|
return { action: "deny", message: `refused by the ${verdict.mode} permission mode at an inherited ancestor layer (${verdict.askClass})`, decisionReason: "mode" };
|
|
45
46
|
};
|
|
46
47
|
const policy = lockedPreflight.toolPolicy;
|
|
47
|
-
const auditPolicyNames = (auditee,
|
|
48
|
+
const auditPolicyNames = (auditee, layer = "caller_policy") => {
|
|
49
|
+
const refused = [];
|
|
48
50
|
const nameGroups = toolPolicyNameSets(auditee);
|
|
49
51
|
if (nameGroups.length > 0) {
|
|
50
52
|
const known = mountedToolNames(tools);
|
|
@@ -58,7 +60,7 @@ export async function preparePolicyChain(input) {
|
|
|
58
60
|
for (const [kind, list] of [["deny", g.deny], ["ask", g.ask], ["allow", g.allow]]) {
|
|
59
61
|
for (const n of list ?? []) {
|
|
60
62
|
const verdict = judgeRuleToolName(n, known, kind);
|
|
61
|
-
const twin = verdict.kind === "current" &&
|
|
63
|
+
const twin = verdict.kind === "current" && layer !== "ancestor_session_rules" ? nearMissSpellingOf(n, rootFacing) : undefined;
|
|
62
64
|
const stale = verdict.kind !== "current" ? verdict : twin !== undefined ? { kind: "case_twin", twin, carrier: known.has(twin) || callerNames.has(twin) ? "run" : pool.names.has(twin) ? "pool" : "catalog" } : undefined;
|
|
63
65
|
if (stale !== undefined) {
|
|
64
66
|
const entry = `tool policy ${kind}-list entry "${n}"`;
|
|
@@ -81,9 +83,8 @@ export async function preparePolicyChain(input) {
|
|
|
81
83
|
return exhaustive;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
throw err;
|
|
86
|
+
refused.push({ message, problem: { code: POLICY_NAME_REFUSAL_CODE, field: kind, entry: n, reason: stale.kind === "case_twin" ? "near_miss" : stale.kind, layer } });
|
|
87
|
+
continue;
|
|
87
88
|
}
|
|
88
89
|
if (known.has(n))
|
|
89
90
|
continue;
|
|
@@ -93,6 +94,8 @@ export async function preparePolicyChain(input) {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
}
|
|
97
|
+
if (refused[0] !== undefined)
|
|
98
|
+
throw policyNameRefusal(refused[0], refused.slice(1));
|
|
96
99
|
const dedupeKey = [...unmatched].sort().join("|");
|
|
97
100
|
const advised = advisedPolicyNames.get(deps) ?? new Set();
|
|
98
101
|
if (unmatched.size > 0 && !advised.has(dedupeKey)) {
|
|
@@ -162,9 +165,9 @@ export async function preparePolicyChain(input) {
|
|
|
162
165
|
check: (creq) => checkToolPolicyProjection(entry, creq) ?? { action: "allow" },
|
|
163
166
|
}));
|
|
164
167
|
const narrowingLayers = [hostFloor !== undefined ? hostFloorPolicy(hostFloor) : undefined, sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
|
|
165
|
-
auditPolicyNames(sessionRulePolicy);
|
|
168
|
+
auditPolicyNames(sessionRulePolicy, "session_rules");
|
|
166
169
|
for (const layer of ancestorRulePolicies)
|
|
167
|
-
auditPolicyNames(layer,
|
|
170
|
+
auditPolicyNames(layer, "ancestor_session_rules");
|
|
168
171
|
const denyNarrowingPolicy = narrowingLayers.length === 0 ? undefined : narrowingLayers.length === 1 ? narrowingLayers[0] : combinePolicies(...narrowingLayers);
|
|
169
172
|
const basePolicyForResumeEdit = lockedPreflight.basePolicyForResumeEdit ?? lockedPreflight.toolPolicy;
|
|
170
173
|
const ownChainJudges = chainJudges(modBus);
|
|
@@ -316,7 +319,7 @@ export async function preparePolicyChain(input) {
|
|
|
316
319
|
};
|
|
317
320
|
};
|
|
318
321
|
const inheritedAskEvidence = inheritedAskRuleEvidence(deps.permissionRuleStore);
|
|
319
|
-
const listFacts = { root: taskRootFinal, sessionId, liveCwd: () => handsCwdRef?.current, anchors: pathRuleAnchors.leg };
|
|
322
|
+
const listFacts = { root: taskRootFinal, sessionId, liveCwd: () => handsCwdRef?.current, anchors: pathRuleAnchors.leg, classifyAllShell: classifiesAllShell(spec) };
|
|
320
323
|
const skillGrantLane = skillGrants.lane(listFacts);
|
|
321
324
|
const allowEntryLanes = { request: allowedToolTables.request.lane(listFacts), deployment: allowedToolTables.deployment.lane(listFacts) };
|
|
322
325
|
const ruleLaneFacts = {
|
|
@@ -331,7 +334,7 @@ export async function preparePolicyChain(input) {
|
|
|
331
334
|
questionToolName: ASK_USER_QUESTION_TOOL_NAME,
|
|
332
335
|
onRevisionDefect: (message) => deps.onError?.(new Error(message), { phase: "config", sessionId }),
|
|
333
336
|
onDisclosure: (message) => emitTrace(deps.tracer, () => ({ kind: "permission.rule_store_unreadable", version: 1, taskId: hostTaskId, message, ts: Date.now() })),
|
|
334
|
-
stripsAllow: (rule, req) =>
|
|
337
|
+
stripsAllow: (rule, req) => autoStrippedRule(rule, req, permissionMode.current, listFacts.classifyAllShell),
|
|
335
338
|
};
|
|
336
339
|
const { personal: permissionRuleLane, org: permissionRuleOrgLane } = createPermissionRuleLanes({ provider: deps.permissionRuleStore, localOwnerDeclared: deps.localOwnerRules === true, principal: spec.principal, ...ruleLaneFacts, rows: personRows });
|
|
337
340
|
const ruleOffersOf = createRuleOffersOf({
|
|
@@ -382,7 +385,7 @@ export async function preparePolicyChain(input) {
|
|
|
382
385
|
else if (re.action === "allow") {
|
|
383
386
|
return onApproval(withAttestation({ action: "allow", updatedInput: editArgs, decisionReason: "mode" }, re.attestation));
|
|
384
387
|
}
|
|
385
|
-
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: read.kind === "rewritten" ? undefined : ancestorAutoMode, ask: re, req:
|
|
388
|
+
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: read.kind === "rewritten" ? undefined : ancestorAutoMode, ask: re, req: withArgsBinding(creq, editArgs), signal: csignal ?? abortController.signal, subject: "the approved edit", allowRewrite: editArgs, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(ancestorDecider?.timeoutMs !== undefined ? { budgetMs: ancestorDecider.timeoutMs } : {}), route: frozenApproverRoute(onAskOf), onNotice: deps.onNotice, sessionId, runId }) });
|
|
386
389
|
if (judged.kind === "allow") {
|
|
387
390
|
return onApproval(judged.result);
|
|
388
391
|
}
|
|
@@ -439,7 +442,7 @@ export async function preparePolicyChain(input) {
|
|
|
439
442
|
return settledAs(mandateUnreconstructibleDeny(creq));
|
|
440
443
|
}
|
|
441
444
|
const presentedArgs = decision.updatedInput !== undefined ? argsAsTheToolReads(creq, decision.updatedInput) : creq.args;
|
|
442
|
-
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req:
|
|
445
|
+
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: withArgsBinding(creq, presentedArgs), signal: csignal ?? abortController.signal, subject: "this call", allowRewrite: decision.updatedInput, facts: inheritedStationFacts(creq), unavailableSeat: classifierUnavailableSeat({ station: "ancestor", ...(pc.autoMode?.decider.timeoutMs !== undefined ? { budgetMs: pc.autoMode.decider.timeoutMs } : {}), route: frozenApproverRoute(pc.onAsk), onNotice: deps.onNotice, sessionId, runId }) });
|
|
443
446
|
if (judged.kind === "allow")
|
|
444
447
|
return settledAs(judged.result);
|
|
445
448
|
if (judged.kind === "deny")
|
|
@@ -609,7 +612,7 @@ export async function preparePolicyChain(input) {
|
|
|
609
612
|
}
|
|
610
613
|
return d;
|
|
611
614
|
}));
|
|
612
|
-
const modeGateLayer = createModeGatePolicy(permissionMode, { env: executionEnv, rootPath: taskRootFinal, acceptDirs: [
|
|
615
|
+
const modeGateLayer = createModeGatePolicy(permissionMode, { env: executionEnv, rootPath: taskRootFinal, acceptDirs: () => [writeLocation(), ...additionalRootsCanonical], roster: toolRosterDeltas, readOnlyDeclared: (name) => mountedToolDeclaresReadOnly(tools, name) });
|
|
613
616
|
const policyLayers = [...narrowingLayers, ...instrumentedChain, ...(rewriteCapableChain.length > 0 ? narrowingLayers : [])];
|
|
614
617
|
const integrityGuardLayers = [createTranscriptIntegrityPolicy(), createUnverifiableDeletePolicy({ removalSeat: { env: executionEnv, additionalRoots: () => additionalRootsCanonical } })];
|
|
615
618
|
const guardedPolicyLayers = [...integrityGuardLayers, ...policyLayers, modeGateLayer];
|
|
@@ -14,8 +14,8 @@ export interface PrepareProjectContextInput {
|
|
|
14
14
|
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `sessionId` (phase derivation + the
|
|
15
15
|
* continuation projections), `skills` (the roster), `userInvokedSkills` (the person's invoked skills — their
|
|
16
16
|
* rows are written here), `principal` (the shared-memory tools' trusted identity), `projectMemory` (the request's
|
|
17
|
-
* off switch for the seam — the config door's one reading). Never mutated. */
|
|
18
|
-
spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal" | "excludeAllTools" | "projectMemory">;
|
|
17
|
+
* off switch for the seam — the config door's one reading), `classifyAllShell` (the Skill card's auto strip). Never mutated. */
|
|
18
|
+
spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal" | "excludeAllTools" | "projectMemory" | "classifyAllShell">;
|
|
19
19
|
/** borrowed-readonly — trusted internals: `agentName` (seam ctx), `inheritedSkillGrants` (the parent's captured
|
|
20
20
|
* skill grant rows, seeded as `inherited`), `inheritedAllowedTools` (the parent's request entries, seeded as this leg's
|
|
21
21
|
* own). `undefined` on a standalone prepare. */
|
|
@@ -6,7 +6,7 @@ import { createSharedMemoryTools } from "../shared-memory/tools.js";
|
|
|
6
6
|
import { SHARED_MEMORY_TOOL_NAMES } from "../shared-memory/types.js";
|
|
7
7
|
import { defineTool } from "../tools.js";
|
|
8
8
|
import { readFrozenSkillGrants, seedSkillGrants, skillSeatReader } from "../skill-grant.js";
|
|
9
|
-
import { allowedToolsNotGrantedNotice, seedAllowEntryTables } from "../allow-entry.js";
|
|
9
|
+
import { allowedToolsNotGrantedNotice, classifiesAllShell, seedAllowEntryTables } from "../allow-entry.js";
|
|
10
10
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
11
11
|
import { announceMemoryNotMounted } from "./announce-once-ledger.js";
|
|
12
12
|
import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, createSkillTool, normalizeSkills } from "./synthetic-tools.js";
|
|
@@ -110,7 +110,7 @@ export async function prepareProjectContext(input) {
|
|
|
110
110
|
}
|
|
111
111
|
roster.mount(createSkillTool(skillSpecs, skillGrants), { source: "builtin", mountedBy: "optional" });
|
|
112
112
|
}
|
|
113
|
-
const skillSeatOf = skillSeatReader(skillSpecs, mounted);
|
|
113
|
+
const skillSeatOf = skillSeatReader(skillSpecs, classifiesAllShell(spec), mounted);
|
|
114
114
|
const sharedMemoryProvider = deps.sharedMemoryStores;
|
|
115
115
|
let sharedMemoryPairMounted = false;
|
|
116
116
|
if (sharedMemoryProvider !== undefined) {
|
|
@@ -55,7 +55,7 @@ export interface PreparePromptInputsInput {
|
|
|
55
55
|
* workflow tool): drives the orchestration prompt flags. */
|
|
56
56
|
selfOrchestrationActive: boolean;
|
|
57
57
|
/** borrowed-readonly — the task's execution env: `isIsolated` for the isolation flag, `exec` for the
|
|
58
|
-
* one batched probe
|
|
58
|
+
* one batched probe (which also carries the cwd-alignment question). Never re-bound, never destroyed here. */
|
|
59
59
|
executionEnv: ExecutionEnv;
|
|
60
60
|
/** borrowed-readonly — the session's reminder mark (rides the prompt facts for the declaration). */
|
|
61
61
|
reminderMark: string;
|
|
@@ -6,6 +6,7 @@ import { isIsolated } from "../remote-env.js";
|
|
|
6
6
|
import { readDateAnchor } from "./conversation-segment.js";
|
|
7
7
|
import { probeGitStatusLane } from "./git-status-frame.js";
|
|
8
8
|
import { renderMcpInstructionsEntry } from "./turn-attachments.js";
|
|
9
|
+
import { cwdAlignmentProbe, cwdMisalignmentMessage, readCwdAlignment } from "./cwd-alignment-probe.js";
|
|
9
10
|
const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
|
|
10
11
|
import { compactionEnabled } from "../context-settings.js";
|
|
11
12
|
export async function preparePromptInputs(input) {
|
|
@@ -83,7 +84,7 @@ export async function preparePromptInputs(input) {
|
|
|
83
84
|
envFacts.additionalReadDirectories = [...additionalReadRootsCanonical];
|
|
84
85
|
}
|
|
85
86
|
try {
|
|
86
|
-
const probe = await executionEnv.exec('uname -s; uname -r; (git rev-parse --is-inside-work-tree 2>/dev/null || echo false); (git symbolic-ref --short -q HEAD 2>/dev/null || echo "HEAD (detached)"); (git rev-parse --show-toplevel 2>/dev/null || echo); (test -n "$(git status --porcelain 2>/dev/null | head -1)" && echo dirty || echo clean); (s=$(ps -p $$ -o comm= 2>/dev/null); s=${s##*/}; echo "${s#-}"); (test "$(git rev-parse --git-dir 2>/dev/null)" != "$(git rev-parse --git-common-dir 2>/dev/null)" && echo linked || echo main);
|
|
87
|
+
const probe = await executionEnv.exec('uname -s; uname -r; (git rev-parse --is-inside-work-tree 2>/dev/null || echo false); (git symbolic-ref --short -q HEAD 2>/dev/null || echo "HEAD (detached)"); (git rev-parse --show-toplevel 2>/dev/null || echo); (test -n "$(git status --porcelain 2>/dev/null | head -1)" && echo dirty || echo clean); (s=$(ps -p $$ -o comm= 2>/dev/null); s=${s##*/}; echo "${s#-}"); (test "$(git rev-parse --git-dir 2>/dev/null)" != "$(git rev-parse --git-common-dir 2>/dev/null)" && echo linked || echo main); ' + cwdAlignmentProbe(taskRootFinal), { cwd: envFacts.cwd, timeout: 10 });
|
|
87
88
|
if (probe.ok && probe.value.exitCode === 0) {
|
|
88
89
|
const lines = probe.value.stdout.split("\n");
|
|
89
90
|
if (lines.length >= 6) {
|
|
@@ -109,24 +110,12 @@ export async function preparePromptInputs(input) {
|
|
|
109
110
|
envFacts.shell = sh;
|
|
110
111
|
if (envFacts.isGitRepo && (lines[7] ?? "").trim() === "linked")
|
|
111
112
|
envFacts.isLinkedWorktree = true;
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
return p;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const canonicalProbed = await canonOf(probedPwd);
|
|
124
|
-
if (canonicalProbed !== (await canonOf(envFacts.cwd))) {
|
|
125
|
-
try {
|
|
126
|
-
deps.onError?.(new Error(`execution-env cwd misalignment: task root is "${envFacts.cwd}" but the env's shell reports pwd "${canonicalProbed}" — per-exec cwd injection may be ignored on this lane (execs/artifacts can land outside the workspace root)`), { phase: "config", sessionId });
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
}
|
|
113
|
+
const alignment = readCwdAlignment(lines);
|
|
114
|
+
if (alignment?.verdict === "differ") {
|
|
115
|
+
try {
|
|
116
|
+
deps.onError?.(new Error(cwdMisalignmentMessage(taskRootFinal, alignment.shellPwd)), { phase: "config", sessionId });
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
130
119
|
}
|
|
131
120
|
}
|
|
132
121
|
}
|
|
@@ -44,8 +44,8 @@ export interface PrepareProtocolToolsInput {
|
|
|
44
44
|
spec: Pick<TaskSpec, "principal" | "tools" | "excludeAllTools" | "signal">;
|
|
45
45
|
/** borrowed-readonly — the deployment seats the materializers and their operator faces read: `onElicit`
|
|
46
46
|
* and `mcpImageResizer` ride into the MCP intake; `onError` takes the A2A warnings (no ledger — a peer is
|
|
47
|
-
* re-read every prepare); `mcpRevocations` + `onNotice` make the revocation wiring. */
|
|
48
|
-
deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice">;
|
|
47
|
+
* re-read every prepare); `mcpRevocations` + `onNotice` make the revocation wiring; `peerSeat` answers what each MCP / A2A request carries. */
|
|
48
|
+
deps: Pick<RunnerDeps, "onElicit" | "mcpImageResizer" | "onError" | "mcpRevocations" | "onNotice" | "peerSeat">;
|
|
49
49
|
/** borrowed-readonly — the leg's mods bus: its `prompt.section` station disposes of each server's instructions at the dial. */
|
|
50
50
|
modBus: LegModBus;
|
|
51
51
|
/** borrowed-readonly — the run tree's MCP connection pool (the leg leases its connections from it) and whether THIS leg created it
|
|
@@ -59,6 +59,8 @@ export interface PrepareProtocolToolsInput {
|
|
|
59
59
|
/** borrowed-mutable — the reminder-disclosure counters: the MCP intake's bounding writes them here, and
|
|
60
60
|
* the run loop's attachment lanes keep writing the same object (`Prepared.reminderDisclosureCounts`). */
|
|
61
61
|
reminderDisclosureCounts: Prepared["reminderDisclosureCounts"];
|
|
62
|
+
/** borrowed-readonly — the leg's request-meta seat: every minted MCP tool reads what stands for its call, and the leg's session id (`_meta`). */
|
|
63
|
+
mcpRequestMeta: import("../mcp-call-meta.js").McpLegMetaReader;
|
|
62
64
|
/** borrowed-readonly — the run's invocation id (the revocation probe-failure notice names it). */
|
|
63
65
|
runId: string;
|
|
64
66
|
/** borrowed-readonly — the acquired session id (operator-line context). */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import {
|
|
2
|
+
import { materializeLegMcpTools } from "../mcp.js";
|
|
3
3
|
import { applyMcpRosterDelta, commitMcpRosterChanges, redialMcpServer, rosterHolding, settledOnRoster } from "./mcp-redial.js";
|
|
4
4
|
import { valveLeaves, valveLeavesPeer } from "../../agents/tool-filter.js";
|
|
5
5
|
import { resourceFacesLeft } from "../mounted-mcp.js";
|
|
6
6
|
import { materializeA2aTools } from "../a2a.js";
|
|
7
|
+
import { whereToAuthorize } from "../mcp-failure.js";
|
|
7
8
|
import { deliverEngineNotice } from "../types.js";
|
|
8
9
|
import { RosterBuilder } from "../tool-roster.js";
|
|
9
10
|
import { TOOL_WIRE_NAME_MAX_CHARS } from "../tool-face.js";
|
|
@@ -30,7 +31,7 @@ export async function prepareProtocolTools(input) {
|
|
|
30
31
|
const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
31
32
|
const resourcesReached = resourceFacesLeft(leaves);
|
|
32
33
|
const mcp = lockedPreflight.mcp?.length
|
|
33
|
-
? await
|
|
34
|
+
? await materializeLegMcpTools(input.mcpRequestMeta, lockedPreflight.mcp, spec.principal, deps.onElicit, deps.mcpImageResizer, { reminderMark, counts: reminderDisclosureCounts }, mcpRevocationWiring(deps, runId), mcpPool === undefined ? undefined : { pool: mcpPool.pool, ownsPool: mcpPool.owned }, sectionDisposerOf(input.modBus, abortController.signal), (entry) => resourcesReached || serverReached(mintNamespacePrefix(MCP_NAMESPACE, entry.name)), AbortSignal.any([abortController.signal, ...(spec.signal !== undefined ? [spec.signal] : [])]), hostFloor, deps.peerSeat, mcpAuthorizationNotice(deps, sessionId, runId, spec.principal))
|
|
34
35
|
:
|
|
35
36
|
{ tools: [], toolAxes: [], warnings: [], serverInstructions: [], instructionsDelta: { pendingAdds: [], pendingRemovals: [] }, droppedTools: [], statuses: [], refresh: async () => [], reconnect: async (server) => ({ server, prefix: mintNamespacePrefix(MCP_NAMESPACE, server), outcome: "not_declared", reason: "this task declared no MCP servers", toolCount: 0, added: [], removed: [] }), dispose: async () => { } };
|
|
36
37
|
if (lockedPreflight.mcp?.length)
|
|
@@ -167,7 +168,7 @@ export async function prepareProtocolTools(input) {
|
|
|
167
168
|
foldProtocolAxes(mcp.toolAxes, "MCP");
|
|
168
169
|
const a2aDeclared = lockedPreflight.a2a;
|
|
169
170
|
const a2a = a2aDeclared
|
|
170
|
-
? await materializeA2aTools(a2aDeclared, spec.principal, abortController.signal, hostFloor)
|
|
171
|
+
? await materializeA2aTools(a2aDeclared, spec.principal, abortController.signal, hostFloor, deps.peerSeat)
|
|
171
172
|
: { tools: [], toolAxes: [], warnings: [], statuses: [], refresh: async () => [], dispose: async () => { } };
|
|
172
173
|
if (a2aDeclared)
|
|
173
174
|
rollback.push(function a2aDispose() { return a2a.dispose(); });
|
|
@@ -187,6 +188,13 @@ export async function prepareProtocolTools(input) {
|
|
|
187
188
|
foldProtocolAxes(a2a.toolAxes, "A2A");
|
|
188
189
|
return { mcp, a2a, rebuildHarnessToolsRef, contentOriginWrapRef, toolCallGateArmedRef, ...(mcpRedial !== undefined ? { mcpRedial } : {}) };
|
|
189
190
|
}
|
|
191
|
+
function mcpAuthorizationNotice(deps, sessionId, runId, principal) {
|
|
192
|
+
return (server, { reason, authorizeUrl }) => deliverEngineNotice(deps.onNotice, {
|
|
193
|
+
code: "mcp.authorization_required",
|
|
194
|
+
message: `MCP server "${server}" needs the user's authorization before it serves them (${reason}) — authorize it ${whereToAuthorize(authorizeUrl)}; its tools are unavailable until then.`,
|
|
195
|
+
detail: { server, reason, ...(authorizeUrl !== undefined ? { authorizeUrl } : {}), ...(principal !== undefined ? { principal } : {}), sessionId, runId },
|
|
196
|
+
});
|
|
197
|
+
}
|
|
190
198
|
function mcpRevocationWiring(deps, runId) {
|
|
191
199
|
if (deps.mcpRevocations === undefined)
|
|
192
200
|
return undefined;
|
|
@@ -21,6 +21,7 @@ import { SubagentRetainLedger } from "../../agents/retain-ledger.js";
|
|
|
21
21
|
import type { TaskEvent, TaskSpec } from "../types.js";
|
|
22
22
|
import { SkillGrantTable } from "../skill-grant.js";
|
|
23
23
|
import type { Prepared, RunInternals, ToolProgressLane } from "./contracts.js";
|
|
24
|
+
import type { ReviewRequest } from "../present-plan-tool.js";
|
|
24
25
|
import type { PermissionModeController } from "../mode-policy.js";
|
|
25
26
|
import { type EditedFilesLedger } from "./edited-files-ledger.js";
|
|
26
27
|
import { type ToolOccurrenceTable } from "./tool-occurrence.js";
|
|
@@ -78,9 +79,7 @@ export interface PrepareRunRefsResult {
|
|
|
78
79
|
* `plan_review` checkpoint is minted. */
|
|
79
80
|
reviewRequestRef: Prepared["reviewRequestRef"];
|
|
80
81
|
/** owned — the ctx primitive that arms `reviewRequestRef`. */
|
|
81
|
-
requestReview: (opts?:
|
|
82
|
-
reason?: string;
|
|
83
|
-
}) => void;
|
|
82
|
+
requestReview: (opts?: ReviewRequest) => void;
|
|
84
83
|
/** borrowed-mutable — the stop-after-turn latch (`Prepared.stopRequestedRef`). Writers: `requestStopAfterTurn`
|
|
85
84
|
* here, and nothing else; the run loop reads it at a turn boundary. */
|
|
86
85
|
stopRequestedRef: Prepared["stopRequestedRef"];
|
|
@@ -30,7 +30,10 @@ export function prepareRunRefs(input) {
|
|
|
30
30
|
const reviewRequestRef = {};
|
|
31
31
|
const requestReview = (opts) => {
|
|
32
32
|
if (reviewRequestRef.pending === undefined) {
|
|
33
|
-
reviewRequestRef.pending =
|
|
33
|
+
reviewRequestRef.pending = {
|
|
34
|
+
...(opts?.reason !== undefined ? { reason: opts.reason } : {}),
|
|
35
|
+
...(opts?.requestedByCallId !== undefined ? { requestedByCallId: opts.requestedByCallId } : {}),
|
|
36
|
+
};
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
const stopRequestedRef = { current: false };
|
|
@@ -169,6 +169,8 @@ export interface PrepareSuspendSagaInput {
|
|
|
169
169
|
placementRootResolved: string;
|
|
170
170
|
/** borrowed-readonly — this leg's checkpoint scope (the driver's one `checkpointScopeOf` derivation; the row's `legScope` stamp). */
|
|
171
171
|
checkpointScope: string;
|
|
172
|
+
/** borrowed-readonly — the config doors' one reading of the leg's run origin (the row's `runOrigin` stamp; absent ⇒ the host said nothing). */
|
|
173
|
+
runOrigin: SerializedCheckpointState["runOrigin"];
|
|
172
174
|
/** borrowed-readonly — the tool-selector layers this leg was spawned under (the live seat, else the resumed row's), the row's `toolCeiling` stamp. */
|
|
173
175
|
toolCeiling: readonly import("../tool-face.js").ToolSelectorLayer[] | undefined;
|
|
174
176
|
/** borrowed-readonly — the spawning run's judgment of this leg's own lists, while it is bound to them (`boundToolListsJudgment`), the row's `toolListsJudged` stamp. */
|
|
@@ -82,7 +82,7 @@ function stampPlacementRootSessionId(placementRootResolved) {
|
|
|
82
82
|
return placementValueOrAbsent(placementRootResolved);
|
|
83
83
|
}
|
|
84
84
|
export function prepareSuspendSaga(input) {
|
|
85
|
-
const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
|
|
85
|
+
const { gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection, reminderMark, handsCwdRef, handsRoot, handsHome, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors, inheritedPathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, runOrigin, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, crossBoundary, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter } = input;
|
|
86
86
|
if (!gateMachineryActive)
|
|
87
87
|
return { saga: undefined };
|
|
88
88
|
const taskAccess = { owner: hostTaskId, scope: taskScope, sessionId };
|
|
@@ -178,6 +178,7 @@ export function prepareSuspendSaga(input) {
|
|
|
178
178
|
placementRootSessionId: stampPlacementRootSessionId(placementRootResolved),
|
|
179
179
|
externalContentTarget: externalContentTargetActive ? true : undefined,
|
|
180
180
|
legScope: checkpointScope,
|
|
181
|
+
runOrigin,
|
|
181
182
|
toolCeiling: toolCeiling !== undefined ? toolCeiling.map((l) => ({ ...(l.allow !== undefined ? { allow: persistedToolNameList(l.allow, "allowed") } : {}), deny: persistedToolNameList(l.deny, "denied") })) : undefined,
|
|
182
183
|
toolListsJudged,
|
|
183
184
|
ownToolLists: ownToolLists !== undefined ? { toolName: ownToolLists.toolName, ...(ownToolLists.definition !== undefined ? { definition: ownToolLists.definition } : {}), lists: ownToolLists.lists } : undefined,
|