@sema-agent/core 7.60.0 → 7.62.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 +917 -0
- package/README.md +2 -2
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/agent-transcript-tool.js +1 -1
- package/dist/agents/cascade.d.ts +71 -12
- package/dist/agents/cascade.js +61 -21
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -0
- package/dist/agents/inherited-tool-pool.d.ts +5 -3
- package/dist/agents/inherited-tool-pool.js +2 -2
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +49 -10
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.js +3 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +7 -4
- package/dist/agents/send-message-tool.d.ts +8 -10
- package/dist/agents/send-message-tool.js +43 -23
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +36 -41
- package/dist/agents/subagent.js +245 -200
- package/dist/agents/suspend-guard.d.ts +47 -16
- package/dist/agents/suspend-guard.js +13 -4
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +41 -30
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +59 -23
- package/dist/core/allow-entry.js +131 -38
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -1
- package/dist/core/auto-mode.js +3 -5
- package/dist/core/background-agent-store.d.ts +7 -5
- package/dist/core/background-agent-store.js +12 -11
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-requirements.d.ts +33 -5
- package/dist/core/checkpoint-requirements.js +18 -5
- package/dist/core/checkpoint-row-verdict.d.ts +99 -0
- package/dist/core/checkpoint-row-verdict.js +225 -0
- package/dist/core/checkpoint-store.d.ts +107 -738
- package/dist/core/checkpoint-store.js +45 -143
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/context-settings.js +3 -5
- package/dist/core/cross-boundary-taint.d.ts +1 -1
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +68 -21
- package/dist/core/engine-notice.js +9 -2
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +10 -0
- package/dist/core/frame-settlement.js +6 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +4 -3
- package/dist/core/gate-lanes.js +7 -4
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +14 -4
- package/dist/core/governance-codes.js +19 -4
- package/dist/core/hooks.d.ts +25 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +47 -7
- package/dist/core/image-admission.js +35 -4
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +4 -3
- package/dist/core/locked-config.js +5 -3
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +76 -15
- package/dist/core/mcp-failure.js +60 -33
- package/dist/core/mcp-host-seat.d.ts +92 -53
- package/dist/core/mcp-host-seat.js +225 -46
- package/dist/core/mcp-probe.js +2 -2
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +6 -49
- package/dist/core/mcp.js +115 -111
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-engine/consolidation-driver.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- package/dist/core/memory-engine/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- package/dist/core/memory-engine/sync-client.d.ts +39 -18
- package/dist/core/memory-engine/sync-client.js +72 -14
- package/dist/core/memory-engine/sync-report.d.ts +7 -4
- package/dist/core/memory-engine/sync.d.ts +9 -1
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +8 -6
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +94 -1
- package/dist/core/mods/dollar.js +13 -1
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +4 -3
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +14 -3
- package/dist/core/mods/kernel/events.js +18 -15
- package/dist/core/mods/kernel/registration.d.ts +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +118 -0
- package/dist/core/mods/session-append.js +318 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +138 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +88 -21
- package/dist/core/mods/stations.js +149 -11
- package/dist/core/mods/tool-call.d.ts +2 -0
- package/dist/core/mods/tool-call.js +4 -4
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +68 -2
- package/dist/core/own-property-receipt.js +45 -2
- package/dist/core/park-selfcheck.js +4 -2
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +3 -3
- package/dist/core/peer-seat.js +20 -8
- package/dist/core/permission-rule-consent.d.ts +21 -5
- package/dist/core/permission-rule-consent.js +21 -1
- package/dist/core/permission-rule-model.d.ts +34 -11
- package/dist/core/permission-rule-model.js +47 -10
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- package/dist/core/read-root-candidate.js +1 -1
- package/dist/core/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retired-keys.d.ts +4 -4
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -3
- package/dist/core/runner/assemble-result.js +12 -7
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- package/dist/core/runner/compact-session.js +18 -3
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +2 -2
- package/dist/core/runner/contracts.d.ts +116 -34
- package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- package/dist/core/runner/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/git-status-frame.d.ts +3 -3
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- package/dist/core/runner/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
- package/dist/core/runner/permission-rule-lanes.js +28 -9
- package/dist/core/runner/person-path-rows.d.ts +15 -0
- package/dist/core/runner/person-path-rows.js +27 -4
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +4 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +19 -21
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +9 -9
- package/dist/core/runner/prepare-delegation-surface.js +4 -5
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +19 -14
- package/dist/core/runner/prepare-gate-stations.js +6 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
- package/dist/core/runner/prepare-hands-readface.js +32 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
- package/dist/core/runner/prepare-inherited-gate.js +10 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -2
- package/dist/core/runner/prepare-park-ask.js +4 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
- package/dist/core/runner/prepare-policy-chain.js +16 -25
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -7
- package/dist/core/runner/prepare-suspend-saga.js +17 -7
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +61 -30
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +10 -6
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +8 -6
- package/dist/core/runner/resume-admission.js +23 -6
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +14 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +2 -0
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +6 -2
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +14 -5
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +64 -36
- package/dist/core/runner/run-notification-lane.js +20 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +12 -9
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +34 -18
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +33 -17
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +16 -7
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -2
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- package/dist/core/runner/tool-face-overlay.js +2 -0
- package/dist/core/runner/tool-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- package/dist/core/runner/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +8 -2
- package/dist/core/runner/turn-attachments.js +2 -2
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +26 -27
- package/dist/core/secret-env.d.ts +19 -16
- package/dist/core/secret-env.js +45 -27
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +1 -1
- package/dist/core/session-policy-store.js +5 -2
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +3 -1
- package/dist/core/session-store.js +10 -8
- package/dist/core/session.d.ts +16 -5
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +83 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/session-store-contract.js +22 -8
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
- package/dist/core/task-event.d.ts +24 -9
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +89 -14
- package/dist/core/task-registry-agent.d.ts +32 -50
- package/dist/core/task-registry-agent.js +36 -56
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-monitor.js +15 -60
- package/dist/core/task-registry-shared.d.ts +22 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +5 -21
- package/dist/core/task-registry.d.ts +32 -62
- package/dist/core/task-registry.js +30 -110
- package/dist/core/task-result.d.ts +29 -12
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +11 -11
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +36 -6
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +2 -5
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.js +3 -2
- package/dist/core/tool-face.d.ts +8 -5
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-name-aliases.d.ts +5 -29
- package/dist/core/tool-name-aliases.js +9 -5
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +109 -18
- package/dist/core/tool-policy.js +84 -14
- package/dist/core/tool-result-store.d.ts +23 -0
- package/dist/core/tool-result-store.js +3 -2
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +23 -6
- package/dist/core/trace.d.ts +18 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +26 -21
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -9
- package/dist/engine/execution-env/node-execution-env.js +221 -22
- package/dist/engine/harness/agent-harness.d.ts +65 -18
- package/dist/engine/harness/agent-harness.js +90 -23
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +52 -7
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +6 -1
- package/dist/engine/loop/agent-loop.js +20 -11
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.js +1 -1
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +29 -18
- package/dist/index.js +19 -11
- package/dist/internal/harness-types.d.ts +2 -0
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +14 -17
- package/dist/orchestration/run-workflow-tool.js +43 -50
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +7 -0
- package/dist/orchestration/workflow.js +10 -12
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +13 -9
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +7 -12
- package/dist/stores/file/index.js +25 -12
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.js +42 -22
- package/dist/stores/file/memory-store.js +3 -2
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.js +3 -2
- package/dist/stores/file/session-store.d.ts +26 -7
- package/dist/stores/file/session-store.js +59 -35
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/tool-result-store.js +57 -3
- package/dist/stores/file/usage-window-store.js +3 -2
- package/dist/stores/file/workflow-journal-store.d.ts +0 -2
- package/dist/stores/file/workflow-journal-store.js +3 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +7 -7
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
- package/dist/tools/fs/fs-bash-background-text.js +6 -0
- package/dist/tools/fs/fs-bash.d.ts +3 -18
- package/dist/tools/fs/fs-bash.js +37 -124
- package/dist/tools/fs/fs-pdf.js +8 -6
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-shared.d.ts +28 -3
- package/dist/tools/fs/fs-shared.js +15 -0
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/index.js +4 -14
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +13 -5
- package/dist/tools/fs/read-floor.js +206 -2
- package/dist/tools/fs/removal-targets.js +2 -2
- package/dist/tools/fs/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- package/dist/tools/fs/shell-read-argv.d.ts +4 -2
- package/dist/tools/fs/shell-read-argv.js +14 -3
- package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
- package/dist/tools/fs/shell-read-bindings.js +148 -68
- package/dist/tools/fs/shell-read-check.js +20 -4
- package/dist/tools/fs/shell-read-establish.js +25 -9
- package/dist/tools/fs/shell-read-functions.js +2 -2
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +8 -0
- package/dist/tools/fs/shell-read-plan.js +47 -30
- package/dist/tools/fs/shell-read-start.d.ts +66 -13
- package/dist/tools/fs/shell-read-start.js +89 -17
- package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
- package/dist/tools/fs/shell-read-workdir.js +31 -8
- package/dist/tools/monitor.d.ts +8 -7
- package/dist/tools/monitor.js +12 -10
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +112 -42
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -13,7 +13,7 @@ import { hasVerifiableStructureSignal } from "./grounding-signal.js";
|
|
|
13
13
|
import { announceToolCall, batchResponseDigest, emitSettled } from "./tool-end-body.js";
|
|
14
14
|
import { neverExecuted, stampRowNotExecuted } from "./tool-not-executed.js";
|
|
15
15
|
import { extensionCallOf, noteExtensionCallDenied, requesterOf } from "../mods/extension-call.js";
|
|
16
|
-
import { noteCompletedTurn } from "../mods/lifecycle-stations.js";
|
|
16
|
+
import { noteCompletedTurn, raiseStartedTurn } from "../mods/lifecycle-stations.js";
|
|
17
17
|
import { createResponseModelSeat } from "./response-model-seat.js";
|
|
18
18
|
import { createToolCallIdFoldSeat } from "./tool-call-id-fold-seat.js";
|
|
19
19
|
import { createFinishReasonSeat } from "./finish-reason-seat.js";
|
|
@@ -28,8 +28,8 @@ export function createHarnessHandlers(input) {
|
|
|
28
28
|
const toolTurnIncompleteSeat = createToolTurnIncompleteSeat(deps.runnerHooks.onNotice, { sessionId: prepared.sessionId, runId: prepared.runId });
|
|
29
29
|
const finishReasonSeat = createFinishReasonSeat(deps.runnerHooks.onNotice, { sessionId: prepared.sessionId, runId: prepared.runId });
|
|
30
30
|
const withheldShellEnvSeat = createWithheldShellEnvSeat(prepared, deps.runnerHooks.onNotice);
|
|
31
|
-
const { spec, queue, internals, ident, pushContent, emitCommitted, startedToolCallIds, toolStartAt, toolProgress, writeFamilyOf, toolLabels, postToolBatchArmed, batchArgs, internalsNotifier,
|
|
32
|
-
const frames = { push: (f) => pushContent({ ...f, ...ident() }), structured: prepared.structuredProjector,
|
|
31
|
+
const { spec, queue, internals, ident, pushContent, emitCommitted, startedToolCallIds, toolStartAt, toolProgress, writeFamilyOf, toolLabels, postToolBatchArmed, batchArgs, internalsNotifier, mediaBudgetBase64Chars } = deps;
|
|
32
|
+
const frames = { push: (f) => pushContent({ ...f, ...ident() }), structured: prepared.structuredProjector, mediaBudgetBase64Chars };
|
|
33
33
|
const startOf = (e) => {
|
|
34
34
|
const label = toolLabels.get(e.toolName);
|
|
35
35
|
return { toolCallId: e.toolCallId, spelledName: e.toolName, wireName: rosterToolName(prepared.toolRosterDeltas.current, e.toolName), ...(label !== undefined ? { label } : {}), args: e.args, ...requesterOf(prepared.modBus, e.toolCallId) };
|
|
@@ -296,6 +296,7 @@ export function createHarnessHandlers(input) {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
|
+
const onTurnStart = () => raiseStartedTurn(prepared.modBus, prepared.hookIdentity, stats.turns + 1, prepared.abortController.signal);
|
|
299
300
|
const onTurnEnd = (event) => {
|
|
300
301
|
stats.turns += 1;
|
|
301
302
|
noteCompletedTurn(prepared.modBus, rs.turn, event.message.role === "assistant" ? event.message : undefined, stats.turns, prepared.abortController.signal.aborted, rs.turn.turnUsageMissing ? undefined : rs.turn.turnUsage);
|
|
@@ -363,5 +364,5 @@ export function createHarnessHandlers(input) {
|
|
|
363
364
|
}
|
|
364
365
|
}
|
|
365
366
|
};
|
|
366
|
-
return { onMessageUpdate, onMessageEnd, onToolStart, onToolEnd, onTurnEnd, announceWorkspaceMove };
|
|
367
|
+
return { onMessageUpdate, onMessageEnd, onToolStart, onToolEnd, onTurnEnd, onTurnStart, announceWorkspaceMove };
|
|
367
368
|
}
|
|
@@ -7,7 +7,7 @@ import type { Stats } from "./assemble-result.js";
|
|
|
7
7
|
import { type CallerStopGate } from "./caller-stop-gate.js";
|
|
8
8
|
import type { CaptureOptOutRef, LiveHandle, ManualCompactRef, McpRedialRef, NotificationLaneBindings, NotifyRef, Prepared, RunInternals, RunnerDepsSeat, TaskIdRef } from "./contracts.js";
|
|
9
9
|
export interface RunIdentityWiringInput {
|
|
10
|
-
/** borrowed-readonly — the task spec: the
|
|
10
|
+
/** borrowed-readonly — the task spec: the memory / notification seats it names, its principal and its signal. */
|
|
11
11
|
spec: TaskSpec;
|
|
12
12
|
/** borrowed-mutable — the run's event queue: the manifest, roster-delta, task_started, compaction_outcome and
|
|
13
13
|
* redelivered task_notification frames. */
|
|
@@ -49,7 +49,7 @@ export interface RunIdentityWiringInput {
|
|
|
49
49
|
runner: RunnerDepsSeat;
|
|
50
50
|
}
|
|
51
51
|
export interface RunIdentityWiringResult {
|
|
52
|
-
/** The
|
|
52
|
+
/** The leg's task id (`Prepared.taskId`, minted once at prepare) — one source, shared with `ident()`. */
|
|
53
53
|
runSourceTaskId: string;
|
|
54
54
|
/** The spawning tool call's id when this task runs AS A SUB-AGENT; undefined on a top-level run. */
|
|
55
55
|
parentToolCallId: string | undefined;
|
|
@@ -3,10 +3,12 @@ import { createSafeNotifier, observeThenableRejection } from "../safe-notify.js"
|
|
|
3
3
|
import { forwardSafely } from "./forward-sink.js";
|
|
4
4
|
import { emitsChildRowFrames, taskStartedFrame } from "../delegation-frames.js";
|
|
5
5
|
import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js";
|
|
6
|
+
import { createReceivingChain } from "../mods/session-receive.js";
|
|
6
7
|
import { discloseDroppedPending, renderTaskNotificationXml, taskNotificationDedupKey } from "../task-notification.js";
|
|
7
8
|
import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
|
|
8
9
|
import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
9
10
|
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
|
|
11
|
+
import { droppedInputsDisclosure } from "../input-author.js";
|
|
10
12
|
import { mintCallerStopGate } from "./caller-stop-gate.js";
|
|
11
13
|
export function runIdentityWiring(input) {
|
|
12
14
|
const { spec, queue, prepared, internals, taskIdRef, onReady, manualCompactRef, notifyRef, captureOptOutRef, mcpRedialRef, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, notificationLane, pendingSessionNotifications, runner } = input;
|
|
@@ -16,7 +18,7 @@ export function runIdentityWiring(input) {
|
|
|
16
18
|
taskIdRef.effectiveMemoryScopes = prepared.effectiveMemoryScopes;
|
|
17
19
|
if (taskIdRef)
|
|
18
20
|
taskIdRef.editedFiles = prepared.editedFilesSnapshot;
|
|
19
|
-
const runSourceTaskId =
|
|
21
|
+
const runSourceTaskId = prepared.taskId;
|
|
20
22
|
const parentToolCallId = internals?.parentToolCallId;
|
|
21
23
|
const ident = () => parentToolCallId !== undefined ? { eventId: uuidv7(), parentToolCallId, sourceTaskId: runSourceTaskId } : { eventId: uuidv7() };
|
|
22
24
|
notificationLane.ident = ident;
|
|
@@ -71,10 +73,11 @@ export function runIdentityWiring(input) {
|
|
|
71
73
|
undrainedUserAtEnd = { steer: counts.steer, followUp: counts.followUp, ...(inputIds !== undefined ? { inputIds } : {}) };
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
74
|
-
for (const notice of undrainedUserInputNotices({ ...counts, ...(inputIds !== undefined ? { inputIds } : {}) },
|
|
76
|
+
for (const notice of undrainedUserInputNotices({ ...counts, ...(inputIds !== undefined ? { inputIds } : {}) }, prepared.taskId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
75
77
|
deliverEngineNotice(runner.deps.onNotice, notice);
|
|
76
78
|
}
|
|
77
79
|
};
|
|
80
|
+
prepared.harness.onUndrainedOtherInputs = (authors) => runner.deps.onError?.(droppedInputsDisclosure(authors), { phase: "degraded", sessionId: prepared.sessionId, classification: "undelivered-input-dropped" });
|
|
78
81
|
prepared.harness.onEngineNoteConsumed = (p) => {
|
|
79
82
|
const payload = p;
|
|
80
83
|
const peer = payload?.peer;
|
|
@@ -117,17 +120,23 @@ export function runIdentityWiring(input) {
|
|
|
117
120
|
catch {
|
|
118
121
|
}
|
|
119
122
|
{
|
|
123
|
+
const receiving = createReceivingChain(() => prepared.receiveSeat);
|
|
120
124
|
const pendingIdle = pendingSessionNotifications.drain(prepared.sessionId);
|
|
121
125
|
if (pendingIdle !== undefined) {
|
|
122
126
|
for (const payload of discloseDroppedPending(pendingIdle, prepared.taskReadHandleOf, () => prepared.listBackgroundTasks({ settled: true }))) {
|
|
123
127
|
const parkedPriority = pendingIdle.priorities?.get(payload);
|
|
124
128
|
deliveredAtTurnOpen.add(taskNotificationDedupKey(payload));
|
|
125
129
|
queue.push({ type: "task_notification", notification: payload, ...(parkedPriority !== undefined ? { priority: parkedPriority } : {}), ...ident() });
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
const handOver = (shown) => {
|
|
131
|
+
void prepared.harness.nextTurn(renderTaskNotificationXml(shown), { provenance: "engine-note", enginePayload: payload }).catch(() => {
|
|
132
|
+
pendingSessionNotifications.pend(prepared.sessionId, payload, parkedPriority);
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
receiving.pass(payload, { handOver, fault: () => pendingSessionNotifications.pend(prepared.sessionId, payload, parkedPriority) });
|
|
129
136
|
}
|
|
130
137
|
}
|
|
138
|
+
if (receiving.settled !== undefined)
|
|
139
|
+
prepared.turnOpenRedelivery.current = receiving.settled;
|
|
131
140
|
}
|
|
132
141
|
const loopLatch = { ended: false, userInterrupted: false, userHalted: false, callerStop: mintCallerStopGate(spec.signal) };
|
|
133
142
|
onReady({ harness: prepared.harness, abortController: prepared.abortController, loop: loopLatch, reminderMark: prepared.reminderMark, sessionId: prepared.sessionId, runId: prepared.runId, hookIdentity: prepared.hookIdentity, modBus: prepared.modBus, permissionMode: prepared.permissionMode });
|
|
@@ -40,8 +40,8 @@ export interface RunLegInput<R> {
|
|
|
40
40
|
rs: RunState;
|
|
41
41
|
/** borrowed-readonly — the API-boundary attribution snapshot of the objective's actor (the objective leg's speaker envelope). */
|
|
42
42
|
entryActor: ActorAssertion | undefined;
|
|
43
|
-
/** borrowed-readonly — `RunInternals.
|
|
44
|
-
|
|
43
|
+
/** borrowed-readonly — `RunInternals.objectiveAuthor` as the trusted channel gave it: who wrote the objective, read at its seat. */
|
|
44
|
+
objectiveAuthor: unknown;
|
|
45
45
|
/** borrowed-readonly — the effective walltime window (undefined = unbounded): `<= 0` refuses the first turn. */
|
|
46
46
|
effectiveTimeoutMs: number | undefined;
|
|
47
47
|
/** borrowed-mutable — the hard walltime timer: claimed (`fired`) and cleared by the exhausted arms and the finally. */
|
|
@@ -84,7 +84,7 @@ export interface RunLegInput<R> {
|
|
|
84
84
|
unsubBoundary: () => void;
|
|
85
85
|
/** borrowed-readonly — the git lane's harness-event release, called third. */
|
|
86
86
|
unsub: () => void;
|
|
87
|
-
/** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`, `hooks`, `onNotice`, `
|
|
87
|
+
/** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`, `hooks`, `onNotice`, `mediaBudgetBase64Chars`; the resumed
|
|
88
88
|
* decision's resolver files its execution record's word through `onNotice` too); the one home of why it is a seat and not a
|
|
89
89
|
* captured object is {@link RunnerDepsSeat}. */
|
|
90
90
|
runner: RunnerDepsSeat;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { snapshotActorAssertion } from "../../internal/llm.js";
|
|
2
|
-
import {
|
|
2
|
+
import { steeringPreview } from "./steering-preview.js";
|
|
3
3
|
import { isEngineQuestionFace } from "../ask-question.js";
|
|
4
|
-
import { CheckpointError, readPendingSteerQueue, realApprovalOrgFact, remainingBudgetMicroUsd } from "../checkpoint-store.js";
|
|
4
|
+
import { CheckpointError, planReviewRequesterOf, readPendingSteerQueue, realApprovalOrgFact, remainingBudgetMicroUsd } from "../checkpoint-store.js";
|
|
5
5
|
import { normalizePersistedRuleHit } from "../rule-lane-reads.js";
|
|
6
6
|
import { decidersNote, SETTLEMENT_NOBODY_JUDGED } from "../gate-outcome.js";
|
|
7
7
|
import { formatHookFeedback } from "../hooks.js";
|
|
8
|
-
import { classicEventBase, failedHandlerClause, legEventsOf, openSubagent, screenUserPrompt } from "../mods/stations.js";
|
|
8
|
+
import { classicEventBase, failedHandlerClause, legEventsOf, legNoticeTaskId, openSubagent, screenUserPrompt, seatHears } from "../mods/stations.js";
|
|
9
|
+
import { raiseSessionEnd, raiseSessionStart } from "../mods/lifecycle-stations.js";
|
|
9
10
|
import { offeredAgentListing } from "../mods/agent-stations.js";
|
|
11
|
+
import { appendAdmittedRow } from "../row-admission.js";
|
|
10
12
|
import { buildAppliedHumanInputEvent, buildHumanInputEvent, projectHumanInput } from "../human-input-projection.js";
|
|
13
|
+
import { countsAsOperator, objectiveAuthorOf } from "../input-author.js";
|
|
11
14
|
import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
|
|
12
15
|
import { readToolCallArguments, uuidv7 } from "../../internal/harness.js";
|
|
13
16
|
import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
|
|
@@ -43,7 +46,7 @@ import { readStationAnswer } from "../shell-read-silence.js";
|
|
|
43
46
|
import { resolveGitLegDelivery, wrapGitFrame } from "./git-leg-delivery.js";
|
|
44
47
|
import { GIT_STATUS_ECHO_PREVIEW } from "./git-status-frame.js";
|
|
45
48
|
import { toImageContents } from "./image.js";
|
|
46
|
-
import { maybeHumanRejectionHalt } from "./prepare-gate-stations.js";
|
|
49
|
+
import { isBareHumanRefusal, maybeHumanRejectionHalt } from "./prepare-gate-stations.js";
|
|
47
50
|
import { nextHumanInputSeq } from "./steer-admission.js";
|
|
48
51
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
49
52
|
import { announceToolCall, emitSettled, toolResultMsg } from "./tool-end-body.js";
|
|
@@ -55,7 +58,7 @@ import { thrownMarksOf } from "../thrown-value.js";
|
|
|
55
58
|
import { egressThrownText, egressValue } from "../untrusted-egress.js";
|
|
56
59
|
import { ruleSourcePhrase } from "../rule-denial-sentence.js";
|
|
57
60
|
export async function runLeg(input) {
|
|
58
|
-
const { spec, queue, prepared, resume, rs, entryActor,
|
|
61
|
+
const { spec, queue, prepared, resume, rs, entryActor, objectiveAuthor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
|
|
59
62
|
let final;
|
|
60
63
|
let threw;
|
|
61
64
|
let abortedLive = false;
|
|
@@ -63,6 +66,9 @@ export async function runLeg(input) {
|
|
|
63
66
|
let strandedHumanAnswers = [];
|
|
64
67
|
const legRunOrigin = prepared.wiringManifest.leg?.runOrigin;
|
|
65
68
|
try {
|
|
69
|
+
const starting = raiseSessionStart(prepared.modBus, prepared.hookIdentity, { cwd: prepared.cwdRef?.current ?? prepared.taskRootPath, sessionId: prepared.sessionId }, prepared.abortController.signal);
|
|
70
|
+
if (starting !== undefined)
|
|
71
|
+
await starting;
|
|
66
72
|
if (prepared.abortController.signal.aborted) {
|
|
67
73
|
const e = new Error("run aborted");
|
|
68
74
|
e.name = "AbortError";
|
|
@@ -186,6 +192,7 @@ export async function runLeg(input) {
|
|
|
186
192
|
continuation += "\n\n" + formatHookFeedback(resume.wakeMessageHookContext, prepared.reminderMark);
|
|
187
193
|
engineSegments.push({ start: hookStart, end: continuation.length });
|
|
188
194
|
}
|
|
195
|
+
let delivered = { text: steer.text, rewrittenBy: source === "wake" ? resume.wakeMessageRewrittenBy : undefined };
|
|
189
196
|
if (source === "steer") {
|
|
190
197
|
const screen = await screenUserPrompt(prepared.modBus, {
|
|
191
198
|
...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
|
|
@@ -214,7 +221,7 @@ export async function runLeg(input) {
|
|
|
214
221
|
...(steer.inputId !== undefined ? { inputId: steer.inputId } : {}),
|
|
215
222
|
sessionId: prepared.sessionId,
|
|
216
223
|
runId: prepared.runId,
|
|
217
|
-
...(
|
|
224
|
+
...legNoticeTaskId(prepared),
|
|
218
225
|
},
|
|
219
226
|
});
|
|
220
227
|
queue.push({
|
|
@@ -233,6 +240,8 @@ export async function runLeg(input) {
|
|
|
233
240
|
});
|
|
234
241
|
continue;
|
|
235
242
|
}
|
|
243
|
+
if (screen.kind === "answered" && screen.rewrittenBy !== undefined)
|
|
244
|
+
delivered = { text: screen.text, rewrittenBy: screen.rewrittenBy };
|
|
236
245
|
if ("context" in outcome && outcome.context !== undefined) {
|
|
237
246
|
const hookStart = continuation.length;
|
|
238
247
|
continuation += "\n\n" + formatHookFeedback(outcome.context, prepared.reminderMark);
|
|
@@ -241,25 +250,28 @@ export async function runLeg(input) {
|
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
252
|
const start = continuation.length;
|
|
244
|
-
const projected = projectHumanInput({ text:
|
|
253
|
+
const projected = projectHumanInput({ text: delivered.text, actor: steer.actor, source });
|
|
245
254
|
continuation +=
|
|
246
255
|
"\n\n" +
|
|
247
256
|
(steer.trusted ? formatHookFeedback(projected, prepared.reminderMark) : delimitUntrusted("supervisor steering message", projected));
|
|
248
257
|
if (steer.trusted)
|
|
249
258
|
engineSegments.push({ start, end: continuation.length });
|
|
250
259
|
appliedEvents.push(() => ({
|
|
251
|
-
...buildAppliedHumanInputEvent({ carrier: source, source, sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal, runOrigin: steer.runOrigin }),
|
|
260
|
+
...buildAppliedHumanInputEvent({ carrier: source, source, sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal, runOrigin: steer.runOrigin, rewrittenBy: delivered.rewrittenBy }),
|
|
252
261
|
...ident(),
|
|
253
262
|
}));
|
|
254
263
|
}
|
|
255
264
|
if (approvalWords !== undefined)
|
|
256
265
|
continuation = withApprovalWords(continuation, engineSegments, approvalWords);
|
|
257
266
|
const pending = resume.cp.pendingAction;
|
|
258
|
-
const
|
|
259
|
-
|
|
267
|
+
const decided = resume.outcome.gate === "policy_ask" || resume.outcome.gate === "plan_review" ? resume.outcome.gateOutcome : undefined;
|
|
268
|
+
const refusalEndsTurn = isBareHumanRefusal(decided, prepared.hookIdentity.isDelegatedChild);
|
|
269
|
+
const rejectionHalt = refusalEndsTurn && pending.kind === "tool_approval"
|
|
270
|
+
? maybeHumanRejectionHalt({ gate: decided, isDelegatedChild: prepared.hookIdentity.isDelegatedChild, toolName: pending.toolName, toolCallId: pending.toolCallId })
|
|
260
271
|
: undefined;
|
|
261
|
-
|
|
262
|
-
|
|
272
|
+
const refusedCallId = pending.kind === "tool_approval" ? pending.toolCallId : planReviewRequesterOf(pending);
|
|
273
|
+
if (refusalEndsTurn)
|
|
274
|
+
prepared.batchHaltRef.current = { ...(refusedCallId !== undefined ? { rejectedToolCallId: refusedCallId } : {}) };
|
|
263
275
|
prepared.undeliveredContinuationRef.current = { parkedSteers: [...resumeFrames.map(({ entry }) => entry).filter((e) => !withheldSteerIds.has(e.inputId)), ...approvalFrames], orphanTasks };
|
|
264
276
|
if (!prepared.abortController.signal.aborted) {
|
|
265
277
|
registerAdvisorReceipt(prepared, continuation);
|
|
@@ -278,16 +290,19 @@ export async function runLeg(input) {
|
|
|
278
290
|
});
|
|
279
291
|
}
|
|
280
292
|
if (outputStyleWrapped !== undefined) {
|
|
281
|
-
const preview =
|
|
293
|
+
const preview = steeringPreview(prepared.outputStyleFrame);
|
|
282
294
|
prepared.frameReceipts.pending.push({ source: "output_style", text: continuation, commit: () => void (queue.push({ type: "steering_injected", source: "output_style", preview, ...ident() }), (rs.attach.attachmentsInjected += 1)) });
|
|
283
295
|
}
|
|
284
296
|
if (postureText !== undefined)
|
|
285
297
|
prepared.frameReceipts.pending.push({ source: "posture", text: continuation, commit: () => undefined });
|
|
286
298
|
if (unavailableResume !== undefined)
|
|
287
|
-
prepared.frameReceipts.pending.push({ source: "mcp_unavailable", text: continuation, commit: () => void (settleMcpUnavailable(prepared, unavailableResume.entries), queue.push({ type: "steering_injected", source: "mcp_unavailable", preview:
|
|
299
|
+
prepared.frameReceipts.pending.push({ source: "mcp_unavailable", text: continuation, commit: () => void (settleMcpUnavailable(prepared, unavailableResume.entries), queue.push({ type: "steering_injected", source: "mcp_unavailable", preview: steeringPreview(unavailableResume.body), ...ident() }), (rs.attach.attachmentsInjected += 1)) });
|
|
300
|
+
if (prepared.turnOpenRedelivery.current !== undefined)
|
|
301
|
+
await prepared.turnOpenRedelivery.current;
|
|
288
302
|
final = await withBrainSinks(() => prepared.harness.prompt(continuation, {
|
|
289
303
|
engineSegments,
|
|
290
304
|
settleUnansweredToolCalls: rejectionHalt !== undefined ? { halt: rejectionHalt } : {},
|
|
305
|
+
...(refusalEndsTurn && appliedEvents.length === 0 ? { endsAwaitingUser: true } : {}),
|
|
291
306
|
onCommitted: () => {
|
|
292
307
|
if (resume !== undefined)
|
|
293
308
|
resume.decisionDelivered = true;
|
|
@@ -304,11 +319,13 @@ export async function runLeg(input) {
|
|
|
304
319
|
}
|
|
305
320
|
else {
|
|
306
321
|
const objectiveActor = entryActor;
|
|
307
|
-
|
|
322
|
+
let projectedObjective = projectHumanInput({ text: spec.objective, actor: objectiveActor, source: "objective" });
|
|
323
|
+
let objectiveRewrittenBy;
|
|
308
324
|
let effectiveObjective = projectedObjective;
|
|
309
325
|
let promptBlocked = false;
|
|
310
|
-
const
|
|
311
|
-
|
|
326
|
+
const author = objectiveAuthorOf(objectiveAuthor, (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId, classification: "input-author-unreadable" }));
|
|
327
|
+
const objectiveEvents = legEventsOf(prepared.hookIdentity);
|
|
328
|
+
if (countsAsOperator(author)) {
|
|
312
329
|
const screen = await screenUserPrompt(prepared.modBus, {
|
|
313
330
|
...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
|
|
314
331
|
prompt: spec.objective,
|
|
@@ -316,6 +333,11 @@ export async function runLeg(input) {
|
|
|
316
333
|
...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
|
|
317
334
|
...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
|
|
318
335
|
}, prepared.abortController.signal);
|
|
336
|
+
if (screen?.kind === "answered" && screen.rewrittenBy !== undefined) {
|
|
337
|
+
projectedObjective = projectHumanInput({ text: screen.text, actor: objectiveActor, source: "objective" });
|
|
338
|
+
objectiveRewrittenBy = screen.rewrittenBy;
|
|
339
|
+
effectiveObjective = projectedObjective;
|
|
340
|
+
}
|
|
319
341
|
if (screen?.kind === "aborted") {
|
|
320
342
|
holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
|
|
321
343
|
`the prompt was NOT submitted (fail-closed)`);
|
|
@@ -371,7 +393,7 @@ export async function runLeg(input) {
|
|
|
371
393
|
firstFrames.push({ source: "mcp_unavailable", body: unavailable.body, commit: () => settleMcpUnavailable(prepared, unavailable.entries), disclose: () => undefined });
|
|
372
394
|
if (rs.attach.attachState !== undefined) {
|
|
373
395
|
const attach = rs.attach.attachState;
|
|
374
|
-
const offeredListing = !rs.attach.agentListingOn ? undefined : prepared.modBus
|
|
396
|
+
const offeredListing = !rs.attach.agentListingOn ? undefined : seatHears({ bus: prepared.modBus }, "agent.offer") ? await offeredAgentListing({ bus: prepared.modBus }, prepared.agentListing, prepared.abortController.signal) : prepared.agentListing;
|
|
375
397
|
if (offeredListing !== undefined) {
|
|
376
398
|
const listing = offeredListing;
|
|
377
399
|
const frame = renderAgentListingFrame(attach, listing.entries, listing.toolName, listing.models, listing.budget);
|
|
@@ -481,7 +503,7 @@ export async function runLeg(input) {
|
|
|
481
503
|
text: effectiveObjective,
|
|
482
504
|
commit: () => {
|
|
483
505
|
f.commit();
|
|
484
|
-
queue.push({ type: "steering_injected", source: f.source, preview:
|
|
506
|
+
queue.push({ type: "steering_injected", source: f.source, preview: steeringPreview(f.body), ...ident() });
|
|
485
507
|
rs.attach.attachmentsInjected += 1;
|
|
486
508
|
f.disclose();
|
|
487
509
|
},
|
|
@@ -505,9 +527,12 @@ export async function runLeg(input) {
|
|
|
505
527
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
506
528
|
...(attachmentFrames.length > 0 ? { attachments: humanInputAttachmentsOf(attachmentFrames) } : {}),
|
|
507
529
|
...(legRunOrigin !== undefined ? { runOrigin: legRunOrigin } : {}),
|
|
530
|
+
...(objectiveRewrittenBy !== undefined ? { rewrittenBy: objectiveRewrittenBy } : {}),
|
|
508
531
|
}),
|
|
509
532
|
...ident(),
|
|
510
533
|
});
|
|
534
|
+
if (prepared.turnOpenRedelivery.current !== undefined)
|
|
535
|
+
await prepared.turnOpenRedelivery.current;
|
|
511
536
|
final = await withBrainSinks(() => prepared.harness.prompt(effectiveObjective, {
|
|
512
537
|
...(images && images.length > 0 ? { images } : {}),
|
|
513
538
|
...(enginePrefixChars > 0 ? { enginePrefixChars } : {}),
|
|
@@ -531,6 +556,9 @@ export async function runLeg(input) {
|
|
|
531
556
|
await settleTeardownLeg(() => prepared.mcp.dispose(), "mcp.dispose (tool_unavailable leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
|
|
532
557
|
await settleTeardownLeg(() => prepared.a2a?.dispose(), "a2a.dispose (tool_unavailable leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
|
|
533
558
|
await settleTeardownLeg(() => (prepared.ownedEnv && hasDestroy(prepared.ownedEnv) ? prepared.ownedEnv.destroy() : undefined), "ownedEnv.destroy (tool_unavailable leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
|
|
559
|
+
const ending = raiseSessionEnd(prepared.modBus, prepared.hookIdentity, { reason: "failed", sessionId: prepared.sessionId });
|
|
560
|
+
if (ending !== undefined)
|
|
561
|
+
await ending;
|
|
534
562
|
throw err;
|
|
535
563
|
}
|
|
536
564
|
threw = err;
|
|
@@ -618,7 +646,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
618
646
|
const settleEnd = async (isError, result, refusedBy, neverRan, extension) => {
|
|
619
647
|
if (refusedBy !== undefined)
|
|
620
648
|
occurrences.refuse(pendingAction.toolCallId, refusedBy, extension);
|
|
621
|
-
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector,
|
|
649
|
+
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars });
|
|
622
650
|
notExecuted = settled.notExecuted === true;
|
|
623
651
|
const gate = settled.gate ?? decidedGate;
|
|
624
652
|
const word = await resume.recordExecutionOutcome(gate);
|
|
@@ -628,24 +656,24 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
628
656
|
const marks = egressValue("same-principal", thrownMarksOf(error));
|
|
629
657
|
const text = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: the tool could not read ${which} — its argument preparation failed (${egressThrownText("same-principal", error)}). This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
|
|
630
658
|
await settleEnd(true, { content: text, ...(marks !== undefined ? { details: marks } : {}) }, undefined, true);
|
|
631
|
-
emitCommitted(await prepared.session
|
|
659
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(text, true)), "toolResult", pendingAction.toolCallId);
|
|
632
660
|
};
|
|
633
661
|
const vetoApproval = async (miss) => {
|
|
634
662
|
const text = formatHookFeedback(miss.message, prepared.reminderMark);
|
|
635
663
|
await settleEnd(true, { content: text, ...(miss.code !== undefined ? { details: { code: miss.code } } : {}) }, "policy");
|
|
636
|
-
emitCommitted(await prepared.session
|
|
664
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(text, true)), "toolResult", pendingAction.toolCallId);
|
|
637
665
|
};
|
|
638
666
|
if (outcome.decision === "deny") {
|
|
639
667
|
const settlementKind = outcome.gateOutcome?.settlement?.kind;
|
|
640
668
|
const reason = settlementKind === "policy_refused"
|
|
641
|
-
? policyRefusalMessage(pendingAction.toolName, undefined, decidersNote(outcome.reason))
|
|
669
|
+
? policyRefusalMessage(pendingAction.toolName, undefined, decidersNote(outcome.reason), outcome.hostDecision.decidedVia)
|
|
642
670
|
: settlementKind === "park_sla_expired"
|
|
643
671
|
? outcome.reason
|
|
644
672
|
? delimitUntrusted("reviewer note", outcome.reason, REVIEWER_NOTE_MAX_BODY)
|
|
645
673
|
: `No one answered the approval request for the pending tool call "${pendingAction.toolName}" — the approval window elapsed with no answer, so it was not executed.`
|
|
646
674
|
: humanRefusalSentence("tool use", outcome.reason, prepared.hookIdentity.isDelegatedChild);
|
|
647
675
|
await settleEnd(true, { content: formatHookFeedback(reason, prepared.reminderMark) });
|
|
648
|
-
const eid = await prepared.session
|
|
676
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(formatHookFeedback(reason, prepared.reminderMark), true));
|
|
649
677
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
650
678
|
const parkedFallback = pendingAction.denialLimitFallback;
|
|
651
679
|
if (parkedFallback !== undefined && settlementKind !== undefined && SETTLEMENT_NOBODY_JUDGED[settlementKind]) {
|
|
@@ -664,7 +692,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
664
692
|
if (screened !== undefined && "refused" in screened) {
|
|
665
693
|
const hookDenial = formatHookFeedback(screened.refused, prepared.reminderMark);
|
|
666
694
|
await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension);
|
|
667
|
-
emitCommitted(await prepared.session
|
|
695
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
668
696
|
return;
|
|
669
697
|
}
|
|
670
698
|
const executedArgs = resolvedArgs;
|
|
@@ -675,7 +703,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
675
703
|
if (unjudgeable !== undefined) {
|
|
676
704
|
const chainDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: its input changed after the approval and the inherited ancestor chain cannot judge the changed input (${unjudgeable}). This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
|
|
677
705
|
await settleEnd(true, { content: chainDenial }, "policy");
|
|
678
|
-
emitCommitted(await prepared.session
|
|
706
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(chainDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
679
707
|
return;
|
|
680
708
|
}
|
|
681
709
|
const beltBudget = {
|
|
@@ -710,7 +738,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
710
738
|
const editedDenial = formatHookFeedback(`The approver EDITED this call's input; the edited call is refused by the deployment's tool policy and was not executed${why}.`, prepared.reminderMark);
|
|
711
739
|
const outlet = rechecked.action !== "deny" && !personUnanswered && rewrite?.unread === undefined && rewrite !== undefined ? { details: { editRewritten: { acceptableForm: rewrite.args } } } : denialCard(rechecked);
|
|
712
740
|
await settleEnd(true, { content: editedDenial, ...outlet }, "policy");
|
|
713
|
-
emitCommitted(await prepared.session
|
|
741
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(editedDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
714
742
|
return;
|
|
715
743
|
}
|
|
716
744
|
}
|
|
@@ -719,7 +747,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
719
747
|
if (gateOrgGoverned && prepared.permissionRuleOrg === undefined) {
|
|
720
748
|
const unwiredDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: its approval was minted under organization governance (${gateRealApproval.origin}), and this worker has no org adjudication wiring — a governed approval may only be redeemed where governance can be enforced. This approval is spent; re-issue the call on an org-wired worker.`, prepared.reminderMark);
|
|
721
749
|
await settleEnd(true, { content: unwiredDenial }, "org");
|
|
722
|
-
const eid = await prepared.session
|
|
750
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(unwiredDenial, true));
|
|
723
751
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
724
752
|
return;
|
|
725
753
|
}
|
|
@@ -753,7 +781,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
753
781
|
: "";
|
|
754
782
|
const orgDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: ${blocked}.${orgDisclosures} This approval is spent — the call has to be re-issued and ${unanswered ? "decided by a person" : "approved again once organization policy permits it"}.`, prepared.reminderMark);
|
|
755
783
|
await settleEnd(true, { content: orgDenial }, "org");
|
|
756
|
-
const eid = await prepared.session
|
|
784
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(orgDenial, true));
|
|
757
785
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
758
786
|
return;
|
|
759
787
|
}
|
|
@@ -763,7 +791,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
763
791
|
if (narrowed.action === "deny") {
|
|
764
792
|
const narrowedDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" is now denied by ${ruleSourcePhrase("narrowing")} and was not executed${narrowed.message ? `: ${narrowed.message}` : ""}.`, prepared.reminderMark);
|
|
765
793
|
await settleEnd(true, { content: narrowedDenial, ...denialCard(narrowed) }, "policy");
|
|
766
|
-
const eid = await prepared.session
|
|
794
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(narrowedDenial, true));
|
|
767
795
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
768
796
|
return;
|
|
769
797
|
}
|
|
@@ -772,7 +800,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
772
800
|
if (skillRefusal !== undefined) {
|
|
773
801
|
const skillDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: ${skillRefusal.message}. This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
|
|
774
802
|
await settleEnd(true, { content: skillDenial }, "policy");
|
|
775
|
-
emitCommitted(await prepared.session
|
|
803
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(skillDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
776
804
|
return;
|
|
777
805
|
}
|
|
778
806
|
if (prepared.persistedRuleLane !== undefined) {
|
|
@@ -795,7 +823,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
795
823
|
: `it could not be read against your standing deny/ask rules (${read.reason})`;
|
|
796
824
|
const ruleDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: ${why}. This approval is spent — the call has to be re-issued and approved again.`, prepared.reminderMark);
|
|
797
825
|
await settleEnd(true, { content: ruleDenial, ...denialCard(tightened.decision) }, "persisted_rule");
|
|
798
|
-
const eid = await prepared.session
|
|
826
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(ruleDenial, true));
|
|
799
827
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
800
828
|
return;
|
|
801
829
|
}
|
|
@@ -818,7 +846,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
818
846
|
if (reading.kind === "refuse" || reading.kind === "silence" || (unseen && reading.kind !== "vouch")) {
|
|
819
847
|
const readDenial = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: ${reading.verdict.sentence ?? "the read boundary does not vouch for what it reads on this leg"} This approval is spent — the call has to be re-issued and approved again.`, prepared.reminderMark);
|
|
820
848
|
await settleEnd(true, { content: readDenial, ...(reading.verdict.details !== undefined ? { details: reading.verdict.details } : {}) }, "read_boundary");
|
|
821
|
-
const eid = await prepared.session
|
|
849
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(readDenial, true));
|
|
822
850
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
823
851
|
return;
|
|
824
852
|
}
|
|
@@ -839,7 +867,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
839
867
|
if (crossBoundaryRefusal !== undefined) {
|
|
840
868
|
const text = formatHookFeedback(crossBoundaryRefusal.message, prepared.reminderMark);
|
|
841
869
|
await settleEnd(true, { content: text }, "policy");
|
|
842
|
-
emitCommitted(await prepared.session
|
|
870
|
+
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(text, true)), "toolResult", pendingAction.toolCallId);
|
|
843
871
|
return;
|
|
844
872
|
}
|
|
845
873
|
if ((prepared.crossBoundary?.storeWaits() ?? 0) === waited)
|
|
@@ -861,14 +889,14 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
861
889
|
const failed = await finalize({ result: { content: [{ type: "text", text: execError }], details: marks ?? {} }, isError: true });
|
|
862
890
|
const failedText = failed.result.content.flatMap((c) => (c.type === "text" ? [c.text] : [])).join("\n");
|
|
863
891
|
await settleEnd(true, { content: failedText, ...(marks !== undefined ? { details: marks } : {}) });
|
|
864
|
-
const eid = await prepared.session
|
|
892
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(failedText, true));
|
|
865
893
|
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
866
894
|
return;
|
|
867
895
|
}
|
|
868
896
|
const ran = await finalize({ result: res, isError: res.isError === true });
|
|
869
897
|
await settleEnd(ran.isError, ran.result);
|
|
870
898
|
onResolvedToolSuccess?.(pendingAction.toolName, ran.isError ? undefined : ran.result.details);
|
|
871
|
-
const eid = await prepared.session
|
|
899
|
+
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, {
|
|
872
900
|
role: "toolResult",
|
|
873
901
|
toolCallId: pendingAction.toolCallId,
|
|
874
902
|
toolName: pendingAction.toolName,
|
|
@@ -3,6 +3,9 @@ import { boundInputHashOf } from "../canonical-json.js";
|
|
|
3
3
|
import { readPendingSteerQueue } from "../checkpoint-store.js";
|
|
4
4
|
import { wakeOpening } from "../run-origin.js";
|
|
5
5
|
import { bindDeliveryObligations, createLiveNotificationLane, DeliveryObligations, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
|
|
6
|
+
import { settleConsumedFrame } from "../frame-settlement.js";
|
|
7
|
+
import { createReceivingChain } from "../mods/session-receive.js";
|
|
8
|
+
import { asThrownError } from "../thrown-value.js";
|
|
6
9
|
import { ToolDetachHub } from "../tool-detach.js";
|
|
7
10
|
import { pendingContentAskCallId } from "./decide-continuation.js";
|
|
8
11
|
export function runNotificationLane(input) {
|
|
@@ -14,6 +17,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
14
17
|
const prepareResume = resume
|
|
15
18
|
? {
|
|
16
19
|
leafId: resume.cp.leafId,
|
|
20
|
+
...(resume.cp.heldRows !== undefined ? { heldRows: [...resume.cp.heldRows] } : {}),
|
|
17
21
|
suspendedBatch: new Set(resume.cp.pendingAction.kind === "tool_approval" ? resume.cp.pendingAction.batchToolCallIds : []),
|
|
18
22
|
seed: resume.cp.state,
|
|
19
23
|
outcome: resume.outcome,
|
|
@@ -70,10 +74,21 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
70
74
|
runner.deps.onError?.(new Error(`background-agent terminal ${payload.task_id} stayed on this run's own session — the delegation tree's root session is not reachable from this run (no uplink, no root anchor)`), { phase: "degraded", sessionId: notificationSessionId ?? "", classification: "descendant-terminal-unrouted" });
|
|
71
75
|
}
|
|
72
76
|
};
|
|
77
|
+
const receiving = createReceivingChain(() => prepared.receiveSeat);
|
|
73
78
|
const unsubscribeTaskNotifications = taskNotificationQueue.subscribe((item) => {
|
|
74
79
|
queue.push({ type: "task_notification", notification: item.payload, priority: item.priority, ...notificationIdent() });
|
|
80
|
+
receiving.pass(item.payload, {
|
|
81
|
+
handOver: (shown) => handOver(item, shown),
|
|
82
|
+
consumed: (verdict) => {
|
|
83
|
+
settleConsumedFrame(prepared.frameSettlement, taskNotificationDedupKey(item.payload), verdict.by, verdict.reason);
|
|
84
|
+
item.onDisposition?.("refused");
|
|
85
|
+
},
|
|
86
|
+
fault: (e) => runner.deps.onError?.(asThrownError(e), { phase: "degraded", sessionId: notificationSessionId ?? "", classification: "receive-hand-over" }),
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
function handOver(item, shown) {
|
|
75
90
|
if (notificationHarness && prepared.batchHaltRef.current === undefined) {
|
|
76
|
-
const xml = renderTaskNotificationXml(
|
|
91
|
+
const xml = renderTaskNotificationXml(shown);
|
|
77
92
|
const noteOptions = {
|
|
78
93
|
provenance: "engine-note",
|
|
79
94
|
enginePayload: item.payload,
|
|
@@ -90,7 +105,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
90
105
|
else {
|
|
91
106
|
parkTaskNotification(item.payload, item.priority, item.onDisposition);
|
|
92
107
|
}
|
|
93
|
-
}
|
|
108
|
+
}
|
|
94
109
|
const upstreamTaskNotification = internals?.onTaskNotification;
|
|
95
110
|
const deliveredAtTurnOpen = new Set();
|
|
96
111
|
const laneSeat = createLiveNotificationLane({
|
|
@@ -139,6 +154,9 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
139
154
|
onTaskNotification: laneSink,
|
|
140
155
|
}, self, taskIdRef, holdSessionLock, legWrites);
|
|
141
156
|
pendingSessionNotifications.bindSessionBox(prepared.sessionId, prepared.sessionBox);
|
|
157
|
+
const settling = pendingSessionNotifications.settleBoxDebts(prepared.sessionId, prepared.abortController.signal);
|
|
158
|
+
if (settling !== undefined)
|
|
159
|
+
await settling;
|
|
142
160
|
const notificationLane = {
|
|
143
161
|
get harness() { return notificationHarness; }, set harness(h) { notificationHarness = h; },
|
|
144
162
|
get sessionId() { return notificationSessionId; },
|
|
@@ -24,8 +24,9 @@ export function runRecoveryLanes(input) {
|
|
|
24
24
|
const passSignal = AbortSignal.any([prepared.abortController.signal, callerStop.signal, ...(turnSignal !== undefined ? [turnSignal] : [])]);
|
|
25
25
|
const passReport = compactionPassReport(queue, ident);
|
|
26
26
|
try {
|
|
27
|
-
const comp = await
|
|
27
|
+
const comp = await prepared.compactStation.compact({
|
|
28
28
|
session: prepared.session,
|
|
29
|
+
admitRows: prepared.admitRows,
|
|
29
30
|
promptIdentity: prepared.promptIdentity,
|
|
30
31
|
...centerAdoptionOption(prepared),
|
|
31
32
|
model: prepared.harness.getModel(),
|
|
@@ -52,7 +53,7 @@ export function runRecoveryLanes(input) {
|
|
|
52
53
|
...windowSafetyOptions(prepared.harness.getModel()),
|
|
53
54
|
...compactionHookOptions(runner, prepared, "forced", passSignal),
|
|
54
55
|
onStarted: passReport.onStarted,
|
|
55
|
-
});
|
|
56
|
+
}, maybeCompact);
|
|
56
57
|
if (comp.compacted) {
|
|
57
58
|
compactionBreaker.failures = 0;
|
|
58
59
|
recordCompactionReuse(runner, prepared, comp);
|