@sema-agent/core 7.66.0 → 7.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3498 -0
- package/LICENSE +2 -1
- package/dist/agents/agent-definition.js +2 -1
- package/dist/agents/agent-transcript-tool.d.ts +1 -1
- package/dist/agents/agent-transcript-tool.js +4 -3
- package/dist/agents/builtin-agents.d.ts +10 -7
- package/dist/agents/builtin-agents.js +1 -0
- package/dist/agents/cascade.d.ts +24 -11
- package/dist/agents/cascade.js +21 -9
- package/dist/agents/child-failure.d.ts +30 -0
- package/dist/agents/child-failure.js +25 -1
- package/dist/agents/composition-placement.d.ts +6 -2
- package/dist/agents/composition-placement.js +7 -3
- package/dist/agents/cross-session-envelope.d.ts +10 -1
- package/dist/agents/cross-session-envelope.js +6 -2
- package/dist/agents/cross-session-judge.d.ts +7 -1
- package/dist/agents/cross-session-judge.js +1 -0
- package/dist/agents/cumulative-stats.d.ts +36 -2
- package/dist/agents/cumulative-stats.js +44 -9
- package/dist/agents/delegation-registry-seat.js +2 -3
- package/dist/agents/inherited-tool-pool.d.ts +9 -4
- package/dist/agents/inherited-tool-pool.js +7 -1
- package/dist/agents/leg-label.d.ts +28 -0
- package/dist/agents/leg-label.js +9 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/list-agents-tool.js +4 -4
- package/dist/agents/org-delivery-gate.d.ts +129 -23
- package/dist/agents/org-delivery-gate.js +41 -20
- package/dist/agents/peer-held-queue.d.ts +15 -10
- package/dist/agents/peer-held-queue.js +47 -19
- package/dist/agents/peer-notice-route.js +2 -2
- package/dist/agents/peer-notices.d.ts +13 -2
- package/dist/agents/peer-notices.js +12 -2
- package/dist/agents/peer-session-drain.d.ts +65 -15
- package/dist/agents/peer-session-drain.js +198 -41
- package/dist/agents/read-inbox-tool.d.ts +3 -2
- package/dist/agents/read-inbox-tool.js +7 -5
- package/dist/agents/repair-loop.js +20 -16
- package/dist/agents/retain-ledger.d.ts +1 -1
- package/dist/agents/retain-ledger.js +2 -4
- package/dist/agents/root-session-lane.d.ts +27 -0
- package/dist/agents/root-session-lane.js +57 -0
- package/dist/agents/roster-store.js +1 -2
- package/dist/agents/send-message-tool.js +6 -4
- package/dist/agents/subagent.d.ts +20 -4
- package/dist/agents/subagent.js +218 -183
- package/dist/agents/tool-filter.d.ts +3 -10
- package/dist/agents/tool-filter.js +0 -13
- package/dist/agents/verifier-independence.d.ts +31 -0
- package/dist/agents/verifier-independence.js +23 -0
- package/dist/agents/verify.d.ts +23 -11
- package/dist/agents/verify.js +28 -12
- package/dist/agents/yield-adoption.d.ts +24 -0
- package/dist/agents/yield-adoption.js +84 -0
- package/dist/bench/metrics.d.ts +2 -2
- package/dist/brain/anthropic.d.ts +4 -2
- package/dist/brain/anthropic.js +49 -35
- package/dist/brain/brain-faces.d.ts +11 -0
- package/dist/brain/brain-faces.js +6 -0
- package/dist/brain/cache-retention.d.ts +2 -0
- package/dist/brain/cache-retention.js +9 -0
- package/dist/brain/circuit-breaker.js +51 -26
- package/dist/brain/errors.d.ts +15 -1
- package/dist/brain/errors.js +8 -0
- package/dist/brain/failover.d.ts +6 -0
- package/dist/brain/failover.js +52 -37
- package/dist/brain/media-degrade.d.ts +5 -0
- package/dist/brain/media-degrade.js +4 -0
- package/dist/brain/model-capability.d.ts +2 -1
- package/dist/brain/model-lane.d.ts +145 -0
- package/dist/brain/model-lane.js +444 -0
- package/dist/brain/open-responses.js +19 -22
- package/dist/brain/openai.js +23 -22
- package/dist/brain/provider-message.d.ts +9 -0
- package/dist/brain/provider-message.js +18 -0
- package/dist/brain/reasoning-request.d.ts +9 -7
- package/dist/brain/reasoning-request.js +9 -10
- package/dist/brain/reasoning.d.ts +47 -13
- package/dist/brain/reasoning.js +20 -10
- package/dist/brain/route-adjudicator.d.ts +8 -2
- package/dist/brain/route-adjudicator.js +35 -1
- package/dist/brain/route-conformance.js +17 -0
- package/dist/brain/routing.d.ts +2 -0
- package/dist/brain/routing.js +19 -8
- package/dist/brain/status-sink.d.ts +5 -4
- package/dist/brain/status-sink.js +2 -2
- package/dist/brain/stream-engine.js +8 -2
- package/dist/brain/stream-shared.d.ts +12 -0
- package/dist/brain/stream-shared.js +18 -0
- package/dist/brain/timeout.d.ts +28 -0
- package/dist/brain/timeout.js +13 -4
- package/dist/brain/tool-schema-projection.d.ts +2 -0
- package/dist/brain/tool-schema-projection.js +108 -0
- package/dist/brain/usage-reading.d.ts +49 -0
- package/dist/brain/usage-reading.js +44 -0
- package/dist/brain/usage-reasoning.d.ts +38 -0
- package/dist/brain/usage-reasoning.js +9 -0
- package/dist/config/catalog.d.ts +3 -0
- package/dist/config/catalog.js +18 -9
- package/dist/core/a2a.d.ts +22 -4
- package/dist/core/a2a.js +191 -50
- package/dist/core/agent-definition.d.ts +3 -1
- package/dist/core/agent-state.d.ts +29 -16
- package/dist/core/agent-state.js +36 -9
- package/dist/core/allow-entry.d.ts +12 -3
- package/dist/core/allow-entry.js +10 -3
- package/dist/core/approval-display.d.ts +18 -0
- package/dist/core/approval-display.js +26 -0
- package/dist/core/approval-object.js +2 -2
- package/dist/core/approval-route.d.ts +16 -0
- package/dist/core/approval-route.js +5 -0
- package/dist/core/approval-words.d.ts +43 -0
- package/dist/core/approval-words.js +37 -0
- package/dist/core/ask-origin.d.ts +37 -10
- package/dist/core/ask-origin.js +19 -7
- package/dist/core/ask-question.d.ts +36 -8
- package/dist/core/ask-question.js +24 -9
- package/dist/core/ask-unresolvable-notice.d.ts +3 -2
- package/dist/core/ask-unresolvable-notice.js +3 -2
- package/dist/core/attachment-source.d.ts +50 -0
- package/dist/core/attachment-source.js +46 -0
- package/dist/core/auto-compaction.d.ts +151 -40
- package/dist/core/auto-compaction.js +115 -50
- package/dist/core/auto-mode.d.ts +5 -0
- package/dist/core/auto-mode.js +11 -4
- package/dist/core/background-agent-store.d.ts +151 -23
- package/dist/core/background-agent-store.js +201 -61
- package/dist/core/background-shell.d.ts +4 -1
- package/dist/core/background-shell.js +1 -0
- package/dist/core/cache-break-detector.d.ts +49 -25
- package/dist/core/cache-break-detector.js +99 -44
- package/dist/core/caller-text.d.ts +28 -0
- package/dist/core/caller-text.js +12 -0
- package/dist/core/canonical-json.d.ts +5 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +80 -9
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-generation.d.ts +8 -1
- package/dist/core/checkpoint-generation.js +3 -0
- package/dist/core/checkpoint-queries.d.ts +47 -14
- package/dist/core/checkpoint-queries.js +63 -30
- package/dist/core/checkpoint-requirements.d.ts +36 -3
- package/dist/core/checkpoint-requirements.js +11 -1
- package/dist/core/checkpoint-row-verdict.d.ts +0 -2
- package/dist/core/checkpoint-row-verdict.js +5 -8
- package/dist/core/checkpoint-store.d.ts +166 -41
- package/dist/core/checkpoint-store.js +96 -15
- package/dist/core/child-clamp-seats.d.ts +10 -2
- package/dist/core/child-clamp-seats.js +2 -2
- package/dist/core/classifier-unavailable-arm.d.ts +11 -9
- package/dist/core/classifier-unavailable-arm.js +4 -2
- package/dist/core/command-sandbox-dispatch.d.ts +13 -0
- package/dist/core/command-sandbox-dispatch.js +8 -0
- package/dist/core/command-sandbox.d.ts +231 -0
- package/dist/core/command-sandbox.js +344 -0
- package/dist/core/completion-id.d.ts +21 -0
- package/dist/core/completion-id.js +14 -0
- package/dist/core/config-refusal-codes.d.ts +22 -0
- package/dist/core/config-refusal-codes.js +196 -0
- package/dist/core/context-edit.d.ts +26 -0
- package/dist/core/context-edit.js +4 -2
- package/dist/core/context-guard.d.ts +80 -7
- package/dist/core/context-guard.js +126 -25
- package/dist/core/context-settings.d.ts +32 -0
- package/dist/core/context-settings.js +41 -3
- package/dist/core/contract-faces.d.ts +22 -0
- package/dist/core/contract-faces.js +1 -0
- package/dist/core/credential-echo.d.ts +2 -2
- package/dist/core/credential-echo.js +2 -2
- package/dist/core/cross-boundary-taint.d.ts +10 -8
- package/dist/core/decision-receipt.d.ts +3 -2
- package/dist/core/decision-receipt.js +1 -1
- package/dist/core/definition-entry-grammar.d.ts +42 -0
- package/dist/core/definition-entry-grammar.js +15 -0
- package/dist/core/engine-attestation.d.ts +19 -4
- package/dist/core/engine-attestation.js +4 -0
- package/dist/core/engine-capabilities.d.ts +8 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-contracts/open-face-contract.d.ts +39 -0
- package/dist/core/engine-contracts/open-face-contract.js +57 -0
- package/dist/core/engine-notice.d.ts +161 -33
- package/dist/core/exclusive-temp.d.ts +25 -0
- package/dist/core/exclusive-temp.js +19 -0
- package/dist/core/existing-target.d.ts +112 -0
- package/dist/core/existing-target.js +88 -0
- package/dist/core/file-history-store.d.ts +14 -6
- package/dist/core/gate-lanes.js +8 -3
- package/dist/core/gate-outcome.d.ts +2 -1
- package/dist/core/git-worktree-env.d.ts +92 -1
- package/dist/core/git-worktree-env.js +87 -6
- package/dist/core/governance-codes.d.ts +49 -8
- package/dist/core/governance-codes.js +59 -8
- package/dist/core/hands-band.d.ts +10 -6
- package/dist/core/hooks.d.ts +60 -6
- package/dist/core/hooks.js +10 -2
- package/dist/core/host-floor.d.ts +24 -8
- package/dist/core/host-floor.js +45 -16
- package/dist/core/human-input-projection.d.ts +7 -0
- package/dist/core/human-input-projection.js +11 -3
- package/dist/core/image-admission.d.ts +16 -4
- package/dist/core/image-admission.js +29 -17
- package/dist/core/input-author.d.ts +43 -1
- package/dist/core/input-author.js +19 -0
- package/dist/core/isolation-scope.d.ts +41 -0
- package/dist/core/isolation-scope.js +10 -0
- package/dist/core/json-schema-seats.d.ts +11 -0
- package/dist/core/json-schema-seats.js +5 -0
- package/dist/core/leg-identity.d.ts +53 -5
- package/dist/core/leg-identity.js +32 -1
- package/dist/core/locked-config.d.ts +33 -38
- package/dist/core/locked-config.js +21 -3
- package/dist/core/lsp.js +2 -1
- package/dist/core/mailbox-store.d.ts +111 -18
- package/dist/core/mailbox-store.js +101 -13
- package/dist/core/mcp-call-meta.js +1 -1
- package/dist/core/mcp-connection-pool.d.ts +8 -2
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +6 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-host-read.d.ts +293 -0
- package/dist/core/mcp-host-read.js +428 -0
- package/dist/core/mcp-server-link.d.ts +28 -6
- package/dist/core/mcp-server-link.js +35 -7
- package/dist/core/mcp-server-spec.d.ts +22 -29
- package/dist/core/mcp-server-spec.js +7 -14
- package/dist/core/mcp-server-unavailable-notice.d.ts +32 -0
- package/dist/core/mcp-server-unavailable-notice.js +15 -0
- package/dist/core/mcp-session-end.d.ts +5 -2
- package/dist/core/mcp-session-end.js +7 -2
- package/dist/core/mcp-tool-meta.d.ts +6 -0
- package/dist/core/mcp-tool-meta.js +1 -0
- package/dist/core/mcp.d.ts +54 -19
- package/dist/core/mcp.js +194 -241
- package/dist/core/memory-engine/committed-shadow-read.d.ts +16 -0
- package/dist/core/memory-engine/committed-shadow-read.js +21 -0
- package/dist/core/memory-engine/consolidation-driver.js +2 -1
- package/dist/core/memory-engine/consolidation.d.ts +3 -3
- package/dist/core/memory-engine/control-objects.d.ts +4 -3
- package/dist/core/memory-engine/control-objects.js +6 -4
- package/dist/core/memory-engine/delegation-settlement.d.ts +127 -25
- package/dist/core/memory-engine/delegation-settlement.js +145 -18
- package/dist/core/memory-engine/distiller.d.ts +2 -1
- package/dist/core/memory-engine/distiller.js +10 -5
- package/dist/core/memory-engine/dual-root.js +2 -2
- package/dist/core/memory-engine/engine.d.ts +127 -33
- package/dist/core/memory-engine/engine.js +774 -323
- package/dist/core/memory-engine/entry-scan.d.ts +3 -0
- package/dist/core/memory-engine/entry-scan.js +8 -0
- package/dist/core/memory-engine/export-bundle.d.ts +4 -0
- package/dist/core/memory-engine/export-bundle.js +2 -0
- package/dist/core/memory-engine/file-backend.d.ts +62 -17
- package/dist/core/memory-engine/file-backend.js +155 -99
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layer-observations.d.ts +7 -1
- package/dist/core/memory-engine/layer-observations.js +6 -0
- package/dist/core/memory-engine/layout.d.ts +88 -26
- package/dist/core/memory-engine/layout.js +105 -29
- package/dist/core/memory-engine/memory-deployment.js +4 -4
- package/dist/core/memory-engine/mount-failed-notice.d.ts +24 -0
- package/dist/core/memory-engine/mount-failed-notice.js +22 -0
- package/dist/core/memory-engine/origin-clearance.d.ts +15 -1
- package/dist/core/memory-engine/origin-clearance.js +30 -10
- package/dist/core/memory-engine/scan.js +1 -1
- package/dist/core/memory-engine/scope-contract.js +4 -3
- package/dist/core/memory-engine/session-write-home.js +13 -1
- package/dist/core/memory-engine/sync-client.d.ts +1 -1
- package/dist/core/memory-engine/sync-client.js +3 -1
- package/dist/core/memory-engine/tools.d.ts +5 -4
- package/dist/core/memory-engine/tools.js +1 -1
- package/dist/core/memory-engine/types.d.ts +18 -1
- package/dist/core/memory-engine/types.js +1 -0
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/memory.js +2 -6
- package/dist/core/mode-policy.d.ts +8 -1
- package/dist/core/mode-policy.js +6 -2
- package/dist/core/model-fallbacks.d.ts +103 -0
- package/dist/core/model-fallbacks.js +79 -0
- package/dist/core/model-receipt.d.ts +15 -3
- package/dist/core/model-receipt.js +22 -1
- package/dist/core/model-seat.d.ts +1 -1
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/dollar.d.ts +47 -2
- package/dist/core/mods/dollar.js +28 -5
- package/dist/core/mods/kernel/budget.d.ts +6 -0
- package/dist/core/mods/kernel/budget.js +6 -0
- package/dist/core/mods/kernel/dispatch.d.ts +23 -2
- package/dist/core/mods/kernel/dispatch.js +104 -15
- package/dist/core/mods/kernel/events.d.ts +18 -1
- package/dist/core/mods/kernel/events.js +7 -6
- package/dist/core/mods/kernel/index.d.ts +2 -2
- package/dist/core/mods/kernel/index.js +1 -1
- package/dist/core/mods/kernel/receive.d.ts +2 -1
- package/dist/core/mods/lifecycle-stations.d.ts +13 -4
- package/dist/core/mods/lifecycle-stations.js +8 -3
- package/dist/core/mods/message-display.d.ts +81 -0
- package/dist/core/mods/message-display.js +369 -0
- package/dist/core/mods/prompt-submit.d.ts +1 -1
- package/dist/core/mods/prompt-submit.js +5 -2
- package/dist/core/mods/session-append.d.ts +2 -2
- package/dist/core/mods/session-append.js +2 -1
- package/dist/core/mods/session-compact.js +2 -2
- package/dist/core/mods/stations.d.ts +48 -18
- package/dist/core/mods/stations.js +100 -19
- package/dist/core/mods/stop-answers.d.ts +23 -0
- package/dist/core/mods/stop-answers.js +20 -0
- package/dist/core/mounted-mcp.d.ts +48 -8
- package/dist/core/mounted-mcp.js +82 -16
- package/dist/core/namespaced-rule-name.js +2 -1
- package/dist/core/own-property-receipt.js +3 -5
- package/dist/core/parent-spec-seat.d.ts +20 -1
- package/dist/core/parent-spec-seat.js +13 -3
- package/dist/core/park-selfcheck.js +1 -0
- package/dist/core/path-identity.js +2 -1
- package/dist/core/peer-seat.d.ts +21 -7
- package/dist/core/peer-seat.js +25 -16
- package/dist/core/permission-rule-consent.js +15 -5
- package/dist/core/permission-rule-model.d.ts +4 -2
- package/dist/core/permission-rule-model.js +43 -23
- package/dist/core/permission-rule-store.d.ts +31 -16
- package/dist/core/permission-rule-store.js +27 -18
- package/dist/core/present-plan-tool.d.ts +6 -1
- package/dist/core/present-plan-tool.js +11 -3
- package/dist/core/pricing.d.ts +8 -6
- package/dist/core/pricing.js +1 -1
- package/dist/core/principal-name.d.ts +13 -0
- package/dist/core/principal-name.js +9 -2
- package/dist/core/process-identity.d.ts +140 -0
- package/dist/core/process-identity.js +215 -0
- package/dist/core/protocol-http-auth.d.ts +28 -6
- package/dist/core/protocol-http-auth.js +22 -5
- package/dist/core/protocol-naming.d.ts +7 -0
- package/dist/core/protocol-naming.js +12 -2
- package/dist/core/protocol-revocation.d.ts +72 -0
- package/dist/core/protocol-revocation.js +98 -0
- package/dist/core/protocol-table.d.ts +4 -4
- package/dist/core/protocol-table.js +3 -2
- package/dist/core/push-queue.d.ts +35 -2
- package/dist/core/push-queue.js +60 -4
- package/dist/core/read-only-shell.d.ts +19 -0
- package/dist/core/read-only-shell.js +38 -11
- package/dist/core/real-approval.d.ts +26 -0
- package/dist/core/real-approval.js +15 -0
- package/dist/core/redaction-marks.d.ts +6 -2
- package/dist/core/redaction-marks.js +3 -0
- package/dist/core/reminder-mint.d.ts +6 -0
- package/dist/core/reminder-mint.js +9 -8
- package/dist/core/remote-env.d.ts +31 -15
- package/dist/core/remote-env.js +29 -0
- package/dist/core/request-copy-projection.d.ts +51 -0
- package/dist/core/request-copy-projection.js +410 -0
- package/dist/core/resume-config-judge.d.ts +69 -0
- package/dist/core/resume-config-judge.js +78 -0
- package/dist/core/resume-startup-cause.d.ts +14 -4
- package/dist/core/resume-startup-cause.js +12 -2
- package/dist/core/retention-policy.js +2 -1
- package/dist/core/retention.d.ts +119 -24
- package/dist/core/retention.js +60 -16
- package/dist/core/retired-keys.d.ts +0 -10
- package/dist/core/retired-keys.js +2 -3
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +65 -4
- package/dist/core/row-shape.d.ts +149 -0
- package/dist/core/row-shape.js +184 -0
- package/dist/core/runner/advertised-writable-dirs.js +10 -9
- package/dist/core/runner/advisor-instructions.d.ts +11 -27
- package/dist/core/runner/advisor-instructions.js +18 -20
- package/dist/core/runner/advisor-tool.js +1 -0
- package/dist/core/runner/announce-once-ledger.js +4 -1
- package/dist/core/runner/approval-feedback.d.ts +17 -8
- package/dist/core/runner/approval-feedback.js +18 -13
- package/dist/core/runner/approver-defect-announcer.d.ts +17 -0
- package/dist/core/runner/approver-defect-announcer.js +22 -0
- package/dist/core/runner/assemble-result.d.ts +29 -14
- package/dist/core/runner/assemble-result.js +16 -25
- package/dist/core/runner/cache-hit-account.d.ts +77 -0
- package/dist/core/runner/cache-hit-account.js +46 -0
- package/dist/core/runner/call-hook-stations.d.ts +3 -2
- package/dist/core/runner/call-hook-stations.js +5 -4
- package/dist/core/runner/changed-files-scan.d.ts +43 -0
- package/dist/core/runner/changed-files-scan.js +34 -0
- package/dist/core/runner/checkpoint-scope.d.ts +33 -9
- package/dist/core/runner/checkpoint-scope.js +27 -1
- package/dist/core/runner/classifier-ladder.d.ts +2 -2
- package/dist/core/runner/classifier-ladder.js +18 -9
- package/dist/core/runner/clock-and-limits.d.ts +15 -4
- package/dist/core/runner/clock-and-limits.js +19 -1
- package/dist/core/runner/compact-session.js +84 -14
- package/dist/core/runner/compaction-call-options.d.ts +2 -29
- package/dist/core/runner/compaction-call-options.js +2 -9
- package/dist/core/runner/compaction-restate.d.ts +18 -2
- package/dist/core/runner/compaction-restate.js +36 -2
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/context-room.d.ts +55 -0
- package/dist/core/runner/context-room.js +71 -0
- package/dist/core/runner/contracts.d.ts +313 -205
- package/dist/core/runner/conversation-segment.d.ts +49 -14
- package/dist/core/runner/conversation-segment.js +92 -19
- package/dist/core/runner/cross-boundary-lane.d.ts +4 -0
- package/dist/core/runner/cross-boundary-lane.js +9 -6
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/deferred-ask.d.ts +62 -0
- package/dist/core/runner/deferred-ask.js +44 -0
- package/dist/core/runner/delegation-owner.d.ts +19 -0
- package/dist/core/runner/delegation-owner.js +27 -1
- package/dist/core/runner/denial-limit-arms.d.ts +10 -6
- package/dist/core/runner/denial-limit-arms.js +13 -7
- package/dist/core/runner/env-capability-census.d.ts +1 -1
- package/dist/core/runner/file-history-request.js +2 -1
- package/dist/core/runner/file-history-restore.d.ts +16 -2
- package/dist/core/runner/file-history-restore.js +9 -1
- package/dist/core/runner/gate-exit.d.ts +18 -5
- package/dist/core/runner/gate-exit.js +26 -15
- package/dist/core/runner/git-status-frame.d.ts +26 -8
- package/dist/core/runner/git-status-frame.js +14 -9
- package/dist/core/runner/halt-attribution.d.ts +29 -12
- package/dist/core/runner/halt-attribution.js +38 -11
- package/dist/core/runner/image.js +3 -2
- package/dist/core/runner/initial-run-state.d.ts +1 -1
- package/dist/core/runner/initial-run-state.js +4 -4
- package/dist/core/runner/language-frame.d.ts +66 -0
- package/dist/core/runner/language-frame.js +76 -0
- package/dist/core/runner/leg-frame.d.ts +81 -0
- package/dist/core/runner/leg-frame.js +68 -0
- package/dist/core/runner/main-call-account.d.ts +34 -0
- package/dist/core/runner/main-call-account.js +50 -0
- package/dist/core/runner/mcp-redial.d.ts +9 -7
- package/dist/core/runner/mcp-redial.js +20 -21
- package/dist/core/runner/memory-consolidation-driver.d.ts +2 -0
- package/dist/core/runner/memory-consolidation-driver.js +5 -3
- package/dist/core/runner/messages-omitted-seat.d.ts +2 -0
- package/dist/core/runner/messages-omitted-seat.js +21 -0
- package/dist/core/runner/model-fallback-seat.d.ts +20 -0
- package/dist/core/runner/model-fallback-seat.js +43 -0
- package/dist/core/runner/model-lane-seat.d.ts +12 -0
- package/dist/core/runner/model-lane-seat.js +35 -0
- package/dist/core/runner/nested-memory-content.d.ts +33 -0
- package/dist/core/runner/nested-memory-content.js +171 -0
- package/dist/core/runner/nested-memory-lane.d.ts +181 -0
- package/dist/core/runner/nested-memory-lane.js +673 -0
- package/dist/core/runner/park-commit.d.ts +7 -0
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-advisor.d.ts +7 -9
- package/dist/core/runner/prepare-advisor.js +11 -5
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +8 -3
- package/dist/core/runner/prepare-ask-lane.d.ts +21 -3
- package/dist/core/runner/prepare-ask-lane.js +32 -28
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +21 -17
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +10 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +24 -18
- package/dist/core/runner/prepare-config-doors.d.ts +51 -5
- package/dist/core/runner/prepare-config-doors.js +73 -73
- package/dist/core/runner/prepare-context-lane.d.ts +68 -3
- package/dist/core/runner/prepare-context-lane.js +137 -27
- package/dist/core/runner/prepare-defer-classify.d.ts +0 -4
- package/dist/core/runner/prepare-defer-classify.js +9 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +8 -8
- package/dist/core/runner/prepare-delegation-surface.js +72 -64
- package/dist/core/runner/prepare-execution-env.js +1 -9
- package/dist/core/runner/prepare-file-history.d.ts +3 -2
- package/dist/core/runner/prepare-file-history.js +11 -4
- package/dist/core/runner/prepare-gate-stations.d.ts +21 -11
- package/dist/core/runner/prepare-gate-stations.js +13 -13
- package/dist/core/runner/prepare-hands-readface.d.ts +23 -6
- package/dist/core/runner/prepare-hands-readface.js +18 -12
- package/dist/core/runner/prepare-inherited-gate.d.ts +12 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -10
- package/dist/core/runner/prepare-lsp.js +2 -1
- package/dist/core/runner/prepare-memory-engine-session.js +30 -10
- package/dist/core/runner/prepare-memory.d.ts +4 -0
- package/dist/core/runner/prepare-memory.js +38 -16
- package/dist/core/runner/prepare-offload-wrappers.d.ts +3 -16
- package/dist/core/runner/prepare-offload-wrappers.js +6 -5
- package/dist/core/runner/prepare-park-ask.d.ts +13 -3
- package/dist/core/runner/prepare-park-ask.js +25 -19
- package/dist/core/runner/prepare-policy-chain.d.ts +17 -3
- package/dist/core/runner/prepare-policy-chain.js +144 -120
- package/dist/core/runner/prepare-project-context.d.ts +15 -53
- package/dist/core/runner/prepare-project-context.js +20 -83
- package/dist/core/runner/prepare-prompt-assembly.d.ts +7 -1
- package/dist/core/runner/prepare-prompt-assembly.js +9 -7
- package/dist/core/runner/prepare-prompt-inputs.d.ts +9 -3
- package/dist/core/runner/prepare-prompt-inputs.js +5 -3
- package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
- package/dist/core/runner/prepare-protocol-tools.js +46 -27
- package/dist/core/runner/prepare-question-face.d.ts +7 -6
- package/dist/core/runner/prepare-question-face.js +7 -6
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -0
- package/dist/core/runner/prepare-suspend-saga.js +1 -1
- package/dist/core/runner/prepare-task.d.ts +3 -3
- package/dist/core/runner/prepare-task.js +113 -61
- package/dist/core/runner/prepare-tool-disclosure-mount.js +6 -5
- package/dist/core/runner/prepare-turn-wiring.d.ts +33 -7
- package/dist/core/runner/prepare-turn-wiring.js +53 -17
- package/dist/core/runner/prepare-wiring-manifest.d.ts +42 -5
- package/dist/core/runner/prepare-wiring-manifest.js +81 -42
- package/dist/core/runner/prepare-workspace-restore.js +3 -2
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +31 -18
- package/dist/core/runner/reply-pricing.js +10 -15
- package/dist/core/runner/resume-admission.js +10 -15
- package/dist/core/runner/resume-apply.js +20 -9
- package/dist/core/runner/resume-checkpoint-screen.js +2 -4
- package/dist/core/runner/resume-internals-and-config.d.ts +12 -9
- package/dist/core/runner/resume-internals-and-config.js +37 -9
- package/dist/core/runner/resume-preflight.js +3 -3
- package/dist/core/runner/retired-runner-deps.js +3 -0
- package/dist/core/runner/rewind-files.js +6 -6
- package/dist/core/runner/run-attachment-seats.d.ts +1 -3
- package/dist/core/runner/run-attachment-seats.js +1 -6
- package/dist/core/runner/run-brain-sinks.d.ts +4 -7
- package/dist/core/runner/run-brain-sinks.js +7 -10
- package/dist/core/runner/run-clock-and-content.d.ts +8 -5
- package/dist/core/runner/run-clock-and-content.js +18 -3
- package/dist/core/runner/run-compaction-machinery.d.ts +8 -4
- package/dist/core/runner/run-compaction-machinery.js +4 -19
- package/dist/core/runner/run-git-lane.d.ts +8 -3
- package/dist/core/runner/run-git-lane.js +5 -3
- package/dist/core/runner/run-harness-handlers.d.ts +4 -1
- package/dist/core/runner/run-harness-handlers.js +70 -45
- package/dist/core/runner/run-identity-wiring.d.ts +6 -0
- package/dist/core/runner/run-identity-wiring.js +17 -8
- package/dist/core/runner/run-leg.d.ts +5 -2
- package/dist/core/runner/run-leg.js +156 -71
- package/dist/core/runner/run-notification-lane.d.ts +1 -1
- package/dist/core/runner/run-notification-lane.js +22 -10
- package/dist/core/runner/run-recovery-lanes.js +8 -6
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -0
- package/dist/core/runner/run-settle-and-teardown.js +77 -26
- package/dist/core/runner/run-stop-and-final-verify.js +46 -12
- package/dist/core/runner/run-telemetry-and-budget-seats.js +13 -28
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -2
- package/dist/core/runner/run-terminal-adoption.js +14 -9
- package/dist/core/runner/run-tool-mount-facts.js +5 -9
- package/dist/core/runner/run-turn-boundary.d.ts +3 -2
- package/dist/core/runner/run-turn-boundary.js +112 -106
- package/dist/core/runner/runtask.d.ts +28 -8
- package/dist/core/runner/runtask.js +132 -41
- package/dist/core/runner/session-file-state-replay.d.ts +5 -3
- package/dist/core/runner/session-file-state-replay.js +10 -3
- package/dist/core/runner/session-rule-policy.d.ts +3 -3
- package/dist/core/runner/session-verb-doors.d.ts +18 -3
- package/dist/core/runner/session-verb-doors.js +38 -6
- package/dist/core/runner/shell-env-withheld.d.ts +8 -5
- package/dist/core/runner/shell-env-withheld.js +4 -4
- package/dist/core/runner/side-call-account.d.ts +12 -8
- package/dist/core/runner/side-call-account.js +24 -15
- package/dist/core/runner/stream-halt-verbs.js +1 -0
- package/dist/core/runner/stream-mode-verb.js +2 -1
- package/dist/core/runner/stream-settle-backstop.js +4 -1
- package/dist/core/runner/stream-steer-verb.js +35 -19
- package/dist/core/runner/sub-agent-deny-lists.d.ts +47 -11
- package/dist/core/runner/sub-agent-deny-lists.js +140 -39
- package/dist/core/runner/teardown-bounded.d.ts +6 -0
- package/dist/core/runner/teardown-bounded.js +12 -7
- package/dist/core/runner/terminal-account.d.ts +2 -0
- package/dist/core/runner/terminal-account.js +6 -1
- package/dist/core/runner/tool-disclosure.js +2 -1
- package/dist/core/runner/tool-end-body.js +3 -1
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +1 -1
- package/dist/core/runner/tool-occurrence.d.ts +34 -9
- package/dist/core/runner/tool-occurrence.js +32 -21
- package/dist/core/runner/tool-progress-lane.d.ts +20 -5
- package/dist/core/runner/tool-progress-lane.js +27 -5
- package/dist/core/runner/tool-result-media-seat.d.ts +15 -4
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/tool-table-view.js +1 -1
- package/dist/core/runner/turn-attachments.d.ts +44 -71
- package/dist/core/runner/turn-attachments.js +52 -104
- package/dist/core/runner/usage-accounting.d.ts +3 -2
- package/dist/core/runner/usage-accounting.js +3 -2
- package/dist/core/runner/void-verifier-pause.js +1 -1
- package/dist/core/runner-deps.d.ts +42 -158
- package/dist/core/runtime-caps.d.ts +16 -4
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +46 -23
- package/dist/core/sensitive-path-policy.d.ts +8 -0
- package/dist/core/sensitive-path-policy.js +10 -2
- package/dist/core/session-checkout.d.ts +32 -27
- package/dist/core/session-checkout.js +109 -61
- package/dist/core/session-log-transfer.js +2 -1
- package/dist/core/session-policy-store.d.ts +24 -11
- package/dist/core/session-policy-store.js +11 -2
- package/dist/core/session-store.d.ts +16 -2
- package/dist/core/session-store.js +43 -17
- package/dist/core/session.d.ts +31 -3
- package/dist/core/session.js +33 -2
- package/dist/core/shell-run-candidates.d.ts +20 -8
- package/dist/core/shell-run-candidates.js +44 -21
- package/dist/core/side-query.d.ts +17 -5
- package/dist/core/side-query.js +17 -14
- package/dist/core/skill-grant.js +2 -3
- package/dist/core/skills-directory.js +3 -66
- package/dist/core/snapshot-frame-seat.d.ts +8 -0
- package/dist/core/snapshot-frame-seat.js +24 -0
- package/dist/core/steer-replay.d.ts +19 -3
- package/dist/core/steer-replay.js +8 -1
- package/dist/core/store-contracts/background-agent-store-contract.d.ts +17 -2
- package/dist/core/store-contracts/background-agent-store-contract.js +131 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +63 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +213 -3
- package/dist/core/store-contracts/permission-rule-write-contract.js +24 -0
- package/dist/core/store-contracts/session-deletion-cascade-contract.d.ts +15 -0
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +288 -0
- package/dist/core/store-contracts/session-policy-store-contract.js +57 -36
- package/dist/core/store-contracts/session-repo-contract.js +130 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/session-store-contract.js +17 -0
- package/dist/core/store-contracts/task-list-store-contract.d.ts +32 -0
- package/dist/core/store-contracts/task-list-store-contract.js +240 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +41 -0
- package/dist/core/stub-env.d.ts +2 -2
- package/dist/core/stub-env.js +1 -0
- package/dist/core/synthetic-read-verdict.d.ts +38 -28
- package/dist/core/synthetic-read-verdict.js +19 -28
- package/dist/core/task-event.d.ts +171 -19
- package/dist/core/task-intake.d.ts +26 -0
- package/dist/core/task-intake.js +31 -0
- package/dist/core/task-limits.d.ts +8 -6
- package/dist/core/task-notification.d.ts +88 -8
- package/dist/core/task-notification.js +45 -5
- package/dist/core/task-registry-agent.d.ts +24 -7
- package/dist/core/task-registry-agent.js +51 -28
- package/dist/core/task-registry-monitor.js +16 -14
- package/dist/core/task-registry-shared.d.ts +177 -35
- package/dist/core/task-registry-shared.js +44 -17
- package/dist/core/task-registry-workflow.js +8 -5
- package/dist/core/task-registry-yield.d.ts +32 -0
- package/dist/core/task-registry-yield.js +85 -0
- package/dist/core/task-registry.d.ts +88 -10
- package/dist/core/task-registry.js +124 -33
- package/dist/core/task-result.d.ts +115 -31
- package/dist/core/task-spec-members.d.ts +140 -1
- package/dist/core/task-spec-members.js +23 -8
- package/dist/core/task-spec.d.ts +181 -51
- package/dist/core/task-spec.js +1 -1
- package/dist/core/task-stream.d.ts +12 -2
- package/dist/core/terminal-cause.d.ts +12 -4
- package/dist/core/thrown-value.d.ts +49 -7
- package/dist/core/thrown-value.js +38 -2
- package/dist/core/tool-catalog-entries.js +13 -3
- package/dist/core/tool-data-door.d.ts +7 -0
- package/dist/core/tool-data-door.js +13 -0
- package/dist/core/tool-face-lists.d.ts +25 -0
- package/dist/core/tool-face-lists.js +38 -0
- package/dist/core/tool-face-reader.d.ts +0 -10
- package/dist/core/tool-face-reader.js +5 -3
- package/dist/core/tool-list-grammar.d.ts +103 -0
- package/dist/core/tool-list-grammar.js +130 -0
- package/dist/core/tool-mount-facts.d.ts +47 -0
- package/dist/core/tool-mount-facts.js +50 -0
- package/dist/core/tool-mount-plan.d.ts +196 -0
- package/dist/core/tool-mount-plan.js +404 -0
- package/dist/core/tool-mount-static.d.ts +12 -0
- package/dist/core/tool-mount-static.js +174 -0
- package/dist/core/tool-name-aliases.d.ts +60 -2
- package/dist/core/tool-name-aliases.js +22 -2
- package/dist/core/tool-name-list.d.ts +3 -0
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +246 -51
- package/dist/core/tool-policy.js +165 -71
- package/dist/core/tool-registry.d.ts +4 -11
- package/dist/core/tool-registry.js +0 -3
- package/dist/core/tool-result-bytes.d.ts +94 -0
- package/dist/core/tool-result-bytes.js +34 -0
- package/dist/core/tool-result-store.d.ts +97 -13
- package/dist/core/tool-result-store.js +52 -4
- package/dist/core/tool-roster.d.ts +71 -10
- package/dist/core/tool-roster.js +71 -21
- package/dist/core/tool-search-setting.d.ts +7 -9
- package/dist/core/tool-search-setting.js +23 -7
- package/dist/core/tool-spec.d.ts +32 -2
- package/dist/core/tools.js +6 -20
- package/dist/core/trace.d.ts +63 -11
- package/dist/core/trace.js +19 -0
- package/dist/core/types.d.ts +8 -6
- package/dist/core/types.js +3 -1
- package/dist/core/unmatched-tool-names.d.ts +37 -0
- package/dist/core/unmatched-tool-names.js +18 -0
- package/dist/core/untrusted-egress.d.ts +16 -5
- package/dist/core/untrusted-egress.js +202 -32
- package/dist/core/untrusted-text.d.ts +29 -8
- package/dist/core/untrusted-text.js +6 -3
- package/dist/core/user-attachment.d.ts +129 -35
- package/dist/core/user-attachment.js +124 -57
- package/dist/core/user-row-origin.d.ts +63 -0
- package/dist/core/user-row-origin.js +61 -0
- package/dist/core/wiring-manifest.d.ts +161 -39
- package/dist/core/wiring-manifest.js +42 -6
- package/dist/core/workflow-run-store-contract.d.ts +11 -1
- package/dist/core/workflow-run-store-contract.js +60 -7
- package/dist/core/workflow-run-store.d.ts +61 -12
- package/dist/core/workflow-run-store.js +100 -15
- package/dist/core/workspace-snapshot.d.ts +10 -14
- package/dist/core/workspace-snapshot.js +3 -22
- package/dist/core/write-protect.d.ts +3 -5
- package/dist/core/write-protect.js +2 -4
- package/dist/engine/compaction/compaction.d.ts +3 -0
- package/dist/engine/compaction/compaction.js +4 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +15 -4
- package/dist/engine/execution-env/node-execution-env.js +80 -27
- package/dist/engine/harness/agent-harness.d.ts +143 -27
- package/dist/engine/harness/agent-harness.js +162 -74
- package/dist/engine/harness/types.d.ts +84 -13
- package/dist/engine/harness/types.js +21 -1
- package/dist/engine/llm/tool-turns.d.ts +4 -0
- package/dist/engine/llm/tool-turns.js +7 -2
- package/dist/engine/llm/types.d.ts +111 -24
- package/dist/engine/llm/types.js +69 -5
- package/dist/engine/llm/validation.js +2 -1
- package/dist/engine/loop/agent-loop.d.ts +39 -6
- package/dist/engine/loop/agent-loop.js +172 -82
- package/dist/engine/loop/types.d.ts +43 -4
- package/dist/engine/lsp/node-lsp-manager.d.ts +5 -3
- package/dist/engine/lsp/node-lsp-manager.js +14 -10
- package/dist/engine/session/import-validate.js +9 -0
- package/dist/engine/session/memory-repo.d.ts +8 -1
- package/dist/engine/session/memory-repo.js +20 -12
- package/dist/engine/session/repo-utils.d.ts +10 -0
- package/dist/engine/session/repo-utils.js +11 -5
- package/dist/engine/session/row-cells.d.ts +32 -0
- package/dist/engine/session/row-cells.js +25 -0
- package/dist/index.d.ts +63 -34
- package/dist/index.js +44 -21
- package/dist/internal/harness.d.ts +8 -6
- package/dist/internal/harness.js +6 -4
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/governance-baseline-validity.d.ts +7 -0
- package/dist/orchestration/governance-baseline-validity.js +33 -9
- package/dist/orchestration/run-workflow-tool.d.ts +2 -0
- package/dist/orchestration/run-workflow-tool.js +25 -12
- package/dist/orchestration/workflow-governance.d.ts +19 -4
- package/dist/orchestration/workflow-governance.js +30 -9
- package/dist/orchestration/workflow-primitives.d.ts +4 -1
- package/dist/orchestration/workflow-primitives.js +2 -2
- package/dist/orchestration/workflow-script-runner.d.ts +1 -1
- package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
- package/dist/orchestration/workflow-types.d.ts +21 -12
- package/dist/orchestration/workflow-types.js +15 -4
- package/dist/orchestration/workflow.d.ts +37 -7
- package/dist/orchestration/workflow.js +81 -35
- package/dist/prompt-assembly/artifact-store.js +6 -9
- package/dist/prompt-assembly/assemble.d.ts +4 -10
- package/dist/prompt-assembly/assemble.js +1 -3
- package/dist/prompt-assembly/catalog/constitution.d.ts +0 -20
- package/dist/prompt-assembly/catalog/constitution.js +2 -0
- package/dist/prompt-assembly/catalog/core-behavior.js +5 -3
- package/dist/prompt-assembly/catalog/engine.d.ts +108 -0
- package/dist/prompt-assembly/catalog/engine.js +19 -0
- package/dist/prompt-assembly/catalog/environment.d.ts +276 -0
- package/dist/prompt-assembly/catalog/environment.js +61 -0
- package/dist/prompt-assembly/catalog/index.d.ts +9 -2
- package/dist/prompt-assembly/catalog/index.js +73 -2
- package/dist/prompt-assembly/catalog/locales/index.d.ts +16 -0
- package/dist/prompt-assembly/catalog/locales/index.js +22 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +124 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.d.ts +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +120 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.d.ts +8 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.js +442 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +15 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +50 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +163 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.d.ts +7 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +148 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/team.d.ts +6 -0
- package/dist/prompt-assembly/catalog/locales/zh-Hans/team.js +246 -0
- package/dist/prompt-assembly/catalog/role.js +3 -6
- package/dist/prompt-assembly/catalog/schema.d.ts +23 -1
- package/dist/prompt-assembly/catalog/schema.js +2 -0
- package/dist/prompt-assembly/composer.d.ts +6 -11
- package/dist/prompt-assembly/composer.js +7 -7
- package/dist/prompt-assembly/engine-text.d.ts +9 -0
- package/dist/prompt-assembly/engine-text.js +33 -0
- package/dist/prompt-assembly/event-registry.js +3 -3
- package/dist/prompt-assembly/explain.d.ts +1 -0
- package/dist/prompt-assembly/explain.js +1 -1
- package/dist/prompt-assembly/locale-review.d.ts +13 -0
- package/dist/prompt-assembly/locale-review.js +19 -0
- package/dist/prompt-assembly/overlay.d.ts +7 -3
- package/dist/prompt-assembly/overlay.js +27 -5
- package/dist/prompt-assembly/renderers.d.ts +4 -4
- package/dist/prompt-assembly/renderers.js +26 -17
- package/dist/prompt-assembly/role-base.d.ts +1 -1
- package/dist/prompt-assembly/select.d.ts +26 -5
- package/dist/prompt-assembly/select.js +25 -2
- package/dist/prompt-assembly/slots.d.ts +19 -0
- package/dist/prompt-assembly/slots.js +16 -0
- package/dist/prompt-assembly/sugar.d.ts +4 -7
- package/dist/prompt-assembly/sugar.js +1 -2
- package/dist/prompt-assembly/tool-catalog.d.ts +5 -1
- package/dist/prompt-assembly/tool-catalog.js +5 -1
- package/dist/prompt-assembly/turn-snapshot.d.ts +38 -10
- package/dist/prompt-assembly/turn-snapshot.js +43 -13
- package/dist/prompt-assembly/types.d.ts +3 -0
- package/dist/prompts/cowork.d.ts +6 -25
- package/dist/prompts/cowork.js +10 -12
- package/dist/prompts/default.d.ts +10 -32
- package/dist/prompts/default.js +37 -63
- package/dist/shell/lex.d.ts +39 -13
- package/dist/shell/lex.js +70 -30
- package/dist/stores/file/background-agent-store.d.ts +5 -0
- package/dist/stores/file/background-agent-store.js +35 -61
- package/dist/stores/file/checkpoint-store.d.ts +5 -3
- package/dist/stores/file/checkpoint-store.js +8 -10
- package/dist/stores/file/fs-atomic.d.ts +27 -70
- package/dist/stores/file/fs-atomic.js +52 -148
- package/dist/stores/file/index.d.ts +12 -0
- package/dist/stores/file/index.js +27 -2
- package/dist/stores/file/mailbox-store.d.ts +10 -1
- package/dist/stores/file/mailbox-store.js +40 -12
- package/dist/stores/file/permission-rule-adopt.js +5 -2
- package/dist/stores/file/permission-rule-store.d.ts +81 -20
- package/dist/stores/file/permission-rule-store.js +126 -33
- package/dist/stores/file/session-policy-store.d.ts +2 -2
- package/dist/stores/file/session-store.d.ts +21 -2
- package/dist/stores/file/session-store.js +27 -14
- package/dist/stores/file/task-list-store.js +23 -25
- package/dist/stores/file/tool-result-store.d.ts +45 -7
- package/dist/stores/file/tool-result-store.js +99 -36
- package/dist/stores/file/workflow-run-store.d.ts +1 -0
- package/dist/stores/file/workflow-run-store.js +14 -11
- package/dist/tools/artifact/artifact-tool.js +2 -0
- package/dist/tools/artifact/local-stub.js +6 -6
- package/dist/tools/fs/bash-program-position.d.ts +1 -2
- package/dist/tools/fs/bash-readonly-classifier.d.ts +35 -0
- package/dist/tools/fs/bash-readonly-classifier.js +50 -12
- package/dist/tools/fs/env-error-detail.d.ts +1 -0
- package/dist/tools/fs/env-error-detail.js +7 -0
- package/dist/tools/fs/fs-bash.d.ts +24 -6
- package/dist/tools/fs/fs-bash.js +73 -25
- package/dist/tools/fs/fs-pdf.js +6 -4
- package/dist/tools/fs/fs-read.d.ts +76 -31
- package/dist/tools/fs/fs-read.js +159 -79
- package/dist/tools/fs/fs-search-tools.d.ts +1 -1
- package/dist/tools/fs/fs-search-tools.js +3 -1
- package/dist/tools/fs/fs-shared.d.ts +59 -63
- package/dist/tools/fs/fs-shared.js +31 -18
- package/dist/tools/fs/fs-write.d.ts +13 -0
- package/dist/tools/fs/fs-write.js +69 -13
- package/dist/tools/fs/index.d.ts +19 -1
- package/dist/tools/fs/index.js +10 -2
- package/dist/tools/fs/pdf.js +10 -9
- package/dist/tools/fs/read-deny.js +4 -10
- package/dist/tools/fs/read-floor.d.ts +5 -4
- package/dist/tools/fs/removal-targets.d.ts +11 -5
- package/dist/tools/fs/removal-targets.js +62 -32
- package/dist/tools/fs/safety.d.ts +26 -19
- package/dist/tools/fs/safety.js +13 -8
- package/dist/tools/fs/search.d.ts +1 -1
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-bindings.d.ts +128 -26
- package/dist/tools/fs/shell-read-bindings.js +667 -139
- package/dist/tools/fs/shell-read-check.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +4 -1
- package/dist/tools/fs/shell-read-judge.js +5 -1
- package/dist/tools/fs/shell-read-plan.d.ts +4 -0
- package/dist/tools/fs/shell-read-plan.js +21 -19
- package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
- package/dist/tools/fs/shell-read-sourced.js +18 -1
- package/dist/tools/fs/shell-read-start.d.ts +6 -6
- package/dist/tools/fs/shell-read-start.js +1 -6
- package/dist/tools/fs/shell-read-word.d.ts +4 -2
- package/dist/tools/fs/shell-read-word.js +7 -6
- package/dist/tools/fs/shell-read-workdir.d.ts +1 -1
- package/dist/tools/fs/shell-reentry-text.d.ts +24 -9
- package/dist/tools/fs/shell-reentry-text.js +50 -20
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +14 -4
- package/dist/tools/scheduler-tools.d.ts +5 -2
- package/dist/tools/scheduler-tools.js +8 -6
- package/dist/tools/task-list.d.ts +49 -20
- package/dist/tools/task-list.js +115 -35
- package/dist/tools/web.d.ts +13 -3
- package/dist/tools/web.js +17 -6
- package/dist/tools/worktree.d.ts +3 -2
- package/dist/tools/worktree.js +24 -25
- package/package.json +10 -3
- package/test/export-surface.snapshot.json +330 -32
- package/wire-changes/core-stores-sql@7.66.1.json +30 -0
- package/wire-changes/core-stores-sql@7.67.0.json +39 -0
- package/wire-changes/core@7.66.1.json +46 -0
- package/wire-changes/core@7.67.0.json +12578 -0
- package/wire-changes/mods-kernel@7.66.1.json +30 -0
- package/wire-changes/mods-kernel@7.67.0.json +167 -0
- package/wire-changes/primitives@7.66.1.json +30 -0
- package/wire-changes/primitives@7.67.0.json +325 -0
- package/wire-changes/wiki-gate@7.67.0.json +1636 -0
- package/dist/brain/degrading.d.ts +0 -93
- package/dist/brain/degrading.js +0 -189
- package/dist/core/tool-conformance.d.ts +0 -20
- package/dist/core/tool-conformance.js +0 -37
package/dist/agents/subagent.js
CHANGED
|
@@ -5,10 +5,14 @@ import { bindDelegationName } from "../core/delegation-name.js";
|
|
|
5
5
|
import { authoredSteerOf } from "../core/input-author.js";
|
|
6
6
|
import { DELEGATION_OWNER_UNBOUND, delegationOwnerOf, rowOwnerReading } from "../core/runner/delegation-owner.js";
|
|
7
7
|
import { resumeRefusalDetailOf, resumeStartupCauseOf } from "../core/resume-startup-cause.js";
|
|
8
|
-
import { errorCodeOf
|
|
8
|
+
import { errorCodeOf } from "../core/runner/terminal-account.js";
|
|
9
9
|
import { applyParentSpecSeat, parentSpecSeatOfCtx } from "../core/parent-spec-seat.js";
|
|
10
|
+
import { isolationScopeOf } from "../core/isolation-scope.js";
|
|
11
|
+
import { delegationRootOf } from "../core/background-agent-store.js";
|
|
12
|
+
import { declaredCheckpointScope } from "../core/runner/checkpoint-scope.js";
|
|
13
|
+
import { sanitizedTtlMs } from "../core/runner/park-commit.js";
|
|
10
14
|
import { ADVISOR_FORK_SENTENCE, ADVISOR_TOOL_NAME } from "../core/advisor-verdict.js";
|
|
11
|
-
import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf,
|
|
15
|
+
import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf, clampValuesOf, engineHeadlessLegSeats, foldClampSources, postureUnderClamps, readClampFloor } from "../core/child-clamp-seats.js";
|
|
12
16
|
import { assertNoRetiredKeys } from "../core/retired-keys.js";
|
|
13
17
|
import { stripSpawnTurnQuestionFace } from "../core/ask-question.js";
|
|
14
18
|
import { withDelegationProvenance } from "../core/tool-policy.js";
|
|
@@ -23,7 +27,8 @@ export { childThinkingSeat, deploymentSubagentThinking, deploymentSubagentTierMo
|
|
|
23
27
|
import { REPORT_BLOCKED_TOOL_NAME } from "../core/runner/synthetic-tools.js";
|
|
24
28
|
import { TOOL_SEARCH_NAME } from "../core/runner/tool-disclosure.js";
|
|
25
29
|
import { OFFLOAD_TOOL_NAME, persistTaskArtifact } from "../core/tool-result-store.js";
|
|
26
|
-
import { compileToolSelector, delegationListWhere, namesEveryTool, toolListsDigest, toolNameAllowed
|
|
30
|
+
import { compileToolSelector, delegationListWhere, namesEveryTool, toolListsDigest, toolNameAllowed } from "./tool-filter.js";
|
|
31
|
+
import { toolNameListFlaw } from "../core/runner/sub-agent-deny-lists.js";
|
|
27
32
|
import { snapshotDefinitionLists } from "./agent-definition.js";
|
|
28
33
|
import { readToolNameList, snapshotToolNameList } from "../core/tool-name-list.js";
|
|
29
34
|
import { EXTRA_TOOL_NAMES_CODE, delegationPoolFace, extraToolNamesError, firstUndeclaredExtraTool, readExtraToolNames } from "./extra-tool-names.js";
|
|
@@ -34,9 +39,10 @@ import { roleBaseOf } from "../prompt-assembly/role-base.js";
|
|
|
34
39
|
import { readPromptRole } from "../prompt-assembly/select.js";
|
|
35
40
|
import { declaresSubagentPlacement, hasSessionFork } from "../core/session.js";
|
|
36
41
|
import { isDurablePause, pauseFamily } from "./suspend-guard.js";
|
|
37
|
-
import { childRejection, childTerminalFace, childThrownText } from "./child-failure.js";
|
|
42
|
+
import { childAnswerCode, childFailureOf, childRejection, childRowCode, childTerminalFace, childThrownText, rejectedChildOf } from "./child-failure.js";
|
|
38
43
|
import { forwardSafely } from "../core/runner/forward-sink.js";
|
|
39
44
|
import { callerPlacementSeats } from "../core/runner/child-tree.js";
|
|
45
|
+
import { raceTeardownLeg, settleTeardownLeg, TeardownLegTimeoutError } from "../core/runner/teardown-bounded.js";
|
|
40
46
|
import { legTaskIdOf } from "../core/leg-identity.js";
|
|
41
47
|
import { delimitUntrusted, inlineUntrusted } from "../core/untrusted-text.js";
|
|
42
48
|
import { createSafeNotifier } from "../core/safe-notify.js";
|
|
@@ -44,15 +50,16 @@ import { boundedRedactedSummary, extensionWords } from "../core/untrusted-egress
|
|
|
44
50
|
import { readExtensionRequester } from "../core/extension-requester.js";
|
|
45
51
|
import { uuidv7 } from "../internal/harness.js";
|
|
46
52
|
import { addWorktree } from "../core/git-worktree-env.js";
|
|
47
|
-
import {
|
|
48
|
-
import { BG_AGENT_REAP_STOP_ERROR, chosenAgentName } from "../core/task-registry.js";
|
|
53
|
+
import { BG_AGENT_REAP_STOP_ERROR, chosenAgentName, PARKED_CLAIM_ROLLBACK_FACE } from "../core/task-registry.js";
|
|
49
54
|
import { delegationRegistryOf } from "./delegation-registry-seat.js";
|
|
55
|
+
import { registerYieldAdoption } from "./yield-adoption.js";
|
|
50
56
|
import { agentOutcomeIsError } from "../core/task-registry-agent.js";
|
|
51
57
|
import { readDurableOrgAdmission } from "../core/memory-admission.js";
|
|
52
58
|
import { governanceRetryClass } from "../core/governance-codes.js";
|
|
53
59
|
import { readSkillGrantCapture } from "../core/skill-grant.js";
|
|
54
60
|
import { admitsBackgroundLaunch, completionResultField, moveTerminalDelivery, oweTerminalDelivery, resolveCompletionSink, terminalFrameFacets } from "../core/task-notification.js";
|
|
55
61
|
import { deliverEngineNotice } from "../core/engine-notice.js";
|
|
62
|
+
import { resumeLaneMissingNotice, rootSessionAddressOf, rootSessionLaneOf, rootSessionSink } from "./root-session-lane.js";
|
|
56
63
|
import { RETAIN_DEFAULT_TTL_MS, RETAIN_DEFAULT_MAX, RUNNING_AGENT_OBSERVE_EVERY_BEATS, DELEGATION_MAX_CONCURRENT_DEFAULT, DELEGATION_MAX_PER_SESSION_DEFAULT } from "../config/defaults.js";
|
|
57
64
|
function rollupDelegatedCost(stats, nested) {
|
|
58
65
|
if (stats.costMicroUsd === undefined)
|
|
@@ -89,8 +96,8 @@ import { childOwnerKeys, parkCompletionNotify, runningBackgroundUnder } from "./
|
|
|
89
96
|
import { placesSubagentTranscripts, subagentTranscriptPlacement } from "./subagent-transcript-placement.js";
|
|
90
97
|
import { OUTPUT_TOOL_NAME, mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
91
98
|
import { canonicalNameValue } from "../core/permission-rule-model.js";
|
|
92
|
-
import { definitionAllowTools, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, withDefinitionServers, withoutWakerSeats } from "./inherited-tool-pool.js";
|
|
93
|
-
import { readMember, thrownText } from "../core/thrown-value.js";
|
|
99
|
+
import { definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, selectorLayerOf, withDefinitionServers, withoutWakerSeats } from "./inherited-tool-pool.js";
|
|
100
|
+
import { codedRefusal, readMember, thrownMarksOf, thrownText } from "../core/thrown-value.js";
|
|
94
101
|
const BG_AGENT_RESULT_MAX = 4_000;
|
|
95
102
|
const BG_AGENT_RESULT_FULL_MAX = 200_000;
|
|
96
103
|
function resultSettleFields(result) {
|
|
@@ -205,65 +212,87 @@ export const EXTRA_TOOLS_MAX_FACTORY_CALLS_PER_TREE = 64;
|
|
|
205
212
|
export const DEFAULT_SUBAGENT_MAX_DEPTH = 3;
|
|
206
213
|
export const EXTRA_TOOLS_FAILED_NOTE = "note: extraTools evaluation failed — the injected tool set was skipped for this spawn.";
|
|
207
214
|
export const EXTRA_TOOLS_BUDGET_NOTE = `note: extraTools evaluation was skipped — this spawn tree exhausted its factory-call budget (${EXTRA_TOOLS_MAX_FACTORY_CALLS_PER_TREE}); no dynamic tools were injected for this spawn.`;
|
|
215
|
+
function editOutcomeOf(end) {
|
|
216
|
+
if (end.notExecuted === true || end.gate?.disposition.kind === "denied")
|
|
217
|
+
return "refused";
|
|
218
|
+
return end.isError ? "failed" : "landed";
|
|
219
|
+
}
|
|
208
220
|
function countArgLines(v) {
|
|
209
221
|
return typeof v === "string" && v.length > 0 ? v.split("\n").length : 0;
|
|
210
222
|
}
|
|
211
223
|
function createToolStatsCounter(delegationToolName) {
|
|
212
224
|
const t = { readCount: 0, searchCount: 0, bashCount: 0, editFileCount: 0, linesAdded: 0, linesRemoved: 0, otherToolCount: 0 };
|
|
225
|
+
const outcomes = { landed: 0, refused: 0, failed: 0 };
|
|
226
|
+
const openEdits = new Map();
|
|
227
|
+
const callKey = (e) => `${e.sourceTaskId ?? ""}\u0000${e.toolCallId}`;
|
|
213
228
|
const excluded = new Set([delegationToolName, DEFAULT_SUBAGENT_TOOL_NAME]);
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
const editLines = (toolName, args) => {
|
|
230
|
+
const a = args !== null && typeof args === "object" ? args : {};
|
|
231
|
+
if (toolName === "Write")
|
|
232
|
+
return { added: countArgLines(a.content), removed: 0 };
|
|
233
|
+
if (toolName === "NotebookEdit")
|
|
234
|
+
return { added: countArgLines(a.new_source), removed: 0 };
|
|
235
|
+
if (!Array.isArray(a.edits))
|
|
236
|
+
return { added: countArgLines(a.new_string), removed: countArgLines(a.old_string) };
|
|
237
|
+
let added = 0;
|
|
238
|
+
let removed = 0;
|
|
239
|
+
for (const ed of a.edits) {
|
|
240
|
+
if (ed !== null && typeof ed === "object") {
|
|
241
|
+
added += countArgLines(ed.new_string);
|
|
242
|
+
removed += countArgLines(ed.old_string);
|
|
224
243
|
}
|
|
244
|
+
}
|
|
245
|
+
return { added, removed };
|
|
246
|
+
};
|
|
247
|
+
const start = (key, toolName, args) => {
|
|
248
|
+
if (excluded.has(toolName))
|
|
249
|
+
return;
|
|
250
|
+
switch (toolName) {
|
|
251
|
+
case "Read":
|
|
252
|
+
t.readCount++;
|
|
253
|
+
break;
|
|
254
|
+
case "Grep":
|
|
255
|
+
case "Glob":
|
|
256
|
+
t.searchCount++;
|
|
257
|
+
break;
|
|
258
|
+
case "Bash":
|
|
259
|
+
t.bashCount++;
|
|
260
|
+
break;
|
|
261
|
+
case "Edit":
|
|
262
|
+
case "Write":
|
|
263
|
+
case "NotebookEdit":
|
|
264
|
+
t.editFileCount++;
|
|
265
|
+
openEdits.set(key, editLines(toolName, args));
|
|
266
|
+
break;
|
|
267
|
+
default:
|
|
268
|
+
t.otherToolCount++;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const end = (e) => {
|
|
272
|
+
const open = openEdits.get(callKey(e));
|
|
273
|
+
if (open === undefined)
|
|
225
274
|
return;
|
|
275
|
+
openEdits.delete(callKey(e));
|
|
276
|
+
const outcome = editOutcomeOf(e);
|
|
277
|
+
outcomes[outcome]++;
|
|
278
|
+
if (outcome === "landed") {
|
|
279
|
+
t.linesAdded += open.added;
|
|
280
|
+
t.linesRemoved += open.removed;
|
|
226
281
|
}
|
|
227
|
-
t.linesAdded += countArgLines(a.new_string);
|
|
228
|
-
t.linesRemoved += countArgLines(a.old_string);
|
|
229
282
|
};
|
|
230
283
|
return {
|
|
231
|
-
|
|
284
|
+
observe(e) {
|
|
232
285
|
try {
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
t.readCount++;
|
|
238
|
-
break;
|
|
239
|
-
case "Grep":
|
|
240
|
-
case "Glob":
|
|
241
|
-
t.searchCount++;
|
|
242
|
-
break;
|
|
243
|
-
case "Bash":
|
|
244
|
-
t.bashCount++;
|
|
245
|
-
break;
|
|
246
|
-
case "Edit":
|
|
247
|
-
t.editFileCount++;
|
|
248
|
-
recordEditLines(args);
|
|
249
|
-
break;
|
|
250
|
-
case "Write":
|
|
251
|
-
t.editFileCount++;
|
|
252
|
-
t.linesAdded += countArgLines(args?.content);
|
|
253
|
-
break;
|
|
254
|
-
case "NotebookEdit":
|
|
255
|
-
t.editFileCount++;
|
|
256
|
-
t.linesAdded += countArgLines(args?.new_source);
|
|
257
|
-
break;
|
|
258
|
-
default:
|
|
259
|
-
t.otherToolCount++;
|
|
260
|
-
}
|
|
286
|
+
if (e.type === "tool_start")
|
|
287
|
+
start(callKey(e), e.toolName, e.args);
|
|
288
|
+
else if (e.type === "tool_end")
|
|
289
|
+
end(e);
|
|
261
290
|
}
|
|
262
291
|
catch {
|
|
263
292
|
}
|
|
264
293
|
},
|
|
265
294
|
snapshot() {
|
|
266
|
-
return t.readCount + t.searchCount + t.bashCount + t.editFileCount + t.otherToolCount > 0 ? { ...t } : undefined;
|
|
295
|
+
return t.readCount + t.searchCount + t.bashCount + t.editFileCount + t.otherToolCount > 0 ? { ...t, ...(t.editFileCount > 0 ? { editFileOutcomes: { ...outcomes } } : {}) } : undefined;
|
|
267
296
|
},
|
|
268
297
|
total() {
|
|
269
298
|
return t.readCount + t.searchCount + t.bashCount + t.editFileCount + t.otherToolCount;
|
|
@@ -285,19 +314,20 @@ const UNDECLARED_EXTRA_TOOL_REFUSAL = {
|
|
|
285
314
|
undeclared_origin: "the extraTools factory of this delegation tool injected a tool of a content class beyond the one its declared extra tools state — the declaration is the upper bound of what the factory may inject.",
|
|
286
315
|
};
|
|
287
316
|
const WORKTREE_NOT_A_REPOSITORY = "isolation.not_a_repository";
|
|
288
|
-
const
|
|
317
|
+
const WORKTREE_FAILED = "isolation.failed";
|
|
318
|
+
const WORKTREE_UNAVAILABLE_CODE = "isolation.unavailable";
|
|
319
|
+
const worktreeUnavailableSentence = (reason) => `Sub-agent not started: isolation "worktree" is unavailable on this run (${reason}). Running it in the main tree instead would need the isolation parameter removed explicitly, which is a different choice from the one requested.`;
|
|
289
320
|
const WORKTREE_UNAVAILABLE = {
|
|
290
321
|
readOnly: worktreeUnavailableSentence("no worktree capability — a read-only run mints no worktree"),
|
|
291
322
|
needsFactory: worktreeUnavailableSentence("this deployment has no executionEnvFactory — a static execution environment has one shared working directory, so the child would run in this run's own root instead of a worktree; deploy an executionEnvFactory to enable worktree isolation"),
|
|
292
323
|
notHonored: worktreeUnavailableSentence("the execution environment factory placed the child inside this run's own tree instead of the worktree it was offered — it would have read and written this checkout; the worktree was removed and the child was not started"),
|
|
293
324
|
seatSilent: worktreeUnavailableSentence("the runner this tool runs children on does not declare whether it can place a child in a tree other than the caller's (its seat has no canRerootChild), and an undeclared answer is read as no; use a Runner, or add that method to the seat"),
|
|
325
|
+
notARepository: worktreeUnavailableSentence("the working directory is not a git repository"),
|
|
326
|
+
mintFailed: worktreeUnavailableSentence("the worktree could not be created; the repository state may need fixing"),
|
|
294
327
|
};
|
|
295
|
-
const placementRefused = (terminal) => terminal?.kind === "failed" && terminal.code ===
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
content,
|
|
299
|
-
details: { error: "isolation.unavailable" },
|
|
300
|
-
});
|
|
328
|
+
const placementRefused = (terminal) => terminal?.kind === "failed" && terminal.code === WORKTREE_UNAVAILABLE_CODE;
|
|
329
|
+
const isolationRefusal = (content, code, cause) => notStartedResult({ isError: true, content, details: { error: code, code, ...(cause !== undefined ? { cause } : {}) } });
|
|
330
|
+
const isolationUnavailable = (content) => isolationRefusal(content, WORKTREE_UNAVAILABLE_CODE);
|
|
301
331
|
export function createSubagentWorktreeHelper(baseEnv, repoRoot, parentFloor) {
|
|
302
332
|
const handles = new Map();
|
|
303
333
|
const readFloorNow = () => { const readFloor = parentFloor(); return readFloor !== undefined ? { readFloor } : {}; };
|
|
@@ -312,43 +342,24 @@ export function createSubagentWorktreeHelper(baseEnv, repoRoot, parentFloor) {
|
|
|
312
342
|
repoRoot,
|
|
313
343
|
sessionId: childId,
|
|
314
344
|
readFloor: parentFloor,
|
|
345
|
+
onExit: "keep-if-dirty",
|
|
315
346
|
rootEnvAt: (dir) => Object.create(baseEnv, {
|
|
316
347
|
cwd: { value: dir, configurable: true },
|
|
317
348
|
destroy: { value: undefined, writable: true, configurable: true },
|
|
318
349
|
}),
|
|
319
350
|
});
|
|
320
|
-
|
|
321
|
-
.then(() => baseEnv.exec("git rev-parse HEAD", { cwd: worktreeDir, ...readFloorNow() }))
|
|
322
|
-
.then((r) => (r.ok && r.value.exitCode === 0 ? r.value.stdout.trim() : undefined))
|
|
323
|
-
.catch(() => undefined);
|
|
324
|
-
handles.set(worktreeDir, { destroy: () => env.destroy(), baseSha });
|
|
351
|
+
handles.set(worktreeDir, { release: () => env.destroy() });
|
|
325
352
|
return { worktreeDir };
|
|
326
353
|
},
|
|
327
354
|
async finish(worktreeDir) {
|
|
328
355
|
const handle = handles.get(worktreeDir);
|
|
329
356
|
handles.delete(worktreeDir);
|
|
330
|
-
let changed = true;
|
|
331
357
|
try {
|
|
332
|
-
|
|
333
|
-
if (status.ok && status.value.exitCode === 0 && handle?.baseSha !== undefined) {
|
|
334
|
-
const dirtyFiles = status.value.stdout.split("\n").filter((l) => l.trim() !== "").length;
|
|
335
|
-
const ahead = await baseEnv.exec(`git rev-list --count ${shellQuote(`${handle.baseSha}..HEAD`)}`, { cwd: worktreeDir, ...readFloorNow() });
|
|
336
|
-
const commits = ahead.ok && ahead.value.exitCode === 0 ? parseInt(ahead.value.stdout.trim(), 10) || 0 : -1;
|
|
337
|
-
if (commits >= 0)
|
|
338
|
-
changed = dirtyFiles > 0 || commits > 0;
|
|
339
|
-
}
|
|
358
|
+
return (await handle?.release())?.removed === true ? "pruned" : "kept";
|
|
340
359
|
}
|
|
341
360
|
catch {
|
|
342
361
|
return "kept";
|
|
343
362
|
}
|
|
344
|
-
if (changed)
|
|
345
|
-
return "kept";
|
|
346
|
-
try {
|
|
347
|
-
await handle?.destroy();
|
|
348
|
-
}
|
|
349
|
-
catch {
|
|
350
|
-
}
|
|
351
|
-
return "pruned";
|
|
352
363
|
},
|
|
353
364
|
};
|
|
354
365
|
}
|
|
@@ -380,9 +391,7 @@ export const RESERVED_AGENT_NAMES = new Set([OUTPUT_TOOL_NAME, TOOL_SEARCH_NAME,
|
|
|
380
391
|
export const REPORT_FIELD_MAX = 300;
|
|
381
392
|
const ROSTER_ECHO_MAX = 400;
|
|
382
393
|
function configError(message, code) {
|
|
383
|
-
|
|
384
|
-
e.code = code;
|
|
385
|
-
return e;
|
|
394
|
+
return codedRefusal(code, message);
|
|
386
395
|
}
|
|
387
396
|
export const SUBAGENT_ERROR_KINDS = Object.freeze(["rate_limit", "timeout", "network", "logic", "governance", "unknown"]);
|
|
388
397
|
const SUBAGENT_ERROR_KIND_BY_CODE = {
|
|
@@ -417,12 +426,9 @@ export function classifySubagentError(terminal) {
|
|
|
417
426
|
return { errorKind: "governance", retryable: governanceClass === "transient" };
|
|
418
427
|
return { errorKind: "logic", retryable: SUBAGENT_RETRYABLE.logic };
|
|
419
428
|
}
|
|
420
|
-
function thrownErrorCode(e) {
|
|
421
|
-
const code = readMember(e, "code");
|
|
422
|
-
return typeof code === "string" ? code : undefined;
|
|
423
|
-
}
|
|
424
429
|
export function completedAgentCard(child, extras) {
|
|
425
430
|
const face = childTerminalFace(child.terminal);
|
|
431
|
+
const code = childAnswerCode(face.errorCode !== undefined ? { code: face.errorCode } : {});
|
|
426
432
|
return {
|
|
427
433
|
type: "agent",
|
|
428
434
|
...(extras.attestation !== undefined ? { attestation: extras.attestation } : {}),
|
|
@@ -435,7 +441,7 @@ export function completedAgentCard(child, extras) {
|
|
|
435
441
|
...(child.structuredOutput !== undefined ? { structuredOutput: child.structuredOutput } : {}),
|
|
436
442
|
...(face.blockedReason !== undefined ? { blockedReason: face.blockedReason } : {}),
|
|
437
443
|
...(face.errorMessage !== undefined ? { errorMessage: face.errorMessage } : {}),
|
|
438
|
-
...(
|
|
444
|
+
...(code !== undefined ? { code } : {}),
|
|
439
445
|
...providerFaultField(child),
|
|
440
446
|
...(child.retryAfterMs !== undefined ? { retryAfterMs: child.retryAfterMs } : {}),
|
|
441
447
|
...(child.degraded !== undefined ? { degraded: child.degraded } : {}),
|
|
@@ -453,13 +459,13 @@ export const SUBAGENT_SUSPENDED_NEEDS_REVIEW = "suspended.needs_review";
|
|
|
453
459
|
export const SUBAGENT_SUSPENDED_CHECKPOINT_EXPIRED = "suspended.checkpoint_expired";
|
|
454
460
|
function durablePauseDelegationReport(reportLabel, paused) {
|
|
455
461
|
const needsReview = pauseFamily(paused) === "needs_review";
|
|
456
|
-
const
|
|
462
|
+
const checkpointId = paused.checkpointId;
|
|
457
463
|
return {
|
|
458
464
|
isError: true,
|
|
459
465
|
content: `[Sub-agent report${reportLabel}]\n` +
|
|
460
466
|
`status: suspended\n` +
|
|
461
467
|
`This delegation is PARKED at an approval gate — it did not fail, and it is not finished. ` +
|
|
462
|
-
`${needsReview ? "A human review" : "An approval"} it cannot grant itself is pending, held by checkpoint ${
|
|
468
|
+
`${needsReview ? "A human review" : "An approval"} it cannot grant itself is pending, held by ${checkpointId !== undefined ? `checkpoint ${inlineUntrusted(checkpointId, 64)}` : "a checkpoint"}. ` +
|
|
463
469
|
`The gated action has NOT run.\n` +
|
|
464
470
|
`Only the deployment's approval channel can release it: you cannot approve it from here, and no ` +
|
|
465
471
|
`result from it will arrive in this turn. Do not re-issue the same approval-gated action — an ` +
|
|
@@ -467,7 +473,7 @@ function durablePauseDelegationReport(reportLabel, paused) {
|
|
|
467
473
|
`this delegation, or report that it is awaiting approval.`,
|
|
468
474
|
details: {
|
|
469
475
|
error: needsReview ? SUBAGENT_SUSPENDED_NEEDS_REVIEW : SUBAGENT_SUSPENDED_AWAITING_APPROVAL,
|
|
470
|
-
|
|
476
|
+
...(checkpointId !== undefined ? { checkpointId } : {}),
|
|
471
477
|
},
|
|
472
478
|
};
|
|
473
479
|
}
|
|
@@ -475,7 +481,7 @@ function unparkedDurablePauseReason(d) {
|
|
|
475
481
|
return d.kind === "no_park_lane"
|
|
476
482
|
? `the agent hit an approval gate and paused durably, but this delegation cannot be parked ` +
|
|
477
483
|
`(parking needs a durable agent row, a checkpoint store and the ` +
|
|
478
|
-
`durable-session capability). Its checkpoint ${d.
|
|
484
|
+
`durable-session capability). Its checkpoint${d.checkpointId !== undefined ? ` ${inlineUntrusted(d.checkpointId, 64)}` : ""} is still committed and the ` +
|
|
479
485
|
`approval must be resolved through the deployment's approval channel; the gated action never ran.`
|
|
480
486
|
: `the agent hit an approval gate and paused durably, but the park did not take (` +
|
|
481
487
|
`${d.cause === "capability_veto" ? "the durable-session capability refused" : "a concurrent stop won the arbitration"}` +
|
|
@@ -488,7 +494,7 @@ function errorKindClause(c) {
|
|
|
488
494
|
const FAILED_SESSION_RETAIN_TTL_MS = 15 * 60 * 1000;
|
|
489
495
|
const PARTIAL_FINDINGS_MAX_CHARS = 1200;
|
|
490
496
|
const BG_NOTIFY_DRAIN_WINDOW_MS = 2_000;
|
|
491
|
-
function createBgActivityBeat(parentToolCallId, emitTick
|
|
497
|
+
function createBgActivityBeat(parentToolCallId, emitTick) {
|
|
492
498
|
let beats = 0;
|
|
493
499
|
let starts = 0;
|
|
494
500
|
return (e) => {
|
|
@@ -499,13 +505,27 @@ function createBgActivityBeat(parentToolCallId, emitTick, noteActivity) {
|
|
|
499
505
|
if (e.type === "tool_start")
|
|
500
506
|
starts += 1;
|
|
501
507
|
beats += 1;
|
|
502
|
-
noteActivity?.();
|
|
503
508
|
if (beats === 1 || beats % RUNNING_AGENT_OBSERVE_EVERY_BEATS === 0)
|
|
504
509
|
emitTick(starts);
|
|
505
510
|
};
|
|
506
511
|
}
|
|
507
|
-
function backgroundLegFacts(taskId, cycleSeq) {
|
|
508
|
-
return {
|
|
512
|
+
function backgroundLegFacts(taskId, cycleSeq, registry) {
|
|
513
|
+
return {
|
|
514
|
+
delegationTaskType: "background_agent",
|
|
515
|
+
rowTaskId: taskId,
|
|
516
|
+
...(cycleSeq !== undefined ? { cycleSeq } : {}),
|
|
517
|
+
...(registry !== undefined ? { onSubtreeActivity: rowActivitySeat(registry, taskId) } : {}),
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
function rowActivitySeat(registry, taskId) {
|
|
521
|
+
return () => registry.noteBackgroundAgentActivity(taskId);
|
|
522
|
+
}
|
|
523
|
+
function hostAbortListener(ctx, abort) {
|
|
524
|
+
return () => {
|
|
525
|
+
if (ctx.hostRunParked?.() === true)
|
|
526
|
+
return;
|
|
527
|
+
abort.abort();
|
|
528
|
+
};
|
|
509
529
|
}
|
|
510
530
|
export function markerFragment() {
|
|
511
531
|
return uuidv7().replace(/-/g, "").slice(-12);
|
|
@@ -673,15 +693,16 @@ export function createSubagentResume(deps) {
|
|
|
673
693
|
...(currentTool !== undefined ? { currentTool } : {}),
|
|
674
694
|
usage: { toolUses: toolStarts },
|
|
675
695
|
});
|
|
676
|
-
}
|
|
696
|
+
});
|
|
677
697
|
releaseCycleSlot = deps.entryGate?.occupy(reviveCycle !== undefined ? "registered" : "local") ?? noopRelease;
|
|
678
698
|
stream = childRunner.runTaskStream(resumeSpec, undefined, {
|
|
679
699
|
...entry.internalsSnapshot,
|
|
700
|
+
...(deps.registry !== undefined && deps.taskId !== undefined ? { onSubtreeActivity: rowActivitySeat(deps.registry, deps.taskId) } : {}),
|
|
680
701
|
...inheritedHostSeats(deps.currentMcpHostSeats, resumeSpec.mcp ?? []),
|
|
681
702
|
...(deps.currentPlacementTarget !== undefined ? { placementTarget: deps.currentPlacementTarget } : {}),
|
|
682
703
|
objectiveAuthor: by.author,
|
|
683
704
|
cycleSeq: entry.cycleSeq,
|
|
684
|
-
parentInteractionPosture: postureUnderClamps(entry.internalsSnapshot.parentInteractionPosture, { interactiveTools: resumeSpec.interactiveTools, approvalReach: resumeSpec.approvalReach }),
|
|
705
|
+
parentInteractionPosture: postureUnderClamps(entry.internalsSnapshot.parentInteractionPosture, { interactiveTools: resumeSpec.interactiveTools, approvalReach: resumeSpec.approvalReach }, "interactive"),
|
|
685
706
|
...(true
|
|
686
707
|
? {
|
|
687
708
|
onForwardEvent: (e) => {
|
|
@@ -853,7 +874,7 @@ export function createSubagentResume(deps) {
|
|
|
853
874
|
}
|
|
854
875
|
catch (e) {
|
|
855
876
|
const msgRevive = childThrownText(e);
|
|
856
|
-
const errCodeReviveReject = abort.signal.aborted ? undefined :
|
|
877
|
+
const errCodeReviveReject = abort.signal.aborted ? undefined : childRowCode(childFailureOf(e));
|
|
857
878
|
const errClassReviveReject = abort.signal.aborted ? undefined : classifySubagentError({ kind: "failed", ...(errCodeReviveReject !== undefined ? { code: errCodeReviveReject } : {}) });
|
|
858
879
|
let completionIdRejectRevive;
|
|
859
880
|
if (reviveCycle !== undefined && deps.registry !== undefined && deps.taskId !== undefined) {
|
|
@@ -1397,6 +1418,11 @@ export function agentWhenToUseText(def, lean = true) {
|
|
|
1397
1418
|
return (leanText || def.whenToUse) || undefined;
|
|
1398
1419
|
}
|
|
1399
1420
|
function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
1421
|
+
const node = buildSubagentToolNode(opts, depth, excluded, extraToolsBudget);
|
|
1422
|
+
registerYieldAdoption(node, opts.background);
|
|
1423
|
+
return node;
|
|
1424
|
+
}
|
|
1425
|
+
function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
1400
1426
|
const maxDepth = opts.maxDepth ?? DEFAULT_SUBAGENT_MAX_DEPTH;
|
|
1401
1427
|
const toolName = opts.name ?? DEFAULT_SUBAGENT_TOOL_NAME;
|
|
1402
1428
|
const notifier = createSafeNotifier(opts.onObserverError !== undefined ? { onError: (f) => opts.onObserverError?.(f.error, { site: f.site }) } : undefined);
|
|
@@ -1552,8 +1578,10 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1552
1578
|
const parentSpecSeat = parentSpecSeatOfCtx(ctx);
|
|
1553
1579
|
const background = opts.background, backgroundRegistry = delegationRegistryOf(ctx, background);
|
|
1554
1580
|
const reviveClaim = ctx.reviveClaim;
|
|
1555
|
-
const
|
|
1556
|
-
const
|
|
1581
|
+
const heldInRegistry = reviveClaim?.parkedResume !== undefined ? backgroundRegistry?.parkedCompletionSink(reviveClaim.row.handle) : undefined;
|
|
1582
|
+
const rowRoot = reviveClaim?.parkedResume !== undefined && heldInRegistry === undefined && ctx.onTaskNotification === undefined ? { address: rootSessionAddressOf(reviveClaim.row) } : undefined;
|
|
1583
|
+
const rootLane = rowRoot !== undefined && background !== undefined && (background.notify !== undefined || rootSessionLaneOf(opts.runner, rowRoot.address).ok) ? rootSessionSink(opts.runner, rowRoot.address, background.notify) : undefined;
|
|
1584
|
+
const backgroundSink = background !== undefined ? resolveCompletionSink(ctx.onTaskNotification ?? heldInRegistry ?? rootLane, background.notify) : undefined;
|
|
1557
1585
|
const backgroundLane = background !== undefined && admitsBackgroundLaunch(backgroundSink);
|
|
1558
1586
|
if (reviveClaim !== undefined && !backgroundLane) {
|
|
1559
1587
|
return notStartedResult({
|
|
@@ -1587,12 +1615,12 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1587
1615
|
const omitted = rawType === "" || (!generalPurposeShadowed && rawType === GENERAL_PURPOSE_SUBAGENT_TYPE);
|
|
1588
1616
|
const def = hasAgents && !wantsFork && !omitted ? agentMap.get(rawType) : undefined;
|
|
1589
1617
|
const spawnAgentType = wantsFork ? FORK_SUBAGENT_TYPE : omitted ? GENERAL_PURPOSE_SUBAGENT_TYPE : rawType;
|
|
1590
|
-
const allowFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "allowed", def !== undefined ? def.allowTools : opts.allowTools);
|
|
1618
|
+
const allowFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "allowed", def !== undefined ? def.allowTools : opts.allowTools, def !== undefined);
|
|
1591
1619
|
if (allowFlaw !== undefined)
|
|
1592
|
-
return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(allowFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } });
|
|
1593
|
-
const denyFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "denied", def !== undefined ? def.denyTools : opts.denyTools);
|
|
1620
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(allowFlaw.message, 480)}`, details: { error: "config.agent.unknown_tool", reason: allowFlaw.reason } });
|
|
1621
|
+
const denyFlaw = toolNameListFlaw(delegationListWhere(toolName, def?.name), "denied", def !== undefined ? def.denyTools : opts.denyTools, def !== undefined);
|
|
1594
1622
|
if (denyFlaw !== undefined)
|
|
1595
|
-
return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(denyFlaw, 480)}`, details: { error: "config.agent.unknown_tool" } });
|
|
1623
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: ${inlineUntrusted(denyFlaw.message, 480)}`, details: { error: "config.agent.unknown_tool", reason: denyFlaw.reason } });
|
|
1596
1624
|
if (a.name !== undefined && typeof a.name !== "string") {
|
|
1597
1625
|
return notStartedResult({ isError: true, content: "Sub-agent not started: name must be a string.", details: { error: "name.invalid" } });
|
|
1598
1626
|
}
|
|
@@ -1819,23 +1847,25 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1819
1847
|
worktreeDir = (await iso.mint(ctx.toolCallId)).worktreeDir;
|
|
1820
1848
|
}
|
|
1821
1849
|
catch (e) {
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
content: errorCodeOf(e) === WORKTREE_NOT_A_REPOSITORY
|
|
1825
|
-
? "Sub-agent not started: worktree isolation failed — the working directory is not a git repository. Retry without the isolation parameter."
|
|
1826
|
-
: "Sub-agent not started: worktree isolation failed. Retry without the isolation parameter, or fix the repository state.",
|
|
1827
|
-
details: { error: "isolation.failed", cause: childThrownText(e) },
|
|
1828
|
-
});
|
|
1850
|
+
const notARepository = errorCodeOf(e) === WORKTREE_NOT_A_REPOSITORY;
|
|
1851
|
+
return isolationRefusal(notARepository ? WORKTREE_UNAVAILABLE.notARepository : WORKTREE_UNAVAILABLE.mintFailed, WORKTREE_FAILED, childThrownText(e));
|
|
1829
1852
|
}
|
|
1830
1853
|
}
|
|
1831
1854
|
let worktreeKeptPath;
|
|
1832
1855
|
let childPlacement;
|
|
1833
1856
|
let worktreeFault;
|
|
1857
|
+
const reportWedgedLeg = (site) => (err) => {
|
|
1858
|
+
try {
|
|
1859
|
+
opts.onObserverError?.(err, { site });
|
|
1860
|
+
}
|
|
1861
|
+
catch {
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1834
1864
|
const finishWorktree = async (terminal) => {
|
|
1835
1865
|
if (worktreeDir === undefined)
|
|
1836
1866
|
return undefined;
|
|
1837
1867
|
try {
|
|
1838
|
-
const outcome = await ctx.worktreeIsolation.finish(worktreeDir);
|
|
1868
|
+
const outcome = await raceTeardownLeg(() => ctx.worktreeIsolation.finish(worktreeDir), "worktree isolation finish");
|
|
1839
1869
|
if (placementRefused(terminal))
|
|
1840
1870
|
return undefined;
|
|
1841
1871
|
if (childPlacement?.placement === "elsewhere")
|
|
@@ -1844,11 +1874,13 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1844
1874
|
worktreeKeptPath = worktreeDir;
|
|
1845
1875
|
return outcome === "pruned"
|
|
1846
1876
|
? `worktree: ${worktreeDir} (pruned — the agent made no changes)`
|
|
1847
|
-
: `worktree: ${worktreeDir} (KEPT —
|
|
1877
|
+
: `worktree: ${worktreeDir} (KEPT — it holds changes or files git ignores, or git would not remove it; inspect/merge it, then remove it)`;
|
|
1848
1878
|
}
|
|
1849
1879
|
catch (e) {
|
|
1850
1880
|
worktreeKeptPath = worktreeDir;
|
|
1851
1881
|
worktreeFault = childThrownText(e);
|
|
1882
|
+
if (e instanceof TeardownLegTimeoutError)
|
|
1883
|
+
reportWedgedLeg("worktree.finish")(e);
|
|
1852
1884
|
return `worktree: ${worktreeDir} (cleanup check failed — the directory is kept on disk)`;
|
|
1853
1885
|
}
|
|
1854
1886
|
};
|
|
@@ -1933,8 +1965,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1933
1965
|
}
|
|
1934
1966
|
childPool = [...(opts.tools ?? inherited.filter((t) => ![t.name, ...(t.aliases ?? [])].some((n) => taken.has(n)))), ...accepted];
|
|
1935
1967
|
}
|
|
1936
|
-
const
|
|
1937
|
-
const childOwnLayer = Object.freeze({ ...(governingLists.allow != null ? { allow: Object.freeze([...governingLists.allow]) } : {}), deny: Object.freeze([...(governingLists.deny ?? [])]) });
|
|
1968
|
+
const childOwnLayer = def !== undefined ? definitionSelectorLayer(def) : selectorLayerOf(opts.allowTools, opts.denyTools);
|
|
1938
1969
|
const childListsDigest = toolListsDigest(childOwnLayer.allow, childOwnLayer.deny);
|
|
1939
1970
|
const childListsJudged = agentToolPool !== undefined ? childListsDigest : undefined;
|
|
1940
1971
|
const childCeiling = ctx.toolSelector?.layers ?? [];
|
|
@@ -1944,7 +1975,6 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1944
1975
|
const childTools = [...childPool];
|
|
1945
1976
|
const childRoleBase = roleBaseOf([def !== undefined ? { systemPrompt: def.systemPrompt } : undefined, { promptRole: opts.promptRole, systemPrompt: opts.systemPrompt }]);
|
|
1946
1977
|
const childSystemPrompt = childRoleBase?.systemPrompt;
|
|
1947
|
-
const childDefaultPersona = childRoleBase === undefined && !wantsFork ? SUBAGENT_PROMPT : undefined;
|
|
1948
1978
|
const defMaxTurns = typeof def?.maxTurns === "number" && Number.isFinite(def.maxTurns) && def.maxTurns > 0 ? def.maxTurns : undefined;
|
|
1949
1979
|
const childLimits = defMaxTurns !== undefined ? { ...opts.limits, maxTurns: defMaxTurns } : opts.limits;
|
|
1950
1980
|
const nextExcluded = def ? new Set([...excluded, def.name]) : excluded;
|
|
@@ -2168,8 +2198,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2168
2198
|
if (e.type === "text_delta" && e.parentToolCallId === ctx.toolCallId) {
|
|
2169
2199
|
assistantTextTail = (assistantTextTail + e.delta).slice(-PARTIAL_FINDINGS_MAX_CHARS);
|
|
2170
2200
|
}
|
|
2171
|
-
|
|
2172
|
-
toolStatsCounter.record(e.toolName, e.args);
|
|
2201
|
+
toolStatsCounter.observe(e);
|
|
2173
2202
|
if (e.type === "task_progress") {
|
|
2174
2203
|
const currentAction = stepRecorder.currentAction();
|
|
2175
2204
|
if (currentAction !== undefined) {
|
|
@@ -2184,11 +2213,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2184
2213
|
const editedFiles = stepRecorder.editedFiles();
|
|
2185
2214
|
return { ...(recentSteps ? { recentSteps } : {}), ...(editedFiles ? { editedFiles } : {}) };
|
|
2186
2215
|
};
|
|
2187
|
-
const treeScope = reviveClaim?.row.scope ?? parentSpecSeat
|
|
2216
|
+
const treeScope = reviveClaim?.row.scope ?? isolationScopeOf(parentSpecSeat ?? {}) ?? background?.scope;
|
|
2188
2217
|
const entryCapPoolAnchor = backgroundRegistry ?? opts;
|
|
2189
2218
|
const entryCaps = ctx.delegationEntryCaps ?? { maxConcurrent: DELEGATION_MAX_CONCURRENT_DEFAULT, maxCumulativePerSession: DELEGATION_MAX_PER_SESSION_DEFAULT };
|
|
2190
2219
|
const entryCapRoot = reviveClaim !== undefined
|
|
2191
|
-
? (reviveClaim.row
|
|
2220
|
+
? delegationRootOf(reviveClaim.row)
|
|
2192
2221
|
: (ctx.rootSessionId ?? ctx.sessionId);
|
|
2193
2222
|
const entryPoolSeat = { poolAnchor: entryCapPoolAnchor, scope: treeScope, root: entryCapRoot };
|
|
2194
2223
|
const openEntryGate = () => openDelegationEntryGate({
|
|
@@ -2206,8 +2235,9 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2206
2235
|
? { optedOut: (await ctx.memoryCaptureOptedOut) === true, indeterminate: (await ctx.memoryCaptureIndeterminate) === true }
|
|
2207
2236
|
: undefined;
|
|
2208
2237
|
const revivalClamps = bornFloor !== undefined ? clampValuesOf(clampSourceOf(ctx, "clamp"), bornFloor) : undefined;
|
|
2209
|
-
const childPosture = revivalClamps !== undefined
|
|
2238
|
+
const childPosture = revivalClamps !== undefined ? postureUnderClamps(ctx.interactionPosture, { interactiveTools: revivalClamps.interactiveTools, approvalReach: revivalClamps.approvalReach }, "interactive") : ctx.interactionPosture;
|
|
2210
2239
|
const childInternals = {
|
|
2240
|
+
...(ctx.onSubtreeActivity !== undefined ? { onSubtreeActivity: ctx.onSubtreeActivity } : {}),
|
|
2211
2241
|
...(ctx.toolSelector !== undefined ? { toolCeiling: childCeiling, ...(childListsJudged !== undefined ? { toolListsJudged: childListsJudged } : {}) } : {}),
|
|
2212
2242
|
...(childListsDigest !== undefined ? { ownToolLists: { toolName, ...(def !== undefined ? { definition: def.name } : {}), lists: childListsDigest } } : {}),
|
|
2213
2243
|
...(mountedMcpNow?.pool !== undefined && childMcp.length > 0 ? { mcpPool: mountedMcpNow.pool } : {}),
|
|
@@ -2230,7 +2260,6 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2230
2260
|
return ref;
|
|
2231
2261
|
})(),
|
|
2232
2262
|
peerInboundChainRef: createPeerInboundChainRef(reviveClaim?.peerSeed?.hopChain),
|
|
2233
|
-
...(childDefaultPersona !== undefined ? { defaultSystemPrompt: childDefaultPersona } : {}),
|
|
2234
2263
|
isDelegatedChild: true,
|
|
2235
2264
|
objectiveAuthor: reviveClaim !== undefined ? "peer" : "parent_model",
|
|
2236
2265
|
...(childPosture !== undefined ? { parentInteractionPosture: childPosture } : {}),
|
|
@@ -2253,23 +2282,25 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2253
2282
|
? {
|
|
2254
2283
|
...(reviveClaim.row.parentTaskId !== undefined ? { parentTaskId: reviveClaim.row.parentTaskId } : {}),
|
|
2255
2284
|
...(reviveClaim.row.parentSessionId !== undefined ? { parentSessionId: reviveClaim.row.parentSessionId } : {}),
|
|
2256
|
-
...((reviveClaim.row
|
|
2257
|
-
? { rootSessionId: reviveClaim.row
|
|
2285
|
+
...(delegationRootOf(reviveClaim.row) !== undefined
|
|
2286
|
+
? { rootSessionId: delegationRootOf(reviveClaim.row) }
|
|
2258
2287
|
: {}),
|
|
2259
2288
|
...(reviveClaim.row.rootSessionId !== undefined && reviveClaim.row.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: reviveClaim.row.rootSessionIncarnation } : {}),
|
|
2289
|
+
...(reviveClaim.row.rootSessionId !== undefined && reviveClaim.row.rootSessionScope !== undefined ? { rootSessionScope: reviveClaim.row.rootSessionScope } : {}),
|
|
2260
2290
|
}
|
|
2261
2291
|
: {
|
|
2262
2292
|
...(ctx.taskId !== undefined ? { parentTaskId: ctx.taskId } : {}),
|
|
2263
2293
|
...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
|
|
2264
2294
|
...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
|
|
2265
2295
|
...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
|
|
2296
|
+
...(ctx.rootSessionScope !== undefined ? { rootSessionScope: ctx.rootSessionScope } : {}),
|
|
2266
2297
|
...(ctx.placementRoot !== undefined ? { placementRoot: ctx.placementRoot } : {}),
|
|
2267
2298
|
}),
|
|
2268
2299
|
...(ctx.centerArtifactDigest !== undefined ? { parentCenterArtifactDigest: ctx.centerArtifactDigest } : {}),
|
|
2269
2300
|
...(ctx.centerSourceRevision !== undefined ? { parentCenterSourceRevision: ctx.centerSourceRevision } : {}),
|
|
2270
2301
|
...(() => {
|
|
2271
2302
|
const viaRoot = reviveClaim !== undefined && (ctx.parentTaskId !== undefined || ctx.sessionId === undefined);
|
|
2272
|
-
const address = viaRoot ? (reviveClaim.row
|
|
2303
|
+
const address = viaRoot ? delegationRootOf(reviveClaim.row) : ctx.sessionId;
|
|
2273
2304
|
const injector = viaRoot ? undefined : ctx.onTaskNotification;
|
|
2274
2305
|
return {
|
|
2275
2306
|
...(address !== undefined ? { uplinkSessionId: address } : {}),
|
|
@@ -2546,7 +2577,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2546
2577
|
const notify = backgroundSink;
|
|
2547
2578
|
const abort = new AbortController();
|
|
2548
2579
|
const sessionScopedBg = ctx.backgroundScope === "session" && ctx.sessionId !== undefined;
|
|
2549
|
-
const onHostAbort = (
|
|
2580
|
+
const onHostAbort = hostAbortListener(ctx, abort);
|
|
2550
2581
|
const dropHostAbortListener = () => ctx.signal?.removeEventListener("abort", onHostAbort);
|
|
2551
2582
|
if (ctx.signal) {
|
|
2552
2583
|
if (ctx.signal.aborted)
|
|
@@ -2631,12 +2662,14 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2631
2662
|
...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
|
|
2632
2663
|
...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
|
|
2633
2664
|
...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
|
|
2665
|
+
...(ctx.rootSessionScope !== undefined ? { rootSessionScope: ctx.rootSessionScope } : {}),
|
|
2634
2666
|
...(rowModelKey !== undefined ? { model: rowModelKey } : {}),
|
|
2635
2667
|
deliveryChannel: "attaching",
|
|
2636
2668
|
toolUseId: ctx.toolCallId,
|
|
2637
2669
|
...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}),
|
|
2638
2670
|
...(bg.agentStore !== undefined ? { store: bg.agentStore, policyFloor: spawnPolicyFloor() } : {}),
|
|
2639
2671
|
abort,
|
|
2672
|
+
yieldLane: "fork_child",
|
|
2640
2673
|
});
|
|
2641
2674
|
}
|
|
2642
2675
|
catch (e) {
|
|
@@ -2737,13 +2770,13 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2737
2770
|
...(currentTool !== undefined ? { currentTool } : {}),
|
|
2738
2771
|
usage: { toolUses: toolStarts },
|
|
2739
2772
|
});
|
|
2740
|
-
}
|
|
2773
|
+
});
|
|
2741
2774
|
const bgForkInternals = bgSink
|
|
2742
2775
|
? {
|
|
2743
2776
|
...forkInternals,
|
|
2744
2777
|
...(forkQuestionStrip !== undefined ? forkQuestionStrip.internalsFlag : {}),
|
|
2745
2778
|
onNotifyInjectorReady: s2ForkNotifyReady,
|
|
2746
|
-
...backgroundLegFacts(taskId, bgForkCycleSeq),
|
|
2779
|
+
...backgroundLegFacts(taskId, bgForkCycleSeq, bgRegistry),
|
|
2747
2780
|
onForwardEvent: (e) => {
|
|
2748
2781
|
try {
|
|
2749
2782
|
recordingForward(e, { bgAgentId: taskId });
|
|
@@ -2778,7 +2811,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2778
2811
|
...forkInternals,
|
|
2779
2812
|
...(forkQuestionStrip !== undefined ? forkQuestionStrip.internalsFlag : {}),
|
|
2780
2813
|
onNotifyInjectorReady: s2ForkNotifyReady,
|
|
2781
|
-
...backgroundLegFacts(taskId, bgForkCycleSeq),
|
|
2814
|
+
...backgroundLegFacts(taskId, bgForkCycleSeq, bgRegistry),
|
|
2782
2815
|
onForwardEvent: (e) => {
|
|
2783
2816
|
try {
|
|
2784
2817
|
recordingForward(e, { bgAgentId: taskId });
|
|
@@ -2881,7 +2914,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2881
2914
|
void finishWorktree();
|
|
2882
2915
|
const killed = abort.signal.aborted;
|
|
2883
2916
|
const msgFork = childThrownText(e);
|
|
2884
|
-
const errCodeForkReject = killed ? undefined :
|
|
2917
|
+
const errCodeForkReject = killed ? undefined : childRowCode(childFailureOf(e));
|
|
2885
2918
|
const errClassForkReject = killed ? undefined : classifySubagentError({ kind: "failed", ...(errCodeForkReject !== undefined ? { code: errCodeForkReject } : {}) });
|
|
2886
2919
|
const settleWinnerForkReject = bgRegistry.settleBackgroundAgent(taskId, {
|
|
2887
2920
|
cycle: 0,
|
|
@@ -2979,7 +3012,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2979
3012
|
catch {
|
|
2980
3013
|
}
|
|
2981
3014
|
const wt = await finishWorktree();
|
|
2982
|
-
return { isError: true, content: `Fork failed: the forked run threw (${childThrownText(e)}).${wt ? `\n${wt}` : ""}`, details:
|
|
3015
|
+
return { isError: true, content: `Fork failed: the forked run threw (${childThrownText(e)}).${wt ? `\n${wt}` : ""}`, details: thrownMarksOf(childRejection(e)) ?? {} };
|
|
2983
3016
|
}
|
|
2984
3017
|
finally {
|
|
2985
3018
|
syncForkAdmission.release();
|
|
@@ -3046,14 +3079,17 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3046
3079
|
if (ctx.checkpointStoreForChildren !== undefined && ctx.checkpointStoreForChildren !== "disabled" && bg.checkpointStore !== undefined && bg.checkpointStore !== ctx.checkpointStoreForChildren)
|
|
3047
3080
|
throw configError("background.checkpointStore is not the store this run's children park in (the host's resolved checkpoint seat, TaskSpec/RunnerDeps.checkpointStore) — wire the one store, or leave the option unset and let the seat ride.", "config.invalid_checkpoint_store");
|
|
3048
3081
|
const childParkStore = ctx.checkpointStoreForChildren === undefined ? bg.checkpointStore : ctx.checkpointStoreForChildren === "disabled" ? undefined : ctx.checkpointStoreForChildren;
|
|
3082
|
+
const parkCapable = bg.agentStore !== undefined && childParkStore !== undefined && bg.ensureChildSessionDurable !== undefined;
|
|
3083
|
+
const legYield = parkCapable ? new AbortController() : undefined;
|
|
3049
3084
|
const notify = backgroundSink;
|
|
3050
3085
|
const abort = new AbortController();
|
|
3051
3086
|
const reviveRow = reviveClaim?.row;
|
|
3052
3087
|
const parkedResume = reviveClaim?.parkedResume;
|
|
3053
|
-
let cycleSink = parkedResume !== undefined &&
|
|
3088
|
+
let cycleSink = parkedResume !== undefined && heldInRegistry !== undefined ? heldInRegistry : notify;
|
|
3089
|
+
let attemptEnding;
|
|
3054
3090
|
const sessionScopedBg = reviveRow !== undefined ? reviveRow.sessionScoped : ctx.backgroundScope === "session" && ctx.sessionId !== undefined;
|
|
3055
3091
|
const outlivesThisRequest = sessionScopedBg || reviveRow !== undefined;
|
|
3056
|
-
const onHostAbort = (
|
|
3092
|
+
const onHostAbort = hostAbortListener(ctx, abort);
|
|
3057
3093
|
const dropHostAbortListener = () => ctx.signal?.removeEventListener("abort", onHostAbort);
|
|
3058
3094
|
if (ctx.signal) {
|
|
3059
3095
|
if (ctx.signal.aborted)
|
|
@@ -3148,8 +3184,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3148
3184
|
name: reviveRow.name,
|
|
3149
3185
|
...(reviveRow.parentTaskId !== undefined ? { parentTaskId: reviveRow.parentTaskId } : {}),
|
|
3150
3186
|
...(reviveRow.parentSessionId !== undefined ? { parentSessionId: reviveRow.parentSessionId } : {}),
|
|
3151
|
-
...((reviveRow
|
|
3152
|
-
? { rootSessionId: reviveRow
|
|
3187
|
+
...(delegationRootOf(reviveRow) !== undefined
|
|
3188
|
+
? { rootSessionId: delegationRootOf(reviveRow) }
|
|
3153
3189
|
: {}),
|
|
3154
3190
|
...(reviveRow.model !== undefined ? { model: reviveRow.model } : {}),
|
|
3155
3191
|
deliveryChannel: "attaching",
|
|
@@ -3171,6 +3207,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3171
3207
|
}
|
|
3172
3208
|
: {}),
|
|
3173
3209
|
abort,
|
|
3210
|
+
yieldLane: parkCapable ? "parkable" : "no_park_lane",
|
|
3174
3211
|
}
|
|
3175
3212
|
: {
|
|
3176
3213
|
...(bgOwner !== undefined ? { owner: bgOwner } : {}),
|
|
@@ -3184,12 +3221,14 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3184
3221
|
...(ctx.sessionId !== undefined ? { parentSessionId: ctx.sessionId } : {}),
|
|
3185
3222
|
...((ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}),
|
|
3186
3223
|
...(ctx.rootSessionIncarnation !== undefined ? { rootSessionIncarnation: ctx.rootSessionIncarnation } : {}),
|
|
3224
|
+
...(ctx.rootSessionScope !== undefined ? { rootSessionScope: ctx.rootSessionScope } : {}),
|
|
3187
3225
|
...(rowModelKey !== undefined ? { model: rowModelKey } : {}),
|
|
3188
3226
|
deliveryChannel: "attaching",
|
|
3189
3227
|
toolUseId: ctx.toolCallId,
|
|
3190
3228
|
...(ctx.crossBoundaryTreeForChildren !== undefined ? { crossBoundaryTree: ctx.crossBoundaryTreeForChildren } : {}),
|
|
3191
3229
|
...(bg.agentStore !== undefined ? { store: bg.agentStore, policyFloor: spawnPolicyFloor() } : {}),
|
|
3192
3230
|
abort,
|
|
3231
|
+
yieldLane: parkCapable ? "parkable" : "no_park_lane",
|
|
3193
3232
|
});
|
|
3194
3233
|
}
|
|
3195
3234
|
catch (e) {
|
|
@@ -3211,7 +3250,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3211
3250
|
oweTerminalDelivery(notify, { task_id: taskId, task_type: "background_agent" });
|
|
3212
3251
|
childInternals.peerSelfRef?.addAxis("h", taskId);
|
|
3213
3252
|
if (agentName !== undefined) {
|
|
3214
|
-
recordRosterSpawn(ctx.roster, { name: agentName, agentId: taskId, toolUseId: ctx.toolCallId, owner: bgOwner, scope: bgScope, ...(reviveRow !== undefined ? (reviveRow.model !== undefined ? { model: reviveRow.model } : {}) : rowModelKey !== undefined ? { model: rowModelKey } : {}), ...(modelFallback !== undefined ? { modelFallback } : {}), ...(reviveRow !== undefined ? ((reviveRow
|
|
3253
|
+
recordRosterSpawn(ctx.roster, { name: agentName, agentId: taskId, toolUseId: ctx.toolCallId, owner: bgOwner, scope: bgScope, ...(reviveRow !== undefined ? (reviveRow.model !== undefined ? { model: reviveRow.model } : {}) : rowModelKey !== undefined ? { model: rowModelKey } : {}), ...(modelFallback !== undefined ? { modelFallback } : {}), ...(reviveRow !== undefined ? (delegationRootOf(reviveRow) !== undefined ? { rootSessionId: delegationRootOf(reviveRow) } : {}) : (ctx.rootSessionId ?? ctx.sessionId) !== undefined ? { rootSessionId: ctx.rootSessionId ?? ctx.sessionId } : {}), ...(sessionScopedBg ? { sessionScoped: true } : {}), createdAt: reviveRow?.spawnedAt ?? Date.now() }, (err) => opts.onObserverError?.(err, { site: "roster.recordSpawn" }));
|
|
3215
3254
|
}
|
|
3216
3255
|
const bgSink = ctx.onBackgroundChildEvent;
|
|
3217
3256
|
const sinkEmit = (event) => {
|
|
@@ -3271,7 +3310,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3271
3310
|
? {
|
|
3272
3311
|
...(reviveRow.parentTaskId !== undefined ? { parentTaskId: reviveRow.parentTaskId } : {}),
|
|
3273
3312
|
...(reviveRow.parentSessionId !== undefined ? { parentSessionId: reviveRow.parentSessionId } : {}),
|
|
3274
|
-
...((reviveRow
|
|
3313
|
+
...(delegationRootOf(reviveRow) !== undefined ? { rootSessionId: delegationRootOf(reviveRow) } : {}),
|
|
3275
3314
|
}
|
|
3276
3315
|
: {
|
|
3277
3316
|
...(ctx.taskId !== undefined && ctx.taskId !== ctx.sessionId ? { parentTaskId: ctx.taskId } : {}),
|
|
@@ -3300,14 +3339,12 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3300
3339
|
};
|
|
3301
3340
|
}
|
|
3302
3341
|
bgRegistry.bindBackgroundAgentSession(taskId, bgChildSessionId, opts.runner.sessions);
|
|
3303
|
-
const forwardDurableApproval = ctx.durableApprovalForChildren !== undefined &&
|
|
3304
|
-
bg.agentStore !== undefined &&
|
|
3305
|
-
childParkStore !== undefined &&
|
|
3306
|
-
bg.ensureChildSessionDurable !== undefined;
|
|
3342
|
+
const forwardDurableApproval = ctx.durableApprovalForChildren !== undefined && parkCapable;
|
|
3307
3343
|
const bgSpecBase = {
|
|
3308
3344
|
...buildChildSpec(abort.signal),
|
|
3309
3345
|
sessionId: bgChildSessionId,
|
|
3310
3346
|
...(forwardDurableApproval ? { durableApproval: { ...ctx.durableApprovalForChildren } } : {}),
|
|
3347
|
+
...(legYield !== undefined ? { preemptSignal: legYield.signal } : {}),
|
|
3311
3348
|
...(reviveRow !== undefined ? { requireExistingSession: true } : {}),
|
|
3312
3349
|
};
|
|
3313
3350
|
const bgQuestionStrip = outlivesThisRequest ? stripSpawnTurnQuestionFace(bgSpecBase) : undefined;
|
|
@@ -3341,17 +3378,17 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3341
3378
|
...(currentTool !== undefined ? { currentTool } : {}),
|
|
3342
3379
|
usage: { toolUses: toolStarts },
|
|
3343
3380
|
});
|
|
3344
|
-
}
|
|
3381
|
+
});
|
|
3345
3382
|
const bgPlacement = placedTreeOwner !== undefined
|
|
3346
3383
|
? { ...subagentTranscriptPlacement(ctx, bgScope, taskId), owner: placedTreeOwner }
|
|
3347
3384
|
: undefined;
|
|
3348
|
-
const
|
|
3385
|
+
const bgLaneInternals = bgSink
|
|
3349
3386
|
? {
|
|
3350
3387
|
...childInternals,
|
|
3351
3388
|
...(bgQuestionStrip !== undefined ? bgQuestionStrip.internalsFlag : {}),
|
|
3352
3389
|
...(bgPlacement !== undefined ? { sessionPlacement: bgPlacement } : {}),
|
|
3353
3390
|
onNotifyInjectorReady: s2NotifyReady,
|
|
3354
|
-
...backgroundLegFacts(taskId, bgCycleSeq),
|
|
3391
|
+
...backgroundLegFacts(taskId, bgCycleSeq, bgRegistry),
|
|
3355
3392
|
onForwardEvent: (e) => {
|
|
3356
3393
|
try {
|
|
3357
3394
|
recordingForward(e, { bgAgentId: taskId });
|
|
@@ -3387,7 +3424,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3387
3424
|
...(bgQuestionStrip !== undefined ? bgQuestionStrip.internalsFlag : {}),
|
|
3388
3425
|
...(bgPlacement !== undefined ? { sessionPlacement: bgPlacement } : {}),
|
|
3389
3426
|
onNotifyInjectorReady: s2NotifyReady,
|
|
3390
|
-
...backgroundLegFacts(taskId, bgCycleSeq),
|
|
3427
|
+
...backgroundLegFacts(taskId, bgCycleSeq, bgRegistry),
|
|
3391
3428
|
onForwardEvent: (e) => {
|
|
3392
3429
|
try {
|
|
3393
3430
|
recordingForward(e, { bgAgentId: taskId });
|
|
@@ -3397,10 +3434,16 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3397
3434
|
bgActivityBeat(e);
|
|
3398
3435
|
},
|
|
3399
3436
|
};
|
|
3437
|
+
const bgInternals = legYield !== undefined ? { ...bgLaneInternals, reportSuspendLane: ({ ready }) => bgRegistry.attachYieldLeg(taskId, legYield, ready) } : bgLaneInternals;
|
|
3400
3438
|
const driveParkedResume = async () => {
|
|
3401
3439
|
const pr = parkedResume;
|
|
3402
3440
|
const claimStores = { agentStore: bg.agentStore, checkpointStore: childParkStore };
|
|
3403
|
-
|
|
3441
|
+
const endAttempt = (ending, cause, account) => {
|
|
3442
|
+
attemptEnding = ending;
|
|
3443
|
+
if (!PARKED_CLAIM_ROLLBACK_FACE[ending].carriesTerminal)
|
|
3444
|
+
cycleSink = undefined;
|
|
3445
|
+
throw new Error(`${PARKED_CLAIM_ROLLBACK_FACE[ending].lead}: ${account}`, { cause });
|
|
3446
|
+
};
|
|
3404
3447
|
const rollbackAndThrow = async (e) => {
|
|
3405
3448
|
let disp = "retry";
|
|
3406
3449
|
try {
|
|
@@ -3408,14 +3451,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3408
3451
|
}
|
|
3409
3452
|
catch {
|
|
3410
3453
|
}
|
|
3411
|
-
|
|
3412
|
-
cycleSink = undefined;
|
|
3413
|
-
const msg = thrownText(e);
|
|
3414
|
-
throw new Error(disp === "rolled_back"
|
|
3415
|
-
? `parked resume rolled back — the approval is still pending (retryable): ${msg}`
|
|
3416
|
-
: disp === "failed"
|
|
3417
|
-
? `parked resume failed — the approval is no longer redeemable: ${msg}`
|
|
3418
|
-
: `parked resume did not proceed (${disp}): ${msg}`, { cause: e });
|
|
3454
|
+
return endAttempt(attemptEnding ?? disp, e, thrownText(e));
|
|
3419
3455
|
};
|
|
3420
3456
|
if (floorRefusal !== undefined)
|
|
3421
3457
|
return rollbackAndThrow(Object.assign(new Error(`the agent was not resumed: ${inlineUntrusted(floorRefusal, 400)}, so the restrictions it ran under cannot be held on a new cycle`), { code: "revive.policy_floor_unreadable" }));
|
|
@@ -3425,7 +3461,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3425
3461
|
await opts.runner.sessions.forget(bgChildSessionId);
|
|
3426
3462
|
}
|
|
3427
3463
|
catch (e) {
|
|
3428
|
-
const code = e
|
|
3464
|
+
const code = readMember(e, "code");
|
|
3429
3465
|
if (code === "not_found") {
|
|
3430
3466
|
try {
|
|
3431
3467
|
const cp = (await childParkStore.get(pr.ticket.token));
|
|
@@ -3459,25 +3495,19 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3459
3495
|
return rollbackAndThrow(e);
|
|
3460
3496
|
}
|
|
3461
3497
|
if (!seat || seat.parkClaimId !== pr.ticket.claimId) {
|
|
3462
|
-
|
|
3463
|
-
"
|
|
3464
|
-
"re-list pending approvals and claim afresh");
|
|
3498
|
+
return rollbackAndThrow(new Error("this claim ticket is no longer seated on the row (rolled back, swept stale, or " +
|
|
3499
|
+
"superseded by a newer claim) — the approval was NOT consumed; re-list pending approvals and claim afresh"));
|
|
3465
3500
|
}
|
|
3466
3501
|
}
|
|
3467
3502
|
const afterCheckpointResolve = async () => {
|
|
3503
|
+
attemptEnding = "failed";
|
|
3468
3504
|
const won = await bgRegistry.consumeParkedFlip(taskId, { agentStore: bg.agentStore }, pr.ticket);
|
|
3469
3505
|
if (!won)
|
|
3470
3506
|
throw new Error("the parked row moved under the resume (a stop or another transition won) — resume aborted");
|
|
3471
|
-
moveTerminalDelivery(
|
|
3507
|
+
moveTerminalDelivery(heldInRegistry, notify, { task_id: taskId, task_type: "background_agent" });
|
|
3472
3508
|
cycleSink = notify;
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
deliverEngineNotice(undefined, {
|
|
3476
|
-
code: "delegation.resume_lane_missing",
|
|
3477
|
-
message: `the parked agent ${taskId} was resumed with no run lane in this process to complete into (it parked in another process, or before this one restarted): its completion goes to the deployment's background channel, and a submission still waiting on it elsewhere is not settled by it`,
|
|
3478
|
-
detail: { taskId, ...(reviveRow?.rootSessionId !== undefined ? { rootSessionId: reviveRow.rootSessionId } : {}) },
|
|
3479
|
-
});
|
|
3480
|
-
}
|
|
3509
|
+
if (rowRoot !== undefined)
|
|
3510
|
+
deliverEngineNotice(undefined, resumeLaneMissingNotice(taskId, reviveRow?.rootSessionId, rootSessionLaneOf(opts.runner, rowRoot.address)));
|
|
3481
3511
|
};
|
|
3482
3512
|
let childResult;
|
|
3483
3513
|
try {
|
|
@@ -3486,8 +3516,9 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3486
3516
|
try {
|
|
3487
3517
|
const cp0 = (await childParkStore.get(pr.ticket.token));
|
|
3488
3518
|
const rec = cp0?.durableApproval;
|
|
3489
|
-
|
|
3490
|
-
|
|
3519
|
+
const recScope = declaredCheckpointScope(rec);
|
|
3520
|
+
if (rec !== undefined && recScope !== undefined) {
|
|
3521
|
+
resumeConfig.durableApproval = { scope: recScope, ...(typeof rec.ttlMs === "number" ? { ttlMs: sanitizedTtlMs(rec.ttlMs) } : {}) };
|
|
3491
3522
|
}
|
|
3492
3523
|
else if (rec === undefined && cp0?.gate?.kind === "human" && typeof cp0.scope === "string" && cp0.scope.length > 0) {
|
|
3493
3524
|
resumeConfig.durableApproval = { scope: cp0.scope };
|
|
@@ -3535,9 +3566,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3535
3566
|
return await cpS.expire(pr.ticket.token, cp.scope);
|
|
3536
3567
|
},
|
|
3537
3568
|
});
|
|
3538
|
-
|
|
3539
|
-
cycleSink = undefined;
|
|
3540
|
-
throw new Error(`parked resume could not complete and the approval was REOPENED (still approvable/retryable): ${childResult.terminal.message ?? "failed"}`, { cause: childResult.terminal });
|
|
3569
|
+
return endAttempt(reParked === "parked" ? "rolled_back" : "failed", childResult.terminal, `the resumed run could not complete and its checkpoint was REOPENED: ${childResult.terminal.message ?? "failed"}`);
|
|
3541
3570
|
}
|
|
3542
3571
|
}
|
|
3543
3572
|
return childResult;
|
|
@@ -3555,6 +3584,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3555
3584
|
})();
|
|
3556
3585
|
})()
|
|
3557
3586
|
: opts.runner.runTask(bgSpec, bgInternals);
|
|
3587
|
+
const bgChildRejection = bgChildPromise.then(() => undefined, rejectedChildOf);
|
|
3558
3588
|
extensionSpawn?.launched(taskId, spawnModel);
|
|
3559
3589
|
void bgChildPromise
|
|
3560
3590
|
.then(async (child) => {
|
|
@@ -3562,7 +3592,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3562
3592
|
const rowSettled = settleDelegationRow(child.terminal);
|
|
3563
3593
|
closeObserverWindow(childFace.status);
|
|
3564
3594
|
dropHostAbortListener();
|
|
3565
|
-
await rowSettled;
|
|
3595
|
+
await settleTeardownLeg(() => rowSettled, "delegation settlement terminal write", reportWedgedLeg("delegation.settleRow"));
|
|
3566
3596
|
await finishWorktree(child.terminal);
|
|
3567
3597
|
try {
|
|
3568
3598
|
const ns2 = child.stats.nested;
|
|
@@ -3597,6 +3627,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3597
3627
|
let unparkedPause;
|
|
3598
3628
|
if (isDurablePause(child.terminal)) {
|
|
3599
3629
|
const pausedToken = child.terminal.token;
|
|
3630
|
+
const pausedCheckpointId = child.terminal.checkpointId;
|
|
3600
3631
|
const cpStore = childParkStore;
|
|
3601
3632
|
const expireByStoreScope = async (token2) => {
|
|
3602
3633
|
try {
|
|
@@ -3609,8 +3640,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3609
3640
|
return false;
|
|
3610
3641
|
}
|
|
3611
3642
|
};
|
|
3612
|
-
|
|
3613
|
-
if (wired) {
|
|
3643
|
+
if (parkCapable) {
|
|
3614
3644
|
const token = pausedToken;
|
|
3615
3645
|
if (abort.signal.aborted) {
|
|
3616
3646
|
await expireByStoreScope(token);
|
|
@@ -3627,7 +3657,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3627
3657
|
catch {
|
|
3628
3658
|
attested = false;
|
|
3629
3659
|
}
|
|
3630
|
-
const parked = attested
|
|
3660
|
+
const parked = attested && !abort.signal.aborted
|
|
3631
3661
|
? bgRegistry.parkBackgroundAgent(taskId, {
|
|
3632
3662
|
checkpointToken: token,
|
|
3633
3663
|
seq: seqAtSettle ?? 1,
|
|
@@ -3648,7 +3678,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3648
3678
|
}
|
|
3649
3679
|
}
|
|
3650
3680
|
else {
|
|
3651
|
-
unparkedPause = { kind: "no_park_lane",
|
|
3681
|
+
unparkedPause = { kind: "no_park_lane", checkpointId: pausedCheckpointId };
|
|
3652
3682
|
}
|
|
3653
3683
|
}
|
|
3654
3684
|
const ok = child.terminal.kind === "completed";
|
|
@@ -3748,7 +3778,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3748
3778
|
const rowSettled = settleDelegationRow({ kind: "failed" });
|
|
3749
3779
|
closeObserverWindow("failed");
|
|
3750
3780
|
dropHostAbortListener();
|
|
3751
|
-
await rowSettled;
|
|
3781
|
+
await settleTeardownLeg(() => rowSettled, "delegation settlement terminal write", reportWedgedLeg("delegation.settleRow"));
|
|
3782
|
+
const rejected = (await bgChildRejection) ?? rejectedChildOf(e);
|
|
3752
3783
|
void finishWorktree();
|
|
3753
3784
|
const killed = abort.signal.aborted;
|
|
3754
3785
|
const seqAtSettle = cycleSeqOfFrames();
|
|
@@ -3758,8 +3789,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3758
3789
|
else
|
|
3759
3790
|
bgRetainLedger?.markSettled(ctx.toolCallId);
|
|
3760
3791
|
}
|
|
3761
|
-
const msg =
|
|
3762
|
-
const errCodeBgReject = killed ? undefined :
|
|
3792
|
+
const msg = rejected.text;
|
|
3793
|
+
const errCodeBgReject = killed ? undefined : childRowCode(rejected.failure);
|
|
3763
3794
|
const errClassBgReject = killed ? undefined : classifySubagentError({ kind: "failed", ...(errCodeBgReject !== undefined ? { code: errCodeBgReject } : {}) });
|
|
3764
3795
|
const settleWinnerBgReject = bgRegistry.settleBackgroundAgent(taskId, {
|
|
3765
3796
|
cycle: 0,
|
|
@@ -3808,13 +3839,17 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3808
3839
|
]);
|
|
3809
3840
|
if (startup === "settled") {
|
|
3810
3841
|
if (parkedResume !== undefined) {
|
|
3811
|
-
const
|
|
3842
|
+
const rejected = await bgChildRejection;
|
|
3843
|
+
const failure = rejected !== undefined
|
|
3844
|
+
? { err: rejected.text, cause: resumeStartupCauseOf(childRowCode(rejected.failure)), refusal: resumeRefusalDetailOf(rejected.failure.detail) }
|
|
3845
|
+
: await bgChildPromise.then((r) => ({ err: undefined, cause: resumeStartupCauseOf(r.terminal.kind === "failed" ? r.terminal.code : undefined), refusal: undefined }));
|
|
3812
3846
|
return {
|
|
3813
3847
|
isError: true,
|
|
3814
|
-
content: `Parked resume did not complete: ${(failure.err ?? "the resumed run settled before its delivery lane bound"
|
|
3848
|
+
content: `Parked resume did not complete: ${inlineUntrusted(failure.err ?? "the resumed run settled before its delivery lane bound", 600)}`,
|
|
3815
3849
|
details: {
|
|
3816
3850
|
error: "parked_resume.startup_failed",
|
|
3817
3851
|
task_id: taskId,
|
|
3852
|
+
...(attemptEnding !== undefined ? { rollback: attemptEnding } : {}),
|
|
3818
3853
|
...(failure.cause !== undefined ? { cause: failure.cause } : {}),
|
|
3819
3854
|
...(failure.refusal !== undefined ? { detail: failure.refusal } : {}),
|
|
3820
3855
|
},
|
|
@@ -3874,7 +3909,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3874
3909
|
ledger: ctx.subagentRetain,
|
|
3875
3910
|
parentToolCallId: ctx.toolCallId,
|
|
3876
3911
|
runner: opts.runner,
|
|
3877
|
-
|
|
3912
|
+
notify: rootSessionSink(opts.runner, rootSessionAddressOf(childInternals), background?.notify),
|
|
3878
3913
|
sink: ctx.onSubagentSpawn,
|
|
3879
3914
|
...(backgroundRegistry ? { registry: backgroundRegistry } : {}),
|
|
3880
3915
|
entryGate: syncEntryGate,
|