@sema-agent/core 7.67.3 → 7.68.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 +1516 -0
- package/README.md +18 -9
- package/README.zh-CN.md +16 -8
- package/dist/agents/agent-definition.d.ts +1 -1
- package/dist/agents/agent-definition.js +4 -1
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +3 -1
- package/dist/agents/cumulative-stats.d.ts +2 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/list-agents-tool.d.ts +30 -0
- package/dist/agents/list-agents-tool.js +45 -3
- package/dist/agents/peer-admission.d.ts +2 -2
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +1 -0
- package/dist/agents/repair-loop.js +3 -1
- package/dist/agents/retain-ledger.d.ts +61 -8
- package/dist/agents/retain-ledger.js +25 -3
- package/dist/agents/roster-store.d.ts +4 -2
- package/dist/agents/send-message-tool.d.ts +1 -1
- package/dist/agents/send-message-tool.js +20 -15
- package/dist/agents/subagent-steps.js +2 -10
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +106 -76
- package/dist/agents/tool-filter.d.ts +20 -11
- package/dist/agents/tool-filter.js +8 -4
- package/dist/agents/verify.d.ts +3 -1
- package/dist/agents/verify.js +2 -0
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/reasoning-request.d.ts +73 -19
- package/dist/brain/reasoning-request.js +164 -72
- package/dist/brain/reasoning-stamp.d.ts +26 -0
- package/dist/brain/reasoning-stamp.js +10 -0
- package/dist/brain/reasoning.d.ts +95 -162
- package/dist/brain/reasoning.js +31 -86
- package/dist/brain/route-adjudicator.d.ts +9 -7
- package/dist/brain/route-adjudicator.js +12 -10
- package/dist/brain/status-sink.d.ts +19 -64
- package/dist/brain/status-sink.js +5 -21
- package/dist/brain/stream-engine.d.ts +11 -2
- package/dist/brain/stream-engine.js +10 -0
- package/dist/core/a2a.d.ts +17 -5
- package/dist/core/a2a.js +11 -3
- package/dist/core/allow-entry.d.ts +35 -15
- package/dist/core/allow-entry.js +47 -60
- package/dist/core/ask-headline.d.ts +68 -0
- package/dist/core/ask-headline.js +23 -0
- package/dist/core/ask-origin.d.ts +36 -8
- package/dist/core/ask-origin.js +17 -10
- package/dist/core/ask-question.d.ts +34 -7
- package/dist/core/ask-question.js +10 -1
- package/dist/core/ask-unresolvable-notice.d.ts +7 -0
- package/dist/core/ask-unresolvable-notice.js +9 -3
- package/dist/core/auto-strip.d.ts +53 -0
- package/dist/core/auto-strip.js +76 -0
- package/dist/core/background-agent-store.d.ts +45 -5
- package/dist/core/background-agent-store.js +69 -15
- package/dist/core/background-shell.d.ts +2 -2
- package/dist/core/caller-text.js +2 -2
- package/dist/core/canonical-json.d.ts +13 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +66 -20
- package/dist/core/checkpoint-features.js +12 -1
- package/dist/core/checkpoint-generation.d.ts +1 -1
- package/dist/core/checkpoint-queries.d.ts +1 -1
- package/dist/core/checkpoint-queries.js +4 -1
- package/dist/core/checkpoint-requirements.d.ts +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +20 -14
- package/dist/core/protocol-http-auth.js +70 -50
- package/dist/core/read-only-shell.js +9 -5
- package/dist/core/redaction-marks.d.ts +4 -26
- package/dist/core/redaction-marks.js +9 -21
- package/dist/core/remote-env.d.ts +43 -16
- package/dist/core/remote-env.js +1 -1
- package/dist/core/request-copy-projection.d.ts +1 -1
- package/dist/core/request-copy-projection.js +40 -50
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +35 -18
- package/dist/core/resume-startup-cause.js +13 -10
- package/dist/core/retention.d.ts +167 -25
- package/dist/core/retention.js +100 -20
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +11 -5
- package/dist/core/rule-lane-reads.d.ts +3 -0
- package/dist/core/rule-lane-reads.js +5 -1
- package/dist/core/rule-store-fault.d.ts +70 -0
- package/dist/core/rule-store-fault.js +102 -0
- package/dist/core/runner/advertised-writable-dirs.js +16 -31
- package/dist/core/runner/announce-once-ledger.d.ts +19 -2
- package/dist/core/runner/announce-once-ledger.js +24 -2
- package/dist/core/runner/assemble-result.d.ts +6 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/auto-strip-notice.d.ts +36 -0
- package/dist/core/runner/auto-strip-notice.js +59 -0
- package/dist/core/runner/branch-window.d.ts +3 -0
- package/dist/core/runner/branch-window.js +37 -0
- package/dist/core/runner/caller-roster.d.ts +8 -3
- package/dist/core/runner/capability-withheld-seat.js +3 -9
- package/dist/core/runner/clock-and-limits.d.ts +22 -1
- package/dist/core/runner/clock-and-limits.js +30 -0
- package/dist/core/runner/contracts.d.ts +58 -35
- package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
- package/dist/core/runner/credential-refusal-seat.js +47 -0
- package/dist/core/runner/cross-boundary-lane.js +6 -4
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/file-history-restore.d.ts +53 -2
- package/dist/core/runner/file-history-restore.js +29 -10
- package/dist/core/runner/forward-sink.d.ts +14 -1
- package/dist/core/runner/forward-sink.js +14 -12
- package/dist/core/runner/gate-exit.d.ts +8 -7
- package/dist/core/runner/gate-exit.js +13 -13
- package/dist/core/runner/git-status-frame.js +2 -4
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/main-call-account.d.ts +3 -1
- package/dist/core/runner/main-call-account.js +5 -3
- package/dist/core/runner/mcp-redial.d.ts +2 -5
- package/dist/core/runner/mcp-redial.js +2 -2
- package/dist/core/runner/nested-memory-content.d.ts +7 -1
- package/dist/core/runner/nested-memory-content.js +73 -13
- package/dist/core/runner/nested-memory-lane.d.ts +44 -19
- package/dist/core/runner/nested-memory-lane.js +152 -76
- package/dist/core/runner/park-commit.js +3 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
- package/dist/core/runner/permission-rule-lanes.js +29 -3
- package/dist/core/runner/person-path-rows.d.ts +3 -11
- package/dist/core/runner/person-path-rows.js +21 -24
- package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +20 -14
- package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
- package/dist/core/runner/prepare-ask-lane.js +6 -5
- package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
- package/dist/core/runner/prepare-boundary-parks.js +27 -24
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -24
- package/dist/core/runner/prepare-config-doors.js +58 -41
- package/dist/core/runner/prepare-context-lane.d.ts +2 -2
- package/dist/core/runner/prepare-context-lane.js +3 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +3 -2
- package/dist/core/runner/prepare-file-history.d.ts +62 -26
- package/dist/core/runner/prepare-file-history.js +117 -46
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +6 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
- package/dist/core/runner/prepare-hands-readface.js +8 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +6 -6
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +10 -3
- package/dist/core/runner/prepare-park-ask.js +7 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
- package/dist/core/runner/prepare-policy-chain.js +18 -13
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +5 -3
- package/dist/core/runner/prepare-prompt-assembly.js +2 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
- package/dist/core/runner/prepare-protocol-tools.js +7 -7
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-run-refs.d.ts +7 -2
- package/dist/core/runner/prepare-run-refs.js +8 -7
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
- package/dist/core/runner/prepare-suspend-saga.js +4 -3
- package/dist/core/runner/prepare-task.js +66 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
- package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +1 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
- package/dist/core/runner/prepare-wiring-manifest.js +14 -6
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
- package/dist/core/runner/prepare-workspace-restore.js +15 -6
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/restore-seat.d.ts +41 -0
- package/dist/core/runner/restore-seat.js +38 -0
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +4 -3
- package/dist/core/runner/resume-checkpoint-screen.js +2 -1
- package/dist/core/runner/resume-internals-and-config.js +2 -1
- package/dist/core/runner/resume-preflight.js +2 -1
- package/dist/core/runner/rewind-files.js +22 -6
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
- package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
- package/dist/core/runner/run-brain-sinks.d.ts +3 -6
- package/dist/core/runner/run-brain-sinks.js +6 -6
- package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.js +20 -12
- package/dist/core/runner/run-leg.js +31 -72
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -4
- package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
- package/dist/core/runner/run-reasoning-seat.js +13 -18
- package/dist/core/runner/run-settle-and-teardown.js +13 -9
- package/dist/core/runner/run-terminal-adoption.js +4 -8
- package/dist/core/runner/run-turn-boundary.js +6 -3
- package/dist/core/runner/runtask.d.ts +9 -4
- package/dist/core/runner/runtask.js +29 -22
- package/dist/core/runner/session-rule-policy.d.ts +11 -1
- package/dist/core/runner/shell-env-withheld.js +2 -7
- package/dist/core/runner/side-call-account.d.ts +5 -6
- package/dist/core/runner/side-call-account.js +2 -2
- package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
- package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
- package/dist/core/runner/stream-settle-backstop.js +4 -6
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +4 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
- package/dist/core/runner/sub-agent-deny-lists.js +7 -4
- package/dist/core/runner/teardown-bounded.d.ts +7 -0
- package/dist/core/runner/teardown-bounded.js +7 -0
- package/dist/core/runner/terminal-account.js +41 -13
- package/dist/core/runner/terminal-projection.d.ts +1 -5
- package/dist/core/runner/tool-end-body.d.ts +9 -3
- package/dist/core/runner/tool-end-body.js +6 -3
- package/dist/core/runner/tool-output-projection.d.ts +13 -4
- package/dist/core/runner/tool-output-projection.js +10 -14
- package/dist/core/runner/turn-attachments.d.ts +3 -2
- package/dist/core/runner/turn-attachments.js +12 -5
- package/dist/core/runner-deps.d.ts +6 -6
- package/dist/core/runtime-caps.d.ts +2 -1
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +13 -15
- package/dist/core/session-checkout.d.ts +115 -15
- package/dist/core/session-checkout.js +435 -136
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.js +1 -0
- package/dist/core/session-store.js +2 -0
- package/dist/core/session.d.ts +11 -1
- package/dist/core/shell-run-candidates.d.ts +1 -0
- package/dist/core/shell-run-candidates.js +1 -1
- package/dist/core/shutdown-debug.d.ts +6 -5
- package/dist/core/shutdown-debug.js +5 -1
- package/dist/core/skill-grant.js +4 -1
- package/dist/core/skills-directory.js +5 -3
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
- package/dist/core/store-contracts/file-history-store-contract.js +26 -2
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
- package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/task-list-store-contract.js +28 -1
- package/dist/core/task-event.d.ts +48 -27
- package/dist/core/task-notification.d.ts +15 -9
- package/dist/core/task-notification.js +12 -0
- package/dist/core/task-registry-agent.d.ts +24 -22
- package/dist/core/task-registry-agent.js +65 -46
- package/dist/core/task-registry-shared.d.ts +17 -5
- package/dist/core/task-registry.d.ts +17 -6
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-result.d.ts +71 -25
- package/dist/core/task-spec-members.d.ts +0 -1
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +60 -52
- package/dist/core/task-stream.d.ts +45 -12
- package/dist/core/terminal-cause.d.ts +45 -8
- package/dist/core/terminal-cause.js +5 -0
- package/dist/core/tool-card-bound.d.ts +32 -0
- package/dist/core/tool-card-bound.js +33 -0
- package/dist/core/tool-catalog-entries.d.ts +9 -0
- package/dist/core/tool-catalog-entries.js +48 -0
- package/dist/core/tool-errors.d.ts +4 -3
- package/dist/core/tool-face.d.ts +3 -3
- package/dist/core/tool-mount-facts.d.ts +3 -2
- package/dist/core/tool-mount-facts.js +1 -1
- package/dist/core/tool-mount-static.js +7 -5
- package/dist/core/tool-policy.d.ts +21 -19
- package/dist/core/tool-policy.js +5 -6
- package/dist/core/tool-registry.d.ts +3 -1
- package/dist/core/tool-registry.js +15 -1
- package/dist/core/tool-result-store.d.ts +9 -3
- package/dist/core/tool-result-store.js +14 -1
- package/dist/core/tool-roster.d.ts +6 -0
- package/dist/core/tool-roster.js +18 -0
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +10 -9
- package/dist/core/untrusted-egress.js +9 -9
- package/dist/core/untrusted-text.d.ts +0 -18
- package/dist/core/untrusted-text.js +7 -3
- package/dist/core/user-attachment.d.ts +9 -6
- package/dist/core/user-attachment.js +12 -10
- package/dist/core/user-row-origin.d.ts +44 -25
- package/dist/core/user-row-origin.js +30 -20
- package/dist/core/wiring-manifest.d.ts +26 -7
- package/dist/core/wiring-manifest.js +14 -11
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
- package/dist/engine/execution-env/node-execution-env.js +127 -67
- package/dist/engine/harness/agent-harness.d.ts +4 -5
- package/dist/engine/harness/agent-harness.js +2 -7
- package/dist/engine/harness/types.d.ts +51 -19
- package/dist/engine/harness/types.js +28 -1
- package/dist/engine/llm/types.d.ts +26 -14
- package/dist/engine/llm/types.js +2 -2
- package/dist/engine/loop/agent-loop.d.ts +2 -2
- package/dist/engine/loop/agent-loop.js +51 -275
- package/dist/engine/loop/types.d.ts +0 -18
- package/dist/engine/session/import-validate.d.ts +3 -0
- package/dist/engine/session/import-validate.js +34 -2
- package/dist/engine/session/repo-utils.d.ts +42 -4
- package/dist/engine/session/repo-utils.js +33 -5
- package/dist/engine/session/session.d.ts +41 -14
- package/dist/engine/session/session.js +96 -25
- package/dist/index.d.ts +21 -16
- package/dist/index.js +16 -10
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -9
- package/dist/orchestration/run-workflow-tool.js +15 -19
- package/dist/orchestration/workflow-governance.js +13 -21
- package/dist/orchestration/workflow-observe.d.ts +4 -3
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
- package/dist/orchestration/workflow-record-artifact.js +32 -0
- package/dist/orchestration/workflow-script-store.d.ts +9 -0
- package/dist/orchestration/workflow-script-store.js +20 -1
- package/dist/orchestration/workflow-types.d.ts +33 -3
- package/dist/orchestration/workflow.d.ts +24 -14
- package/dist/orchestration/workflow.js +52 -23
- package/dist/prompt-assembly/artifact.js +4 -8
- package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
- package/dist/prompt-assembly/catalog/engine.js +30 -0
- package/dist/prompt-assembly/catalog/index.d.ts +1 -1
- package/dist/prompt-assembly/catalog/index.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
- package/dist/prompt-assembly/epoch.js +6 -8
- package/dist/prompt-assembly/turn-snapshot.js +8 -9
- package/dist/stores/file/background-agent-store.js +5 -6
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +7 -3
- package/dist/stores/file/file-history-store.d.ts +8 -0
- package/dist/stores/file/file-history-store.js +72 -0
- package/dist/stores/file/fs-atomic.js +17 -12
- package/dist/stores/file/index.js +11 -5
- package/dist/stores/file/mailbox-store.js +13 -4
- package/dist/stores/file/permission-rule-store.js +14 -13
- package/dist/stores/file/shared-ledger.d.ts +4 -0
- package/dist/stores/file/shared-ledger.js +4 -0
- package/dist/stores/file/task-list-store.js +12 -3
- package/dist/stores/file/workflow-run-store.js +1 -0
- package/dist/tools/fs/bash-program-position.d.ts +4 -2
- package/dist/tools/fs/bash-program-position.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +1 -1
- package/dist/tools/fs/bound-open.d.ts +97 -0
- package/dist/tools/fs/bound-open.js +103 -0
- package/dist/tools/fs/containment-face.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.d.ts +7 -1
- package/dist/tools/fs/fs-pdf.js +31 -23
- package/dist/tools/fs/fs-read.d.ts +24 -17
- package/dist/tools/fs/fs-read.js +84 -53
- package/dist/tools/fs/fs-shared.d.ts +14 -12
- package/dist/tools/fs/fs-shared.js +5 -4
- package/dist/tools/fs/fs-write.d.ts +2 -2
- package/dist/tools/fs/fs-write.js +20 -12
- package/dist/tools/fs/index.d.ts +4 -4
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +12 -3
- package/dist/tools/fs/pdf.js +22 -9
- package/dist/tools/fs/read-deny-home.d.ts +3 -2
- package/dist/tools/fs/read-deny-home.js +8 -11
- package/dist/tools/fs/safety.d.ts +3 -2
- package/dist/tools/fs/shell-read-check.js +10 -9
- package/dist/tools/monitor.d.ts +6 -5
- package/dist/tools/task-list.d.ts +16 -6
- package/dist/tools/task-list.js +4 -0
- package/dist/tools/web.d.ts +9 -1
- package/dist/tools/web.js +8 -3
- package/dist/tools/worktree.d.ts +7 -5
- package/dist/tools/worktree.js +4 -3
- package/package.json +4 -3
- package/test/export-surface.snapshot.json +93 -7
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uuidv7 } from "../../internal/harness.js";
|
|
2
|
-
import {
|
|
3
|
-
import { forwardSafely } from "./forward-sink.js";
|
|
2
|
+
import { observeThenableRejection } from "../safe-notify.js";
|
|
3
|
+
import { forwardSafely, hostSinkNotifier } from "./forward-sink.js";
|
|
4
4
|
import { createSnapshotFrameSeat } from "../snapshot-frame-seat.js";
|
|
5
5
|
import { emitsChildRowFrames, taskStartedFrame } from "../delegation-frames.js";
|
|
6
6
|
import { recordFrameReceipt, toolResultReceiptKey } from "../frame-settlement.js";
|
|
@@ -9,7 +9,9 @@ import { discloseDroppedPending, renderTaskNotificationXml, sessionAddressOf, ta
|
|
|
9
9
|
import { buildAppliedHumanInputEvent } from "../human-input-projection.js";
|
|
10
10
|
import { announceAcceptance, nextHumanInputSeq } from "./steer-admission.js";
|
|
11
11
|
import { deliverDelegationLifecycle, deliverEngineNotice, parentLegIds, parkedInputIdsOf, undrainedUserInputNotices } from "../types.js";
|
|
12
|
-
import { droppedInputsDisclosure } from "../input-author.js";
|
|
12
|
+
import { droppedInputsDisclosure, droppedInputsNotice } from "../input-author.js";
|
|
13
|
+
import { legNoticeTaskId } from "../mods/stations.js";
|
|
14
|
+
import { announceDigest, withAnnounceDigests } from "./announce-once-ledger.js";
|
|
13
15
|
import { inputSourceOf } from "../steer-replay.js";
|
|
14
16
|
import { mintCallerStopGate } from "./caller-stop-gate.js";
|
|
15
17
|
export function runIdentityWiring(input) {
|
|
@@ -24,9 +26,7 @@ export function runIdentityWiring(input) {
|
|
|
24
26
|
const parentToolCallId = internals?.parentToolCallId;
|
|
25
27
|
const ident = () => parentToolCallId !== undefined ? { eventId: uuidv7(), parentToolCallId, sourceTaskId: runSourceTaskId } : { eventId: uuidv7() };
|
|
26
28
|
notificationLane.ident = ident;
|
|
27
|
-
const internalsNotifier =
|
|
28
|
-
onError: (f) => console.warn(`[sema-core] ${f.site}: run-internals sink threw (contained; further failures counted, not re-disclosed): ${f.error.message}`),
|
|
29
|
-
});
|
|
29
|
+
const internalsNotifier = hostSinkNotifier(runner.deps.onNotice, "run_internals");
|
|
30
30
|
const legAt = Object.freeze({ taskId: prepared.taskId, sessionId: prepared.sessionId });
|
|
31
31
|
const offerLegFrame = (frame) => {
|
|
32
32
|
Object.freeze(frame);
|
|
@@ -40,15 +40,13 @@ export function runIdentityWiring(input) {
|
|
|
40
40
|
prepared.toolRosterDeltas.subscribe((delta) => queue.push({ type: "tool_roster_delta", delta, ...ident() }));
|
|
41
41
|
prepared.toolDisclosure?.subscribe((snapshot) => queue.push({ type: "tool_disclosure", ...snapshot, ...ident() }));
|
|
42
42
|
prepared.workspaceFrame.subscribe((snapshot) => offerLegFrame({ type: "workspace_changed", ...snapshot, ...ident() }));
|
|
43
|
-
const delegationLifecycleNotifier =
|
|
44
|
-
onError: (f) => console.warn(`[sema-core] ${f.site}: delegation-lifecycle observer threw (contained; further failures counted, not re-disclosed): ${f.error.message}`),
|
|
45
|
-
});
|
|
43
|
+
const delegationLifecycleNotifier = hostSinkNotifier(runner.deps.onNotice, "delegation_lifecycle");
|
|
46
44
|
const emitDelegationLifecycle = (event) => {
|
|
47
45
|
if (!prepared.hookIdentity.isDelegatedChild)
|
|
48
46
|
return;
|
|
49
47
|
if (runner.deps.onDelegationLifecycle === undefined)
|
|
50
48
|
return;
|
|
51
|
-
deliverDelegationLifecycle(runner.deps.onDelegationLifecycle, event, delegationLifecycleNotifier, "runtask.onDelegationLifecycle");
|
|
49
|
+
deliverDelegationLifecycle(runner.deps.onDelegationLifecycle, event, delegationLifecycleNotifier, "runtask.onDelegationLifecycle", runner.deps.onNotice);
|
|
52
50
|
};
|
|
53
51
|
if (emitsChildRowFrames(prepared.hookIdentity) && prepared.hookIdentity.legKind !== "resume") {
|
|
54
52
|
const started = taskStartedFrame({ taskId: runSourceTaskId, sessionId: prepared.sessionId, model: prepared.model.id, identity: prepared.hookIdentity }, internals, ident());
|
|
@@ -87,7 +85,17 @@ export function runIdentityWiring(input) {
|
|
|
87
85
|
deliverEngineNotice(runner.deps.onNotice, notice);
|
|
88
86
|
}
|
|
89
87
|
};
|
|
90
|
-
prepared.harness.onUndrainedOtherInputs = (authors) =>
|
|
88
|
+
prepared.harness.onUndrainedOtherInputs = (authors) => {
|
|
89
|
+
runner.deps.onError?.(droppedInputsDisclosure(authors), { phase: "degraded", sessionId: prepared.sessionId, classification: "undelivered-input-dropped" });
|
|
90
|
+
const notice = droppedInputsNotice(authors, { ...prepared.legNotice.route.address, ...legNoticeTaskId(prepared), runId: prepared.runId });
|
|
91
|
+
const digest = announceDigest(notice.code, prepared.sessionId);
|
|
92
|
+
const record = prepared.announcedListingsRef;
|
|
93
|
+
if (record.advisories?.includes(digest) === true)
|
|
94
|
+
return;
|
|
95
|
+
deliverEngineNotice(runner.deps.onNotice, notice, prepared.legNotice.admission);
|
|
96
|
+
record.advisories = withAnnounceDigests(record.advisories, [digest]);
|
|
97
|
+
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
98
|
+
};
|
|
91
99
|
prepared.harness.onEngineNoteConsumed = (p) => {
|
|
92
100
|
const payload = p;
|
|
93
101
|
const peer = payload?.peer;
|
|
@@ -152,6 +160,6 @@ export function runIdentityWiring(input) {
|
|
|
152
160
|
}
|
|
153
161
|
const loopLatch = { ended: false, userInterrupted: false, userHalted: false, callerStop: mintCallerStopGate(spec.signal) };
|
|
154
162
|
onReady({ harness: prepared.harness, abortController: prepared.abortController, loop: loopLatch, reminderMark: prepared.reminderMark, sessionId: prepared.sessionId, runId: prepared.runId, hookIdentity: prepared.hookIdentity, modBus: prepared.modBus, permissionMode: prepared.permissionMode });
|
|
155
|
-
const stats = { turns: 0, tokens: 0, toolCalls: 0, promptTokens: 0, totalInputTokens: 0, cachedTokens: 0, cacheWriteTokens: 0, cacheWriteTokensLong: 0, outputTokens: 0, costMicroUsd: 0 };
|
|
163
|
+
const stats = { turns: 0, tokens: 0, toolCalls: 0, promptTokens: 0, totalInputTokens: 0, cachedTokens: 0, cacheWriteTokens: 0, cacheWriteTokensLong: 0, outputTokens: 0, costMicroUsd: 0, apiDurationMs: 0 };
|
|
156
164
|
return { runSourceTaskId, parentToolCallId, ident, emitDelegationLifecycle, loopLatch, stats, internalsNotifier, offerLegFrame, undrainedUserAtEnd: { get current() { return undrainedUserAtEnd; } }, userInputLostAtEnd: { get current() { return userInputLostAtEnd; } } };
|
|
157
165
|
}
|
|
@@ -6,7 +6,7 @@ import { CheckpointError, planReviewRequesterOf, readPendingSteerQueue, realAppr
|
|
|
6
6
|
import { normalizePersistedRuleHit } from "../rule-lane-reads.js";
|
|
7
7
|
import { decidersNote, SETTLEMENT_NOBODY_JUDGED } from "../gate-outcome.js";
|
|
8
8
|
import { formatHookFeedback } from "../hooks.js";
|
|
9
|
-
import { classicEventBase, failedHandlerClause, legEventsOf, legNoticeTaskId, openSubagent, screenUserPrompt, seatHears } from "../mods/stations.js";
|
|
9
|
+
import { classicEventBase, failedHandlerClause, legEventsOf, legNoticeTaskId, observePermissionDenied, openSubagent, screenUserPrompt, seatHears } from "../mods/stations.js";
|
|
10
10
|
import { raiseSessionEnd, raiseSessionStart } from "../mods/lifecycle-stations.js";
|
|
11
11
|
import { offeredAgentListing } from "../mods/agent-stations.js";
|
|
12
12
|
import { appendAdmittedRow } from "../row-admission.js";
|
|
@@ -45,7 +45,7 @@ import { approvalWordsOf, owedApprovalWords, withApprovalWords } from "./approva
|
|
|
45
45
|
import { chainCannotJudge } from "./call-hook-stations.js";
|
|
46
46
|
import { settleExecutionRecord } from "./execution-record.js";
|
|
47
47
|
import { holdPrompt } from "./prompt-block.js";
|
|
48
|
-
import { frozenInputSnapshot } from "./gate-exit.js";
|
|
48
|
+
import { frozenInputSnapshot, permissionDeniedOf } from "./gate-exit.js";
|
|
49
49
|
import { withGateTimeout } from "../gate-bounded-await.js";
|
|
50
50
|
import { readStationAnswer } from "../shell-read-silence.js";
|
|
51
51
|
import { resolveGitLegDelivery, wrapGitFrame } from "./git-leg-delivery.js";
|
|
@@ -55,6 +55,7 @@ import { isBareHumanRefusal, maybeHumanRejectionHalt } from "./prepare-gate-stat
|
|
|
55
55
|
import { nextHumanInputSeq } from "./steer-admission.js";
|
|
56
56
|
import { usableInputId } from "../user-row-origin.js";
|
|
57
57
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
58
|
+
import { runAbortedError } from "../terminal-cause.js";
|
|
58
59
|
import { announceToolCall, emitSettled, toolResultMsg } from "./tool-end-body.js";
|
|
59
60
|
import { rowDetailsOf, withRowNotExecuted } from "./tool-not-executed.js";
|
|
60
61
|
import { announceListingTruncation } from "../skill-listing-budget.js";
|
|
@@ -81,11 +82,8 @@ export async function runLeg(input) {
|
|
|
81
82
|
const starting = raiseSessionStart(prepared.modBus, prepared.hookIdentity, { cwd: prepared.cwdRef?.current ?? prepared.taskRootPath, sessionId: prepared.sessionId }, prepared.abortController.signal);
|
|
82
83
|
if (starting !== undefined)
|
|
83
84
|
await starting;
|
|
84
|
-
if (prepared.abortController.signal.aborted)
|
|
85
|
-
|
|
86
|
-
e.name = "AbortError";
|
|
87
|
-
throw e;
|
|
88
|
-
}
|
|
85
|
+
if (prepared.abortController.signal.aborted)
|
|
86
|
+
throw runAbortedError();
|
|
89
87
|
if (resume) {
|
|
90
88
|
const walltimeExhaustedResume = effectiveTimeoutMs !== undefined && effectiveTimeoutMs <= 0;
|
|
91
89
|
const approvalWords = approvalWordsOf(resume.outcome);
|
|
@@ -728,13 +726,12 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
728
726
|
const occurrences = prepared.toolOccurrences;
|
|
729
727
|
const callStart = { toolCallId: pendingAction.toolCallId, spelledName, wireName: pendingAction.toolName, ...pendingLabel, args: resolvedArgs, ...(resume.cp.checkpointId !== undefined ? { resumesCheckpoint: resume.cp.checkpointId } : {}) };
|
|
730
728
|
announceToolCall(occurrences, callStart, { push: emit });
|
|
731
|
-
|
|
729
|
+
const decidedInput = frozenInputSnapshot(resolvedArgs);
|
|
730
|
+
occurrences.gateRound(pendingAction.toolCallId, decidedGate, decidedInput);
|
|
732
731
|
let notExecuted = false;
|
|
733
732
|
const resultRow = (text, isError) => withRowNotExecuted(toolResultMsg(pendingAction.toolCallId, pendingAction.toolName, text, isError), notExecuted);
|
|
734
|
-
const settleEnd = async (isError, result,
|
|
735
|
-
|
|
736
|
-
occurrences.refuse(pendingAction.toolCallId, refusedBy, facts);
|
|
737
|
-
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars });
|
|
733
|
+
const settleEnd = async (isError, result, neverRan) => {
|
|
734
|
+
const settled = emitSettled(occurrences, callStart, { result, isError, ...(neverRan ? { notExecuted: true } : {}) }, { push: emit, structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars, reviewRequest: prepared.reviewRequestRef });
|
|
738
735
|
notExecuted = settled.notExecuted === true;
|
|
739
736
|
const gate = settled.gate ?? decidedGate;
|
|
740
737
|
const word = await resume.recordExecutionOutcome(gate);
|
|
@@ -743,14 +740,17 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
743
740
|
const settleUnreadable = async (error, which) => {
|
|
744
741
|
const marks = egressValue("same-principal", thrownMarksOf(error));
|
|
745
742
|
const text = formatHookFeedback(`The approved tool call "${pendingAction.toolName}" was not executed: the tool could not read ${which} — its argument preparation failed (${egressThrownText("same-principal", error)}). This approval is spent — the call has to be re-issued.`, prepared.reminderMark);
|
|
746
|
-
await settleEnd(true, { content: text, ...(marks !== undefined ? { details: marks } : {}) },
|
|
743
|
+
await settleEnd(true, { content: text, ...(marks !== undefined ? { details: marks } : {}) }, true);
|
|
747
744
|
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(text, true)), "toolResult", pendingAction.toolCallId);
|
|
748
745
|
};
|
|
749
|
-
const
|
|
750
|
-
const
|
|
751
|
-
await
|
|
746
|
+
const refuseCall = async (sentence, by, card = {}) => {
|
|
747
|
+
const gate = by === undefined ? decidedGate : occurrences.refuse(pendingAction.toolCallId, by.layer, by.facts);
|
|
748
|
+
await observePermissionDenied({ legBus: prepared.modBus, payload: permissionDeniedOf({ toolName: pendingAction.toolName, finalInput: decidedInput, toolCallId: pendingAction.toolCallId, reason: sentence, gate, identity: prepared.hookIdentity, permissionMode: prepared.permissionMode.observed }), signal: prepared.abortController.signal });
|
|
749
|
+
const text = formatHookFeedback(sentence, prepared.reminderMark);
|
|
750
|
+
await settleEnd(true, { content: text, ...card });
|
|
752
751
|
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(text, true)), "toolResult", pendingAction.toolCallId);
|
|
753
752
|
};
|
|
753
|
+
const vetoApproval = (miss) => refuseCall(miss.message, { layer: "policy" }, miss.code !== undefined ? { details: { code: miss.code } } : {});
|
|
754
754
|
if (outcome.decision === "deny") {
|
|
755
755
|
const settlementKind = outcome.gateOutcome?.settlement?.kind;
|
|
756
756
|
const reason = settlementKind === "policy_refused"
|
|
@@ -760,9 +760,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
760
760
|
? delimitUntrusted("reviewer note", outcome.reason, REVIEWER_NOTE_MAX_BODY)
|
|
761
761
|
: `No one answered the approval request for the pending tool call "${pendingAction.toolName}" — the approval window elapsed with no answer, so it was not executed.`
|
|
762
762
|
: humanRefusalSentence("tool use", outcome.reason, prepared.hookIdentity.isDelegatedChild);
|
|
763
|
-
await
|
|
764
|
-
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(formatHookFeedback(reason, prepared.reminderMark), true));
|
|
765
|
-
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
763
|
+
await refuseCall(reason);
|
|
766
764
|
const parkedFallback = pendingAction.denialLimitFallback;
|
|
767
765
|
if (parkedFallback !== undefined && settlementKind !== undefined && SETTLEMENT_NOBODY_JUDGED[settlementKind]) {
|
|
768
766
|
prepared.stopForDenialLimit({ toolName: pendingAction.toolName, toolCallId: pendingAction.toolCallId, fallback: parkedFallback, settlement: settlementKind });
|
|
@@ -777,23 +775,15 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
777
775
|
if (decided.unread !== undefined)
|
|
778
776
|
return settleUnreadable(decided.unread.error, humanRewrite !== undefined ? "the arguments the decision edited it to" : "its arguments");
|
|
779
777
|
const screened = await prepared.approvedCallScreen?.({ toolCallId: pendingAction.toolCallId, toolName: pendingAction.toolName, args: structuredClone(resolvedArgs), answered });
|
|
780
|
-
if (screened !== undefined && "refused" in screened)
|
|
781
|
-
|
|
782
|
-
await settleEnd(true, { content: hookDenial }, "hook", undefined, screened.extension !== undefined ? { extension: screened.extension } : undefined);
|
|
783
|
-
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(hookDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
784
|
-
return;
|
|
785
|
-
}
|
|
778
|
+
if (screened !== undefined && "refused" in screened)
|
|
779
|
+
return refuseCall(screened.refused, { layer: "hook", facts: screened.extension !== undefined ? { extension: screened.extension } : undefined });
|
|
786
780
|
const executedArgs = resolvedArgs;
|
|
787
781
|
const unseen = !licenseCovers(pendingAction.boundInputHash, pendingAction.toolName, executedArgs);
|
|
788
782
|
let beltReading;
|
|
789
783
|
const beltReq = () => ({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId, ...callFactsSeat({ face: beltFace(), budget: beltBudget, cwd: prepared.cwdRef?.current, root: prepared.handsRoot, advertisedWritableDirs: prepared.advertisedWritableDirs, exemptRoots: prepared.exemptRoots }), ...(beltReading !== undefined ? { targetReading: beltReading } : {}), ...requestGrantBinding((call, args) => skillGrantBindingMembers(call, args, prepared.skillSpecs, SKILL_TOOL_NAME), pendingAction, executedArgs) });
|
|
790
784
|
const unjudgeable = unseen ? chainCannotJudge(resume.cp.state.inheritedGate) : undefined;
|
|
791
|
-
if (unjudgeable !== undefined)
|
|
792
|
-
|
|
793
|
-
await settleEnd(true, { content: chainDenial }, "policy");
|
|
794
|
-
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(chainDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
785
|
+
if (unjudgeable !== undefined)
|
|
786
|
+
return refuseCall(`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.`, { layer: "policy" });
|
|
797
787
|
const beltBudget = {
|
|
798
788
|
resourceRemainingMicroUsd: remainingBudgetMicroUsd(prepared.resourceLedger),
|
|
799
789
|
resourceSpentMicroUsd: prepared.resourceLedger?.spentMicroUsd ?? 0,
|
|
@@ -823,21 +813,14 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
823
813
|
: personUnanswered
|
|
824
814
|
? " (the call as it would run raises a question that requires a person's approval, and no person answered that question for this call; send the call again to have it asked)"
|
|
825
815
|
: " (the policy rewrote these bytes to a value that was not approved)";
|
|
826
|
-
const editedDenial = formatHookFeedback(`The approver EDITED this call's input; the edited call is refused by the deployment's tool policy and was not executed${why}.`, prepared.reminderMark);
|
|
827
816
|
const outlet = rechecked.action !== "deny" && !personUnanswered && rewrite?.unread === undefined && rewrite !== undefined ? { details: { editRewritten: { acceptableForm: rewrite.args } } } : denialCard(rechecked);
|
|
828
|
-
|
|
829
|
-
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(editedDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
830
|
-
return;
|
|
817
|
+
return refuseCall(`The approver EDITED this call's input; the edited call is refused by the deployment's tool policy and was not executed${why}.`, { layer: "policy" }, outlet);
|
|
831
818
|
}
|
|
832
819
|
}
|
|
833
820
|
const gateRealApproval = resume.cp.gate.kind === "irreversible_ask" ? resume.cp.gate.realApproval : undefined;
|
|
834
821
|
const gateOrgGoverned = realApprovalOrgFact(gateRealApproval) !== undefined;
|
|
835
822
|
if (gateOrgGoverned && prepared.permissionRuleOrg === undefined) {
|
|
836
|
-
|
|
837
|
-
await settleEnd(true, { content: unwiredDenial }, "org");
|
|
838
|
-
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(unwiredDenial, true));
|
|
839
|
-
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
840
|
-
return;
|
|
823
|
+
return refuseCall(`The approved tool call "${pendingAction.toolName}" was not executed: its approval was minted under organization governance (${gateRealApproval.origin}), and this worker has no org adjudication wiring — a governed approval may only be redeemed where governance can be enforced. This approval is spent; re-issue the call on an org-wired worker.`, { layer: "org" });
|
|
841
824
|
}
|
|
842
825
|
if (prepared.permissionRuleOrg !== undefined) {
|
|
843
826
|
const orgVerdict = prepared.permissionRuleOrg
|
|
@@ -867,30 +850,18 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
867
850
|
const orgDisclosures = org.status === "unavailable" && org.disclosures.length > 0
|
|
868
851
|
? ` Governance disclosures: ${inlineUntrusted(org.disclosures.join("; "), ORG_DISCLOSURE_MAX_CHARS)}.`
|
|
869
852
|
: "";
|
|
870
|
-
|
|
871
|
-
await settleEnd(true, { content: orgDenial }, "org");
|
|
872
|
-
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(orgDenial, true));
|
|
873
|
-
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
874
|
-
return;
|
|
853
|
+
return refuseCall(`The approved tool call "${pendingAction.toolName}" was not executed: ${blocked}.${orgDisclosures} This approval is spent — the call has to be re-issued and ${unanswered ? "decided by a person" : "approved again once organization policy permits it"}.`, { layer: "org" });
|
|
875
854
|
}
|
|
876
855
|
}
|
|
877
856
|
if (prepared.denyNarrowingPolicy) {
|
|
878
857
|
const narrowed = refuseOutOfContractDecision(await beltCheck((signal) => prepared.denyNarrowingPolicy.check(beltReq(), signal), "the narrowing rules re-checking a resumed call"));
|
|
879
858
|
if (narrowed.action === "deny") {
|
|
880
|
-
|
|
881
|
-
await settleEnd(true, { content: narrowedDenial, ...denialCard(narrowed) }, "policy");
|
|
882
|
-
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(narrowedDenial, true));
|
|
883
|
-
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
884
|
-
return;
|
|
859
|
+
return refuseCall(`The approved tool call "${pendingAction.toolName}" is now denied by ${ruleSourcePhrase("narrowing")} and was not executed${narrowed.message ? `: ${narrowed.message}` : ""}.`, { layer: "policy" }, denialCard(narrowed));
|
|
885
860
|
}
|
|
886
861
|
}
|
|
887
862
|
const skillRefusal = skillRowRefusal(prepared.skillGrants, beltReq());
|
|
888
|
-
if (skillRefusal !== undefined)
|
|
889
|
-
|
|
890
|
-
await settleEnd(true, { content: skillDenial }, "policy");
|
|
891
|
-
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(skillDenial, true)), "toolResult", pendingAction.toolCallId);
|
|
892
|
-
return;
|
|
893
|
-
}
|
|
863
|
+
if (skillRefusal !== undefined)
|
|
864
|
+
return refuseCall(`The approved tool call "${pendingAction.toolName}" was not executed: ${skillRefusal.message}. This approval is spent — the call has to be re-issued.`, { layer: "policy" });
|
|
894
865
|
if (prepared.persistedRuleLane !== undefined) {
|
|
895
866
|
const unreadable = { unreadable: true };
|
|
896
867
|
let laneWaitCancelled = false;
|
|
@@ -909,11 +880,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
909
880
|
: tightened.tightened === "deny"
|
|
910
881
|
? `a standing deny rule of yours (${disclosedRuleSet(read.hit?.rules ?? [])}) now refuses it`
|
|
911
882
|
: `it could not be read against your standing deny/ask rules (${read.reason})`;
|
|
912
|
-
|
|
913
|
-
await settleEnd(true, { content: ruleDenial, ...denialCard(tightened.decision) }, "persisted_rule");
|
|
914
|
-
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(ruleDenial, true));
|
|
915
|
-
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
916
|
-
return;
|
|
883
|
+
return refuseCall(`The approved tool call "${pendingAction.toolName}" was not executed: ${why}. This approval is spent — the call has to be re-issued and approved again.`, { layer: "persisted_rule" }, denialCard(tightened.decision));
|
|
917
884
|
}
|
|
918
885
|
}
|
|
919
886
|
if (prepared.shellReadCheck !== undefined) {
|
|
@@ -932,11 +899,7 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
932
899
|
}
|
|
933
900
|
const reading = readStationAnswer(verdict, { toolName: pendingAction.toolName, toolCallId: pendingAction.toolCallId });
|
|
934
901
|
if (reading.kind === "refuse" || reading.kind === "silence" || (unseen && reading.kind !== "vouch")) {
|
|
935
|
-
|
|
936
|
-
await settleEnd(true, { content: readDenial, ...(reading.verdict.details !== undefined ? { details: reading.verdict.details } : {}) }, "read_boundary", undefined, reading.verdict.echoed !== undefined ? { echoed: reading.verdict.echoed } : undefined);
|
|
937
|
-
const eid = await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(readDenial, true));
|
|
938
|
-
emitCommitted(eid, "toolResult", pendingAction.toolCallId);
|
|
939
|
-
return;
|
|
902
|
+
return refuseCall(`The approved tool call "${pendingAction.toolName}" was not executed: ${reading.verdict.sentence ?? "the read boundary does not vouch for what it reads on this leg"} This approval is spent — the call has to be re-issued and approved again.`, { layer: "read_boundary", facts: reading.verdict.echoed !== undefined ? { echoed: reading.verdict.echoed } : undefined }, reading.verdict.details !== undefined ? { details: reading.verdict.details } : {});
|
|
940
903
|
}
|
|
941
904
|
reading.verdict.admit?.();
|
|
942
905
|
}
|
|
@@ -952,12 +915,8 @@ async function resolvePendingCall(runner, prepared, resume, emit, emitCommitted,
|
|
|
952
915
|
tool = mounted().tool;
|
|
953
916
|
const waited = prepared.crossBoundary?.storeWaits() ?? 0;
|
|
954
917
|
const crossBoundaryRefusal = await prepared.crossBoundary?.check?.exit({ toolName: pendingAction.toolName, args: executedArgs, toolCallId: pendingAction.toolCallId }, answered);
|
|
955
|
-
if (crossBoundaryRefusal !== undefined)
|
|
956
|
-
|
|
957
|
-
await settleEnd(true, { content: text }, "policy");
|
|
958
|
-
emitCommitted(await appendAdmittedRow(prepared.admitRows, prepared.session, resultRow(text, true)), "toolResult", pendingAction.toolCallId);
|
|
959
|
-
return;
|
|
960
|
-
}
|
|
918
|
+
if (crossBoundaryRefusal !== undefined)
|
|
919
|
+
return refuseCall(crossBoundaryRefusal.message, { layer: "policy" });
|
|
961
920
|
if ((prepared.crossBoundary?.storeWaits() ?? 0) === waited)
|
|
962
921
|
break;
|
|
963
922
|
}
|
|
@@ -5,6 +5,7 @@ import { DeliveryObligations, type NotificationInjectionOutcome, type PendingSes
|
|
|
5
5
|
import type { RunnerDeps, TaskEvent, TaskSpec } from "../types.js";
|
|
6
6
|
import type { SessionReadFileStates } from "./session-read-file-states.js";
|
|
7
7
|
import type { SessionModeSeats } from "./session-mode-seats.js";
|
|
8
|
+
import type { SessionMcpPools } from "../mcp-connection-pool.js";
|
|
8
9
|
import type { NotificationLaneBindings, Prepared, PrepareTaskFn, ResumeRun, RunInternals, RunnerDepsSeat, RunnerSelfSeat, TaskIdRef } from "./contracts.js";
|
|
9
10
|
export interface RunNotificationLaneInput<R> {
|
|
10
11
|
/** borrowed-readonly — the task spec: prepare's input, and the isolation scope the peer scope is minted from. */
|
|
@@ -36,6 +37,8 @@ export interface RunNotificationLaneInput<R> {
|
|
|
36
37
|
sessionReadStates: SessionReadFileStates;
|
|
37
38
|
/** borrowed-mutable — the Runner's per-session permission-mode seats, ALWAYS this Runner's (a caller-supplied one is overridden). */
|
|
38
39
|
sessionModeSeats: SessionModeSeats;
|
|
40
|
+
/** borrowed-mutable — the per-session MCP pools of this Runner's session store, ALWAYS (as the two above). */
|
|
41
|
+
sessionMcpPools: SessionMcpPools;
|
|
39
42
|
/** borrowed-mutable — the Runner's per-session parked-notification store: the torn-down lane and the escalation pend here. */
|
|
40
43
|
pendingSessionNotifications: PendingSessionNotifications;
|
|
41
44
|
/** borrowed-readonly — the orchestrator's entry (a lane may not name the orchestrator; the driver hands it in), as the ONE
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { recordedSyncChildBlock } from "../leg-identity.js";
|
|
2
1
|
import { createPeerInboundChainRef, createPeerSelfRef } from "../../agents/peer-admission.js";
|
|
3
2
|
import { boundInputHashOf } from "../canonical-json.js";
|
|
4
3
|
import { readPendingSteerQueue } from "../checkpoint-store.js";
|
|
@@ -15,14 +14,13 @@ export function runNotificationLane(input) {
|
|
|
15
14
|
return obligations.run(() => runNotificationLaneAs(input, obligations));
|
|
16
15
|
}
|
|
17
16
|
async function runNotificationLaneAs(input, obligations) {
|
|
18
|
-
const { spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef, runner, self, sessions, sessionReadStates, sessionModeSeats, pendingSessionNotifications, prepareTask, next } = input;
|
|
17
|
+
const { spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef, runner, self, sessions, sessionReadStates, sessionModeSeats, sessionMcpPools, pendingSessionNotifications, prepareTask, next } = input;
|
|
19
18
|
const prepareResume = resume
|
|
20
19
|
? {
|
|
21
20
|
leafId: resume.cp.leafId,
|
|
22
21
|
...(resume.cp.heldRows !== undefined ? { heldRows: [...resume.cp.heldRows] } : {}),
|
|
23
22
|
suspendedBatch: new Set(resume.cp.pendingAction.kind === "tool_approval" ? resume.cp.pendingAction.batchToolCallIds : []),
|
|
24
23
|
seed: resume.cp.state,
|
|
25
|
-
...((recorded) => (recorded !== undefined ? { syncChildBlockOfRow: recorded } : {}))(recordedSyncChildBlock(resume.cp)),
|
|
26
24
|
outcome: resume.outcome,
|
|
27
25
|
...((opening) => (opening !== undefined ? { opening } : {}))(resume.outcome.gate === "wake" ? wakeOpening(readPendingSteerQueue(resume.cp.state), resume.wakeMessage) : undefined),
|
|
28
26
|
...(resume.legMods !== undefined ? { legMods: resume.legMods } : {}),
|
|
@@ -151,7 +149,7 @@ async function runNotificationLaneAs(input, obligations) {
|
|
|
151
149
|
peerInboundChainRef,
|
|
152
150
|
detachHub,
|
|
153
151
|
sessionReadStates,
|
|
154
|
-
sessionModeSeats,
|
|
152
|
+
sessionModeSeats, sessionMcpPools,
|
|
155
153
|
onTaskNotification: laneSink,
|
|
156
154
|
}, self, taskIdRef, holdSessionLock, legWrites, (destination, delivery) => pendingSessionNotifications.discardsStaleNotice(destination, delivery), promptSubmitRef);
|
|
157
155
|
try {
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* The run body's REASONING seat (R5), verbatim from `Runner.runLocked`: the leg-entry resolution of
|
|
3
3
|
* the requested reasoning intensity against the model's real capability, the ONE publisher that writes both faces
|
|
4
4
|
* (the `reasoning.resolved` trace frame and the `TaskResult.effectiveReasoning` seat on the backstop carrier), and
|
|
5
|
-
* the
|
|
6
|
-
* reports are contained at their call sites, not here).
|
|
5
|
+
* the reader that lets the leg's first request with a terminal message correct the entry value (once).
|
|
7
6
|
*/
|
|
8
|
-
import
|
|
7
|
+
import type { ResolvedReasoning } from "../../brain/reasoning.js";
|
|
9
8
|
import type { Prepared, RunState, TaskIdRef } from "./contracts.js";
|
|
10
9
|
export interface RunReasoningSeatInput {
|
|
11
10
|
/** borrowed-readonly — the leg's prepared seat: the requested thinking level and the model. */
|
|
@@ -16,10 +15,10 @@ export interface RunReasoningSeatInput {
|
|
|
16
15
|
taskIdRef: TaskIdRef | undefined;
|
|
17
16
|
}
|
|
18
17
|
export interface RunReasoningSeatResult {
|
|
19
|
-
/**
|
|
20
|
-
|
|
18
|
+
/** Read one `message_end` message of the leg's harness — the git lane's subscription hands every one here. */
|
|
19
|
+
observeReasoningMessage: (message: unknown) => void;
|
|
21
20
|
/** The leg's resolution as a READ FACE over this lane's own `let` (the leg-entry mint, then at most one
|
|
22
|
-
* first-
|
|
21
|
+
* first-request correction): the settle lane's result assembly reads it for `effectiveReasoning`. */
|
|
23
22
|
reasoningResolution: {
|
|
24
23
|
readonly current: ResolvedReasoning | undefined;
|
|
25
24
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { resolveReasoning } from "../../brain/reasoning.js";
|
|
1
|
+
import { resolutionOf, resolveReasoning } from "../../brain/reasoning-request.js";
|
|
2
|
+
import { reasoningStampOf } from "../../brain/reasoning-stamp.js";
|
|
2
3
|
import { emitTrace } from "../trace.js";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
5
|
export function runReasoningSeat(input) {
|
|
4
6
|
const { prepared, rs, taskIdRef } = input;
|
|
5
|
-
let reasoningResolution = prepared.thinking
|
|
7
|
+
let reasoningResolution = prepared.thinking !== undefined ? resolveReasoning(prepared.thinking, prepared.model) : undefined;
|
|
6
8
|
const publishReasoningResolution = (r) => {
|
|
7
9
|
reasoningResolution = r;
|
|
8
10
|
if (taskIdRef)
|
|
@@ -24,25 +26,18 @@ export function runReasoningSeat(input) {
|
|
|
24
26
|
};
|
|
25
27
|
if (reasoningResolution !== undefined)
|
|
26
28
|
publishReasoningResolution(reasoningResolution);
|
|
27
|
-
let
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
29
|
+
let corrected = false;
|
|
30
|
+
const observeReasoningMessage = (message) => {
|
|
31
|
+
if (corrected || reasoningResolution === undefined)
|
|
30
32
|
return;
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
+
const stamp = reasoningStampOf(message);
|
|
34
|
+
if (stamp === undefined || stamp.model !== prepared.model)
|
|
33
35
|
return;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
current.effective === next.effective &&
|
|
38
|
-
current.graded === next.graded &&
|
|
39
|
-
current.clamped === next.clamped &&
|
|
40
|
-
current.format === next.format &&
|
|
41
|
-
current.endpoint === next.endpoint &&
|
|
42
|
-
current.dropped === next.dropped) {
|
|
36
|
+
corrected = true;
|
|
37
|
+
const next = resolutionOf(stamp.level, stamp.carried, prepared.model.api ?? "unknown");
|
|
38
|
+
if (isDeepStrictEqual(next, reasoningResolution))
|
|
43
39
|
return;
|
|
44
|
-
}
|
|
45
40
|
publishReasoningResolution(next);
|
|
46
41
|
};
|
|
47
|
-
return {
|
|
42
|
+
return { observeReasoningMessage, reasoningResolution: { get current() { return reasoningResolution; } } };
|
|
48
43
|
}
|
|
@@ -17,11 +17,11 @@ import { deliverEngineNotice, parentLegIds, settleOwedUserInput } from "../types
|
|
|
17
17
|
import { assembleResult } from "./assemble-result.js";
|
|
18
18
|
import { discloseUnconsumedEndings } from "./halt-attribution.js";
|
|
19
19
|
import { forwardSafely } from "./forward-sink.js";
|
|
20
|
-
import { TIMER_LATENESS_REPORT_MS } from "./clock-and-limits.js";
|
|
20
|
+
import { completedPastLimitNotice, limitCrossedOf, TIMER_LATENESS_REPORT_MS } from "./clock-and-limits.js";
|
|
21
21
|
import { resumeDecisionWasNegative } from "./decide-continuation.js";
|
|
22
22
|
import { drainForwardedFramesBeforeDone, forwardsSubagentEvents } from "./prepare-run-refs.js";
|
|
23
23
|
import { generatePromptSuggestions } from "./prompt-suggestions.js";
|
|
24
|
-
import {
|
|
24
|
+
import { raceTeardownLegOr, settleTeardownLeg, teardownLegBudget } from "./teardown-bounded.js";
|
|
25
25
|
import { owedDateAnchor } from "./conversation-segment.js";
|
|
26
26
|
import { autoRunConsolidationFromRecommendation, autoRunOnRecommendationEffective, scopeHasUnconsumedRecommendation } from "./memory-consolidation-driver.js";
|
|
27
27
|
import { amendTerminal, terminalProjection } from "./terminal-projection.js";
|
|
@@ -107,6 +107,7 @@ export async function runSettleAndTeardown(input) {
|
|
|
107
107
|
intake: taskIdRef?.intake,
|
|
108
108
|
...(displayed !== undefined ? { displayed } : {}),
|
|
109
109
|
strandedHumanAnswers,
|
|
110
|
+
refusedAsks: prepared.refusedAsks,
|
|
110
111
|
remoteEnvFailures: prepared.remoteEnvFailures,
|
|
111
112
|
effectiveReadFace: prepared.effectiveReadFace,
|
|
112
113
|
effectiveWriteFace: prepared.effectiveWriteFace,
|
|
@@ -120,6 +121,7 @@ export async function runSettleAndTeardown(input) {
|
|
|
120
121
|
abortedForTurns: rs.limits.turnsExceeded,
|
|
121
122
|
abortedLive,
|
|
122
123
|
answerSettled,
|
|
124
|
+
limitCrossed: limitCrossedOf({ limits: rs.limits, budget: rs.budget, stats, walltimeLimitMs: spec.limits?.maxWalltimeMs, walltimeTimerFired: timeout.fired, elapsedMs: Math.ceil(performance.now() - rs.telemetry.taskStartMonotonic) }),
|
|
123
125
|
budgetHit: rs.limits.budgetHit,
|
|
124
126
|
budgetAxis: rs.limits.budgetAxis,
|
|
125
127
|
blockedReason: prepared.blockedRef.reason,
|
|
@@ -144,6 +146,8 @@ export async function runSettleAndTeardown(input) {
|
|
|
144
146
|
},
|
|
145
147
|
});
|
|
146
148
|
}
|
|
149
|
+
if (result.limitCrossed !== undefined)
|
|
150
|
+
deliverEngineNotice(runner.deps.onNotice, completedPastLimitNotice(result.limitCrossed, { sessionId: prepared.sessionId, runId: rs.telemetry.runId, ...legNoticeTaskId(prepared) }));
|
|
147
151
|
discloseUnconsumedEndings({ accepted: loopLatch.userHalted, consumption: prepared.harness.haltConsumption(), onNotice: runner.deps.onNotice, sessionId: prepared.sessionId, runId: rs.telemetry.runId, taskId: prepared.taskId });
|
|
148
152
|
let rowReturned = false;
|
|
149
153
|
if (resume !== undefined &&
|
|
@@ -154,7 +158,7 @@ export async function runSettleAndTeardown(input) {
|
|
|
154
158
|
const reopenReason = reopenReasonOf(resumeStartupCauseOf(result.terminal.kind === "failed" ? result.terminal.code : undefined));
|
|
155
159
|
const row = await compensateUnstarted(resume.reopenUnstarted, reopenReason, resume.claimedRowPending);
|
|
156
160
|
rowReturned = row.kind === "reopened";
|
|
157
|
-
amendTerminal(result, rowReturned ? "resume.reopened_unstarted" : "resume.reopen_failed_unstarted", row.kind, (m) => `${m ?? "the resume leg did not complete"} — ${unstartedRowSentence(row)}`);
|
|
161
|
+
amendTerminal(result, rowReturned ? "resume.reopened_unstarted" : "resume.reopen_failed_unstarted", row.kind, (m) => `${m ?? "the resume leg did not complete"} — ${unstartedRowSentence(row, resume.cp)}`);
|
|
158
162
|
}
|
|
159
163
|
settleOwedUserInput(owedUserInput, rowReturned, { taskId: prepared.taskId, sessionId: prepared.sessionId, runId: prepared.runId, parent: parentLegIds(internals) }, runner.deps.onNotice);
|
|
160
164
|
prepared.sealReadStateSeat?.(ownCommittedTailRef.current);
|
|
@@ -231,7 +235,11 @@ export async function runSettleAndTeardown(input) {
|
|
|
231
235
|
const mes = prepared.memoryEngineSession;
|
|
232
236
|
await settleTeardownLeg(() => mes.harvest(), "memoryEngineSession.harvest (settle leg)", (e) => runner.deps.onError?.(e, { phase: "config", sessionId: prepared.sessionId }));
|
|
233
237
|
const scope = mes.handle.writeScope;
|
|
234
|
-
|
|
238
|
+
const gateOwed = scope !== null && autoRunOnRecommendationEffective(runner.deps) && (await raceTeardownLegOr(() => scopeHasUnconsumedRecommendation(mes.engine, scope), "memory consolidation gate read (settle leg)", (timeout) => {
|
|
239
|
+
runner.deps.onError?.(timeout, { phase: "config", sessionId: prepared.sessionId });
|
|
240
|
+
return false;
|
|
241
|
+
}));
|
|
242
|
+
if (scope !== null && gateOwed) {
|
|
235
243
|
const compliance = { postureOf: runner.deps.compliancePostureResolver, scopeContract: mes.scopeContract, denies: spec.complianceAdditionalDenies };
|
|
236
244
|
void autoRunConsolidationFromRecommendation({ deps: runner.deps, engine: mes.engine, scope, sessionId: prepared.sessionId, writeJudge: prepared.consolidationWriteJudge, compliance, onNotice: runner.deps.onNotice, onError: runner.deps.onError });
|
|
237
245
|
}
|
|
@@ -351,11 +359,7 @@ async function yieldParkedLegBackground(prepared, runner) {
|
|
|
351
359
|
`${report.notYieldable.map((u) => `${u.id} (${u.reason})`).join(", ")} — they were not parked and do not continue with it.`);
|
|
352
360
|
}
|
|
353
361
|
const budgetMs = teardownLegBudget();
|
|
354
|
-
const drained = await
|
|
355
|
-
if (e instanceof TeardownLegTimeoutError)
|
|
356
|
-
return undefined;
|
|
357
|
-
throw e;
|
|
358
|
-
});
|
|
362
|
+
const drained = await raceTeardownLegOr(() => report.drained(), "parked leg's background agents", () => undefined);
|
|
359
363
|
if (drained !== undefined) {
|
|
360
364
|
if (drained.unpersisted.length > 0)
|
|
361
365
|
disclose(`the rows of ${drained.unpersisted.length} background agent(s) this parked leg yielded were not written (${drained.unpersisted.join(", ")}): the store refused the write; it is retried, and until it lands those rows read their previous state.`);
|
|
@@ -15,6 +15,7 @@ import { emitSettled, reconciledEnd } from "./tool-end-body.js";
|
|
|
15
15
|
import { isApprovalWordsFrame } from "./approval-feedback.js";
|
|
16
16
|
import { asThrownError } from "../thrown-value.js";
|
|
17
17
|
import { modelLaneBrainOf } from "./model-lane-seat.js";
|
|
18
|
+
import { raceTeardownLeg } from "./teardown-bounded.js";
|
|
18
19
|
export async function runTerminalAdoption(input) {
|
|
19
20
|
const { spec, queue, prepared, rs, stats, ident, emitCommitted, startedToolCallIds, toolLabels, timeout, compactionBrain, compactionBreaker, windowSafetyOptions, undrainedUserAtEnd, userInputLostAtEnd, final, abortedLive, userInterruptedLive, callerStop, runner, sessions, next } = input;
|
|
20
21
|
let { threw } = input;
|
|
@@ -47,7 +48,7 @@ export async function runTerminalAdoption(input) {
|
|
|
47
48
|
const report = await reconcileInterruptedSession(prepared.session, prepared.toolEffects, undefined, startedToolCallIds, prepared.admitRows);
|
|
48
49
|
orphansClosed = report.recovered.length;
|
|
49
50
|
for (const orphan of report.recovered) {
|
|
50
|
-
emitSettled(prepared.toolOccurrences, { toolCallId: orphan.toolCallId, spelledName: orphan.toolName, ...(toolLabels.has(orphan.toolName) ? { label: toolLabels.get(orphan.toolName) } : {}), args: orphan.args }, reconciledEnd(orphan), { push: (f) => queue.push({ ...f, ...ident() }), structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars });
|
|
51
|
+
emitSettled(prepared.toolOccurrences, { toolCallId: orphan.toolCallId, spelledName: orphan.toolName, ...(toolLabels.has(orphan.toolName) ? { label: toolLabels.get(orphan.toolName) } : {}), args: orphan.args }, reconciledEnd(orphan), { push: (f) => queue.push({ ...f, ...ident() }), structured: prepared.structuredProjector, mediaBudgetBase64Chars: runner.deps.mediaBudgetBase64Chars, reviewRequest: prepared.reviewRequestRef });
|
|
51
52
|
emitCommitted(orphan.entryId, "toolResult", orphan.toolCallId);
|
|
52
53
|
}
|
|
53
54
|
reconcileComplete = true;
|
|
@@ -107,7 +108,7 @@ export async function runTerminalAdoption(input) {
|
|
|
107
108
|
];
|
|
108
109
|
for (const { input, live, approval } of owed) {
|
|
109
110
|
try {
|
|
110
|
-
if (!(await store.setPendingSteer(parkToken, parkScope, input)))
|
|
111
|
+
if (!(await raceTeardownLeg(() => store.setPendingSteer(parkToken, parkScope, input), "checkpointStore.setPendingSteer (parked-input migration leg)")))
|
|
111
112
|
break;
|
|
112
113
|
if (live !== undefined)
|
|
113
114
|
carried.push(live);
|
|
@@ -219,12 +220,7 @@ async function finish(spec, prepared, opts, runner, sessions) {
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
-
await sessions.touch(prepared.sessionId);
|
|
224
|
-
}
|
|
225
|
-
catch (err) {
|
|
226
|
-
runner.deps.onError?.(err, { phase: "config", sessionId: prepared.sessionId });
|
|
227
|
-
}
|
|
223
|
+
await raceTeardownLeg(() => sessions.touch(prepared.sessionId), "sessions.touch (settle leg)").catch((err) => runner.deps.onError?.(err, { phase: "config", sessionId: prepared.sessionId }));
|
|
228
224
|
try {
|
|
229
225
|
await prepared.mcp.dispose();
|
|
230
226
|
}
|
|
@@ -146,6 +146,8 @@ export function createTurnBoundary(input) {
|
|
|
146
146
|
return undefined;
|
|
147
147
|
}
|
|
148
148
|
const axisCrossed = taskAxisCrossed(rs.limits, walltimeMonotonicDeadline);
|
|
149
|
+
if (rs.limits.walltimeCrossedMs === undefined && walltimeMonotonicDeadline !== undefined && performance.now() >= walltimeMonotonicDeadline)
|
|
150
|
+
rs.limits.walltimeCrossedMs = Math.ceil(performance.now() - rs.telemetry.taskStartMonotonic);
|
|
149
151
|
const taskAxisHit = axisCrossed && legOwesTurn();
|
|
150
152
|
if (axisCrossed)
|
|
151
153
|
legContinues = false;
|
|
@@ -223,14 +225,15 @@ export function createTurnBoundary(input) {
|
|
|
223
225
|
};
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
const pendingReview = prepared.reviewRequestRef.pending;
|
|
229
|
+
if (pendingReview !== undefined) {
|
|
228
230
|
prepared.reviewRequestRef.pending = undefined;
|
|
231
|
+
prepared.reviewRequestRef.later = undefined;
|
|
229
232
|
const honorable = prepared.suspendForReview !== undefined &&
|
|
230
233
|
!prepared.abortController.signal.aborted &&
|
|
231
234
|
prepared.pausedRef.current === undefined;
|
|
232
235
|
if (honorable && prepared.suspendForReview) {
|
|
233
|
-
await prepared.suspendForReview(
|
|
236
|
+
await prepared.suspendForReview(pendingReview);
|
|
234
237
|
legContinues &&= !prepared.abortController.signal.aborted && prepared.pausedRef.current === undefined;
|
|
235
238
|
return undefined;
|
|
236
239
|
}
|
|
@@ -4,6 +4,7 @@ import { type TaskOutcome } from "../task-outcome.js";
|
|
|
4
4
|
import { type SwappableDeps } from "../swappable-deps.js";
|
|
5
5
|
import { type SideQuerySpec, type SideQueryResult } from "../side-query.js";
|
|
6
6
|
import type { SessionStore } from "../session.js";
|
|
7
|
+
import { type ForgetMcpFailureRequest, type ForgetMcpFailureResult } from "../mcp-connection-pool.js";
|
|
7
8
|
import { type SessionAddress, type SessionCompletionLane, type TaskNotificationSink } from "../task-notification.js";
|
|
8
9
|
import type { AgentDefinition, EngineNotice, ModelRef, ModelRoles, RunnerDeps, TaskEvent, TaskResult, TaskSpec, TaskStream } from "../types.js";
|
|
9
10
|
import { type ContextSettings, type ContextWindowOverlay } from "../context-settings.js";
|
|
@@ -32,6 +33,8 @@ export declare class Runner implements RunnerSelfSeat {
|
|
|
32
33
|
* evicted) falls back to the transcript-replay rung. See {@link SessionReadFileStates}. */
|
|
33
34
|
private readonly sessionReadStates;
|
|
34
35
|
private readonly sessionModeSeats;
|
|
36
|
+
/** The MCP pools of the sessions of {@link sessions} — the STORE's (shared by every Runner over it): one pool per session, remembering a failed connection attempt ({@link sessionMcpPoolsOf}). */
|
|
37
|
+
private readonly sessionMcpPools;
|
|
35
38
|
/** task notifications born BETWEEN turns (run torn down / harness already idle), parked
|
|
36
39
|
* per session and drained into the session's next run at its first boundary. Runner-lived (outlives any
|
|
37
40
|
* single run, like the registry handles that produce into it); bounded + drop-disclosing, see
|
|
@@ -153,6 +156,8 @@ export declare class Runner implements RunnerSelfSeat {
|
|
|
153
156
|
rewindFiles(request: RewindFilesRequest): Promise<RewindFilesResult>;
|
|
154
157
|
/** The out-of-run manual compaction, no run and no user turn — the contract is {@link compactIdleSession}'s (the one pass every lane runs; refused while a leg of this Runner holds or awaits the session's lock, or a write issued to it has not settled, and while the session is parked at a pending checkpoint). */
|
|
155
158
|
compactSession(request: CompactSessionRequest): Promise<CompactSessionResult>;
|
|
159
|
+
/** The out-of-run recovery of an MCP server: the session forgets its failed connection attempt at `server`, so its next message dials it (nothing is dialed now; no lock, no session entry — {@link forgetSessionMcpFailure}). In a live run, `TaskStream.reconnectMcpServer` dials now. */
|
|
160
|
+
forgetMcpFailure(request: ForgetMcpFailureRequest): ForgetMcpFailureResult;
|
|
156
161
|
/** Run a task and stream live events; await `.result()` for the final TaskResult. `resume` (internal)
|
|
157
162
|
* drives a durable resume through the same loop instead of a fresh objective prompt.
|
|
158
163
|
* `internals` (internal) is a TRUSTED run-scoped channel for live per-task state the
|
|
@@ -218,10 +223,10 @@ export declare class Runner implements RunnerSelfSeat {
|
|
|
218
223
|
* `already_resolved` (lost the CAS — idempotent no-op), `walltime_axis_retired` (pre-CAS: the
|
|
219
224
|
* persisted ledger carries the retired wall-clock budget axis — a worker of the previous release can
|
|
220
225
|
* still finish it), `resume_aborted` (the caller's signal was already aborted at entry, or aborted
|
|
221
|
-
* during the resume —
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
226
|
+
* during the resume — before the claim the checkpoint stays pending; after it, `detail.unstartedRow: "reopened"` says the claim was
|
|
227
|
+
* reversed (pending again), and without it the code does not say which state the row is in — read it), `reopen_failed` (an aborted
|
|
228
|
+
* resume could not prove its claim reversed — `detail.unstartedRow` is `"declined"` (the store refused: read the row) or `"unknown"`
|
|
229
|
+
* (the reopen failed in flight: state unprovable)), `config_refused` (pre-CAS: the re-supplied
|
|
225
230
|
* config or a mode the row recorded is one prepare would refuse — `detail.code` is prepare's own code,
|
|
226
231
|
* `detail.field` says whether the config or the row carries it; the checkpoint stays pending and
|
|
227
232
|
* unchanged). Each code's full contract is on {@link CheckpointError.code}.
|