@sema-agent/core 7.58.0 → 7.60.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 +1340 -0
- package/README.md +6 -4
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- 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 +9 -4
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +32 -50
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +150 -112
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/degrading.js +3 -1
- 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 +90 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- 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 +65 -6
- package/dist/brain/timeout.js +111 -11
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- 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/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +20 -6
- package/dist/core/allow-entry.js +17 -7
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +26 -4
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +66 -25
- package/dist/core/checkpoint-store.js +22 -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 +3 -3
- package/dist/core/compliance.js +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- 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 +156 -23
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +8 -6
- package/dist/core/gate-lanes.js +47 -12
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +17 -1
- package/dist/core/governance-codes.js +25 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +70 -59
- package/dist/core/hooks.js +125 -80
- package/dist/core/image-admission.d.ts +106 -52
- package/dist/core/image-admission.js +184 -56
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +59 -5
- package/dist/core/locked-config.js +82 -50
- 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 +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +122 -20
- package/dist/core/mcp-failure.js +73 -5
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +27 -12
- package/dist/core/mcp.js +105 -76
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- 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/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- 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 +3 -2
- package/dist/core/memory-engine/index.js +2 -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 +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +51 -9
- package/dist/core/memory-engine/sync-client.js +107 -13
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +8 -1
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +6 -5
- package/dist/core/mods/kernel/events.d.ts +11 -4
- package/dist/core/mods/kernel/events.js +11 -7
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +73 -60
- package/dist/core/mods/stations.js +64 -40
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- 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 +14 -8
- package/dist/core/peer-seat.d.ts +133 -16
- package/dist/core/peer-seat.js +319 -42
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +11 -6
- package/dist/core/permission-rule-model.d.ts +20 -2
- package/dist/core/permission-rule-model.js +8 -7
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +13 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +69 -3
- package/dist/core/roles.js +167 -80
- package/dist/core/rule-owner.d.ts +3 -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/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +23 -12
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +82 -57
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- 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/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +87 -11
- package/dist/core/runner/gate-exit.js +30 -8
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- 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/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +5 -5
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- 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.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +7 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +6 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +16 -9
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -3
- package/dist/core/runner/prepare-delegation-surface.js +5 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -1
- package/dist/core/runner/prepare-hands-readface.js +19 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -7
- package/dist/core/runner/prepare-inherited-gate.js +22 -31
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +12 -19
- package/dist/core/runner/prepare-park-ask.d.ts +4 -6
- package/dist/core/runner/prepare-park-ask.js +5 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -7
- package/dist/core/runner/prepare-policy-chain.js +136 -121
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +10 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -2
- package/dist/core/runner/prepare-prompt-inputs.js +10 -20
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +17 -2
- 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 +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +44 -28
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -4
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- 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 +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/retired-runner-deps.js +4 -1
- 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-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +3 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -5
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +63 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +14 -6
- 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 +89 -77
- package/dist/core/runner/runtask.d.ts +8 -5
- package/dist/core/runner/runtask.js +21 -13
- 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/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +20 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +29 -27
- package/dist/core/runner/turn-attachments.js +27 -42
- package/dist/core/runner-deps.d.ts +32 -19
- package/dist/core/secret-env.d.ts +35 -4
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +12 -3
- package/dist/core/session-policy-store.js +29 -10
- package/dist/core/session-store.d.ts +5 -7
- package/dist/core/session-store.js +50 -11
- 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 +17 -5
- package/dist/core/skill-grant.js +24 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +50 -10
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +146 -17
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +19 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +43 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +15 -7
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +21 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +23 -5
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +15 -7
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +11 -5
- package/dist/engine/execution-env/node-execution-env.js +21 -13
- package/dist/engine/harness/agent-harness.d.ts +26 -3
- package/dist/engine/harness/agent-harness.js +49 -16
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +119 -28
- 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 +18 -7
- package/dist/engine/loop/agent-loop.d.ts +20 -12
- package/dist/engine/loop/agent-loop.js +205 -36
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- 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/storage-base.js +4 -21
- package/dist/index.d.ts +35 -21
- package/dist/index.js +26 -17
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- 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.d.ts +4 -0
- package/dist/orchestration/workflow.js +762 -491
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- 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/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +9 -11
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +14 -4
- package/dist/tools/fs/fs-bash.js +29 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +13 -5
- 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 +62 -0
- package/dist/tools/fs/read-floor.js +58 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- 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 +9 -4
- package/dist/tools/monitor.js +17 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +161 -21
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
|
@@ -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";
|
|
@@ -29,7 +30,7 @@ const wordlessDemand = (toolName) => {
|
|
|
29
30
|
throw new Error(`a real-approval demand for "${toolName}" reached the park with no origin word — the origin stamp precedes every park`);
|
|
30
31
|
};
|
|
31
32
|
export function prepareParkAsk(input) {
|
|
32
|
-
const { askLane, saga, spec, deps, sessionId, checkpointStore, checkpointScope, toolRosterDeltas, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots, offloadStore,
|
|
33
|
+
const { askLane, saga, spec, deps, sessionId, checkpointStore, checkpointScope, toolRosterDeltas, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots, offloadStore, suspendTargetGap, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef } = input;
|
|
33
34
|
if (askLane === undefined || saga === undefined)
|
|
34
35
|
return { parkAsk: undefined };
|
|
35
36
|
const { composedCallSignal, approvalPreviewOf } = askLane;
|
|
@@ -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);
|
|
@@ -196,13 +197,8 @@ export function prepareParkAsk(input) {
|
|
|
196
197
|
"holds offloaded results that are lost across a cross-replica resume); inject " +
|
|
197
198
|
"RunnerDeps.toolResultStore or disable offload.");
|
|
198
199
|
}
|
|
199
|
-
if (
|
|
200
|
-
throw new ParkRefusal(
|
|
201
|
-
? `durable suspend is not supported with this per-task executionEnvFactory env: it declares capabilities.suspendable but its adapter does not implement ${incompleteSuspendAdapter.join(" or ")}, so a snapshot taken now could never be restored. Implement the full RemoteExecutionEnv restore surface, or declare capabilities.suspendable:false if the workspace is externally durable (the park-only lane).`
|
|
202
|
-
: "durable suspend is not supported with a non-remote per-task executionEnvFactory env: the " +
|
|
203
|
-
"minted env is destroyed on suspend, so a resumed file/shell tool would act on a fresh " +
|
|
204
|
-
"(empty) env. Use a RemoteExecutionEnv factory (it is paused, not destroyed) or a static, " +
|
|
205
|
-
"caller-owned RunnerDeps.executionEnv.");
|
|
200
|
+
if (suspendTargetGap !== undefined) {
|
|
201
|
+
throw new ParkRefusal(`durable suspend is not supported with this per-task executionEnvFactory env: it ${suspendTargetGap}, so no resumable checkpoint can be taken. Use a RemoteExecutionEnv factory that declares capabilities.suspendable — true with the full restore surface, or false if the workspace is externally durable (the park-only lane) — or a static, caller-owned RunnerDeps.executionEnv.`);
|
|
206
202
|
}
|
|
207
203
|
const leafId = await session.getLeafId();
|
|
208
204
|
if (!leafId) {
|
|
@@ -23,7 +23,7 @@ import type { AgentTool } from "../../internal/harness.js";
|
|
|
23
23
|
import type { ExecutionEnv } from "../../internal/harness.js";
|
|
24
24
|
import { type AskClass } from "../ask-class.js";
|
|
25
25
|
import type { AutoModeDecider } from "../auto-mode.js";
|
|
26
|
-
import { type
|
|
26
|
+
import { type InheritedInstallation, type LegModBus, type ModChainLink } from "../mods/stations.js";
|
|
27
27
|
import type { LockedPreflight } from "../locked-config.js";
|
|
28
28
|
import { type SessionPermissionRules } from "../session-policy-store.js";
|
|
29
29
|
import { type OnAsk, type ToolPolicy } from "../tool-policy.js";
|
|
@@ -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;
|
|
@@ -210,9 +210,10 @@ export interface PreparePolicyChainResult {
|
|
|
210
210
|
/** borrowed-mutable — the inherited-unavailable marker channel. Writers: the inherited arms here (mark); the gate station
|
|
211
211
|
* (the lifecycle-end sweep) and the park lane's consumers (delete on consumption). */
|
|
212
212
|
inheritedUnavailableAsks: Set<string>;
|
|
213
|
-
/** owned — the inherited installations THIS leg's gate
|
|
214
|
-
* leg's own gate does not stand in for
|
|
215
|
-
|
|
213
|
+
/** owned — the inherited installations THIS leg's gate judges its calls on after its own bus (`classic.PreToolUse` at phase 1,
|
|
214
|
+
* `tool.check` at the verdict read; every screening entry the leg's own gate does not stand in for), each with the environment
|
|
215
|
+
* face it was installed against and the settlement its question takes. */
|
|
216
|
+
inheritedInstallations: readonly InheritedInstallation[];
|
|
216
217
|
/** owned — the inherited stations' MODE ARBITRATIONS by tool call (a release or a refusal made inside the fold,
|
|
217
218
|
* where an ancestor's ask is arbitrated before its frozen approver). Writers: the three inherited stations here; the gate's
|
|
218
219
|
* exit reads it onto the disposition and the gate station deletes it at the call's end. */
|
|
@@ -4,7 +4,8 @@ import { policyAskClassOf } from "../ask-class.js";
|
|
|
4
4
|
import { ASK_USER_QUESTION_TOOL_NAME, isEngineQuestionFace } from "../ask-question.js";
|
|
5
5
|
import { classifierUnavailableSeat } from "./classifier-ladder.js";
|
|
6
6
|
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
7
|
-
import { chainJudges,
|
|
7
|
+
import { chainJudges, inheritedInstallations, standsInFor } from "../mods/stations.js";
|
|
8
|
+
import { createHookEnvCapabilities } from "../hooks.js";
|
|
8
9
|
import { isCoveringRuleName, ruleNameCovers } from "../namespaced-rule-name.js";
|
|
9
10
|
import { isIsolated } from "../remote-env.js";
|
|
10
11
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
@@ -15,10 +16,11 @@ import { approvalCardMemberOf } from "../tool-roster.js";
|
|
|
15
16
|
import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
|
|
16
17
|
import { emitTrace } from "../trace.js";
|
|
17
18
|
import { skillGrantBindingMembers } from "../skill-grant.js";
|
|
19
|
+
import { withArgsBinding } from "../skill-grant-binding.js";
|
|
18
20
|
import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
|
|
19
|
-
import { delegationPoolReading } from "./sub-agent-deny-lists.js";
|
|
21
|
+
import { delegationPoolReading, policyNameRefusal, POLICY_NAME_REFUSAL_CODE } from "./sub-agent-deny-lists.js";
|
|
20
22
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
21
|
-
import { autoStrippedRule, cardDisclosureOf, rootFacingToolNames } from "../allow-entry.js";
|
|
23
|
+
import { autoStrippedRule, cardDisclosureOf, classifiesAllShell, rootFacingToolNames } from "../allow-entry.js";
|
|
22
24
|
import { arbitrateByMode, askClassMembersOf, askFaceOf, askMandateMember } from "../ask-origin.js";
|
|
23
25
|
import { createModeGatePolicy, mountedToolDeclaresReadOnly } from "../mode-policy.js";
|
|
24
26
|
const ancestorFacts = (ask) => ({ ...(ask ?? {}), ancestorResolved: true });
|
|
@@ -44,7 +46,8 @@ export async function preparePolicyChain(input) {
|
|
|
44
46
|
return { action: "deny", message: `refused by the ${verdict.mode} permission mode at an inherited ancestor layer (${verdict.askClass})`, decisionReason: "mode" };
|
|
45
47
|
};
|
|
46
48
|
const policy = lockedPreflight.toolPolicy;
|
|
47
|
-
const auditPolicyNames = (auditee,
|
|
49
|
+
const auditPolicyNames = (auditee, layer = "caller_policy") => {
|
|
50
|
+
const refused = [];
|
|
48
51
|
const nameGroups = toolPolicyNameSets(auditee);
|
|
49
52
|
if (nameGroups.length > 0) {
|
|
50
53
|
const known = mountedToolNames(tools);
|
|
@@ -58,8 +61,16 @@ export async function preparePolicyChain(input) {
|
|
|
58
61
|
for (const [kind, list] of [["deny", g.deny], ["ask", g.ask], ["allow", g.allow]]) {
|
|
59
62
|
for (const n of list ?? []) {
|
|
60
63
|
const verdict = judgeRuleToolName(n, known, kind);
|
|
61
|
-
const twin = verdict.kind === "current" &&
|
|
64
|
+
const twin = verdict.kind === "current" && layer !== "ancestor_session_rules" ? nearMissSpellingOf(n, rootFacing) : undefined;
|
|
62
65
|
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;
|
|
66
|
+
if (stale?.kind === "retired" && kind === "allow") {
|
|
67
|
+
unmatched.add(`"${n}" (allow — a retired tool name: ${stale.guidance})`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (stale?.kind === "unmintable_segment" && stale.ambiguous === true && kind === "allow") {
|
|
71
|
+
unmatched.add(`"${n}" (allow — ${stale.guidance}${stale.currentName !== undefined ? ` Write "${stale.currentName}".` : ""})`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
63
74
|
if (stale !== undefined) {
|
|
64
75
|
const entry = `tool policy ${kind}-list entry "${n}"`;
|
|
65
76
|
let message;
|
|
@@ -81,9 +92,8 @@ export async function preparePolicyChain(input) {
|
|
|
81
92
|
return exhaustive;
|
|
82
93
|
}
|
|
83
94
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
throw err;
|
|
95
|
+
refused.push({ message, problem: { code: POLICY_NAME_REFUSAL_CODE, field: kind, entry: n, reason: stale.kind === "case_twin" ? "near_miss" : stale.kind, layer } });
|
|
96
|
+
continue;
|
|
87
97
|
}
|
|
88
98
|
if (known.has(n))
|
|
89
99
|
continue;
|
|
@@ -93,6 +103,8 @@ export async function preparePolicyChain(input) {
|
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
}
|
|
106
|
+
if (refused[0] !== undefined)
|
|
107
|
+
throw policyNameRefusal(refused[0], refused.slice(1));
|
|
96
108
|
const dedupeKey = [...unmatched].sort().join("|");
|
|
97
109
|
const advised = advisedPolicyNames.get(deps) ?? new Set();
|
|
98
110
|
if (unmatched.size > 0 && !advised.has(dedupeKey)) {
|
|
@@ -162,9 +174,9 @@ export async function preparePolicyChain(input) {
|
|
|
162
174
|
check: (creq) => checkToolPolicyProjection(entry, creq) ?? { action: "allow" },
|
|
163
175
|
}));
|
|
164
176
|
const narrowingLayers = [hostFloor !== undefined ? hostFloorPolicy(hostFloor) : undefined, sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
|
|
165
|
-
auditPolicyNames(sessionRulePolicy);
|
|
177
|
+
auditPolicyNames(sessionRulePolicy, "session_rules");
|
|
166
178
|
for (const layer of ancestorRulePolicies)
|
|
167
|
-
auditPolicyNames(layer,
|
|
179
|
+
auditPolicyNames(layer, "ancestor_session_rules");
|
|
168
180
|
const denyNarrowingPolicy = narrowingLayers.length === 0 ? undefined : narrowingLayers.length === 1 ? narrowingLayers[0] : combinePolicies(...narrowingLayers);
|
|
169
181
|
const basePolicyForResumeEdit = lockedPreflight.basePolicyForResumeEdit ?? lockedPreflight.toolPolicy;
|
|
170
182
|
const ownChainJudges = chainJudges(modBus);
|
|
@@ -316,7 +328,7 @@ export async function preparePolicyChain(input) {
|
|
|
316
328
|
};
|
|
317
329
|
};
|
|
318
330
|
const inheritedAskEvidence = inheritedAskRuleEvidence(deps.permissionRuleStore);
|
|
319
|
-
const listFacts = { root: taskRootFinal, sessionId, liveCwd: () => handsCwdRef?.current, anchors: pathRuleAnchors.leg };
|
|
331
|
+
const listFacts = { root: taskRootFinal, sessionId, liveCwd: () => handsCwdRef?.current, anchors: pathRuleAnchors.leg, classifyAllShell: classifiesAllShell(spec) };
|
|
320
332
|
const skillGrantLane = skillGrants.lane(listFacts);
|
|
321
333
|
const allowEntryLanes = { request: allowedToolTables.request.lane(listFacts), deployment: allowedToolTables.deployment.lane(listFacts) };
|
|
322
334
|
const ruleLaneFacts = {
|
|
@@ -331,7 +343,7 @@ export async function preparePolicyChain(input) {
|
|
|
331
343
|
questionToolName: ASK_USER_QUESTION_TOOL_NAME,
|
|
332
344
|
onRevisionDefect: (message) => deps.onError?.(new Error(message), { phase: "config", sessionId }),
|
|
333
345
|
onDisclosure: (message) => emitTrace(deps.tracer, () => ({ kind: "permission.rule_store_unreadable", version: 1, taskId: hostTaskId, message, ts: Date.now() })),
|
|
334
|
-
stripsAllow: (rule, req) =>
|
|
346
|
+
stripsAllow: (rule, req) => autoStrippedRule(rule, req, permissionMode.current, listFacts.classifyAllShell),
|
|
335
347
|
};
|
|
336
348
|
const { personal: permissionRuleLane, org: permissionRuleOrgLane } = createPermissionRuleLanes({ provider: deps.permissionRuleStore, localOwnerDeclared: deps.localOwnerRules === true, principal: spec.principal, ...ruleLaneFacts, rows: personRows });
|
|
337
349
|
const ruleOffersOf = createRuleOffersOf({
|
|
@@ -382,7 +394,7 @@ export async function preparePolicyChain(input) {
|
|
|
382
394
|
else if (re.action === "allow") {
|
|
383
395
|
return onApproval(withAttestation({ action: "allow", updatedInput: editArgs, decisionReason: "mode" }, re.attestation));
|
|
384
396
|
}
|
|
385
|
-
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: read.kind === "rewritten" ? undefined : ancestorAutoMode, ask: re, req:
|
|
397
|
+
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
398
|
if (judged.kind === "allow") {
|
|
387
399
|
return onApproval(judged.result);
|
|
388
400
|
}
|
|
@@ -439,13 +451,13 @@ export async function preparePolicyChain(input) {
|
|
|
439
451
|
return settledAs(mandateUnreconstructibleDeny(creq));
|
|
440
452
|
}
|
|
441
453
|
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:
|
|
454
|
+
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
455
|
if (judged.kind === "allow")
|
|
444
456
|
return settledAs(judged.result);
|
|
445
457
|
if (judged.kind === "deny")
|
|
446
458
|
return settledAs(judged.result);
|
|
447
459
|
const { ask: inheritedAsk, fallback } = judged;
|
|
448
|
-
if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
|
|
460
|
+
if (fallback === undefined && sandboxAdmissionArmed && pc.policy !== undefined && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
|
|
449
461
|
recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
|
|
450
462
|
return settledAs(decision.updatedInput !== undefined ? { action: "allow", updatedInput: decision.updatedInput, decisionReason: "sandbox" } : { action: "allow", decisionReason: "sandbox" });
|
|
451
463
|
}
|
|
@@ -481,119 +493,122 @@ export async function preparePolicyChain(input) {
|
|
|
481
493
|
return { kind: "approved", resolved, askWaitMs, classes: askClassMembersOf(judged.classification).classes };
|
|
482
494
|
};
|
|
483
495
|
const legStandsIn = (pc) => standsInFor(pc, { chain: ownModChain, onAsk: frozenOnAsk, hookEnv: hookEnvSource, decider: autoModeDecider() }, ownChainJudges);
|
|
484
|
-
const parentConstraintWrappers = (inheritedParentConstraints ?? []).
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
action: "
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (isDelegatedQuestion(creq)) {
|
|
508
|
-
if (pc.contentMandate !== true || markInheritedUnavailable(creq.toolCallId))
|
|
496
|
+
const parentConstraintWrappers = (inheritedParentConstraints ?? []).flatMap((pc) => {
|
|
497
|
+
const ancestorPolicy = pc.policy;
|
|
498
|
+
if (ancestorPolicy === undefined)
|
|
499
|
+
return [];
|
|
500
|
+
return [
|
|
501
|
+
policy !== undefined && ancestorPolicy === policy
|
|
502
|
+
? {
|
|
503
|
+
check: async function arbitrate(creq, csignal) {
|
|
504
|
+
const recorded = sharedFirstDecision.get(creq.toolCallId);
|
|
505
|
+
const first = recorded?.decision;
|
|
506
|
+
const stale = recorded !== undefined && !sameBytes(creq, recorded.decision.updatedInput !== undefined ? recorded.decision.updatedInput : recorded.judged, creq.args);
|
|
507
|
+
if (recorded !== undefined)
|
|
508
|
+
noteArbitration(creq.toolCallId, arbitrate, stale);
|
|
509
|
+
if (stale)
|
|
510
|
+
return { action: "allow" };
|
|
511
|
+
if (first === undefined) {
|
|
512
|
+
return {
|
|
513
|
+
action: "deny",
|
|
514
|
+
message: `inherited parent policy could not be arbitrated for "${creq.toolName}" ` +
|
|
515
|
+
`(shared-instance first decision unavailable); denied fail-closed`,
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
if (first.action === "deny")
|
|
509
519
|
return first;
|
|
520
|
+
if (first.action === "allow")
|
|
521
|
+
return { action: "allow" };
|
|
522
|
+
if (isDelegatedQuestion(creq)) {
|
|
523
|
+
if (pc.contentMandate !== true || markInheritedUnavailable(creq.toolCallId))
|
|
524
|
+
return first;
|
|
525
|
+
return {
|
|
526
|
+
action: "deny",
|
|
527
|
+
message: `inherited parent policy requires durable handling of the question raised for "${creq.toolName}" and the marker channel is at capacity — ` +
|
|
528
|
+
`denied fail-closed (tighten-only)`,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
if (pc.durableMandate === true) {
|
|
532
|
+
if (mandatedCallFloats(creq.toolCallId))
|
|
533
|
+
return first;
|
|
534
|
+
return mandateUnreconstructibleDeny(creq);
|
|
535
|
+
}
|
|
536
|
+
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: first, req: creq, signal: csignal ?? abortController.signal, subject: "this call", 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 }) });
|
|
537
|
+
if (judged.kind === "allow")
|
|
538
|
+
return judged.result;
|
|
539
|
+
if (judged.kind === "deny")
|
|
540
|
+
return judged.result;
|
|
541
|
+
const { ask: inheritedAsk, fallback } = judged;
|
|
542
|
+
if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(ancestorPolicy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
|
|
543
|
+
recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
|
|
544
|
+
return { action: "allow", decisionReason: "sandbox" };
|
|
545
|
+
}
|
|
546
|
+
const arbitrated = arbitrateInherited(inheritedAsk, creq.toolCallId, judged);
|
|
547
|
+
if (arbitrated !== undefined)
|
|
548
|
+
return arbitrated;
|
|
549
|
+
const presentedArgs = creq.args;
|
|
550
|
+
const askT0 = now();
|
|
551
|
+
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
|
|
552
|
+
toolName: creq.toolName,
|
|
553
|
+
toolCallId: creq.toolCallId,
|
|
554
|
+
args: presentedArgs,
|
|
555
|
+
...ruleOffersOf(creq, presentedArgs, ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
556
|
+
...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
|
|
557
|
+
...askSourceIdentity(),
|
|
558
|
+
...riskAxesOf(creq),
|
|
559
|
+
...approvalCardMemberOf(creq),
|
|
560
|
+
...grantBindingOf(creq, presentedArgs),
|
|
561
|
+
...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
562
|
+
...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
563
|
+
...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
|
|
564
|
+
ruleEvidence: inheritedAskEvidence,
|
|
565
|
+
}, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
|
|
566
|
+
void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
|
|
567
|
+
const askWaitMs = Math.max(0, now() - askT0);
|
|
568
|
+
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
569
|
+
if (markInheritedUnavailable(creq.toolCallId))
|
|
570
|
+
return settled.ask;
|
|
571
|
+
return markerChannelFullDeny(creq);
|
|
572
|
+
}
|
|
573
|
+
settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
574
|
+
if (resolved.action !== "allow")
|
|
575
|
+
return resolved;
|
|
576
|
+
if (resolved.updatedInput !== undefined) {
|
|
577
|
+
return recheckApprovedEdit(ancestorPolicy, pc.onAsk, creq, resolved.updatedInput, resolved, csignal, pc.autoMode);
|
|
578
|
+
}
|
|
579
|
+
recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, askWaitMs, resolved, askClassMembersOf(settled.classification).classes);
|
|
580
|
+
return { action: "allow", decisionReason: "mode" };
|
|
581
|
+
},
|
|
582
|
+
}
|
|
583
|
+
: wrapToolPolicy(ancestorPolicy, async (creq, csignal) => {
|
|
584
|
+
let decision;
|
|
585
|
+
try {
|
|
586
|
+
decision = refuseOutOfContractDecision(await ancestorPolicy.check(creq, csignal ?? abortController.signal), { call: creq });
|
|
587
|
+
}
|
|
588
|
+
catch (err) {
|
|
589
|
+
reportPolicyThrow(notifyOwnHookCrash, "an inherited parent policy", creq, err, csignal ?? abortController.signal);
|
|
510
590
|
return {
|
|
511
591
|
action: "deny",
|
|
512
|
-
message: `inherited parent policy
|
|
513
|
-
`denied fail-closed (tighten-only)`,
|
|
592
|
+
message: `inherited parent policy errored for "${creq.toolName}": ${policyThrowLine(err)}`,
|
|
514
593
|
};
|
|
515
594
|
}
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
if (judged.kind === "allow")
|
|
523
|
-
return judged.result;
|
|
524
|
-
if (judged.kind === "deny")
|
|
525
|
-
return judged.result;
|
|
526
|
-
const { ask: inheritedAsk, fallback } = judged;
|
|
527
|
-
if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
|
|
528
|
-
recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
|
|
529
|
-
return { action: "allow", decisionReason: "sandbox" };
|
|
530
|
-
}
|
|
531
|
-
const arbitrated = arbitrateInherited(inheritedAsk, creq.toolCallId, judged);
|
|
532
|
-
if (arbitrated !== undefined)
|
|
533
|
-
return arbitrated;
|
|
534
|
-
const presentedArgs = creq.args;
|
|
535
|
-
const askT0 = now();
|
|
536
|
-
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
|
|
537
|
-
toolName: creq.toolName,
|
|
538
|
-
toolCallId: creq.toolCallId,
|
|
539
|
-
args: presentedArgs,
|
|
540
|
-
...ruleOffersOf(creq, presentedArgs, ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
541
|
-
...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
|
|
542
|
-
...askSourceIdentity(),
|
|
543
|
-
...riskAxesOf(creq),
|
|
544
|
-
...approvalCardMemberOf(creq),
|
|
545
|
-
...grantBindingOf(creq, presentedArgs),
|
|
546
|
-
...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
547
|
-
...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
548
|
-
...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
|
|
549
|
-
ruleEvidence: inheritedAskEvidence,
|
|
550
|
-
}, pc.onAsk, csignal ?? abortController.signal, lateAskSettlementObserver({ toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice, onError: deps.onError })), pc.autoMode?.denialTracking, creq, inheritedStationFacts(creq));
|
|
551
|
-
void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
|
|
552
|
-
const askWaitMs = Math.max(0, now() - askT0);
|
|
553
|
-
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
554
|
-
if (markInheritedUnavailable(creq.toolCallId))
|
|
555
|
-
return settled.ask;
|
|
556
|
-
return markerChannelFullDeny(creq);
|
|
557
|
-
}
|
|
558
|
-
settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
559
|
-
if (resolved.action !== "allow")
|
|
560
|
-
return resolved;
|
|
595
|
+
if (decision.action !== "ask")
|
|
596
|
+
return decision;
|
|
597
|
+
const settled = await settleInstallationAsk(pc, decision, creq, csignal);
|
|
598
|
+
if (settled.kind === "settled")
|
|
599
|
+
return settled.result;
|
|
600
|
+
const { resolved } = settled;
|
|
561
601
|
if (resolved.updatedInput !== undefined) {
|
|
562
|
-
return recheckApprovedEdit(
|
|
602
|
+
return recheckApprovedEdit(ancestorPolicy, pc.onAsk, creq, resolved.updatedInput, resolved, csignal, pc.autoMode);
|
|
563
603
|
}
|
|
564
|
-
recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, askWaitMs, resolved, askClassMembersOf(settled.classification).classes);
|
|
565
|
-
return { action: "allow", decisionReason: "mode" };
|
|
566
|
-
},
|
|
567
|
-
}
|
|
568
|
-
: wrapToolPolicy(pc.policy, async (creq, csignal) => {
|
|
569
|
-
let decision;
|
|
570
|
-
try {
|
|
571
|
-
decision = refuseOutOfContractDecision(await pc.policy.check(creq, csignal ?? abortController.signal), { call: creq });
|
|
572
|
-
}
|
|
573
|
-
catch (err) {
|
|
574
|
-
reportPolicyThrow(notifyOwnHookCrash, "an inherited parent policy", creq, err, csignal ?? abortController.signal);
|
|
575
|
-
return {
|
|
576
|
-
action: "deny",
|
|
577
|
-
message: `inherited parent policy errored for "${creq.toolName}": ${policyThrowLine(err)}`,
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
if (decision.action !== "ask")
|
|
581
|
-
return decision;
|
|
582
|
-
const settled = await settleInstallationAsk(pc, decision, creq, csignal);
|
|
583
|
-
if (settled.kind === "settled")
|
|
584
|
-
return settled.result;
|
|
585
|
-
const { resolved } = settled;
|
|
586
|
-
if (resolved.updatedInput !== undefined) {
|
|
587
|
-
return recheckApprovedEdit(pc.policy, pc.onAsk, creq, resolved.updatedInput, resolved, csignal, pc.autoMode);
|
|
588
|
-
}
|
|
589
|
-
if (screeningInstallationsOf([pc]).length === 0) {
|
|
590
604
|
recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, settled.askWaitMs, resolved, settled.classes);
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return resolved;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
605
|
+
if (decision.updatedInput === undefined)
|
|
606
|
+
return resolved;
|
|
607
|
+
return { ...resolved, updatedInput: decision.updatedInput };
|
|
608
|
+
}),
|
|
609
|
+
];
|
|
610
|
+
});
|
|
611
|
+
const installationsOnLeg = inheritedInstallations(inheritedParentConstraints ?? [], legStandsIn, (pc) => (typeof pc.hookEnv === "object" && pc.hookEnv !== null ? createHookEnvCapabilities(pc.hookEnv) : undefined), (pc) => async (ask, creq, csignal) => {
|
|
597
612
|
const settled = await settleInstallationAsk(pc, ask, creq, csignal);
|
|
598
613
|
return settled.kind === "settled" ? settled.result : settled.resolved;
|
|
599
614
|
});
|
|
@@ -653,7 +668,7 @@ export async function preparePolicyChain(input) {
|
|
|
653
668
|
return decision;
|
|
654
669
|
})
|
|
655
670
|
: foldedPolicy;
|
|
656
|
-
return { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations,
|
|
671
|
+
return { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedInstallations: installationsOnLeg };
|
|
657
672
|
}
|
|
658
673
|
const advisedPolicyNames = new WeakMap();
|
|
659
674
|
const ADVISED_KEYS_CAP = 64;
|
|
@@ -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";
|
|
@@ -48,9 +48,9 @@ export async function prepareProjectContext(input) {
|
|
|
48
48
|
catch {
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
let loaded
|
|
51
|
+
let loaded;
|
|
52
52
|
try {
|
|
53
|
-
|
|
53
|
+
const answered = await Promise.resolve(loadProjectMemory.call(deps, {
|
|
54
54
|
cwd: taskRootFinal,
|
|
55
55
|
handsEnabled,
|
|
56
56
|
isSubagent: delegation.isNonForkChild,
|
|
@@ -59,13 +59,16 @@ export async function prepareProjectContext(input) {
|
|
|
59
59
|
runId,
|
|
60
60
|
phase: projectMemoryPhase,
|
|
61
61
|
}));
|
|
62
|
+
if (answered === null || typeof answered !== "object")
|
|
63
|
+
throw new Error(`RunnerDeps.loadProjectMemory answered ${answered === null ? "null" : typeof answered} — the answer is a ProjectMemoryLoad object ({ content: string | null, … }); answer { content: null } for no project layer. Not read: this leg runs with no project layer.`);
|
|
64
|
+
loaded = answered;
|
|
62
65
|
}
|
|
63
66
|
catch (err) {
|
|
64
67
|
deps.onError?.(asThrownError(err), { phase: "config", sessionId });
|
|
65
68
|
}
|
|
66
|
-
const projectMem = loaded
|
|
67
|
-
const seededFiles = loaded
|
|
68
|
-
const declaredSources = loaded
|
|
69
|
+
const projectMem = loaded?.content;
|
|
70
|
+
const seededFiles = loaded?.seededFiles;
|
|
71
|
+
const declaredSources = loaded?.instructionSources;
|
|
69
72
|
if (declaredSources !== undefined && declaredSources.length > 0)
|
|
70
73
|
instructionSources = declaredSources;
|
|
71
74
|
if (seededFiles?.length && seedContextFiles) {
|
|
@@ -110,7 +113,7 @@ export async function prepareProjectContext(input) {
|
|
|
110
113
|
}
|
|
111
114
|
roster.mount(createSkillTool(skillSpecs, skillGrants), { source: "builtin", mountedBy: "optional" });
|
|
112
115
|
}
|
|
113
|
-
const skillSeatOf = skillSeatReader(skillSpecs, mounted);
|
|
116
|
+
const skillSeatOf = skillSeatReader(skillSpecs, classifiesAllShell(spec), mounted);
|
|
114
117
|
const sharedMemoryProvider = deps.sharedMemoryStores;
|
|
115
118
|
let sharedMemoryPairMounted = false;
|
|
116
119
|
if (sharedMemoryProvider !== undefined) {
|
|
@@ -31,7 +31,7 @@ import type { MaterializedMcp } from "../mcp.js";
|
|
|
31
31
|
import type { RosterBuilder } from "../tool-roster.js";
|
|
32
32
|
import type { ResolvedRole } from "../roles.js";
|
|
33
33
|
import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
34
|
-
import type { SessionTreeEntry } from "../../internal/harness-types.js";
|
|
34
|
+
import type { ReadFloor, SessionTreeEntry } from "../../internal/harness-types.js";
|
|
35
35
|
import type { DateAnchorRead, PrepareResume, PromptFeatureFlags, RunInternals, ToolFaceSnapshot } from "./contracts.js";
|
|
36
36
|
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
37
37
|
import { type GitStatusLaneRef } from "./git-status-frame.js";
|
|
@@ -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;
|
|
@@ -99,6 +99,9 @@ export interface PreparePromptInputsInput {
|
|
|
99
99
|
resume: PrepareResume | undefined;
|
|
100
100
|
/** borrowed-readonly — whether a real execution env is mounted (the hands facts + both probes). */
|
|
101
101
|
handsEnabled: boolean;
|
|
102
|
+
/** borrowed-readonly — the byte floor of the run's base read-deny table (`undefined` when the table holds no row): both
|
|
103
|
+
* probes' output reaches the model, so their starts carry it as every relaying start does. */
|
|
104
|
+
readFloor: ReadFloor | undefined;
|
|
102
105
|
/** borrowed-readonly — the FINAL task root: the env `cwd` fact and the git lane's root. */
|
|
103
106
|
taskRootFinal: string;
|
|
104
107
|
/** borrowed-readonly — the canonical extra working roots (copied into the env facts). */
|
|
@@ -6,10 +6,11 @@ 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) {
|
|
12
|
-
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, session, advertisedWritableDirs } = input;
|
|
13
|
+
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, readFloor, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, session, advertisedWritableDirs } = input;
|
|
13
14
|
const promptPolicyEnabled = Boolean(lockedPreflight.toolPolicy);
|
|
14
15
|
const promptHooksEnabled = input.modBus.hasHandlers("classic.PreToolUse") || input.modBus.hasHandlers("classic.PostToolUse");
|
|
15
16
|
if (failClosedReason) {
|
|
@@ -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, ...(readFloor !== undefined ? { readFloor } : {}) });
|
|
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
|
}
|
|
@@ -140,6 +129,7 @@ export async function preparePromptInputs(input) {
|
|
|
140
129
|
envFacts,
|
|
141
130
|
handsEnabled,
|
|
142
131
|
taskRoot: taskRootFinal,
|
|
132
|
+
readFloor,
|
|
143
133
|
onDegrade: (reason) => deps.onError?.(new Error(`env git snapshot degraded — ${reason}`), { phase: "degraded", sessionId, classification: "env-git-snapshot" }),
|
|
144
134
|
});
|
|
145
135
|
return { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz, dateAnchor, gitStatusRef };
|