@sema-agent/core 7.60.0 → 7.61.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 +605 -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 +61 -10
- package/dist/agents/cascade.js +60 -20
- 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-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 +36 -7
- 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 +30 -40
- package/dist/agents/subagent.js +187 -196
- package/dist/agents/suspend-guard.d.ts +9 -0
- package/dist/agents/suspend-guard.js +4 -0
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +37 -27
- 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-requirements.d.ts +24 -3
- package/dist/core/checkpoint-requirements.js +9 -1
- package/dist/core/checkpoint-store.d.ts +78 -19
- package/dist/core/checkpoint-store.js +8 -4
- 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 +49 -18
- 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 +2 -1
- 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 +12 -4
- package/dist/core/governance-codes.js +16 -4
- package/dist/core/hooks.d.ts +12 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- package/dist/core/image-admission.d.ts +48 -8
- 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 +2 -1
- 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 +220 -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.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/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +7 -5
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- package/dist/core/mods/dollar.d.ts +62 -0
- 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 +4 -1
- package/dist/core/mods/kernel/events.js +6 -6
- 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/session-append.d.ts +115 -0
- package/dist/core/mods/session-append.js +311 -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 +141 -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 +38 -16
- package/dist/core/mods/stations.js +25 -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 +61 -2
- package/dist/core/own-property-receipt.js +42 -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/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- 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 +14 -2
- 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 +98 -26
- 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/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/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 +5 -1
- package/dist/core/runner/permission-rule-lanes.js +28 -9
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- 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 +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -0
- package/dist/core/runner/prepare-config-doors.js +16 -17
- 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 +5 -5
- package/dist/core/runner/prepare-hands-readface.js +4 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -0
- package/dist/core/runner/prepare-inherited-gate.js +3 -0
- 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 +56 -28
- 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 +5 -3
- package/dist/core/runner/resume-admission.js +17 -3
- package/dist/core/runner/resume-apply.js +3 -1
- 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.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +2 -2
- 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 +40 -29
- 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 +9 -7
- 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 +27 -14
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +27 -11
- 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/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 +8 -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-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 +3 -2
- package/dist/core/runner/turn-attachments.js +1 -1
- 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 +24 -25
- package/dist/core/secret-env.d.ts +11 -11
- package/dist/core/secret-env.js +8 -9
- 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 +2 -0
- package/dist/core/session-store.js +5 -7
- package/dist/core/session.d.ts +2 -1
- 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 +2 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +15 -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/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 +17 -8
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +87 -13
- package/dist/core/task-registry-agent.d.ts +5 -43
- package/dist/core/task-registry-agent.js +24 -51
- 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 +15 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +4 -21
- package/dist/core/task-registry.d.ts +19 -60
- package/dist/core/task-registry.js +19 -106
- package/dist/core/task-result.d.ts +24 -7
- 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 +10 -10
- 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 +30 -0
- 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 +2 -3
- 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 +108 -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-spec.d.ts +19 -6
- package/dist/core/trace.d.ts +18 -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 +34 -9
- package/dist/engine/execution-env/node-execution-env.js +213 -21
- 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 +41 -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/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +21 -11
- package/dist/index.js +15 -7
- package/dist/internal/harness-types.d.ts +2 -0
- 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 +11 -17
- package/dist/orchestration/run-workflow-tool.js +19 -42
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +8 -5
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.js +7 -4
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/index.d.ts +5 -3
- package/dist/stores/file/index.js +23 -8
- 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 +16 -3
- package/dist/stores/file/session-store.js +21 -20
- 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/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/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- package/dist/tools/fs/shell-read-establish.js +3 -1
- 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/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 +92 -10
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MailboxCrossProcessVerdict, type MailboxStore } from "../core/mailbox-store.js";
|
|
2
|
-
import { type SessionBoxBinding, type SystemInjectionPriority, type TaskNotificationPayload } from "../core/task-notification.js";
|
|
2
|
+
import { type FrameReceiver, type SessionBoxBinding, type SystemInjectionPriority, type TaskNotificationPayload } from "../core/task-notification.js";
|
|
3
3
|
import { type FrameSettlement } from "../core/frame-settlement.js";
|
|
4
4
|
import { type EngineNotice, type RunnerDeps } from "../core/types.js";
|
|
5
5
|
import { type PermissionModeClass } from "./cross-session-envelope.js";
|
|
@@ -140,6 +140,11 @@ export interface PeerSessionDrainOptions {
|
|
|
140
140
|
* private one, which is honest but inert: nothing fills it, so every delivered record waits for a
|
|
141
141
|
* receipt that never comes and stays parked (at-least-once). Every production binding supplies it. */
|
|
142
142
|
settlement?: FrameSettlement;
|
|
143
|
+
/** The leg's receiving station (`session.receive`): every record the PULL face hands back passes it first, and a
|
|
144
|
+
* record it consumed is settled as that decision (its sender told `refused`). A record the drain injects passes it on
|
|
145
|
+
* the live lane, which answers a consume through the settlement seam ({@link FrameSettlement.consumed}). Absent ⇒ no
|
|
146
|
+
* station: every record is handed over as made. */
|
|
147
|
+
receive?: FrameReceiver;
|
|
143
148
|
leaseTtlMs?: number;
|
|
144
149
|
/** Tests: a virtual clock for the held deadlines and idle timers (honored when this process first sees the session). */
|
|
145
150
|
clock?: PeerClock;
|
|
@@ -318,6 +323,8 @@ export declare function bindPeerLaneDrain(harness: PeerDrainHarness, args: {
|
|
|
318
323
|
/** #1036 — the leg's settlement seam (receipts + compaction effects), minted by the
|
|
319
324
|
* orchestrator and shared with the harness sink and the compaction commit beat. */
|
|
320
325
|
settlement?: FrameSettlement;
|
|
326
|
+
/** The leg's receiving station ({@link PeerSessionDrainOptions.receive}). */
|
|
327
|
+
receive?: FrameReceiver;
|
|
321
328
|
selfName?: () => string | undefined;
|
|
322
329
|
parked?: () => boolean;
|
|
323
330
|
lastTurnText?: () => string | undefined;
|
|
@@ -156,6 +156,13 @@ export function createPeerSessionDrain(opts) {
|
|
|
156
156
|
else
|
|
157
157
|
void routePeerDeliveryReceipt(route(), to, state, entry.seq);
|
|
158
158
|
};
|
|
159
|
+
const settleConsumed = (lane, seq, payload, by, reason) => {
|
|
160
|
+
lane.ledger.set(seq, { kind: "terminal", why: "consumed" });
|
|
161
|
+
const peerMeta = payload._sema_provenance?.kind === "cross_session_message" ? payload._sema_provenance.peerMeta : undefined;
|
|
162
|
+
const to = peerMeta !== undefined ? receiptAddress(lane, { peerMeta }) : undefined;
|
|
163
|
+
if (to !== undefined)
|
|
164
|
+
void routePeerDeliveryReceipt(route(), to, "refused", seq, by === "engine" ? "the receiving engine (it could not judge the message)" : `extension ${by} of that session: ${reason}`);
|
|
165
|
+
};
|
|
159
166
|
const heldSink = (lane, live) => ({
|
|
160
167
|
judge: (entry) => judgeMeta(readFacts(), entry.peerMeta),
|
|
161
168
|
...(live
|
|
@@ -164,6 +171,10 @@ export function createPeerSessionDrain(opts) {
|
|
|
164
171
|
if (currentRound === undefined || !currentRound.holds(lane))
|
|
165
172
|
return "deferred";
|
|
166
173
|
const payload = buildPeerMessagePayload(lane, entry);
|
|
174
|
+
if (currentRound.out !== undefined && opts.receive?.listens() === true) {
|
|
175
|
+
currentRound.batch.push({ lane, payload, priority: "next", urgent: false, seq: entry.seq, attempt: 1 });
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
167
178
|
if (currentRound.deliver(payload, "next") === "deferred")
|
|
168
179
|
return "deferred";
|
|
169
180
|
noteDelivered(lane, entry.seq, 1, payload, currentRound.carrier);
|
|
@@ -253,7 +264,7 @@ export function createPeerSessionDrain(opts) {
|
|
|
253
264
|
return true;
|
|
254
265
|
return false;
|
|
255
266
|
};
|
|
256
|
-
const noteDelivered = (lane, seq, attempt, payload, carrier) => {
|
|
267
|
+
const noteDelivered = (lane, seq, attempt, payload, carrier, shown = payload) => {
|
|
257
268
|
const own = taskNotificationDedupKey(payload);
|
|
258
269
|
const key = carrier === undefined ? own : `${carrier}|${own}`;
|
|
259
270
|
lane.ledger.set(seq, { kind: "delivered", attempt, key, payload });
|
|
@@ -266,7 +277,7 @@ export function createPeerSessionDrain(opts) {
|
|
|
266
277
|
opts.onError?.(e, { phase: "degraded", sessionId, classification: "peer-external-mark" });
|
|
267
278
|
}
|
|
268
279
|
}
|
|
269
|
-
seam.awaiting.set(key, carrier === undefined ? { carrier: own } : { carrier, frameText: renderTaskNotificationXml(
|
|
280
|
+
seam.awaiting.set(key, carrier === undefined ? { carrier: own } : { carrier, frameText: renderTaskNotificationXml(shown) });
|
|
270
281
|
};
|
|
271
282
|
const deriveAckPrefix = (lane, messages) => {
|
|
272
283
|
let prefix;
|
|
@@ -287,10 +298,16 @@ export function createPeerSessionDrain(opts) {
|
|
|
287
298
|
const settleLaneLocally = (lane, landed) => {
|
|
288
299
|
const { ledger, boxHandle } = lane;
|
|
289
300
|
const hostWithheldSeqs = [];
|
|
290
|
-
if (seam.receipts.size > 0 || seam.withheld.size > 0 || seam.hostWithheld.size > 0) {
|
|
301
|
+
if (seam.receipts.size > 0 || seam.withheld.size > 0 || seam.hostWithheld.size > 0 || seam.consumed.size > 0) {
|
|
291
302
|
for (const [seq, d] of ledger) {
|
|
292
303
|
if (d.kind !== "delivered")
|
|
293
304
|
continue;
|
|
305
|
+
const consumed = seam.consumed.get(d.key);
|
|
306
|
+
if (consumed !== undefined) {
|
|
307
|
+
seam.consumed.delete(d.key);
|
|
308
|
+
settleConsumed(lane, seq, d.payload, consumed.by, consumed.reason);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
294
311
|
if (seam.hostWithheld.delete(d.key)) {
|
|
295
312
|
ledger.set(seq, { kind: "terminal", why: "host_withheld" });
|
|
296
313
|
hostWithheldSeqs.push(seq);
|
|
@@ -311,7 +328,7 @@ export function createPeerSessionDrain(opts) {
|
|
|
311
328
|
}
|
|
312
329
|
}
|
|
313
330
|
if (hostWithheldSeqs.length > 0) {
|
|
314
|
-
opts.onError?.(new Error(`${hostWithheldSeqs.length} cross-session message frame(s) (seq ${hostWithheldSeqs.join(", ")}) could not be found in this session's ReadInbox result as a postToolUse hook
|
|
331
|
+
opts.onError?.(new Error(`${hostWithheldSeqs.length} cross-session message frame(s) (seq ${hostWithheldSeqs.join(", ")}) could not be found in this session's ReadInbox result as the host side rewrote it (a postToolUse hook or an extension's session.append handler: removed, truncated or reshaped beyond whitespace) — settled as the host's decision: they leave ${boxHandle} and are not handed over again`), { phase: "degraded", sessionId, classification: "peer-inbox-host-withheld" });
|
|
315
332
|
}
|
|
316
333
|
for (const effect of landed) {
|
|
317
334
|
for (const [seq, d] of ledger) {
|
|
@@ -373,7 +390,7 @@ export function createPeerSessionDrain(opts) {
|
|
|
373
390
|
else {
|
|
374
391
|
const state = notice.state;
|
|
375
392
|
const recipients = [notice.recipient ?? m.from ?? ""];
|
|
376
|
-
text = state === "dropped" ? renderCrossSessionDroppedNotice(1, recipients, [notice.dropReason]) : renderCrossSessionDeliveryNotice(state, 1, recipients);
|
|
393
|
+
text = state === "dropped" ? renderCrossSessionDroppedNotice(1, recipients, [notice.dropReason]) : renderCrossSessionDeliveryNotice(state, 1, recipients, notice.detail);
|
|
377
394
|
}
|
|
378
395
|
const judged = judgeMeta(facts, meta);
|
|
379
396
|
if (judged.verdict === "refuse") {
|
|
@@ -647,15 +664,26 @@ export function createPeerSessionDrain(opts) {
|
|
|
647
664
|
finally {
|
|
648
665
|
const ordered = round.batch.splice(0).sort((a, b) => Number(b.urgent) - Number(a.urgent));
|
|
649
666
|
for (const item of ordered) {
|
|
667
|
+
let shown = item.payload;
|
|
668
|
+
if (round.out !== undefined && opts.receive?.listens() === true) {
|
|
669
|
+
if (round.spent)
|
|
670
|
+
continue;
|
|
671
|
+
const verdict = await opts.receive.receive(item.payload);
|
|
672
|
+
if (verdict.kind === "consumed") {
|
|
673
|
+
settleConsumed(item.lane, item.seq, item.payload, verdict.by, verdict.reason);
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
shown = verdict.payload;
|
|
677
|
+
}
|
|
650
678
|
try {
|
|
651
|
-
if (round.deliver(
|
|
679
|
+
if (round.deliver(shown, item.priority) === "deferred")
|
|
652
680
|
continue;
|
|
653
681
|
}
|
|
654
682
|
catch (e) {
|
|
655
683
|
opts.onError?.(e, { phase: "degraded", sessionId, classification: "peer-box-inject" });
|
|
656
684
|
break;
|
|
657
685
|
}
|
|
658
|
-
noteDelivered(item.lane, item.seq, item.attempt, item.payload, round.carrier);
|
|
686
|
+
noteDelivered(item.lane, item.seq, item.attempt, item.payload, round.carrier, shown);
|
|
659
687
|
}
|
|
660
688
|
}
|
|
661
689
|
for (const { lane, lease } of leased) {
|
|
@@ -872,6 +900,7 @@ export function bindPeerLaneDrain(harness, args) {
|
|
|
872
900
|
selfName: () => rowName ?? args.selfName?.(),
|
|
873
901
|
warmup: lookupRowName,
|
|
874
902
|
...(args.settlement !== undefined ? { settlement: args.settlement } : {}),
|
|
903
|
+
...(args.receive !== undefined ? { receive: args.receive } : {}),
|
|
875
904
|
...(args.parked !== undefined ? { parked: args.parked } : {}),
|
|
876
905
|
...(args.lastTurnText !== undefined ? { lastTurnText: args.lastTurnText } : {}),
|
|
877
906
|
...(args.markExternalContent !== undefined ? { markExternalContent: args.markExternalContent } : {}),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isDurablePause, pauseFamily } from "./suspend-guard.js";
|
|
2
2
|
import { delimitUntrusted, sanitizeUntrustedText } from "../core/untrusted-text.js";
|
|
3
|
+
import { recipeContinuationLeg } from "../core/input-author.js";
|
|
3
4
|
import { assertOracleIsolation } from "../core/oracle-isolation.js";
|
|
4
5
|
import { buildCumulativeStats } from "./cumulative-stats.js";
|
|
6
|
+
import { laterLegAllowance } from "./composition-allowance.js";
|
|
5
7
|
export function isolationPermitsAutoAccept(verdict) {
|
|
6
8
|
return verdict.protected && verdict.isolationClass === "out_of_process";
|
|
7
9
|
}
|
|
@@ -154,8 +156,11 @@ export async function runRepairLoop(runner, implSpec, config) {
|
|
|
154
156
|
});
|
|
155
157
|
let restartedOnce = false;
|
|
156
158
|
let restartUsed = false;
|
|
159
|
+
let firstAttempt = true;
|
|
160
|
+
let laterAttemptSpec = implSpec;
|
|
161
|
+
const ownSpend = () => ({ costMicroUsd: anyAttemptUnpriced ? undefined : ownCostMicro, tokens: ownTokens, turns: ownTurns });
|
|
157
162
|
const cleanRestartSpec = () => {
|
|
158
|
-
const { sessionId: _drop, ...rest } =
|
|
163
|
+
const { sessionId: _drop, ...rest } = laterAttemptSpec;
|
|
159
164
|
return { ...rest, objective: `${implSpec.objective}\n\n${repairObjective(bundle)}` };
|
|
160
165
|
};
|
|
161
166
|
const exhaustedBeforeDispatch = (message, errorCode) => ({
|
|
@@ -188,7 +193,7 @@ export async function runRepairLoop(runner, implSpec, config) {
|
|
|
188
193
|
const spec = restartedOnce
|
|
189
194
|
? cleanRestartSpec()
|
|
190
195
|
: isRepair
|
|
191
|
-
? { ...
|
|
196
|
+
? { ...laterAttemptSpec, sessionId: lastResult.sessionId, objective: repairObjective(bundle) }
|
|
192
197
|
: isSeededResume
|
|
193
198
|
? {
|
|
194
199
|
...implSpec,
|
|
@@ -200,10 +205,11 @@ export async function runRepairLoop(runner, implSpec, config) {
|
|
|
200
205
|
liveStamp.unref?.();
|
|
201
206
|
let result;
|
|
202
207
|
try {
|
|
203
|
-
result = await runner.runTask(spec, { repairBundle: bundle });
|
|
208
|
+
result = await runner.runTask(spec, firstAttempt ? { repairBundle: bundle } : recipeContinuationLeg({ repairBundle: bundle }));
|
|
204
209
|
}
|
|
205
210
|
finally {
|
|
206
211
|
clearInterval(liveStamp);
|
|
212
|
+
firstAttempt = false;
|
|
207
213
|
}
|
|
208
214
|
spend += (result.stats.costMicroUsd ?? 0) + (result.stats.nested?.costMicroUsd ?? 0);
|
|
209
215
|
stampAccount();
|
|
@@ -258,8 +264,12 @@ export async function runRepairLoop(runner, implSpec, config) {
|
|
|
258
264
|
}
|
|
259
265
|
const overTime = config.totalTimeoutMs != null && priorActiveMs + (Date.now() - startedAt) >= config.totalTimeoutMs;
|
|
260
266
|
const overCost = config.costCeilingMicroUsd != null && spend >= config.costCeilingMicroUsd;
|
|
261
|
-
|
|
262
|
-
|
|
267
|
+
const allowance = laterLegAllowance(implSpec, ownSpend());
|
|
268
|
+
if (allowance.spec !== undefined)
|
|
269
|
+
laterAttemptSpec = allowance.spec;
|
|
270
|
+
const overAllowance = allowance.exhausted;
|
|
271
|
+
if (bundle.attemptCount >= maxAttempts || overTime || overCost || overAllowance !== undefined) {
|
|
272
|
+
if (bundle.attemptCount >= maxAttempts && !overTime && !overCost && overAllowance === undefined && lastResult !== undefined && !restartUsed) {
|
|
263
273
|
restartUsed = true;
|
|
264
274
|
restartedOnce = true;
|
|
265
275
|
continue;
|
|
@@ -272,7 +282,7 @@ export async function runRepairLoop(runner, implSpec, config) {
|
|
|
272
282
|
bundle,
|
|
273
283
|
...(isolationClass ? { isolationClass } : {}),
|
|
274
284
|
oracleCostMicroUsd,
|
|
275
|
-
verification: outcomeFor(terminal, lastOracle, bundle.attemptCount),
|
|
285
|
+
verification: { ...outcomeFor(terminal, lastOracle, bundle.attemptCount), ...(overAllowance !== undefined ? { allowanceExhausted: overAllowance } : {}) },
|
|
276
286
|
};
|
|
277
287
|
}
|
|
278
288
|
}
|
|
@@ -3,6 +3,8 @@ import { PEER_MESSAGE_NOTICE } from "./peer-admission.js";
|
|
|
3
3
|
import { createSafeNotifier } from "../core/safe-notify.js";
|
|
4
4
|
import { RETAIN_DEFAULT_TTL_MS, RETAIN_DEFAULT_MAX } from "../config/defaults.js";
|
|
5
5
|
import { asThrownError } from "../core/thrown-value.js";
|
|
6
|
+
import { optionKeys, receiveMembers } from "../core/own-property-receipt.js";
|
|
7
|
+
const RETAIN_CONFIG_KEYS = optionKeys()({ ttlMs: 0, max: 0 });
|
|
6
8
|
export const SUBAGENT_RESUME_CAP = 8;
|
|
7
9
|
export function holdChildDeclarations(runner, declared) {
|
|
8
10
|
if (typeof runner.holdDeclarations !== "function") {
|
|
@@ -24,7 +26,7 @@ export class SubagentRetainLedger {
|
|
|
24
26
|
lastFailure;
|
|
25
27
|
notifier = createSafeNotifier();
|
|
26
28
|
constructor(config, hooks) {
|
|
27
|
-
const cfg = config === true ? {} : config;
|
|
29
|
+
const cfg = config === true ? {} : receiveMembers(config, { subject: "TaskSpec.retainSubagentSessions", unit: "member", moment: "when the retain ledger is made" }, RETAIN_CONFIG_KEYS);
|
|
28
30
|
this.ttlMs = cfg.ttlMs ?? RETAIN_DEFAULT_TTL_MS;
|
|
29
31
|
this.max = cfg.max ?? RETAIN_DEFAULT_MAX;
|
|
30
32
|
this.hooks = hooks;
|
|
@@ -133,7 +133,7 @@ export declare class MemoryRosterStore implements RosterStore {
|
|
|
133
133
|
private entries;
|
|
134
134
|
private readonly maxAgeMs;
|
|
135
135
|
private readonly gc;
|
|
136
|
-
constructor(
|
|
136
|
+
constructor(options?: RosterGcOptions);
|
|
137
137
|
record(entry: RosterEntry): void;
|
|
138
138
|
resolve(name: string, access: RosterAccess): RosterEntry | undefined;
|
|
139
139
|
list(): RosterEntry[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdirSync, readFileSync } from "node:fs";
|
|
2
2
|
import { assertRetentionPolicy } from "../core/retention-policy.js";
|
|
3
|
-
import { receiveOptions } from "../core/own-property-receipt.js";
|
|
3
|
+
import { optionKeys, receiveOptions } from "../core/own-property-receipt.js";
|
|
4
4
|
import { atomicWriteFile } from "../stores/file/fs-atomic.js";
|
|
5
5
|
import { dirname } from "node:path";
|
|
6
6
|
import { normalizeAgentName } from "../core/task-registry.js";
|
|
@@ -29,6 +29,8 @@ function resolveIn(entries, name, access) {
|
|
|
29
29
|
return undefined;
|
|
30
30
|
return latestOf(entries.filter((e) => normalizeAgentName(e.name) === key && entryAccessible(e, access)));
|
|
31
31
|
}
|
|
32
|
+
const ROSTER_GC_OPTION_KEYS = optionKeys()({ onNotifyError: 0, maxAgeMs: 0, maxEntries: 0, onEvicted: 0 });
|
|
33
|
+
const FILE_ROSTER_STORE_OPTION_KEYS = optionKeys()({ onNotifyError: 0, maxAgeMs: 0, maxEntries: 0, onEvicted: 0, onCorruptRead: 0 });
|
|
32
34
|
function freshOnly(entries, maxAgeMs, now = Date.now()) {
|
|
33
35
|
if (maxAgeMs === undefined)
|
|
34
36
|
return entries;
|
|
@@ -51,9 +53,10 @@ export class MemoryRosterStore {
|
|
|
51
53
|
entries = [];
|
|
52
54
|
maxAgeMs;
|
|
53
55
|
gc;
|
|
54
|
-
constructor(
|
|
56
|
+
constructor(options) {
|
|
57
|
+
const opts = receiveOptions(options, "MemoryRosterStore", ROSTER_GC_OPTION_KEYS);
|
|
55
58
|
assertRetentionPolicy("RosterStore", opts);
|
|
56
|
-
this.maxAgeMs = opts
|
|
59
|
+
this.maxAgeMs = opts.maxAgeMs;
|
|
57
60
|
this.gc = opts;
|
|
58
61
|
}
|
|
59
62
|
record(entry) {
|
|
@@ -81,7 +84,7 @@ export class FileRosterStore {
|
|
|
81
84
|
gc;
|
|
82
85
|
onCorruptRead;
|
|
83
86
|
constructor(path, options) {
|
|
84
|
-
const opts =
|
|
87
|
+
const opts = receiveOptions(options, "FileRosterStore", FILE_ROSTER_STORE_OPTION_KEYS);
|
|
85
88
|
assertRetentionPolicy("RosterStore", opts);
|
|
86
89
|
this.path = path;
|
|
87
90
|
this.maxAgeMs = opts?.maxAgeMs;
|
|
@@ -20,7 +20,7 @@ export interface SendMessageToolOptions {
|
|
|
20
20
|
/** design/122 D1 — the parent run's retain ledger (present only when `TaskSpec.retainSubagentSessions`
|
|
21
21
|
* opted in). Absent ⇒ the tool stays mounted but every call returns the honest not-retained text. */
|
|
22
22
|
retain?: SubagentRetainLedger;
|
|
23
|
-
/** Registry access identity (mirrors
|
|
23
|
+
/** Registry access identity (mirrors TaskStop's closure identity — the mount fills these). */
|
|
24
24
|
owner?: string;
|
|
25
25
|
scope?: string;
|
|
26
26
|
sessionId?: string;
|
|
@@ -33,20 +33,18 @@ export interface SendMessageToolOptions {
|
|
|
33
33
|
/** Completion-notify sink for the resumed run. The Runner mount wires the SENDING run's own
|
|
34
34
|
* notification injector here (its runtask-wrapped `injectTaskNotification`), so the completion
|
|
35
35
|
* notice lands in the sender's live injection queue at a turn boundary; a direct mount may wire a
|
|
36
|
-
* deployment-level background-notify sink instead.
|
|
36
|
+
* deployment-level background-notify sink instead. A call's own run lane (`ctx.onTaskNotification`) wins over it —
|
|
37
|
+
* the one completion-sink resolution. With neither (and no {@link notificationWired} channel) continuing a finished
|
|
38
|
+
* agent is refused at the call: a continuation is a background run, and nothing would hear it complete. */
|
|
37
39
|
notify?: (n: TaskNotificationPayload, opts?: {
|
|
38
40
|
priority?: "now" | "next" | "later";
|
|
39
41
|
}) => void;
|
|
40
42
|
/** The sending run's result store, the pair of {@link notify}: a continued agent's cut completion is stored where that
|
|
41
43
|
* run's `ReadToolResult` reads. Absent ⇒ the cut says the full text is not readable from this session. */
|
|
42
44
|
taskArtifacts?: import("../core/tool-result-store.js").TaskArtifactSeat;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* mount that wires its own sink here. Pass `true` only when the deployment announces a finished
|
|
47
|
-
* agent through a channel of its own (this tool then keeps the wired wording); `false` states the
|
|
48
|
-
* degraded truth explicitly. A one-shot submission needs no wording of its own: its ending waits for a continued
|
|
49
|
-
* agent's completion, owed to the lane `notify` delivers into (`DeliveryObligations`). */
|
|
45
|
+
/** `true` when the deployment announces a finished agent through a channel of its own — the deployment-channel term
|
|
46
|
+
* of the one background admission: continuing a finished agent is then admitted without a sink here (its
|
|
47
|
+
* completion reaches the sender that way). Absent / `false` ⇒ only a resolved sink admits a continuation. */
|
|
50
48
|
notificationWired?: boolean;
|
|
51
49
|
/** Steer-handle sink: the revived run re-emits a FRESH handle (design/122 risk-table contract). */
|
|
52
50
|
sink?: (handle: SubagentSteerHandle) => void;
|
|
@@ -83,7 +81,7 @@ export interface SendMessageToolOptions {
|
|
|
83
81
|
* resolved fine). RB-409 opened the ctx route as well ({@link enrichCtx}), and the Runner mount
|
|
84
82
|
* fills BOTH from the same internals chain; this seat remains the fallback (and the only route for
|
|
85
83
|
* a host that wires the tool itself). A `ctx.parentTaskId` wins when present. SendMessage ONLY —
|
|
86
|
-
* the TaskStop
|
|
84
|
+
* the TaskStop mount deliberately has no such seat (no widening of the kill
|
|
87
85
|
* surface). */
|
|
88
86
|
parentTaskId?: string;
|
|
89
87
|
/** RB-390 — companion session axis of {@link parentTaskId} (RunInternals.parentSessionId): a
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
1
2
|
import { Type } from "typebox";
|
|
2
|
-
import { isNotificationInjectionOutcome } from "../core/task-notification.js";
|
|
3
|
+
import { admitsBackgroundLaunch, isNotificationInjectionOutcome, resolveCompletionSink } from "../core/task-notification.js";
|
|
3
4
|
import { defineTool } from "../core/tools.js";
|
|
4
5
|
import { normalizeAgentName, chosenAgentName, DURABLE_AGENT_HANDLE_RE, DURABLE_AGENT_HEARTBEAT_MS } from "../core/task-registry.js";
|
|
5
6
|
import { announceTranscriptIntegrityGapOnce, canAccessAgentRecord, clearRevivedRowTerminalPayload } from "../core/background-agent-store.js";
|
|
@@ -24,7 +25,11 @@ import { clampValuesOf } from "../core/child-clamp-seats.js";
|
|
|
24
25
|
import { assertParentSpecSeatCurrent } from "../core/parent-spec-seat.js";
|
|
25
26
|
import { resolveSubagentTranscriptTier } from "../core/wiring-manifest.js";
|
|
26
27
|
export const SEND_MESSAGE_TOOL_NAME = "SendMessage";
|
|
27
|
-
let uplinkSeqGlobal =
|
|
28
|
+
let uplinkSeqGlobal = processUplinkSeqOrigin();
|
|
29
|
+
function processUplinkSeqOrigin() {
|
|
30
|
+
const draw = randomBytes(7);
|
|
31
|
+
return 2 ** 51 + (draw[0] & 0x07) * 2 ** 48 + draw.readUIntBE(1, 6);
|
|
32
|
+
}
|
|
28
33
|
const UPLINK_RESULT_MAX = 8000;
|
|
29
34
|
function clipCarrierMessage(text) {
|
|
30
35
|
return text.length > UPLINK_RESULT_MAX ? `${text.slice(0, UPLINK_RESULT_MAX)}\n[message truncated: ${text.length} chars total]` : text;
|
|
@@ -102,13 +107,8 @@ export function createSendMessageTool(opts) {
|
|
|
102
107
|
const sendMessageParameters = peerLane.active
|
|
103
108
|
? Type.Object({ ...baseParameters.properties, message: Type.Optional(Type.String({ description: `${baseParameters.properties.message.description ?? ""} Optional only for a pure notify_when_idle subscription.`.trim() })), ...notifyWhenIdleParameter })
|
|
104
109
|
: baseParameters;
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const capitalize = (text) => `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
|
|
108
|
-
const notifyWired = opts.notificationWired ?? opts.notify !== undefined;
|
|
109
|
-
const NO_COMPLETION_NOTICE = `its completion is NOT announced on this mount — ${RETRIEVE_LATER}`;
|
|
110
|
-
const AWAIT_COMPLETION = notifyWired ? "Wait for its completion notification" : capitalize(CHECK_LATER);
|
|
111
|
-
const awaitCompletion = notifyWired ? "wait for its completion notification" : CHECK_LATER;
|
|
110
|
+
const AWAIT_COMPLETION = "Wait for its completion notification";
|
|
111
|
+
const awaitCompletion = "wait for its completion notification";
|
|
112
112
|
const sendMessagePins = new Map();
|
|
113
113
|
const pinGuard = (targetId, targetName, rung, to) => {
|
|
114
114
|
if (rung === "other")
|
|
@@ -150,9 +150,7 @@ export function createSendMessageTool(opts) {
|
|
|
150
150
|
`background run with its full prior conversation preserved, so don't re-explain what it already knows. Names ` +
|
|
151
151
|
`keep working after an agent completes; but if a name you already messaged is later taken by a NEWER agent, the ` +
|
|
152
152
|
`send is refused rather than silently redirected — re-send with the task_id of whichever agent you meant. ` +
|
|
153
|
-
|
|
154
|
-
? `You will be notified automatically when it completes — prefer ending your turn; do not poll. `
|
|
155
|
-
: `A finished agent is NOT announced on this mount — check on it with TaskOutput(task_id) where mounted rather than ending your turn to wait for a notification that never comes. `) +
|
|
153
|
+
`You will be notified automatically when it completes — prefer ending your turn; do not poll. ` +
|
|
156
154
|
(continuationTier === "full"
|
|
157
155
|
? `Continuing a finished agent works for agents with a durable record — by name or task_id, even across restarts — and for runs that retain sub-agent sessions; when neither covers it you get an honest error and should launch a new agent with the needed context instead.`
|
|
158
156
|
: continuationTier === "rows"
|
|
@@ -201,6 +199,11 @@ export function createSendMessageTool(opts) {
|
|
|
201
199
|
if (isObserverTaskId(to)) {
|
|
202
200
|
return { content: OBSERVER_SENDMESSAGE_TARGET_REFUSAL, details: { error: "observer_target", to }, isError: true };
|
|
203
201
|
}
|
|
202
|
+
if (message !== "" && ctx.sendStation?.listens() === true) {
|
|
203
|
+
const verdict = await ctx.sendStation.send({ to, text: message, toolCallId: ctx.toolCallId }, ctx.signal);
|
|
204
|
+
if (!verdict.go)
|
|
205
|
+
return { content: `Message not sent: ${verdict.reason}`, details: { error: "send_refused", code: "send_refused", by: verdict.by, to }, isError: true };
|
|
206
|
+
}
|
|
204
207
|
const admissionConfig = resolvePeerLaneConfig(opts.lane, opts.onNotice);
|
|
205
208
|
const guardScope = ctx.principal ?? opts.scope ?? opts.peerSelfSession?.scope;
|
|
206
209
|
const selfRef = ctx.peerSelfRef ?? opts.peerSelf;
|
|
@@ -216,6 +219,13 @@ export function createSendMessageTool(opts) {
|
|
|
216
219
|
const prospectiveChain = appendHopToken(inboundChain, senderKey);
|
|
217
220
|
const admitFor = (recipientKey, ownTokens) => judgePeerAdmission(guardScope, recipientKey, { senderKey, body: message, prospectiveChain, ownTokens }, admissionConfig);
|
|
218
221
|
const DEDUP_RETRY_NOTE = "Note: resending the identical text within the dedup window reads as duplicate — rephrase or wait it out.";
|
|
222
|
+
const continuationSink = resolveCompletionSink(ctx.onTaskNotification, opts.notify);
|
|
223
|
+
const continuationAdmitted = admitsBackgroundLaunch(continuationSink, opts.notificationWired === true);
|
|
224
|
+
const noContinuationLane = (whoLabel) => ({
|
|
225
|
+
content: `Message not sent: ${whoLabel.slice(0, 200)} has finished and cannot be continued here — no completion would come back from it on this mount. Launch a new agent with the needed context instead.`,
|
|
226
|
+
details: { error: "revive.no_background", code: "revive.no_background", to },
|
|
227
|
+
isError: true,
|
|
228
|
+
});
|
|
219
229
|
const admissionRefusal = (reason, whoLabel) => {
|
|
220
230
|
const text = reason === "rate_limited"
|
|
221
231
|
? `you are sending messages to ${whoLabel} faster than its rate limit — the budget refills on its own; slow down and resend in a moment.`
|
|
@@ -463,7 +473,9 @@ export function createSendMessageTool(opts) {
|
|
|
463
473
|
? `Message parked in process for main (${mainLabel}): it has no run in progress, so the message waits in this process for its next run — this copy does not survive a restart of this process. Continue with your task; do not wait for a reply.`
|
|
464
474
|
: outcome === "dropped_duplicate"
|
|
465
475
|
? `Message not re-sent to main (${mainLabel}): it already delivered this exact message. Continue with your task; do not resend the same content.`
|
|
466
|
-
:
|
|
476
|
+
: outcome === "refused"
|
|
477
|
+
? `Message not delivered to main (${mainLabel}): its receiving station did not hand it to its model (an extension there consumed it, or a handler there failed). Continue with your task; do not resend the same content.`
|
|
478
|
+
: `Message sent to main — queued for ${mainLabel} at its next turn boundary (accepted into its lane, not yet read). If that run finishes before reading it, the message may not survive. Continue with your task; do not wait for a reply.`;
|
|
467
479
|
return {
|
|
468
480
|
content,
|
|
469
481
|
details: { type: "send-message", status: "uplinked", to: "main", seq: uplinkSeq, ...(outcome !== undefined ? { disposition: outcome } : {}), ...(opts.uplinkSessionId !== undefined ? { session: opts.uplinkSessionId } : {}) },
|
|
@@ -552,6 +564,8 @@ export function createSendMessageTool(opts) {
|
|
|
552
564
|
}
|
|
553
565
|
if (row.sessionId === undefined)
|
|
554
566
|
return undefined;
|
|
567
|
+
if (!continuationAdmitted)
|
|
568
|
+
return noContinuationLane(whoT3);
|
|
555
569
|
const floorRead = readClampFloor(row.policyFloor);
|
|
556
570
|
if (!floorRead.ok) {
|
|
557
571
|
return {
|
|
@@ -786,9 +800,7 @@ export function createSendMessageTool(opts) {
|
|
|
786
800
|
const priorCount = lease.messages.length - 1;
|
|
787
801
|
return {
|
|
788
802
|
content: `Message sent — ${whoT3} was revived in the background with its prior context intact${priorCount > 0 ? ` (${priorCount} earlier pending message(s) delivered with it)` : ""}. ` +
|
|
789
|
-
|
|
790
|
-
? `You will be notified automatically when it completes. Continue with other work — do not poll.`
|
|
791
|
-
: `${NO_COMPLETION_NOTICE.charAt(0).toUpperCase()}${NO_COMPLETION_NOTICE.slice(1)}.`),
|
|
803
|
+
`You will be notified automatically when it completes. Continue with other work — do not poll.`,
|
|
792
804
|
details: { type: "send-message", status: "revived", to, task_id: handle, seq: nextSeq, ...(priorCount > 0 ? { priorMessages: priorCount } : {}) },
|
|
793
805
|
};
|
|
794
806
|
}
|
|
@@ -929,15 +941,22 @@ export function createSendMessageTool(opts) {
|
|
|
929
941
|
}, { priority: "next" });
|
|
930
942
|
if (delivered.ok) {
|
|
931
943
|
const receiptText = delivered.disposition === "parked"
|
|
932
|
-
? `Message parked for ${who}: the agent finished before reading it — it will be delivered when the agent is next continued.
|
|
944
|
+
? `Message parked for ${who}: the agent finished before reading it — it will be delivered when the agent is next continued. You will be notified of its completion; continue with other work.`
|
|
933
945
|
: delivered.disposition === "pending"
|
|
934
|
-
? `Message accepted for ${who} but delivery is UNCONFIRMED (its channel did not confirm within the wait window) — it stays queued and will deliver if the channel binds.
|
|
935
|
-
: `Message queued for delivery to ${who} at its next turn. If it finishes before reading it, the message may not survive —
|
|
946
|
+
? `Message accepted for ${who} but delivery is UNCONFIRMED (its channel did not confirm within the wait window) — it stays queued and will deliver if the channel binds. You will be notified of the agent's completion either way; resend then if it went unanswered. ${DEDUP_RETRY_NOTE}`
|
|
947
|
+
: `Message queued for delivery to ${who} at its next turn. If it finishes before reading it, the message may not survive — you will be notified of its completion either way; resend then if it went unanswered. Continue with other work; do not poll. ${DEDUP_RETRY_NOTE}`;
|
|
936
948
|
return {
|
|
937
949
|
content: receiptText,
|
|
938
950
|
details: { type: "send-message", status: "delivered_running", disposition: delivered.disposition, to, task_id: targetId, summary },
|
|
939
951
|
};
|
|
940
952
|
}
|
|
953
|
+
if (delivered.reason === "refused") {
|
|
954
|
+
return {
|
|
955
|
+
content: `Message not delivered: ${who} did not take it — its receiving station did not hand it to its model (an extension there consumed it, or a handler there failed). Do not resend the same message; continue, or choose another approach.`,
|
|
956
|
+
details: { error: "refused", code: "refused", to },
|
|
957
|
+
isError: true,
|
|
958
|
+
};
|
|
959
|
+
}
|
|
941
960
|
if (delivered.reason === "no_channel") {
|
|
942
961
|
return {
|
|
943
962
|
content: `Message not sent: ${who} is still running and this deployment has no mid-run delivery channel for it. ${AWAIT_COMPLETION}, then SendMessage to continue it. ${DEDUP_RETRY_NOTE}`,
|
|
@@ -1011,6 +1030,8 @@ export function createSendMessageTool(opts) {
|
|
|
1011
1030
|
isError: true,
|
|
1012
1031
|
};
|
|
1013
1032
|
}
|
|
1033
|
+
if (!continuationAdmitted)
|
|
1034
|
+
return noContinuationLane(who);
|
|
1014
1035
|
return await withTargetLane(targetLaneKey(access.scope, targetId), async () => {
|
|
1015
1036
|
const l3Entry = ledger.get(resumeToolUseId);
|
|
1016
1037
|
const l3RecipientKey = peerAxisToken(access.scope, "h", targetId);
|
|
@@ -1028,7 +1049,7 @@ export function createSendMessageTool(opts) {
|
|
|
1028
1049
|
runner: opts.runner,
|
|
1029
1050
|
peerOrigin: { hopChain: prospectiveChain },
|
|
1030
1051
|
...(opts.notify !== undefined && selfRef !== undefined ? { currentParentPeerRef: selfRef } : {}),
|
|
1031
|
-
...(
|
|
1052
|
+
...(continuationSink !== undefined ? { notify: continuationSink } : {}),
|
|
1032
1053
|
...(opts.sink ? { sink: opts.sink } : {}),
|
|
1033
1054
|
registry: opts.registry,
|
|
1034
1055
|
taskId: targetId,
|
|
@@ -1051,6 +1072,7 @@ export function createSendMessageTool(opts) {
|
|
|
1051
1072
|
currentClamps: clampValuesOf(ctx, ctx.parentSpecSeat),
|
|
1052
1073
|
...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
|
|
1053
1074
|
currentMcpHostSeats: ctx.mountedMcp?.().hostSeats,
|
|
1075
|
+
currentPlacementTarget: ctx.placementTarget,
|
|
1054
1076
|
});
|
|
1055
1077
|
const fromPrefix = senderIsChild ? `(message from teammate "${senderLabel}")\n` : "";
|
|
1056
1078
|
try {
|
|
@@ -1059,9 +1081,7 @@ export function createSendMessageTool(opts) {
|
|
|
1059
1081
|
const marker = await resume(`${fromPrefix}[${safeSummary}] ${safeMessage}`);
|
|
1060
1082
|
return {
|
|
1061
1083
|
content: `Message sent — ${who} resumed in the background with its prior context intact (correlation marker [${marker}]).\n` +
|
|
1062
|
-
|
|
1063
|
-
? `You will be notified automatically when it completes; its reply will carry [${marker}]. Continue with other work — do not poll.`
|
|
1064
|
-
: `Its reply will carry [${marker}], but ${NO_COMPLETION_NOTICE}.`),
|
|
1084
|
+
`You will be notified automatically when it completes; its reply will carry [${marker}]. Continue with other work — do not poll.`,
|
|
1065
1085
|
details: { type: "send-message", status: "resumed", to, task_id: targetId, marker, summary },
|
|
1066
1086
|
};
|
|
1067
1087
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TaskRegistry } from "../core/task-registry.js";
|
|
2
|
+
import { type TaskNotificationPayload } from "../core/task-notification.js";
|
|
3
|
+
import type { SubagentRetainEntry } from "./retain-ledger.js";
|
|
4
|
+
/** The registry owner keys a child's own background work registers under: run-scoped work under the
|
|
5
|
+
* child's task id, session-scoped work under its session id (the `sessionScoped ? sessionId : taskId`
|
|
6
|
+
* owner read of the bash and monitor tools and of the sub-agent lanes). On a background lane the two
|
|
7
|
+
* differ — the task id is the row id — so a reader of "the child's work" reads both; elsewhere they are
|
|
8
|
+
* one key. */
|
|
9
|
+
export declare function childOwnerKeys(taskId: string, sessionId: string): readonly string[];
|
|
10
|
+
/** Running background tasks under any of `owners` (the gate's liveness read). */
|
|
11
|
+
export declare function runningBackgroundUnder(registry: TaskRegistry, owners: readonly string[]): number;
|
|
12
|
+
/**
|
|
13
|
+
* design/144 §1.2 — PARK a background child's `completed` notification behind its own still-running
|
|
14
|
+
* background tasks (207 p0g: "the child finished, but work it launched is still running — the completion
|
|
15
|
+
* news waits for the last of it"). Callers: the spawn settle resolve leg AND the resume settle resolve
|
|
16
|
+
* leg (1.284 C1 — the gate applies to every stop cycle). The frame is the PARK-TIME SNAPSHOT (seq /
|
|
17
|
+
* recentSteps / editedFiles composed by the caller before this call); delivery happens on the registry's
|
|
18
|
+
* owner-quiescence hook (the LAST settling background task's poke), exactly once (registry one-shot set
|
|
19
|
+
* + the `done` latch). The delivered frame's summary gets a decorative "(delivered after N …)" suffix —
|
|
20
|
+
* DISPLAY ONLY, not contract (tests must never lock that wording). `entry.deferredNotify` is both the
|
|
21
|
+
* resume-void hook (a wake cancels the watcher and drops the frame — see the SubagentRetainEntry ruling)
|
|
22
|
+
* and the C2 eviction-flush hook (an entry leaving the ledger delivers the frame NOW, undecorated).
|
|
23
|
+
*/
|
|
24
|
+
export declare function parkCompletionNotify(deps: {
|
|
25
|
+
registry: TaskRegistry;
|
|
26
|
+
entry: SubagentRetainEntry;
|
|
27
|
+
/** The child's owner keys in the registry ({@link childOwnerKeys}). */
|
|
28
|
+
owners: readonly string[];
|
|
29
|
+
/** Running background-task count at park time (rides the decorative delivery suffix). */
|
|
30
|
+
pendingCount: number;
|
|
31
|
+
payload: TaskNotificationPayload;
|
|
32
|
+
notify: (n: TaskNotificationPayload, opts?: {
|
|
33
|
+
priority?: "now" | "next" | "later";
|
|
34
|
+
}) => void;
|
|
35
|
+
}): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { retireTerminalDelivery } from "../core/task-notification.js";
|
|
2
|
+
export function childOwnerKeys(taskId, sessionId) {
|
|
3
|
+
return taskId === sessionId ? [taskId] : [taskId, sessionId];
|
|
4
|
+
}
|
|
5
|
+
export function runningBackgroundUnder(registry, owners) {
|
|
6
|
+
let n = 0;
|
|
7
|
+
for (const owner of owners)
|
|
8
|
+
n += registry.countRunningBackgroundForOwner(owner);
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
export function parkCompletionNotify(deps) {
|
|
12
|
+
const { registry, entry, owners, pendingCount, payload, notify } = deps;
|
|
13
|
+
let done = false;
|
|
14
|
+
const deliver = (decorated) => {
|
|
15
|
+
if (done)
|
|
16
|
+
return;
|
|
17
|
+
done = true;
|
|
18
|
+
unsubscribe();
|
|
19
|
+
if (entry.deferredNotify?.cancel === cancel)
|
|
20
|
+
entry.deferredNotify = undefined;
|
|
21
|
+
try {
|
|
22
|
+
notify(decorated
|
|
23
|
+
? {
|
|
24
|
+
...payload,
|
|
25
|
+
summary: `${payload.summary} (delivered after ${pendingCount} background ${pendingCount === 1 ? "child" : "children"} settled)`,
|
|
26
|
+
}
|
|
27
|
+
: payload, { priority: "next" });
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const watchers = new Map();
|
|
33
|
+
const unsubscribe = () => {
|
|
34
|
+
for (const off of watchers.values())
|
|
35
|
+
off();
|
|
36
|
+
watchers.clear();
|
|
37
|
+
};
|
|
38
|
+
const arm = () => {
|
|
39
|
+
for (const owner of owners) {
|
|
40
|
+
if (watchers.has(owner) || registry.countRunningBackgroundForOwner(owner) === 0)
|
|
41
|
+
continue;
|
|
42
|
+
watchers.set(owner, registry.onBackgroundQuiescence(owner, (reason) => {
|
|
43
|
+
watchers.delete(owner);
|
|
44
|
+
if (reason === "evicted")
|
|
45
|
+
deliver(false);
|
|
46
|
+
else if (runningBackgroundUnder(registry, owners) === 0)
|
|
47
|
+
deliver(true);
|
|
48
|
+
else
|
|
49
|
+
arm();
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
arm();
|
|
54
|
+
const cancel = () => {
|
|
55
|
+
if (done)
|
|
56
|
+
return;
|
|
57
|
+
done = true;
|
|
58
|
+
unsubscribe();
|
|
59
|
+
retireTerminalDelivery(notify, payload);
|
|
60
|
+
};
|
|
61
|
+
entry.deferredNotify = { ...(payload.seq !== undefined ? { seq: payload.seq } : {}), cancel, flush: () => deliver(false) };
|
|
62
|
+
}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Scope: ONE direct child. A grandchild re-threads the same forward sink, and the sink does not order direct-child
|
|
7
7
|
* content before grandchild frames, so scoping is EXPLICIT:
|
|
8
|
-
* 1. the spawn site calls {@link SubagentStepRecorder.lockTo} the moment the child's
|
|
9
|
-
* (
|
|
10
|
-
*
|
|
8
|
+
* 1. the spawn site calls {@link SubagentStepRecorder.lockTo} the moment the child's task id is known
|
|
9
|
+
* (a background lane: its registry row id; a synchronous fork: the forked sessionId; a synchronous
|
|
10
|
+
* retained child: the pre-minted child sessionId; a retained wake: the woken leg's task id) — after
|
|
11
|
+
* that, only `sourceTaskId === lockedSource` frames are recorded;
|
|
11
12
|
* 2. lanes where the child id is minted inside `runTask` (plain sync / non-retained background) anchor
|
|
12
13
|
* by FRAME PAIRING instead: the runner stamps `sourceTaskId` + `parentToolCallId` together on every
|
|
13
14
|
* child content event, and the DIRECT child's `parentToolCallId` is THIS delegation's own tool-call
|
|
@@ -70,9 +71,9 @@ export declare class SubagentStepRecorder {
|
|
|
70
71
|
*/
|
|
71
72
|
constructor(parentToolCallId?: string);
|
|
72
73
|
/**
|
|
73
|
-
* CORE-2 — explicitly anchor the observed DIRECT child by its
|
|
74
|
-
*
|
|
75
|
-
* spawn site. If events arrived BEFORE the anchor and the provisional lock caught a DIFFERENT source
|
|
74
|
+
* CORE-2 — explicitly anchor the observed DIRECT child by its task id — the `sourceTaskId` its frames
|
|
75
|
+
* carry (`legTaskIdOf`: its registry row id on a background lane, else its session id, since
|
|
76
|
+
* `buildChildSpec` never sets `spec.taskId`). Call as soon as the id is known at the spawn site. If events arrived BEFORE the anchor and the provisional lock caught a DIFFERENT source
|
|
76
77
|
* (a grandchild racing through the shared sink), everything recorded so far belongs to the wrong
|
|
77
78
|
* descendant — reset it and re-lock, so the projection never mixes generations.
|
|
78
79
|
*/
|