@sema-agent/core 7.57.0 → 7.59.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 +1161 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +89 -22
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +20 -7
- package/dist/core/allow-entry.js +18 -9
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +2 -2
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +19 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-store.d.ts +85 -23
- package/dist/core/checkpoint-store.js +31 -9
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +99 -9
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +7 -4
- package/dist/core/gate-lanes.js +19 -6
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +35 -4
- package/dist/core/hooks.js +17 -11
- 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 +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +20 -3
- package/dist/core/locked-config.js +40 -3
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +117 -15
- package/dist/core/mcp-failure.js +71 -3
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +27 -3
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +16 -20
- package/dist/core/mcp.js +112 -55
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +12 -9
- package/dist/core/mods/kernel/events.d.ts +6 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +9 -1
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +33 -12
- package/dist/core/mods/stations.js +45 -11
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +13 -4
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +248 -0
- package/dist/core/peer-seat.js +439 -0
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +20 -3
- package/dist/core/present-plan-tool.js +48 -4
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +38 -0
- package/dist/core/rewrite-rejudge.js +42 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +33 -21
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +30 -8
- package/dist/core/runner/gate-exit.js +15 -8
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +3 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +14 -10
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -0
- package/dist/core/runner/prepare-delegation-surface.js +16 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +11 -3
- package/dist/core/runner/prepare-hands-readface.js +9 -1
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +26 -37
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +7 -7
- package/dist/core/runner/prepare-policy-chain.js +18 -15
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +11 -3
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +28 -13
- package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -1
- package/dist/core/runner/prepare-wiring-manifest.js +4 -3
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +5 -3
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +6 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +42 -29
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +2 -1
- package/dist/core/runner/tool-occurrence.d.ts +5 -2
- package/dist/core/runner/tool-occurrence.js +4 -3
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +3 -3
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +9 -10
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +86 -24
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +20 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +92 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +7 -1
- package/dist/core/task-spec.d.ts +49 -1
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +11 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +18 -6
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +24 -23
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +30 -2
- package/dist/engine/harness/agent-harness.js +43 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +56 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +30 -10
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +11 -22
- package/dist/index.d.ts +29 -16
- package/dist/index.js +21 -11
- package/dist/internal/harness-types.d.ts +2 -2
- package/dist/internal/harness.d.ts +3 -2
- package/dist/internal/harness.js +2 -2
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +7 -3
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +61 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +26 -9
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +5 -2
- package/test/export-surface.snapshot.json +149 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
|
@@ -2,7 +2,7 @@ import type { PeerInboundChainRef } from "../../agents/peer-admission.js";
|
|
|
2
2
|
import { type SafeNotifier } from "../safe-notify.js";
|
|
3
3
|
import { type NotificationInjectionOutcome, type PendingSessionNotifications, type SystemInjectionPriority, type TaskNotificationPayload } from "../task-notification.js";
|
|
4
4
|
import type { PushQueue } from "../push-queue.js";
|
|
5
|
-
import type { TaskEvent, TaskSpec } from "../types.js";
|
|
5
|
+
import type { HeldUserInputs, TaskEvent, TaskSpec } from "../types.js";
|
|
6
6
|
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";
|
|
@@ -73,10 +73,7 @@ export interface RunIdentityWiringResult {
|
|
|
73
73
|
/** The held agent_end account, a READ FACE over this lane's own `let` (the undrained-inputs sink writes it
|
|
74
74
|
* when the run committed a durable park); the terminal-adoption lane settles it minus what the park carried. */
|
|
75
75
|
undrainedUserAtEnd: {
|
|
76
|
-
readonly current:
|
|
77
|
-
steer: number;
|
|
78
|
-
followUp: number;
|
|
79
|
-
} | undefined;
|
|
76
|
+
readonly current: HeldUserInputs | undefined;
|
|
80
77
|
};
|
|
81
78
|
/** The run's ONE isolation scope for the {@link RunInternals} observation sinks: minted here because
|
|
82
79
|
* the manifest sink below is the run's first call into one, and handed on to the harness-handlers lane
|
|
@@ -6,7 +6,7 @@ import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js
|
|
|
6
6
|
import { discloseDroppedPending, renderTaskNotificationXml, taskNotificationDedupKey } from "../task-notification.js";
|
|
7
7
|
import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
|
|
8
8
|
import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
9
|
-
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, undrainedUserInputNotices } from "../types.js";
|
|
9
|
+
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
|
|
10
10
|
import { mintCallerStopGate } from "./caller-stop-gate.js";
|
|
11
11
|
export function runIdentityWiring(input) {
|
|
12
12
|
const { spec, queue, prepared, internals, taskIdRef, onReady, manualCompactRef, notifyRef, captureOptOutRef, mcpRedialRef, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, notificationLane, pendingSessionNotifications, runner } = input;
|
|
@@ -28,6 +28,7 @@ export function runIdentityWiring(input) {
|
|
|
28
28
|
internalsNotifier.notify(() => observeThenableRejection(internals?.onWiringManifest?.(wiringManifest), internalsNotifier, "runtask.onWiringManifest"), "runtask.onWiringManifest");
|
|
29
29
|
prepared.toolRosterDeltas.subscribe((delta) => queue.push({ type: "tool_roster_delta", delta, ...ident() }));
|
|
30
30
|
prepared.toolDisclosure?.subscribe((snapshot) => queue.push({ type: "tool_disclosure", ...snapshot, ...ident() }));
|
|
31
|
+
prepared.workspaceFrame.subscribe((snapshot) => queue.push({ type: "workspace_changed", ...snapshot, ...ident() }));
|
|
31
32
|
const delegationLifecycleNotifier = createSafeNotifier({
|
|
32
33
|
onError: (f) => console.warn(`[sema-core] ${f.site}: delegation-lifecycle observer threw (contained; further failures counted, not re-disclosed): ${f.error.message}`),
|
|
33
34
|
});
|
|
@@ -63,13 +64,14 @@ export function runIdentityWiring(input) {
|
|
|
63
64
|
prepared.harness.engineInjectionsHeld = () => prepared.batchHaltRef.current !== undefined;
|
|
64
65
|
let undrainedUserAtEnd;
|
|
65
66
|
let userInputLostAtEnd = false;
|
|
66
|
-
prepared.harness.onUndrainedUserInputs = (counts) => {
|
|
67
|
+
prepared.harness.onUndrainedUserInputs = (counts, parkRecords) => {
|
|
67
68
|
userInputLostAtEnd = counts.steer + counts.followUp > 0;
|
|
69
|
+
const inputIds = parkRecords !== undefined ? parkedInputIdsOf(parkRecords) : undefined;
|
|
68
70
|
if (prepared.pausedRef.current !== undefined || prepared.undeliveredContinuationRef.current.parkedSteers.length > 0) {
|
|
69
|
-
undrainedUserAtEnd = counts;
|
|
71
|
+
undrainedUserAtEnd = { steer: counts.steer, followUp: counts.followUp, ...(inputIds !== undefined ? { inputIds } : {}) };
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
|
-
for (const notice of undrainedUserInputNotices(counts, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
74
|
+
for (const notice of undrainedUserInputNotices({ ...counts, ...(inputIds !== undefined ? { inputIds } : {}) }, spec.taskId ?? prepared.sessionId, prepared.sessionId, prepared.runId, parentLegIds(internals))) {
|
|
73
75
|
deliverEngineNotice(runner.deps.onNotice, notice);
|
|
74
76
|
}
|
|
75
77
|
};
|
|
@@ -40,6 +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.operatorObjective`: this delegated leg's objective carries a person's words. */
|
|
44
|
+
operatorObjective: boolean;
|
|
43
45
|
/** borrowed-readonly — the effective walltime window (undefined = unbounded): `<= 0` refuses the first turn. */
|
|
44
46
|
effectiveTimeoutMs: number | undefined;
|
|
45
47
|
/** borrowed-mutable — the hard walltime timer: claimed (`fired`) and cleared by the exhausted arms and the finally. */
|
|
@@ -5,14 +5,15 @@ import { CheckpointError, readPendingSteerQueue, realApprovalOrgFact, remainingB
|
|
|
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, screenUserPrompt } from "../mods/stations.js";
|
|
8
|
+
import { classicEventBase, failedHandlerClause, legEventsOf, openSubagent, screenUserPrompt } from "../mods/stations.js";
|
|
9
9
|
import { buildAppliedHumanInputEvent, buildHumanInputEvent, projectHumanInput } from "../human-input-projection.js";
|
|
10
10
|
import { humanInputAttachmentsOf, readObjectiveAttachments, userAttachmentDeclarations } from "../user-attachment.js";
|
|
11
11
|
import { readToolCallArguments, uuidv7 } from "../../internal/harness.js";
|
|
12
12
|
import { ORG_ADJUDICATION_TIMEOUT_MS, settleOrgVerdictWithin } from "../permission-rule-org.js";
|
|
13
13
|
import { applyPersistedTightening, disclosedRuleSet } from "../persisted-rule-arms.js";
|
|
14
14
|
import { argsReadBy, stampArgsReading } from "../effective-path-target.js";
|
|
15
|
-
import { skillRowRefusal } from "../skill-grant.js";
|
|
15
|
+
import { skillGrantBindingMembers, skillRowRefusal } from "../skill-grant.js";
|
|
16
|
+
import { requestGrantBinding } from "../skill-grant-binding.js";
|
|
16
17
|
import { judgeApprovalObject } from "../approval-object.js";
|
|
17
18
|
import { SKILL_TOOL_NAME } from "./synthetic-tools.js";
|
|
18
19
|
import { computeCostMicroUsd } from "../pricing.js";
|
|
@@ -53,12 +54,13 @@ import { thrownMarksOf } from "../thrown-value.js";
|
|
|
53
54
|
import { egressThrownText, egressValue } from "../untrusted-egress.js";
|
|
54
55
|
import { ruleSourcePhrase } from "../rule-denial-sentence.js";
|
|
55
56
|
export async function runLeg(input) {
|
|
56
|
-
const { spec, queue, prepared, resume, rs, entryActor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
|
|
57
|
+
const { spec, queue, prepared, resume, rs, entryActor, operatorObjective, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, writeFamilyOf, startedToolCallIds, announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub, runner, next } = input;
|
|
57
58
|
let final;
|
|
58
59
|
let threw;
|
|
59
60
|
let abortedLive = false;
|
|
60
61
|
let userInterruptedLive = false;
|
|
61
62
|
let strandedHumanAnswers = [];
|
|
63
|
+
const legRunOrigin = prepared.wiringManifest.leg?.runOrigin;
|
|
62
64
|
try {
|
|
63
65
|
if (prepared.abortController.signal.aborted) {
|
|
64
66
|
const e = new Error("run aborted");
|
|
@@ -224,6 +226,7 @@ export async function runLeg(input) {
|
|
|
224
226
|
...(steer.actor !== undefined ? { actor: steer.actor } : {}),
|
|
225
227
|
...(steer.actor?.issuer !== undefined ? { issuer: steer.actor.issuer } : {}),
|
|
226
228
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
229
|
+
...(steer.runOrigin !== undefined ? { runOrigin: steer.runOrigin } : {}),
|
|
227
230
|
}),
|
|
228
231
|
...ident(),
|
|
229
232
|
});
|
|
@@ -244,7 +247,7 @@ export async function runLeg(input) {
|
|
|
244
247
|
if (steer.trusted)
|
|
245
248
|
engineSegments.push({ start, end: continuation.length });
|
|
246
249
|
appliedEvents.push(() => ({
|
|
247
|
-
...buildAppliedHumanInputEvent({ carrier: source, source, sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal }),
|
|
250
|
+
...buildAppliedHumanInputEvent({ carrier: source, source, sessionSeq: nextHumanInputSeq(prepared.harness), inputId: steer.inputId, actor: steer.actor, principal: spec.principal, runOrigin: steer.runOrigin }),
|
|
248
251
|
...ident(),
|
|
249
252
|
}));
|
|
250
253
|
}
|
|
@@ -303,28 +306,36 @@ export async function runLeg(input) {
|
|
|
303
306
|
const projectedObjective = projectHumanInput({ text: spec.objective, actor: objectiveActor, source: "objective" });
|
|
304
307
|
let effectiveObjective = projectedObjective;
|
|
305
308
|
let promptBlocked = false;
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
309
|
+
const objectiveEvents = legEventsOf(prepared.hookIdentity, operatorObjective);
|
|
310
|
+
if (objectiveEvents.screen !== undefined) {
|
|
311
|
+
const screen = await screenUserPrompt(prepared.modBus, {
|
|
312
|
+
...classicEventBase(prepared.hookIdentity, prepared.permissionMode.observed),
|
|
313
|
+
prompt: spec.objective,
|
|
314
|
+
source: "objective",
|
|
315
|
+
...(objectiveActor !== undefined ? { actor: snapshotActorAssertion(objectiveActor) } : {}),
|
|
316
|
+
...(prepared.userAttachments !== undefined ? { userAttachments: userAttachmentDeclarations(prepared.userAttachments) } : {}),
|
|
317
|
+
}, prepared.abortController.signal);
|
|
318
|
+
if (screen?.kind === "aborted") {
|
|
319
|
+
holdPrompt(prepared.blockedRef, prepared.reminderMark, "cancelled", `the task was cancelled while the deployment's userPromptSubmit hook was still screening this prompt; ` +
|
|
320
|
+
`the prompt was NOT submitted (fail-closed)`);
|
|
321
|
+
promptBlocked = true;
|
|
322
|
+
}
|
|
323
|
+
else if (screen?.kind === "failed") {
|
|
324
|
+
holdPrompt(prepared.blockedRef, prepared.reminderMark, screen.cause === "timeout" ? "timeout" : "crashed", `the deployment's userPromptSubmit hook ${failedHandlerClause(screen)} while screening this prompt; the prompt was NOT submitted (fail-closed)`);
|
|
325
|
+
promptBlocked = true;
|
|
326
|
+
}
|
|
327
|
+
else if (screen?.block) {
|
|
328
|
+
holdPrompt(prepared.blockedRef, prepared.reminderMark, "block", screen.block);
|
|
329
|
+
promptBlocked = true;
|
|
330
|
+
}
|
|
331
|
+
else if (screen?.additionalContext) {
|
|
332
|
+
effectiveObjective = `${formatHookFeedback(screen.additionalContext, prepared.reminderMark)}\n\n${projectedObjective}`;
|
|
333
|
+
}
|
|
325
334
|
}
|
|
326
|
-
|
|
327
|
-
|
|
335
|
+
if (objectiveEvents.start !== undefined && !promptBlocked) {
|
|
336
|
+
const start = await openSubagent(prepared.modBus, prepared.hookIdentity, prepared.permissionMode.observed, prepared.abortController.signal);
|
|
337
|
+
if (start?.additionalContext)
|
|
338
|
+
effectiveObjective = `${formatHookFeedback(start.additionalContext, prepared.reminderMark)}\n\n${effectiveObjective}`;
|
|
328
339
|
}
|
|
329
340
|
const objectiveInputId = uuidv7();
|
|
330
341
|
const { frames: attachmentFrames, chars: attachmentChars } = await readObjectiveAttachments(prepared, objectiveInputId, promptBlocked, { overlay: () => legContextOverlayOption(prepared, runner).contextOverlay, objectiveChars: effectiveObjective.length });
|
|
@@ -493,6 +504,7 @@ export async function runLeg(input) {
|
|
|
493
504
|
...(objectiveActor?.issuer !== undefined ? { issuer: objectiveActor.issuer } : {}),
|
|
494
505
|
...(spec.principal !== undefined ? { principal: spec.principal } : {}),
|
|
495
506
|
...(attachmentFrames.length > 0 ? { attachments: humanInputAttachmentsOf(attachmentFrames) } : {}),
|
|
507
|
+
...(legRunOrigin !== undefined ? { runOrigin: legRunOrigin } : {}),
|
|
496
508
|
}),
|
|
497
509
|
...ident(),
|
|
498
510
|
});
|
|
@@ -501,6 +513,7 @@ export async function runLeg(input) {
|
|
|
501
513
|
...(enginePrefixChars > 0 ? { enginePrefixChars } : {}),
|
|
502
514
|
...(attachmentFrames.length > 0 ? { trailing: attachmentFrames.map((f) => f.seed) } : {}),
|
|
503
515
|
...(objectiveActor !== undefined ? { actor: objectiveActor } : {}),
|
|
516
|
+
...(legRunOrigin !== undefined ? { runOrigin: legRunOrigin } : {}),
|
|
504
517
|
}));
|
|
505
518
|
await flushGitMirror();
|
|
506
519
|
if (prepared.gitStatusRef.announced?.pending === true)
|
|
@@ -596,9 +609,9 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
596
609
|
occurrences.gateRound(pendingAction.toolCallId, decidedGate, frozenInputSnapshot(resolvedArgs));
|
|
597
610
|
let notExecuted = false;
|
|
598
611
|
const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
|
|
599
|
-
const settleEnd = async (isError, result, refusedBy, neverRan) => {
|
|
612
|
+
const settleEnd = async (isError, result, refusedBy, neverRan, extension) => {
|
|
600
613
|
if (refusedBy !== undefined)
|
|
601
|
-
occurrences.refuse(pendingAction.toolCallId, refusedBy);
|
|
614
|
+
occurrences.refuse(pendingAction.toolCallId, refusedBy, extension);
|
|
602
615
|
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaByteCapBytes: runner.deps.mediaByteCapBytes });
|
|
603
616
|
notExecuted = settled.notExecuted === true;
|
|
604
617
|
const gate = settled.gate ?? decidedGate;
|
|
@@ -644,7 +657,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
644
657
|
const screened = await prepared.approvedCallScreen?.({ toolCallId: pendingAction.toolCallId, toolName: pendingAction.toolName, args: structuredClone(resolvedArgs), decidedBy: outcome.hostDecision.decidedBy });
|
|
645
658
|
if (screened !== undefined && "refused" in screened) {
|
|
646
659
|
const hookDenial = formatHookFeedback(screened.refused, prepared.reminderMark);
|
|
647
|
-
await settleEnd(true, { content: hookDenial }, "hook");
|
|
660
|
+
await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension);
|
|
648
661
|
emitCommitted(await prepared.session.appendMessage(resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
649
662
|
return;
|
|
650
663
|
}
|
|
@@ -659,7 +672,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
659
672
|
const executedArgs = rescreened !== undefined ? rescreened.args : resolvedArgs;
|
|
660
673
|
const unseen = !licenseCovers(pendingAction.boundInputHash, executedArgs);
|
|
661
674
|
let beltReading;
|
|
662
|
-
const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}) });
|
|
675
|
+
const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFaceSeat(beltFace()), budget: beltBudget, ...(prepared.cwdRef !== undefined ? { cwd: prepared.cwdRef.current } : {}), ...(prepared.handsRoot !== undefined ? { root: prepared.handsRoot } : {}), ...advertisedWritableRootsSeat(prepared.advertisedWritableDirs), ...exemptRootsSeat(prepared.exemptRoots), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
|
|
663
676
|
const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
|
|
664
677
|
if (unjudgeable !== undefined) {
|
|
665
678
|
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);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createPeerInboundChainRef, createPeerSelfRef } from "../../agents/peer-admission.js";
|
|
2
2
|
import { boundInputHashOf } from "../canonical-json.js";
|
|
3
|
+
import { readPendingSteerQueue } from "../checkpoint-store.js";
|
|
4
|
+
import { wakeOpening } from "../run-origin.js";
|
|
3
5
|
import { createLiveNotificationLane, DurableAppendObligations, injectionLaneOf, isDelegatedAgentTerminal, isTerminalTaskNotification, renderTaskNotificationXml, routeOrParkNotification, SystemInjectionQueue, taskNotificationDedupKey } from "../task-notification.js";
|
|
4
6
|
import { ToolDetachHub } from "../tool-detach.js";
|
|
5
7
|
import { pendingContentAskCallId } from "./decide-continuation.js";
|
|
@@ -15,6 +17,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
15
17
|
suspendedBatch: new Set(resume.cp.pendingAction.kind === "tool_approval" ? resume.cp.pendingAction.batchToolCallIds : []),
|
|
16
18
|
seed: resume.cp.state,
|
|
17
19
|
outcome: resume.outcome,
|
|
20
|
+
...((opening) => (opening !== undefined ? { opening } : {}))(resume.outcome.gate === "wake" ? wakeOpening(readPendingSteerQueue(resume.cp.state), resume.wakeMessage) : undefined),
|
|
18
21
|
...(resume.legMods !== undefined ? { legMods: resume.legMods } : {}),
|
|
19
22
|
priorSuspendCount: resume.cp.suspendCount,
|
|
20
23
|
priorLedger: resume.cp.resourceLedger,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { openSystemReminder } from "../reminder-mint.js";
|
|
2
2
|
import { formatHookFeedback } from "../hooks.js";
|
|
3
|
-
import { classicEventBase, dispatchClassic,
|
|
3
|
+
import { classicEventBase, dispatchClassic, legEventsOf, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
|
|
4
4
|
import { asThrownError } from "../thrown-value.js";
|
|
5
5
|
const STOP_HOOK_BLOCK_CAP = 8;
|
|
6
6
|
export function runStopAndFinalVerify(input) {
|
|
7
7
|
const { spec, prepared, queue, rs, stats, ident, walltimeMonotonicDeadline, runner } = input;
|
|
8
|
-
const stopEvent =
|
|
8
|
+
const stopEvent = legEventsOf(prepared.hookIdentity).stop;
|
|
9
9
|
const stopArmed = prepared.modBus.hasHandlers(stopEvent);
|
|
10
10
|
const finalVerificationOn = spec.finalVerification === true;
|
|
11
11
|
const finalVerifyBudgetFill = () => {
|
|
@@ -19,7 +19,7 @@ import type { Model } from "../../internal/llm.js";
|
|
|
19
19
|
import { type MaybeCompactOptions } from "../auto-compaction.js";
|
|
20
20
|
import type { SessionStore } from "../session.js";
|
|
21
21
|
import type { PushQueue } from "../push-queue.js";
|
|
22
|
-
import type
|
|
22
|
+
import { type Brain, type HeldUserInputs, type OwedUserInputAccount, type TaskEvent, type TaskSpec } from "../types.js";
|
|
23
23
|
import { type Stats } from "./assemble-result.js";
|
|
24
24
|
import type { EndOfTaskCompaction, Prepared, RunnerDepsSeat, RunState } from "./contracts.js";
|
|
25
25
|
import type { CallerStopGate } from "./caller-stop-gate.js";
|
|
@@ -61,10 +61,7 @@ export interface RunTerminalAdoptionInput<R> {
|
|
|
61
61
|
windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">;
|
|
62
62
|
/** borrowed-readonly — the held agent_end account, as the read face on the identity lane's Result. */
|
|
63
63
|
undrainedUserAtEnd: {
|
|
64
|
-
readonly current:
|
|
65
|
-
steer: number;
|
|
66
|
-
followUp: number;
|
|
67
|
-
} | undefined;
|
|
64
|
+
readonly current: HeldUserInputs | undefined;
|
|
68
65
|
};
|
|
69
66
|
/** borrowed-readonly — did the run end with a person's steer / follow-up still pending (the identity lane's read face)? Folded
|
|
70
67
|
* into the answer-settled verdict this lane evaluates once. */
|
|
@@ -2,6 +2,7 @@ import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTR
|
|
|
2
2
|
import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
|
|
3
3
|
import { appendInterruptionMarker, reconcileInterruptedSession } from "../session-reconcile.js";
|
|
4
4
|
import { emitTrace } from "../trace.js";
|
|
5
|
+
import { parkedInputIdsOf } from "../types.js";
|
|
5
6
|
import { answerSettled } from "./assemble-result.js";
|
|
6
7
|
import { errorCodeOf } from "./terminal-account.js";
|
|
7
8
|
import { awaitChargeWithSlowDisclosure, discloseUnevaluableWindow } from "./clock-and-limits.js";
|
|
@@ -79,6 +80,7 @@ export async function runTerminalAdoption(input) {
|
|
|
79
80
|
}
|
|
80
81
|
let migratedParked = { steer: 0, followUp: 0 };
|
|
81
82
|
let carriedContinuation = 0;
|
|
83
|
+
const carriedContinuationInputIds = [];
|
|
82
84
|
let carriedApproval = 0;
|
|
83
85
|
let approvalRefusal;
|
|
84
86
|
if (committedPause !== undefined && runner.deps.checkpointStore !== undefined) {
|
|
@@ -101,8 +103,11 @@ export async function runTerminalAdoption(input) {
|
|
|
101
103
|
carried.push(live);
|
|
102
104
|
else if (approval)
|
|
103
105
|
carriedApproval += 1;
|
|
104
|
-
else
|
|
106
|
+
else {
|
|
105
107
|
carriedContinuation += 1;
|
|
108
|
+
if (typeof input.inputId === "string")
|
|
109
|
+
carriedContinuationInputIds.push(input.inputId);
|
|
110
|
+
}
|
|
106
111
|
}
|
|
107
112
|
catch (parkErr) {
|
|
108
113
|
runner.deps.onError?.(asThrownError(parkErr), {
|
|
@@ -118,9 +123,10 @@ export async function runTerminalAdoption(input) {
|
|
|
118
123
|
break;
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
|
-
|
|
126
|
+
const dropped = prepared.harness.dropParkedUserInputs(carried);
|
|
127
|
+
migratedParked = { steer: dropped.steer, followUp: dropped.followUp, inputIds: parkedInputIdsOf(dropped.records) };
|
|
122
128
|
}
|
|
123
|
-
const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
|
|
129
|
+
const owedUserInput = { held: undrainedUserAtEnd.current, migrated: migratedParked, continuation: { frames: prepared.undeliveredContinuationRef.current.parkedSteers.filter((f) => !isApprovalWordsFrame(f)), carried: carriedContinuation, carriedInputIds: carriedContinuationInputIds, approval: { owed: prepared.undeliveredContinuationRef.current.parkedSteers.filter(isApprovalWordsFrame).length, carried: carriedApproval, ...(approvalRefusal !== undefined ? { refusal: approvalRefusal } : {}) } } };
|
|
124
130
|
if (rs.attach.attachState?.postCompactPending === true && (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true) {
|
|
125
131
|
emitTrace(rs.telemetry.tracer, () => ({ kind: "compaction.announce_dropped", version: 1, taskId: rs.telemetry.taskId, ts: Date.now() }));
|
|
126
132
|
}
|
|
@@ -4,7 +4,7 @@ import { eventDefaultOn } from "../../prompt-assembly/event-registry.js";
|
|
|
4
4
|
import { compactionFailureReason, compactionPassReport, DEFAULT_COMPACTION_INSTRUCTIONS, isCompactionManualCancel, manualCompactOutcomeOf, maybeCompact, mintCompactedEvent, nextTrimForceBackoff, recordCompactionAndCheckRapidRefill } from "../auto-compaction.js";
|
|
5
5
|
import { emitTrace } from "../trace.js";
|
|
6
6
|
import { redactThenCut } from "../../agents/subagent-steps.js";
|
|
7
|
-
import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, TOTAL_TOKENS_REMINDER_DEFAULT_MODE, attachmentEnvelopeTags, clipToBytes, collectDateChange, collectDueAttachments, collectInstructionsChange, commitAgentListing, commitInstructionsChange, commitSkillsListing, isIntactSource, rebaseCadenceWindows, renderAgentListingFrame,
|
|
7
|
+
import { ATTACHMENT_BYTE_CAP, CHANGED_FILES_MAX, TOTAL_TOKENS_REMINDER_DEFAULT_MODE, attachmentEnvelopeTags, clipToBytes, collectDateChange, collectDueAttachments, collectInstructionsChange, commitAgentListing, commitInstructionsChange, commitSkillsListing, isIntactSource, rebaseCadenceWindows, renderAgentListingFrame, renderMcpInstructionsDelta, selectMcpDroppedBatch, renderSkillsListingFrame } from "./turn-attachments.js";
|
|
8
8
|
import { announceListingTruncation } from "../skill-listing-budget.js";
|
|
9
9
|
import { buildWorkingFileAttachments, centerAdoptionOption, contextInstructionFilesOption, emitInputTruncated, forkContextOption, legCompactionSettings, legContextOverlayOption } from "./compaction-call-options.js";
|
|
10
10
|
import { classicEventBase, dispatchClassic, stringMembersAnswer, stringMembersOf } from "../mods/stations.js";
|
|
@@ -20,6 +20,13 @@ import { contextUsageSections } from "../../prompt-assembly/section-usage.js";
|
|
|
20
20
|
import { asThrownError } from "../thrown-value.js";
|
|
21
21
|
const BATCH_CONTEXT_MIN_KEEP_BYTES = 160;
|
|
22
22
|
const BATCH_TRUNCATION_MARKER = "\n…[truncated]";
|
|
23
|
+
function consumeDelivered(pending, delivered) {
|
|
24
|
+
for (const d of delivered) {
|
|
25
|
+
const at = pending.indexOf(d);
|
|
26
|
+
if (at !== -1)
|
|
27
|
+
pending.splice(at, 1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
23
30
|
export function createTurnBoundary(input) {
|
|
24
31
|
const { prepared, stats, rs, deps } = input;
|
|
25
32
|
const { spec, queue, loopLatch: { callerStop }, manualCompactRef, todoToolMounted, taskToolsMounted, walltimeMonotonicDeadline, timeout, ident, postToolBatchArmed, batchArgs, compactionBrain, withinTaskCompaction, compactionBreaker, windowSafetyOptions, rapidRefill, drainManualCompact, runnerHooks, runner } = deps;
|
|
@@ -152,7 +159,8 @@ export function createTurnBoundary(input) {
|
|
|
152
159
|
turnOwesRequest &&
|
|
153
160
|
prepared.batchHaltRef.current === undefined &&
|
|
154
161
|
!boundarySteered &&
|
|
155
|
-
!prepared.abortController.signal.aborted
|
|
162
|
+
!prepared.abortController.signal.aborted &&
|
|
163
|
+
!frameCarried(prepared.frameReceipts, "limit_approach")) {
|
|
156
164
|
const thresholds = approachCfg?.at ?? LIMIT_APPROACH_DEFAULT_THRESHOLDS;
|
|
157
165
|
const ratios = [];
|
|
158
166
|
if (rs.budget.maxTokensWindow !== undefined && rs.budget.maxTokensWindow > 0) {
|
|
@@ -177,22 +185,31 @@ export function createTurnBoundary(input) {
|
|
|
177
185
|
tightest = r;
|
|
178
186
|
const index = rs.counters.approachNoticesSent;
|
|
179
187
|
if (tightest !== undefined && tightest.ratio >= thresholds[index]) {
|
|
180
|
-
rs.counters.approachNoticesSent += 1;
|
|
181
188
|
const percent = Math.min(100, Math.round(tightest.ratio * 100));
|
|
182
189
|
const body = limitApproachFrames(index === 0 ? 0 : 1, tightest.axis, percent, prepared.reminderMark);
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
const preview = body.slice(0, 220);
|
|
191
|
+
prepared.frameReceipts.pending.push({
|
|
192
|
+
source: "limit_approach",
|
|
193
|
+
text: body,
|
|
194
|
+
commit: () => {
|
|
195
|
+
rs.counters.approachNoticesSent += 1;
|
|
196
|
+
queue.push({ type: "steering_injected", source: "limit_approach", preview, ...ident() });
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
void prepared.harness.steer(body, { engineMinted: true }).catch(() => {
|
|
200
|
+
prepared.frameReceipts.pending = prepared.frameReceipts.pending.filter((r) => r.text !== body);
|
|
201
|
+
});
|
|
185
202
|
boundarySteered = true;
|
|
186
203
|
}
|
|
187
204
|
}
|
|
188
205
|
if (prepared.reviewRequestRef.pending !== undefined) {
|
|
189
|
-
const { reason } = prepared.reviewRequestRef.pending;
|
|
206
|
+
const { reason, requestedByCallId } = prepared.reviewRequestRef.pending;
|
|
190
207
|
prepared.reviewRequestRef.pending = undefined;
|
|
191
208
|
const honorable = prepared.suspendForReview !== undefined &&
|
|
192
209
|
!prepared.abortController.signal.aborted &&
|
|
193
210
|
prepared.pausedRef.current === undefined;
|
|
194
211
|
if (honorable && prepared.suspendForReview) {
|
|
195
|
-
await prepared.suspendForReview(reason);
|
|
212
|
+
await prepared.suspendForReview(reason, requestedByCallId);
|
|
196
213
|
legContinues = !prepared.abortController.signal.aborted && prepared.pausedRef.current === undefined;
|
|
197
214
|
return undefined;
|
|
198
215
|
}
|
|
@@ -215,7 +232,9 @@ export function createTurnBoundary(input) {
|
|
|
215
232
|
}
|
|
216
233
|
let boundaryAttachmentBytes = 0;
|
|
217
234
|
let attachmentsPayload;
|
|
218
|
-
const
|
|
235
|
+
const recordSteps = new Map();
|
|
236
|
+
const bundleReceipts = [];
|
|
237
|
+
const carried = (source) => frameCarried(prepared.frameReceipts, source);
|
|
219
238
|
if ((rs.attach.dateState !== undefined ||
|
|
220
239
|
rs.attach.instrState !== undefined ||
|
|
221
240
|
rs.attach.sizeGuidelineState !== undefined ||
|
|
@@ -229,7 +248,7 @@ export function createTurnBoundary(input) {
|
|
|
229
248
|
const due = [];
|
|
230
249
|
if (rs.attach.attachState !== undefined) {
|
|
231
250
|
const attachState = rs.attach.attachState;
|
|
232
|
-
const changedFilesOn = Boolean(rs.attach.attachmentsCfg?.changedFiles);
|
|
251
|
+
const changedFilesOn = Boolean(rs.attach.attachmentsCfg?.changedFiles) && !carried("changed_files");
|
|
233
252
|
let changed;
|
|
234
253
|
if (changedFilesOn && prepared.detectExternalChanges !== undefined) {
|
|
235
254
|
const maxFiles = typeof rs.attach.attachmentsCfg?.changedFiles === "object"
|
|
@@ -246,10 +265,9 @@ export function createTurnBoundary(input) {
|
|
|
246
265
|
rs.attach.attachState.surfacedMtime.delete(p);
|
|
247
266
|
changed = scan.changed;
|
|
248
267
|
}
|
|
249
|
-
const backgroundTasksOn = (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true;
|
|
268
|
+
const backgroundTasksOn = (rs.attach.attachmentsCfg?.backgroundTasks ?? eventDefaultOn("background_tasks")) === true && !carried("background_tasks");
|
|
250
269
|
const bgTasks = backgroundTasksOn && rs.attach.attachState.postCompactPending ? prepared.listBackgroundTasks() : undefined;
|
|
251
|
-
const toolsDeltaOn = rs.attach.attachmentsCfg?.toolsDelta === true;
|
|
252
|
-
let announcedOnceDirty = false;
|
|
270
|
+
const toolsDeltaOn = rs.attach.attachmentsCfg?.toolsDelta === true && !carried("tools_delta");
|
|
253
271
|
const tdRef = toolsDeltaOn ? prepared.toolsDeltaRef : undefined;
|
|
254
272
|
const pendingTools = tdRef !== undefined && tdRef.pending.length > 0 ? [...tdRef.pending] : undefined;
|
|
255
273
|
const pendingRemovedTools = tdRef !== undefined && tdRef.pendingRemoved.length > 0 ? [...tdRef.pendingRemoved] : undefined;
|
|
@@ -264,7 +282,7 @@ export function createTurnBoundary(input) {
|
|
|
264
282
|
const mcpDelta = prepared.mcp.instructionsDelta;
|
|
265
283
|
const mcpAdds = mcpInstructionsOn && mcpDelta.pendingAdds.length > 0 ? [...mcpDelta.pendingAdds] : undefined;
|
|
266
284
|
const mcpRemovals = mcpInstructionsOn && mcpDelta.pendingRemovals.length > 0 ? [...mcpDelta.pendingRemovals] : undefined;
|
|
267
|
-
const mcpDropped = mcpInstructionsOn && prepared.mcp.droppedTools.length > 0 ? selectMcpDroppedBatch(prepared.mcp.droppedTools) : undefined;
|
|
285
|
+
const mcpDropped = mcpInstructionsOn && !carried("mcp_dropped_tools") && prepared.mcp.droppedTools.length > 0 ? selectMcpDroppedBatch(prepared.mcp.droppedTools) : undefined;
|
|
268
286
|
const budgetUsdOn = rs.attach.attachmentsCfg?.budgetUsd === true && rs.budget.maxCostMicroUsd !== undefined;
|
|
269
287
|
const totalTokensDeclared = rs.attach.attachmentsCfg?.totalTokensReminder;
|
|
270
288
|
const totalTokensMode = rs.attach.attachmentsCfg?.totalTokensReminderMode ?? TOTAL_TOKENS_REMINDER_DEFAULT_MODE;
|
|
@@ -273,7 +291,7 @@ export function createTurnBoundary(input) {
|
|
|
273
291
|
totalTokensMode !== "fixed" &&
|
|
274
292
|
totalTokensMode !== "infinite";
|
|
275
293
|
const totalTokensOn = totalTokensDeclared === true || totalTokensArmedByDefault;
|
|
276
|
-
const toolSearchReminderOn = rs.attach.attachmentsCfg?.toolSearchReminder === true && prepared.deferredToolNames !== undefined;
|
|
294
|
+
const toolSearchReminderOn = rs.attach.attachmentsCfg?.toolSearchReminder === true && prepared.deferredToolNames !== undefined && !carried("tool_search_usage_reminder");
|
|
277
295
|
const undiscoveredTools = toolSearchReminderOn
|
|
278
296
|
? [...prepared.deferredToolNames].filter((n) => !prepared.activeTools.has(n)).sort()
|
|
279
297
|
: undefined;
|
|
@@ -286,7 +304,7 @@ export function createTurnBoundary(input) {
|
|
|
286
304
|
todoMounted: todoToolMounted,
|
|
287
305
|
taskListMounted: taskToolsMounted,
|
|
288
306
|
config: {
|
|
289
|
-
todoReminder: rs.attach.attachmentsCfg?.todoReminder === true,
|
|
307
|
+
todoReminder: rs.attach.attachmentsCfg?.todoReminder === true && !carried("todo_reminder") && !carried("task_reminder"),
|
|
290
308
|
...(rs.attach.attachmentsCfg?.todoReminderMode !== undefined ? { todoReminderMode: rs.attach.attachmentsCfg.todoReminderMode } : {}),
|
|
291
309
|
toolSearchReminder: toolSearchReminderOn,
|
|
292
310
|
changedFiles: changedFilesOn,
|
|
@@ -336,27 +354,16 @@ export function createTurnBoundary(input) {
|
|
|
336
354
|
: {}),
|
|
337
355
|
...(mcpDropped !== undefined ? { mcpDroppedTools: mcpDropped } : {}),
|
|
338
356
|
}));
|
|
339
|
-
if (pendingTools !== undefined || mcpToolsDelta !== undefined) {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
...(prepared.toolMaterializeStatic ? { staticFace: true } : {}),
|
|
343
|
-
...(prepared.toolMaterializeStatic && pendingTools !== undefined
|
|
344
|
-
? { swappedUnderStatic: pendingTools.filter((n) => prepared.staticFaceFor?.(n) !== true) }
|
|
345
|
-
: {}),
|
|
346
|
-
...(prepared.toolMaterializeStatic && pendingReaddedTools !== undefined
|
|
347
|
-
? { readdedSwappedUnderStatic: pendingReaddedTools.filter((n) => prepared.staticFaceFor?.(n) !== true) }
|
|
348
|
-
: {}),
|
|
349
|
-
...(mcpToolsDelta ?? {}),
|
|
350
|
-
});
|
|
351
|
-
if (exact !== undefined && due.some((a) => a.source === "tools_delta" && a.body === exact)) {
|
|
352
|
-
const ref = prepared.toolsDeltaRef;
|
|
357
|
+
if ((pendingTools !== undefined || mcpToolsDelta !== undefined) && due.some((a) => a.source === "tools_delta")) {
|
|
358
|
+
const ref = prepared.toolsDeltaRef;
|
|
359
|
+
recordSteps.set("tools_delta", () => {
|
|
353
360
|
if (pendingTools !== undefined)
|
|
354
|
-
ref.pending
|
|
361
|
+
consumeDelivered(ref.pending, pendingTools);
|
|
355
362
|
if (pendingRemovedTools !== undefined)
|
|
356
|
-
ref.pendingRemoved
|
|
363
|
+
consumeDelivered(ref.pendingRemoved, pendingRemovedTools);
|
|
357
364
|
if (pendingReaddedTools !== undefined)
|
|
358
|
-
ref.pendingReadded
|
|
359
|
-
}
|
|
365
|
+
consumeDelivered(ref.pendingReadded, pendingReaddedTools);
|
|
366
|
+
});
|
|
360
367
|
}
|
|
361
368
|
if ((mcpAdds !== undefined || mcpRemovals !== undefined) &&
|
|
362
369
|
due.some((a) => a.source === "mcp_instructions" && a.body === renderMcpInstructionsDelta(mcpAdds ?? [], mcpRemovals ?? []))) {
|
|
@@ -365,64 +372,57 @@ export function createTurnBoundary(input) {
|
|
|
365
372
|
if (mcpRemovals !== undefined)
|
|
366
373
|
mcpDelta.pendingRemovals.splice(0, mcpRemovals.length);
|
|
367
374
|
}
|
|
368
|
-
if (mcpDropped !== undefined &&
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (!noNextRequest()) {
|
|
375
|
+
if (mcpDropped !== undefined && due.some((a) => a.source === "mcp_dropped_tools")) {
|
|
376
|
+
recordSteps.set("mcp_dropped_tools", () => {
|
|
377
|
+
consumeDelivered(prepared.mcp.droppedTools, mcpDropped);
|
|
372
378
|
prepared.announcedListingsRef.advisories = withAnnounceDigests(prepared.announcedListingsRef.advisories, mcpDropped.map(droppedToolDigest));
|
|
373
|
-
|
|
374
|
-
}
|
|
379
|
+
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
380
|
+
});
|
|
375
381
|
}
|
|
376
382
|
if (agentListingDue && due.some((a) => a.source === "agent_listing")) {
|
|
377
383
|
const listing = prepared.agentListing;
|
|
378
384
|
const frame = renderAgentListingFrame(attachState, listing.entries, listing.toolName, listing.models, listing.budget);
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
prepared.announcedListingsRef.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
387
|
-
announceListingTruncation(deps.runner.deps.onNotice, { listing: "agents", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
|
|
388
|
-
},
|
|
385
|
+
recordSteps.set("agent_listing", () => {
|
|
386
|
+
commitAgentListing(attachState, listing.entries, listing.models);
|
|
387
|
+
prepared.announcedListingsRef.agents = listing.entries.map((e) => e.name);
|
|
388
|
+
if (listing.models !== undefined)
|
|
389
|
+
prepared.announcedListingsRef.models = [...listing.models];
|
|
390
|
+
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
391
|
+
announceListingTruncation(deps.runner.deps.onNotice, { listing: "agents", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
|
|
389
392
|
});
|
|
390
393
|
}
|
|
391
394
|
if (skillsListingDue && due.some((a) => a.source === "skills_listing")) {
|
|
392
395
|
const listing = prepared.skillsListing;
|
|
393
396
|
const frame = renderSkillsListingFrame(attachState, listing.entries, listing.budget);
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
400
|
-
announceListingTruncation(deps.runner.deps.onNotice, { listing: "skills", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
|
|
401
|
-
},
|
|
397
|
+
recordSteps.set("skills_listing", () => {
|
|
398
|
+
commitSkillsListing(attachState, listing.entries);
|
|
399
|
+
prepared.announcedListingsRef.skills = listing.entries.map((e) => e.name);
|
|
400
|
+
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
401
|
+
announceListingTruncation(deps.runner.deps.onNotice, { listing: "skills", total: frame.listed, nameOnly: frame.nameOnly, dropped: frame.dropped, budget: listing.budget, sessionId: prepared.sessionId });
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
if (announcedOnceDirty)
|
|
405
|
-
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
406
404
|
}
|
|
407
405
|
if (rs.attach.dateState !== undefined && !frameCarried(prepared.frameReceipts, "date_change")) {
|
|
408
406
|
const today = prepared.dateChange.today();
|
|
409
407
|
const cand = collectDateChange(rs.attach.dateState, today);
|
|
410
408
|
if (cand !== undefined) {
|
|
411
409
|
due.unshift(cand);
|
|
412
|
-
|
|
410
|
+
recordSteps.set("date_change", () => void (rs.attach.dateState.announcedDate = today));
|
|
413
411
|
}
|
|
414
412
|
}
|
|
415
|
-
if (rs.attach.sizeGuidelineState !== undefined) {
|
|
416
|
-
const
|
|
417
|
-
|
|
413
|
+
if (rs.attach.sizeGuidelineState !== undefined && !carried("workflow_size_guideline_change")) {
|
|
414
|
+
const sizeState = rs.attach.sizeGuidelineState;
|
|
415
|
+
const guideline = sizeState.current();
|
|
416
|
+
if (guideline !== sizeState.announcedGuideline) {
|
|
418
417
|
due.splice(due.length > 0 && due[0].source === "date_change" ? 1 : 0, 0, {
|
|
419
418
|
source: "workflow_size_guideline_change",
|
|
420
419
|
body: workflowSizeGuidelineChangeNotice(guideline),
|
|
421
420
|
});
|
|
422
|
-
|
|
421
|
+
recordSteps.set("workflow_size_guideline_change", () => void (sizeState.announcedGuideline = guideline));
|
|
423
422
|
}
|
|
424
423
|
}
|
|
425
|
-
if (rs.attach.instrState !== undefined && rs.attach.instrProbe !== undefined) {
|
|
424
|
+
if (rs.attach.instrState !== undefined && rs.attach.instrProbe !== undefined && !carried("instructions_change")) {
|
|
425
|
+
const instrState = rs.attach.instrState;
|
|
426
426
|
let probed = null;
|
|
427
427
|
try {
|
|
428
428
|
const PROBE_CEILING_MS = 2_000;
|
|
@@ -436,10 +436,10 @@ export function createTurnBoundary(input) {
|
|
|
436
436
|
catch {
|
|
437
437
|
probed = null;
|
|
438
438
|
}
|
|
439
|
-
const cand = collectInstructionsChange(
|
|
439
|
+
const cand = collectInstructionsChange(instrState, probed);
|
|
440
440
|
if (cand !== undefined) {
|
|
441
441
|
due.splice(due.length > 0 && due[0].source === "date_change" ? 1 : 0, 0, cand.attachment);
|
|
442
|
-
commitInstructionsChange(
|
|
442
|
+
recordSteps.set("instructions_change", () => commitInstructionsChange(instrState, cand.announced));
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
if (due.length > 0) {
|
|
@@ -447,9 +447,16 @@ export function createTurnBoundary(input) {
|
|
|
447
447
|
for (const a of due)
|
|
448
448
|
if (!isIntactSource(a.source))
|
|
449
449
|
boundaryAttachmentBytes += Buffer.byteLength(a.body, "utf8");
|
|
450
|
-
rs.attach.attachmentsInjected += due.length;
|
|
451
450
|
for (const a of due) {
|
|
452
|
-
|
|
451
|
+
const record = a.commit ?? recordSteps.get(a.source);
|
|
452
|
+
bundleReceipts.push({
|
|
453
|
+
source: a.source,
|
|
454
|
+
commit: () => {
|
|
455
|
+
queue.push({ type: "steering_injected", source: a.source, preview: redactThenCut(a.body, 220), ...ident() });
|
|
456
|
+
rs.attach.attachmentsInjected += 1;
|
|
457
|
+
record?.();
|
|
458
|
+
},
|
|
459
|
+
});
|
|
453
460
|
}
|
|
454
461
|
}
|
|
455
462
|
}
|
|
@@ -485,7 +492,7 @@ export function createTurnBoundary(input) {
|
|
|
485
492
|
}
|
|
486
493
|
if ((attachmentsPayload !== undefined || batchContextBlock !== undefined) && prepared.batchHaltRef.current === undefined) {
|
|
487
494
|
const payload = attachmentsPayload !== undefined && batchContextBlock !== undefined ? `${attachmentsPayload}\n${batchContextBlock}` : (attachmentsPayload ?? batchContextBlock);
|
|
488
|
-
for (const c of
|
|
495
|
+
for (const c of bundleReceipts)
|
|
489
496
|
prepared.frameReceipts.pending.push({ source: c.source, text: payload, commit: c.commit });
|
|
490
497
|
void prepared.harness.steer(payload, { engineMinted: true }).catch(() => {
|
|
491
498
|
prepared.frameReceipts.pending = prepared.frameReceipts.pending.filter((r) => r.text !== payload);
|