@sema-agent/core 7.51.2 → 7.53.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 +698 -2
- package/README.md +3 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/cascade.js +4 -0
- package/dist/agents/cross-session-envelope.d.ts +8 -0
- package/dist/agents/cross-session-envelope.js +6 -0
- package/dist/agents/cross-session-judge.d.ts +21 -1
- package/dist/agents/cross-session-judge.js +8 -0
- package/dist/agents/cross-session-ref.d.ts +5 -0
- package/dist/agents/cross-session-ref.js +1 -0
- package/dist/agents/cumulative-stats.d.ts +3 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/org-delivery-gate.d.ts +122 -0
- package/dist/agents/org-delivery-gate.js +69 -0
- package/dist/agents/peer-held-queue.d.ts +9 -4
- package/dist/agents/peer-held-queue.js +6 -5
- package/dist/agents/peer-session-drain.d.ts +35 -5
- package/dist/agents/peer-session-drain.js +271 -180
- package/dist/agents/read-inbox-tool.d.ts +8 -1
- package/dist/agents/read-inbox-tool.js +5 -1
- package/dist/agents/repair-loop.js +4 -0
- package/dist/agents/send-message-tool.d.ts +11 -16
- package/dist/agents/send-message-tool.js +11 -13
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +105 -76
- package/dist/agents/tool-filter.d.ts +58 -13
- package/dist/agents/tool-filter.js +34 -14
- package/dist/bench/metrics.d.ts +1 -0
- package/dist/brain/anthropic.d.ts +6 -1
- package/dist/brain/anthropic.js +17 -13
- package/dist/brain/model-presets.d.ts +4 -5
- package/dist/brain/model-presets.js +6 -5
- package/dist/brain/open-responses.js +16 -12
- package/dist/brain/openai.js +16 -12
- package/dist/brain/request-params.d.ts +12 -33
- package/dist/brain/request-params.js +5 -2
- package/dist/brain/request-route.d.ts +9 -8
- package/dist/brain/request-route.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +123 -47
- package/dist/brain/route-adjudicator.js +171 -42
- package/dist/brain/route-conformance.js +2 -2
- package/dist/brain/routing.d.ts +24 -1
- package/dist/brain/routing.js +54 -19
- package/dist/brain/status-sink.d.ts +18 -0
- package/dist/brain/status-sink.js +7 -0
- package/dist/brain/timeout.js +5 -4
- package/dist/core/a2a.d.ts +5 -2
- package/dist/core/a2a.js +30 -13
- package/dist/core/allow-entry.d.ts +42 -9
- package/dist/core/allow-entry.js +25 -18
- package/dist/core/auto-compaction.d.ts +80 -20
- package/dist/core/auto-compaction.js +65 -18
- package/dist/core/auto-promote.d.ts +2 -1
- package/dist/core/auto-promote.js +2 -2
- package/dist/core/caller-tool-name.d.ts +9 -0
- package/dist/core/caller-tool-name.js +13 -0
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +57 -24
- package/dist/core/checkpoint-store.js +3 -3
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +2 -1
- package/dist/core/compliance.js +3 -1
- package/dist/core/credential-vocabulary.d.ts +33 -8
- package/dist/core/credential-vocabulary.js +32 -7
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/delegation-frames.d.ts +9 -2
- package/dist/core/delegation-name.d.ts +18 -0
- package/dist/core/delegation-name.js +47 -0
- package/dist/core/effective-path-target.d.ts +25 -6
- package/dist/core/effective-path-target.js +24 -2
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +49 -21
- package/dist/core/frontmatter-fence.d.ts +10 -0
- package/dist/core/frontmatter-fence.js +6 -0
- package/dist/core/gate-fold.js +8 -25
- package/dist/core/gate-lanes.js +358 -274
- package/dist/core/gate-outcome.d.ts +11 -6
- package/dist/core/governance-codes.d.ts +11 -4
- package/dist/core/governance-codes.js +12 -3
- package/dist/core/hands-band-screen.d.ts +7 -0
- package/dist/core/hands-band-screen.js +32 -0
- package/dist/core/hooks.d.ts +283 -739
- package/dist/core/hooks.js +100 -193
- package/dist/{tools/fs → core}/image-admission.d.ts +21 -3
- package/dist/{tools/fs → core}/image-admission.js +24 -6
- package/dist/core/locked-config.d.ts +84 -32
- package/dist/core/locked-config.js +128 -42
- package/dist/core/mcp-connection-pool.d.ts +4 -1
- package/dist/core/mcp-connection-pool.js +7 -2
- package/dist/core/mcp-probe.d.ts +12 -9
- package/dist/core/mcp-probe.js +3 -3
- package/dist/core/mcp-server-spec.d.ts +104 -10
- package/dist/core/mcp-server-spec.js +183 -33
- package/dist/core/mcp.d.ts +31 -20
- package/dist/core/mcp.js +66 -56
- package/dist/core/memory-engine/data-plane.js +5 -1
- package/dist/core/memory-engine/distiller.js +16 -2
- package/dist/core/memory-engine/engine.d.ts +22 -30
- package/dist/core/memory-engine/engine.js +16 -10
- package/dist/core/memory-engine/frontmatter.d.ts +6 -0
- package/dist/core/memory-engine/frontmatter.js +19 -16
- package/dist/core/memory.d.ts +2 -2
- package/dist/core/mode-policy.d.ts +5 -16
- package/dist/core/mode-policy.js +7 -19
- package/dist/core/model-seat.d.ts +4 -1
- package/dist/core/mods/dollar.d.ts +109 -0
- package/dist/core/mods/dollar.js +154 -0
- package/dist/core/mods/host.d.ts +23 -0
- package/dist/core/mods/host.js +21 -0
- package/dist/core/mods/kernel/budget.d.ts +43 -0
- package/dist/core/mods/kernel/budget.js +83 -0
- package/dist/core/mods/kernel/dispatch.d.ts +100 -0
- package/dist/core/mods/kernel/dispatch.js +699 -0
- package/dist/core/mods/kernel/events.d.ts +245 -0
- package/dist/core/mods/kernel/events.js +210 -0
- package/dist/core/mods/kernel/index.d.ts +6 -0
- package/dist/core/mods/kernel/index.js +5 -0
- package/dist/core/mods/kernel/receive.d.ts +94 -0
- package/dist/core/mods/kernel/receive.js +188 -0
- package/dist/core/mods/kernel/registration.d.ts +131 -0
- package/dist/core/mods/kernel/registration.js +102 -0
- package/dist/core/mods/kernel/site-rules.d.ts +149 -0
- package/dist/core/mods/kernel/site-rules.js +296 -0
- package/dist/core/mods/stations.d.ts +344 -0
- package/dist/core/mods/stations.js +437 -0
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +71 -2
- package/dist/core/own-property-receipt.d.ts +13 -0
- package/dist/core/own-property-receipt.js +13 -23
- package/dist/core/parent-spec-seat.d.ts +18 -7
- package/dist/core/parent-spec-seat.js +6 -2
- package/dist/core/path-identity.js +2 -1
- package/dist/core/permission-rule-model.d.ts +58 -9
- package/dist/core/permission-rule-model.js +81 -7
- package/dist/core/permission-rule-org.d.ts +163 -33
- package/dist/core/permission-rule-org.js +205 -71
- package/dist/core/permission-rule-syntax.d.ts +15 -0
- package/dist/core/permission-rule-syntax.js +24 -16
- package/dist/core/permission-rules.d.ts +14 -2
- package/dist/core/permission-rules.js +63 -23
- package/dist/core/prompt-section-seat.d.ts +15 -27
- package/dist/core/prompt-section-seat.js +73 -40
- package/dist/core/protocol-http-auth.d.ts +3 -1
- package/dist/core/protocol-http-auth.js +2 -0
- package/dist/core/reminder-mint.d.ts +2 -2
- package/dist/core/remote-env.d.ts +24 -12
- package/dist/core/remote-env.js +1 -0
- package/dist/core/resume-startup-cause.d.ts +16 -1
- package/dist/core/resume-startup-cause.js +4 -1
- package/dist/core/retention.js +7 -2
- package/dist/core/retired-keys.d.ts +12 -2
- package/dist/core/retired-keys.js +15 -1
- package/dist/core/roles.js +60 -10
- package/dist/core/rule-lane-reads.js +1 -1
- package/dist/core/runner/announce-once-ledger.d.ts +31 -1
- package/dist/core/runner/announce-once-ledger.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +9 -0
- package/dist/core/runner/assemble-result.js +3 -1
- package/dist/core/runner/call-hook-stations.d.ts +23 -27
- package/dist/core/runner/call-hook-stations.js +58 -42
- package/dist/core/runner/caller-stop-gate.d.ts +25 -0
- package/dist/core/runner/caller-stop-gate.js +7 -0
- package/dist/core/runner/compaction-seams.d.ts +8 -22
- package/dist/core/runner/compaction-seams.js +28 -53
- package/dist/core/runner/construction-doors.js +11 -1
- package/dist/core/runner/contracts.d.ts +86 -83
- package/dist/core/runner/credential-origin-seat.d.ts +2 -0
- package/dist/core/runner/credential-origin-seat.js +19 -0
- package/dist/core/runner/extra-body-dropped-seat.d.ts +2 -6
- package/dist/core/runner/gate-exit.d.ts +47 -36
- package/dist/core/runner/gate-exit.js +12 -5
- package/dist/core/runner/image.js +1 -2
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/mcp-redial.d.ts +52 -10
- package/dist/core/runner/mcp-redial.js +38 -9
- package/dist/core/runner/notice-seat-input.d.ts +11 -0
- package/dist/core/runner/notice-seat-input.js +1 -0
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
- package/dist/core/runner/permission-rule-lanes.js +22 -10
- package/dist/core/runner/person-path-rows.d.ts +3 -1
- package/dist/core/runner/person-path-rows.js +3 -2
- package/dist/core/runner/prepare-acquire-reconcile.js +5 -1
- package/dist/core/runner/prepare-ask-lane.d.ts +5 -7
- package/dist/core/runner/prepare-ask-lane.js +6 -15
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +25 -8
- package/dist/core/runner/prepare-config-doors.d.ts +52 -1
- package/dist/core/runner/prepare-config-doors.js +168 -143
- package/dist/core/runner/prepare-defer-classify.js +7 -11
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +7 -5
- package/dist/core/runner/prepare-gate-stations.d.ts +8 -11
- package/dist/core/runner/prepare-gate-stations.js +11 -10
- package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
- package/dist/core/runner/prepare-hands-readface.js +2 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -12
- package/dist/core/runner/prepare-inherited-gate.js +10 -23
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
- package/dist/core/runner/prepare-memory-engine-session.js +20 -7
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +6 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
- package/dist/core/runner/prepare-offload-wrappers.js +2 -1
- package/dist/core/runner/prepare-park-ask.js +10 -14
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -15
- package/dist/core/runner/prepare-policy-chain.js +104 -109
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +11 -12
- package/dist/core/runner/prepare-prompt-assembly.d.ts +45 -40
- package/dist/core/runner/prepare-prompt-assembly.js +138 -101
- package/dist/core/runner/prepare-prompt-inputs.d.ts +28 -23
- package/dist/core/runner/prepare-prompt-inputs.js +11 -10
- package/dist/core/runner/prepare-protocol-tools.d.ts +11 -7
- package/dist/core/runner/prepare-protocol-tools.js +20 -13
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-question-face.js +4 -3
- package/dist/core/runner/prepare-safety-scan.js +6 -10
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -5
- package/dist/core/runner/prepare-task.js +41 -23
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -15
- package/dist/core/runner/prepare-turn-wiring.js +29 -27
- package/dist/core/runner/prepare-wiring-manifest.d.ts +13 -9
- package/dist/core/runner/prepare-wiring-manifest.js +14 -11
- package/dist/core/runner/resume-admission.d.ts +4 -1
- package/dist/core/runner/resume-admission.js +7 -5
- package/dist/core/runner/resume-apply.d.ts +5 -2
- package/dist/core/runner/resume-apply.js +24 -42
- package/dist/core/runner/resume-checkpoint-screen.d.ts +1 -0
- package/dist/core/runner/resume-checkpoint-screen.js +9 -1
- package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
- package/dist/core/runner/resume-internals-and-config.js +3 -8
- package/dist/core/runner/resume-preflight.js +38 -16
- package/dist/core/runner/retired-runner-deps.d.ts +5 -6
- package/dist/core/runner/retired-runner-deps.js +4 -5
- package/dist/core/runner/run-brain-sinks.d.ts +3 -2
- package/dist/core/runner/run-brain-sinks.js +5 -1
- package/dist/core/runner/run-compaction-machinery.d.ts +7 -1
- package/dist/core/runner/run-compaction-machinery.js +7 -33
- package/dist/core/runner/run-harness-handlers.js +4 -2
- package/dist/core/runner/run-identity-wiring.d.ts +3 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +103 -95
- package/dist/core/runner/run-notification-lane.js +1 -0
- package/dist/core/runner/run-recovery-lanes.d.ts +3 -0
- package/dist/core/runner/run-recovery-lanes.js +14 -11
- package/dist/core/runner/run-settle-and-teardown.js +9 -28
- package/dist/core/runner/run-stop-and-final-verify.js +18 -25
- package/dist/core/runner/run-terminal-adoption.d.ts +3 -0
- package/dist/core/runner/run-terminal-adoption.js +34 -22
- package/dist/core/runner/run-tool-mount-facts.js +5 -3
- package/dist/core/runner/run-turn-boundary.js +32 -37
- package/dist/core/runner/runtask.d.ts +6 -7
- package/dist/core/runner/runtask.js +15 -73
- package/dist/core/runner/session-rule-policy.d.ts +5 -5
- package/dist/core/runner/session-rule-policy.js +13 -8
- package/dist/core/runner/side-call-account.d.ts +68 -0
- package/dist/core/runner/side-call-account.js +61 -0
- package/dist/core/runner/skills-seat.d.ts +15 -0
- package/dist/core/runner/skills-seat.js +57 -0
- package/dist/core/runner/stream-halt-verbs.js +12 -17
- package/dist/core/runner/stream-lifecycle-verbs.js +8 -5
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +20 -38
- package/dist/core/runner/sub-agent-deny-lists.d.ts +124 -23
- package/dist/core/runner/sub-agent-deny-lists.js +230 -71
- package/dist/core/runner/synthetic-tools.d.ts +5 -2
- package/dist/core/runner/synthetic-tools.js +2 -12
- package/dist/core/runner/tool-end-body.d.ts +5 -6
- package/dist/core/runner/tool-end-body.js +6 -4
- package/dist/core/runner/tool-not-executed.d.ts +15 -0
- package/dist/core/runner/tool-not-executed.js +30 -0
- package/dist/core/runner/tool-occurrence.d.ts +8 -7
- package/dist/core/runner/tool-occurrence.js +5 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +1 -1
- package/dist/core/runner-deps.d.ts +43 -36
- package/dist/core/safety-merge-corpus.js +18 -2
- package/dist/core/secret-env.d.ts +88 -20
- package/dist/core/secret-env.js +192 -38
- package/dist/core/session-policy-store.d.ts +71 -16
- package/dist/core/session-policy-store.js +138 -28
- package/dist/core/session-reconcile.d.ts +4 -0
- package/dist/core/session-reconcile.js +2 -1
- package/dist/core/shell-read-silence.js +3 -32
- package/dist/core/side-query.d.ts +5 -3
- package/dist/core/skill-grant.d.ts +3 -2
- package/dist/core/skill-grant.js +17 -9
- package/dist/core/skills-directory.d.ts +31 -11
- package/dist/core/skills-directory.js +655 -104
- package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +49 -3
- package/dist/core/task-notification.js +2 -2
- package/dist/core/task-result.d.ts +8 -0
- package/dist/core/task-spec.d.ts +20 -19
- package/dist/core/task-stream.d.ts +14 -4
- package/dist/core/tighten-task-spec.d.ts +4 -3
- package/dist/core/tighten-task-spec.js +2 -4
- package/dist/core/tool-check-reading.d.ts +74 -0
- package/dist/core/tool-check-reading.js +80 -0
- package/dist/core/tool-policy.d.ts +62 -18
- package/dist/core/tool-policy.js +86 -15
- package/dist/core/tool-registry.d.ts +20 -0
- package/dist/core/tool-registry.js +4 -0
- package/dist/core/tool-spec.d.ts +10 -6
- package/dist/core/tools.js +2 -0
- package/dist/core/trace.d.ts +51 -32
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/unc-spelling.d.ts +10 -0
- package/dist/core/unc-spelling.js +3 -0
- package/dist/core/untrusted-egress.d.ts +8 -0
- package/dist/core/untrusted-egress.js +4 -1
- package/dist/core/untrusted-text.d.ts +16 -0
- package/dist/core/untrusted-text.js +7 -2
- package/dist/core/user-attachment.d.ts +25 -4
- package/dist/core/user-attachment.js +63 -42
- package/dist/core/wiring-manifest.d.ts +18 -15
- package/dist/core/wiring-manifest.js +2 -2
- package/dist/engine/compaction/utils.js +1 -2
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/symlink-chain.js +1 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +5 -4
- package/dist/engine/harness/types.d.ts +20 -16
- package/dist/engine/harness/types.js +7 -1
- package/dist/engine/llm/types.d.ts +12 -7
- package/dist/engine/loop/agent-loop.d.ts +12 -1
- package/dist/engine/loop/agent-loop.js +18 -6
- package/dist/engine/loop/types.d.ts +8 -2
- package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
- package/dist/engine/session/import-validate.js +3 -10
- package/dist/engine/session/session.d.ts +4 -4
- package/dist/engine/session/session.js +4 -4
- package/dist/index.d.ts +33 -23
- package/dist/index.js +23 -15
- package/dist/internal/harness.d.ts +2 -1
- package/dist/internal/harness.js +2 -1
- package/dist/orchestration/goal.d.ts +24 -1
- package/dist/orchestration/goal.js +3 -2
- package/dist/orchestration/run-spec.d.ts +4 -6
- package/dist/orchestration/run-spec.js +39 -63
- package/dist/orchestration/run-workflow-tool.js +1 -2
- package/dist/orchestration/workflow.d.ts +11 -3
- package/dist/orchestration/workflow.js +11 -2
- package/dist/prompt-assembly/artifact-store.d.ts +72 -56
- package/dist/prompt-assembly/artifact-store.js +60 -52
- package/dist/prompt-assembly/artifact.d.ts +90 -76
- package/dist/prompt-assembly/artifact.js +197 -145
- package/dist/prompt-assembly/assemble.d.ts +36 -29
- package/dist/prompt-assembly/assemble.js +34 -220
- package/dist/prompt-assembly/bands.d.ts +20 -0
- package/dist/prompt-assembly/bands.js +18 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +23 -0
- package/dist/prompt-assembly/catalog/constitution.js +69 -0
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +9 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +85 -0
- package/dist/prompt-assembly/catalog/index.d.ts +11 -0
- package/dist/prompt-assembly/catalog/index.js +60 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
- package/dist/prompt-assembly/catalog/memory.js +6 -0
- package/dist/prompt-assembly/catalog/modes.d.ts +15 -0
- package/dist/prompt-assembly/catalog/modes.js +137 -0
- package/dist/prompt-assembly/catalog/role.d.ts +10 -0
- package/dist/prompt-assembly/catalog/role.js +157 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +138 -0
- package/dist/prompt-assembly/catalog/schema.js +25 -0
- package/dist/prompt-assembly/catalog/sections.d.ts +9 -0
- package/dist/prompt-assembly/catalog/sections.js +98 -0
- package/dist/prompt-assembly/catalog/team.d.ts +4 -0
- package/dist/prompt-assembly/catalog/team.js +258 -0
- package/dist/prompt-assembly/composer.d.ts +26 -28
- package/dist/prompt-assembly/composer.js +124 -46
- package/dist/prompt-assembly/epoch.d.ts +89 -79
- package/dist/prompt-assembly/epoch.js +115 -142
- package/dist/prompt-assembly/explain.d.ts +58 -34
- package/dist/prompt-assembly/explain.js +21 -24
- package/dist/prompt-assembly/overlay.d.ts +137 -0
- package/dist/prompt-assembly/overlay.js +339 -0
- package/dist/prompt-assembly/renderers.d.ts +21 -0
- package/dist/prompt-assembly/renderers.js +39 -0
- package/dist/prompt-assembly/section-usage.d.ts +3 -3
- package/dist/prompt-assembly/section-usage.js +1 -1
- package/dist/prompt-assembly/select.d.ts +71 -0
- package/dist/prompt-assembly/select.js +106 -0
- package/dist/prompt-assembly/sugar.d.ts +31 -0
- package/dist/prompt-assembly/sugar.js +20 -0
- package/dist/prompt-assembly/turn-snapshot.d.ts +3 -2
- package/dist/prompt-assembly/types.d.ts +45 -148
- package/dist/prompts/coordinator.d.ts +2 -21
- package/dist/prompts/coordinator.js +3 -255
- package/dist/prompts/cowork.d.ts +27 -16
- package/dist/prompts/cowork.js +2 -23
- package/dist/prompts/default.d.ts +38 -511
- package/dist/prompts/default.js +20 -288
- package/dist/prompts/supervisor.d.ts +6 -71
- package/dist/prompts/supervisor.js +6 -117
- package/dist/stores/file/permission-rule-store.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.js +2 -1
- package/dist/tools/artifact/artifact-tool.js +4 -3
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -5
- package/dist/tools/fs/dir-entries.d.ts +4 -2
- package/dist/tools/fs/dir-entries.js +16 -4
- package/dist/tools/fs/fs-bash.d.ts +1 -1
- package/dist/tools/fs/fs-bash.js +22 -11
- package/dist/tools/fs/fs-pdf.js +17 -13
- package/dist/tools/fs/fs-read.js +4 -3
- package/dist/tools/fs/fs-shared.d.ts +1 -10
- package/dist/tools/fs/fs-shared.js +3 -4
- package/dist/tools/fs/fs-write.js +2 -1
- package/dist/tools/fs/notebook.js +1 -1
- package/dist/tools/fs/pdf.d.ts +20 -10
- package/dist/tools/fs/pdf.js +19 -10
- package/dist/tools/fs/program-read-model.d.ts +68 -8
- package/dist/tools/fs/program-read-model.js +112 -33
- package/dist/tools/fs/program-read-model.rows.js +30 -10
- package/dist/tools/fs/read-deny-home.d.ts +25 -9
- package/dist/tools/fs/read-deny-home.js +28 -27
- package/dist/tools/fs/read-deny.d.ts +41 -11
- package/dist/tools/fs/read-deny.js +51 -5
- package/dist/tools/fs/safety.d.ts +4 -26
- package/dist/tools/fs/safety.js +10 -32
- package/dist/tools/fs/search.js +15 -10
- package/dist/tools/fs/shell-read-argv.d.ts +3 -2
- package/dist/tools/fs/shell-read-argv.js +118 -38
- package/dist/tools/fs/shell-read-establish.d.ts +5 -5
- package/dist/tools/fs/shell-read-establish.js +11 -61
- package/dist/tools/fs/shell-read-identity.js +6 -3
- package/dist/tools/fs/shell-read-judge.d.ts +13 -15
- package/dist/tools/fs/shell-read-judge.js +18 -4
- package/dist/tools/fs/shell-read-plan.d.ts +2 -2
- package/dist/tools/web.js +1 -1
- package/package.json +13 -1
- package/test/export-surface.snapshot.json +306 -103
- package/wire-changes/core@7.52.0.json +5859 -0
- package/wire-changes/core@7.53.0.json +1946 -0
- package/dist/core/hook-seats.d.ts +0 -66
- package/dist/core/hook-seats.js +0 -37
- package/dist/prompt-assembly/packs/sema-default.d.ts +0 -2
- package/dist/prompt-assembly/packs/sema-default.js +0 -147
- package/dist/prompts/simple-sections.d.ts +0 -58
- package/dist/prompts/simple-sections.js +0 -43
|
@@ -20,10 +20,10 @@ import type { ToolSelector } from "../tool-face.js";
|
|
|
20
20
|
export interface PrepareOffloadWrappersInput {
|
|
21
21
|
/** borrowed-readonly — the REBOUND spec (the config-doors result); read for the per-task coarse
|
|
22
22
|
* offload knob only. */
|
|
23
|
-
spec: Pick<TaskSpec, "toolResultThresholdChars">;
|
|
24
|
-
/** borrowed-readonly — the leg's compiled selector: an offloaded result is read back through the
|
|
25
|
-
* does not
|
|
26
|
-
* sends the model to a tool it does not have is a dead end. */
|
|
23
|
+
spec: Pick<TaskSpec, "toolResultThresholdChars" | "excludeAllTools">;
|
|
24
|
+
/** borrowed-readonly — the leg's compiled selector, read through the valve (`valveLeaves`): an offloaded result is read back through the
|
|
25
|
+
* reader tool, so a leg whose valve does not leave the reader (a sub-agent whose lists leave it out, a deployment that excludes it, a
|
|
26
|
+
* run whose whole face is switched off) offloads nothing — a preview that sends the model to a tool it does not have is a dead end. */
|
|
27
27
|
selector: Pick<ToolSelector, "admits">;
|
|
28
28
|
/** borrowed-readonly — the deployment's coarse offload knob and its injected store (used AS-IS when
|
|
29
29
|
* present; a Runner-shared instance is viewed per task, see the body). */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_TOOL_RESULT_THRESHOLD_CHARS, InMemoryToolResultStore, OFFLOAD_TOOL_NAME, RunnerSharedToolResultStore, ScopedToolResultStore, withToolResultOffload, } from "../tool-result-store.js";
|
|
2
2
|
import { faceOf } from "../tool-roster.js";
|
|
3
|
+
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
3
4
|
const FIRST_PARTY_OFFLOAD_THRESHOLD_CHARS = 50_000;
|
|
4
5
|
export function prepareOffloadWrappers(input) {
|
|
5
6
|
const { spec, deps, resume, offloadScope, sessionId, selector } = input;
|
|
@@ -21,7 +22,7 @@ export function prepareOffloadWrappers(input) {
|
|
|
21
22
|
};
|
|
22
23
|
const explicitGlobalThreshold = spec.toolResultThresholdChars ?? deps.toolResultThresholdChars;
|
|
23
24
|
const offloadThreshold = explicitGlobalThreshold ?? DEFAULT_TOOL_RESULT_THRESHOLD_CHARS;
|
|
24
|
-
const offloadEnabled = Number.isFinite(offloadThreshold) && offloadThreshold > 0 && selector
|
|
25
|
+
const offloadEnabled = Number.isFinite(offloadThreshold) && offloadThreshold > 0 && valveLeaves(spec, selector)({ name: OFFLOAD_TOOL_NAME });
|
|
25
26
|
const rawOffloadStore = offloadEnabled ? (deps.toolResultStore ?? new InMemoryToolResultStore()) : undefined;
|
|
26
27
|
const offloadStore = rawOffloadStore instanceof RunnerSharedToolResultStore
|
|
27
28
|
? new ScopedToolResultStore(rawOffloadStore, offloadScope)
|
|
@@ -9,7 +9,7 @@ import { pauseOf } from "../pause-registry.js";
|
|
|
9
9
|
import { askCarryRowMembers } from "../hooks.js";
|
|
10
10
|
import { askMandateMember, ownedClearanceFacts } from "../ask-origin.js";
|
|
11
11
|
import { defaultTaskRegistry } from "../task-registry.js";
|
|
12
|
-
import { advertisedWritableRootsSeat, exemptRootsSeat, isLiveApproverSeat, carriesBidiControls, describeThrown, refuseOutOfContractDecision, tryCloneArgs } from "../tool-policy.js";
|
|
12
|
+
import { advertisedWritableRootsSeat, exemptRootsSeat, isLiveApproverSeat, carriesBidiControls, describeThrown, ownArgs, refuseOutOfContractDecision, tryCloneArgs } from "../tool-policy.js";
|
|
13
13
|
import { InMemoryToolResultStore, ScopedToolResultStore, isVolatileOffloadStore } from "../tool-result-store.js";
|
|
14
14
|
import { raceAbort, raceSettlementAgainstSignal } from "./abort-race.js";
|
|
15
15
|
import { CONTENT_ASK_BINDING_CAP } from "./content-ask-bindings.js";
|
|
@@ -43,11 +43,7 @@ export function prepareParkAsk(input) {
|
|
|
43
43
|
return;
|
|
44
44
|
contentAskBindings.set(req.toolCallId, { ...entry, questionsHash, deliveryId });
|
|
45
45
|
};
|
|
46
|
-
const refuseBeforeDelivery = (code
|
|
47
|
-
kind: "delivery_failure",
|
|
48
|
-
code,
|
|
49
|
-
...(presentedInput !== undefined ? { presentedInput } : {}),
|
|
50
|
-
});
|
|
46
|
+
const refuseBeforeDelivery = (code) => ({ kind: "delivery_failure", code });
|
|
51
47
|
let retained;
|
|
52
48
|
let presented;
|
|
53
49
|
try {
|
|
@@ -59,13 +55,13 @@ export function prepareParkAsk(input) {
|
|
|
59
55
|
}
|
|
60
56
|
const retainedQuestionsHash = boundInputHashOf(retained.questions);
|
|
61
57
|
if (!Value.Check(mountedQuestionTool.parameters, retained) || validateAskQuestions(presented) !== undefined) {
|
|
62
|
-
return refuseBeforeDelivery("question.malformed_request"
|
|
58
|
+
return refuseBeforeDelivery("question.malformed_request");
|
|
63
59
|
}
|
|
64
60
|
if (contentAskBindings.size >= CONTENT_ASK_BINDING_CAP && !contentAskBindings.has(req.toolCallId)) {
|
|
65
61
|
return { kind: "unavailable", parkDeclined: true };
|
|
66
62
|
}
|
|
67
63
|
if (contentAskSignal.aborted) {
|
|
68
|
-
return { kind: "delivery_failure", code: "question.aborted"
|
|
64
|
+
return { kind: "delivery_failure", code: "question.aborted" };
|
|
69
65
|
}
|
|
70
66
|
try {
|
|
71
67
|
const facePromise = (async () => liveQuestionFace({
|
|
@@ -90,13 +86,13 @@ export function prepareParkAsk(input) {
|
|
|
90
86
|
const reading = classifyQuestionOutcome(outcome);
|
|
91
87
|
if (reading.shape === "contradictory") {
|
|
92
88
|
bindOutcome({ kind: "failed", error: new Error("the question channel returned a contradictory outcome (an unavailable answer)") }, retainedQuestionsHash);
|
|
93
|
-
return { kind: "delivery_failure", code: "question.human_channel_failed"
|
|
89
|
+
return { kind: "delivery_failure", code: "question.human_channel_failed" };
|
|
94
90
|
}
|
|
95
91
|
if (reading.shape === "unavailable")
|
|
96
|
-
return { kind: "unavailable", parkDeclined: true
|
|
92
|
+
return { kind: "unavailable", parkDeclined: true };
|
|
97
93
|
const answerSnapshot = reading.answer;
|
|
98
94
|
bindOutcome({ kind: "answered", answer: answerSnapshot }, retainedQuestionsHash);
|
|
99
|
-
return { kind: "answered"
|
|
95
|
+
return { kind: "answered" };
|
|
100
96
|
}
|
|
101
97
|
const error = settlement.tag === "threw"
|
|
102
98
|
? settlement.error
|
|
@@ -105,12 +101,11 @@ export function prepareParkAsk(input) {
|
|
|
105
101
|
return {
|
|
106
102
|
kind: "delivery_failure",
|
|
107
103
|
code: settlement.tag === "aborted" || contentAskSignal.aborted ? "question.aborted" : "question.human_channel_failed",
|
|
108
|
-
presentedInput: retained,
|
|
109
104
|
};
|
|
110
105
|
}
|
|
111
106
|
catch (err) {
|
|
112
107
|
bindOutcome({ kind: "failed", error: err }, retainedQuestionsHash);
|
|
113
|
-
return { kind: "delivery_failure", code: "question.human_channel_failed"
|
|
108
|
+
return { kind: "delivery_failure", code: "question.human_channel_failed" };
|
|
114
109
|
}
|
|
115
110
|
};
|
|
116
111
|
const suspendAsk = parkLaneArmed && checkpointStore !== undefined
|
|
@@ -180,7 +175,8 @@ export function prepareParkAsk(input) {
|
|
|
180
175
|
if (reprojectedRaced.tag === "threw")
|
|
181
176
|
throw reprojectedRaced.error;
|
|
182
177
|
const reprojected = refuseOutOfContractDecision(reprojectedRaced.value);
|
|
183
|
-
const
|
|
178
|
+
const filedAsHeld = ownArgs(parkedArgs);
|
|
179
|
+
const rewroteTheFiledValue = reprojected.updatedInput !== undefined && !(filedAsHeld.ok && samePlainValue(reprojected.updatedInput, filedAsHeld.value));
|
|
184
180
|
if (reprojected.action === "deny" || rewroteTheFiledValue) {
|
|
185
181
|
throw new ParkRefusal(`the arguments of "${req.toolName}" change shape when stored by this checkpoint backend, and the deployment's tool policy does not accept the stored shape` +
|
|
186
182
|
`${reprojected.action === "deny" && reprojected.message ? `: ${reprojected.message}` : ""} — ` +
|
|
@@ -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 InheritedToolCheck, 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";
|
|
@@ -34,6 +34,7 @@ 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
36
|
import type { GrantBindingOf } from "../skill-grant-binding.js";
|
|
37
|
+
import type { ToolSelector } from "../tool-face.js";
|
|
37
38
|
import { type AllowEntryLane, type AllowEntryTable } from "../allow-entry.js";
|
|
38
39
|
import type { InheritedGate, IrreversibilityTier, PrepareResume, RunInternals, StopForDenialLimit } from "./contracts.js";
|
|
39
40
|
import { type Arbitration } from "../ask-origin.js";
|
|
@@ -43,14 +44,14 @@ import { createRuleOffersOf, type PermissionRuleLanes } from "./permission-rule-
|
|
|
43
44
|
import type { ToolCallLike } from "../tool-registry.js";
|
|
44
45
|
export interface PreparePolicyChainInput {
|
|
45
46
|
/** borrowed-readonly — the REBOUND spec. Read: `sessionId` / `principal` (the session-rule read and the lanes' identity),
|
|
46
|
-
* `
|
|
47
|
-
* Never mutated. */
|
|
48
|
-
spec: Pick<TaskSpec, "sessionId" | "principal" | "
|
|
49
|
-
/** borrowed-readonly — the deployment seats: `sessionPolicyStore` (the rule reads),
|
|
47
|
+
* `durableApproval` / `checkpointStore` (the mandate-park facility test and the sandbox arming's park prerequisites), `taskId` (the late-ask observer's detail),
|
|
48
|
+
* `tools` (the names the caller mounted, for the name audit). Never mutated. */
|
|
49
|
+
spec: Pick<TaskSpec, "sessionId" | "principal" | "durableApproval" | "taskId" | "checkpointStore" | "tools" | "excludeAllTools">;
|
|
50
|
+
/** borrowed-readonly — the deployment seats: `sessionPolicyStore` (the rule reads),
|
|
50
51
|
* `permissionRuleStore` / `localOwnerRules` (the lanes and the offer factory), `onError` / `onNotice` (the advisories,
|
|
51
52
|
* the refusal disclosures, the late-ask observer), `tracer` (the admission and rule-store frames), `checkpointStore` (the park facility). Receiver preserved;
|
|
52
53
|
* the advisory dedupe is KEYED on this object's identity. */
|
|
53
|
-
deps: Pick<RunnerDeps, "sessionPolicyStore" | "
|
|
54
|
+
deps: Pick<RunnerDeps, "sessionPolicyStore" | "permissionRuleStore" | "localOwnerRules" | "onError" | "onNotice" | "tracer" | "checkpointStore" | "a2a">;
|
|
54
55
|
/** borrowed-readonly — the trusted spawn-side channel: `parentTaskId` (the from-subagent bit), `explicitAgentName` /
|
|
55
56
|
* `agentName` (the source agent name) — the ask source identity's local, trusted facts. */
|
|
56
57
|
internals: Pick<RunInternals, "parentTaskId" | "explicitAgentName" | "agentName"> | undefined;
|
|
@@ -82,6 +83,8 @@ export interface PreparePolicyChainInput {
|
|
|
82
83
|
tools: ReadonlyArray<AgentTool>;
|
|
83
84
|
/** borrowed-readonly — the harness list (placeholders keep their deferred names), the audit universe's second half. */
|
|
84
85
|
harnessTools: ReadonlyArray<AgentTool>;
|
|
86
|
+
/** borrowed-readonly — the leg's compiled tool selector: the name audit reads the delegation tools it leaves ({@link delegationPoolReading}). */
|
|
87
|
+
selector: Pick<ToolSelector, "admits">;
|
|
85
88
|
/** borrowed-readonly — the effect collection, read by the narrowing layers (path-confinable write tools). */
|
|
86
89
|
toolEffects: ReadonlyMap<string, ToolEffect>;
|
|
87
90
|
/** borrowed-readonly — the egress mark set (the risk axes, the boundary predicate, the offer factory). */
|
|
@@ -146,8 +149,12 @@ export interface PreparePolicyChainInput {
|
|
|
146
149
|
frozenOnAsk: OnAsk | undefined;
|
|
147
150
|
/** borrowed-readonly — the identity of this task's hook-env source (the pass-through test's environment term). */
|
|
148
151
|
hookEnvSource: unknown;
|
|
149
|
-
/** borrowed-readonly — the own
|
|
152
|
+
/** borrowed-readonly — the leg's own failure lane (`onError`, phase `hook`, swallow-guarded): an inherited policy that threw. */
|
|
150
153
|
notifyOwnHookCrash: (err: unknown) => void;
|
|
154
|
+
/** borrowed-readonly — the leg's mods bus (whether this leg's own phase 1 judges with `classic.PreToolUse` — the pass-through test). */
|
|
155
|
+
modBus: LegModBus;
|
|
156
|
+
/** borrowed-readonly — this leg's chain identity as its admission recorded it (`chainOfBus`) — the stand-in test's chain term. */
|
|
157
|
+
ownModChain: readonly ModChainLink[];
|
|
151
158
|
/** borrowed-readonly — LATE-BOUND: this task's own classifier instance (the pass-through test's decider term), read at chain
|
|
152
159
|
* assembly (the arming runs after this phase, and again on a steer into `auto`). */
|
|
153
160
|
autoModeDecider: () => AutoModeDecider | undefined;
|
|
@@ -182,14 +189,6 @@ export interface PreparePolicyChainInput {
|
|
|
182
189
|
};
|
|
183
190
|
}
|
|
184
191
|
export interface PreparePolicyChainResult {
|
|
185
|
-
/** owned — the resolved hook record (`spec.hooks ?? deps.hooks`), or undefined. */
|
|
186
|
-
hooks: Hooks | undefined;
|
|
187
|
-
/** owned — the per-leg hook timeout, resolved and validated ONCE (`Prepared.hookTimeoutMs`). */
|
|
188
|
-
hookTimeoutMs: number;
|
|
189
|
-
/** owned — whether the deployment declared its screening face observational. */
|
|
190
|
-
preToolUseObservational: boolean;
|
|
191
|
-
/** owned — the screening face this task's OWN gate runs in phase 1 (the observational wrapper when declared). */
|
|
192
|
-
ownGatePreToolUse: Hooks["preToolUse"] | undefined;
|
|
193
192
|
/** owned — the resume-edit base policy (`Prepared.basePolicyForResumeEdit`), or undefined. */
|
|
194
193
|
basePolicyForResumeEdit: ToolPolicy | undefined;
|
|
195
194
|
/** owned — the deny-narrowing fold (`Prepared.denyNarrowingPolicy`), or undefined when no layer exists. */
|
|
@@ -208,6 +207,9 @@ export interface PreparePolicyChainResult {
|
|
|
208
207
|
/** borrowed-mutable — the inherited-unavailable marker channel. Writers: the inherited arms here (mark); the gate station
|
|
209
208
|
* (the lifecycle-end sweep) and the park lane's consumers (delete on consumption). */
|
|
210
209
|
inheritedUnavailableAsks: Set<string>;
|
|
210
|
+
/** owned — the inherited installations THIS leg's gate raises `tool.check` on after its own bus (every screening entry the
|
|
211
|
+
* leg's own gate does not stand in for — the fold's pass-through test), each with the settlement its question takes. */
|
|
212
|
+
inheritedToolChecks: readonly InheritedToolCheck[];
|
|
211
213
|
/** owned — the inherited stations' MODE ARBITRATIONS by tool call (a release or a refusal made inside the fold,
|
|
212
214
|
* where an ancestor's ask is arbitrated before its frozen approver). Writers: the three inherited stations here; the gate's
|
|
213
215
|
* exit reads it onto the disposition and the gate station deletes it at the call's end. */
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { withArgsReading } from "../effective-path-target.js";
|
|
1
|
+
import { argsAsTheToolReads, withArgsReading } from "../effective-path-target.js";
|
|
2
2
|
import { policyAskClassOf } from "../ask-class.js";
|
|
3
3
|
import { ASK_USER_QUESTION_TOOL_NAME } from "../ask-question.js";
|
|
4
4
|
import { classifierUnavailableSeat } from "./classifier-ladder.js";
|
|
5
5
|
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
6
|
-
import {
|
|
7
|
-
import { assertHookSeatsCallable } from "../hook-seats.js";
|
|
6
|
+
import { chainJudges, inheritedToolChecks, screeningInstallationsOf, standsInFor } from "../mods/stations.js";
|
|
8
7
|
import { isNamespacedCoveringRuleName, namespacedRuleNameCovers } from "../permission-rules.js";
|
|
9
8
|
import { isIsolated } from "../remote-env.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
10
|
+
import { earlierGrammarNotice } from "../session-policy-store.js";
|
|
11
|
+
import { attest, attestationOf, checkToolPolicyProjection, combinePolicies, createTranscriptIntegrityPolicy, createUnverifiableDeletePolicy, durableParkOptInDeclared, isLiveApproverSeat, mergeAttestation, refuseOutOfContractDecision, resolveAsk, toolPolicyNameSets, withAttestation, wrapToolPolicy } from "../tool-policy.js";
|
|
12
12
|
import { judgeRuleToolName, mountedToolNames } from "../tool-name-aliases.js";
|
|
13
13
|
import { approvalCardMemberOf } from "../tool-roster.js";
|
|
14
14
|
import { NAMESPACED_NAME_SHAPES } from "../protocol-table.js";
|
|
15
15
|
import { emitTrace } from "../trace.js";
|
|
16
16
|
import { skillGrantBindingMembers } from "../skill-grant.js";
|
|
17
17
|
import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
|
|
18
|
-
import {
|
|
18
|
+
import { delegationPoolReading } from "./sub-agent-deny-lists.js";
|
|
19
|
+
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
20
|
+
import { autoStrippedRule, cardDisclosureOf, nearMissSpellingOf, rootFacingToolNames } from "../allow-entry.js";
|
|
19
21
|
import { arbitrateByMode, askClassMembersOf, askFaceOf, askMandateMember } from "../ask-origin.js";
|
|
20
22
|
import { createModeGatePolicy, mountedToolDeclaresReadOnly } from "../mode-policy.js";
|
|
21
23
|
const ancestorFacts = (ask) => ({ ...(ask ?? {}), ancestorResolved: true });
|
|
@@ -28,7 +30,7 @@ import { createLiveSessionRules, createSessionRulePolicy } from "./session-rule-
|
|
|
28
30
|
import { policyThrowLine, reportPolicyThrow } from "./policy-throw.js";
|
|
29
31
|
import { heldBy, heldValues, seatOf, wireOf } from "../tool-name-readings.js";
|
|
30
32
|
export async function preparePolicyChain(input) {
|
|
31
|
-
const { spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight, pathRuleAnchors, headLeads, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, readFace, permissionMode, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
|
|
33
|
+
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, scratchpadDir, toolRosterDeltas, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef } = input;
|
|
32
34
|
const ancestorArbitrations = new Map();
|
|
33
35
|
const arbitrateInherited = (ask, toolCallId, judged) => {
|
|
34
36
|
const verdict = arbitrateByMode(permissionMode.current, judged.classification, { origin: judged.origin, ...askMandateMember(ancestorFacts(judged.ask.action === "ask" ? judged.ask : undefined)) });
|
|
@@ -40,32 +42,40 @@ export async function preparePolicyChain(input) {
|
|
|
40
42
|
return { action: "deny", message: `refused by the ${verdict.mode} permission mode at an inherited ancestor layer (${verdict.askClass})`, decisionReason: "mode" };
|
|
41
43
|
};
|
|
42
44
|
const policy = lockedPreflight.toolPolicy;
|
|
43
|
-
const auditPolicyNames = (auditee) => {
|
|
45
|
+
const auditPolicyNames = (auditee, inherited = false) => {
|
|
44
46
|
const nameGroups = toolPolicyNameSets(auditee);
|
|
45
47
|
if (nameGroups.length > 0) {
|
|
46
48
|
const known = mountedToolNames(tools);
|
|
47
49
|
for (const t of harnessTools)
|
|
48
50
|
known.add(t.name);
|
|
51
|
+
const pool = delegationPoolReading(spec.tools ?? [], valveLeaves(spec, selector));
|
|
52
|
+
const callerNames = mountedToolNames(spec.tools ?? []);
|
|
53
|
+
const rootFacing = rootFacingToolNames([...known, ...callerNames, ...pool.names]);
|
|
49
54
|
const unmatched = new Set();
|
|
50
55
|
for (const g of nameGroups) {
|
|
51
56
|
for (const [kind, list] of [["deny", g.deny], ["ask", g.ask], ["allow", g.allow]]) {
|
|
52
57
|
for (const n of list ?? []) {
|
|
53
58
|
const verdict = judgeRuleToolName(n, known);
|
|
54
|
-
|
|
59
|
+
const twin = verdict.kind === "current" && !inherited ? nearMissSpellingOf(n, rootFacing) : undefined;
|
|
60
|
+
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;
|
|
61
|
+
if (stale !== undefined) {
|
|
55
62
|
const entry = `tool policy ${kind}-list entry "${n}"`;
|
|
56
63
|
let message;
|
|
57
|
-
switch (
|
|
64
|
+
switch (stale.kind) {
|
|
58
65
|
case "retired":
|
|
59
|
-
message = `${entry} is a RETIRED tool name (${
|
|
66
|
+
message = `${entry} is a RETIRED tool name (${stale.guidance}) and matches nothing in this run's roster — legacy-name normalization was removed (RB-476-A), so this entry would silently guard nothing. Update the deployment's rule to the current name.`;
|
|
60
67
|
break;
|
|
61
68
|
case "unprefixed_namespace":
|
|
62
69
|
message = `${entry} carries the "__" namespace separator but no protocol prefix, and matches nothing in this run's roster — protocol tools are named ${NAMESPACED_NAME_SHAPES}, and legacy-name normalization was removed (RB-476-A), so this entry would silently guard nothing. Prefix the entry with the owning protocol's marker.`;
|
|
63
70
|
break;
|
|
64
71
|
case "unmintable_segment":
|
|
65
|
-
message = `${entry} can match no tool, ever (${
|
|
72
|
+
message = `${entry} can match no tool, ever (${stale.guidance}), so it would silently guard nothing.${stale.currentName !== undefined ? ` Write "${stale.currentName}".` : ""}`;
|
|
73
|
+
break;
|
|
74
|
+
case "case_twin":
|
|
75
|
+
message = `${entry} differs from ${stale.carrier === "run" ? "the mounted tool" : stale.carrier === "pool" ? "the tool a delegation pool carries" : "the engine's catalog tool"} "${stale.twin}" only in case, and a policy compares tool names exactly, so it matches nothing in this run's roster and would silently guard nothing. Write "${stale.twin}".`;
|
|
66
76
|
break;
|
|
67
77
|
default: {
|
|
68
|
-
const exhaustive =
|
|
78
|
+
const exhaustive = stale;
|
|
69
79
|
return exhaustive;
|
|
70
80
|
}
|
|
71
81
|
}
|
|
@@ -111,7 +121,7 @@ export async function preparePolicyChain(input) {
|
|
|
111
121
|
catch {
|
|
112
122
|
}
|
|
113
123
|
};
|
|
114
|
-
const announceEarlierGrammar = (rulesSessionId) => (entries) => deps.
|
|
124
|
+
const announceEarlierGrammar = (rulesSessionId) => (entries, field, grammar) => deliverEngineNotice(deps.onNotice, earlierGrammarNotice({ rulesSessionId, sessionId, entries, field, grammar }));
|
|
115
125
|
let sessionRulePolicy;
|
|
116
126
|
if (deps.sessionPolicyStore && spec.sessionId) {
|
|
117
127
|
const store = deps.sessionPolicyStore;
|
|
@@ -156,31 +166,12 @@ export async function preparePolicyChain(input) {
|
|
|
156
166
|
check: (creq) => checkToolPolicyProjection(entry, creq) ?? { action: "allow" },
|
|
157
167
|
}));
|
|
158
168
|
const narrowingLayers = [sessionRulePolicy, ...ancestorRulePolicies, ...frozenConstraintLayers].filter((p) => p !== undefined);
|
|
159
|
-
|
|
160
|
-
|
|
169
|
+
auditPolicyNames(sessionRulePolicy);
|
|
170
|
+
for (const layer of ancestorRulePolicies)
|
|
171
|
+
auditPolicyNames(layer, true);
|
|
161
172
|
const denyNarrowingPolicy = narrowingLayers.length === 0 ? undefined : narrowingLayers.length === 1 ? narrowingLayers[0] : combinePolicies(...narrowingLayers);
|
|
162
173
|
const basePolicyForResumeEdit = lockedPreflight.basePolicyForResumeEdit ?? lockedPreflight.toolPolicy;
|
|
163
|
-
const
|
|
164
|
-
assertHookSeatsCallable(hooks, spec.hooks !== undefined ? "spec" : "deps");
|
|
165
|
-
const hookTimeoutMs = resolveHookTimeoutMs(hooks?.timeoutMs, notifyOwnHookCrash, hooks);
|
|
166
|
-
const preToolUseObservational = hooks?.preToolUse !== undefined && hooks.preToolUseObservational === true;
|
|
167
|
-
const ownGatePreToolUse = !preToolUseObservational
|
|
168
|
-
? hooks?.preToolUse
|
|
169
|
-
: async (toolName, input, ctx) => {
|
|
170
|
-
const r = await hooks.preToolUse(toolName, cloneObserverInput(input), ctx);
|
|
171
|
-
if (r === undefined)
|
|
172
|
-
return undefined;
|
|
173
|
-
try {
|
|
174
|
-
const action = typeof r.action === "string" ? r.action : "(non-string action)";
|
|
175
|
-
deps.onError?.(new Error(`a PreToolUse hook declared observational (Hooks.preToolUseObservational) returned a decision ("${action}") while screening ` +
|
|
176
|
-
`"${toolName}" — the decision was NOT adopted and the call proceeded as if the hook had no opinion. ` +
|
|
177
|
-
`A declared-observational face must return undefined; drop the declaration if its verdicts are meant to count ` +
|
|
178
|
-
`(they then also travel to delegated children as an inherited screening constraint).`), { phase: "hook", sessionId, classification: "observational-hook-verdict-ignored" });
|
|
179
|
-
}
|
|
180
|
-
catch {
|
|
181
|
-
}
|
|
182
|
-
return undefined;
|
|
183
|
-
};
|
|
174
|
+
const ownChainJudges = chainJudges(modBus);
|
|
184
175
|
const sameInstanceAncestorCount = policy === undefined ? 0 : (inheritedParentConstraints ?? []).reduce((n, pc) => (pc.policy === policy ? n + 1 : n), 0);
|
|
185
176
|
const sharedFirstDecision = new Map();
|
|
186
177
|
const SHARED_FIRST_DECISION_CAP = 256;
|
|
@@ -354,7 +345,7 @@ export async function preparePolicyChain(input) {
|
|
|
354
345
|
const recheckApprovedEdit = async (pol, onAskOf, creq, edit, approved, csignal, ancestorAutoMode) => {
|
|
355
346
|
const ancestorDecider = ancestorAutoMode?.decider;
|
|
356
347
|
const ancestorTracker = ancestorAutoMode?.denialTracking;
|
|
357
|
-
let editArgs = edit;
|
|
348
|
+
let editArgs = argsAsTheToolReads(creq, edit);
|
|
358
349
|
let settledBy = approved;
|
|
359
350
|
const onApproval = (d) => withAttestation(d, mergeAttestation(creq, attestationOf(settledBy, creq), attestationOf(d, creq), "answer"));
|
|
360
351
|
const vetoed = onApproval;
|
|
@@ -367,8 +358,7 @@ export async function preparePolicyChain(input) {
|
|
|
367
358
|
}
|
|
368
359
|
let re;
|
|
369
360
|
try {
|
|
370
|
-
|
|
371
|
-
re = refuseOutOfContractDecision(await pol.check(editReq !== undefined ? await editReq : { ...creq, args: editArgs }, csignal ?? abortController.signal));
|
|
361
|
+
re = refuseOutOfContractDecision(await pol.check(await withArgsReading(creq, editArgs, csignal ?? abortController.signal), csignal ?? abortController.signal));
|
|
372
362
|
}
|
|
373
363
|
catch (err) {
|
|
374
364
|
reportPolicyThrow(notifyOwnHookCrash, "an inherited parent policy's re-check of the approved edit", creq, err, csignal ?? abortController.signal);
|
|
@@ -384,7 +374,7 @@ export async function preparePolicyChain(input) {
|
|
|
384
374
|
return onApproval(withAttestation({ action: "allow", updatedInput: re.updatedInput !== undefined ? re.updatedInput : editArgs, ...(stated !== undefined ? { decisionReason: stated } : {}) }, re.attestation));
|
|
385
375
|
}
|
|
386
376
|
if (re.updatedInput !== undefined)
|
|
387
|
-
editArgs = re.updatedInput;
|
|
377
|
+
editArgs = argsAsTheToolReads(creq, re.updatedInput);
|
|
388
378
|
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: ancestorAutoMode, ask: re, req: { ...creq, args: 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 }) });
|
|
389
379
|
if (judged.kind === "allow") {
|
|
390
380
|
return onApproval(judged.result);
|
|
@@ -419,17 +409,69 @@ export async function preparePolicyChain(input) {
|
|
|
419
409
|
settledBy = rr;
|
|
420
410
|
if (rr.updatedInput === undefined)
|
|
421
411
|
return onApproval({ action: "allow", updatedInput: editArgs, decisionReason: "mode" });
|
|
422
|
-
editArgs = rr.updatedInput;
|
|
412
|
+
editArgs = argsAsTheToolReads(creq, rr.updatedInput);
|
|
423
413
|
}
|
|
424
414
|
};
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
415
|
+
const settleInstallationAsk = async (pc, decision, creq, csignal) => {
|
|
416
|
+
const settledAs = (result) => ({ kind: "settled", result });
|
|
417
|
+
if (isDelegatedQuestion(creq)) {
|
|
418
|
+
if (pc.contentMandate !== true || markInheritedUnavailable(creq.toolCallId))
|
|
419
|
+
return settledAs(decision);
|
|
420
|
+
return settledAs({
|
|
421
|
+
action: "deny",
|
|
422
|
+
message: `inherited parent policy requires durable handling of the question raised for "${creq.toolName}" and the marker channel is at capacity — ` +
|
|
423
|
+
`denied fail-closed (tighten-only)`,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
if (pc.durableMandate === true) {
|
|
427
|
+
if (mandatedCallFloats(creq.toolCallId))
|
|
428
|
+
return settledAs(decision);
|
|
429
|
+
return settledAs(mandateUnreconstructibleDeny(creq));
|
|
430
|
+
}
|
|
431
|
+
const presentedArgs = decision.updatedInput !== undefined ? argsAsTheToolReads(creq, decision.updatedInput) : creq.args;
|
|
432
|
+
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: { ...creq, args: 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 }) });
|
|
433
|
+
if (judged.kind === "allow")
|
|
434
|
+
return settledAs(judged.result);
|
|
435
|
+
if (judged.kind === "deny")
|
|
436
|
+
return settledAs(judged.result);
|
|
437
|
+
const { ask: inheritedAsk, fallback } = judged;
|
|
438
|
+
if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
|
|
439
|
+
recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
|
|
440
|
+
return settledAs(decision.updatedInput !== undefined ? { action: "allow", updatedInput: decision.updatedInput, decisionReason: "sandbox" } : { action: "allow", decisionReason: "sandbox" });
|
|
441
|
+
}
|
|
442
|
+
const arbitrated = arbitrateInherited(inheritedAsk.action === "ask" ? { ...inheritedAsk, ...(decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {}) } : inheritedAsk, creq.toolCallId, judged);
|
|
443
|
+
if (arbitrated !== undefined)
|
|
444
|
+
return settledAs(arbitrated);
|
|
445
|
+
const askT0 = now();
|
|
446
|
+
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
|
|
447
|
+
toolName: creq.toolName,
|
|
448
|
+
toolCallId: creq.toolCallId,
|
|
449
|
+
args: presentedArgs,
|
|
450
|
+
...ruleOffersOf(creq, presentedArgs, ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
451
|
+
...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
|
|
452
|
+
...askSourceIdentity(),
|
|
453
|
+
...riskAxesOf(creq),
|
|
454
|
+
...approvalCardMemberOf(creq),
|
|
455
|
+
...grantBindingOf(creq, presentedArgs),
|
|
456
|
+
...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
457
|
+
...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
458
|
+
...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
|
|
459
|
+
ruleEvidence: inheritedAskEvidence,
|
|
460
|
+
}, 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));
|
|
461
|
+
void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
|
|
462
|
+
const askWaitMs = Math.max(0, now() - askT0);
|
|
463
|
+
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
464
|
+
if (markInheritedUnavailable(creq.toolCallId))
|
|
465
|
+
return settledAs(settled.ask);
|
|
466
|
+
return settledAs(markerChannelFullDeny(creq));
|
|
467
|
+
}
|
|
468
|
+
settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
469
|
+
if (resolved.action !== "allow")
|
|
470
|
+
return settledAs(resolved);
|
|
471
|
+
return { kind: "approved", resolved, askWaitMs, classes: askClassMembersOf(judged.classification).classes };
|
|
472
|
+
};
|
|
473
|
+
const legStandsIn = (pc) => standsInFor(pc, { chain: ownModChain, onAsk: frozenOnAsk, hookEnv: hookEnvSource, decider: autoModeDecider() }, ownChainJudges);
|
|
474
|
+
const parentConstraintWrappers = (inheritedParentConstraints ?? []).map((pc) => legStandsIn(pc)
|
|
433
475
|
? { check: () => ({ action: "allow" }) }
|
|
434
476
|
: policy !== undefined && pc.policy === policy
|
|
435
477
|
? {
|
|
@@ -521,70 +563,24 @@ export async function preparePolicyChain(input) {
|
|
|
521
563
|
}
|
|
522
564
|
if (decision.action !== "ask")
|
|
523
565
|
return decision;
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
action: "deny",
|
|
529
|
-
message: `inherited parent policy requires durable handling of the question raised for "${creq.toolName}" and the marker channel is at capacity — ` +
|
|
530
|
-
`denied fail-closed (tighten-only)`,
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
if (pc.durableMandate === true) {
|
|
534
|
-
if (mandatedCallFloats(creq.toolCallId))
|
|
535
|
-
return decision;
|
|
536
|
-
return mandateUnreconstructibleDeny(creq);
|
|
537
|
-
}
|
|
538
|
-
const presentedArgs = decision.updatedInput !== undefined ? decision.updatedInput : creq.args;
|
|
539
|
-
const judged = await judgeInheritedClassifier({ liveMode: () => permissionMode.current, autoMode: pc.autoMode, ask: decision, req: { ...creq, args: 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 }) });
|
|
540
|
-
if (judged.kind === "allow")
|
|
541
|
-
return judged.result;
|
|
542
|
-
if (judged.kind === "deny")
|
|
543
|
-
return judged.result;
|
|
544
|
-
const { ask: inheritedAsk, fallback } = judged;
|
|
545
|
-
if (fallback === undefined && sandboxAdmissionArmed && policyAskClassOf(pc.policy) === "sandbox_local" && !sandboxBoundaryCapable(creq) && judged.classification.row.sandboxAdmission) {
|
|
546
|
-
recordAncestorSandboxAdmission(creq.toolCallId, creq.toolName);
|
|
547
|
-
return decision.updatedInput !== undefined ? { action: "allow", updatedInput: decision.updatedInput, decisionReason: "sandbox" } : { action: "allow", decisionReason: "sandbox" };
|
|
548
|
-
}
|
|
549
|
-
const arbitrated = arbitrateInherited(inheritedAsk.action === "ask" ? { ...inheritedAsk, ...(decision.updatedInput !== undefined ? { updatedInput: decision.updatedInput } : {}) } : inheritedAsk, creq.toolCallId, judged);
|
|
550
|
-
if (arbitrated !== undefined)
|
|
551
|
-
return arbitrated;
|
|
552
|
-
const askT0 = now();
|
|
553
|
-
const { resolved, judged: settled } = await resolveInheritedAsk(judged, (j) => resolveAsk({
|
|
554
|
-
toolName: creq.toolName,
|
|
555
|
-
toolCallId: creq.toolCallId,
|
|
556
|
-
args: presentedArgs,
|
|
557
|
-
...ruleOffersOf(creq, presentedArgs, ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
558
|
-
...cardDisclosureOf(j.ask, inheritedAskFallbackMessage(creq.toolName)),
|
|
559
|
-
...askSourceIdentity(),
|
|
560
|
-
...riskAxesOf(creq),
|
|
561
|
-
...approvalCardMemberOf(creq),
|
|
562
|
-
...grantBindingOf(creq, presentedArgs),
|
|
563
|
-
...(j.ask.action === "ask" && j.ask.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
564
|
-
...askMandateMember(ancestorFacts(j.ask.action === "ask" ? j.ask : undefined)),
|
|
565
|
-
...inheritedAskCarry(j, isLiveApproverSeat(pc.onAsk), pc.autoMode?.denialTracking),
|
|
566
|
-
ruleEvidence: inheritedAskEvidence,
|
|
567
|
-
}, 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));
|
|
568
|
-
void settleReadRootGrant(resolved.readRootGrant, undefined, { toolName: creq.toolName, toolCallId: creq.toolCallId, sessionId, runId, ...(spec.taskId !== undefined ? { taskId: spec.taskId } : {}), onNotice: deps.onNotice });
|
|
569
|
-
const askWaitMs = Math.max(0, now() - askT0);
|
|
570
|
-
if (resolved.action === "deny" && resolved.approverUnavailable === true) {
|
|
571
|
-
if (markInheritedUnavailable(creq.toolCallId))
|
|
572
|
-
return settled.ask;
|
|
573
|
-
return markerChannelFullDeny(creq);
|
|
574
|
-
}
|
|
575
|
-
settleDenialLimitFallback({ fallback: settled.fallback, mintedHere: settled.mintedHere, tracker: pc.autoMode?.denialTracking, resolved, headless: headlessDenyAtFold, stop: stopForDenialLimit, toolName: creq.toolName, toolCallId: creq.toolCallId });
|
|
576
|
-
if (resolved.action !== "allow")
|
|
577
|
-
return resolved;
|
|
566
|
+
const settled = await settleInstallationAsk(pc, decision, creq, csignal);
|
|
567
|
+
if (settled.kind === "settled")
|
|
568
|
+
return settled.result;
|
|
569
|
+
const { resolved } = settled;
|
|
578
570
|
if (resolved.updatedInput !== undefined) {
|
|
579
571
|
return recheckApprovedEdit(pc.policy, pc.onAsk, creq, resolved.updatedInput, resolved, csignal, pc.autoMode);
|
|
580
572
|
}
|
|
581
|
-
if (pc.
|
|
582
|
-
recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, askWaitMs, resolved,
|
|
573
|
+
if (screeningInstallationsOf([pc]).length === 0) {
|
|
574
|
+
recordInheritedAskGrant(creq.toolCallId, pc.onAsk, resolved.presentedInput, settled.askWaitMs, resolved, settled.classes);
|
|
583
575
|
}
|
|
584
576
|
if (decision.updatedInput === undefined)
|
|
585
577
|
return resolved;
|
|
586
578
|
return { ...resolved, updatedInput: decision.updatedInput };
|
|
587
579
|
}));
|
|
580
|
+
const installationToolChecks = inheritedToolChecks(inheritedParentConstraints ?? [], legStandsIn, (pc) => async (ask, creq, csignal) => {
|
|
581
|
+
const settled = await settleInstallationAsk(pc, ask, creq, csignal);
|
|
582
|
+
return settled.kind === "settled" ? settled.result : settled.resolved;
|
|
583
|
+
});
|
|
588
584
|
const rewriteCapableLayers = policy !== undefined || parentConstraintWrappers.length > 0;
|
|
589
585
|
const rewriteEmitterIndex = new Map();
|
|
590
586
|
const rewriteCapableChain = [
|
|
@@ -640,8 +636,7 @@ export async function preparePolicyChain(input) {
|
|
|
640
636
|
}
|
|
641
637
|
}
|
|
642
638
|
const recheckLayers = [...recheckPrefix, ...postEmitterSameInstanceAdapters];
|
|
643
|
-
const
|
|
644
|
-
const finalReq = finalRead !== undefined ? await finalRead : { ...req, args: decision.updatedInput };
|
|
639
|
+
const finalReq = await withArgsReading(req, decision.updatedInput, signal);
|
|
645
640
|
let asked;
|
|
646
641
|
let revalidated;
|
|
647
642
|
let restated;
|
|
@@ -678,7 +673,7 @@ export async function preparePolicyChain(input) {
|
|
|
678
673
|
return decision;
|
|
679
674
|
})
|
|
680
675
|
: foldedPolicy;
|
|
681
|
-
return {
|
|
676
|
+
return { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedToolChecks: installationToolChecks };
|
|
682
677
|
}
|
|
683
678
|
const advisedPolicyNames = new WeakMap();
|
|
684
679
|
const ADVISED_KEYS_CAP = 64;
|
|
@@ -14,7 +14,7 @@ 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). Never mutated. */
|
|
17
|
-
spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal">;
|
|
17
|
+
spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal" | "excludeAllTools">;
|
|
18
18
|
/** borrowed-readonly — trusted internals: `agentName` (seam ctx), `inheritedSkillGrants` (the parent's captured
|
|
19
19
|
* skill grant rows, seeded as `inherited`), `inheritedAllowedTools` (the parent's request entries, seeded as this leg's
|
|
20
20
|
* own). `undefined` on a standalone prepare. */
|
|
@@ -8,14 +8,17 @@ import { defineTool } from "../tools.js";
|
|
|
8
8
|
import { readFrozenSkillGrants, seedSkillGrants, skillSeatReader } from "../skill-grant.js";
|
|
9
9
|
import { allowedToolsNotGrantedNotice, seedAllowEntryTables } from "../allow-entry.js";
|
|
10
10
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
11
|
+
import { announceMemoryNotMounted } from "./announce-once-ledger.js";
|
|
11
12
|
import { SKILL_CONTENT_MAX_CHARS, SKILL_TOOL_NAME, createSkillTool, normalizeSkills } from "./synthetic-tools.js";
|
|
12
13
|
import { skillLoadReading } from "./skill-base-dir.js";
|
|
13
14
|
import { RosterBuilder } from "../tool-roster.js";
|
|
14
15
|
import { mountedToolNames } from "../tool-name-aliases.js";
|
|
16
|
+
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
15
17
|
import { asThrownError } from "../thrown-value.js";
|
|
16
18
|
export async function prepareProjectContext(input) {
|
|
17
19
|
const { deps, spec, internals, session, sessionId, runId, hostTaskId, taskRootFinal, handsEnabled, delegation, seedContextFiles, memoryBlockFromEngine, skillGrants, allowedTools, allowedToolTables, roster, toolFaceSnapshot, onceLedger, memoryTools, memoryEngineSession, memorySearchToolsPlanned, memoryPairExcludedName, memoryPairOccupiedName, resume, skillListingBudget } = input;
|
|
18
20
|
const tools = roster.tools;
|
|
21
|
+
const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
19
22
|
let memoryBlock = memoryBlockFromEngine;
|
|
20
23
|
let instructionSources;
|
|
21
24
|
let projectInstructionContent;
|
|
@@ -114,14 +117,12 @@ export async function prepareProjectContext(input) {
|
|
|
114
117
|
for (const alias of t.aliases ?? [])
|
|
115
118
|
mountedNameDomain.add(alias);
|
|
116
119
|
}
|
|
117
|
-
const excludedName = SHARED_MEMORY_TOOL_NAMES.find((n) => !
|
|
120
|
+
const excludedName = SHARED_MEMORY_TOOL_NAMES.find((n) => !leaves({ name: n }));
|
|
118
121
|
const occupiedName = SHARED_MEMORY_TOOL_NAMES.find((n) => mountedNameDomain.has(n));
|
|
119
122
|
if (excludedName !== undefined || occupiedName !== undefined) {
|
|
120
|
-
onceLedger
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
: `this task already declares a tool named "${occupiedName}" (the built-in yields to it)`) +
|
|
124
|
-
" — the pair mounts together or not at all."), { phase: "config", sessionId, classification: "shared-memory-not-mounted" });
|
|
123
|
+
announceMemoryNotMounted(onceLedger, sessionId, "shared", SHARED_MEMORY_TOOL_NAMES, excludedName !== undefined
|
|
124
|
+
? `the run's tool face (allowTools / excludeTools / excludeAllTools) does not admit "${excludedName}"`
|
|
125
|
+
: `this task already declares a tool named "${occupiedName}" (the built-in yields to it)`);
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
128
|
roster.mountAll(createSharedMemoryTools({
|
|
@@ -137,13 +138,11 @@ export async function prepareProjectContext(input) {
|
|
|
137
138
|
memoryEnginePairMounted = true;
|
|
138
139
|
}
|
|
139
140
|
else if (memoryEngineSession !== undefined && !memorySearchToolsPlanned) {
|
|
140
|
-
onceLedger
|
|
141
|
-
(
|
|
142
|
-
|
|
143
|
-
: `this task already declares a tool named "${memoryPairOccupiedName}" (the built-in yields to it)`) +
|
|
144
|
-
" — these tools mount together or not at all."), { phase: "config", sessionId, classification: "memory-tools-not-mounted" });
|
|
141
|
+
announceMemoryNotMounted(onceLedger, sessionId, "engine", MEMORY_ENGINE_TOOL_NAMES, memoryPairExcludedName !== undefined
|
|
142
|
+
? `the run's tool face (allowTools / excludeTools / excludeAllTools) does not admit "${memoryPairExcludedName}"`
|
|
143
|
+
: `this task already declares a tool named "${memoryPairOccupiedName}" (the built-in yields to it)`);
|
|
145
144
|
}
|
|
146
|
-
const skillsListing = skillSpecs.length > 0
|
|
145
|
+
const skillsListing = skillSpecs.length > 0 && leaves({ name: SKILL_TOOL_NAME })
|
|
147
146
|
? {
|
|
148
147
|
entries: skillSpecs.map((s) => ({
|
|
149
148
|
name: s.name,
|