@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
package/dist/core/hooks.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ActorAssertion, DocumentContent, ImageContent, TextContent } from "../internal/llm.js";
|
|
2
2
|
import type { ExecutionEnv, FileError, Result, SessionTreeEntry } from "../internal/harness-types.js";
|
|
3
|
-
import type { DecisionReason, PermissionResult, ResolvedAsk, ToolCallFace, ToolCallRequest
|
|
3
|
+
import type { DecisionReason, PermissionResult, ResolvedAsk, ToolCallFace, ToolCallRequest } from "./tool-policy.js";
|
|
4
4
|
import { type CallTargetStamp } from "./effective-path-target.js";
|
|
5
|
-
import type { GateOutcome } from "./gate-outcome.js";
|
|
5
|
+
import type { ClassifierDenyCause, DeniedBy, GateOutcome } from "./gate-outcome.js";
|
|
6
6
|
import { type PreToolUseScreening } from "./runner/gate-exit.js";
|
|
7
7
|
export { normalizeOrgGateVerdict, normalizePersistedRuleHit } from "./rule-lane-reads.js";
|
|
8
|
-
import {
|
|
8
|
+
import type { AskClass } from "./ask-class.js";
|
|
9
9
|
import { type PermissionMode } from "./ask-origin.js";
|
|
10
10
|
import { type AutoModeDenialTracker } from "./auto-mode.js";
|
|
11
11
|
export { formatHookFeedback } from "./reminder-mint.js";
|
|
@@ -100,8 +100,11 @@ export interface PostToolBatchEvent extends ClassicEventBase {
|
|
|
100
100
|
readonly injectedThisTurn?: "final_verification" | "finalize";
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
* `classic.UserPromptSubmit`'s `e` — EVERY user-lane entrance:
|
|
104
|
-
* (pre-claim, at the verb) and a parked steer's redelivery, discriminated by {@link source}.
|
|
103
|
+
* `classic.UserPromptSubmit`'s `e` — EVERY user-lane entrance: a top-level leg's objective, a live steer, a wake resume's
|
|
104
|
+
* message (pre-claim, at the verb) and a parked steer's redelivery, discriminated by {@link source}. A delegated child's
|
|
105
|
+
* objective is one only when it carries an operator's words (a retained child resumed through its steer handle);
|
|
106
|
+
* otherwise its delegator wrote it, the screen that can refuse it is the delegator's `classic.PreToolUse` on the call that
|
|
107
|
+
* delegates (its `input.prompt`), and the child opens on `classic.SubagentStart` ({@link SubagentStartEvent}). Pinned: `source`,
|
|
105
108
|
* `inputId`, `actor`. A handler that blocks unconditionally therefore refuses steers too — branch on `source` (and
|
|
106
109
|
* `actor`). Answer: {@link UserPromptSubmitResult}. Block per entrance: objective ⇒ the task ends `blocked`; live steer
|
|
107
110
|
* ⇒ typed `steering.blocked_by_hook`; resume message ⇒ typed pre-claim refusal (the checkpoint stays pending); parked
|
|
@@ -114,7 +117,7 @@ export interface UserPromptSubmitEvent extends ClassicEventBase {
|
|
|
114
117
|
/** The caller's text, raw. */
|
|
115
118
|
readonly prompt: string;
|
|
116
119
|
/**
|
|
117
|
-
* WHICH entrance: `"objective"` (
|
|
120
|
+
* WHICH entrance: `"objective"` (a top-level task's opening prompt), `"steer"` (a live mid-run steer), `"resume_message"`
|
|
118
121
|
* (a wake resume's message, screened pre-claim), `"parked_redelivery"` (a parked steer re-screened on the CURRENT
|
|
119
122
|
* process when any resume kind that drains parked steers redelivers it). ⚠️ DOUBLE ARRIVAL IS CONTRACTUAL: one input
|
|
120
123
|
* can arrive twice (screened live as `"steer"`, parked, re-screened as `"parked_redelivery"`) — idempotency is the
|
|
@@ -140,6 +143,31 @@ export interface UserPromptSubmitEvent extends ClassicEventBase {
|
|
|
140
143
|
*/
|
|
141
144
|
readonly userAttachments?: readonly import("./user-attachment.js").UserAttachmentDeclaration[];
|
|
142
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* `classic.SubagentStart`'s `e` — raised on a delegated child's own leg when it opens on its objective (a first spawn,
|
|
148
|
+
* a revival, a retained child's next prompt; every lane — synchronous, background, fork, workflow), before its first
|
|
149
|
+
* request; never on a top-level leg and never on a checkpoint resume (that continues a turn it already opened). The
|
|
150
|
+
* child's prompt is not here: its parent's model wrote it, and the parent's `classic.PreToolUse` on the delegating call
|
|
151
|
+
* is where it is judged. Pinned: `agentId`, `agentType`. Context only — it NEVER keeps a subagent from starting: a
|
|
152
|
+
* handler that fails (throws, overruns its budget, answers what the station cannot take) is skipped and reported.
|
|
153
|
+
* Answer: {@link SubagentStartResult}.
|
|
154
|
+
*/
|
|
155
|
+
export interface SubagentStartEvent extends ClassicEventBase {
|
|
156
|
+
/** The child's id (its task id) — always present on this event. */
|
|
157
|
+
readonly agentId: string;
|
|
158
|
+
/** The resolved subagent type the child was spawned as ({@link HookInvocationIdentity.agentType}; the word a handler
|
|
159
|
+
* matches on). Absent when the spawner threaded none (a workflow-lane agent). */
|
|
160
|
+
readonly agentType?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* What a `classic.SubagentStart` handler answers. There is no refusal member: an answer carrying `block` is one the
|
|
164
|
+
* station cannot take (the handler is skipped and reported, the child starts) — a deployment that must keep a child from
|
|
165
|
+
* starting denies the delegating call at `classic.PreToolUse`.
|
|
166
|
+
*/
|
|
167
|
+
export interface SubagentStartResult {
|
|
168
|
+
/** Delivered ahead of the child's prompt in its first request (wrapped as a `<system-reminder>`). */
|
|
169
|
+
additionalContext?: string;
|
|
170
|
+
}
|
|
143
171
|
/**
|
|
144
172
|
* `classic.Stop`'s `e` — raised when the agent WOULD OTHERWISE END its run (no more tool calls, steering and follow-up
|
|
145
173
|
* queues dry). Answer: {@link StopHookResult}; `{ block }` pushes back (the reason is injected and the run continues one
|
|
@@ -410,9 +438,8 @@ export declare function createHookEnvCapabilities(env: ExecutionEnv): HookEnvCap
|
|
|
410
438
|
* ({@link mintHookInvocationIdentity} — single mint home) and every station reuses it.
|
|
411
439
|
* · HONESTLY ABSENT (no fabrication) where the engine structurally cannot know:
|
|
412
440
|
* 1. a HOST driving the exported {@link runToolGate} directly without supplying `ToolGateInput.identity`;
|
|
413
|
-
* 2.
|
|
414
|
-
*
|
|
415
|
-
* 3. a deployment driving the compaction module directly with its own `preCompact`/`postCompact` options.
|
|
441
|
+
* 2. a deployment driving the compaction module directly with its own `preCompact`/`postCompact` options.
|
|
442
|
+
* (An ancestor's installation judging a DESCENDANT's call carries the descendant's envelope: the e is the judged leg's.)
|
|
416
443
|
*
|
|
417
444
|
* CONSUMER NOTE — the minted object is FROZEN and carries a NULL PROTOTYPE (same rule and same
|
|
418
445
|
* trade as {@link HookEnvCapabilities}: absence must be a fact about this object, not about what
|
|
@@ -502,8 +529,9 @@ export interface HookToolOutput {
|
|
|
502
529
|
* whole hook result; the concurrent arm never carried it, so the two arms disagreed on a member neither
|
|
503
530
|
* of them reads. Nothing in the engine reads it off a decision.
|
|
504
531
|
*
|
|
505
|
-
* PreToolUse lane × settlement table (the gate's phase 1 in {@link runToolGate}
|
|
506
|
-
* {@link
|
|
532
|
+
* PreToolUse lane × settlement table (the gate's phase 1 in {@link runToolGate}, for the leg's own bus; an inherited
|
|
533
|
+
* installation's words are read in {@link createPreToolUseScreening}: its ask goes to its own frozen regime, its allow is no
|
|
534
|
+
* objection, its deny and its failure are as below). "Held" = the ask survives to a person:
|
|
507
535
|
* neither an allow rule (`decisionReason: "hook"` is outside the allow layer) nor the classifier (hook asks are
|
|
508
536
|
* never classifier-answerable) clears it.
|
|
509
537
|
* · returns `allow` (± `updatedInput` / `additionalContext`) → the face's own word (`hookAllowedBy`, naming the registration); the policy
|
|
@@ -755,12 +783,14 @@ export interface ToolGateInput extends PermissionSeatInputs, SkillGateSeats, All
|
|
|
755
783
|
* the call fail-closed (the event's failure column), and so does a cancel; an observe handler never decides.
|
|
756
784
|
*/
|
|
757
785
|
modBus?: Pick<import("./mods/kernel/index.js").ModBus, "hasHandlers" | "dispatch">;
|
|
758
|
-
/** The inherited installations
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
|
|
786
|
+
/** The inherited installations that judge this leg's calls too (`inheritedInstallations`, the rule's one home), each on its
|
|
787
|
+
* own bus after {@link modBus}: `classic.PreToolUse` at phase 1 (and at every re-screen), with this leg's identity and the
|
|
788
|
+
* installation's environment; `tool.check` at the verdict read, each over the verdict the previous left standing. On both
|
|
789
|
+
* events their `deny` is the hook's own refusal, their `allow` never clears an ask (an installation answers only its own
|
|
790
|
+
* leg's questions; it is disclosed as the `hook` member's shadow), and their `ask` goes to each installation's own `settle`
|
|
791
|
+
* (where its installation froze the question), never to this gate's resolver; an approval there that edits the call takes
|
|
792
|
+
* this gate's approved-edit pass. Absent ⇒ only {@link modBus} is raised. */
|
|
793
|
+
inheritedInstallations?: readonly import("./mods/stations.js").InheritedInstallation[];
|
|
764
794
|
/** The leg's observed permission mode, carried on every `classic.PreToolUse` e this gate call raises. Absent ⇒ the e
|
|
765
795
|
* carries none (a host-driven gate with no leg seat). */
|
|
766
796
|
observedPermissionMode?: () => PermissionMode;
|
|
@@ -1254,7 +1284,7 @@ export interface ToolGateInput extends PermissionSeatInputs, SkillGateSeats, All
|
|
|
1254
1284
|
};
|
|
1255
1285
|
/**
|
|
1256
1286
|
* F-012 L2 — the SANDBOX ADMISSION leg. Present ONLY when the runner armed the mode: the execution
|
|
1257
|
-
* env DECLARES isolation (`
|
|
1287
|
+
* env DECLARES isolation (`capabilities.isolation === true`, read through `isIsolated` — a Runner-resolved
|
|
1258
1288
|
* fact, never caller self-report) AND the park prerequisites hold (durable park configured + a wired
|
|
1259
1289
|
* checkpoint store — every store carries the required `reopen`, read at its seat). Absent ⇒ the whole step does not
|
|
1260
1290
|
* exist and the decision path is byte-identical to a build without it.
|
|
@@ -1292,52 +1322,33 @@ export interface ToolGateInput extends PermissionSeatInputs, SkillGateSeats, All
|
|
|
1292
1322
|
};
|
|
1293
1323
|
}
|
|
1294
1324
|
/**
|
|
1295
|
-
* The PreToolUse screening face ({@link PreToolUseScreening}) for ONE call — `classic.PreToolUse` raised on the leg's
|
|
1296
|
-
* bus
|
|
1297
|
-
*
|
|
1298
|
-
* approved
|
|
1325
|
+
* The PreToolUse screening face ({@link PreToolUseScreening}) for ONE call — `classic.PreToolUse` raised on the leg's own
|
|
1326
|
+
* bus and then on each inherited installation's ({@link ToolGateInput.inheritedInstallations}), the per-screening e and the
|
|
1327
|
+
* fail-closed sentences, built in ONE place for every site that screens a call: the gate's phase 1, the fold's second look
|
|
1328
|
+
* and the approved-edit re-screens (through {@link runToolGate}'s pass) and the resumed leg's re-screen of an approved call.
|
|
1329
|
+
* Undefined when no handler hangs on the event on any of those buses.
|
|
1299
1330
|
*
|
|
1300
1331
|
* The e: `tool` (the call's wire name), `tool_use_id`, `input` — a deep-frozen copy of the args, so what a handler
|
|
1301
1332
|
* judges is what runs (`input` is pinned; a rewrite is the answer's `updatedInput`) — `agentId` on a delegated leg,
|
|
1302
|
-
* `cwd` (the task's tracked cwd, read per screening), `env` (the capability face), `identity`, `permissionMode`.
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
/**
|
|
1306
|
-
* Fold a leg's `classic.PreToolUse` chain into a {@link ToolPolicy} layer, so the screening a task installed can also
|
|
1307
|
-
* travel down a delegation chain as one more inherited constraint — the constraint MINT. `chain` is the installing
|
|
1308
|
-
* leg's bus; the policy raises `classic.PreToolUse` on it with the handlers that JUDGE (an observe handler never enters
|
|
1309
|
-
* a constraint — the participant filter below is that rule's one home).
|
|
1310
|
-
*
|
|
1311
|
-
* Why a policy and not a second channel: a delegated child already folds each ancestor's caller policy
|
|
1312
|
-
* (`InheritedGate.parentConstraints`), and that fold is where `deny > ask > allow`, the rewrite cascade, the
|
|
1313
|
-
* ancestor-frozen approver and the durable mandate all already live. Expressing the screening in the same shape means
|
|
1314
|
-
* the child gains no new decision channel — the existing fold consumes it — and the tighten-only property is
|
|
1315
|
-
* structural rather than restated.
|
|
1316
|
-
*
|
|
1317
|
-
* The mapping mirrors the gate's own phase 1 decision for decision:
|
|
1318
|
-
* - no opinion, and an `allow` → `allow`, contributing nothing (a constraint only tightens: it clears no question);
|
|
1319
|
-
* - `deny` → `deny` in the fold's own words;
|
|
1320
|
-
* - `ask` → `ask`, stamped `decisionReason:"hook"` (and the mandate, when the answer set it) so every consumer that
|
|
1321
|
-
* distinguishes a screening ask from a policy ask reads the same fact one level down;
|
|
1322
|
-
* - `allow`/`ask` with `updatedInput` → the same rewrite, which the fold cascades and re-checks;
|
|
1323
|
-
* - a failed screening (a handler that threw, ran past its budget or broke the site's contract) or a cancel → the
|
|
1324
|
-
* fail-closed deny, because a screening that cannot answer must not pass the call. The installing leg's bus
|
|
1325
|
-
* already reported a crash or a timeout on that leg's error lane.
|
|
1326
|
-
*
|
|
1327
|
-
* **Idempotency** ({@link combinePolicies}): a layer's `check` may run more than once for a single tool call (the fold
|
|
1328
|
-
* scans past an `ask`, a later rewrite re-runs the prefix, an approved edit is re-adjudicated), so a handler with a side
|
|
1329
|
-
* effect sees that call more than once on those paths. Its own leg's phase 1 has always had the third of these.
|
|
1330
|
-
*
|
|
1331
|
-
* Not carried, and not reconstructible in this shape: `additionalContext` (a policy verdict has no channel for
|
|
1332
|
-
* model-facing text — the context belongs to the run whose gate ran it), the leg identity and the tracked cwd (the
|
|
1333
|
-
* fold's request carries neither, and the installing leg's would name the wrong run), and the phase-1 observer
|
|
1334
|
-
* exclusion (a deny raised here is a fold deny: the descendant's deny observer sees it as `source:"policy"`). `env` is
|
|
1335
|
-
* the capability face of the environment the chain was installed against, captured at the install site.
|
|
1333
|
+
* `cwd` (the task's tracked cwd, read per screening), `env` (the capability face), `identity`, `permissionMode`. On an
|
|
1334
|
+
* inherited installation the e is THIS leg's (its identity, its mode, its cwd — the call being judged) and the `env` is the
|
|
1335
|
+
* environment that installation was installed against; only its judging handlers take part.
|
|
1336
1336
|
*
|
|
1337
|
-
*
|
|
1338
|
-
*
|
|
1337
|
+
* Every installation is one judge of the call, under one answer reading: a failure or a cancel refuses the call
|
|
1338
|
+
* fail-closed, a `deny` refuses it as the hook's own refusal, a rewrite is adopted (an installation that judged the earlier
|
|
1339
|
+
* bytes judges the rewrite once — a verdict covers the bytes it was given; a deny or yet another form there refuses), the
|
|
1340
|
+
* context lines are collected. Its other words differ by WHOSE installation it is: the leg's own `ask` / `allow` is the
|
|
1341
|
+
* leg's (folded by the gate as before); an inherited installation's `ask` is settled under the regime it froze
|
|
1342
|
+
* (`InheritedInstallation.settle`, read through `readSettled` — the pass's ledger): refused ⇒ the call is refused,
|
|
1343
|
+
* approved ⇒ that question is answered, approved with an edit ⇒ the screen ends and the gate's approved-edit pass takes the
|
|
1344
|
+
* edit, floated ⇒ the question stands marked; its `allow` is no objection (an installation answers only its own leg's
|
|
1345
|
+
* questions), disclosed beside the leg's own hook member.
|
|
1339
1346
|
*/
|
|
1340
|
-
export declare function
|
|
1347
|
+
export declare function createPreToolUseScreening(input: Pick<ToolGateInput, "event" | "modBus" | "inheritedInstallations" | "observedPermissionMode" | "trackedCwd" | "hookEnv" | "identity" | "abortSignal" | "callSignal">, readSettled?: (settled: PermissionResult) => {
|
|
1348
|
+
readonly decision: PermissionResult;
|
|
1349
|
+
readonly deniedBy?: DeniedBy;
|
|
1350
|
+
readonly cause?: ClassifierDenyCause;
|
|
1351
|
+
}): PreToolUseScreening | undefined;
|
|
1341
1352
|
/**
|
|
1342
1353
|
* The park closure's ONE structural seat — what the gate hands the durable park beyond the twelve
|
|
1343
1354
|
* positional seats. Every member is optional and read by name, so a new thing the park must know
|
package/dist/core/hooks.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { argsAsTheToolReads, stampArgsReading } from "./effective-path-target.js";
|
|
2
|
-
import { extensionAuthors, noteRewrite, screeningAuthorship } from "./rewrite-rejudge.js";
|
|
3
|
-
import {
|
|
4
|
-
import { createSettlementLedger, engineFailClosedExit, hookDenyExit, unownedArgsExit } from "./runner/gate-exit.js";
|
|
5
|
-
import {
|
|
2
|
+
import { extensionAuthors, noteRewrite, readRejudge, rewriteChasedSentence, screeningAuthorship } from "./rewrite-rejudge.js";
|
|
3
|
+
import { decisionText, describeThrown, foldHookAsk, isEngineRefusal, ownArgs, ownedReading, refuseOutOfContractDecision } from "./tool-policy.js";
|
|
4
|
+
import { createSettlementLedger, engineFailClosedExit, hookDenyExit, settledScreen, settledScreenExit, takeInheritedScreen, unownedArgsExit } from "./runner/gate-exit.js";
|
|
5
|
+
import { composeCallSignal } from "./runner/abort-race.js";
|
|
6
|
+
import { classicEventBase, dispatchClassic, ENGINE_CORE_ANSWER, failedHandlerClause, judgedInputOf, observePermissionDenied } from "./mods/stations.js";
|
|
6
7
|
import { runGateFold } from "./gate-fold.js";
|
|
7
8
|
import { runGateLanes } from "./gate-lanes.js";
|
|
8
9
|
export { normalizeOrgGateVerdict, normalizePersistedRuleHit } from "./rule-lane-reads.js";
|
|
9
|
-
import { brandPolicyAskClass } from "./ask-class.js";
|
|
10
10
|
import { isAskOrigin, screenAskClassMembers } from "./ask-origin.js";
|
|
11
11
|
import { isAutoModeFallbackCause } from "./auto-mode.js";
|
|
12
12
|
import { inlineUntrusted } from "./untrusted-text.js";
|
|
@@ -111,13 +111,14 @@ function preToolUseRefusedReason(subject, failed) {
|
|
|
111
111
|
: "";
|
|
112
112
|
return `a PreToolUse hook ${failedHandlerClause(failed)} while screening ${subject}; the call was NOT executed (fail-closed).${tail}`;
|
|
113
113
|
}
|
|
114
|
-
export function createPreToolUseScreening(input) {
|
|
115
|
-
const
|
|
116
|
-
|
|
114
|
+
export function createPreToolUseScreening(input, readSettled = (decision) => ({ decision })) {
|
|
115
|
+
const own = input.modBus !== undefined && input.modBus.hasHandlers("classic.PreToolUse") ? input.modBus : undefined;
|
|
116
|
+
const inherited = (input.inheritedInstallations ?? []).filter((i) => i.bus.hasHandlers("classic.PreToolUse", i.judges));
|
|
117
|
+
if (own === undefined && inherited.length === 0)
|
|
117
118
|
return undefined;
|
|
118
119
|
const { toolCallId, toolName } = input.event;
|
|
119
120
|
const screenedName = wireOf("gate.preToolUse", input.event);
|
|
120
|
-
const eventOf = (args) => {
|
|
121
|
+
const eventOf = (args, env) => {
|
|
121
122
|
const cwd = input.trackedCwd?.();
|
|
122
123
|
return {
|
|
123
124
|
...classicEventBase(input.identity, input.observedPermissionMode?.()),
|
|
@@ -125,78 +126,114 @@ export function createPreToolUseScreening(input) {
|
|
|
125
126
|
tool_use_id: toolCallId,
|
|
126
127
|
input: judgedInputOf(args),
|
|
127
128
|
...(typeof cwd === "string" ? { cwd } : {}),
|
|
128
|
-
...(
|
|
129
|
+
...(env !== undefined ? { env } : {}),
|
|
129
130
|
};
|
|
130
131
|
};
|
|
132
|
+
const raise = async (bus, participant, env, args, subject, readAs, signal) => {
|
|
133
|
+
let outcome;
|
|
134
|
+
const authorship = screeningAuthorship(readAs);
|
|
135
|
+
try {
|
|
136
|
+
outcome = await dispatchClassic(bus, "classic.PreToolUse", eventOf(args, env), { ...(signal !== undefined ? { signal } : {}), ...(participant !== undefined ? { participant } : {}), checkAnswer: (a, e, by, below) => preToolUseAnswerViolation(a) ?? authorship.record(a, e, by, below), ranks: PRE_TOOL_USE_RANKS });
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
return { kind: "refused", reason: preToolUseRefusedReason(subject, { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screening: ${describeThrown(err)}`, skipped: [] }) };
|
|
140
|
+
}
|
|
141
|
+
if (outcome === undefined || outcome.kind === "aborted")
|
|
142
|
+
return { kind: "refused", reason: preToolUseRefusedReason(subject, undefined) };
|
|
143
|
+
if (outcome.kind === "failed")
|
|
144
|
+
return { kind: "refused", reason: preToolUseRefusedReason(subject, outcome), extension: outcome.registration };
|
|
145
|
+
const r = screenPreToolUseResult(outcome.answer);
|
|
146
|
+
const answer = r === null || r === false ? undefined : r;
|
|
147
|
+
const rewrittenBy = authorship.of(outcome.answer);
|
|
148
|
+
return { kind: "answered", answer, ...(outcome.answeredBy !== undefined ? { answeredBy: outcome.answeredBy } : {}), rewrittenBy: answer?.updatedInput === undefined ? [] : rewrittenBy.length > 0 || outcome.answeredBy === undefined ? rewrittenBy : [outcome.answeredBy] };
|
|
149
|
+
};
|
|
150
|
+
const seats = [
|
|
151
|
+
...(own !== undefined ? [{ look: ((args, subject, readAs, signal) => raise(own, undefined, input.hookEnv, args, subject, readAs, signal)) }] : []),
|
|
152
|
+
...inherited.map((installation) => ({ installation, look: ((args, subject, readAs, signal) => raise(installation.bus, installation.judges, installation.env, args, subject, readAs, signal)) })),
|
|
153
|
+
];
|
|
154
|
+
const deniedReason = (answer) => decisionText(answer) ?? `tool "${toolName}" blocked by a PreToolUse hook`;
|
|
131
155
|
return {
|
|
132
156
|
screen: async (args, subject, readAs) => {
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const answer = r === null || r === false ? undefined : r;
|
|
147
|
-
const rewrittenBy = authorship.of(outcome.answer);
|
|
148
|
-
return { kind: "answered", answer, ...(outcome.answeredBy !== undefined ? { answeredBy: outcome.answeredBy } : {}), ...(answer?.updatedInput !== undefined ? { rewrittenBy: rewrittenBy.length > 0 || outcome.answeredBy === undefined ? rewrittenBy : [outcome.answeredBy] } : {}) };
|
|
149
|
-
},
|
|
150
|
-
deniedReason: (answer) => decisionText(answer) ?? `tool "${toolName}" blocked by a PreToolUse hook`,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
export function createPreToolUseConstraintPolicy(chain, env) {
|
|
154
|
-
const judges = (p) => !p.observe;
|
|
155
|
-
const minted = brandPolicyAskClass({
|
|
156
|
-
check: async (req, signal) => {
|
|
157
|
-
if (!chain.hasHandlers("classic.PreToolUse", judges))
|
|
158
|
-
return { action: "allow" };
|
|
159
|
-
const unasked = unaskedSeatAnswer(req, signal, { aborted: `the inherited PreToolUse screening of "${req.toolName}" was not consulted: the run or turn was already interrupted`, unreachable: `the inherited PreToolUse screening of "${req.toolName}" was not consulted: nobody can be asked about this call` }, "hook");
|
|
160
|
-
if (unasked !== undefined)
|
|
161
|
-
return unasked;
|
|
162
|
-
const subject = `this call to "${req.toolName}"`;
|
|
163
|
-
let outcome;
|
|
164
|
-
try {
|
|
165
|
-
outcome = await chain.dispatch("classic.PreToolUse", { tool: req.toolName, tool_use_id: req.toolCallId, input: judgedInputOf(req.args), ...(env !== undefined ? { env } : {}) }, {
|
|
166
|
-
bottom: engineCore,
|
|
167
|
-
participant: judges,
|
|
168
|
-
...(signal !== undefined ? { signal } : {}),
|
|
169
|
-
checkAnswer: (a) => (a === ENGINE_CORE_ANSWER ? undefined : preToolUseAnswerViolation(a)),
|
|
170
|
-
ranks: PRE_TOOL_USE_RANKS,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (err) {
|
|
174
|
-
return { action: "deny", message: preToolUseRefusedReason(subject, { kind: "failed", registration: "engine", cause: "threw", reason: `could not raise the screening: ${describeThrown(err)}`, skipped: [] }), decisionReason: "hook" };
|
|
175
|
-
}
|
|
176
|
-
if (outcome.kind === "aborted")
|
|
177
|
-
return abortedSeatDeny(req, `the inherited PreToolUse screening of "${req.toolName}" ended when the run or turn was interrupted`, "hook");
|
|
178
|
-
if (outcome.kind === "failed")
|
|
179
|
-
return { action: "deny", message: preToolUseRefusedReason(subject, outcome), decisionReason: "hook" };
|
|
180
|
-
const r = screenPreToolUseResult(outcome.answer);
|
|
181
|
-
if (r === undefined || r === null || r === false)
|
|
182
|
-
return { action: "allow" };
|
|
183
|
-
if (r.action === "deny") {
|
|
184
|
-
return { action: "deny", message: decisionText(r) ?? `tool "${req.toolName}" blocked by a PreToolUse hook`, decisionReason: "hook" };
|
|
185
|
-
}
|
|
186
|
-
if (r.action === "ask") {
|
|
157
|
+
const as = readAs ?? {};
|
|
158
|
+
const signal = input.abortSignal !== undefined ? composeCallSignal(input.abortSignal, input.callSignal) : input.callSignal;
|
|
159
|
+
let bytes = args;
|
|
160
|
+
let form;
|
|
161
|
+
const authors = [];
|
|
162
|
+
const contexts = [];
|
|
163
|
+
let ownAnswer;
|
|
164
|
+
let ownBy;
|
|
165
|
+
const allowedBy = new Map();
|
|
166
|
+
const floated = new Map();
|
|
167
|
+
const answered = (answer, answeredBy, approved) => {
|
|
168
|
+
const shown = form !== undefined && answer?.action !== "deny" ? { ...answer, updatedInput: form.raw } : answer;
|
|
169
|
+
const asks = [...floated.values()];
|
|
187
170
|
return {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
...(
|
|
192
|
-
|
|
171
|
+
kind: "answered",
|
|
172
|
+
answer: shown,
|
|
173
|
+
...(answeredBy !== undefined ? { answeredBy } : {}),
|
|
174
|
+
...(form !== undefined && answer?.action !== "deny" ? { rewrittenBy: authors } : {}),
|
|
175
|
+
contexts,
|
|
176
|
+
...(inherited.length > 0 ? { inherited: { allowedBy: [...allowedBy.values()], ...(asks.length > 0 ? { floated: asks.reduce((a, b) => foldHookAsk(a, b)) } : {}), ...(approved !== undefined ? { approved } : {}) } } : {}),
|
|
193
177
|
};
|
|
178
|
+
};
|
|
179
|
+
const judgedOf = () => (bytes !== args ? { judged: bytes } : {});
|
|
180
|
+
const lookAt = async (i, second) => {
|
|
181
|
+
const seat = seats[i];
|
|
182
|
+
const r = await seat.look(bytes, subject, as, signal);
|
|
183
|
+
if (r.kind === "refused")
|
|
184
|
+
return { ...r, ...judgedOf() };
|
|
185
|
+
const a = r.answer;
|
|
186
|
+
if (a?.additionalContext)
|
|
187
|
+
contexts.push(a.additionalContext);
|
|
188
|
+
if (a?.action === "deny")
|
|
189
|
+
return { ...answered(a, r.answeredBy), ...judgedOf() };
|
|
190
|
+
const read = readRejudge(as, bytes, a);
|
|
191
|
+
if (second && read.kind === "rewritten")
|
|
192
|
+
return { kind: "refused", reason: rewriteChasedSentence(toolName), ...judgedOf() };
|
|
193
|
+
if (a?.updatedInput !== undefined) {
|
|
194
|
+
form = { raw: a.updatedInput };
|
|
195
|
+
authors.push(...r.rewrittenBy.filter((by) => !authors.includes(by)));
|
|
196
|
+
}
|
|
197
|
+
if (read.kind === "rewritten") {
|
|
198
|
+
bytes = read.form;
|
|
199
|
+
for (let j = 0; j < i; j++) {
|
|
200
|
+
const ended = await lookAt(j, true);
|
|
201
|
+
if (ended !== undefined)
|
|
202
|
+
return ended;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const verdict = a === undefined ? undefined : (({ updatedInput: _form, ...v }) => v)(a);
|
|
206
|
+
if (seat.installation === undefined) {
|
|
207
|
+
ownAnswer = verdict;
|
|
208
|
+
ownBy = r.answeredBy;
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
allowedBy.delete(i);
|
|
212
|
+
floated.delete(i);
|
|
213
|
+
if (verdict?.action === "allow" && r.answeredBy !== undefined)
|
|
214
|
+
allowedBy.set(i, r.answeredBy);
|
|
215
|
+
if (verdict?.action !== "ask")
|
|
216
|
+
return undefined;
|
|
217
|
+
const ask = { action: "ask", message: decisionText(verdict) ?? `approval required for "${toolName}" (an inherited PreToolUse hook)`, decisionReason: "hook", ...(verdict.requiresRealApproval === true ? { requiresRealApproval: true } : {}) };
|
|
218
|
+
const call = Object.freeze({ toolName, toolCallId, args: bytes, ...(as.face !== undefined ? { face: as.face } : {}) });
|
|
219
|
+
const settled = readSettled(await seat.installation.settle(ask, call, signal));
|
|
220
|
+
if (settled.decision.action === "deny")
|
|
221
|
+
return settledScreen(settled, judgedOf());
|
|
222
|
+
if (settled.decision.action === "allow" && settled.decision.updatedInput !== undefined)
|
|
223
|
+
return answered(ownAnswer, ownBy, { ...settled.decision, updatedInput: settled.decision.updatedInput });
|
|
224
|
+
if (settled.decision.action === "ask")
|
|
225
|
+
floated.set(i, settled.decision);
|
|
226
|
+
return undefined;
|
|
227
|
+
};
|
|
228
|
+
for (let i = 0; i < seats.length; i++) {
|
|
229
|
+
const ended = await lookAt(i, false);
|
|
230
|
+
if (ended !== undefined)
|
|
231
|
+
return ended;
|
|
194
232
|
}
|
|
195
|
-
return
|
|
233
|
+
return answered(ownAnswer, ownBy);
|
|
196
234
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return minted;
|
|
235
|
+
deniedReason,
|
|
236
|
+
};
|
|
200
237
|
}
|
|
201
238
|
export function askCarryRowMembers(carry) {
|
|
202
239
|
if (carry === undefined)
|
|
@@ -225,7 +262,12 @@ export async function runToolGate(input) {
|
|
|
225
262
|
const onHostObserverFailure = (err) => void notifier.notify(() => { throw err; }, "toolGate.permissionDenied");
|
|
226
263
|
return observePermissionDenied({ legBus: input.modBus, hostObserver: input.permissionDenied, payload: seen, signal: input.abortSignal, onHostObserverFailure });
|
|
227
264
|
};
|
|
228
|
-
const
|
|
265
|
+
const ledger = createSettlementLedger({ toolCallId, toolName });
|
|
266
|
+
const screening = createPreToolUseScreening(input, (settled) => {
|
|
267
|
+
const read = ledger.fromDecision(settled);
|
|
268
|
+
const cause = ledger.causeOf(read.decision);
|
|
269
|
+
return { ...read, ...(cause !== undefined ? { cause } : {}) };
|
|
270
|
+
});
|
|
229
271
|
const pass = {
|
|
230
272
|
input,
|
|
231
273
|
event,
|
|
@@ -236,7 +278,7 @@ export async function runToolGate(input) {
|
|
|
236
278
|
toolCallId,
|
|
237
279
|
callSignal,
|
|
238
280
|
notifier,
|
|
239
|
-
ledger
|
|
281
|
+
ledger,
|
|
240
282
|
notifyPermissionDenied: notifyPermissionDeniedSeat,
|
|
241
283
|
screening,
|
|
242
284
|
afterFold: runGateLanes,
|
|
@@ -257,16 +299,18 @@ export async function runToolGate(input) {
|
|
|
257
299
|
return await unownedArgsExit(pass, owned.reason);
|
|
258
300
|
if (screening !== undefined) {
|
|
259
301
|
const screened = await screening.screen(pass.currentInput, `this call to "${toolName}"`, pass.req);
|
|
302
|
+
if ((screened.kind !== "answered" || screened.answer?.action === "deny") && screened.judged !== undefined)
|
|
303
|
+
pass.currentInput = screened.judged;
|
|
260
304
|
if (screened.kind === "refused") {
|
|
261
|
-
return await engineFailClosedExit(pass, screened.reason);
|
|
305
|
+
return await engineFailClosedExit(pass, screened.reason, screened.extension);
|
|
262
306
|
}
|
|
307
|
+
if (screened.kind === "settled")
|
|
308
|
+
return await settledScreenExit(pass, screened);
|
|
309
|
+
pass.preToolContext.push(...screened.contexts);
|
|
263
310
|
const r = screened.answer;
|
|
264
311
|
if (r) {
|
|
265
|
-
if (r.additionalContext) {
|
|
266
|
-
pass.preToolContext.push(r.additionalContext);
|
|
267
|
-
}
|
|
268
312
|
if (r.action === "deny") {
|
|
269
|
-
return hookDenyExit(pass, screening.deniedReason(r));
|
|
313
|
+
return hookDenyExit(pass, screening.deniedReason(r), screened.answeredBy);
|
|
270
314
|
}
|
|
271
315
|
if (r.updatedInput !== undefined) {
|
|
272
316
|
const rewritten = argsAsTheToolReads(pass.req, r.updatedInput);
|
|
@@ -279,6 +323,7 @@ export async function runToolGate(input) {
|
|
|
279
323
|
if (r.action === "allow")
|
|
280
324
|
pass.hookAllowedBy = screened.answeredBy !== undefined ? [screened.answeredBy] : [];
|
|
281
325
|
}
|
|
326
|
+
takeInheritedScreen(pass, screened.inherited);
|
|
282
327
|
}
|
|
283
328
|
return await runGateFold(pass);
|
|
284
329
|
}
|