@sema-agent/core 7.72.0 → 7.74.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 +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/permission-rules.js +4 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +42 -30
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -2,8 +2,9 @@ import { CheckpointError } from "../checkpoint-store.js";
|
|
|
2
2
|
import { isGateKind, PAUSE_REGISTRY, resumeGateMatches } from "../pause-registry.js";
|
|
3
3
|
import { sanitizeUntrustedText, sentinelTagRefusal } from "../untrusted-text.js";
|
|
4
4
|
import { assertOutcomeText, captureHostDecision, describeSuppliedValue, refuseSuppliedKeys, SUPPLIED_RECORD_KEY } from "./decide-continuation.js";
|
|
5
|
+
import { isPermissionMode, PERMISSION_MODES } from "../ask-origin.js";
|
|
5
6
|
export function resumeReviewOutcome(input) {
|
|
6
|
-
const { cp, outcome, outcomeGate, wakeMessage } = input;
|
|
7
|
+
const { cp, outcome, outcomeGate, wakeMessage, configPermissionMode } = input;
|
|
7
8
|
const gateMatch = isGateKind(cp.gate.kind) && resumeGateMatches(cp.gate.kind, outcomeGate);
|
|
8
9
|
if (!gateMatch) {
|
|
9
10
|
throw new CheckpointError("checkpoint.gate_mismatch", `resume outcome (gate "${describeSuppliedValue(outcomeGate)}") does not match checkpoint gate "${cp.gate.kind}" — resume serves ${Object.entries(PAUSE_REGISTRY)
|
|
@@ -17,6 +18,7 @@ export function resumeReviewOutcome(input) {
|
|
|
17
18
|
const decision = decide.decision;
|
|
18
19
|
const editedPlan = decide.editedPlan;
|
|
19
20
|
const reason = decide.reason;
|
|
21
|
+
const permissionMode = decide.permissionMode;
|
|
20
22
|
if (decision !== "approve" && decision !== "edit" && decision !== "reject") {
|
|
21
23
|
throw new CheckpointError("checkpoint.invalid_outcome", `resume decision "${describeSuppliedValue(decision)}" is outside the plan_review domain — a plan review is exactly "approve", "edit" or "reject"; refusing pre-CAS, the checkpoint stays pending`);
|
|
22
24
|
}
|
|
@@ -24,11 +26,15 @@ export function resumeReviewOutcome(input) {
|
|
|
24
26
|
const hostDecision = captureHostDecision(cp, decide.hostDecision, "plan_review", { word: decision, allows: decision !== "reject" });
|
|
25
27
|
assertOutcomeText(editedPlan, "editedPlan");
|
|
26
28
|
assertOutcomeText(reason, "reason");
|
|
29
|
+
const modeRefusal = planApprovalModeRefusal(permissionMode, decision, configPermissionMode);
|
|
30
|
+
if (modeRefusal !== undefined)
|
|
31
|
+
throw new CheckpointError("checkpoint.invalid_outcome", `${modeRefusal}; refusing pre-CAS, the checkpoint stays pending`);
|
|
27
32
|
plainReviewOutcome = {
|
|
28
33
|
gate: "plan_review",
|
|
29
34
|
decision,
|
|
30
35
|
...(editedPlan !== undefined ? { editedPlan } : {}),
|
|
31
36
|
...(reason !== undefined ? { reason } : {}),
|
|
37
|
+
...(permissionMode !== undefined ? { permissionMode: permissionMode } : {}),
|
|
32
38
|
hostDecision,
|
|
33
39
|
};
|
|
34
40
|
}
|
|
@@ -71,6 +77,10 @@ export function resumeReviewOutcome(input) {
|
|
|
71
77
|
if (winner.reason !== undefined && winner.reason !== plainReviewOutcome.reason) {
|
|
72
78
|
throw new CheckpointError("checkpoint.reopen_revote", "an env_failed reopen replays the ALREADY-RECORDED review decision — refusing a re-vote whose reviewer note differs from the recorded one");
|
|
73
79
|
}
|
|
80
|
+
const replayedMode = plainReviewOutcome.gate === "plan_review" ? plainReviewOutcome.permissionMode : undefined;
|
|
81
|
+
if (winner.permissionMode !== undefined && winner.permissionMode !== replayedMode) {
|
|
82
|
+
throw new CheckpointError("checkpoint.reopen_revote", `an env_failed reopen replays the ALREADY-RECORDED review decision — refusing a re-vote whose approved mode ("${describeSuppliedValue(replayedMode)}") differs from the recorded one ("${winner.permissionMode}")`);
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
86
|
let plainParkOutcome;
|
|
@@ -89,3 +99,16 @@ export function resumeReviewOutcome(input) {
|
|
|
89
99
|
}
|
|
90
100
|
return { plainReviewOutcome, plainParkOutcome };
|
|
91
101
|
}
|
|
102
|
+
function planApprovalModeRefusal(mode, decision, configMode) {
|
|
103
|
+
if (mode === undefined)
|
|
104
|
+
return undefined;
|
|
105
|
+
if (!isPermissionMode(mode))
|
|
106
|
+
return `plan_review permissionMode "${describeSuppliedValue(mode)}" is not one of ${PERMISSION_MODES.map((w) => JSON.stringify(w)).join(", ")}`;
|
|
107
|
+
if (mode === "plan")
|
|
108
|
+
return 'plan_review permissionMode "plan" would keep an approved plan open — name the mode the plan runs under, or leave it out';
|
|
109
|
+
if (decision === "reject")
|
|
110
|
+
return "plan_review permissionMode names the mode an approved plan runs under, and a reject approves none — leave it out";
|
|
111
|
+
if (configMode !== undefined && configMode !== "plan" && configMode !== mode)
|
|
112
|
+
return `plan_review permissionMode "${mode}" contradicts the resume config's permissionMode "${configMode}" — name the mode once`;
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* `classifier.role_defaulted`) are never named here.
|
|
12
12
|
*
|
|
13
13
|
* The word may be a TIER the deployment's tiers leave absent (nothing bound at that tier or below it, #2614): the same reading and the same
|
|
14
|
-
* chain, with `reason: "tier_unbound"` where a name the catalog does not hold says `"unknown_model_ref"` (the `summarize` line
|
|
15
|
-
*
|
|
16
|
-
* own model). A role whose own tier DEFAULT is absent while its seat names nothing is said nowhere — nothing was stated that went unmet; the
|
|
14
|
+
* chain, with `reason: "tier_unbound"` where a name the catalog does not hold says `"unknown_model_ref"` (the `summarize` line says "or the tier
|
|
15
|
+
* default for that role" only while that role's own tier default is bound, whatever the cause: with none declared or none bound there, the
|
|
16
|
+
* compaction pass is on the conversation's own model). A role whose own tier DEFAULT is absent while its seat names nothing is said nowhere — nothing was stated that went unmet; the
|
|
17
17
|
* walk goes on to the next role of its chain (`roleHop`, `src/core/roles.ts`).
|
|
18
18
|
*
|
|
19
19
|
* Root legs only: a delegated child inherits the deployment's maps and would repeat the parent's line once per spawn.
|
|
@@ -14,7 +14,7 @@ export function roleDefaultedNotice(u, ids) {
|
|
|
14
14
|
const shown = bindingShown(u.word);
|
|
15
15
|
const reason = u.cause === "tier_unbound" ? "tier_unbound" : "unknown_model_ref";
|
|
16
16
|
const absent = reason === "tier_unbound" ? absentTierReading(u.word) : undefined;
|
|
17
|
-
const standsIn = (STANDS_IN[u.role] ?? "its fallback chain decides") + (u.role === "summarize" &&
|
|
17
|
+
const standsIn = (STANDS_IN[u.role] ?? "its fallback chain decides") + (u.role === "summarize" && u.ownTierBound ? TIER_DEFAULT_STANDS_IN : "");
|
|
18
18
|
return {
|
|
19
19
|
code: "config.entries_not_applied",
|
|
20
20
|
message: absent !== undefined
|
|
@@ -7,7 +7,7 @@ import { type AnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
|
7
7
|
* told where the mode answers it unasked; the person is told by the run's row notice (`config.entries_not_applied`, kind `stored_rule_row`), not here. A read
|
|
8
8
|
* is told once the mode has settled ({@link PermissionModeController.whenArmed}) — the run's start read comes before the deployment's
|
|
9
9
|
* arming facts bind, and a mode the arming folds back (`auto` with no classifier wired, a relaxed mode the deployment denies) would read
|
|
10
|
-
* as itself then, the person
|
|
10
|
+
* as itself then, the person's sentence stating the wrong cost and the operator's line naming a mode the leg does not run under. A call's read finds the mode
|
|
11
11
|
* settled and tells at once. */
|
|
12
12
|
export declare function ruleStoreUnreadableNotice(onNotice: RunnerDeps["onNotice"], ids: {
|
|
13
13
|
readonly sessionId: string;
|
|
@@ -8,19 +8,19 @@ export function ruleStoreUnreadableNotice(onNotice, ids, record, modeSeat) {
|
|
|
8
8
|
const tell = (at, faults, rows) => {
|
|
9
9
|
const mode = modeSeat.observed;
|
|
10
10
|
const data = faults.map((f) => ({ sources: [...f.sources], reason: f.reason }));
|
|
11
|
-
|
|
11
|
+
const relaxed = modeAnswersUnasked(mode, "rule_unreadable");
|
|
12
|
+
if (relaxed) {
|
|
12
13
|
record.oncePerSession(announceDigest(RULE_STORE_UNREADABLE_RELAXED, `${mode}\n${rows !== undefined ? "rows\n" : ""}${ruleStoreFaultsKey(faults)}`), () => deliverEngineNotice(onNotice, {
|
|
13
14
|
code: RULE_STORE_UNREADABLE_RELAXED,
|
|
14
15
|
message: ruleStoreUnreadableRelaxedSentence(mode, at, faults, rows),
|
|
15
16
|
detail: { at, mode, sessionId: ids.sessionId, runId: ids.runId, faults: data },
|
|
16
17
|
}));
|
|
17
|
-
return;
|
|
18
18
|
}
|
|
19
19
|
if (rows !== undefined)
|
|
20
20
|
return;
|
|
21
21
|
record.oncePerSession(announceDigest(RULE_STORE_UNAVAILABLE, ruleStoreFaultsKey(faults)), () => deliverEngineNotice(onNotice, {
|
|
22
22
|
code: RULE_STORE_UNAVAILABLE,
|
|
23
|
-
message: ruleStoreUnreadableNoticeSentence(at, faults),
|
|
23
|
+
message: ruleStoreUnreadableNoticeSentence(at, faults, relaxed ? mode : undefined),
|
|
24
24
|
detail: { at, sessionId: ids.sessionId, runId: ids.runId, faults: data },
|
|
25
25
|
}));
|
|
26
26
|
};
|
|
@@ -67,6 +67,9 @@ export function createHarnessHandlers(input) {
|
|
|
67
67
|
else if (ev.type === "thinking_delta" && ev.delta) {
|
|
68
68
|
pushContent({ type: "reasoning_delta", delta: ev.delta, ...ident() });
|
|
69
69
|
}
|
|
70
|
+
else if (ev.type === "thinking_end" && typeof ev.content === "string" && ev.content.length !== 0) {
|
|
71
|
+
pushContent({ type: "reasoning_end", content: ev.content, ...ident() });
|
|
72
|
+
}
|
|
70
73
|
if (callsModel && rs.budget.streamCancel && !rs.limits.budgetHit && (ev.type === "text_delta" || ev.type === "thinking_delta") && ev.delta) {
|
|
71
74
|
rs.budget.callOutputChars += ev.delta.length;
|
|
72
75
|
if (rs.budget.callOutputChars - rs.budget.lastStreamBudgetCheck >= 256) {
|
|
@@ -278,7 +281,7 @@ export function createHarnessHandlers(input) {
|
|
|
278
281
|
}, frames);
|
|
279
282
|
if (settled.gate?.disposition.kind === "denied")
|
|
280
283
|
noteExtensionCallDenied(prepared.modBus, event.toolCallId);
|
|
281
|
-
stampRowNotExecuted(event.result, settled
|
|
284
|
+
stampRowNotExecuted(event.result, settled);
|
|
282
285
|
emitTrace(rs.telemetry.tracer, () => ({
|
|
283
286
|
kind: "tool.call",
|
|
284
287
|
version: 1,
|
|
@@ -5,7 +5,7 @@ import { createSnapshotFrameSeat } from "../snapshot-frame-seat.js";
|
|
|
5
5
|
import { emitsChildRowFrames, taskStartedFrame } from "../delegation-frames.js";
|
|
6
6
|
import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js";
|
|
7
7
|
import { createReceivingChain } from "../mods/session-receive.js";
|
|
8
|
-
import { discloseDroppedPending, isSystemInjectionPriority, parkAtSeat, renderTaskNotificationXml, sessionAddressOf, taskNotificationDedupKey, taskNotificationFrame, taskNotificationNoteOptions } from "../task-notification.js";
|
|
8
|
+
import { discloseDroppedPending, isSystemInjectionPriority, isTerminalTaskNotification, parkAtSeat, renderTaskNotificationXml, sessionAddressOf, taskNotificationDedupKey, taskNotificationFrame, taskNotificationNoteOptions } from "../task-notification.js";
|
|
9
9
|
import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
|
|
10
10
|
import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
11
11
|
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
|
|
@@ -55,7 +55,7 @@ export function runIdentityWiring(input) {
|
|
|
55
55
|
deliverDelegationLifecycle(runner.deps.onDelegationLifecycle, event, delegationLifecycleNotifier, "runtask.onDelegationLifecycle", runner.deps.onNotice);
|
|
56
56
|
};
|
|
57
57
|
if (emitsChildRowFrames(prepared.hookIdentity) && (resume === undefined || resume.opensCycle === true)) {
|
|
58
|
-
const started = taskStartedFrame({ taskId: runSourceTaskId, sessionId: prepared.sessionId, model: prepared.model.id, identity: prepared.hookIdentity }, internals, ident());
|
|
58
|
+
const started = taskStartedFrame({ taskId: runSourceTaskId, sessionId: prepared.sessionId, model: prepared.model.id, identity: prepared.hookIdentity, startedAt: prepared.legStartedAt }, internals, ident());
|
|
59
59
|
queue.push(started);
|
|
60
60
|
forwardSafely(internals, started);
|
|
61
61
|
emitDelegationLifecycle({ phase: "spawn", identity: prepared.hookIdentity });
|
|
@@ -154,6 +154,7 @@ export function runIdentityWiring(input) {
|
|
|
154
154
|
for (const payload of discloseDroppedPending(pendingIdle, prepared.taskReadHandleOf, () => prepared.listBackgroundTasks({ settled: true }))) {
|
|
155
155
|
const parkedPriority = pendingIdle.priorities?.get(payload);
|
|
156
156
|
deliveredAtTurnOpen.add(taskNotificationDedupKey(payload));
|
|
157
|
+
prepared.runLedgerBook?.observeFrame(payload, isTerminalTaskNotification(payload));
|
|
157
158
|
queue.push({ ...taskNotificationFrame(payload, parkedPriority), ...ident() });
|
|
158
159
|
const handOver = (shown) => {
|
|
159
160
|
void prepared.harness.nextTurn(renderTaskNotificationXml(shown), taskNotificationNoteOptions(payload, parkedPriority)).catch(() => {
|
|
@@ -761,11 +761,11 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
761
761
|
announceToolCall(occurrences, callStart, { push: emit });
|
|
762
762
|
const decidedInput = frozenInputSnapshot(resolvedArgs);
|
|
763
763
|
occurrences.gateRound(pendingAction.toolCallId, decidedGate, decidedInput);
|
|
764
|
-
let notExecuted
|
|
764
|
+
let notExecuted;
|
|
765
765
|
const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
|
|
766
766
|
const settleEnd = async (isError, result, neverRan) => {
|
|
767
767
|
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars, reviewRequest: prepared.reviewRequestRef, verdicts: prepared.verdictLedger });
|
|
768
|
-
notExecuted = settled
|
|
768
|
+
notExecuted = settled;
|
|
769
769
|
const gate = settled.gate ?? decidedGate;
|
|
770
770
|
const word = await resume.recordExecutionOutcome(gate);
|
|
771
771
|
settleExecutionRecord(runner.deps.onNotice, word, { toolName: pendingAction.toolName, gate, sessionId: prepared.sessionId, runId: prepared.runId, scope: resume.cp.scope, identity: readGateIdentity(resume.cp.checkpointId, resume.cp.token) });
|
|
@@ -959,6 +959,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
959
959
|
const args = structuredClone(executedArgs);
|
|
960
960
|
screened?.admit();
|
|
961
961
|
onExecuteStart?.(pendingAction.toolCallId);
|
|
962
|
+
prepared.runLedgerBook?.callResumed(pendingAction.toolCallId);
|
|
962
963
|
occurrences.release(pendingAction.toolCallId);
|
|
963
964
|
prepared.suspendProgressRef.executedApproved = true;
|
|
964
965
|
const finalize = (executed) => prepared.harness.finalizeToolCall({ type: "toolCall", id: pendingAction.toolCallId, name: spelledName, arguments: executedArgs }, executedArgs, executed);
|
|
@@ -973,12 +974,14 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
973
974
|
const failed = await finalize({ result: { content: [{ type: "text", text: execError }], details: marks ?? {} }, isError: true });
|
|
974
975
|
const failedText = failed.result.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("\n");
|
|
975
976
|
await settleEnd(true, { content: failedText, ...(marks !== undefined ? { details: marks } : {}) });
|
|
977
|
+
prepared.runLedgerBook?.callEnded(pendingAction.toolCallId);
|
|
976
978
|
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(failedText, true));
|
|
977
979
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
978
980
|
return;
|
|
979
981
|
}
|
|
980
982
|
const ran = await finalize({ result: res, isError: res.isError === true });
|
|
981
983
|
await settleEnd(ran.isError, ran.result);
|
|
984
|
+
prepared.runLedgerBook?.callEnded(pendingAction.toolCallId);
|
|
982
985
|
onResolvedToolSuccess?.(pendingAction.toolName, ran.isError ? undefined : ran.result.details);
|
|
983
986
|
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, {
|
|
984
987
|
role: "toolResult",
|
|
@@ -3,6 +3,9 @@ import { boundInputHashOf } from "../canonical-json.js";
|
|
|
3
3
|
import { readPendingSteerQueue } from "../checkpoint-store.js";
|
|
4
4
|
import { scopeKeyOf } from "../isolation-scope.js";
|
|
5
5
|
import { wakeOpening } from "../run-origin.js";
|
|
6
|
+
import { runLedgerBookFor } from "../run-ledger.js";
|
|
7
|
+
import { bindRunLedgerBook } from "../run-ledger-seat.js";
|
|
8
|
+
import { rootAnchorOf } from "../leg-identity.js";
|
|
6
9
|
import { bindDeliveryObligations, createLiveNotificationLane, DeliveryObligations, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, sessionAddressOf, SystemInjectionQueue, taskNotificationDedupKey, taskNotificationFrame, taskNotificationNoteOptions } from "../task-notification.js";
|
|
7
10
|
import { settleConsumedFrame, settleUndeliveredFrame } from "../frame-settlement.js";
|
|
8
11
|
import { createReceivingChain } from "../mods/session-receive.js";
|
|
@@ -85,6 +88,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
85
88
|
};
|
|
86
89
|
const receiving = createReceivingChain(() => prepared.receiveSeat);
|
|
87
90
|
const unsubscribeTaskNotifications = taskNotificationQueue.subscribe((item) => {
|
|
91
|
+
runLedgerBook?.observeFrame(item.payload, isTerminalTaskNotification(item.payload));
|
|
88
92
|
queue.push({ ...taskNotificationFrame(item.payload, item.priority), ...notificationIdent() });
|
|
89
93
|
receiving.pass(item.payload, {
|
|
90
94
|
handOver: (shown) => handOver(item, shown),
|
|
@@ -124,7 +128,13 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
124
128
|
});
|
|
125
129
|
const takeOnThisLane = laneSeat.take;
|
|
126
130
|
const takeAsDestination = laneSeat.takeAsDestination;
|
|
131
|
+
const refusePeerTaskFrame = (notification) => {
|
|
132
|
+
runner.deps.onError?.(new Error(`peer_task notification ${notification.task_id} refused: no peer-task producer is active on this lane in this engine release`), { phase: "degraded", sessionId: notificationAddress?.sessionId ?? "", classification: "peer-task-frame-refused" });
|
|
133
|
+
return Promise.resolve("refused");
|
|
134
|
+
};
|
|
127
135
|
const injectTaskNotification = (notification, opts) => {
|
|
136
|
+
if (notification.task_type === "peer_task")
|
|
137
|
+
return refusePeerTaskFrame(notification);
|
|
128
138
|
const priority = opts?.priority ?? "later";
|
|
129
139
|
return new Promise((resolve) => {
|
|
130
140
|
const own = takeOnThisLane(notification, priority, resolve);
|
|
@@ -140,14 +150,20 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
140
150
|
const peerInboundChainRef = internals?.peerInboundChainRef ?? createPeerInboundChainRef();
|
|
141
151
|
const modelCatalog = runner.deps.models;
|
|
142
152
|
const deliveryObligations = new DeliveryObligations();
|
|
153
|
+
const runLedgerBook = runLedgerBookFor(spec, resume !== undefined ? { section: resume.cp.state.runLedger } : undefined, internals?.rowTaskId);
|
|
154
|
+
if (taskIdRef !== undefined && runLedgerBook?.taskId !== undefined)
|
|
155
|
+
taskIdRef.current = runLedgerBook.taskId;
|
|
143
156
|
const laneSink = (notification, opts) => {
|
|
157
|
+
if (notification.task_type === "peer_task")
|
|
158
|
+
return refusePeerTaskFrame(notification);
|
|
144
159
|
try {
|
|
145
160
|
upstreamTaskNotification?.(notification, opts);
|
|
146
161
|
}
|
|
147
162
|
catch {
|
|
148
163
|
}
|
|
164
|
+
const terminal = isTerminalTaskNotification(notification);
|
|
149
165
|
const outcome = injectTaskNotification(notification, opts);
|
|
150
|
-
if (
|
|
166
|
+
if (terminal)
|
|
151
167
|
deliveryObligations.discharge(notification);
|
|
152
168
|
return outcome;
|
|
153
169
|
};
|
|
@@ -162,8 +178,11 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
162
178
|
sessionReadStates,
|
|
163
179
|
sessionModeSeats, sessionFastModeSeats, sessionPromptSeats, sessionMcpPools,
|
|
164
180
|
onTaskNotification: laneSink,
|
|
181
|
+
runLedgerBook,
|
|
165
182
|
}, self, taskIdRef, holdSessionLock, legWrites, (destination, delivery) => pendingSessionNotifications.discardsStaleNotice(destination, delivery), promptSubmitRef, runEnd);
|
|
166
183
|
settlementSeat = prepared.frameSettlement;
|
|
184
|
+
if (runLedgerBook !== undefined)
|
|
185
|
+
bindRunLedgerBook(runLedgerBook, prepared, rootAnchorOf(internals, prepared.sessionId, prepared.sessionIncarnation).occupant);
|
|
167
186
|
try {
|
|
168
187
|
pendingSessionNotifications.admit(sessionAddressOf(prepared), prepared.sessionBox);
|
|
169
188
|
const settling = pendingSessionNotifications.settleBoxDebts(sessionAddressOf(prepared), prepared.abortController.signal);
|
|
@@ -15,6 +15,8 @@ import { emitTrace } from "../trace.js";
|
|
|
15
15
|
import { deliverEngineNotice, parentLegIds, settleOwedUserInput } from "../types.js";
|
|
16
16
|
import { assembleResult } from "./assemble-result.js";
|
|
17
17
|
import { discloseUnconsumedEndings, haltConsumed } from "./halt-attribution.js";
|
|
18
|
+
import { runLedgerIdentityOf } from "../run-ledger.js";
|
|
19
|
+
import { reapTaskAgentsBeforeLastWord } from "../run-ledger-seat.js";
|
|
18
20
|
import { forwardSafely } from "./forward-sink.js";
|
|
19
21
|
import { completedPastLimitNotice, limitCrossedOf, TIMER_LATENESS_REPORT_MS } from "./clock-and-limits.js";
|
|
20
22
|
import { verdictRefusedNotice } from "./verdict-refusal.js";
|
|
@@ -37,6 +39,10 @@ export async function runSettleAndTeardown(input) {
|
|
|
37
39
|
const { spec, queue, prepared, resume, internals, rs, stats, ident, loopLatch, timeout, ownCommittedTailRef, legWrites, emitDelegationLifecycle, taskIdRef, manualCompactRef, drainManualCompact, final, threw, abortedLive, userInterruptedLive, answerSettled, strandedHumanAnswers, reasoningResolution, deliveryObligations, compactionBreaker, owedUserInput, setResult, onSuggestions, onSuspend, runner, sessions, display } = input;
|
|
38
40
|
const bound = settleBound(), writeOwedSessionRecords = legEndRecords(prepared, rs, runner, bound);
|
|
39
41
|
let rowAnswer;
|
|
42
|
+
const runEndNow = () => prepared.pausedRef.current !== undefined
|
|
43
|
+
? undefined
|
|
44
|
+
: runEndCauseOf({ ceiling: oneShotEndingBook(spec.oneShot, deliveryObligations)?.stoppedWaitingAtCeiling === true, abortedLive, userInterrupted: userInterruptedLive, userHalted: haltConsumed(prepared.harness.haltConsumption()), walltime: timeout.fired, turns: rs.limits.turnsExceeded, spendStopped: rs.limits.budgetHit !== undefined });
|
|
45
|
+
const stopSourceNow = () => abortedLive && !answerSettled && !timeout.fired && !rs.limits.turnsExceeded && rs.limits.budgetHit === undefined && prepared.pausedRef.current === undefined ? "user" : "parent";
|
|
40
46
|
try {
|
|
41
47
|
const shown = display?.settled();
|
|
42
48
|
if (shown !== undefined)
|
|
@@ -137,7 +143,7 @@ export async function runSettleAndTeardown(input) {
|
|
|
137
143
|
if (abortedLive && answerSettled && result.terminal.kind === "completed") {
|
|
138
144
|
const origin = runEndCauseOf({ ceiling: false, abortedLive, userInterrupted: userInterruptedLive, userHalted: false, walltime: timeout.fired, turns: rs.limits.turnsExceeded, spendStopped: rs.limits.budgetHit !== undefined });
|
|
139
145
|
const waitedFor = stopTailWaitedFor(waitStoppedAtCeiling ? undefined : endingBook, endingReach);
|
|
140
|
-
deliverEngineNotice(runner.deps.onNotice, interruptUnconsumedNotice(waitedFor, origin, { sessionId: prepared.sessionId, runId: rs.telemetry.runId, ...legNoticeTaskId(prepared) }));
|
|
146
|
+
deliverEngineNotice(runner.deps.onNotice, interruptUnconsumedNotice(waitedFor, origin, { sessionId: prepared.sessionId, runId: rs.telemetry.runId, ...legNoticeTaskId(prepared) }, result.limitCrossed?.axis));
|
|
141
147
|
}
|
|
142
148
|
if (result.limitCrossed !== undefined && result.terminal.kind === "completed")
|
|
143
149
|
deliverEngineNotice(runner.deps.onNotice, completedPastLimitNotice(result.limitCrossed, { sessionId: prepared.sessionId, runId: rs.telemetry.runId, ...legNoticeTaskId(prepared) }));
|
|
@@ -262,6 +268,18 @@ export async function runSettleAndTeardown(input) {
|
|
|
262
268
|
}));
|
|
263
269
|
if (prepared.pausedRef.current !== undefined)
|
|
264
270
|
await yieldParkedLegBackground(prepared, runner);
|
|
271
|
+
if (prepared.runLedgerBook === undefined) {
|
|
272
|
+
const kept = runLedgerIdentityOf(spec, resume !== undefined ? { section: resume.cp.state.runLedger } : undefined, undefined);
|
|
273
|
+
if (kept !== undefined && "notKept" in kept)
|
|
274
|
+
result.runLedgerNotKept = kept.notKept;
|
|
275
|
+
}
|
|
276
|
+
if (prepared.runLedgerBook !== undefined) {
|
|
277
|
+
if (result.terminal.kind !== "paused")
|
|
278
|
+
await reapTaskAgentsBeforeLastWord(prepared.registryAccess, stopSourceNow(), runEndNow());
|
|
279
|
+
const ledger = prepared.runLedgerBook.snapshot(result.terminal.kind === "paused" ? { kind: "park" } : { kind: "run_end" });
|
|
280
|
+
result.runLedger = ledger;
|
|
281
|
+
await settleTeardownLeg(async () => void (await prepared.session.appendRunLedger?.(ledger)), "session.appendRunLedger (settle leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
|
|
282
|
+
}
|
|
265
283
|
await writeOwedSessionRecords();
|
|
266
284
|
result.continuesFrom = await settledContinuesFrom({
|
|
267
285
|
closed: legWrites.close(), bound,
|
|
@@ -305,20 +323,11 @@ export async function runSettleAndTeardown(input) {
|
|
|
305
323
|
finally {
|
|
306
324
|
settleOwedUserInput(owedUserInput, !prepared.suspendProgressRef.executedApproved, { taskId: prepared.taskId, sessionId: prepared.sessionId, runId: prepared.runId, parent: parentLegIds(internals) }, runner.deps.onNotice);
|
|
307
325
|
await writeOwedSessionRecords();
|
|
308
|
-
const runEnd =
|
|
309
|
-
? undefined
|
|
310
|
-
: runEndCauseOf({ ceiling: oneShotEndingBook(spec.oneShot, deliveryObligations)?.stoppedWaitingAtCeiling === true, abortedLive, userInterrupted: userInterruptedLive, userHalted: haltConsumed(prepared.harness.haltConsumption()), walltime: timeout.fired, turns: rs.limits.turnsExceeded, spendStopped: rs.limits.budgetHit !== undefined });
|
|
326
|
+
const runEnd = runEndNow();
|
|
311
327
|
const envGoing = envDestroyedAtTeardown(prepared, resume?.cp.state.workspaceHandle !== undefined && rowKeepsWhatItsRetryNeeds(rowAnswer));
|
|
312
328
|
const ownedEnvDying = envGoing !== undefined && isIsolated(envGoing);
|
|
313
329
|
await settleTeardownLeg(() => defaultTaskRegistry.settleKilledForOwner({ ...prepared.registryAccess, sessionId: prepared.sessionId }, {
|
|
314
|
-
source:
|
|
315
|
-
!answerSettled &&
|
|
316
|
-
!timeout.fired &&
|
|
317
|
-
!rs.limits.turnsExceeded &&
|
|
318
|
-
rs.limits.budgetHit === undefined &&
|
|
319
|
-
prepared.pausedRef.current === undefined
|
|
320
|
-
? "user"
|
|
321
|
-
: "parent",
|
|
330
|
+
source: stopSourceNow(),
|
|
322
331
|
skipSessionScoped: true,
|
|
323
332
|
envDying: ownedEnvDying,
|
|
324
333
|
retainProcesses: spec.retainBackgroundProcesses === true,
|
|
@@ -6,6 +6,7 @@ import { classicEventBase, legEventsOf } from "../mods/stations.js";
|
|
|
6
6
|
import { judgeStopFamily, stopFamilyBlockText, stopFamilyContextText, stopFamilyWord, teammateStopPass } from "../mods/teammate-stations.js";
|
|
7
7
|
import { heldInProgress } from "../../tools/task-list.js";
|
|
8
8
|
import { steeringPreview } from "./steering-preview.js";
|
|
9
|
+
import { ceilingTurnNote, stopTailWaitedFor } from "./stop-tail-notice.js";
|
|
9
10
|
import { taskAxisCrossed } from "./clock-and-limits.js";
|
|
10
11
|
import { oneShotEndingBook, oneShotWaitCeilingOf } from "../task-notification.js";
|
|
11
12
|
import { FINAL_VERIFICATION_MARK } from "./clock-and-limits.js";
|
|
@@ -40,6 +41,7 @@ export function runStopAndFinalVerify(input) {
|
|
|
40
41
|
const owed = oneShotEndingBook(spec.oneShot, deliveryObligations);
|
|
41
42
|
if (stopArmed || teammateArmed || finalVerificationOn || owed !== undefined) {
|
|
42
43
|
let consecutiveBlocks = 0;
|
|
44
|
+
let ceilingTurnGiven = false;
|
|
43
45
|
const ending = () => prepared.abortController.signal.aborted || prepared.pausedRef.current !== undefined || prepared.batchHaltRef.current !== undefined || taskAxisCrossed(rs.limits, walltimeMonotonicDeadline);
|
|
44
46
|
prepared.harness.setStopGate(async () => {
|
|
45
47
|
if (ending())
|
|
@@ -48,6 +50,10 @@ export function runStopAndFinalVerify(input) {
|
|
|
48
50
|
const waitEnd = pushedBack.length === 0 ? await owed?.waitOut(AbortSignal.any([prepared.abortController.signal, callerStop.signal]), () => !ending() && prepared.harness.pendingInjectionCount() === 0, (wake) => prepared.harness.subscribe((e) => void (e.type === "queue_update" && wake())), oneShotWaitCeilingOf(spec.limits)) : undefined;
|
|
49
51
|
if (waitEnd === "signal")
|
|
50
52
|
prepared.harness.consumeStopAtEnding();
|
|
53
|
+
if (waitEnd === "ceiling" && prepared.runLedgerBook !== undefined && !ceilingTurnGiven && owed !== undefined) {
|
|
54
|
+
ceilingTurnGiven = true;
|
|
55
|
+
return [{ role: "user", engineMinted: true, content: ceilingTurnNote(stopTailWaitedFor(owed, { read: { ...prepared.registryAccess, sessionId: prepared.sessionId }, owner: prepared.registryAccess }), oneShotWaitCeilingOf(spec.limits)), timestamp: Date.now() }];
|
|
56
|
+
}
|
|
51
57
|
return pushedBack;
|
|
52
58
|
});
|
|
53
59
|
async function pushBack() {
|
|
@@ -70,7 +70,7 @@ export function runTelemetryAndBudgetSeats(input) {
|
|
|
70
70
|
taskIdRef.current = rs.telemetry.taskId;
|
|
71
71
|
taskIdRef.sessionId = prepared.sessionId;
|
|
72
72
|
}
|
|
73
|
-
rs.telemetry.taskStart =
|
|
73
|
+
rs.telemetry.taskStart = prepared.legStartedAt;
|
|
74
74
|
rs.telemetry.taskStartMonotonic = performance.now();
|
|
75
75
|
const discloseNoteTaskRunFailure = (err) => {
|
|
76
76
|
try {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NoticeRoute } from "../leg-identity.js";
|
|
1
2
|
import type { Model } from "../../internal/llm.js";
|
|
2
3
|
import { type CheckpointToken, type ResumeOutcome } from "../checkpoint-store.js";
|
|
3
4
|
import { type TaskOutcome } from "../task-outcome.js";
|
|
@@ -13,6 +14,7 @@ export type { ResumeTaskConfig } from "./contracts.js";
|
|
|
13
14
|
import { type ResumeConfigQuestion, type ResumeConfigVerdict } from "../resume-config-judge.js";
|
|
14
15
|
import { type TaskStartVerdict } from "../task-start-judge.js";
|
|
15
16
|
import type { SessionChanges, SessionChangesRequest } from "../session-changes.js";
|
|
17
|
+
import { type InstructionPreviewResult } from "../instruction-preview.js";
|
|
16
18
|
import type { CompactSessionRequest, CompactSessionResult } from "../auto-compaction.js";
|
|
17
19
|
import type { RewindFilesRequest, RewindFilesResult } from "../file-history-store.js";
|
|
18
20
|
import type { RewindConversationRequest, RewindConversationResult } from "../rewind-conversation.js";
|
|
@@ -87,7 +89,7 @@ export declare class Runner implements RunnerSelfSeat {
|
|
|
87
89
|
* into private deps. */
|
|
88
90
|
emitTaskOutcome(outcome: TaskOutcome): void;
|
|
89
91
|
/** Announce a composition's own fact on `RunnerDeps.onNotice` (read at the call: `swapDeps` replaces the deps): {@link RunnerSelfSeat.emitNotice}. */
|
|
90
|
-
emitNotice(notice: EngineNotice): void;
|
|
92
|
+
emitNotice(notice: EngineNotice, route?: NoticeRoute): void;
|
|
91
93
|
/** Whether a child this Runner runs can be placed in another tree: {@link RunnerSelfSeat.canRerootChild}. */
|
|
92
94
|
canRerootChild(): boolean;
|
|
93
95
|
/** A completion addressed to a tree's root, through this Runner's route: {@link RunnerSelfSeat.sessionCompletionLane}. */
|
|
@@ -162,6 +164,8 @@ export declare class Runner implements RunnerSelfSeat {
|
|
|
162
164
|
rewindFiles(request: RewindFilesRequest): Promise<RewindFilesResult>;
|
|
163
165
|
/** What changed in a session's files, read outside any run — the contract is {@link readSessionChanges}'s (no lock: a leg running on the session does not refuse it; no gate, no frame, no write). */
|
|
164
166
|
readSessionChanges(request: SessionChangesRequest): Promise<SessionChanges>;
|
|
167
|
+
/** Pre-run instruction-file manifest preview via the lane's single first-load reading (zero model calls, session/read-state writes, or notices; coded refusal on bad specs). */
|
|
168
|
+
previewInstructions(spec: TaskSpec, internals?: RunInternals): Promise<InstructionPreviewResult>;
|
|
165
169
|
/** The out-of-run manual compaction, no run and no user turn — the contract is {@link compactIdleSession}'s (the one pass every lane runs; refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled, and while the session is parked at a pending checkpoint). */
|
|
166
170
|
compactSession(request: CompactSessionRequest): Promise<CompactSessionResult>;
|
|
167
171
|
/** The out-of-run conversation rewind, no model call and no run — the contract is {@link rewindSessionConversation}'s (the landing a run's `resumeAt` + `resumeAtMode: "before"` makes; refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled, and while the session is parked at a pending checkpoint; `dryRun` judges the same and writes nothing). */
|
|
@@ -335,6 +339,6 @@ export declare class Runner implements RunnerSelfSeat {
|
|
|
335
339
|
*/
|
|
336
340
|
private resumeHandoff;
|
|
337
341
|
}
|
|
338
|
-
/** Convenience: one-shot run with explicit deps (creates a throwaway Runner). */
|
|
342
|
+
/** Convenience: one-shot run with explicit deps (creates a throwaway Runner; delivers a construction refusal as a failed TaskResult rather than throwing synchronously). */
|
|
339
343
|
export declare function runTask(spec: TaskSpec, deps: RunnerDeps): Promise<TaskResult>;
|
|
340
344
|
export type { TaskEvent, TaskStream };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { classicEventBase, legEventsOf, legNoticeTaskId } from "../mods/stations.js";
|
|
2
2
|
import { openMessageDisplay } from "../mods/message-display.js";
|
|
3
|
-
import { legTaskIdOf } from "../leg-identity.js";
|
|
4
|
-
import {
|
|
3
|
+
import { legNoticeAdmission, legTaskIdOf } from "../leg-identity.js";
|
|
4
|
+
import { restoreRowIdentity, resumedDeclaredTaskId } from "./checkpoint-scope.js";
|
|
5
5
|
import { checkpointClaimRevOf, checkpointRevOf } from "../checkpoint-generation.js";
|
|
6
6
|
import { judgedOwnerSeat, readRootOccupant } from "./delegation-owner.js";
|
|
7
7
|
import { raceSettlementAgainstSignal } from "./abort-race.js";
|
|
@@ -59,7 +59,7 @@ import { resumePreflight } from "./resume-preflight.js";
|
|
|
59
59
|
import { resumeClaim } from "./resume-claim.js";
|
|
60
60
|
import { voidVerifierPause } from "./void-verifier-pause.js";
|
|
61
61
|
import { LocalClaims } from "./local-claims.js";
|
|
62
|
-
import { streamSettleBackstop } from "./stream-settle-backstop.js";
|
|
62
|
+
import { failedPreRunResult, streamSettleBackstop } from "./stream-settle-backstop.js";
|
|
63
63
|
import { streamReap } from "./stream-reap.js";
|
|
64
64
|
import { streamSteerVerb } from "./stream-steer-verb.js";
|
|
65
65
|
import { bindAuthoredSteer } from "../input-author.js";
|
|
@@ -90,6 +90,7 @@ import { deploymentCanRerootChild } from "./child-tree.js";
|
|
|
90
90
|
import { rewindSessionFiles } from "./rewind-files.js";
|
|
91
91
|
import { rewindOutcomeOf } from "./rewind-outcome.js";
|
|
92
92
|
import { readSessionChanges } from "./read-session-changes.js";
|
|
93
|
+
import { previewInstructionsOf } from "../instruction-preview.js";
|
|
93
94
|
import { compactIdleSession } from "./compact-session.js";
|
|
94
95
|
import { rewindSessionConversation } from "./rewind-conversation.js";
|
|
95
96
|
import { egressThrownText } from "../untrusted-egress.js";
|
|
@@ -171,8 +172,8 @@ export class Runner {
|
|
|
171
172
|
emitTaskOutcome(outcome) {
|
|
172
173
|
emitTaskOutcome(this.deps, outcome);
|
|
173
174
|
}
|
|
174
|
-
emitNotice(notice) {
|
|
175
|
-
deliverEngineNotice(this.deps.onNotice, notice);
|
|
175
|
+
emitNotice(notice, route) {
|
|
176
|
+
deliverEngineNotice(this.deps.onNotice, notice, route !== undefined ? legNoticeAdmission(route, (destination, delivery) => this.pendingSessionNotifications.discardsStaleNotice(destination, delivery)) : undefined);
|
|
176
177
|
}
|
|
177
178
|
canRerootChild() { return deploymentCanRerootChild(this.deps); }
|
|
178
179
|
sessionCompletionLane(root, unkept) { return this.pendingSessionNotifications.completionLaneOf(root, unkept); }
|
|
@@ -294,6 +295,7 @@ export class Runner {
|
|
|
294
295
|
}
|
|
295
296
|
rewindFiles(request) { return rewindSessionFiles({ deps: this.deps, sessions: this.sessions, readStates: this.sessionReadStates, ...this.verbLockSeats }, request); }
|
|
296
297
|
readSessionChanges(request) { return readSessionChanges({ deps: this.deps, sessions: this.sessions }, request); }
|
|
298
|
+
previewInstructions(spec, internals) { return previewInstructionsOf({ deps: this.deps, sessions: this.sessions, readStates: this.sessionReadStates }, spec, internals); }
|
|
297
299
|
compactSession(request) { return compactIdleSession({ deps: this.deps, liveModels: () => this.deps.models, sessions: this.sessions, ...this.verbLockSeats }, request); }
|
|
298
300
|
rewindConversation(request) { return rewindSessionConversation({ deps: this.deps, sessions: this.sessions, ...this.verbLockSeats }, request); }
|
|
299
301
|
forgetMcpFailure(request) { return forgetSessionMcpFailure(this.sessionMcpPools, request, this.deps.peerSeat); }
|
|
@@ -305,6 +307,8 @@ export class Runner {
|
|
|
305
307
|
throw new TypeError("runTaskStream: `resume` must be a ResumeRun carrying `outcome` — got a value without one. " +
|
|
306
308
|
"(Note the parameter order: runTaskStream(spec, resume?, internals?) — internals is the THIRD parameter.)");
|
|
307
309
|
}
|
|
310
|
+
if (resume !== undefined)
|
|
311
|
+
internals = restoreRowIdentity(internals, resume.cp.state);
|
|
308
312
|
const entry = readEntrySpec(spec, () => this.deps.models);
|
|
309
313
|
spec = entry.spec;
|
|
310
314
|
const entryActor = entry.actor;
|
|
@@ -341,7 +345,7 @@ export class Runner {
|
|
|
341
345
|
};
|
|
342
346
|
const runStartedAt = Date.now();
|
|
343
347
|
const rewind = rewindOutcomeOf(spec);
|
|
344
|
-
const taskIdRef = { current: legTaskIdOf(spec,
|
|
348
|
+
const taskIdRef = { current: legTaskIdOf(spec, internals, undefined), sessionId: spec.sessionId, intake: { committed: false }, ...(judgedOwnerSeat(internals) !== undefined ? { rowVerified: false } : {}), ...(rewind !== undefined ? { rewind } : {}) };
|
|
345
349
|
let held = resumeHold === undefined ? undefined : { sessionId: resumeHold.sessionId, taken: Promise.resolve() };
|
|
346
350
|
let releaseLock = resumeHold?.release;
|
|
347
351
|
const holdSessionLock = (sessionId) => {
|
|
@@ -641,7 +645,7 @@ export class Runner {
|
|
|
641
645
|
async resumeLadder(token, outcome, admitted) {
|
|
642
646
|
const { config, internals, store, cp, outcomeGate, resumeSignal, wakeMessage, chainRefusal, rootLayerUnrestated } = admitted;
|
|
643
647
|
const readGeneration = checkpointRevOf(cp);
|
|
644
|
-
const { plainReviewOutcome, plainParkOutcome } = resumeReviewOutcome({ cp, outcome, outcomeGate, wakeMessage });
|
|
648
|
+
const { plainReviewOutcome, plainParkOutcome } = resumeReviewOutcome({ cp, outcome, outcomeGate, wakeMessage, configPermissionMode: config.permissionMode });
|
|
645
649
|
const { plainPolicyOutcome: capturedPolicyOutcome, redeemedAnswer } = resumePolicyOutcome({ cp, outcome, config, runner: this.depsSeat });
|
|
646
650
|
const { resumeInternals, chainRung } = resumeCheckpointScreen({ cp, resumeSignal, internals, tools: config.tools, runner: this.depsSeat, chainRefusal });
|
|
647
651
|
const { recheckGovernanceWindow } = resumeInternalsAndConfig({ cp, config, internals, outcomeGate, runner: this.depsSeat, resumeSignal, chainRefused: chainRung !== undefined });
|
|
@@ -687,11 +691,13 @@ export class Runner {
|
|
|
687
691
|
const answerFace = plainPolicyOutcome !== undefined && redeemedAnswer !== undefined
|
|
688
692
|
? answerFaceForRedeemedCall(redeemedAnswer, plainPolicyOutcome.boundCallId, config.onQuestion ?? this.deps.onQuestion, boundInputHashOf(cp.pendingAction.args?.questions))
|
|
689
693
|
: undefined;
|
|
694
|
+
const declaredTaskId = resumedDeclaredTaskId(config, cp.state);
|
|
690
695
|
const spec = {
|
|
691
696
|
...config,
|
|
692
697
|
...((config.principal || undefined) === undefined && (cp.principal || undefined) !== undefined ? { principal: cp.principal } : {}),
|
|
693
698
|
...((config.isolationScope || undefined) === undefined && (cp.isolationScope || undefined) !== undefined ? { isolationScope: cp.isolationScope } : {}),
|
|
694
699
|
...(config.durableApproval === undefined && cp.durableApproval === false ? { durableApproval: cp.durableApproval } : {}),
|
|
700
|
+
...(declaredTaskId !== undefined ? { taskId: declaredTaskId } : {}),
|
|
695
701
|
objective: "",
|
|
696
702
|
sessionId: cp.sessionId,
|
|
697
703
|
requireExistingSession: true,
|
|
@@ -724,6 +730,12 @@ async function sessionLockUnlessAborted(taken, signal, row) {
|
|
|
724
730
|
void taken.then((release) => release(), () => { });
|
|
725
731
|
throw new CheckpointError("checkpoint.resume_aborted", resumeCancelledSentence("while it waited for the session to be free", row));
|
|
726
732
|
}
|
|
727
|
-
export function runTask(spec, deps) {
|
|
728
|
-
|
|
733
|
+
export async function runTask(spec, deps) {
|
|
734
|
+
try {
|
|
735
|
+
const runner = enterConfigDoor("deps", () => new Runner(deps));
|
|
736
|
+
return runner.runTask(spec);
|
|
737
|
+
}
|
|
738
|
+
catch (err) {
|
|
739
|
+
return failedPreRunResult(err, spec);
|
|
740
|
+
}
|
|
729
741
|
}
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
* `"unknown"` (or a read that throws) is a wiring fault: it is announced to the operator under the existing
|
|
24
24
|
* capability-shape code, once per run, and the person is told nothing — no reading defaults to `"unknown"`.
|
|
25
25
|
*
|
|
26
|
-
* The same seat relays the environment's
|
|
26
|
+
* The same seat relays the environment's two other disclosures about what its shell gets (`relayLateDeclaration`,
|
|
27
|
+
* `relayModelShellDropped`, below).
|
|
27
28
|
*/
|
|
28
29
|
import { type EngineNotice } from "../engine-notice.js";
|
|
29
30
|
import { type PeerEntriesTaken } from "../secret-env.js";
|
|
@@ -31,13 +32,14 @@ import type { ExecutionEnv } from "../../internal/harness.js";
|
|
|
31
32
|
import type { Prepared } from "./contracts.js";
|
|
32
33
|
export type WithheldShellEnvSeatInput = Pick<Prepared, "runId" | "sessionId" | "legNotice" | "toolRosterDeltas" | "announcedListingsRef" | "frameReceipts"> & {
|
|
33
34
|
readonly harness: {
|
|
34
|
-
readonly env: Pick<ExecutionEnv, "withheldEnv" | "lateDeclarationNotice">;
|
|
35
|
+
readonly env: Pick<ExecutionEnv, "withheldEnv" | "lateDeclarationNotice" | "modelShellDropped">;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
38
|
/** The seat, per run. `onToolStart` and `onToolEnd` never throw: a diagnostic may not be what fails a call. `peerEntries` = the (variable,
|
|
38
|
-
* entry) pairs the leg's receipt took in (leg-receipt.ts `LegReceipt.peerEntries`)
|
|
39
|
+
* entry) pairs the leg's receipt took in (leg-receipt.ts `LegReceipt.peerEntries`) and `isolationScope` = the leg's isolation scope
|
|
39
40
|
* (isolation-scope.ts `legIdentityOf`): the entries its notice names, each for its variable, are those pairs and the ones the host declared
|
|
40
|
-
* to every leg or
|
|
41
|
+
* to every leg or to the scope of the session the notice is delivered to — read off the leg's one notice route (`Prepared.legNotice`:
|
|
42
|
+
* a delegated leg's root address carries its scope), by the notice's own reading (secret-env.ts `withheldEnvUserNotice`). */
|
|
41
43
|
export declare function createWithheldShellEnvSeat(prepared: WithheldShellEnvSeatInput, onNotice: ((notice: EngineNotice) => void) | undefined, peerEntries: PeerEntriesTaken | undefined, isolationScope?: string): {
|
|
42
44
|
onToolStart(toolName: string): void;
|
|
43
45
|
onToolEnd(): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
2
|
+
import { shellStateEnvDroppedNotice } from "../model-shell.js";
|
|
2
3
|
import { withheldEnvUserNotice } from "../secret-env.js";
|
|
3
4
|
import { isEngineShellFace } from "../tool-catalog-entries.js";
|
|
4
5
|
import { toolCallFaceOf } from "../tool-roster.js";
|
|
@@ -18,6 +19,24 @@ function readWithheldEnv(env) {
|
|
|
18
19
|
return { malformed: "unreadable" };
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
function relayModelShellDropped(prepared, onNotice) {
|
|
23
|
+
const told = new WeakMap();
|
|
24
|
+
return () => {
|
|
25
|
+
try {
|
|
26
|
+
const record = prepared.harness.env.modelShellDropped;
|
|
27
|
+
const entries = readMember(record, "entries");
|
|
28
|
+
if (typeof record !== "object" || record === null || !Array.isArray(entries))
|
|
29
|
+
return;
|
|
30
|
+
const fresh = entries.slice(told.get(record) ?? 0);
|
|
31
|
+
if (fresh.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
told.set(record, entries.length);
|
|
34
|
+
deliverEngineNotice(onNotice, shellStateEnvDroppedNotice(fresh));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
21
40
|
function relayLateDeclaration(prepared, onNotice) {
|
|
22
41
|
let told = false;
|
|
23
42
|
return () => {
|
|
@@ -43,9 +62,12 @@ function relayLateDeclaration(prepared, onNotice) {
|
|
|
43
62
|
export function createWithheldShellEnvSeat(prepared, onNotice, peerEntries, isolationScope) {
|
|
44
63
|
let shapeFaultTold = false;
|
|
45
64
|
const relay = relayLateDeclaration(prepared, onNotice);
|
|
46
|
-
const
|
|
65
|
+
const relayDropped = relayModelShellDropped(prepared, onNotice);
|
|
47
66
|
return {
|
|
48
|
-
onToolEnd:
|
|
67
|
+
onToolEnd: () => {
|
|
68
|
+
relay();
|
|
69
|
+
relayDropped();
|
|
70
|
+
},
|
|
49
71
|
onToolStart(toolName) {
|
|
50
72
|
if (!isEngineShellFace(toolCallFaceOf(prepared.toolRosterDeltas.current, toolName)))
|
|
51
73
|
return;
|
|
@@ -61,7 +83,7 @@ export function createWithheldShellEnvSeat(prepared, onNotice, peerEntries, isol
|
|
|
61
83
|
});
|
|
62
84
|
return;
|
|
63
85
|
}
|
|
64
|
-
const notice = withheldEnvUserNotice(answer, { ...prepared.legNotice.route.address, runId: prepared.runId }, peerEntries,
|
|
86
|
+
const notice = withheldEnvUserNotice(answer, { ...prepared.legNotice.route.address, runId: prepared.runId }, peerEntries, isolationScope, prepared.legNotice.route.destination?.scope);
|
|
65
87
|
if (notice === undefined)
|
|
66
88
|
return;
|
|
67
89
|
const d = notice.detail;
|