@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/roles.js
CHANGED
|
@@ -1,83 +1,98 @@
|
|
|
1
1
|
import { selectModel } from "./select-model.js";
|
|
2
2
|
import { namesRoleBase } from "../prompt-assembly/role-base.js";
|
|
3
3
|
import { readPromptRole } from "../prompt-assembly/select.js";
|
|
4
|
-
import {
|
|
4
|
+
import { bindingShown, isList, isModelSnapshot, modelBindingRefusal, receiveModel } from "./model-receipt.js";
|
|
5
|
+
import { describeFault, receive } from "./mods/kernel/receive.js";
|
|
6
|
+
import { CONFIG_RECEIPT_MODE, DECLARATION_RECEIPT_MODE, receiveOwnProperties } from "./own-property-receipt.js";
|
|
5
7
|
import { MODEL_ROLES } from "./types.js";
|
|
6
8
|
export { MODEL_ROLES } from "./types.js";
|
|
7
|
-
|
|
9
|
+
export { bindingShown } from "./model-receipt.js";
|
|
10
|
+
function catalogEntry(ref, models) {
|
|
8
11
|
const m = models != null && (typeof models === "object" || typeof models === "function") && Object.hasOwn(models, ref) ? models[ref] : undefined;
|
|
9
12
|
return m || undefined;
|
|
10
13
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
e.detail = { field, reason };
|
|
15
|
-
return e;
|
|
14
|
+
export function catalogModel(ref, models, seat, what = `${bindingShown(ref)} (a catalog entry)`) {
|
|
15
|
+
const m = catalogEntry(ref, models);
|
|
16
|
+
return m === undefined ? undefined : receiveModel(m, seat, what);
|
|
16
17
|
}
|
|
17
18
|
const ROLE_RECORD_KEYS = new Set(["model", "select", "thinking", "promptRole", "systemPrompt"]);
|
|
18
|
-
function isModelShaped(s) {
|
|
19
|
-
try {
|
|
20
|
-
if (typeof s === "function" || isList(s)) {
|
|
21
|
-
Reflect.ownKeys(s);
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (Reflect.ownKeys(s).some((k) => typeof k !== "string" || !ROLE_RECORD_KEYS.has(k)))
|
|
25
|
-
return true;
|
|
26
|
-
return readMember(s, "id") !== undefined || readMember(s, "api") !== undefined;
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
19
|
function isBindingObject(value) {
|
|
33
20
|
return (typeof value === "object" && value !== null) || typeof value === "function";
|
|
34
21
|
}
|
|
35
|
-
function bindingShown(value) {
|
|
36
|
-
if (typeof value === "string")
|
|
37
|
-
return JSON.stringify(value.length > 80 ? `${value.slice(0, 80)}…` : value);
|
|
38
|
-
return value === null ? "null" : isList(value) ? "a list" : `a ${typeof value}`;
|
|
39
|
-
}
|
|
40
|
-
function isList(value) {
|
|
41
|
-
try {
|
|
42
|
-
return Array.isArray(value);
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
22
|
function unknownModelRefRefusal(ref, seat) {
|
|
49
23
|
return modelBindingRefusal(seat, "unknown_model_ref", `Unknown model ref ${bindingShown(ref)} in ${seat}. Provide it in RunnerDeps.models or pass a Model object.`);
|
|
50
24
|
}
|
|
51
25
|
function modelOfBinding(value, models, seat, binds) {
|
|
52
|
-
assertModelBindingShape(value, seat, binds);
|
|
53
26
|
if (typeof value === "string") {
|
|
54
|
-
const held = catalogModel(value, models);
|
|
27
|
+
const held = catalogModel(value, models, seat);
|
|
55
28
|
if (held === undefined)
|
|
56
29
|
throw unknownModelRefRefusal(value, seat);
|
|
57
|
-
assertModelObject(held, seat, `${bindingShown(value)} (a catalog entry)`);
|
|
58
30
|
return held;
|
|
59
31
|
}
|
|
60
|
-
return value;
|
|
32
|
+
return modelObjectAt(value, seat, binds);
|
|
61
33
|
}
|
|
62
|
-
function
|
|
63
|
-
if (typeof value === "string")
|
|
64
|
-
return;
|
|
34
|
+
function modelObjectAt(value, seat, binds) {
|
|
65
35
|
if (typeof value !== "object" || value === null || isList(value)) {
|
|
66
36
|
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${bindingShown(value)}, not a model reference — ${binds}.`);
|
|
67
37
|
}
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
function assertModelObject(value, seat, what, note = "") {
|
|
71
|
-
const id = readMember(value, "id");
|
|
72
|
-
const api = readMember(value, "api");
|
|
73
|
-
const [member, got] = typeof id !== "string" || id === "" ? ["id", id] : typeof api !== "string" ? ["api", api] : [undefined, undefined];
|
|
74
|
-
if (member === undefined)
|
|
75
|
-
return;
|
|
76
|
-
const shown = got === undefined ? "absent" : bindingShown(got);
|
|
77
|
-
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`${member}\` is ${shown} — a Model carries a non-empty string \`id\` and a string \`api\`.${note}`);
|
|
38
|
+
return receiveModel(value, seat, "a Model object", binds === ROLE_BINDS ? " At a role seat an object that is not a plain record of model / select / thinking / promptRole / systemPrompt is read as a Model, not as a role record." : "");
|
|
78
39
|
}
|
|
79
40
|
const ROLE_BINDS = "a role binds a catalog model name or a Model object";
|
|
41
|
+
const TIER_BINDS = "a tier binds a catalog model name or a Model object";
|
|
80
42
|
const roleModelSeat = (named, seat) => (typeof named === "string" ? seat : `${seat}.model`);
|
|
43
|
+
const RECEIVED_ROLES = new WeakSet();
|
|
44
|
+
const EMPTY_ROLE_RECORD = Object.freeze({});
|
|
45
|
+
function receiveRoleSpec(value, seat) {
|
|
46
|
+
if (typeof value === "function")
|
|
47
|
+
return CONFIG_RECEIPT_MODE.isProxy?.(value) === true ? modelObjectAt(value, `${seat}.model`, ROLE_BINDS) : EMPTY_ROLE_RECORD;
|
|
48
|
+
if (typeof value !== "object" || value === null)
|
|
49
|
+
return value;
|
|
50
|
+
if (isModelSnapshot(value) || RECEIVED_ROLES.has(value))
|
|
51
|
+
return value;
|
|
52
|
+
if (isList(value))
|
|
53
|
+
return EMPTY_ROLE_RECORD;
|
|
54
|
+
if (!isRoleRecord(value))
|
|
55
|
+
return modelObjectAt(value, `${seat}.model`, ROLE_BINDS);
|
|
56
|
+
const read = receive(value, CONFIG_RECEIPT_MODE);
|
|
57
|
+
if (!read.ok)
|
|
58
|
+
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is a role record that could not be read — ${describeFault(read.fault)}.`);
|
|
59
|
+
const given = read.value;
|
|
60
|
+
const out = {};
|
|
61
|
+
for (const key of Object.keys(given)) {
|
|
62
|
+
let member = given[key];
|
|
63
|
+
if (key === "model" && typeof member === "object" && member !== null && !isList(member))
|
|
64
|
+
member = receiveModel(member, `${seat}.model`, "a Model object");
|
|
65
|
+
else if (key !== "model" && typeof member === "object" && member !== null) {
|
|
66
|
+
const data = receive(member, DECLARATION_RECEIPT_MODE);
|
|
67
|
+
if (!data.ok)
|
|
68
|
+
throw modelBindingRefusal(`${seat}.${key}`, "not_a_model_ref", `${seat}.${key} could not be read as plain data — ${describeFault(data.fault)}.`);
|
|
69
|
+
member = data.value;
|
|
70
|
+
}
|
|
71
|
+
Object.defineProperty(out, key, { value: member, enumerable: true, writable: false, configurable: false });
|
|
72
|
+
}
|
|
73
|
+
RECEIVED_ROLES.add(Object.freeze(out));
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
function isRoleRecord(value) {
|
|
77
|
+
if (CONFIG_RECEIPT_MODE.isProxy?.(value) === true)
|
|
78
|
+
return false;
|
|
79
|
+
const proto = Object.getPrototypeOf(value);
|
|
80
|
+
if (proto !== Object.prototype && proto !== null)
|
|
81
|
+
return false;
|
|
82
|
+
return Reflect.ownKeys(value).every((k) => typeof k === "string" && ROLE_RECORD_KEYS.has(k));
|
|
83
|
+
}
|
|
84
|
+
export function receiveRoleMap(roles, field) {
|
|
85
|
+
if (roles === undefined || roles === null)
|
|
86
|
+
return undefined;
|
|
87
|
+
if (typeof roles === "object" && RECEIVED_ROLES.has(roles))
|
|
88
|
+
return roles;
|
|
89
|
+
const given = receiveOwnProperties(roles, { subject: field, unit: "role", moment: "when its roles are read" });
|
|
90
|
+
const out = {};
|
|
91
|
+
for (const key of Object.keys(given))
|
|
92
|
+
Object.defineProperty(out, key, { value: receiveRoleSpec(given[key], `roles.${key}`), enumerable: true, writable: false, configurable: false });
|
|
93
|
+
RECEIVED_ROLES.add(Object.freeze(out));
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
81
96
|
export function resolveModel(ref, models, seat = "model") {
|
|
82
97
|
return modelOfBinding(ref, models, seat, "a model is named by a catalog model name or a Model object");
|
|
83
98
|
}
|
|
@@ -105,7 +120,7 @@ export function expandTiers(models, tiers) {
|
|
|
105
120
|
const b = Object.hasOwn(tiers, name) ? tiers[name] : undefined;
|
|
106
121
|
if (b === undefined)
|
|
107
122
|
return undefined;
|
|
108
|
-
return modelOfBinding(b, models, `tiers.${name}`,
|
|
123
|
+
return modelOfBinding(b, models, `tiers.${name}`, TIER_BINDS);
|
|
109
124
|
};
|
|
110
125
|
const ownKey = (k) => models !== undefined && Object.hasOwn(models, k) && Boolean(models[k]);
|
|
111
126
|
const landing = (t, self) => {
|
|
@@ -160,6 +175,38 @@ export function expandTiers(models, tiers) {
|
|
|
160
175
|
}
|
|
161
176
|
return out;
|
|
162
177
|
}
|
|
178
|
+
const RECEIVED_CATALOGS = new WeakSet();
|
|
179
|
+
export function isReceivedCatalog(models) {
|
|
180
|
+
return models !== undefined && RECEIVED_CATALOGS.has(models);
|
|
181
|
+
}
|
|
182
|
+
export function catalogOfDeps(deps) {
|
|
183
|
+
return isReceivedCatalog(deps.models) ? deps.models : receiveModelCatalog(deps.models, deps.tiers, "RunnerDeps").models;
|
|
184
|
+
}
|
|
185
|
+
export function receiveModelCatalog(models, tiers, field) {
|
|
186
|
+
let held;
|
|
187
|
+
if (models !== undefined && models !== null) {
|
|
188
|
+
const given = receiveOwnProperties(models, { subject: `${field}.models`, unit: "entry", moment: "when the catalog is received" });
|
|
189
|
+
held = {};
|
|
190
|
+
for (const key of Object.keys(given)) {
|
|
191
|
+
const m = given[key];
|
|
192
|
+
Object.defineProperty(held, key, { value: m ? receiveModel(m, `${field}.models.${key}`, `${bindingShown(key)} (a catalog entry)`) : m, enumerable: true, writable: true, configurable: true });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
let bindings;
|
|
196
|
+
if (tiers !== undefined && tiers !== null) {
|
|
197
|
+
const given = receiveOwnProperties(tiers, { subject: `${field}.tiers`, unit: "binding", moment: "when the catalog is received" });
|
|
198
|
+
bindings = {};
|
|
199
|
+
for (const name of Object.keys(given)) {
|
|
200
|
+
const b = given[name];
|
|
201
|
+
Object.defineProperty(bindings, name, { value: b === undefined || typeof b === "string" ? b : modelObjectAt(b, `tiers.${name}`, TIER_BINDS), enumerable: true, writable: false, configurable: false });
|
|
202
|
+
}
|
|
203
|
+
Object.freeze(bindings);
|
|
204
|
+
}
|
|
205
|
+
const expanded = bindings !== undefined && Object.keys(bindings).length > 0 ? expandTiers(held, bindings) : held;
|
|
206
|
+
if (expanded !== undefined)
|
|
207
|
+
RECEIVED_CATALOGS.add(Object.freeze(expanded));
|
|
208
|
+
return { ...(expanded !== undefined ? { models: expanded } : {}), ...(bindings !== undefined ? { tiers: bindings } : {}) };
|
|
209
|
+
}
|
|
163
210
|
export function tierAliasVia(word, models) {
|
|
164
211
|
const via = models?.[TIER_ALIAS_VIA];
|
|
165
212
|
return via?.get(word) ?? [];
|
|
@@ -193,10 +240,7 @@ function roleTierModel(role, models) {
|
|
|
193
240
|
if (!models || !models[TIERS_ACTIVE])
|
|
194
241
|
return undefined;
|
|
195
242
|
const tier = ROLE_TIER_DEFAULTS[role];
|
|
196
|
-
|
|
197
|
-
if (m)
|
|
198
|
-
assertModelObject(m, `tiers.${String(tier)}`, "the catalog entry the tier word names");
|
|
199
|
-
return m;
|
|
243
|
+
return tier !== undefined ? catalogModel(tier, models, `tiers.${tier}`, "the catalog entry the tier word names") : undefined;
|
|
200
244
|
}
|
|
201
245
|
const FALLBACK = {
|
|
202
246
|
default: [],
|
|
@@ -216,21 +260,21 @@ function specParts(s, seat = "a role seat") {
|
|
|
216
260
|
if (!isBindingObject(s)) {
|
|
217
261
|
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${bindingShown(s)}, not a model reference — a role binds a catalog model name, a Model object or a { model, select, thinking, systemPrompt } record.`);
|
|
218
262
|
}
|
|
219
|
-
if (
|
|
263
|
+
if (isModelSnapshot(s)) {
|
|
220
264
|
return { model: s };
|
|
221
265
|
}
|
|
222
266
|
const cfg = s;
|
|
223
267
|
return { model: cfg.model, select: cfg.select, thinking: cfg.thinking, promptRole: readPromptRole(`${seat}.promptRole`, cfg.promptRole), systemPrompt: cfg.systemPrompt };
|
|
224
268
|
}
|
|
225
269
|
export function roleSpecNamesModel(spec) {
|
|
226
|
-
const parts = specParts(spec);
|
|
270
|
+
const parts = specParts(receiveRoleSpec(spec, "a role seat"));
|
|
227
271
|
return parts.model !== undefined || parts.select !== undefined;
|
|
228
272
|
}
|
|
229
273
|
function toConfig(s) {
|
|
230
274
|
if (s === undefined) {
|
|
231
275
|
return undefined;
|
|
232
276
|
}
|
|
233
|
-
if (typeof s === "string" ||
|
|
277
|
+
if (typeof s === "string" || isModelSnapshot(s)) {
|
|
234
278
|
return { model: s };
|
|
235
279
|
}
|
|
236
280
|
return s;
|
|
@@ -259,18 +303,20 @@ function assertKnownRole(word, field, ofKey = false) {
|
|
|
259
303
|
throw modelBindingRefusal(field, "unknown_role_word", `${ofKey ? `${field} key` : field} names the model role ${shown}, which is not one of ${MODEL_ROLES.join(" / ")} — a word outside the vocabulary binds nothing and resolves nothing; bind the model on one of these roles, or name it on TaskSpec.model`);
|
|
260
304
|
}
|
|
261
305
|
export function screenRoleMap(roles, field) {
|
|
262
|
-
|
|
306
|
+
const received = receiveRoleMap(roles, field);
|
|
307
|
+
for (const key of Object.keys(received ?? {}))
|
|
263
308
|
assertKnownRole(key, field, true);
|
|
264
|
-
for (const [key, value] of Object.entries(
|
|
309
|
+
for (const [key, value] of Object.entries(received ?? {})) {
|
|
265
310
|
const seat = `roles.${key}`;
|
|
266
311
|
const named = specParts(value, seat).model;
|
|
267
|
-
if (named !== undefined)
|
|
268
|
-
|
|
312
|
+
if (named !== undefined && typeof named !== "string")
|
|
313
|
+
modelObjectAt(named, roleModelSeat(named, seat), ROLE_BINDS);
|
|
269
314
|
}
|
|
315
|
+
return received;
|
|
270
316
|
}
|
|
271
|
-
function mergeRoles(
|
|
272
|
-
screenRoleMap(
|
|
273
|
-
screenRoleMap(
|
|
317
|
+
function mergeRoles(deployment, task) {
|
|
318
|
+
const base = screenRoleMap(deployment, "RunnerDeps.roles");
|
|
319
|
+
const over = screenRoleMap(task, "TaskSpec.roles");
|
|
274
320
|
const out = { ...base };
|
|
275
321
|
for (const role of Object.keys(over ?? {})) {
|
|
276
322
|
out[role] = mergeRoleSpec(base?.[role], over?.[role]);
|
|
@@ -286,16 +332,50 @@ function partsModel(parts, models, seat = "a role seat") {
|
|
|
286
332
|
if (needs != null && !Array.isArray(needs)) {
|
|
287
333
|
throw modelBindingRefusal(`${seat}.select`, "not_a_model_ref", `${seat}.select.needs is ${bindingShown(needs)}, not a list of capabilities (vision / reasoning).`);
|
|
288
334
|
}
|
|
289
|
-
const held =
|
|
290
|
-
for (const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return
|
|
335
|
+
const held = [];
|
|
336
|
+
for (const key of models != null && typeof models === "object" ? Object.keys(models) : []) {
|
|
337
|
+
const m = catalogModel(key, models, `${seat}.select`, `the catalog entry ${bindingShown(key)} the criteria read`);
|
|
338
|
+
if (m !== undefined)
|
|
339
|
+
held.push(m);
|
|
340
|
+
}
|
|
341
|
+
return selectModel(held, parts.select);
|
|
296
342
|
}
|
|
297
343
|
return undefined;
|
|
298
344
|
}
|
|
345
|
+
export function unheldSeatWord(spec, models) {
|
|
346
|
+
const named = typeof spec === "string" ? spec : isBindingObject(spec) && !("id" in spec && "api" in spec) ? spec.model : undefined;
|
|
347
|
+
return typeof named === "string" && catalogEntry(named, models) === undefined ? named : undefined;
|
|
348
|
+
}
|
|
349
|
+
const STRICT_SEATS = new Set(["default", "classifier"]);
|
|
350
|
+
function seatRead(parts, models, seat, role) {
|
|
351
|
+
const word = STRICT_SEATS.has(role) ? undefined : unheldSeatWord(parts.model, models);
|
|
352
|
+
if (word === undefined)
|
|
353
|
+
return { parts, model: partsModel(parts, models, seat), unheld: undefined };
|
|
354
|
+
const unset = { ...parts, model: undefined };
|
|
355
|
+
return { parts: unset, model: partsModel(unset, models, seat), unheld: { role, seat, word } };
|
|
356
|
+
}
|
|
357
|
+
export function unheldRoleSeats(spec, deps, only) {
|
|
358
|
+
const merged = mergeRoles(deps.roles, spec.roles);
|
|
359
|
+
const out = [];
|
|
360
|
+
for (const role of only ?? MODEL_ROLES) {
|
|
361
|
+
if (only === undefined && STRICT_SEATS.has(role))
|
|
362
|
+
continue;
|
|
363
|
+
const word = unheldSeatWord(merged[role], deps.models);
|
|
364
|
+
if (word !== undefined)
|
|
365
|
+
out.push({ role, seat: `roles.${role}`, word });
|
|
366
|
+
}
|
|
367
|
+
return out;
|
|
368
|
+
}
|
|
369
|
+
export function unheldSeatRefusal(u) {
|
|
370
|
+
return unknownModelRefRefusal(u.word, u.seat);
|
|
371
|
+
}
|
|
372
|
+
export function unheldChainRefusal(chain, models, roles) {
|
|
373
|
+
const first = unheldRoleSeats({}, { models, roles }, chain)[0];
|
|
374
|
+
return first !== undefined ? unheldSeatRefusal(first) : undefined;
|
|
375
|
+
}
|
|
376
|
+
export function roleFallbackChain(role) {
|
|
377
|
+
return FALLBACK[role];
|
|
378
|
+
}
|
|
299
379
|
function chainHead(spec, deps) {
|
|
300
380
|
const start = spec.modelRole === undefined ? "default" : spec.modelRole;
|
|
301
381
|
assertKnownRole(start, "modelRole");
|
|
@@ -308,30 +388,37 @@ export function presetRoleBaseOf(spec, deps) {
|
|
|
308
388
|
}
|
|
309
389
|
export function resolveTaskModel(spec, deps) {
|
|
310
390
|
const { start, merged, startParts } = chainHead(spec, deps);
|
|
311
|
-
|
|
391
|
+
const written = spec.model;
|
|
392
|
+
if (written !== undefined) {
|
|
393
|
+
const model = resolveModel(written, deps.models, "TaskSpec.model");
|
|
312
394
|
return {
|
|
313
|
-
model
|
|
314
|
-
modelRef:
|
|
395
|
+
model,
|
|
396
|
+
modelRef: typeof written === "string" ? written : model,
|
|
315
397
|
thinking: spec.thinking ?? startParts.thinking,
|
|
316
398
|
promptRole: startParts.promptRole,
|
|
317
399
|
systemPrompt: startParts.systemPrompt,
|
|
318
400
|
};
|
|
319
401
|
}
|
|
320
402
|
const { promptRole: startPromptRole, systemPrompt: startSystemPrompt } = startParts;
|
|
403
|
+
let firstUnheld;
|
|
321
404
|
for (const role of [start, ...FALLBACK[start]]) {
|
|
322
|
-
const
|
|
323
|
-
const
|
|
405
|
+
const read = seatRead(specParts(merged[role], `roles.${role}`), deps.models, `roles.${role}`, role);
|
|
406
|
+
const parts = read.parts;
|
|
407
|
+
firstUnheld ??= read.unheld;
|
|
408
|
+
const fromParts = read.model;
|
|
324
409
|
const model = fromParts ?? roleTierModel(role, deps.models);
|
|
325
410
|
if (model) {
|
|
326
411
|
const modelRef = fromParts !== undefined ? (parts.model ?? model) : (ROLE_TIER_DEFAULTS[role] ?? model);
|
|
327
412
|
return { model, modelRef, thinking: spec.thinking ?? parts.thinking, promptRole: startPromptRole, systemPrompt: startSystemPrompt };
|
|
328
413
|
}
|
|
329
414
|
}
|
|
330
|
-
|
|
415
|
+
if (firstUnheld !== undefined)
|
|
416
|
+
throw unheldSeatRefusal(firstUnheld);
|
|
417
|
+
throw modelBindingRefusal(`roles.${start}`, "no_model_for_role", `No model for role "${start}": set TaskSpec.model, or configure RunnerDeps.roles / TaskSpec.roles["${start}"] (or a "default" role). A "select" RoleSpec also fails here if no catalog model matches.`);
|
|
331
418
|
}
|
|
332
419
|
export function roleModelIfSet(role, spec, deps) {
|
|
333
420
|
const merged = mergeRoles(deps.roles, spec.roles);
|
|
334
421
|
const seat = `roles.${role}`;
|
|
335
422
|
const parts = specParts(merged[role], seat);
|
|
336
|
-
return
|
|
423
|
+
return seatRead(parts, deps.models, seat, role).model ?? roleTierModel(role, deps.models);
|
|
337
424
|
}
|
|
@@ -17,6 +17,9 @@ import type { AssertAllKeysHandled } from "./ask-origin.js";
|
|
|
17
17
|
* identity surface is indistinguishable from a real one downstream. Cloud sync and cloud tickets accept
|
|
18
18
|
* ONLY the `principal` kind: syncing is an authenticated act, and a local-owner bucket has no cloud home
|
|
19
19
|
* until it is adopted (`adoptFilePermissionRuleStore`).
|
|
20
|
+
*
|
|
21
|
+
* A memory layer's owner is read the same way: the identity-less owner is this `local-owner` arm, and its layer
|
|
22
|
+
* keeps an opaque key, never a `user:` key (`@contract memory.identity_absence.opaque_key`, scope-contract.ts).
|
|
20
23
|
*/
|
|
21
24
|
export type RuleOwner = {
|
|
22
25
|
kind: "principal";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput
|
|
1
|
+
import type { AnnouncedListingSnapshot, AnnouncedListingSnapshotInput } from "../../internal/harness.js";
|
|
2
2
|
import type { AnnounceOnceSink } from "./contracts.js";
|
|
3
3
|
import type { McpDroppedTool, McpServerStatus } from "../mcp.js";
|
|
4
|
+
import type { McpUnavailableEntry } from "../mcp-failure.js";
|
|
4
5
|
import type { RunnerDeps } from "../types.js";
|
|
5
6
|
/** Upper bound on the advisory-digest arm kept in the record (oldest dropped past it). A digest is
|
|
6
7
|
* 64 hex chars; a session accumulates a handful of distinct advisories, never hundreds — the bound
|
|
@@ -75,13 +76,13 @@ export declare function flushOwedAnnouncedSnapshot(prepared: {
|
|
|
75
76
|
*/
|
|
76
77
|
export declare function settleMcpUnavailable(prepared: {
|
|
77
78
|
readonly mcpUnavailable?: {
|
|
78
|
-
pending:
|
|
79
|
+
pending: McpUnavailableEntry[];
|
|
79
80
|
};
|
|
80
81
|
readonly announcedListingsRef: AnnouncedListingSnapshotInput;
|
|
81
82
|
readonly frameReceipts: {
|
|
82
83
|
listingSnapshotOwed: boolean;
|
|
83
84
|
};
|
|
84
|
-
}, delivered: ReadonlyArray<
|
|
85
|
+
}, delivered: ReadonlyArray<McpUnavailableEntry>): void;
|
|
85
86
|
/** The run-local ledger — see the module header for the two commit disciplines it serves. */
|
|
86
87
|
export interface AnnounceOnceLedger {
|
|
87
88
|
/** The nearest announced snapshot on the branch as read at prepare (undefined = pre-entry
|
|
@@ -109,7 +110,7 @@ export interface AnnounceOnceLedger {
|
|
|
109
110
|
* bounded at intake, the reminder's own bounds) MINUS the pairs already announced on this branch.
|
|
110
111
|
* As a side effect the record's `mcpFailed` arm is pruned to the pairs that are STILL failing —
|
|
111
112
|
* a recovered server leaves the record silently. Call once per prepare. */
|
|
112
|
-
mcpFailuresToAnnounce(statuses: ReadonlyArray<McpServerStatus>):
|
|
113
|
+
mcpFailuresToAnnounce(statuses: ReadonlyArray<McpServerStatus>): McpUnavailableEntry[];
|
|
113
114
|
/** Remove, IN PLACE, the dropped-tool entries whose model-facing digest is already recorded (the
|
|
114
115
|
* frame was delivered on an earlier run of this session). The operator line about each entry is a
|
|
115
116
|
* separate digest — run that loop BEFORE pruning so both faces are judged on the full list. */
|
|
@@ -36,6 +36,7 @@ export function withAnnounceDigests(existing, add) {
|
|
|
36
36
|
}
|
|
37
37
|
return out.length > ANNOUNCE_ONCE_MAX_DIGESTS ? out.slice(out.length - ANNOUNCE_ONCE_MAX_DIGESTS) : out;
|
|
38
38
|
}
|
|
39
|
+
const toldAuthorization = (a) => `needs authorization (${a.reason}, ${createHash("sha256").update(JSON.stringify([a.reason, a.authorizeUrl ?? ""])).digest("hex").slice(0, 16)})`;
|
|
39
40
|
function sameFailure(a, b) {
|
|
40
41
|
return a.name === b.name && a.error === b.error;
|
|
41
42
|
}
|
|
@@ -49,7 +50,8 @@ export async function flushOwedAnnouncedSnapshot(prepared) {
|
|
|
49
50
|
}
|
|
50
51
|
export function settleMcpUnavailable(prepared, delivered) {
|
|
51
52
|
prepared.mcpUnavailable?.pending.splice(0, delivered.length);
|
|
52
|
-
|
|
53
|
+
const told = delivered.map(({ name, error }) => ({ name, ...(error !== undefined ? { error } : {}) }));
|
|
54
|
+
prepared.announcedListingsRef.mcpFailed = [...(prepared.announcedListingsRef.mcpFailed ?? []), ...told];
|
|
53
55
|
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
54
56
|
}
|
|
55
57
|
export async function loadAnnounceOnceLedger(session, checkpointMirror, onError) {
|
|
@@ -94,7 +96,7 @@ export async function loadAnnounceOnceLedger(session, checkpointMirror, onError)
|
|
|
94
96
|
mcpFailuresToAnnounce: (statuses) => {
|
|
95
97
|
const current = statuses
|
|
96
98
|
.filter((s) => s.status === "failed")
|
|
97
|
-
.map((s) => ({ name: inlineUntrusted(s.name, 160), ...(s.error !== undefined ? { error: inlineUntrusted(s.error, 240) } : {}) }));
|
|
99
|
+
.map((s) => ({ name: inlineUntrusted(s.name, 160), ...(s.authorization !== undefined ? { error: toldAuthorization(s.authorization), authorization: { ...s.authorization } } : s.error !== undefined ? { error: inlineUntrusted(s.error, 240) } : {}) }));
|
|
98
100
|
const carried = mcpFailed.filter((r) => current.some((c) => sameFailure(c, r)));
|
|
99
101
|
if (carried.length !== mcpFailed.length)
|
|
100
102
|
dirty = true;
|
|
@@ -48,7 +48,6 @@ export interface Stats {
|
|
|
48
48
|
* only when ≥1 engaged; flows straight through to `TaskResult.stats.mechanisms` via the
|
|
49
49
|
* public-stats spread. */
|
|
50
50
|
mechanisms?: {
|
|
51
|
-
finalVerifyInjected?: true;
|
|
52
51
|
finalVerifyInjections?: number;
|
|
53
52
|
attachmentsInjected?: number;
|
|
54
53
|
repetitionCuts?: number;
|
|
@@ -90,10 +89,6 @@ export interface Stats {
|
|
|
90
89
|
llmRootMicroUsd: number;
|
|
91
90
|
/** Delegated sub-agent (nested) LLM cost (micro-USD) = `stats.nested?.costMicroUsd ?? 0`. */
|
|
92
91
|
nestedSubagentMicroUsd: number;
|
|
93
|
-
/** Post-task memory-consolidation LLM cost (micro-USD) = `stats.memory?.costMicroUsd ?? 0`. Permanently
|
|
94
|
-
* 0: the runner-integrated consolidation pass is retired (the public `TaskStats` doc is the one home
|
|
95
|
-
* for what would fill it again). */
|
|
96
|
-
memoryConsolidationMicroUsd: number;
|
|
97
92
|
/** Within-task compaction LLM cost (micro-USD) = the running `compactionMicroUsd` accumulator (the
|
|
98
93
|
* category Framing-4 missed). This IS part of `costMicroUsd`, so it is subtracted from `llmRoot`. */
|
|
99
94
|
compactionMicroUsd: number;
|
|
@@ -159,7 +159,6 @@ export function assembleResult(spec, sessionId, final, stats, flags) {
|
|
|
159
159
|
stats.costBreakdown = {
|
|
160
160
|
llmRootMicroUsd: Math.max(0, stats.costMicroUsd - compactionMicroUsd),
|
|
161
161
|
nestedSubagentMicroUsd,
|
|
162
|
-
memoryConsolidationMicroUsd: 0,
|
|
163
162
|
compactionMicroUsd,
|
|
164
163
|
...(stats.sideCallMicroUsd !== undefined ? { sideCallMicroUsd: stats.sideCallMicroUsd } : {}),
|
|
165
164
|
};
|
|
@@ -26,9 +26,12 @@ export interface ToolResultSeatEvent {
|
|
|
26
26
|
details: unknown;
|
|
27
27
|
isError: boolean;
|
|
28
28
|
}
|
|
29
|
-
/** The station: the patch the loop applies to the result (`undefined` = unchanged)
|
|
29
|
+
/** The station: the patch the loop applies to the result (`undefined` = unchanged); `details` (emptied) and `isError` only on a
|
|
30
|
+
* result it withholds — nothing of the result rides on. */
|
|
30
31
|
export type ToolResultStation = (e: ToolResultSeatEvent) => Promise<{
|
|
31
32
|
content: Array<TextContent | ImageContent | DocumentContent>;
|
|
33
|
+
details?: Record<string, never>;
|
|
34
|
+
isError?: true;
|
|
32
35
|
} | undefined>;
|
|
33
36
|
export interface ToolResultStationInput {
|
|
34
37
|
/** borrowed-readonly — the leg's mods bus: `classic.PostToolUse` / `classic.PostToolUseFailure` are raised on it, and a
|
|
@@ -40,6 +43,9 @@ export interface ToolResultStationInput {
|
|
|
40
43
|
toolRosterDeltas: ToolRosterDeltaSeat;
|
|
41
44
|
/** borrowed-mutable — PreToolUse `additionalContext` per call id. Writer here: the one-shot drain (`delete`). */
|
|
42
45
|
preToolContexts: Map<string, string[]>;
|
|
46
|
+
/** borrowed-readonly — an inherited installation judges this leg's calls at its gate, so a context line may be stashed for a
|
|
47
|
+
* call though no handler of the leg's own hangs on `classic.PreToolUse`. */
|
|
48
|
+
inheritedScreens: boolean;
|
|
43
49
|
/** borrowed-readonly — prepare's abort seat; `.signal` is the post events' abort and the failure event's interrupt fact. */
|
|
44
50
|
abortController: {
|
|
45
51
|
readonly signal: AbortSignal;
|
|
@@ -61,8 +67,8 @@ export interface ToolResultStationInput {
|
|
|
61
67
|
}
|
|
62
68
|
/** The `tool_result` station, or undefined when no post / screening hook is wired (nothing to register). */
|
|
63
69
|
export declare function createToolResultStation(input: ToolResultStationInput): ToolResultStation | undefined;
|
|
64
|
-
/** What the resumed leg does with the approved call: refuse it with a sentence (it is NOT executed), or
|
|
65
|
-
* `admit` stashes the screen's context for the result's drain — called only once the call is past every belt and about
|
|
70
|
+
/** What the resumed leg does with the approved call: refuse it with a sentence (it is NOT executed), or let the approved bytes
|
|
71
|
+
* run. `admit` stashes the screen's context for the result's drain — called only once the call is past every belt and about
|
|
66
72
|
* to run (a refused call stashes nothing, the live gate's rule). */
|
|
67
73
|
export type ApprovedCallScreen = NonNullable<Prepared["approvedCallScreen"]>;
|
|
68
74
|
export type ApprovedCallVerdict = Awaited<ReturnType<ApprovedCallScreen>>;
|
|
@@ -89,15 +95,16 @@ export interface ApprovedCallScreenInput {
|
|
|
89
95
|
* the call (the decide is the upper bound; the screen can only narrow): a deny, a failed or cancelled screening, or a
|
|
90
96
|
* refused answer refuses the call in the live gate's own sentences; an ask is the question the decide already answered —
|
|
91
97
|
* unless it demands a person and the decide was the deployment's policy (the one predicate every resume station holds a
|
|
92
|
-
* decide against);
|
|
93
|
-
*
|
|
94
|
-
*
|
|
98
|
+
* decide against); context rides the result. Its three outlets are those — a refusal, an ask, the context: a rewrite is not
|
|
99
|
+
* one. The bytes that run are the bytes the decide approved (the person's edit, or the call as shown), so an `updatedInput`
|
|
100
|
+
* here is not adopted — the reference's form, where a parked answer's own input stands over the hook's. Undefined when no
|
|
101
|
+
* handler hangs on `classic.PreToolUse`.
|
|
95
102
|
*/
|
|
96
103
|
export declare function createApprovedCallScreen(input: ApprovedCallScreenInput): ApprovedCallScreen | undefined;
|
|
97
104
|
/**
|
|
98
|
-
* Why the frozen inherited chain cannot judge bytes no gate judged (an approver's edit
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
105
|
+
* Why the frozen inherited chain cannot judge bytes no gate judged (an approver's edit): the row predates the chain, a
|
|
106
|
+
* layer is opaque, or a layer declares a live remainder — undefined when the frozen projections can judge them, or when no
|
|
107
|
+
* parent constraint binds. ONE rule for the pre-claim edit rung (which refuses the edit, the row pending) and the resumed
|
|
108
|
+
* leg's belt behind it (which refuses it, the approval spent).
|
|
102
109
|
*/
|
|
103
110
|
export declare function chainCannotJudge(ig: Checkpoint["state"]["inheritedGate"]): string | undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createPreToolUseScreening, formatHookFeedback } from "../hooks.js";
|
|
2
2
|
import { classicEventBase, dispatchClassic, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
|
|
3
3
|
import { policyCannotAnswer } from "../real-approval.js";
|
|
4
|
+
import { decisionText } from "../tool-policy.js";
|
|
4
5
|
import { rosterToolName } from "../tool-roster.js";
|
|
5
6
|
import { wireOf } from "../tool-name-readings.js";
|
|
6
|
-
import { noteHostRewrite } from "../frame-settlement.js";
|
|
7
|
+
import { noteHostRewrite, settleWithheldResult } from "../frame-settlement.js";
|
|
8
|
+
import { extensionWords } from "../untrusted-egress.js";
|
|
7
9
|
function postToolUseAnswer(answer) {
|
|
8
10
|
const strings = stringMembersAnswer("classic.PostToolUse", ["additionalContext"])(answer);
|
|
9
11
|
if (strings !== undefined || typeof answer !== "object" || answer === null)
|
|
@@ -21,8 +23,8 @@ function isContentBlock(c) {
|
|
|
21
23
|
return typeof c === "object" && c !== null && typeof Reflect.get(c, "type") === "string";
|
|
22
24
|
}
|
|
23
25
|
export function createToolResultStation(input) {
|
|
24
|
-
const { modBus, blockedToolCalls, toolRosterDeltas, preToolContexts, abortController, spec, handsCwdRef, hookEnvFace, hookIdentity, permissionMode, reminderMark, frameSettlement } = input;
|
|
25
|
-
const toolResultStationArmed = modBus.hasHandlers("classic.PostToolUse") || modBus.hasHandlers("classic.PreToolUse") || modBus.hasHandlers("classic.PostToolUseFailure");
|
|
26
|
+
const { modBus, blockedToolCalls, toolRosterDeltas, preToolContexts, inheritedScreens, abortController, spec, handsCwdRef, hookEnvFace, hookIdentity, permissionMode, reminderMark, frameSettlement } = input;
|
|
27
|
+
const toolResultStationArmed = modBus.hasHandlers("classic.PostToolUse") || modBus.hasHandlers("classic.PreToolUse") || modBus.hasHandlers("classic.PostToolUseFailure") || inheritedScreens;
|
|
26
28
|
if (toolResultStationArmed) {
|
|
27
29
|
return async (e) => {
|
|
28
30
|
if (blockedToolCalls.delete(e.toolCallId)) {
|
|
@@ -30,6 +32,7 @@ export function createToolResultStation(input) {
|
|
|
30
32
|
}
|
|
31
33
|
let content = e.content;
|
|
32
34
|
let changed = false;
|
|
35
|
+
let withheld = false;
|
|
33
36
|
const post = { toolName: rosterToolName(toolRosterDeltas.current, e.toolName) };
|
|
34
37
|
const callFacts = (tool) => ({
|
|
35
38
|
...classicEventBase(hookIdentity, permissionMode.observed),
|
|
@@ -65,7 +68,13 @@ export function createToolResultStation(input) {
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
else if (modBus.hasHandlers("classic.PostToolUse")) {
|
|
68
|
-
const outcome = await dispatchClassic(modBus, "classic.PostToolUse", { ...callFacts(wireOf("hook.postToolUse", post)), output: { content: e.content, details: e.details, isError: e.isError } }, { signal: abortController.signal, checkAnswer: postToolUseAnswer }).catch(() =>
|
|
71
|
+
const outcome = await dispatchClassic(modBus, "classic.PostToolUse", { ...callFacts(wireOf("hook.postToolUse", post)), output: { content: e.content, details: e.details, isError: e.isError } }, { signal: abortController.signal, checkAnswer: postToolUseAnswer }).catch(() => ({ kind: "rejected" }));
|
|
72
|
+
if (outcome?.kind === "failed" || outcome?.kind === "rejected") {
|
|
73
|
+
content = [{ type: "text", text: formatHookFeedback(`the result of this call to "${extensionWords(post.toolName, 80)}" could not be given to the classic.PostToolUse extensions that check it: a hook that checks this result could not hand back its answer, so the result is withheld — the call ran (fail-closed)`, reminderMark) }];
|
|
74
|
+
withheld = true;
|
|
75
|
+
changed = true;
|
|
76
|
+
settleWithheldResult(frameSettlement, e.toolCallId, content);
|
|
77
|
+
}
|
|
69
78
|
const answer = outcome?.kind === "answered" ? outcome.answer : undefined;
|
|
70
79
|
const updatedOutput = updatedOutputOf(answer);
|
|
71
80
|
const patch = stringMembersOf(answer, ["additionalContext"]);
|
|
@@ -85,7 +94,7 @@ export function createToolResultStation(input) {
|
|
|
85
94
|
content = [...content, ...pre.map((t) => ({ type: "text", text: formatHookFeedback(t, reminderMark) }))];
|
|
86
95
|
changed = true;
|
|
87
96
|
}
|
|
88
|
-
return changed ? { content } : undefined;
|
|
97
|
+
return changed ? { content, ...(withheld ? { details: {}, isError: true } : {}) } : undefined;
|
|
89
98
|
};
|
|
90
99
|
}
|
|
91
100
|
return undefined;
|
|
@@ -105,20 +114,22 @@ export function createApprovedCallScreen(input) {
|
|
|
105
114
|
abortSignal: abortController.signal,
|
|
106
115
|
});
|
|
107
116
|
if (screening === undefined)
|
|
108
|
-
return {
|
|
117
|
+
return { admit: () => undefined };
|
|
109
118
|
const subject = `this call to "${toolName}"`;
|
|
110
119
|
const screened = await screening.screen(args, subject);
|
|
111
120
|
if (screened.kind === "refused")
|
|
112
|
-
return { refused: screened.reason };
|
|
121
|
+
return { refused: screened.reason, ...(screened.extension !== undefined ? { extension: screened.extension } : {}) };
|
|
122
|
+
if (screened.kind === "settled")
|
|
123
|
+
return { refused: decisionText(screened.deny) ?? `${subject} was refused` };
|
|
113
124
|
const r = screened.answer;
|
|
114
125
|
if (r?.action === "deny")
|
|
115
|
-
return { refused: screening.deniedReason(r) };
|
|
126
|
+
return { refused: screening.deniedReason(r), ...(screened.answeredBy !== undefined ? { extension: screened.answeredBy } : {}) };
|
|
116
127
|
if (r !== undefined && policyCannotAnswer(r, decidedBy))
|
|
117
128
|
return { refused: `a PreToolUse hook requires a person's approval for ${subject}, and this approval was the deployment's policy — not executed` };
|
|
118
|
-
const
|
|
119
|
-
return {
|
|
120
|
-
if (
|
|
121
|
-
preToolContexts.set(toolCallId, [
|
|
129
|
+
const contexts = screened.contexts;
|
|
130
|
+
return { admit: () => {
|
|
131
|
+
if (contexts.length > 0)
|
|
132
|
+
preToolContexts.set(toolCallId, [...contexts]);
|
|
122
133
|
} };
|
|
123
134
|
};
|
|
124
135
|
}
|