@sema-agent/core 7.68.7 → 7.69.1
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 +2139 -0
- package/dist/agents/agent-definition.d.ts +32 -3
- package/dist/agents/agent-definition.js +39 -1
- package/dist/agents/agent-transcript-tool.js +16 -5
- package/dist/agents/cascade.js +9 -6
- package/dist/agents/cc-uds-peer-channel.js +2 -1
- package/dist/agents/cumulative-stats.d.ts +3 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/delegation-review-faces.d.ts +35 -0
- package/dist/agents/delegation-review-faces.js +26 -0
- package/dist/agents/inherited-tool-pool.d.ts +4 -2
- package/dist/agents/list-agents-tool.d.ts +8 -19
- package/dist/agents/list-agents-tool.js +19 -34
- package/dist/agents/peer-directory.js +3 -2
- package/dist/agents/peer-session-drain.js +3 -3
- package/dist/agents/repair-loop.js +17 -21
- package/dist/agents/retain-ledger.d.ts +122 -58
- package/dist/agents/retain-ledger.js +48 -21
- package/dist/agents/root-session-lane.d.ts +17 -0
- package/dist/agents/root-session-lane.js +9 -0
- package/dist/agents/send-message-tool.js +44 -31
- package/dist/agents/subagent-steps.d.ts +0 -11
- package/dist/agents/subagent-steps.js +1 -14
- package/dist/agents/subagent-transcript-placement.d.ts +4 -3
- package/dist/agents/subagent.d.ts +19 -8
- package/dist/agents/subagent.js +252 -208
- package/dist/agents/tool-filter.d.ts +31 -1
- package/dist/agents/tool-filter.js +28 -4
- package/dist/agents/verifier-independence.js +3 -2
- package/dist/agents/verify.d.ts +6 -2
- package/dist/agents/verify.js +17 -7
- package/dist/agents/yield-adoption.d.ts +17 -0
- package/dist/agents/yield-adoption.js +22 -2
- package/dist/brain/anthropic.js +42 -14
- package/dist/brain/claude-model-id.d.ts +36 -0
- package/dist/brain/claude-model-id.js +44 -0
- package/dist/brain/failover.js +14 -3
- package/dist/brain/fast-mode.d.ts +272 -0
- package/dist/brain/fast-mode.js +130 -0
- package/dist/brain/media-degrade.d.ts +5 -0
- package/dist/brain/media-degrade.js +1 -0
- package/dist/brain/model-capability.d.ts +122 -18
- package/dist/brain/model-capability.js +84 -7
- package/dist/brain/model-lane.d.ts +40 -16
- package/dist/brain/model-lane.js +97 -39
- package/dist/brain/model-presets.d.ts +4 -1
- package/dist/brain/model-presets.js +10 -1
- package/dist/brain/open-responses.js +37 -14
- package/dist/brain/openai.js +27 -15
- package/dist/brain/provider-dialect.d.ts +9 -0
- package/dist/brain/provider-dialect.js +4 -0
- package/dist/brain/provider-message.d.ts +2 -2
- package/dist/brain/provider-message.js +8 -8
- package/dist/brain/reasoning-request.d.ts +26 -0
- package/dist/brain/reasoning-request.js +14 -4
- package/dist/brain/reasoning-stamp.d.ts +3 -2
- package/dist/brain/reasoning.d.ts +8 -4
- package/dist/brain/reasoning.js +4 -3
- package/dist/brain/reference-model-traits.d.ts +59 -0
- package/dist/brain/reference-model-traits.js +46 -0
- package/dist/brain/request-params.js +1 -0
- package/dist/brain/route-adjudicator.d.ts +107 -106
- package/dist/brain/route-adjudicator.js +217 -51
- package/dist/brain/route-conformance.d.ts +6 -4
- package/dist/brain/routing.d.ts +2 -1
- package/dist/brain/routing.js +21 -5
- package/dist/brain/status-sink.d.ts +52 -10
- package/dist/brain/stream-engine.d.ts +68 -11
- package/dist/brain/stream-engine.js +512 -93
- package/dist/brain/stream-shared.d.ts +34 -8
- package/dist/brain/stream-shared.js +20 -7
- package/dist/brain/usage-reading.d.ts +15 -0
- package/dist/brain/usage-reading.js +18 -5
- package/dist/core/a2a.js +28 -21
- package/dist/core/advisor-verdict.d.ts +5 -4
- package/dist/core/advisor-verdict.js +2 -2
- package/dist/core/agent-config-dir.d.ts +39 -3
- package/dist/core/agent-config-dir.js +67 -11
- package/dist/core/agent-definition.d.ts +4 -1
- package/dist/core/agent-state.d.ts +25 -2
- package/dist/core/agent-state.js +50 -3
- package/dist/core/allow-entry.d.ts +11 -11
- package/dist/core/allow-entry.js +39 -32
- package/dist/core/ask-headline.d.ts +28 -16
- package/dist/core/ask-headline.js +18 -8
- package/dist/core/ask-origin.d.ts +108 -33
- package/dist/core/ask-origin.js +40 -11
- package/dist/core/ask-question.d.ts +9 -1
- package/dist/core/ask-question.js +3 -0
- package/dist/core/ask-unresolvable-notice.d.ts +10 -2
- package/dist/core/ask-unresolvable-notice.js +5 -2
- package/dist/core/attachment-source.d.ts +1 -1
- package/dist/core/attachment-source.js +2 -0
- package/dist/core/auto-compaction.d.ts +48 -66
- package/dist/core/auto-compaction.js +48 -106
- package/dist/core/auto-mode-directive.d.ts +30 -60
- package/dist/core/auto-mode-directive.js +36 -38
- package/dist/core/auto-mode.d.ts +40 -9
- package/dist/core/auto-mode.js +20 -5
- package/dist/core/background-agent-store.d.ts +87 -1
- package/dist/core/background-agent-store.js +72 -1
- package/dist/core/background-shell.d.ts +3 -0
- package/dist/core/background-shell.js +1 -0
- package/dist/core/cache-break-detector.d.ts +23 -11
- package/dist/core/cache-break-detector.js +12 -6
- package/dist/core/caller-text.d.ts +27 -8
- package/dist/core/caller-text.js +47 -1
- package/dist/core/checkpoint-features.d.ts +18 -10
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-identity.d.ts +53 -0
- package/dist/core/checkpoint-identity.js +29 -0
- package/dist/core/checkpoint-queries.d.ts +4 -3
- package/dist/core/checkpoint-queries.js +5 -3
- package/dist/core/checkpoint-rekey.d.ts +70 -0
- package/dist/core/checkpoint-rekey.js +107 -0
- package/dist/core/checkpoint-requirements.d.ts +83 -10
- package/dist/core/checkpoint-requirements.js +53 -13
- package/dist/core/checkpoint-row-verdict.d.ts +5 -3
- package/dist/core/checkpoint-row-verdict.js +40 -4
- package/dist/core/checkpoint-store.d.ts +84 -7
- package/dist/core/checkpoint-store.js +38 -7
- package/dist/core/child-clamp-seats.d.ts +30 -3
- package/dist/core/child-clamp-seats.js +26 -1
- package/dist/core/classifier-category.d.ts +25 -0
- package/dist/core/classifier-category.js +93 -0
- package/dist/core/classifier-unavailable-arm.d.ts +62 -8
- package/dist/core/classifier-unavailable-arm.js +19 -2
- package/dist/core/command-sandbox-dispatch.d.ts +14 -2
- package/dist/core/command-sandbox.d.ts +209 -28
- package/dist/core/command-sandbox.js +195 -20
- package/dist/core/compaction-retired-members.d.ts +12 -0
- package/dist/core/compaction-retired-members.js +22 -0
- package/dist/core/config-refusal-codes.d.ts +41 -1
- package/dist/core/config-refusal-codes.js +18 -0
- package/dist/core/context-edit.d.ts +34 -18
- package/dist/core/context-edit.js +30 -1
- package/dist/core/context-settings.js +5 -4
- package/dist/core/cron.d.ts +68 -0
- package/dist/core/cron.js +259 -0
- package/dist/core/cross-boundary-taint.d.ts +15 -1
- package/dist/core/cross-boundary-taint.js +6 -0
- package/dist/core/delegation-frames.d.ts +36 -6
- package/dist/core/delegation-frames.js +3 -0
- package/dist/core/delegation-name.d.ts +10 -4
- package/dist/core/delegation-name.js +53 -23
- package/dist/core/engine-attestation.d.ts +26 -2
- package/dist/core/engine-attestation.js +4 -0
- package/dist/core/engine-capabilities.d.ts +53 -3
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +213 -95
- package/dist/core/engine-notice.js +29 -1
- package/dist/core/engine-version.d.ts +1 -0
- package/dist/core/engine-version.js +1 -0
- package/dist/core/extension-call-id.d.ts +4 -0
- package/dist/core/extension-call-id.js +8 -0
- package/dist/core/fast-tier-door.d.ts +36 -0
- package/dist/core/fast-tier-door.js +65 -0
- package/dist/core/file-history-store.d.ts +343 -67
- package/dist/core/file-history-store.js +320 -93
- package/dist/core/frame-settlement.d.ts +4 -0
- package/dist/core/frame-settlement.js +5 -0
- package/dist/core/gate-fold.js +13 -4
- package/dist/core/gate-lanes.js +27 -20
- package/dist/core/gate-outcome.d.ts +116 -13
- package/dist/core/gate-outcome.js +100 -4
- package/dist/core/git-read-only.d.ts +10 -0
- package/dist/core/git-read-only.js +1 -0
- package/dist/core/git-worktree-env.d.ts +29 -10
- package/dist/core/git-worktree-env.js +38 -18
- package/dist/core/governance-codes.d.ts +240 -8
- package/dist/core/governance-codes.js +204 -6
- package/dist/core/hooks.d.ts +27 -16
- package/dist/core/hooks.js +84 -82
- package/dist/core/host-floor.d.ts +2 -8
- package/dist/core/host-floor.js +6 -42
- package/dist/core/identity-rekey.d.ts +275 -0
- package/dist/core/identity-rekey.js +198 -0
- package/dist/core/image-admission.d.ts +7 -4
- package/dist/core/image-admission.js +24 -11
- package/dist/core/isolation-scope.d.ts +12 -0
- package/dist/core/isolation-scope.js +4 -0
- package/dist/core/leg-identity.d.ts +32 -2
- package/dist/core/leg-identity.js +16 -2
- package/dist/core/locked-config.d.ts +26 -6
- package/dist/core/locked-config.js +38 -17
- package/dist/core/loopback-host.d.ts +18 -0
- package/dist/core/loopback-host.js +40 -0
- package/dist/core/lsp.d.ts +3 -0
- package/dist/core/lsp.js +3 -2
- package/dist/core/mcp-connection-pool.d.ts +57 -33
- package/dist/core/mcp-connection-pool.js +47 -23
- package/dist/core/mcp-failure.d.ts +41 -19
- package/dist/core/mcp-failure.js +14 -8
- package/dist/core/mcp-host-read.js +5 -4
- package/dist/core/mcp-host-seat.js +3 -2
- package/dist/core/mcp-name-judge.js +2 -1
- package/dist/core/mcp-server-link.js +2 -1
- package/dist/core/mcp-server-spec.js +2 -2
- package/dist/core/mcp-server-unavailable-notice.d.ts +26 -16
- package/dist/core/mcp-server-unavailable-notice.js +25 -4
- package/dist/core/mcp.d.ts +15 -9
- package/dist/core/mcp.js +46 -34
- package/dist/core/memory-engine/consolidation-driver.js +8 -8
- package/dist/core/memory-engine/consolidation-write-gate.js +3 -2
- package/dist/core/memory-engine/engine.d.ts +48 -12
- package/dist/core/memory-engine/engine.js +117 -55
- package/dist/core/memory-engine/file-backend.d.ts +2 -1
- package/dist/core/memory-engine/index-copies.d.ts +47 -0
- package/dist/core/memory-engine/index-copies.js +88 -0
- package/dist/core/memory-engine/layout.d.ts +26 -8
- package/dist/core/memory-engine/layout.js +40 -4
- package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
- package/dist/core/memory-engine/origin-clearance.js +2 -4
- package/dist/core/memory-engine/types.d.ts +16 -3
- package/dist/core/memory.d.ts +5 -0
- package/dist/core/memory.js +3 -0
- package/dist/core/mode-policy.d.ts +7 -1
- package/dist/core/mode-policy.js +9 -0
- package/dist/core/model-fallbacks.d.ts +13 -7
- package/dist/core/model-fallbacks.js +5 -3
- package/dist/core/model-receipt.d.ts +15 -0
- package/dist/core/model-receipt.js +54 -1
- package/dist/core/model-seat.d.ts +17 -15
- package/dist/core/mods/agent-stations.js +5 -4
- package/dist/core/mods/extension-call.d.ts +0 -4
- package/dist/core/mods/extension-call.js +0 -8
- package/dist/core/mods/host.d.ts +18 -0
- package/dist/core/mods/host.js +7 -0
- package/dist/core/mods/kernel/events.d.ts +12 -0
- package/dist/core/mods/kernel/events.js +18 -9
- package/dist/core/mods/kernel/registration.d.ts +13 -0
- package/dist/core/mods/kernel/registration.js +34 -1
- package/dist/core/mods/message-display.js +1 -1
- package/dist/core/mods/package.js +3 -3
- package/dist/core/mods/prompt-submit.js +2 -2
- package/dist/core/mods/session-append.js +3 -3
- package/dist/core/mods/session-compact.js +7 -7
- package/dist/core/mods/session-receive.js +3 -3
- package/dist/core/mods/session-send.js +3 -3
- package/dist/core/mods/stations.d.ts +10 -5
- package/dist/core/mods/stations.js +15 -13
- package/dist/core/mods/tool-call.js +12 -12
- package/dist/core/mounted-mcp.d.ts +10 -1
- package/dist/core/mounted-mcp.js +4 -0
- package/dist/core/output-style.d.ts +14 -8
- package/dist/core/output-style.js +6 -6
- package/dist/core/own-property-receipt.js +3 -5
- package/dist/core/owner-identity.d.ts +68 -0
- package/dist/core/owner-identity.js +39 -0
- package/dist/core/parent-spec-seat.d.ts +5 -1
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-resumability.js +2 -2
- package/dist/core/park-selfcheck.js +15 -4
- package/dist/core/path-guard-rows.d.ts +8 -3
- package/dist/core/path-guard-rows.js +18 -5
- package/dist/core/peer-seat.d.ts +40 -11
- package/dist/core/peer-seat.js +38 -9
- package/dist/core/permission-rule-model.d.ts +5 -0
- package/dist/core/permission-rule-model.js +27 -6
- package/dist/core/permission-rules.d.ts +42 -5
- package/dist/core/permission-rules.js +74 -10
- package/dist/core/persisted-rule-arms.d.ts +8 -6
- package/dist/core/persisted-rule-arms.js +13 -20
- package/dist/core/physical-path.d.ts +12 -8
- package/dist/core/physical-path.js +24 -14
- package/dist/core/present-plan-tool.js +2 -1
- package/dist/core/pricing.d.ts +65 -8
- package/dist/core/pricing.js +51 -0
- package/dist/core/process-identity.d.ts +11 -3
- package/dist/core/process-identity.js +26 -16
- package/dist/core/prompt-section-seat.js +6 -5
- package/dist/core/protocol-http-auth.d.ts +87 -10
- package/dist/core/protocol-http-auth.js +155 -23
- package/dist/core/reminder-mint.d.ts +4 -0
- package/dist/core/reminder-mint.js +1 -0
- package/dist/core/remote-env.d.ts +46 -1
- package/dist/core/remote-env.js +2 -0
- package/dist/core/resume-at-refusal.d.ts +47 -0
- package/dist/core/resume-at-refusal.js +9 -0
- package/dist/core/resume-startup-cause.d.ts +8 -3
- package/dist/core/resume-startup-cause.js +3 -1
- package/dist/core/retired-keys.d.ts +4 -0
- package/dist/core/retired-keys.js +4 -0
- package/dist/core/roles.d.ts +11 -5
- package/dist/core/roles.js +14 -3
- package/dist/core/rule-store-fault.d.ts +8 -1
- package/dist/core/rule-store-fault.js +5 -0
- package/dist/core/runner/advisor-instructions.d.ts +12 -12
- package/dist/core/runner/advisor-instructions.js +7 -24
- package/dist/core/runner/announce-once-ledger.d.ts +23 -8
- package/dist/core/runner/announce-once-ledger.js +69 -18
- package/dist/core/runner/assemble-result.d.ts +14 -0
- package/dist/core/runner/assemble-result.js +3 -2
- package/dist/core/runner/auto-strip-notice.js +1 -1
- package/dist/core/runner/branch-window.js +5 -3
- package/dist/core/runner/call-hook-stations.d.ts +3 -0
- package/dist/core/runner/call-hook-stations.js +4 -3
- package/dist/core/runner/caller-roster.js +2 -1
- package/dist/core/runner/capability-withheld-seat.js +47 -5
- package/dist/core/runner/classifier-ladder.d.ts +48 -8
- package/dist/core/runner/classifier-ladder.js +88 -38
- package/dist/core/runner/cleared-results-record.d.ts +33 -0
- package/dist/core/runner/cleared-results-record.js +56 -0
- package/dist/core/runner/clock-and-limits.d.ts +13 -2
- package/dist/core/runner/clock-and-limits.js +11 -8
- package/dist/core/runner/command-sandbox-frame.d.ts +56 -0
- package/dist/core/runner/command-sandbox-frame.js +107 -0
- package/dist/core/runner/compact-session.d.ts +3 -1
- package/dist/core/runner/compact-session.js +29 -18
- package/dist/core/runner/compaction-call-options.d.ts +2 -2
- package/dist/core/runner/compaction-knobs.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +4 -4
- package/dist/core/runner/compaction-restate.js +3 -1
- package/dist/core/runner/construction-doors.js +9 -0
- package/dist/core/runner/continuation-gate.d.ts +39 -0
- package/dist/core/runner/continuation-gate.js +43 -0
- package/dist/core/runner/continues-from.d.ts +57 -0
- package/dist/core/runner/continues-from.js +76 -0
- package/dist/core/runner/contracts.d.ts +216 -86
- package/dist/core/runner/conversation-segment.d.ts +19 -12
- package/dist/core/runner/conversation-segment.js +27 -7
- package/dist/core/runner/credential-refusal-seat.js +31 -12
- package/dist/core/runner/cross-boundary-lane.d.ts +2 -2
- package/dist/core/runner/cross-boundary-lane.js +26 -13
- package/dist/core/runner/delegation-owner.d.ts +99 -9
- package/dist/core/runner/delegation-owner.js +107 -4
- package/dist/core/runner/denial-limit-arms.js +13 -12
- package/dist/core/runner/derived-route-fallback.d.ts +12 -26
- package/dist/core/runner/derived-route-fallback.js +4 -10
- package/dist/core/runner/earlier-grammar-notice.d.ts +6 -0
- package/dist/core/runner/earlier-grammar-notice.js +9 -0
- package/dist/core/runner/env-capability-census.js +2 -1
- package/dist/core/runner/execution-record.d.ts +4 -2
- package/dist/core/runner/execution-record.js +1 -1
- package/dist/core/runner/fast-mode-seat.d.ts +89 -0
- package/dist/core/runner/fast-mode-seat.js +215 -0
- package/dist/core/runner/file-history-restore.d.ts +52 -14
- package/dist/core/runner/file-history-restore.js +50 -8
- package/dist/core/runner/forward-sink.js +2 -2
- package/dist/core/runner/gate-exit.d.ts +43 -4
- package/dist/core/runner/gate-exit.js +59 -12
- package/dist/core/runner/git-leg-delivery.js +6 -3
- package/dist/core/runner/git-status-frame.d.ts +35 -27
- package/dist/core/runner/git-status-frame.js +56 -37
- package/dist/core/runner/halt-attribution.js +2 -2
- package/dist/core/runner/hook-progress-lane.d.ts +26 -0
- package/dist/core/runner/hook-progress-lane.js +72 -0
- package/dist/core/runner/initial-run-state.js +2 -2
- package/dist/core/runner/language-frame.d.ts +10 -8
- package/dist/core/runner/language-frame.js +7 -11
- package/dist/core/runner/left-as-is-seat.d.ts +20 -0
- package/dist/core/runner/left-as-is-seat.js +11 -0
- package/dist/core/runner/leg-caller-places.d.ts +39 -0
- package/dist/core/runner/leg-caller-places.js +23 -0
- package/dist/core/runner/leg-frame.d.ts +8 -2
- package/dist/core/runner/leg-receipt.d.ts +65 -0
- package/dist/core/runner/leg-receipt.js +53 -0
- package/dist/core/runner/listing-fold.d.ts +4 -3
- package/dist/core/runner/listing-fold.js +5 -5
- package/dist/core/runner/listing-replay.d.ts +41 -0
- package/dist/core/runner/listing-replay.js +75 -0
- package/dist/core/runner/main-call-account.d.ts +2 -1
- package/dist/core/runner/main-call-account.js +18 -5
- package/dist/core/runner/mcp-redial.d.ts +4 -2
- package/dist/core/runner/mcp-redial.js +3 -0
- package/dist/core/runner/media-removed-seat.d.ts +10 -6
- package/dist/core/runner/media-removed-seat.js +6 -3
- package/dist/core/runner/memory-consolidation-driver.js +3 -2
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
- package/dist/core/runner/messages-omitted-seat.js +15 -5
- package/dist/core/runner/model-fallback-seat.d.ts +12 -9
- package/dist/core/runner/model-fallback-seat.js +24 -20
- package/dist/core/runner/nested-memory-lane.d.ts +16 -8
- package/dist/core/runner/nested-memory-lane.js +64 -53
- package/dist/core/runner/permission-rule-lanes.d.ts +4 -3
- package/dist/core/runner/permission-rule-lanes.js +2 -0
- package/dist/core/runner/person-path-rows.d.ts +25 -7
- package/dist/core/runner/person-path-rows.js +17 -3
- package/dist/core/runner/placement-fence.js +2 -2
- package/dist/core/runner/policy-throw.d.ts +3 -3
- package/dist/core/runner/policy-throw.js +7 -5
- package/dist/core/runner/prefix-ledger.d.ts +120 -0
- package/dist/core/runner/prefix-ledger.js +176 -0
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +7 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +9 -5
- package/dist/core/runner/prepare-advisor.d.ts +5 -0
- package/dist/core/runner/prepare-advisor.js +4 -3
- package/dist/core/runner/prepare-artifact.d.ts +10 -2
- package/dist/core/runner/prepare-artifact.js +19 -8
- package/dist/core/runner/prepare-ask-lane.d.ts +7 -0
- package/dist/core/runner/prepare-ask-lane.js +4 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +11 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +32 -23
- package/dist/core/runner/prepare-config-doors.d.ts +19 -8
- package/dist/core/runner/prepare-config-doors.js +42 -28
- package/dist/core/runner/prepare-context-lane.d.ts +28 -10
- package/dist/core/runner/prepare-context-lane.js +92 -40
- package/dist/core/runner/prepare-defer-classify.d.ts +12 -0
- package/dist/core/runner/prepare-defer-classify.js +5 -2
- package/dist/core/runner/prepare-delegation-surface.d.ts +10 -8
- package/dist/core/runner/prepare-delegation-surface.js +6 -7
- package/dist/core/runner/prepare-execution-env.d.ts +46 -4
- package/dist/core/runner/prepare-execution-env.js +47 -18
- package/dist/core/runner/prepare-file-history.d.ts +4 -1
- package/dist/core/runner/prepare-file-history.js +8 -9
- package/dist/core/runner/prepare-gate-stations.d.ts +18 -11
- package/dist/core/runner/prepare-gate-stations.js +24 -42
- package/dist/core/runner/prepare-hands-readface.d.ts +28 -11
- package/dist/core/runner/prepare-hands-readface.js +64 -54
- package/dist/core/runner/prepare-inherited-gate.d.ts +14 -2
- package/dist/core/runner/prepare-inherited-gate.js +12 -9
- package/dist/core/runner/prepare-leg-adoption.d.ts +36 -0
- package/dist/core/runner/prepare-leg-adoption.js +24 -0
- package/dist/core/runner/prepare-listings.d.ts +3 -0
- package/dist/core/runner/prepare-listings.js +2 -2
- package/dist/core/runner/prepare-lsp.d.ts +0 -3
- package/dist/core/runner/prepare-lsp.js +1 -2
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +10 -2
- package/dist/core/runner/prepare-memory.js +53 -7
- package/dist/core/runner/prepare-offload-wrappers.d.ts +5 -5
- package/dist/core/runner/prepare-offload-wrappers.js +5 -5
- package/dist/core/runner/prepare-park-ask.d.ts +9 -2
- package/dist/core/runner/prepare-park-ask.js +5 -3
- package/dist/core/runner/prepare-policy-chain.d.ts +23 -5
- package/dist/core/runner/prepare-policy-chain.js +44 -27
- package/dist/core/runner/prepare-prompt-assembly.d.ts +23 -6
- package/dist/core/runner/prepare-prompt-assembly.js +15 -6
- package/dist/core/runner/prepare-prompt-inputs.d.ts +6 -10
- package/dist/core/runner/prepare-prompt-inputs.js +7 -8
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
- package/dist/core/runner/prepare-protocol-tools.js +11 -11
- package/dist/core/runner/prepare-run-refs.d.ts +7 -0
- package/dist/core/runner/prepare-run-refs.js +6 -2
- package/dist/core/runner/prepare-safety-scan.js +7 -0
- package/dist/core/runner/prepare-suspend-saga.d.ts +8 -1
- package/dist/core/runner/prepare-suspend-saga.js +6 -2
- package/dist/core/runner/prepare-task.d.ts +1 -30
- package/dist/core/runner/prepare-task.js +156 -186
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
- package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
- package/dist/core/runner/prepare-turn-wiring.d.ts +26 -28
- package/dist/core/runner/prepare-turn-wiring.js +13 -20
- package/dist/core/runner/prepare-wiring-manifest.d.ts +12 -3
- package/dist/core/runner/prepare-wiring-manifest.js +22 -17
- package/dist/core/runner/prompt-block.js +2 -2
- package/dist/core/runner/prompt-suggestions.d.ts +5 -8
- package/dist/core/runner/prompt-suggestions.js +5 -2
- package/dist/core/runner/read-block-judge.d.ts +47 -0
- package/dist/core/runner/read-block-judge.js +33 -0
- package/dist/core/runner/reply-pricing.d.ts +8 -4
- package/dist/core/runner/reply-pricing.js +6 -5
- package/dist/core/runner/resume-admission.js +2 -0
- package/dist/core/runner/resume-apply.js +4 -4
- package/dist/core/runner/resume-checkpoint-screen.d.ts +23 -2
- package/dist/core/runner/resume-checkpoint-screen.js +34 -27
- package/dist/core/runner/resume-preflight.js +3 -3
- package/dist/core/runner/rewind-files.js +21 -14
- package/dist/core/runner/role-resolution-table.d.ts +24 -16
- package/dist/core/runner/role-resolution-table.js +11 -11
- package/dist/core/runner/role-seat-defaulted.js +2 -2
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -2
- package/dist/core/runner/rule-store-unreadable-notice.js +22 -7
- package/dist/core/runner/run-attachment-seats.js +8 -15
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-compaction-machinery.d.ts +1 -11
- package/dist/core/runner/run-compaction-machinery.js +3 -40
- package/dist/core/runner/run-harness-handlers.d.ts +2 -2
- package/dist/core/runner/run-harness-handlers.js +22 -22
- package/dist/core/runner/run-identity-wiring.js +15 -10
- package/dist/core/runner/run-leg.js +44 -13
- package/dist/core/runner/run-notification-lane.d.ts +4 -1
- package/dist/core/runner/run-notification-lane.js +21 -8
- package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
- package/dist/core/runner/run-recovery-lanes.js +35 -19
- package/dist/core/runner/run-settle-and-teardown.d.ts +6 -3
- package/dist/core/runner/run-settle-and-teardown.js +42 -52
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -1
- package/dist/core/runner/run-stop-and-final-verify.js +12 -49
- package/dist/core/runner/run-telemetry-and-budget-seats.js +29 -11
- package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
- package/dist/core/runner/run-terminal-adoption.js +10 -90
- package/dist/core/runner/run-tool-mount-facts.js +1 -5
- package/dist/core/runner/run-turn-boundary.js +69 -37
- package/dist/core/runner/runtask.d.ts +16 -7
- package/dist/core/runner/runtask.js +55 -34
- package/dist/core/runner/sandbox-network-seat.d.ts +52 -0
- package/dist/core/runner/sandbox-network-seat.js +40 -0
- package/dist/core/runner/seat-model-doors.d.ts +16 -0
- package/dist/core/runner/seat-model-doors.js +13 -0
- package/dist/core/runner/session-file-state-replay.d.ts +20 -0
- package/dist/core/runner/session-file-state-replay.js +17 -5
- package/dist/core/runner/session-hash-salt.d.ts +18 -0
- package/dist/core/runner/session-hash-salt.js +36 -0
- package/dist/core/runner/session-read-file-states.d.ts +37 -0
- package/dist/core/runner/session-read-file-states.js +19 -0
- package/dist/core/runner/session-rule-policy.d.ts +2 -1
- package/dist/core/runner/session-rule-policy.js +3 -2
- package/dist/core/runner/session-verb-doors.js +2 -1
- package/dist/core/runner/session-write-ledger.d.ts +5 -1
- package/dist/core/runner/session-write-ledger.js +19 -5
- package/dist/core/runner/shared-read-classifier.d.ts +48 -0
- package/dist/core/runner/shared-read-classifier.js +33 -0
- package/dist/core/runner/shell-env-withheld.d.ts +13 -7
- package/dist/core/runner/shell-env-withheld.js +28 -3
- package/dist/core/runner/side-call-account.d.ts +39 -3
- package/dist/core/runner/side-call-account.js +53 -9
- package/dist/core/runner/skill-mention.d.ts +12 -0
- package/dist/core/runner/skill-mention.js +50 -0
- package/dist/core/runner/skipped-rules-notice.d.ts +43 -0
- package/dist/core/runner/skipped-rules-notice.js +49 -0
- package/dist/core/runner/steering-preview.js +1 -1
- package/dist/core/runner/stop-tail-notice.d.ts +40 -0
- package/dist/core/runner/stop-tail-notice.js +35 -0
- package/dist/core/runner/stream-halt-verbs.js +1 -1
- package/dist/core/runner/stream-mode-verb.d.ts +11 -4
- package/dist/core/runner/stream-mode-verb.js +19 -7
- package/dist/core/runner/stream-settle-backstop.js +4 -1
- package/dist/core/runner/stream-steer-verb.js +4 -3
- package/dist/core/runner/synthetic-tools.d.ts +11 -11
- package/dist/core/runner/synthetic-tools.js +19 -22
- package/dist/core/runner/task-start-doors.d.ts +86 -0
- package/dist/core/runner/task-start-doors.js +108 -0
- package/dist/core/runner/teardown-bounded.d.ts +5 -5
- package/dist/core/runner/teardown-bounded.js +6 -6
- package/dist/core/runner/terminal-account.d.ts +3 -2
- package/dist/core/runner/terminal-account.js +5 -3
- package/dist/core/runner/tool-disclosure.js +8 -9
- package/dist/core/runner/tool-end-body.d.ts +2 -0
- package/dist/core/runner/tool-end-body.js +1 -0
- package/dist/core/runner/tool-face-overlay.js +1 -0
- package/dist/core/runner/tool-occurrence.d.ts +22 -24
- package/dist/core/runner/tool-occurrence.js +9 -15
- package/dist/core/runner/tool-progress-lane.js +1 -1
- package/dist/core/runner/tool-result-media-seat.d.ts +7 -4
- package/dist/core/runner/tool-result-media-seat.js +16 -4
- package/dist/core/runner/tool-table-view.d.ts +12 -10
- package/dist/core/runner/tool-table-view.js +23 -21
- package/dist/core/runner/tool-turn-repair-seat.d.ts +22 -2
- package/dist/core/runner/tool-turn-repair-seat.js +23 -5
- package/dist/core/runner/turn-attachments.d.ts +74 -148
- package/dist/core/runner/turn-attachments.js +153 -223
- package/dist/core/runner/usage-accounting.d.ts +15 -0
- package/dist/core/runner/usage-accounting.js +12 -4
- package/dist/core/runner/verdict-refusal.d.ts +45 -0
- package/dist/core/runner/verdict-refusal.js +39 -0
- package/dist/core/runner/write-protection-station.d.ts +10 -2
- package/dist/core/runner/write-protection-station.js +7 -7
- package/dist/core/runner-deps.d.ts +40 -32
- package/dist/core/runtime-caps.d.ts +5 -3
- package/dist/core/scheduler.d.ts +13 -3
- package/dist/core/scheduler.js +0 -12
- package/dist/core/secret-env.d.ts +61 -20
- package/dist/core/secret-env.js +83 -15
- package/dist/core/sensitive-path-policy.js +4 -0
- package/dist/core/session-checkout.d.ts +18 -1
- package/dist/core/session-checkout.js +33 -17
- package/dist/core/session-log-transfer.js +2 -2
- package/dist/core/session-policy-store.d.ts +220 -31
- package/dist/core/session-policy-store.js +333 -47
- package/dist/core/session-reconcile.d.ts +12 -0
- package/dist/core/session-reconcile.js +1 -1
- package/dist/core/session-store.d.ts +5 -3
- package/dist/core/session-store.js +11 -11
- package/dist/core/session.d.ts +31 -22
- package/dist/core/session.js +3 -2
- package/dist/core/shared-memory/normalize.js +2 -1
- package/dist/core/shell-run-candidates.d.ts +1 -1
- package/dist/core/shell-run-candidates.js +11 -3
- package/dist/core/side-query.d.ts +4 -0
- package/dist/core/side-query.js +7 -4
- package/dist/core/spec-contract.d.ts +4 -2
- package/dist/core/store-contracts/background-agent-store-contract.js +149 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +55 -0
- package/dist/core/store-contracts/contract-kit-version.d.ts +4 -4
- package/dist/core/store-contracts/file-history-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/file-history-store-contract.js +282 -22
- package/dist/core/store-contracts/session-policy-store-contract.js +202 -0
- package/dist/core/store-contracts/session-store-contract.js +48 -14
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +128 -0
- package/dist/core/store-contracts/workflow-journal-store-contract.js +90 -1
- package/dist/core/swappable-deps.d.ts +16 -0
- package/dist/core/swappable-deps.js +61 -1
- package/dist/core/synthetic-read-verdict.d.ts +23 -0
- package/dist/core/synthetic-read-verdict.js +43 -18
- package/dist/core/task-event.d.ts +155 -60
- package/dist/core/task-intake.d.ts +23 -5
- package/dist/core/task-intake.js +33 -3
- package/dist/core/task-limits.d.ts +3 -1
- package/dist/core/task-notification.d.ts +171 -59
- package/dist/core/task-notification.js +162 -104
- package/dist/core/task-registry-agent.d.ts +12 -0
- package/dist/core/task-registry-agent.js +23 -9
- package/dist/core/task-registry-shared.d.ts +4 -2
- package/dist/core/task-registry-shared.js +1 -1
- package/dist/core/task-registry-workflow.js +8 -5
- package/dist/core/task-registry.d.ts +16 -1
- package/dist/core/task-registry.js +35 -23
- package/dist/core/task-result.d.ts +166 -10
- package/dist/core/task-spec-members.d.ts +8 -2
- package/dist/core/task-spec-members.js +11 -7
- package/dist/core/task-spec.d.ts +68 -32
- package/dist/core/task-start-judge.d.ts +41 -0
- package/dist/core/task-start-judge.js +26 -0
- package/dist/core/task-stream.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +23 -9
- package/dist/core/tool-catalog-entries.js +6 -5
- package/dist/core/tool-face-lists.d.ts +3 -2
- package/dist/core/tool-face-lists.js +6 -0
- package/dist/core/tool-face-reader.d.ts +3 -2
- package/dist/core/tool-face-reader.js +2 -2
- package/dist/core/tool-face.d.ts +27 -3
- package/dist/core/tool-face.js +2 -2
- package/dist/core/tool-model-gate.js +14 -13
- package/dist/core/tool-mount-facts.d.ts +16 -3
- package/dist/core/tool-mount-facts.js +10 -0
- package/dist/core/tool-mount-plan.d.ts +79 -10
- package/dist/core/tool-mount-plan.js +79 -24
- package/dist/core/tool-mount-static.d.ts +52 -6
- package/dist/core/tool-mount-static.js +82 -28
- package/dist/core/tool-name-aliases.js +1 -1
- package/dist/core/tool-policy.d.ts +55 -26
- package/dist/core/tool-policy.js +50 -36
- package/dist/core/tool-registry.d.ts +12 -2
- package/dist/core/tool-registry.js +9 -2
- package/dist/core/tool-result-budget.d.ts +2 -2
- package/dist/core/tool-result-bytes.d.ts +28 -9
- package/dist/core/tool-result-bytes.js +7 -5
- package/dist/core/tool-result-store.d.ts +310 -38
- package/dist/core/tool-result-store.js +325 -30
- package/dist/core/tool-roster.d.ts +41 -15
- package/dist/core/tool-roster.js +50 -12
- package/dist/core/tool-search-setting.js +2 -2
- package/dist/core/tool-spec-members.js +1 -1
- package/dist/core/tool-spec.d.ts +37 -10
- package/dist/core/tools.js +1 -0
- package/dist/core/trace.d.ts +42 -19
- package/dist/core/types.d.ts +5 -5
- package/dist/core/types.js +2 -2
- package/dist/core/unc-spelling.d.ts +145 -3
- package/dist/core/unc-spelling.js +161 -0
- package/dist/core/untrusted-egress.d.ts +82 -10
- package/dist/core/untrusted-egress.js +102 -9
- package/dist/core/untrusted-text.d.ts +28 -0
- package/dist/core/untrusted-text.js +67 -3
- package/dist/core/user-attachment.d.ts +18 -3
- package/dist/core/user-attachment.js +37 -31
- package/dist/core/user-row-origin.d.ts +22 -0
- package/dist/core/user-row-origin.js +15 -0
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +2 -12
- package/dist/core/wiring-manifest.d.ts +151 -30
- package/dist/core/wiring-manifest.js +69 -17
- package/dist/core/workflow-journal-store.d.ts +186 -16
- package/dist/core/workflow-journal-store.js +156 -1
- package/dist/core/workflow-run-store-contract.js +104 -1
- package/dist/core/workflow-run-store.d.ts +44 -4
- package/dist/core/workflow-run-store.js +9 -2
- package/dist/core/workspace-snapshot.d.ts +4 -1
- package/dist/core/workspace-snapshot.js +1 -1
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +17 -15
- package/dist/engine/compaction/compaction.d.ts +51 -101
- package/dist/engine/compaction/compaction.js +142 -224
- package/dist/engine/compaction/utils.d.ts +2 -11
- package/dist/engine/compaction/utils.js +4 -13
- package/dist/engine/execution-env/node-execution-env.d.ts +14 -6
- package/dist/engine/execution-env/node-execution-env.js +66 -20
- package/dist/engine/harness/agent-harness.d.ts +36 -12
- package/dist/engine/harness/agent-harness.js +84 -23
- package/dist/engine/harness/types.d.ts +36 -9
- package/dist/engine/harness/types.js +14 -1
- package/dist/engine/llm/tool-turns.d.ts +19 -2
- package/dist/engine/llm/tool-turns.js +29 -2
- package/dist/engine/llm/types.d.ts +103 -22
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/loop/agent-loop.d.ts +32 -10
- package/dist/engine/loop/agent-loop.js +144 -33
- package/dist/engine/loop/types.d.ts +21 -7
- package/dist/engine/lsp/node-lsp-manager.d.ts +6 -4
- package/dist/engine/lsp/node-lsp-manager.js +22 -21
- package/dist/engine/session/import-validate.js +2 -0
- package/dist/engine/session/repo-utils.d.ts +13 -7
- package/dist/engine/session/repo-utils.js +9 -4
- package/dist/index.d.ts +55 -31
- package/dist/index.js +44 -24
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +2 -2
- package/dist/internal/harness.js +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/governance-baseline-validity.d.ts +20 -5
- package/dist/orchestration/governance-baseline-validity.js +87 -16
- package/dist/orchestration/run-spec.js +7 -2
- package/dist/orchestration/run-workflow-tool.d.ts +15 -12
- package/dist/orchestration/run-workflow-tool.js +759 -331
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-observe.d.ts +22 -2
- package/dist/orchestration/workflow-observe.js +20 -9
- package/dist/orchestration/workflow-park-adoption.d.ts +438 -0
- package/dist/orchestration/workflow-park-adoption.js +767 -0
- package/dist/orchestration/workflow-size-guideline.d.ts +6 -8
- package/dist/orchestration/workflow-size-guideline.js +12 -14
- package/dist/orchestration/workflow-types.d.ts +117 -17
- package/dist/orchestration/workflow-types.js +40 -8
- package/dist/orchestration/workflow.d.ts +71 -26
- package/dist/orchestration/workflow.js +503 -201
- package/dist/prompt-assembly/artifact.js +4 -3
- package/dist/prompt-assembly/assemble.d.ts +2 -0
- package/dist/prompt-assembly/assemble.js +4 -1
- package/dist/prompt-assembly/bands.d.ts +3 -0
- package/dist/prompt-assembly/bands.js +6 -0
- package/dist/prompt-assembly/catalog/constitution.d.ts +1 -1
- package/dist/prompt-assembly/catalog/constitution.js +74 -9
- package/dist/prompt-assembly/catalog/core-behavior.d.ts +5 -4
- package/dist/prompt-assembly/catalog/core-behavior.js +52 -9
- package/dist/prompt-assembly/catalog/engine.d.ts +110 -5
- package/dist/prompt-assembly/catalog/engine.js +13 -0
- package/dist/prompt-assembly/catalog/events.d.ts +860 -0
- package/dist/prompt-assembly/catalog/events.js +62 -0
- package/dist/prompt-assembly/catalog/index.js +2 -1
- package/dist/prompt-assembly/catalog/locales/index.d.ts +2 -2
- package/dist/prompt-assembly/catalog/locales/index.js +4 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +53 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +51 -9
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +12 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/events.js +57 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +57 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +8 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +37 -9
- package/dist/prompt-assembly/catalog/mechanism.d.ts +435 -0
- package/dist/prompt-assembly/catalog/mechanism.js +63 -0
- package/dist/prompt-assembly/catalog/memory.d.ts +3 -3
- package/dist/prompt-assembly/catalog/memory.js +12 -3
- package/dist/prompt-assembly/catalog/modes.d.ts +2 -2
- package/dist/prompt-assembly/catalog/modes.js +7 -1
- package/dist/prompt-assembly/catalog/role.d.ts +1 -1
- package/dist/prompt-assembly/catalog/role.js +43 -14
- package/dist/prompt-assembly/catalog/schema.d.ts +43 -20
- package/dist/prompt-assembly/catalog/schema.js +18 -6
- package/dist/prompt-assembly/catalog/sections.d.ts +1 -1
- package/dist/prompt-assembly/catalog/sections.js +28 -12
- package/dist/prompt-assembly/composer.d.ts +3 -0
- package/dist/prompt-assembly/composer.js +11 -5
- package/dist/prompt-assembly/engine-text.d.ts +14 -4
- package/dist/prompt-assembly/engine-text.js +18 -9
- package/dist/prompt-assembly/event-registry.d.ts +38 -31
- package/dist/prompt-assembly/event-registry.js +186 -25
- package/dist/prompt-assembly/explain.d.ts +24 -0
- package/dist/prompt-assembly/explain.js +11 -0
- package/dist/prompt-assembly/locale-review.js +3 -2
- package/dist/prompt-assembly/overlay.d.ts +25 -7
- package/dist/prompt-assembly/overlay.js +68 -14
- package/dist/prompt-assembly/select.d.ts +4 -3
- package/dist/prompt-assembly/select.js +11 -2
- package/dist/prompt-assembly/sugar.d.ts +3 -2
- package/dist/prompt-assembly/sugar.js +2 -2
- package/dist/prompt-assembly/tool-catalog.js +3 -2
- package/dist/prompt-assembly/turn-snapshot.d.ts +15 -27
- package/dist/prompt-assembly/turn-snapshot.js +7 -18
- package/dist/prompt-assembly/types.d.ts +6 -4
- package/dist/prompts/default.d.ts +15 -45
- package/dist/prompts/default.js +7 -21
- package/dist/shell/lex.d.ts +51 -10
- package/dist/shell/lex.js +223 -31
- package/dist/stores/file/adoption/adopt.d.ts +13 -3
- package/dist/stores/file/adoption/adopt.js +90 -95
- package/dist/stores/file/adoption/marker.d.ts +2 -1
- package/dist/stores/file/background-agent-store.d.ts +61 -0
- package/dist/stores/file/background-agent-store.js +64 -15
- package/dist/stores/file/checkpoint-store.d.ts +30 -2
- package/dist/stores/file/checkpoint-store.js +72 -23
- package/dist/stores/file/file-history-store.d.ts +13 -7
- package/dist/stores/file/file-history-store.js +170 -46
- package/dist/stores/file/fs-atomic.d.ts +57 -2
- package/dist/stores/file/fs-atomic.js +116 -48
- package/dist/stores/file/index.d.ts +2 -0
- package/dist/stores/file/index.js +2 -0
- package/dist/stores/file/ledger-damage.d.ts +87 -0
- package/dist/stores/file/ledger-damage.js +103 -0
- package/dist/stores/file/session-policy-store.d.ts +36 -4
- package/dist/stores/file/session-policy-store.js +177 -6
- package/dist/stores/file/shared-ledger.d.ts +123 -11
- package/dist/stores/file/shared-ledger.js +113 -18
- package/dist/stores/file/tool-result-store.d.ts +30 -1
- package/dist/stores/file/tool-result-store.js +60 -6
- package/dist/stores/file/workflow-journal-store.d.ts +73 -26
- package/dist/stores/file/workflow-journal-store.js +195 -32
- package/dist/stores/file/workflow-run-store.d.ts +47 -2
- package/dist/stores/file/workflow-run-store.js +17 -14
- package/dist/tools/artifact/artifact-tool.d.ts +9 -6
- package/dist/tools/artifact/artifact-tool.js +76 -40
- package/dist/tools/fs/bash-program-position.js +2 -6
- package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
- package/dist/tools/fs/bash-readonly-classifier.js +12 -6
- package/dist/tools/fs/containment-face.d.ts +12 -3
- package/dist/tools/fs/containment-face.js +16 -7
- package/dist/tools/fs/env-error-detail.d.ts +11 -0
- package/dist/tools/fs/env-error-detail.js +13 -2
- package/dist/tools/fs/file-read-check.d.ts +26 -1
- package/dist/tools/fs/file-read-check.js +20 -2
- package/dist/tools/fs/fs-bash.js +30 -21
- package/dist/tools/fs/fs-pdf.d.ts +1 -1
- package/dist/tools/fs/fs-pdf.js +2 -2
- package/dist/tools/fs/fs-read.d.ts +3 -0
- package/dist/tools/fs/fs-read.js +6 -6
- package/dist/tools/fs/fs-search-tools.d.ts +2 -2
- package/dist/tools/fs/fs-search-tools.js +4 -4
- package/dist/tools/fs/fs-shared.d.ts +26 -9
- package/dist/tools/fs/fs-shared.js +12 -6
- package/dist/tools/fs/fs-write.d.ts +6 -4
- package/dist/tools/fs/fs-write.js +24 -18
- package/dist/tools/fs/index.js +5 -3
- package/dist/tools/fs/pattern-kill-guard.js +2 -1
- package/dist/tools/fs/pdf.d.ts +8 -0
- package/dist/tools/fs/pdf.js +22 -4
- package/dist/tools/fs/program-read-model.d.ts +4 -0
- package/dist/tools/fs/program-read-model.rows.js +3 -3
- package/dist/tools/fs/read-deny-home.d.ts +13 -2
- package/dist/tools/fs/read-deny-home.js +26 -22
- package/dist/tools/fs/read-deny.js +15 -6
- package/dist/tools/fs/read-floor.d.ts +11 -9
- package/dist/tools/fs/read-floor.js +7 -10
- package/dist/tools/fs/removal-targets.d.ts +33 -17
- package/dist/tools/fs/removal-targets.js +176 -59
- package/dist/tools/fs/repo-map.d.ts +1 -1
- package/dist/tools/fs/repo-map.js +2 -2
- package/dist/tools/fs/safety.d.ts +34 -108
- package/dist/tools/fs/safety.js +49 -124
- package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
- package/dist/tools/fs/shell-read-bindings.js +25 -6
- package/dist/tools/fs/shell-read-check.d.ts +7 -2
- package/dist/tools/fs/shell-read-check.js +28 -6
- package/dist/tools/fs/shell-read-environment.d.ts +10 -2
- package/dist/tools/fs/shell-read-environment.js +20 -11
- package/dist/tools/fs/shell-read-establish.js +73 -43
- package/dist/tools/fs/shell-read-judge.d.ts +51 -21
- package/dist/tools/fs/shell-read-judge.js +22 -8
- package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
- package/dist/tools/fs/shell-read-object-path.js +17 -4
- package/dist/tools/fs/shell-read-plan.d.ts +3 -3
- package/dist/tools/fs/shell-read-plan.js +23 -19
- package/dist/tools/fs/shell-read-sourced.js +10 -3
- package/dist/tools/fs/shell-read-start.d.ts +4 -2
- package/dist/tools/fs/shell-read-start.js +3 -3
- package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
- package/dist/tools/fs/shell-read-workdir.js +35 -17
- package/dist/tools/fs/shell-reentry-text.d.ts +8 -0
- package/dist/tools/fs/shell-reentry-text.js +56 -0
- package/dist/tools/monitor.js +7 -5
- package/dist/tools/scheduler-tools.d.ts +44 -16
- package/dist/tools/scheduler-tools.js +87 -114
- package/dist/tools/task-list.d.ts +12 -4
- package/dist/tools/task-list.js +10 -7
- package/dist/tools/web.d.ts +2 -8
- package/dist/tools/web.js +5 -5
- package/dist/tools/worktree.js +23 -19
- package/package.json +7 -3
- package/test/export-surface.snapshot.json +390 -14
- package/wire-changes/{core-stores-sql@7.68.7.json → core-stores-sql@7.69.0.json} +5 -5
- package/wire-changes/core-stores-sql@7.69.1.json +39 -0
- package/wire-changes/core@7.69.0.json +9561 -0
- package/wire-changes/core@7.69.1.json +2561 -0
- package/wire-changes/mods-kernel@7.69.0.json +80 -0
- package/wire-changes/{mods-kernel@7.68.7.json → mods-kernel@7.69.1.json} +5 -5
- package/wire-changes/primitives@7.69.0.json +79 -0
- package/wire-changes/{primitives@7.68.7.json → primitives@7.69.1.json} +5 -5
- package/wire-changes/{wiki-gate@7.68.7.json → wiki-gate@7.69.0.json} +5 -5
- package/wire-changes/wiki-gate@7.69.1.json +39 -0
- package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
- package/dist/core/runner/prompt-hash-salt.js +0 -2
- package/wire-changes/core@7.68.7.json +0 -140
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { defineTool, errorResult } from "../core/tools.js";
|
|
3
|
-
import { governanceBaselineError,
|
|
3
|
+
import { governanceBaselineError, receiveGovernanceBaseline } from "./governance-baseline-validity.js";
|
|
4
4
|
import { workflowRecordPickupOf } from "./workflow-record-artifact.js";
|
|
5
5
|
import { admitsBackgroundLaunch, oweTerminalDelivery, resolveCompletionSink } from "../core/task-notification.js";
|
|
6
|
-
import { egressText, egressThrownText, boundedRedactedSummary } from "../core/untrusted-egress.js";
|
|
6
|
+
import { egressText, egressThrownText, boundedRedactedSummary, redactThenCut } from "../core/untrusted-egress.js";
|
|
7
|
+
import { foreignLine } from "../core/protocol-http-auth.js";
|
|
7
8
|
import { withDelegationProvenance } from "../core/tool-policy.js";
|
|
8
9
|
import { LAUNCH_RECEIPT_OWN_WORDS_CLAUSE, launchReceiptNoQuoteClause } from "../agents/launch-receipt-contract.js";
|
|
9
|
-
import {
|
|
10
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
11
|
+
import { startWorkflow, WORKFLOW_STORE_WAIT_BOUND_MS, takeWorkflowResumeClaim, releaseWorkflowResumeClaim } from "./workflow.js";
|
|
12
|
+
import { assertJournalStoreGivesClaimsBack, journalKeepsLaunches } from "../core/workflow-journal-store.js";
|
|
13
|
+
import { boundedStoreRead, createWorkflowParkAdopter, otherWaitingLine, readWorkflowRunChain, registerWorkflowParkAdopter, workflowTreeOverBoundSentence } from "./workflow-park-adoption.js";
|
|
10
14
|
import { settledRunOf } from "../core/workflow-settled-run.js";
|
|
11
|
-
import { WORKFLOW_AGENT_PARKED_ERROR_CODE, parkedAgentsOf } from "./workflow-types.js";
|
|
15
|
+
import { WORKFLOW_AGENT_PARKED_ERROR_CODE, WORKFLOW_STEP_ASKED_AGAIN, parkedAgentsOf, workflowParkHolderOf } from "./workflow-types.js";
|
|
12
16
|
import { checkpointStoreOfSeat } from "../core/checkpoint-seat.js";
|
|
13
17
|
import { buildWorkflowPrimitives } from "./workflow-primitives.js";
|
|
14
18
|
import { stripSpawnTurnQuestionFace } from "../core/ask-question.js";
|
|
15
19
|
import { parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
|
|
16
20
|
import { CLAMP_SEATS, CLAMP_SET, assertClampRecord, clampRecordError, clampSourceOf, foldClampSources } from "../core/child-clamp-seats.js";
|
|
17
21
|
import { assertNoRetiredKeys } from "../core/retired-keys.js";
|
|
22
|
+
import { recordCarried, snapshotDefinitionLists } from "../agents/agent-definition.js";
|
|
18
23
|
const RETIRED_RUN_WORKFLOW_TOOL_DEPS_KEYS = {
|
|
19
24
|
principal: "the host run's principal rides `RunWorkflowToolDeps.parentSpecSeat.principal` (the parent SPEC seat the host's prepare mints), never a seat of its own",
|
|
20
25
|
oneShot: "the host run's one-shot fact rides `RunWorkflowToolDeps.parentSpecSeat.oneShot` (only `true` travels), never a seat of its own",
|
|
@@ -26,6 +31,7 @@ const RETIRED_RUN_WORKFLOW_TOOL_DEPS_KEYS = {
|
|
|
26
31
|
`the host's tighten-only clamps ride ONE getter, \`RunWorkflowToolDeps.parentClamps\` (every clamp row, present keys) — return \`${seat}\` from it`,
|
|
27
32
|
])),
|
|
28
33
|
parentDurableApproval: "the host run's durable-approval opt-in object is `RunWorkflowToolDeps.parentDurableApprovalForChildren` (the same value, renamed after its context twin `durableApprovalForChildren`); the host's `durableApproval: false` rides `RunWorkflowToolDeps.parentClamps`",
|
|
34
|
+
parkedResume: "a model's Workflow call no longer carries the host's park decisions: hand them as `RunWorkflowToolDeps.parkedDecisions` (each with its `decisionId` and `outcome`) and the engine continues the decided run itself at the leg's opening",
|
|
29
35
|
};
|
|
30
36
|
import { parseWorkflowMeta, splitWorkflowMeta, workflowScriptReadsClockOrRandom } from "./workflow-meta.js";
|
|
31
37
|
import { mergeWorkflowArgs, normalizeStringArg } from "./workflow-script-store.js";
|
|
@@ -33,6 +39,11 @@ import { workflowSizeGuidelineSection } from "./workflow-size-guideline.js";
|
|
|
33
39
|
import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
34
40
|
import { readMember, thrownText } from "../core/thrown-value.js";
|
|
35
41
|
import { callScopeOf } from "../core/isolation-scope.js";
|
|
42
|
+
import { readKeptLaunch } from "../core/workflow-journal-store.js";
|
|
43
|
+
import { isThinkingLevel } from "../brain/reasoning.js";
|
|
44
|
+
import { inlineUntrusted } from "../core/untrusted-text.js";
|
|
45
|
+
import { claimHeldOf, HOST_FOLD_INPUTS, hostFoldStampOf, notContinuedRefusalOf, storeErrorClassOf, storeFaultReport } from "./workflow-park-adoption.js";
|
|
46
|
+
import { createSafeNotifier, observeThenableRejection } from "../core/safe-notify.js";
|
|
36
47
|
export const RUN_WORKFLOW_TOOL_NAME = "Workflow";
|
|
37
48
|
export const WORKFLOW_NO_COMPLETION_CHANNEL = "a workflow run is not available here — no completion would come back from one on this mount (no notification channel and no deployment notifier is wired), and a workflow has no synchronous form. Do the work directly instead.";
|
|
38
49
|
function stripCodeFences(s) {
|
|
@@ -58,8 +69,8 @@ function completionSummary(name, run) {
|
|
|
58
69
|
: run.resume.journalEntries === 0
|
|
59
70
|
? "; resume found NO journal entries — nothing replayed, the whole script re-ran live"
|
|
60
71
|
: `; resume: replayed ${run.resume.replayed} of ${run.resume.journalEntries} journaled results`;
|
|
61
|
-
return (`workflow${cleanName ? ` "${cleanName}"` : ""} completed${elapsed} — agents ${done}/${run.agents.length} done` +
|
|
62
|
-
`${failed > 0 ? ` (${failed} failed)` : ""}${resumeClause}
|
|
72
|
+
return withUnusedDecisions(`workflow${cleanName ? ` "${cleanName}"` : ""} completed${elapsed} — agents ${done}/${run.agents.length} done` +
|
|
73
|
+
`${failed > 0 ? ` (${failed} failed)` : ""}${resumeClause}`, run);
|
|
63
74
|
}
|
|
64
75
|
function rootOccupantSeat(rootId, ctx, d) {
|
|
65
76
|
if (rootId === undefined)
|
|
@@ -98,7 +109,7 @@ function workflowUsageBlock(run) {
|
|
|
98
109
|
...(run.endedAt !== undefined ? { duration_ms: run.endedAt - run.startedAt } : {}),
|
|
99
110
|
};
|
|
100
111
|
}
|
|
101
|
-
function workflowDiagnostics(runId, journalRef, resumeMiss, record) {
|
|
112
|
+
function workflowDiagnostics(runId, journalRef, resumeMiss, record, held) {
|
|
102
113
|
const journalTeach = journalRef === undefined
|
|
103
114
|
? ""
|
|
104
115
|
: journalRef.includes("://")
|
|
@@ -110,7 +121,28 @@ function workflowDiagnostics(runId, journalRef, resumeMiss, record) {
|
|
|
110
121
|
return ((record ?? "") +
|
|
111
122
|
journalTeach +
|
|
112
123
|
resumeMissTeach +
|
|
113
|
-
|
|
124
|
+
(held !== undefined
|
|
125
|
+
? ` ${heldStepSentence(held)}.`
|
|
126
|
+
: ` To continue after editing the script: re-invoke with resumeFromRunId: "${runId}" (completed agents replay from the journal; only new/changed calls run).`)).trimStart();
|
|
127
|
+
}
|
|
128
|
+
const heldStepSentence = (held) => held.holder !== undefined
|
|
129
|
+
? `The parked step still belongs to run "${held.holder}": with a person's decision on its card, that run continues from the step; ` +
|
|
130
|
+
`if the card is no longer waiting (expired, removed, or decided elsewhere), a resume of "${held.holder}" records the step as failed and its script continues`
|
|
131
|
+
: `A parked step this run inherited is not this run's: continuing from this run would only fail again at that step, and which run holds it could not be read here — ` +
|
|
132
|
+
`a person's decision on its card continues the run that holds it`;
|
|
133
|
+
async function heldStepOf(run, store) {
|
|
134
|
+
if (run?.resume === undefined || run.status !== "failed" || run.errorCode === WORKFLOW_AGENT_PARKED_ERROR_CODE)
|
|
135
|
+
return undefined;
|
|
136
|
+
const inherited = run.parks?.find((p) => p.parkedBy !== undefined && p.parkedBy !== run.id);
|
|
137
|
+
if (inherited === undefined)
|
|
138
|
+
return undefined;
|
|
139
|
+
if (store === undefined)
|
|
140
|
+
return {};
|
|
141
|
+
const chain = await readWorkflowRunChain(store, inherited.parkedBy, run.scope, boundedStoreRead(WORKFLOW_STORE_WAIT_BOUND_MS));
|
|
142
|
+
if (typeof chain === "string")
|
|
143
|
+
return {};
|
|
144
|
+
const holder = workflowParkHolderOf(inherited.token, [chain.root, ...chain.successors]);
|
|
145
|
+
return holder.kind === "held" ? { holder: holder.runId } : {};
|
|
114
146
|
}
|
|
115
147
|
const SCRIPT_ERROR_CODES = new Set([
|
|
116
148
|
"workflow.script_error",
|
|
@@ -122,9 +154,47 @@ const SCRIPT_ERROR_CODES = new Set([
|
|
|
122
154
|
"workflow.result_too_large",
|
|
123
155
|
"workflow.budget_exceeded",
|
|
124
156
|
]);
|
|
125
|
-
function failureSummary(err, runId) {
|
|
157
|
+
function failureSummary(err, runId, run, held) {
|
|
158
|
+
return withUnusedDecisions(failureSummaryOf(err, runId, run, held), run);
|
|
159
|
+
}
|
|
160
|
+
const RESUME_REFUSAL_CODES = new Set(["workflow.parked_call_changed", "workflow.park_truth_unreadable", "workflow.park_binding_broken", "workflow.park_requires_run_store"]);
|
|
161
|
+
function withUnusedDecisions(summary, run) {
|
|
162
|
+
const unused = run?.resume?.decisions?.filter((d) => d.result === "not_reached") ?? [];
|
|
163
|
+
if (unused.length === 0)
|
|
164
|
+
return summary;
|
|
165
|
+
const code = unused[0].code;
|
|
166
|
+
const cause = code === undefined
|
|
167
|
+
? run?.status === "completed"
|
|
168
|
+
? "the script ended without reaching it"
|
|
169
|
+
: "the run ended before reaching it"
|
|
170
|
+
: RESUME_REFUSAL_CODES.has(code)
|
|
171
|
+
? `this continuation was refused (${code}) before it got there`
|
|
172
|
+
: code === WORKFLOW_AGENT_PARKED_ERROR_CODE
|
|
173
|
+
? "an earlier step stopped on an approval again and is waiting for a decision"
|
|
174
|
+
: `the run ended (${code}) before reaching it`;
|
|
175
|
+
const steps = unused.map((d) => `#${d.ordinal}`).join(", ");
|
|
176
|
+
const one = unused.length === 1;
|
|
177
|
+
const card = `${one ? "Its approval card is" : "Their approval cards are"} left as ${one ? "it was" : "they were"}, waiting for a decision`;
|
|
178
|
+
const wayOut = code === WORKFLOW_AGENT_PARKED_ERROR_CODE
|
|
179
|
+
? `, and the decision is not spent: decide the approval that earlier step is waiting for first, then hand ${one ? "this decision" : "these decisions"} over again — before that, handing ${one ? "it" : "them"} over does not continue the workflow`
|
|
180
|
+
: `, and the same decision can be handed over again to continue the workflow`;
|
|
181
|
+
return `${summary}. The approval decision carried for the parked step${one ? "" : "s"} (agent ${steps}) was not used: ${cause}. ${card}${wayOut}`;
|
|
182
|
+
}
|
|
183
|
+
function continuedBeforeSentence(run) {
|
|
184
|
+
const before = run?.resume?.continuedBefore;
|
|
185
|
+
if (before === undefined || typeof before.runId !== "string")
|
|
186
|
+
return "";
|
|
187
|
+
const ended = `${before.status}${before.errorCode !== undefined ? ` (${before.errorCode})` : ""}`;
|
|
188
|
+
return ` — run "${boundedRedactedSummary(run.resume.fromRunId, 80)}" had already been continued as run "${boundedRedactedSummary(before.runId, 80)}", which ended ${ended}; this run continued from that earlier point, so the steps after it that had not completed there ran again here`;
|
|
189
|
+
}
|
|
190
|
+
function failureSummaryOf(err, runId, run, held) {
|
|
126
191
|
const codeWord = readMember(err, "code");
|
|
127
192
|
const code = typeof codeWord === "string" ? codeWord : undefined;
|
|
193
|
+
const refused = code === WORKFLOW_AGENT_PARKED_ERROR_CODE ? run?.resume?.decisions?.find((d) => d.result === "refused") : undefined;
|
|
194
|
+
if (refused !== undefined) {
|
|
195
|
+
const label = run?.agents.find((a) => a.callKey === refused.callKey)?.label ?? `#${refused.ordinal}`;
|
|
196
|
+
return `workflow parked again: the approval decision for "${boundedRedactedSummary(label, 80)}" was not applied${refused.code !== undefined ? ` (${refused.code})` : ""} — the run is parked at the same step and needs a new decision`;
|
|
197
|
+
}
|
|
128
198
|
if (code === WORKFLOW_AGENT_PARKED_ERROR_CODE) {
|
|
129
199
|
const parkedWords = readMember(err, "message");
|
|
130
200
|
const msg = typeof parkedWords === "string" ? egressText("same-principal", parkedWords) : "";
|
|
@@ -133,13 +203,17 @@ function failureSummary(err, runId) {
|
|
|
133
203
|
(runId ? `; the diagnostics below name its record (the yielded agent's row reads status "parked")` : "") +
|
|
134
204
|
`; to continue it, re-invoke with resumeFromRunId${runId ? `: "${runId}"` : ""} and the same script — completed agents replay and the yielded call continues with no decision`);
|
|
135
205
|
}
|
|
136
|
-
return (`workflow parked (${code}): ${msg.length > 200 ? `${msg.slice(0, 200)}…` : msg}
|
|
206
|
+
return (`workflow parked (${code}): ${msg.length > 200 ? `${msg.slice(0, 200)}…` : msg}` +
|
|
207
|
+
(readMember(err, "askedAgain") === true ? ` — ${WORKFLOW_STEP_ASKED_AGAIN}` : "") +
|
|
208
|
+
` — it did not fail and is not finished` +
|
|
137
209
|
(runId ? `; the diagnostics below name its record (the parked agent's row reads status "parked")` : "") +
|
|
138
|
-
`; do not re-issue the same call — once the approval
|
|
210
|
+
`; do not re-issue the same call — once a person decides the approval, the decision continues this run from the parked call; you do not resume it, and if it cannot be continued you are told then`);
|
|
139
211
|
}
|
|
140
|
-
const guide =
|
|
141
|
-
? `; which agents failed is in the diagnostics below
|
|
142
|
-
:
|
|
212
|
+
const guide = held !== undefined
|
|
213
|
+
? `; which agents failed is in the diagnostics below. ${heldStepSentence(held)}`
|
|
214
|
+
: runId
|
|
215
|
+
? `; which agents failed is in the diagnostics below; after fixing, re-invoke with resumeFromRunId: "${runId}" (completed agents replay from the journal)`
|
|
216
|
+
: "";
|
|
143
217
|
const scriptWords = code && SCRIPT_ERROR_CODES.has(code) ? readMember(err, "message") : undefined;
|
|
144
218
|
if (code && typeof scriptWords === "string") {
|
|
145
219
|
const msg = egressText("same-principal", scriptWords);
|
|
@@ -174,8 +248,114 @@ async function collectNamedWorkflowListings(store) {
|
|
|
174
248
|
}
|
|
175
249
|
return [...byName.values()];
|
|
176
250
|
}
|
|
251
|
+
const modelWordOf = (pick) => (typeof pick.modelRef === "string" ? pick.modelRef : pick.model.id);
|
|
252
|
+
function claimWithin(p, late) {
|
|
253
|
+
return new Promise((resolve, reject) => {
|
|
254
|
+
let settled = false;
|
|
255
|
+
const t = setTimeout(() => {
|
|
256
|
+
settled = true;
|
|
257
|
+
resolve("timeout");
|
|
258
|
+
}, WORKFLOW_STORE_WAIT_BOUND_MS);
|
|
259
|
+
p.then((v) => {
|
|
260
|
+
if (settled)
|
|
261
|
+
return late(v);
|
|
262
|
+
settled = true;
|
|
263
|
+
clearTimeout(t);
|
|
264
|
+
resolve(v);
|
|
265
|
+
}, (e) => {
|
|
266
|
+
if (settled)
|
|
267
|
+
return;
|
|
268
|
+
settled = true;
|
|
269
|
+
clearTimeout(t);
|
|
270
|
+
reject(e);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function launchRefusalText(content) {
|
|
275
|
+
const text = typeof content === "string" ? content : Array.isArray(content) ? content.map((c) => (c !== null && typeof c === "object" && typeof c.text === "string" ? c.text : "")).join("") : "";
|
|
276
|
+
try {
|
|
277
|
+
const parsed = JSON.parse(text);
|
|
278
|
+
if (parsed !== null && typeof parsed === "object" && typeof parsed.error === "string")
|
|
279
|
+
return parsed.error;
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
}
|
|
283
|
+
return text !== "" ? text : "the launch started no run";
|
|
284
|
+
}
|
|
285
|
+
const INSTRUCTED_DECISIONS_MAX = 4096;
|
|
286
|
+
const instructedByStore = new WeakMap();
|
|
287
|
+
const instructedDecisionsOf = (store) => {
|
|
288
|
+
if (store === undefined)
|
|
289
|
+
return new Set();
|
|
290
|
+
const held = instructedByStore.get(store);
|
|
291
|
+
if (held !== undefined)
|
|
292
|
+
return held;
|
|
293
|
+
const fresh = new Set();
|
|
294
|
+
instructedByStore.set(store, fresh);
|
|
295
|
+
return fresh;
|
|
296
|
+
};
|
|
297
|
+
function canonicalFoldData(root) {
|
|
298
|
+
const seen = new WeakSet();
|
|
299
|
+
const walk = (v) => {
|
|
300
|
+
if (typeof v === "function" || typeof v === "symbol" || v === undefined)
|
|
301
|
+
return undefined;
|
|
302
|
+
if (v === null || typeof v !== "object")
|
|
303
|
+
return typeof v === "bigint" ? v.toString() : v;
|
|
304
|
+
if (seen.has(v))
|
|
305
|
+
return "[cycle]";
|
|
306
|
+
seen.add(v);
|
|
307
|
+
try {
|
|
308
|
+
if (v instanceof Set)
|
|
309
|
+
return [...v].map((e) => walk(e)).map((e) => JSON.stringify(e)).sort();
|
|
310
|
+
if (v instanceof Map)
|
|
311
|
+
return [...v.entries()].map(([k, e]) => [String(k), walk(e)]).sort((a, b) => String(a[0]).localeCompare(String(b[0])));
|
|
312
|
+
if (Array.isArray(v))
|
|
313
|
+
return v.map((e) => walk(e));
|
|
314
|
+
const o = v;
|
|
315
|
+
if (typeof o.name === "string" && typeof o.execute === "function")
|
|
316
|
+
return { tool: o.name };
|
|
317
|
+
const out = {};
|
|
318
|
+
for (const k of Object.keys(o).sort()) {
|
|
319
|
+
const c = walk(o[k]);
|
|
320
|
+
if (c !== undefined)
|
|
321
|
+
out[k] = c;
|
|
322
|
+
}
|
|
323
|
+
return out;
|
|
324
|
+
}
|
|
325
|
+
finally {
|
|
326
|
+
seen.delete(v);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
return walk(root);
|
|
330
|
+
}
|
|
331
|
+
function workflowHostIdentityOf(fold) {
|
|
332
|
+
const pick = fold.model?.();
|
|
333
|
+
const model = pick === undefined ? undefined : modelWordOf(pick);
|
|
334
|
+
const thinking = fold.thinking?.();
|
|
335
|
+
return { ...(typeof model === "string" && model !== "" ? { model, ...(typeof pick?.modelRef !== "string" ? { modelPinned: true } : {}) } : {}), ...(typeof thinking === "string" ? { thinking } : {}) };
|
|
336
|
+
}
|
|
337
|
+
function workflowHostFoldDigest(fold) {
|
|
338
|
+
const pick = fold.model?.();
|
|
339
|
+
const { baseUrl, api, provider, ...modelRest } = (pick?.model ?? {});
|
|
340
|
+
const baseline = fold.governance.baseline;
|
|
341
|
+
const withoutTools = (slot) => (slot === undefined ? undefined : { ...slot, tools: undefined });
|
|
342
|
+
const inputs = {
|
|
343
|
+
tools: { base: baseline.base?.tools, worktreeBase: baseline.worktreeBase?.tools },
|
|
344
|
+
baseline: { ...baseline, base: withoutTools(baseline.base), worktreeBase: withoutTools(baseline.worktreeBase), workflowModelAllowlist: undefined },
|
|
345
|
+
allowed_models: { catalog: fold.governance.models, allowlist: baseline.workflowModelAllowlist },
|
|
346
|
+
agent_limits: fold.governance.caps,
|
|
347
|
+
permissions: { clamps: fold.clamps(), posture: fold.posture() },
|
|
348
|
+
model: pick === undefined ? undefined : { model: modelRest, modelRef: pick.modelRef },
|
|
349
|
+
endpoint: pick === undefined ? undefined : { baseUrl, api, provider },
|
|
350
|
+
thinking: fold.thinking?.(),
|
|
351
|
+
account: { principal: fold.seat?.principal, isolationScope: fold.seat?.isolationScope },
|
|
352
|
+
};
|
|
353
|
+
const digestOf = (v) => createHash("sha256").update(JSON.stringify(canonicalFoldData(v)) ?? "").digest("hex").slice(0, 32);
|
|
354
|
+
return hostFoldStampOf(Object.fromEntries(HOST_FOLD_INPUTS.map((k) => [k, digestOf(inputs[k])])));
|
|
355
|
+
}
|
|
177
356
|
export function createRunWorkflowTool(d) {
|
|
178
357
|
assertNoRetiredKeys(d, RETIRED_RUN_WORKFLOW_TOOL_DEPS_KEYS, "RunWorkflowToolDeps");
|
|
358
|
+
assertJournalStoreGivesClaimsBack(d.journalStore, "RunWorkflowToolDeps.journalStore");
|
|
179
359
|
if (d.parentClamps !== undefined && typeof d.parentClamps !== "function") {
|
|
180
360
|
throw clampRecordError(`RunWorkflowToolDeps.parentClamps must be a getter returning the host's clamp source, got ${typeof d.parentClamps}`);
|
|
181
361
|
}
|
|
@@ -185,6 +365,10 @@ async function mountRunWorkflowTool(d) {
|
|
|
185
365
|
if (d.scriptRunner.safeForUntrustedScripts !== true) {
|
|
186
366
|
throw new Error("createRunWorkflowTool: refusing to mount run_workflow on a runner that is not safeForUntrustedScripts (design/98 fail-closed)");
|
|
187
367
|
}
|
|
368
|
+
const faultSink = createSafeNotifier();
|
|
369
|
+
const sink = d.onStoreFault;
|
|
370
|
+
const reportStoreFault = sink === undefined ? undefined : (what, err) => void faultSink.notify(() => observeThenableRejection(sink(storeFaultReport(what, err)), faultSink, "onStoreFault"), "onStoreFault");
|
|
371
|
+
const agents = d.agents?.map(snapshotDefinitionLists);
|
|
188
372
|
const lim = d.limits ?? {};
|
|
189
373
|
const maxScriptChars = lim.maxScriptChars ?? DEFAULTS.maxScriptChars;
|
|
190
374
|
const childCaps = {
|
|
@@ -193,9 +377,10 @@ async function mountRunWorkflowTool(d) {
|
|
|
193
377
|
childMaxTokens: lim.childMaxTokens,
|
|
194
378
|
childMaxTurns: lim.childMaxTurns,
|
|
195
379
|
};
|
|
196
|
-
const
|
|
197
|
-
if (problem
|
|
198
|
-
throw governanceBaselineError(problem);
|
|
380
|
+
const receipt = receiveGovernanceBaseline(d.governanceBaseline);
|
|
381
|
+
if ("problem" in receipt)
|
|
382
|
+
throw governanceBaselineError(receipt.problem);
|
|
383
|
+
const received = receipt.baseline;
|
|
199
384
|
const FACE_LIST_FIELDS = ["allowTools", "excludeTools", "deferTools", "alwaysLoadTools"];
|
|
200
385
|
const dropNullFaces = (slot) => {
|
|
201
386
|
let out = slot;
|
|
@@ -213,28 +398,28 @@ async function mountRunWorkflowTool(d) {
|
|
|
213
398
|
const { onAsk: _absent, ...rest } = slot;
|
|
214
399
|
return rest;
|
|
215
400
|
};
|
|
216
|
-
const sanitizedBaseline =
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
...rest,
|
|
222
|
-
...(allowlist === undefined ? {} : { workflowModelAllowlist: allowlist }),
|
|
223
|
-
base: dropNullishOnAsk(dropNullFaces(d.governanceBaseline.base)),
|
|
224
|
-
...(wt === null || wt === undefined ? {} : { worktreeBase: dropNullishOnAsk(dropNullFaces(wt)) }),
|
|
225
|
-
};
|
|
226
|
-
})();
|
|
401
|
+
const sanitizedBaseline = {
|
|
402
|
+
...received,
|
|
403
|
+
base: dropNullishOnAsk(dropNullFaces(received.base)),
|
|
404
|
+
...(received.worktreeBase === undefined ? {} : { worktreeBase: dropNullishOnAsk(dropNullFaces(received.worktreeBase)) }),
|
|
405
|
+
};
|
|
227
406
|
const unionFaceList = (own, parent) => own === undefined ? [...new Set(parent)] : [...new Set([...own, ...parent])];
|
|
228
|
-
const
|
|
407
|
+
const mountFace = {
|
|
408
|
+
...(d.parentDeferTools !== undefined ? { deferTools: [...d.parentDeferTools] } : {}),
|
|
409
|
+
...(d.parentAlwaysLoadTools !== undefined ? { alwaysLoadTools: [...d.parentAlwaysLoadTools] } : {}),
|
|
410
|
+
...(d.parentRestoreGatedTools !== undefined ? { restoreGatedTools: d.parentRestoreGatedTools === true ? true : [...d.parentRestoreGatedTools] } : {}),
|
|
411
|
+
...(d.parentPromptLean !== undefined ? { promptLean: d.parentPromptLean } : {}),
|
|
412
|
+
};
|
|
413
|
+
const withParentFace = (face, base, inherit) => ({
|
|
229
414
|
...base,
|
|
230
|
-
...(
|
|
231
|
-
? { deferTools: unionFaceList(base.deferTools ?? inherit?.deferTools,
|
|
415
|
+
...(face.deferTools?.length
|
|
416
|
+
? { deferTools: unionFaceList(base.deferTools ?? inherit?.deferTools, face.deferTools) }
|
|
232
417
|
: {}),
|
|
233
|
-
...(
|
|
234
|
-
? { alwaysLoadTools: unionFaceList(base.alwaysLoadTools ?? inherit?.alwaysLoadTools,
|
|
418
|
+
...(face.alwaysLoadTools?.length
|
|
419
|
+
? { alwaysLoadTools: unionFaceList(base.alwaysLoadTools ?? inherit?.alwaysLoadTools, face.alwaysLoadTools) }
|
|
235
420
|
: {}),
|
|
236
421
|
...(() => {
|
|
237
|
-
const parent =
|
|
422
|
+
const parent = face.restoreGatedTools;
|
|
238
423
|
if (parent !== true && !(Array.isArray(parent) && parent.length > 0))
|
|
239
424
|
return {};
|
|
240
425
|
const own = base.restoreGatedTools !== undefined ? base.restoreGatedTools : inherit?.restoreGatedTools;
|
|
@@ -249,21 +434,102 @@ async function mountRunWorkflowTool(d) {
|
|
|
249
434
|
};
|
|
250
435
|
})(),
|
|
251
436
|
});
|
|
252
|
-
const withParentLean = (base) =>
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
437
|
+
const withParentLean = (face, base) => face.promptLean !== undefined && base.promptLean === undefined ? { ...base, promptLean: face.promptLean } : base;
|
|
438
|
+
const governanceOf = (face) => ({
|
|
439
|
+
baseline: (face.deferTools?.length ?? 0) > 0 || (face.alwaysLoadTools?.length ?? 0) > 0 || face.promptLean !== undefined || face.restoreGatedTools !== undefined
|
|
440
|
+
? {
|
|
441
|
+
...sanitizedBaseline,
|
|
442
|
+
base: withParentLean(face, withParentFace(face, sanitizedBaseline.base)),
|
|
443
|
+
...(sanitizedBaseline.worktreeBase !== undefined
|
|
444
|
+
? { worktreeBase: withParentFace(face, sanitizedBaseline.worktreeBase, sanitizedBaseline.base) }
|
|
445
|
+
: {}),
|
|
446
|
+
}
|
|
447
|
+
: sanitizedBaseline,
|
|
448
|
+
models: d.models,
|
|
449
|
+
caps: childCaps,
|
|
450
|
+
onNotice: d.onNotice,
|
|
451
|
+
});
|
|
452
|
+
const governance = governanceOf(mountFace);
|
|
263
453
|
const namedWorkflowSection = renderNamedWorkflowListing(await collectNamedWorkflowListings(d.scriptStore));
|
|
264
454
|
const sizeGuidelineSection = workflowSizeGuidelineSection(d.sizeGuideline ?? lim.sizeGuideline);
|
|
265
455
|
const structuredError = (message) => errorResult(JSON.stringify({ error: message }));
|
|
266
|
-
|
|
456
|
+
const detachedSeatOf = (ctx) => {
|
|
457
|
+
const hostSeat = parentSpecSeatOfCtx(ctx) ?? d.parentSpecSeat;
|
|
458
|
+
return hostSeat !== undefined ? stripSpawnTurnQuestionFace(hostSeat) : undefined;
|
|
459
|
+
};
|
|
460
|
+
const hostFoldOf = (ctx, seat, hostOnAsk, inherited) => {
|
|
461
|
+
const g = inherited.face === mountFace ? governance : governanceOf(inherited.face);
|
|
462
|
+
return {
|
|
463
|
+
governance: hostOnAsk !== undefined && g.baseline.base.onAsk === undefined
|
|
464
|
+
? { ...g, baseline: { ...g.baseline, base: { ...g.baseline.base, onAsk: withDelegationProvenance(hostOnAsk, { parentToolCallId: ctx.toolCallId, depth: 1 }) } } }
|
|
465
|
+
: g,
|
|
466
|
+
clamps: () => {
|
|
467
|
+
const host = d.parentClamps?.();
|
|
468
|
+
assertClampRecord(host, "RunWorkflowToolDeps.parentClamps()", "clamp");
|
|
469
|
+
return clampSourceOf(foldClampSources(clampSourceOf(ctx, "clamp"), host), "clamp");
|
|
470
|
+
},
|
|
471
|
+
posture: () => ctx.interactionPosture ?? d.parentInteractionPosture,
|
|
472
|
+
model: inherited.model,
|
|
473
|
+
thinking: inherited.thinking,
|
|
474
|
+
seat,
|
|
475
|
+
face: inherited.face,
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
const mountInherited = { face: mountFace, model: d.parentModel, thinking: d.parentThinking };
|
|
479
|
+
const inheritedOf = (launch) => {
|
|
480
|
+
if (launch === undefined)
|
|
481
|
+
return mountInherited;
|
|
482
|
+
const host = launch.host;
|
|
483
|
+
const word = host?.model;
|
|
484
|
+
const recordedModel = () => {
|
|
485
|
+
if (word === undefined)
|
|
486
|
+
return undefined;
|
|
487
|
+
if (host?.modelPinned !== true && d.resolveModelWord !== undefined)
|
|
488
|
+
return d.resolveModelWord(word);
|
|
489
|
+
const current = d.parentModel?.();
|
|
490
|
+
if (current === undefined)
|
|
491
|
+
return undefined;
|
|
492
|
+
return host?.modelPinned === true ? (typeof current.modelRef !== "string" && current.model.id === word ? current : undefined) : current.modelRef === word ? current : undefined;
|
|
493
|
+
};
|
|
494
|
+
return {
|
|
495
|
+
face: launch.face ?? mountFace,
|
|
496
|
+
model: host === undefined ? d.parentModel : recordedModel,
|
|
497
|
+
thinking: host === undefined ? d.parentThinking : () => (isThinkingLevel(host.thinking) ? host.thinking : undefined),
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
const launchHostUnavailable = (launch, inherited) => {
|
|
501
|
+
const host = launch?.host;
|
|
502
|
+
if (host === undefined)
|
|
503
|
+
return undefined;
|
|
504
|
+
let pick;
|
|
505
|
+
try {
|
|
506
|
+
pick = inherited.model?.();
|
|
507
|
+
}
|
|
508
|
+
catch {
|
|
509
|
+
pick = undefined;
|
|
510
|
+
}
|
|
511
|
+
if (host.model !== undefined && pick === undefined) {
|
|
512
|
+
return host.modelPinned === true
|
|
513
|
+
? `the model it was launched with ("${inlineUntrusted(host.model, 64)}", handed to the session as a model object rather than a catalog name) is not the session's model now`
|
|
514
|
+
: `the model it was launched with ("${inlineUntrusted(host.model, 64)}") is not one this deployment serves any more`;
|
|
515
|
+
}
|
|
516
|
+
if (host.thinking !== undefined && !isThinkingLevel(host.thinking))
|
|
517
|
+
return `its recorded thinking level ("${foreignLine(host.thinking, 32)}") is not one`;
|
|
518
|
+
return undefined;
|
|
519
|
+
};
|
|
520
|
+
const adopterHostFold = (ctx, launch) => hostFoldOf(ctx, detachedSeatOf(ctx)?.spec, ctx.onAsk ?? d.parentOnAsk, inheritedOf(launch));
|
|
521
|
+
const heldForCall = new Map();
|
|
522
|
+
const instructedDecisions = instructedDecisionsOf(d.store);
|
|
523
|
+
const carryKey = (runId, toolCallId) => `${runId}\u0000${toolCallId}`;
|
|
524
|
+
const takeHeldForCall = (runId, toolCallId) => {
|
|
525
|
+
if (runId === undefined || toolCallId === undefined)
|
|
526
|
+
return undefined;
|
|
527
|
+
const key = carryKey(runId, toolCallId);
|
|
528
|
+
const held = heldForCall.get(key);
|
|
529
|
+
heldForCall.delete(key);
|
|
530
|
+
return held;
|
|
531
|
+
};
|
|
532
|
+
const tool = defineTool({
|
|
267
533
|
name: RUN_WORKFLOW_TOOL_NAME,
|
|
268
534
|
...toolFace("workflow"),
|
|
269
535
|
ruleFace: mountRuleFace("workflow"),
|
|
@@ -287,7 +553,7 @@ async function mountRunWorkflowTool(d) {
|
|
|
287
553
|
};
|
|
288
554
|
}
|
|
289
555
|
catch (e) {
|
|
290
|
-
return { form: "script", parseError: thrownText(e)
|
|
556
|
+
return { form: "script", parseError: redactThenCut(thrownText(e), 300), scriptChars: a.script.length };
|
|
291
557
|
}
|
|
292
558
|
},
|
|
293
559
|
description: "Author and run your own deterministic JS WORKFLOW that spawns and coordinates sub-agents. Pass `script` " +
|
|
@@ -317,7 +583,8 @@ async function mountRunWorkflowTool(d) {
|
|
|
317
583
|
"(plain parallel would clobber); this takes precedence over plain parallel. A separate-working-copy need, " +
|
|
318
584
|
"NOT merely 'several agents'.\n" +
|
|
319
585
|
"• resumeFromRunId (this tool's arg): RESUME a prior/crashed run — replay its completed agents, run only new work " +
|
|
320
|
-
"(a run that could park must have finished — a crashed park-capable run is decided through the deployment's approval channel, not resumed
|
|
586
|
+
"(a run that could park must have finished — a crashed park-capable run is decided through the deployment's approval channel, not resumed; " +
|
|
587
|
+
"a run parked on an approval is continued by the person's decision, not by you).\n" +
|
|
321
588
|
"• scriptPath / name (this tool's args): when a script store is wired, every run persists its script and " +
|
|
322
589
|
"returns its scriptPath — to iterate, EDIT that file and re-invoke with {scriptPath} instead of resending " +
|
|
323
590
|
"the full script; {name} runs a saved workflow.\n" +
|
|
@@ -396,317 +663,478 @@ async function mountRunWorkflowTool(d) {
|
|
|
396
663
|
"Requires a journal-backed deployment; omit for a fresh run.",
|
|
397
664
|
})),
|
|
398
665
|
}),
|
|
399
|
-
execute:
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
666
|
+
execute: (rawArgs, ctx) => launch(rawArgs, ctx),
|
|
667
|
+
});
|
|
668
|
+
const journalLocatorOf = (runId, scope) => {
|
|
669
|
+
try {
|
|
670
|
+
return d.journalStore?.locator?.(runId, scope);
|
|
671
|
+
}
|
|
672
|
+
catch {
|
|
673
|
+
return undefined;
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
const launch = async (rawArgs, ctx, continuation) => {
|
|
677
|
+
const rawScript = rawArgs.script;
|
|
678
|
+
const rawName = rawArgs.name;
|
|
679
|
+
const rawScriptPath = rawArgs.scriptPath;
|
|
680
|
+
const scriptArgs = rawArgs.args;
|
|
681
|
+
const rawResume = rawArgs.resumeFromRunId;
|
|
682
|
+
const resumeFromRunId = continuation !== undefined ? continuation.fromRunId : typeof rawResume === "string" && rawResume.length > 0 ? rawResume : undefined;
|
|
683
|
+
const held = continuation === undefined ? takeHeldForCall(resumeFromRunId, ctx.toolCallId) : undefined;
|
|
684
|
+
if (held !== undefined && "refusal" in held)
|
|
685
|
+
return structuredError(held.refusal);
|
|
686
|
+
const sourceTaskId = ctx.taskId ?? d.sourceTaskId;
|
|
687
|
+
const completionSink = resolveCompletionSink(ctx.onTaskNotification, d.taskNotification);
|
|
688
|
+
if (!admitsBackgroundLaunch(completionSink, d.notifier !== undefined))
|
|
689
|
+
return structuredError(WORKFLOW_NO_COMPLETION_CHANNEL);
|
|
690
|
+
const detachedSeat = detachedSeatOf(ctx);
|
|
691
|
+
const parentSpecSeat = detachedSeat?.spec;
|
|
692
|
+
const principal = parentSpecSeat?.principal;
|
|
693
|
+
const taskScope = callScopeOf(ctx, d);
|
|
694
|
+
let script;
|
|
695
|
+
let registeredDefaultArgs;
|
|
696
|
+
let registeredStringArgKey;
|
|
697
|
+
if (continuation !== undefined) {
|
|
698
|
+
script = continuation.launch.script;
|
|
699
|
+
}
|
|
700
|
+
else if (typeof rawScriptPath === "string" && rawScriptPath.length > 0) {
|
|
701
|
+
if (!d.scriptStore)
|
|
702
|
+
return structuredError("scriptPath requires a deployment workflow script store — none is wired; pass `script` inline");
|
|
703
|
+
if (d.scriptStore.scopePartitioned !== true) {
|
|
704
|
+
return structuredError("the wired workflow script store predates the scope-partition contract (scopePartitioned marker absent) — upgrade the store implementation");
|
|
433
705
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return structuredError("named workflows require a deployment workflow script store — none is wired; pass `script` inline");
|
|
437
|
-
}
|
|
438
|
-
let resolved;
|
|
439
|
-
try {
|
|
440
|
-
resolved = await d.scriptStore.resolveName(rawName);
|
|
441
|
-
}
|
|
442
|
-
catch (err) {
|
|
443
|
-
return structuredError(`failed to resolve workflow name: ${egressThrownText("same-principal", err).slice(0, 300)}`);
|
|
444
|
-
}
|
|
445
|
-
const resolvedShape = resolved;
|
|
446
|
-
if (resolvedShape !== undefined && (resolvedShape === null || typeof resolvedShape !== "object")) {
|
|
447
|
-
return structuredError("the wired workflow script store's resolveName returned the retired bare-string form — the resolution shape is now { script, defaultArgs? } (one shape); upgrade the store implementation");
|
|
448
|
-
}
|
|
449
|
-
if (resolved === undefined)
|
|
450
|
-
return structuredError(`unknown workflow name: ${JSON.stringify(rawName)}`);
|
|
451
|
-
script = resolved.script;
|
|
452
|
-
if ("defaultArgs" in resolved)
|
|
453
|
-
registeredDefaultArgs = resolved.defaultArgs;
|
|
454
|
-
if (typeof resolved.stringArgKey === "string" && resolved.stringArgKey.length > 0) {
|
|
455
|
-
registeredStringArgKey = resolved.stringArgKey;
|
|
456
|
-
}
|
|
706
|
+
try {
|
|
707
|
+
script = await d.scriptStore.load(rawScriptPath, taskScope ?? "default");
|
|
457
708
|
}
|
|
458
|
-
|
|
459
|
-
return structuredError(
|
|
709
|
+
catch (err) {
|
|
710
|
+
return structuredError(`failed to read workflow script at scriptPath: ${egressThrownText("same-principal", err).slice(0, 300)}`);
|
|
460
711
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
712
|
+
}
|
|
713
|
+
else if (typeof rawScript === "string" && rawScript.length > 0) {
|
|
714
|
+
script = stripCodeFences(rawScript);
|
|
715
|
+
}
|
|
716
|
+
else if (typeof rawName === "string" && rawName.length > 0) {
|
|
717
|
+
if (!d.scriptStore?.resolveName) {
|
|
718
|
+
return structuredError("named workflows require a deployment workflow script store — none is wired; pass `script` inline");
|
|
464
719
|
}
|
|
465
|
-
let
|
|
720
|
+
let resolved;
|
|
466
721
|
try {
|
|
467
|
-
|
|
722
|
+
resolved = await d.scriptStore.resolveName(rawName);
|
|
468
723
|
}
|
|
469
724
|
catch (err) {
|
|
470
|
-
return structuredError(
|
|
725
|
+
return structuredError(`failed to resolve workflow name: ${egressThrownText("same-principal", err).slice(0, 300)}`);
|
|
471
726
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
if (workflowScriptReadsClockOrRandom(body)) {
|
|
476
|
-
return structuredError("Workflow scripts must be deterministic: Date.now()/Math.random()/new Date() are unavailable (breaks resume). " +
|
|
477
|
-
"Stamp results after the workflow returns, or pass timestamps via args.");
|
|
478
|
-
}
|
|
727
|
+
const resolvedShape = resolved;
|
|
728
|
+
if (resolvedShape !== undefined && (resolvedShape === null || typeof resolvedShape !== "object")) {
|
|
729
|
+
return structuredError("the wired workflow script store's resolveName returned the retired bare-string form — the resolution shape is now { script, defaultArgs? } (one shape); upgrade the store implementation");
|
|
479
730
|
}
|
|
480
|
-
|
|
481
|
-
return structuredError(`workflow
|
|
731
|
+
if (resolved === undefined)
|
|
732
|
+
return structuredError(`unknown workflow name: ${JSON.stringify(rawName)}`);
|
|
733
|
+
script = resolved.script;
|
|
734
|
+
if ("defaultArgs" in resolved)
|
|
735
|
+
registeredDefaultArgs = resolved.defaultArgs;
|
|
736
|
+
if (typeof resolved.stringArgKey === "string" && resolved.stringArgKey.length > 0) {
|
|
737
|
+
registeredStringArgKey = resolved.stringArgKey;
|
|
482
738
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
};
|
|
507
|
-
if (
|
|
508
|
-
return structuredError("
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
return structuredError("Must provide script, name, or scriptPath");
|
|
742
|
+
}
|
|
743
|
+
const effectiveArgs = continuation !== undefined ? continuation.launch.effectiveArgs : mergeWorkflowArgs(normalizeStringArg(scriptArgs, registeredDefaultArgs, registeredStringArgKey), registeredDefaultArgs);
|
|
744
|
+
const callArgs = continuation !== undefined ? { ...continuation.launch.callArgs } : { ...(rawArgs !== null && typeof rawArgs === "object" ? rawArgs : {}) };
|
|
745
|
+
if (continuation === undefined) {
|
|
746
|
+
delete callArgs["resumeFromRunId"];
|
|
747
|
+
delete callArgs["script"];
|
|
748
|
+
delete callArgs["args"];
|
|
749
|
+
}
|
|
750
|
+
if (script.length > maxScriptChars) {
|
|
751
|
+
return structuredError(`script too large: ${script.length} chars > max ${maxScriptChars}`);
|
|
752
|
+
}
|
|
753
|
+
let meta;
|
|
754
|
+
try {
|
|
755
|
+
meta = parseWorkflowMeta(script);
|
|
756
|
+
}
|
|
757
|
+
catch (err) {
|
|
758
|
+
return structuredError(thrownText(err));
|
|
759
|
+
}
|
|
760
|
+
try {
|
|
761
|
+
const { body } = splitWorkflowMeta(script);
|
|
762
|
+
new Function(`return (async function(agent, parallel, pipeline, phase, log, budget, args) {\n${body}\n})`);
|
|
763
|
+
if (workflowScriptReadsClockOrRandom(body)) {
|
|
764
|
+
return structuredError("Workflow scripts must be deterministic: Date.now()/Math.random()/new Date() are unavailable (breaks resume). " +
|
|
765
|
+
"Stamp results after the workflow returns, or pass timestamps via args.");
|
|
509
766
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
767
|
+
}
|
|
768
|
+
catch (err) {
|
|
769
|
+
return structuredError(`workflow script failed to compile: ${thrownText(err)}`);
|
|
770
|
+
}
|
|
771
|
+
const hostOnAsk = ctx.onAsk ?? d.parentOnAsk;
|
|
772
|
+
const hostDurableApproval = ctx.durableApprovalForChildren ?? d.parentDurableApprovalForChildren;
|
|
773
|
+
const childParkSeat = ctx.checkpointStoreForChildren ?? d.parentCheckpointStore;
|
|
774
|
+
const parkStore = checkpointStoreOfSeat(childParkSeat);
|
|
775
|
+
const resumeScope = taskScope ?? d.scope ?? "default";
|
|
776
|
+
const heldDecisionIds = held !== undefined && "decisions" in held ? held.decisions.map((x) => x.decisionId) : [];
|
|
777
|
+
const modelLineRefusal = async () => {
|
|
778
|
+
if (continuation !== undefined || resumeFromRunId === undefined || d.store === undefined)
|
|
779
|
+
return undefined;
|
|
780
|
+
const line = await otherWaitingLine(d.store, parkStore, resumeFromRunId, resumeScope, boundedStoreRead(WORKFLOW_STORE_WAIT_BOUND_MS));
|
|
781
|
+
if (line.kind === "unreadable")
|
|
782
|
+
return `the records of workflow run "${inlineUntrusted(resumeFromRunId, 64)}"'s workflow, or one of its approval cards, could not be read — not started; resume again once the run store answers`;
|
|
783
|
+
if (line.kind === "over_bound")
|
|
784
|
+
return workflowTreeOverBoundSentence(resumeFromRunId);
|
|
785
|
+
if (line.kind === "waiting")
|
|
786
|
+
return notContinuedRefusalOf(resumeFromRunId, "waiting_elsewhere", { waiting: line.lines, decisionIds: heldDecisionIds });
|
|
787
|
+
return { root: line.root };
|
|
788
|
+
};
|
|
789
|
+
const firstLine = await modelLineRefusal();
|
|
790
|
+
if (typeof firstLine === "string")
|
|
791
|
+
return structuredError(firstLine);
|
|
792
|
+
const claimKey = continuation !== undefined ? continuation.claimKey : firstLine?.root;
|
|
793
|
+
let sourceLaunch = continuation?.launch;
|
|
794
|
+
if (continuation === undefined && resumeFromRunId !== undefined && journalKeepsLaunches(d.journalStore)) {
|
|
795
|
+
const scope = taskScope ?? d.scope ?? "default";
|
|
796
|
+
const read = await readKeptLaunch(d.journalStore, resumeFromRunId, scope, WORKFLOW_STORE_WAIT_BOUND_MS);
|
|
797
|
+
if (read.kind === "failed" && read.cause !== undefined)
|
|
798
|
+
reportStoreFault?.(`the launch record of workflow run ${JSON.stringify(resumeFromRunId)} could not be read`, read.cause.err);
|
|
799
|
+
if (read.kind === "failed")
|
|
800
|
+
return structuredError(`the launch record of workflow run "${inlineUntrusted(resumeFromRunId, 64)}" could not be read (${(read.cause === undefined ? `the journal store did not answer within ${WORKFLOW_STORE_WAIT_BOUND_MS}ms` : storeErrorClassOf(read.cause.err)).slice(0, 160)}) — its agents could not be seated on what it was launched with; not started`);
|
|
801
|
+
if (read.kind === "defect")
|
|
802
|
+
return structuredError(notContinuedRefusalOf(resumeFromRunId, "launch_unreadable", { code: read.member }));
|
|
803
|
+
if (read.kind === "record")
|
|
804
|
+
sourceLaunch = read.record;
|
|
805
|
+
}
|
|
806
|
+
const inherited = inheritedOf(sourceLaunch);
|
|
807
|
+
const unseatable = launchHostUnavailable(sourceLaunch, inherited);
|
|
808
|
+
if (unseatable !== undefined)
|
|
809
|
+
return structuredError(`workflow run "${inlineUntrusted(resumeFromRunId ?? "", 64)}" cannot be continued: ${unseatable.slice(0, 300)} — its agents stay on what the run was launched with; start the workflow again`);
|
|
810
|
+
const hostFold = hostFoldOf(ctx, parentSpecSeat, hostOnAsk, inherited);
|
|
811
|
+
const scriptFn = (wfCtx) => {
|
|
812
|
+
const primitives = buildWorkflowPrimitives(wfCtx, hostFold.governance, d.onAgentSpawn, childParkSeat, hostFold.clamps, hostFold.posture);
|
|
813
|
+
return d.scriptRunner.run({ scriptSource: script, primitives, scriptArgs: effectiveArgs, signal: wfCtx.signal }).then((r) => r.result);
|
|
814
|
+
};
|
|
815
|
+
if (ctx.signal?.aborted) {
|
|
816
|
+
return structuredError("the launching tool call was aborted before the workflow could start — not started");
|
|
817
|
+
}
|
|
818
|
+
let handle;
|
|
819
|
+
const workflowTaskId = d.taskRegistry?.mintTaskId("workflow");
|
|
820
|
+
const launchRunId = workflowTaskId ?? (resumeFromRunId !== undefined ? randomUUID() : undefined);
|
|
821
|
+
const yieldIntent = d.taskRegistry !== undefined && d.store !== undefined && parkStore !== undefined ? new AbortController() : undefined;
|
|
822
|
+
const autoModeReview = ctx.autoModeReview ?? d.autoModeReview?.();
|
|
823
|
+
const agentStations = ctx.agentStations ?? d.agentStations?.();
|
|
824
|
+
const centerFromCtx = ctx.centerArtifactDigest !== undefined;
|
|
825
|
+
const parentCenterArtifactDigest = centerFromCtx ? ctx.centerArtifactDigest : d.parentCenterArtifactDigest?.();
|
|
826
|
+
const parentCenterSourceRevision = centerFromCtx ? ctx.centerSourceRevision : d.parentCenterSourceRevision?.();
|
|
827
|
+
let continuationClaim;
|
|
828
|
+
let continuationDecisions = continuation?.decisions;
|
|
829
|
+
const releaseContinuationClaim = () => {
|
|
830
|
+
if (continuationClaim !== undefined && d.journalStore !== undefined)
|
|
831
|
+
void releaseWorkflowResumeClaim(d.journalStore, continuationClaim.args, continuationClaim.fallback);
|
|
832
|
+
};
|
|
833
|
+
if (resumeFromRunId !== undefined && claimKey !== undefined && d.journalStore !== undefined && launchRunId !== undefined) {
|
|
834
|
+
const journal = d.journalStore;
|
|
835
|
+
const args = { sourceRunId: claimKey, newRunId: launchRunId, scope: resumeScope };
|
|
836
|
+
let verdict;
|
|
518
837
|
try {
|
|
519
|
-
|
|
520
|
-
store: d.store,
|
|
521
|
-
...(d.taskArtifacts !== undefined ? { taskArtifacts: d.taskArtifacts } : {}),
|
|
522
|
-
...(parkStore !== undefined ? { checkpointStore: parkStore } : {}),
|
|
523
|
-
...(d.agents !== undefined ? { agents: d.agents } : {}),
|
|
524
|
-
...(d.builtinAgents !== undefined ? { builtinAgents: d.builtinAgents } : {}),
|
|
525
|
-
name: meta.name,
|
|
526
|
-
...(meta.description !== undefined ? { description: meta.description } : {}),
|
|
527
|
-
...(meta.phases !== undefined ? { phases: meta.phases } : {}),
|
|
528
|
-
...(effectiveArgs !== undefined ? { effectiveArgs } : {}),
|
|
529
|
-
...(sourceTaskId !== undefined ? { sourceTaskId } : {}),
|
|
530
|
-
...(d.originatingSessionId !== undefined ? { originatingSessionId: d.originatingSessionId } : {}),
|
|
531
|
-
...((ctx.rootSessionId ?? d.rootSessionId ?? d.originatingSessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? d.rootSessionId ?? d.originatingSessionId } : {}),
|
|
532
|
-
...rootOccupantSeat(ctx.rootSessionId ?? d.rootSessionId ?? d.originatingSessionId, ctx, d),
|
|
533
|
-
...((ctx.placementRoot ?? d.placementRoot) !== undefined ? { placementRoot: ctx.placementRoot ?? d.placementRoot } : {}),
|
|
534
|
-
...((ctx.placementTarget ?? d.placementTarget) !== undefined ? { placementTarget: ctx.placementTarget ?? d.placementTarget } : {}),
|
|
535
|
-
...((ctx.crossBoundaryTreeForChildren ?? d.crossBoundaryTree) !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren ?? d.crossBoundaryTree } : {}),
|
|
536
|
-
...((ctx.delegationOwner ?? d.delegationOwner) !== undefined ? { delegationOwner: ctx.delegationOwner ?? d.delegationOwner } : {}),
|
|
537
|
-
...(workflowTaskId !== undefined ? { runId: workflowTaskId } : {}),
|
|
538
|
-
...(yieldIntent !== undefined ? { preemptSignal: yieldIntent.signal } : {}),
|
|
539
|
-
journalStore: d.journalStore,
|
|
540
|
-
...(resumeFromRunId !== undefined ? { resumeFromRunId } : {}),
|
|
541
|
-
...(d.onBackgroundChildEvent !== undefined ? { onBackgroundChildEvent: d.onBackgroundChildEvent } : {}),
|
|
542
|
-
scope: taskScope ?? d.scope,
|
|
543
|
-
budget: lim.budget,
|
|
544
|
-
maxAgents: lim.maxAgents ?? DEFAULTS.maxAgents,
|
|
545
|
-
totalTimeoutMs: lim.totalTimeoutMs ?? DEFAULTS.totalTimeoutMs,
|
|
546
|
-
maxResultChars: lim.maxResultChars ?? DEFAULTS.maxResultChars,
|
|
547
|
-
maxLogChars: lim.maxLogChars ?? DEFAULTS.maxLogChars,
|
|
548
|
-
...(d.parentCwd !== undefined ? { parentCwd: d.parentCwd } : {}),
|
|
549
|
-
...(d.callerRoot !== undefined ? { callerRoot: d.callerRoot } : {}),
|
|
550
|
-
parentToolCallId: ctx.toolCallId,
|
|
551
|
-
...(sourceTaskId !== undefined ? { parentTaskId: sourceTaskId } : {}),
|
|
552
|
-
...((ctx.interactionPosture ?? d.parentInteractionPosture) !== undefined ? { interactionPosture: (ctx.interactionPosture ?? d.parentInteractionPosture) } : {}),
|
|
553
|
-
...(() => {
|
|
554
|
-
if ("memoryCaptureOptedOut" in ctx) {
|
|
555
|
-
return {
|
|
556
|
-
parentMemoryCaptureState: () => {
|
|
557
|
-
const o = ctx.memoryCaptureOptedOut ?? false;
|
|
558
|
-
const i = ctx.memoryCaptureIndeterminate ?? false;
|
|
559
|
-
const build = (optedOut, indeterminate) => ({
|
|
560
|
-
optedOut: optedOut === true,
|
|
561
|
-
indeterminate: indeterminate === true,
|
|
562
|
-
...(ctx.memoryCaptureControlDir !== undefined ? { controlDir: ctx.memoryCaptureControlDir } : {}),
|
|
563
|
-
...(ctx.memoryCaptureAncestors !== undefined ? { ancestors: ctx.memoryCaptureAncestors } : {}),
|
|
564
|
-
});
|
|
565
|
-
return o instanceof Promise || i instanceof Promise ? Promise.all([o, i]).then(([ov, iv]) => build(ov, iv)) : build(o, i);
|
|
566
|
-
},
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
return d.parentMemoryCaptureState !== undefined ? { parentMemoryCaptureState: d.parentMemoryCaptureState } : {};
|
|
570
|
-
})(),
|
|
571
|
-
...(d.parentModel !== undefined ? { defaultModel: d.parentModel } : {}),
|
|
572
|
-
...(d.parentThinking !== undefined ? { defaultThinking: d.parentThinking } : {}),
|
|
573
|
-
...(d.parentGetApiKeyAndHeaders !== undefined ? { defaultGetApiKeyAndHeaders: d.parentGetApiKeyAndHeaders } : {}),
|
|
574
|
-
...(parentSpecSeat !== undefined ? { parentSpecSeat } : {}),
|
|
575
|
-
...(detachedSeat?.internalsFlag.questionFaceStripped === true || ctx.questionFaceStripped === true || d.parentQuestionFaceStripped === true ? { questionFaceStripped: true } : {}),
|
|
576
|
-
...(hostDurableApproval !== undefined && d.store !== undefined && parkStore !== undefined ? { defaultDurableApproval: { ...hostDurableApproval } } : {}),
|
|
577
|
-
...(resumeFromRunId !== undefined && d.parkedResume !== undefined && d.parkedResume(resumeFromRunId) !== undefined ? { parkedResume: d.parkedResume(resumeFromRunId) } : {}),
|
|
578
|
-
...(d.holder !== undefined ? { holder: d.holder } : {}),
|
|
579
|
-
...(parentCenterArtifactDigest !== undefined ? { parentCenterArtifactDigest } : {}),
|
|
580
|
-
...(parentCenterSourceRevision !== undefined ? { parentCenterSourceRevision } : {}),
|
|
581
|
-
...((ctx.forwardEvent ?? d.forwardEvent) !== undefined ? { onForwardEvent: (ctx.forwardEvent ?? d.forwardEvent) } : {}),
|
|
582
|
-
...((ctx.inheritedGateForChildren ?? d.inheritedGateForChildren) !== undefined
|
|
583
|
-
? { inheritedGate: (ctx.inheritedGateForChildren ?? d.inheritedGateForChildren)() }
|
|
584
|
-
: {}),
|
|
585
|
-
...(autoModeReview !== undefined ? { autoModeReview } : {}),
|
|
586
|
-
...(agentStations !== undefined ? { agentStations } : {}),
|
|
587
|
-
}, { workflowDepth: d.workflowDepth, ...((ctx.toolSelector?.layers ?? d.parentToolCeiling) !== undefined ? { toolCeiling: (ctx.toolSelector?.layers ?? d.parentToolCeiling) } : {}), ...((ctx.mcpPool ?? d.parentMcpPool) !== undefined ? { mcpPool: (ctx.mcpPool ?? d.parentMcpPool) } : {}) });
|
|
838
|
+
verdict = await claimWithin(takeWorkflowResumeClaim(journal, args), (late) => void (late.granted ? releaseWorkflowResumeClaim(journal, args, late.fallback) : undefined));
|
|
588
839
|
}
|
|
589
840
|
catch (err) {
|
|
590
|
-
|
|
841
|
+
reportStoreFault?.(`the ${continuation !== undefined ? "continuation" : "resume"}'s resume claim on workflow run ${JSON.stringify(resumeFromRunId)} could not be taken`, err);
|
|
842
|
+
return structuredError(`the ${continuation !== undefined ? "continuation" : "resume"}'s resume claim could not be taken (the journal store threw ${storeErrorClassOf(err)}) — not started`);
|
|
591
843
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
toolUseId: ctx.toolCallId,
|
|
601
|
-
...(taskOwner !== undefined ? { owner: taskOwner } : {}),
|
|
602
|
-
...(taskScope !== undefined ? { scope: taskScope } : {}),
|
|
603
|
-
...(d.originatingSessionId !== undefined ? { originatingSessionId: d.originatingSessionId } : {}),
|
|
604
|
-
...(yieldIntent !== undefined ? { yieldIntent } : {}),
|
|
605
|
-
});
|
|
844
|
+
if (verdict === "timeout")
|
|
845
|
+
return structuredError(`the ${continuation !== undefined ? "continuation" : "resume"}'s resume claim was not answered within ${WORKFLOW_STORE_WAIT_BOUND_MS}ms — not started`);
|
|
846
|
+
if (!verdict.granted) {
|
|
847
|
+
const held = claimHeldOf(verdict);
|
|
848
|
+
if (continuation === undefined)
|
|
849
|
+
return structuredError(notContinuedRefusalOf(resumeFromRunId, "continuing_elsewhere", { ...held, decisionIds: heldDecisionIds }));
|
|
850
|
+
continuation.onClaimHeld(held);
|
|
851
|
+
return structuredError("another run already holds this run's resume claim — not started");
|
|
606
852
|
}
|
|
607
|
-
|
|
608
|
-
if (
|
|
853
|
+
continuationClaim = { args, fallback: verdict.fallback };
|
|
854
|
+
if (continuation === undefined) {
|
|
855
|
+
let again;
|
|
609
856
|
try {
|
|
610
|
-
|
|
857
|
+
again = await modelLineRefusal();
|
|
611
858
|
}
|
|
612
859
|
catch {
|
|
860
|
+
again = `the records of workflow run "${inlineUntrusted(resumeFromRunId, 64)}"'s workflow could not be read — not started`;
|
|
861
|
+
}
|
|
862
|
+
if (typeof again === "string") {
|
|
863
|
+
releaseContinuationClaim();
|
|
864
|
+
return structuredError(again);
|
|
613
865
|
}
|
|
614
866
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
867
|
+
else {
|
|
868
|
+
let confirmed;
|
|
869
|
+
try {
|
|
870
|
+
confirmed = await continuation.confirm();
|
|
871
|
+
}
|
|
872
|
+
catch {
|
|
873
|
+
confirmed = false;
|
|
874
|
+
}
|
|
875
|
+
if (confirmed === false) {
|
|
876
|
+
releaseContinuationClaim();
|
|
877
|
+
continuation.onSuperseded();
|
|
878
|
+
return structuredError("the approval card changed while this continuation waited for its resume claim — not started");
|
|
879
|
+
}
|
|
880
|
+
continuationDecisions = confirmed;
|
|
881
|
+
}
|
|
882
|
+
if (ctx.signal?.aborted) {
|
|
883
|
+
releaseContinuationClaim();
|
|
884
|
+
return structuredError("the launching tool call was aborted before the workflow could start — not started");
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
try {
|
|
888
|
+
handle = startWorkflow(d.runner, scriptFn, {
|
|
889
|
+
store: d.store,
|
|
890
|
+
...(d.taskArtifacts !== undefined ? { taskArtifacts: d.taskArtifacts } : {}),
|
|
891
|
+
...(parkStore !== undefined ? { checkpointStore: parkStore } : {}),
|
|
892
|
+
...(agents !== undefined ? { agents } : {}),
|
|
893
|
+
...(d.builtinAgents !== undefined ? { builtinAgents: d.builtinAgents } : {}),
|
|
894
|
+
name: meta.name,
|
|
895
|
+
...(meta.description !== undefined ? { description: meta.description } : {}),
|
|
896
|
+
...(meta.phases !== undefined ? { phases: meta.phases } : {}),
|
|
897
|
+
...((record) => ({
|
|
898
|
+
...(journalKeepsLaunches(d.journalStore) ? { launch: record } : {}),
|
|
899
|
+
hostFoldDigest: () => workflowHostFoldDigest(hostFoldOf(ctx, parentSpecSeat, hostOnAsk, inheritedOf(record))),
|
|
900
|
+
}))({ script, ...(effectiveArgs !== undefined ? { effectiveArgs } : {}), callArgs, host: workflowHostIdentityOf(hostFold), face: hostFold.face }),
|
|
901
|
+
...(sourceTaskId !== undefined ? { sourceTaskId } : {}),
|
|
902
|
+
...(d.originatingSessionId !== undefined ? { originatingSessionId: d.originatingSessionId } : {}),
|
|
903
|
+
...((ctx.rootSessionId ?? d.rootSessionId ?? d.originatingSessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? d.rootSessionId ?? d.originatingSessionId } : {}),
|
|
904
|
+
...rootOccupantSeat(ctx.rootSessionId ?? d.rootSessionId ?? d.originatingSessionId, ctx, d),
|
|
905
|
+
...((ctx.placementRoot ?? d.placementRoot) !== undefined ? { placementRoot: ctx.placementRoot ?? d.placementRoot } : {}),
|
|
906
|
+
...((ctx.placementTarget ?? d.placementTarget) !== undefined ? { placementTarget: ctx.placementTarget ?? d.placementTarget } : {}),
|
|
907
|
+
...((ctx.crossBoundaryTreeForChildren ?? d.crossBoundaryTree) !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren ?? d.crossBoundaryTree } : {}),
|
|
908
|
+
...((ctx.delegationOwner ?? d.delegationOwner) !== undefined ? { delegationOwner: ctx.delegationOwner ?? d.delegationOwner } : {}),
|
|
909
|
+
...(launchRunId !== undefined ? { runId: launchRunId } : {}),
|
|
910
|
+
...(yieldIntent !== undefined ? { preemptSignal: yieldIntent.signal } : {}),
|
|
911
|
+
journalStore: d.journalStore,
|
|
912
|
+
...(resumeFromRunId !== undefined ? { resumeFromRunId } : {}),
|
|
913
|
+
...(d.onBackgroundChildEvent !== undefined ? { onBackgroundChildEvent: d.onBackgroundChildEvent } : {}),
|
|
914
|
+
scope: taskScope ?? d.scope,
|
|
915
|
+
budget: lim.budget,
|
|
916
|
+
maxAgents: lim.maxAgents ?? DEFAULTS.maxAgents,
|
|
917
|
+
totalTimeoutMs: lim.totalTimeoutMs ?? DEFAULTS.totalTimeoutMs,
|
|
918
|
+
maxResultChars: lim.maxResultChars ?? DEFAULTS.maxResultChars,
|
|
919
|
+
maxLogChars: lim.maxLogChars ?? DEFAULTS.maxLogChars,
|
|
920
|
+
...(d.parentCwd !== undefined ? { parentCwd: d.parentCwd } : {}),
|
|
921
|
+
...(d.callerRoot !== undefined ? { callerRoot: d.callerRoot } : {}),
|
|
922
|
+
parentToolCallId: ctx.toolCallId,
|
|
923
|
+
...(sourceTaskId !== undefined ? { parentTaskId: sourceTaskId } : {}),
|
|
924
|
+
...((ctx.interactionPosture ?? d.parentInteractionPosture) !== undefined ? { interactionPosture: (ctx.interactionPosture ?? d.parentInteractionPosture) } : {}),
|
|
925
|
+
...(() => {
|
|
926
|
+
if ("memoryCaptureOptedOut" in ctx) {
|
|
927
|
+
return {
|
|
928
|
+
parentMemoryCaptureState: () => {
|
|
929
|
+
const o = ctx.memoryCaptureOptedOut ?? false;
|
|
930
|
+
const i = ctx.memoryCaptureIndeterminate ?? false;
|
|
931
|
+
const build = (optedOut, indeterminate) => ({
|
|
932
|
+
optedOut: optedOut === true,
|
|
933
|
+
indeterminate: indeterminate === true,
|
|
934
|
+
...(ctx.memoryCaptureControlDir !== undefined ? { controlDir: ctx.memoryCaptureControlDir } : {}),
|
|
935
|
+
...(ctx.memoryCaptureAncestors !== undefined ? { ancestors: ctx.memoryCaptureAncestors } : {}),
|
|
936
|
+
});
|
|
937
|
+
return o instanceof Promise || i instanceof Promise ? Promise.all([o, i]).then(([ov, iv]) => build(ov, iv)) : build(o, i);
|
|
938
|
+
},
|
|
939
|
+
};
|
|
626
940
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
941
|
+
return d.parentMemoryCaptureState !== undefined ? { parentMemoryCaptureState: d.parentMemoryCaptureState } : {};
|
|
942
|
+
})(),
|
|
943
|
+
...(hostFold.model !== undefined ? { defaultModel: hostFold.model } : {}),
|
|
944
|
+
...(hostFold.thinking !== undefined ? { defaultThinking: hostFold.thinking } : {}),
|
|
945
|
+
...(d.parentGetApiKeyAndHeaders !== undefined ? { defaultGetApiKeyAndHeaders: d.parentGetApiKeyAndHeaders } : {}),
|
|
946
|
+
...(parentSpecSeat !== undefined ? { parentSpecSeat } : {}),
|
|
947
|
+
...(detachedSeat?.internalsFlag.questionFaceStripped === true || ctx.questionFaceStripped === true || d.parentQuestionFaceStripped === true ? { questionFaceStripped: true } : {}),
|
|
948
|
+
...(hostDurableApproval !== undefined && d.store !== undefined && parkStore !== undefined && journalKeepsLaunches(d.journalStore) ? { defaultDurableApproval: { ...hostDurableApproval } } : {}),
|
|
949
|
+
...(() => {
|
|
950
|
+
const carried = continuation !== undefined ? continuationDecisions : held !== undefined && "decisions" in held ? held.decisions : undefined;
|
|
951
|
+
return carried !== undefined && carried.length > 0 ? { parkedResume: carried.map((e) => ({ ...e })) } : {};
|
|
952
|
+
})(),
|
|
953
|
+
...(d.holder !== undefined ? { holder: d.holder } : {}),
|
|
954
|
+
...(parentCenterArtifactDigest !== undefined ? { parentCenterArtifactDigest } : {}),
|
|
955
|
+
...(parentCenterSourceRevision !== undefined ? { parentCenterSourceRevision } : {}),
|
|
956
|
+
...((ctx.forwardEvent ?? d.forwardEvent) !== undefined ? { onForwardEvent: (ctx.forwardEvent ?? d.forwardEvent) } : {}),
|
|
957
|
+
...((ctx.inheritedGateForChildren ?? d.inheritedGateForChildren) !== undefined
|
|
958
|
+
? { inheritedGate: (ctx.inheritedGateForChildren ?? d.inheritedGateForChildren)() }
|
|
959
|
+
: {}),
|
|
960
|
+
...(autoModeReview !== undefined ? { autoModeReview } : {}),
|
|
961
|
+
...(agentStations !== undefined ? { agentStations } : {}),
|
|
962
|
+
}, { workflowDepth: d.workflowDepth, launchingTool: tool, ...((ctx.toolSelector?.layers ?? d.parentToolCeiling) !== undefined ? { toolCeiling: (ctx.toolSelector?.layers ?? d.parentToolCeiling) } : {}) });
|
|
963
|
+
}
|
|
964
|
+
catch (err) {
|
|
965
|
+
releaseContinuationClaim();
|
|
966
|
+
return structuredError(thrownText(err));
|
|
967
|
+
}
|
|
968
|
+
if (continuationClaim !== undefined)
|
|
969
|
+
void handle.done.then(releaseContinuationClaim, releaseContinuationClaim);
|
|
970
|
+
const runId = handle.runId;
|
|
971
|
+
if (d.taskRegistry) {
|
|
972
|
+
const taskOwner = ctx.taskId ?? d.taskOwner ?? d.sourceTaskId;
|
|
973
|
+
d.taskRegistry.registerWorkflow({
|
|
974
|
+
runId,
|
|
975
|
+
handle,
|
|
976
|
+
store: d.store,
|
|
977
|
+
description: meta.name ?? meta.description,
|
|
978
|
+
toolUseId: ctx.toolCallId,
|
|
979
|
+
...(taskOwner !== undefined ? { owner: taskOwner } : {}),
|
|
980
|
+
...(taskScope !== undefined ? { scope: taskScope } : {}),
|
|
981
|
+
...(d.originatingSessionId !== undefined ? { originatingSessionId: d.originatingSessionId } : {}),
|
|
982
|
+
...(yieldIntent !== undefined ? { yieldIntent } : {}),
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
let persistedScriptPath;
|
|
986
|
+
if (continuation === undefined && d.scriptStore && d.scriptStore.scopePartitioned === true) {
|
|
987
|
+
const store = d.scriptStore;
|
|
988
|
+
persistedScriptPath = await new Promise((resolve) => {
|
|
989
|
+
const t = setTimeout(() => resolve(undefined), WORKFLOW_STORE_WAIT_BOUND_MS);
|
|
990
|
+
Promise.resolve()
|
|
991
|
+
.then(() => store.persist(runId, script, taskScope ?? "default"))
|
|
992
|
+
.then((path) => (clearTimeout(t), resolve(path)), () => (clearTimeout(t), resolve(undefined)));
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
oweTerminalDelivery(completionSink, { task_id: runId, task_type: "workflow" });
|
|
996
|
+
{
|
|
997
|
+
let notified = false;
|
|
998
|
+
const fire = (notification) => {
|
|
999
|
+
if (notified)
|
|
1000
|
+
return;
|
|
1001
|
+
notified = true;
|
|
1002
|
+
try {
|
|
1003
|
+
completionSink?.(notification, { priority: "next" });
|
|
1004
|
+
}
|
|
1005
|
+
catch {
|
|
1006
|
+
}
|
|
1007
|
+
if (!d.notifier)
|
|
1008
|
+
return;
|
|
1009
|
+
void Promise.resolve()
|
|
1010
|
+
.then(() => d.notifier.notify({
|
|
1011
|
+
runId,
|
|
1012
|
+
task_id: notification.task_id,
|
|
1013
|
+
task_type: "workflow",
|
|
1014
|
+
...(notification.toolUseId !== undefined ? { toolUseId: notification.toolUseId } : {}),
|
|
1015
|
+
sourceTaskId,
|
|
1016
|
+
...(d.originatingSessionId !== undefined ? { originatingSessionId: d.originatingSessionId } : {}),
|
|
1017
|
+
principal,
|
|
1018
|
+
status: notification.status === "completed" ? "completed" : "failed",
|
|
1019
|
+
summary: egressText("human", notification.summary),
|
|
1020
|
+
...(notification.result !== undefined ? { result: egressText("human", notification.result) } : {}),
|
|
1021
|
+
...(notification.usage !== undefined ? { usage: notification.usage } : {}),
|
|
1022
|
+
...(notification.diagnostics !== undefined ? { diagnostics: egressText("human", notification.diagnostics) } : {}),
|
|
1023
|
+
...(notification.completionId !== undefined ? { completionId: notification.completionId } : {}),
|
|
1024
|
+
}))
|
|
1025
|
+
.catch(() => { });
|
|
1026
|
+
};
|
|
1027
|
+
const recordOf = (run) => {
|
|
1028
|
+
const pickup = workflowRecordPickupOf(run.recordArtifact);
|
|
1029
|
+
if (pickup.ref !== undefined)
|
|
1030
|
+
d.taskRegistry?.recordArtifactRef(runId, pickup.ref, run.completionId);
|
|
1031
|
+
return workflowRecordTeach(run, pickup.line);
|
|
1032
|
+
};
|
|
1033
|
+
handle.done
|
|
1034
|
+
.then(async (res) => fire({
|
|
1035
|
+
task_id: runId,
|
|
1036
|
+
task_type: "workflow",
|
|
1037
|
+
...(ctx.toolCallId !== undefined ? { toolUseId: ctx.toolCallId } : {}),
|
|
1038
|
+
status: "completed",
|
|
1039
|
+
summary: completionSummary(meta.name, res.run) + continuedBeforeSentence(res.run),
|
|
1040
|
+
result: boundedRedactedSummary(res.result, 4000),
|
|
1041
|
+
usage: workflowUsageBlock(res.run),
|
|
1042
|
+
diagnostics: workflowDiagnostics(runId, journalLocatorOf(runId, res.run.scope), res.run.resume?.journalEntries === 0, recordOf(res.run)),
|
|
1043
|
+
completionId: res.run.completionId,
|
|
1044
|
+
}), async (err) => {
|
|
1045
|
+
let parts = {
|
|
1046
|
+
summary: failureSummary(undefined, runId),
|
|
1047
|
+
diagnostics: workflowDiagnostics(runId, undefined, undefined, workflowRecordPickupOf(undefined).line),
|
|
652
1048
|
};
|
|
653
|
-
|
|
654
|
-
|
|
1049
|
+
try {
|
|
1050
|
+
const failedRun = settledRunOf(handle.done);
|
|
1051
|
+
const record = failedRun !== undefined ? recordOf(failedRun) : workflowRecordPickupOf(undefined).line;
|
|
1052
|
+
const held = await heldStepOf(failedRun, d.store);
|
|
1053
|
+
const summary = failureSummary(err, runId, failedRun, held) + continuedBeforeSentence(failedRun);
|
|
1054
|
+
const settleId = failedRun?.completionId;
|
|
1055
|
+
parts = {
|
|
1056
|
+
summary,
|
|
1057
|
+
diagnostics: workflowDiagnostics(runId, undefined, undefined, record, held),
|
|
1058
|
+
...(settleId !== undefined ? { completionId: settleId } : {}),
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
catch {
|
|
1062
|
+
}
|
|
1063
|
+
fire({
|
|
655
1064
|
task_id: runId,
|
|
656
1065
|
task_type: "workflow",
|
|
657
1066
|
...(ctx.toolCallId !== undefined ? { toolUseId: ctx.toolCallId } : {}),
|
|
658
|
-
status: "
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
...(settleId !== undefined ? { completionId: settleId } : {}),
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
catch {
|
|
1067
|
+
status: "failed",
|
|
1068
|
+
...parts,
|
|
1069
|
+
});
|
|
1070
|
+
})
|
|
1071
|
+
.catch(() => { });
|
|
1072
|
+
}
|
|
1073
|
+
return {
|
|
1074
|
+
details: { type: "workflow-run", status: "backgrounded", workflowRunId: runId, task_id: runId },
|
|
1075
|
+
content: JSON.stringify({
|
|
1076
|
+
runId,
|
|
1077
|
+
task_id: runId,
|
|
1078
|
+
status: "started",
|
|
1079
|
+
...(persistedScriptPath !== undefined ? { scriptPath: persistedScriptPath } : {}),
|
|
1080
|
+
handling: `${launchReceiptNoQuoteClause(" (the ids above, and scriptPath when present)")} ${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE}`,
|
|
1081
|
+
note: (() => {
|
|
1082
|
+
const journalRef = journalLocatorOf(runId, taskScope ?? d.scope ?? "");
|
|
1083
|
+
const carries = ` The completion notification carries its result AND per-agent rows — read them${journalRef !== undefined ? ` (full journal: ${journalRef})` : ""} before assuming an empty or unexpected result.`;
|
|
1084
|
+
if (d.notifier) {
|
|
1085
|
+
return `The workflow runs asynchronously. You will be NOTIFIED when it completes (the notification carries the result). End your turn and wait — do not poll.${carries}`;
|
|
681
1086
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
1087
|
+
return `The workflow runs asynchronously. Its completion is delivered to this session (its next turn, if this one has ended) — end your turn and wait.${carries}`;
|
|
1088
|
+
})(),
|
|
1089
|
+
}),
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
registerWorkflowParkAdopter(tool, createWorkflowParkAdopter({
|
|
1093
|
+
decisions: d.parkedDecisions ?? [],
|
|
1094
|
+
scopeOf: (ctx) => callScopeOf(ctx, d) ?? "default",
|
|
1095
|
+
store: d.store,
|
|
1096
|
+
journalStore: d.journalStore,
|
|
1097
|
+
parkStoreOf: (ctx) => checkpointStoreOfSeat(ctx.checkpointStoreForChildren ?? d.parentCheckpointStore),
|
|
1098
|
+
hostFoldDigest: (ctx, launch) => workflowHostFoldDigest(adopterHostFold(ctx, launch)),
|
|
1099
|
+
chainToHand: (ctx) => (ctx.inheritedGateForChildren ?? d.inheritedGateForChildren)?.().parentConstraints,
|
|
1100
|
+
launch: async (decided, ctx, confirm) => {
|
|
1101
|
+
const claim = {};
|
|
1102
|
+
const continuation = { ...decided, onClaimHeld: (held) => void (claim.held = held), confirm, onSuperseded: () => void (claim.superseded = true) };
|
|
1103
|
+
const out = await launch({}, ctx, continuation);
|
|
1104
|
+
if (claim.held !== undefined)
|
|
1105
|
+
return { claimHeld: claim.held };
|
|
1106
|
+
if (claim.superseded === true)
|
|
1107
|
+
return { superseded: true };
|
|
1108
|
+
const details = typeof out === "object" && out !== null ? out : undefined;
|
|
1109
|
+
if (details?.isError === true || typeof details?.details?.workflowRunId !== "string")
|
|
1110
|
+
return { refused: launchRefusalText(details?.content) };
|
|
1111
|
+
return { runId: details.details.workflowRunId };
|
|
1112
|
+
},
|
|
1113
|
+
waitBoundMs: WORKFLOW_STORE_WAIT_BOUND_MS,
|
|
1114
|
+
...(reportStoreFault !== undefined ? { reportStoreFault } : {}),
|
|
1115
|
+
toolName: RUN_WORKFLOW_TOOL_NAME,
|
|
1116
|
+
holdForCall: (runId, toolCallId, held) => {
|
|
1117
|
+
heldForCall.set(carryKey(runId, toolCallId), held);
|
|
1118
|
+
},
|
|
1119
|
+
instructOnce: (decisionIds) => {
|
|
1120
|
+
const fresh = decisionIds.every((id) => !instructedDecisions.has(id));
|
|
1121
|
+
for (const id of decisionIds) {
|
|
1122
|
+
instructedDecisions.delete(id);
|
|
1123
|
+
instructedDecisions.add(id);
|
|
691
1124
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
...(persistedScriptPath !== undefined ? { scriptPath: persistedScriptPath } : {}),
|
|
699
|
-
handling: `${launchReceiptNoQuoteClause(" (the ids above, and scriptPath when present)")} ${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE}`,
|
|
700
|
-
note: (() => {
|
|
701
|
-
const journalRef = d.journalStore?.locator?.(runId, taskScope ?? d.scope ?? "");
|
|
702
|
-
const carries = ` The completion notification carries its result AND per-agent rows — read them${journalRef !== undefined ? ` (full journal: ${journalRef})` : ""} before assuming an empty or unexpected result.`;
|
|
703
|
-
if (d.notifier) {
|
|
704
|
-
return `The workflow runs asynchronously. You will be NOTIFIED when it completes (the notification carries the result). End your turn and wait — do not poll.${carries}`;
|
|
705
|
-
}
|
|
706
|
-
return `The workflow runs asynchronously. Its completion is delivered to this session (its next turn, if this one has ended) — end your turn and wait.${carries}`;
|
|
707
|
-
})(),
|
|
708
|
-
}),
|
|
709
|
-
};
|
|
1125
|
+
for (const oldest of instructedDecisions) {
|
|
1126
|
+
if (instructedDecisions.size <= INSTRUCTED_DECISIONS_MAX)
|
|
1127
|
+
break;
|
|
1128
|
+
instructedDecisions.delete(oldest);
|
|
1129
|
+
}
|
|
1130
|
+
return fresh;
|
|
710
1131
|
},
|
|
1132
|
+
}));
|
|
1133
|
+
const handed = [governance.baseline.base, governance.baseline.worktreeBase];
|
|
1134
|
+
return recordCarried(tool, {
|
|
1135
|
+
mcp: handed.flatMap((slot) => slot?.mcp ?? []),
|
|
1136
|
+
a2a: handed.flatMap((slot) => slot?.a2a ?? []),
|
|
1137
|
+
agents: [...(agents ?? []), ...handed.flatMap((slot) => slot?.agents ?? [])],
|
|
1138
|
+
tools: handed.flatMap((slot) => slot?.tools ?? []),
|
|
711
1139
|
});
|
|
712
1140
|
}
|