@sema-agent/core 7.72.0 → 7.74.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 +565 -0
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +46 -2
- package/dist/agents/list-agents-tool.js +1 -1
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/retain-ledger.js +3 -3
- package/dist/agents/send-message-tool.js +5 -4
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +43 -12
- package/dist/agents/verify.js +23 -8
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.d.ts +42 -1
- package/dist/brain/anthropic.js +68 -13
- package/dist/brain/failover.d.ts +5 -0
- package/dist/brain/failover.js +51 -22
- package/dist/brain/model-lane.d.ts +12 -3
- package/dist/brain/model-lane.js +5 -5
- package/dist/brain/open-responses.js +7 -8
- package/dist/brain/openai.js +31 -24
- package/dist/brain/route-adjudicator.d.ts +33 -4
- package/dist/brain/route-adjudicator.js +49 -12
- package/dist/brain/stream-engine.js +166 -156
- package/dist/brain/stream-shared.d.ts +4 -3
- package/dist/brain/stream-shared.js +2 -2
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/allow-entry.js +4 -4
- package/dist/core/ask-class.d.ts +2 -2
- package/dist/core/ask-headline.d.ts +1 -1
- package/dist/core/ask-origin.d.ts +44 -4
- package/dist/core/ask-origin.js +29 -10
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/background-agent-store.d.ts +1 -0
- package/dist/core/background-agent-store.js +49 -8
- package/dist/core/checkpoint-features.d.ts +3 -2
- package/dist/core/checkpoint-features.js +1 -1
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +9 -3
- package/dist/core/checkpoint-store.d.ts +26 -2
- package/dist/core/checkpoint-store.js +9 -2
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/cron.js +9 -1
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/deployment-shape.d.ts +7 -0
- package/dist/core/deployment-shape.js +19 -0
- package/dist/core/engine-capabilities.d.ts +13 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +41 -28
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/gate-fold.js +5 -4
- package/dist/core/gate-lanes.js +8 -12
- package/dist/core/gate-outcome.d.ts +8 -2
- package/dist/core/gate-outcome.js +10 -3
- package/dist/core/governance-codes.d.ts +14 -2
- package/dist/core/governance-codes.js +22 -6
- package/dist/core/hook-condition.d.ts +37 -0
- package/dist/core/hook-condition.js +567 -0
- package/dist/core/hooks.d.ts +5 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +18 -13
- package/dist/core/memory-engine/scope-contract.js +18 -18
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +25 -6
- package/dist/core/mode-policy.js +33 -8
- package/dist/core/model-seat.d.ts +8 -5
- package/dist/core/model-shell.d.ts +129 -0
- package/dist/core/model-shell.js +249 -0
- package/dist/core/mods/kernel/digest.d.ts +4 -0
- package/dist/core/mods/kernel/digest.js +5 -0
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +15 -6
- package/dist/core/mods/kernel/events.d.ts +21 -5
- package/dist/core/mods/kernel/events.js +19 -10
- package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
- package/dist/core/mods/kernel/hash-mirror.js +55 -0
- package/dist/core/mods/kernel/index.d.ts +1 -0
- package/dist/core/mods/kernel/index.js +1 -0
- package/dist/core/mods/kernel/package-reader.d.ts +48 -0
- package/dist/core/mods/kernel/package-reader.js +149 -0
- package/dist/core/mods/kernel/site-rules.d.ts +4 -0
- package/dist/core/mods/kernel/site-rules.js +13 -0
- package/dist/core/mods/package.d.ts +7 -3
- package/dist/core/mods/package.js +47 -80
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/parent-spec-seat.d.ts +13 -11
- package/dist/core/parent-spec-seat.js +13 -9
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +33 -5
- package/dist/core/permission-rule-org.js +13 -3
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/permission-rules.js +4 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retain-seat.d.ts +42 -0
- package/dist/core/retain-seat.js +76 -0
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rewind-refusal-codes.d.ts +8 -0
- package/dist/core/rewind-refusal-codes.js +12 -0
- package/dist/core/roles.d.ts +2 -2
- package/dist/core/roles.js +15 -1
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/rule-store-fault.d.ts +9 -7
- package/dist/core/rule-store-fault.js +8 -3
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/checkpoint-scope.d.ts +14 -3
- package/dist/core/runner/checkpoint-scope.js +16 -6
- package/dist/core/runner/compact-session.js +1 -1
- package/dist/core/runner/construction-doors.js +8 -0
- package/dist/core/runner/contracts.d.ts +21 -5
- package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
- package/dist/core/runner/cross-boundary-lane.js +4 -0
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/gate-exit.d.ts +7 -0
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/model-lane-seat.d.ts +3 -0
- package/dist/core/runner/model-lane-seat.js +4 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +27 -16
- package/dist/core/runner/person-path-rows.js +93 -15
- package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +13 -7
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
- package/dist/core/runner/prepare-hands-readface.js +15 -3
- package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
- package/dist/core/runner/prepare-inherited-gate.js +13 -5
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +42 -30
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -6
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-policy-outcome.js +5 -2
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
- package/dist/core/runner/role-seat-defaulted.js +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
- package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
- package/dist/core/runner/run-harness-handlers.js +4 -1
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +5 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +6 -4
- package/dist/core/runner/shell-env-withheld.js +25 -3
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/sub-agent-deny-lists.js +9 -5
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +6 -1
- package/dist/core/runner/terminal-account.js +16 -1
- package/dist/core/runner/tool-end-body.d.ts +1 -1
- package/dist/core/runner/tool-not-executed.d.ts +27 -8
- package/dist/core/runner/tool-not-executed.js +22 -11
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner/write-protection-station.d.ts +1 -1
- package/dist/core/runner/write-protection-station.js +1 -1
- package/dist/core/runner-deps.d.ts +17 -10
- package/dist/core/secret-env.d.ts +61 -37
- package/dist/core/secret-env.js +49 -49
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.d.ts +40 -2
- package/dist/core/shell-read-silence.js +23 -4
- package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +14 -7
- package/dist/core/task-notification.d.ts +96 -10
- package/dist/core/task-notification.js +135 -6
- package/dist/core/task-registry-agent.d.ts +1 -0
- package/dist/core/task-registry-agent.js +1 -1
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +40 -2
- package/dist/core/task-registry.js +80 -15
- package/dist/core/task-result.d.ts +18 -3
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +19 -3
- package/dist/core/task-spec.d.ts +48 -22
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-gate-phase.d.ts +6 -3
- package/dist/core/tool-gate-phase.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +8 -4
- package/dist/core/tool-mount-facts.js +7 -2
- package/dist/core/tool-mount-plan.d.ts +3 -1
- package/dist/core/tool-mount-plan.js +10 -3
- package/dist/core/tool-mount-static.d.ts +1 -1
- package/dist/core/tool-mount-static.js +4 -2
- package/dist/core/tool-result-store.d.ts +56 -3
- package/dist/core/tool-result-store.js +219 -25
- package/dist/core/tool-spec.d.ts +9 -2
- package/dist/core/trace.d.ts +3 -3
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +26 -20
- package/dist/core/wiring-manifest.js +7 -3
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
- package/dist/engine/execution-env/node-execution-env.js +227 -13
- package/dist/engine/harness/types.d.ts +49 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +13 -7
- package/dist/engine/llm/validation.d.ts +8 -1
- package/dist/engine/llm/validation.js +31 -2
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +34 -4
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +1 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +22 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/goal.js +1 -1
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-primitives.js +10 -1
- package/dist/orchestration/workflow-script-runner.d.ts +2 -2
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +31 -7
- package/dist/orchestration/workflow.js +119 -57
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/shell/lex.d.ts +2 -2
- package/dist/shell/lex.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/fs/bash-model-shell.d.ts +23 -0
- package/dist/tools/fs/bash-model-shell.js +25 -0
- package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
- package/dist/tools/fs/bash-readonly-classifier.js +3 -0
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/fs-bash.js +13 -11
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +4 -1
- package/dist/tools/fs/safety.js +4 -2
- package/dist/tools/fs/shell-read-argv.js +1 -0
- package/dist/tools/fs/shell-read-check.d.ts +9 -2
- package/dist/tools/fs/shell-read-check.js +134 -22
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +21 -11
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +7 -3
- package/dist/tools/fs/shell-read-plan.js +8 -5
- package/dist/tools/fs/shell-read-word.d.ts +8 -0
- package/dist/tools/fs/shell-read-word.js +13 -4
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/monitor.js +12 -8
- package/dist/tools/scheduler-tools.d.ts +1 -0
- package/dist/tools/scheduler-tools.js +5 -2
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +192 -3
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/core@7.74.0.json +68 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/primitives@7.74.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core-stores-sql@7.74.0.json +143 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/core@7.74.0.json +2210 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/mods-kernel@7.74.0.json +421 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/primitives@7.74.0.json +174 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
- package/wire-changes/wiki-gate@7.74.0.json +145 -0
|
@@ -2,7 +2,7 @@ import type { AgentDefinition, McpServerSpec, ToolSpec } from "../core/types.js"
|
|
|
2
2
|
import type { ToolSelector, ToolSelectorLayer } from "../core/tool-face.js";
|
|
3
3
|
import { type MountedMcp } from "../core/mounted-mcp.js";
|
|
4
4
|
import type { McpHostSeat } from "../core/mcp-host-seat.js";
|
|
5
|
-
import type { InheritedGate, RunInternals } from "../core/runner/contracts.js";
|
|
5
|
+
import type { InheritedGate, RunInternals, RunnerSelfSeat } from "../core/runner/contracts.js";
|
|
6
6
|
/**
|
|
7
7
|
* What a delegated child inherits when its delegation tool has no explicit pool (`SubagentToolOptions.inheritedTools`):
|
|
8
8
|
* the parent surface, narrowed at spawn by two laws, and the parent's MCP declarations. The mint of the parent bound
|
|
@@ -51,6 +51,13 @@ export declare function withoutWakerSeats(internals: RunInternals): RunInternals
|
|
|
51
51
|
* chain): without any reading of the `sharedArtifactReads` setting. One rule: every wake is a run of its own and reads the seat
|
|
52
52
|
* again — neither the spawner's old `allow` nor the waker's outlives a setting changed since. Every other member stays as it is. */
|
|
53
53
|
export declare function wakeGate(gate: InheritedGate): InheritedGate;
|
|
54
|
+
/** Merge an agent definition's MCP servers with the lane's servers, returning both the mounted list and any shadowed entries. */
|
|
55
|
+
export declare function mergeDefinitionServers<S extends {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
}>(handed: readonly S[] | undefined, own: readonly S[] | undefined): {
|
|
58
|
+
servers: S[];
|
|
59
|
+
dropped: S[];
|
|
60
|
+
};
|
|
54
61
|
/**
|
|
55
62
|
* The MCP servers a leg spawned as an agent definition is declared ({@link AgentDefinition.mcp}): the servers its lane hands it (the
|
|
56
63
|
* spawning run's it inherits, a workflow child's governed spec's) first, then each of the definition's own whose tool namespace none of
|
|
@@ -61,6 +68,24 @@ export declare function wakeGate(gate: InheritedGate): InheritedGate;
|
|
|
61
68
|
export declare function withDefinitionServers<S extends {
|
|
62
69
|
readonly name: string;
|
|
63
70
|
}>(handed: readonly S[] | undefined, own: readonly S[] | undefined): S[];
|
|
71
|
+
/**
|
|
72
|
+
* Announce shadowed agent-definition MCP entries through `mcpInjectionDroppedNotice`, once per (runner, root session address, agent,
|
|
73
|
+
* server) while that tuple is among the last `MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER` announced (one pushed out is said again). The announcement is said on behalf of the spawning tree's leg `leg` and goes where that leg's children's notices go
|
|
74
|
+
* (`noticeAddressOf` over the root anchor `root` the children are handed): to the tree's root, under the runner's admission for that
|
|
75
|
+
* route — an announcement for a root occupant the root no longer holds is discarded and said, never delivered to its later occupant.
|
|
76
|
+
*/
|
|
77
|
+
export declare function announceShadowedDefinitionServers(args: {
|
|
78
|
+
readonly runner: Pick<RunnerSelfSeat, "emitNotice">;
|
|
79
|
+
readonly leg: string | undefined;
|
|
80
|
+
readonly root: {
|
|
81
|
+
readonly rootSessionId?: string;
|
|
82
|
+
readonly rootSessionIncarnation?: string;
|
|
83
|
+
};
|
|
84
|
+
readonly agent: string | undefined;
|
|
85
|
+
readonly dropped: ReadonlyArray<{
|
|
86
|
+
readonly name: string;
|
|
87
|
+
}>;
|
|
88
|
+
}): void;
|
|
64
89
|
/**
|
|
65
90
|
* A definition's own allowed-tools list as its leg's selector reads it: the list it wrote, extended by every tool of each MCP server it
|
|
66
91
|
* declares (`mcp__<server>__*`) — the servers an agent brings are its own whatever its list names, and its denied list still wins over them.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { hostSeatsAlong } from "../core/mounted-mcp.js";
|
|
2
2
|
import { transportKindOf } from "../core/mcp-server-spec.js";
|
|
3
|
+
import { deliverEngineNotice } from "../core/engine-notice.js";
|
|
4
|
+
import { mcpInjectionDroppedNotice } from "../core/mcp-injection-drop.js";
|
|
5
|
+
import { noticeAddressOf } from "../core/leg-identity.js";
|
|
3
6
|
import { MCP_NAMESPACE, mintNamespacePrefix } from "@sema-agent/primitives";
|
|
4
7
|
import { TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME } from "../core/tool-catalog-entries.js";
|
|
5
8
|
export const TEAM_TASK_LIST_TOOL_NAMES = Object.freeze([TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME]);
|
|
@@ -33,9 +36,50 @@ export function wakeGate(gate) {
|
|
|
33
36
|
const { sharedArtifactReads: _reading, ...kept } = gate;
|
|
34
37
|
return kept;
|
|
35
38
|
}
|
|
36
|
-
export function
|
|
39
|
+
export function mergeDefinitionServers(handed, own) {
|
|
37
40
|
const held = new Set((handed ?? []).map((s) => mintNamespacePrefix(MCP_NAMESPACE, s.name)));
|
|
38
|
-
|
|
41
|
+
const kept = [];
|
|
42
|
+
const dropped = [];
|
|
43
|
+
for (const s of own ?? []) {
|
|
44
|
+
if (held.has(mintNamespacePrefix(MCP_NAMESPACE, s.name)))
|
|
45
|
+
dropped.push(s);
|
|
46
|
+
else
|
|
47
|
+
kept.push(s);
|
|
48
|
+
}
|
|
49
|
+
return { servers: [...(handed ?? []), ...kept], dropped };
|
|
50
|
+
}
|
|
51
|
+
export function withDefinitionServers(handed, own) {
|
|
52
|
+
return mergeDefinitionServers(handed, own).servers;
|
|
53
|
+
}
|
|
54
|
+
const announcedShadowedServers = new WeakMap();
|
|
55
|
+
const MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER = 4_096;
|
|
56
|
+
export function announceShadowedDefinitionServers(args) {
|
|
57
|
+
const { runner, leg, root, agent, dropped } = args;
|
|
58
|
+
if (dropped.length === 0 || typeof leg !== "string" || leg.length === 0 || typeof agent !== "string" || agent.length === 0)
|
|
59
|
+
return;
|
|
60
|
+
const route = noticeAddressOf({ sourceSessionId: leg, isDelegatedChild: true }, root);
|
|
61
|
+
const sessionId = route.address.sessionId;
|
|
62
|
+
let seen = announcedShadowedServers.get(runner);
|
|
63
|
+
if (seen === undefined) {
|
|
64
|
+
seen = new Set();
|
|
65
|
+
announcedShadowedServers.set(runner, seen);
|
|
66
|
+
}
|
|
67
|
+
for (const s of dropped) {
|
|
68
|
+
const key = JSON.stringify([sessionId, root.rootSessionIncarnation ?? null, agent, s.name]);
|
|
69
|
+
if (seen.has(key))
|
|
70
|
+
continue;
|
|
71
|
+
if (seen.size >= MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER) {
|
|
72
|
+
const oldest = seen.values().next().value;
|
|
73
|
+
if (oldest !== undefined)
|
|
74
|
+
seen.delete(oldest);
|
|
75
|
+
}
|
|
76
|
+
seen.add(key);
|
|
77
|
+
const notice = mcpInjectionDroppedNotice({ sessionId, server: s.name, reason: "name_already_mounted", agent });
|
|
78
|
+
if (runner.emitNotice !== undefined)
|
|
79
|
+
runner.emitNotice(notice, route);
|
|
80
|
+
else
|
|
81
|
+
deliverEngineNotice(undefined, notice);
|
|
82
|
+
}
|
|
39
83
|
}
|
|
40
84
|
export function definitionAllowTools(def) {
|
|
41
85
|
const written = def.allowTools ?? undefined;
|
|
@@ -76,7 +76,7 @@ export function createListAgentsTool(opts) {
|
|
|
76
76
|
? `Peer sessions are other sessions of this engine running for the same user, shown as \`name [ref] · state · active <N> ago · <directory> · self: agent=…, intent=… · peer session <where>\` (where it runs: ${Object.values(PEER_SESSION_WHERE_LABELS).join(", or ")}); send to one with its name (or \`name [ref]\` ` +
|
|
77
77
|
`when a name is ambiguous, or its \`session.<id>\` address). By default only FRESH peers are listed (working now, or active within the last ${formatAgo(windowMs)}); ` +
|
|
78
78
|
`pass includeAll: true to also list stale and offline ones. A peer that is offline or unlisted still accepts messages — they are parked ` +
|
|
79
|
-
`durably in its session box
|
|
79
|
+
`durably in its session box. `
|
|
80
80
|
: `Peer sessions of this engine are not addressable on this mount (no session directory). `) +
|
|
81
81
|
`Background agents you spawned are listed with their task_id, their status, when they last did anything, and — for one that is parked — what its park waits on (a person's approval, or a yield that continues when its owner runs again), the card id, state and deadline; for one that stopped, whether SendMessage can still continue it and for how long. ` +
|
|
82
82
|
`A ref is only valid against the listing (or disambiguation error) you read it from — do not invent one.`,
|
|
@@ -24,6 +24,16 @@ export declare function parkedResumeDoor(pr: {
|
|
|
24
24
|
}): ParkedResumeGateReading | {
|
|
25
25
|
readonly refusal: unknown;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* The root task's facts a drive must hand, or the refusal naming the first it lacks: the root's seat (`parentSpecSeat`, minted with
|
|
29
|
+
* `parentSpecSeatOf` from the root's stored spec — the revived leg's instruction family, language, directories and mods are read from
|
|
30
|
+
* it; the row records only the principal and the sandbox), then the root's current mode (`parkedResume.inheritedGate.permissionMode`
|
|
31
|
+
* — the row froze the mode at the park, and the root may have tightened it since). Asked of every drive, an allow and a deny alike;
|
|
32
|
+
* the drive refuses before the consume and rolls the claim back, as for any other fact it lacks.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parkedResumeUnhanded(seat: unknown, gate: {
|
|
35
|
+
readonly permissionMode?: PermissionMode;
|
|
36
|
+
} | undefined): Error | undefined;
|
|
27
37
|
/** The account of the resume's own rejection `e` when the chain raised it for a deny the resume validated on THIS card
|
|
28
38
|
* (`takeDeniedChainRefusalToken`, the ladder's mark on that one throw, naming the card's token — every code and reason the chain's
|
|
29
39
|
* rungs refuse with), else `undefined`: its code and reason, as the stopped agent's receipt names them (the refusal's own sentence
|
|
@@ -40,6 +40,15 @@ export function parkedResumeDoor(pr) {
|
|
|
40
40
|
return { refusal: e };
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
export function parkedResumeUnhanded(seat, gate) {
|
|
44
|
+
if (seat === undefined) {
|
|
45
|
+
return Object.assign(new Error("the parked agent was not resumed: the drive hands no `parentSpecSeat` — mint it with `parentSpecSeatOf` from the root task's stored spec, so the agent reads its instruction files, language and directories; the approval stays pending"), { code: "config.parent_spec_seat_missing" });
|
|
46
|
+
}
|
|
47
|
+
if (gate?.permissionMode === undefined) {
|
|
48
|
+
return Object.assign(new Error("the parked agent was not resumed: the drive hands no `parkedResume.inheritedGate.permissionMode` — hand the root task's current mode (the row's is the mode at the park); the approval stays pending"), { code: "config.invalid_argument", detail: { field: "inheritedGate" } });
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
43
52
|
export function unresumableChainRefusal(e, token) {
|
|
44
53
|
if (takeDeniedChainRefusalToken(e) !== token)
|
|
45
54
|
return undefined;
|
|
@@ -146,6 +146,9 @@ export interface SubagentRetainEntry {
|
|
|
146
146
|
* runner, so this adds no new retention class.
|
|
147
147
|
*/
|
|
148
148
|
runner?: RunnerSelfSeat;
|
|
149
|
+
/** The run that dispatched the child keeps a member ledger (`ToolExecuteContext.runLedgerBook` at the spawn): every cycle's
|
|
150
|
+
* terminal frame carries the child's actions digest, a woken cycle's as the spawn cycle's. */
|
|
151
|
+
actionsDigest?: true;
|
|
149
152
|
agentName?: string;
|
|
150
153
|
/** fix-C5: PER-ENTRY retain TTL override (ms). A SESSION-scoped ledger is shared by two purposes with
|
|
151
154
|
* different windows (failure-evidence retain = FAILED_SESSION_RETAIN_TTL_MS vs a session-scoped bg
|
|
@@ -4,10 +4,9 @@ import { PEER_MESSAGE_NOTICE } from "./peer-admission.js";
|
|
|
4
4
|
import { createSafeNotifier } from "../core/safe-notify.js";
|
|
5
5
|
import { RETAIN_DEFAULT_TTL_MS, RETAIN_DEFAULT_MAX } from "../config/defaults.js";
|
|
6
6
|
import { asThrownError, codedRefusal } from "../core/thrown-value.js";
|
|
7
|
-
import {
|
|
7
|
+
import { retainSeatToBuild } from "../core/retain-seat.js";
|
|
8
8
|
import { readClampFloor } from "../core/child-clamp-seats.js";
|
|
9
9
|
import { CONTINUATION_ENDED_BY } from "../core/delegation-frames.js";
|
|
10
|
-
const RETAIN_CONFIG_KEYS = optionKeys()({ ttlMs: 0, max: 0 });
|
|
11
10
|
const FORK_AGENT_TYPE = "fork";
|
|
12
11
|
export function durableRungAdmitsRow(row) {
|
|
13
12
|
if (row.agentType === FORK_AGENT_TYPE)
|
|
@@ -81,7 +80,8 @@ export class SubagentRetainLedger {
|
|
|
81
80
|
lastFailure;
|
|
82
81
|
notifier = createSafeNotifier();
|
|
83
82
|
constructor(config, hooks) {
|
|
84
|
-
const
|
|
83
|
+
const seat = retainSeatToBuild(config);
|
|
84
|
+
const cfg = seat === true ? {} : seat;
|
|
85
85
|
this.ttlMs = cfg.ttlMs ?? RETAIN_DEFAULT_TTL_MS;
|
|
86
86
|
this.max = cfg.max ?? RETAIN_DEFAULT_MAX;
|
|
87
87
|
this.hooks = hooks;
|
|
@@ -175,7 +175,7 @@ export function createSendMessageTool(opts) {
|
|
|
175
175
|
: `Continuing a finished agent requires the run to retain sub-agent sessions; when the session was not ` +
|
|
176
176
|
`retained (or is no longer held) you get an honest error and should launch a new agent with the needed context instead.`) +
|
|
177
177
|
(peerLane.active
|
|
178
|
-
? ` Peer SESSIONS — other sessions of this engine for the same user${opts.peerListingMounted === false ? "" : opts.peerListingMounted === true ? " (list them with ListAgents)" : " (list them with ListAgents where that tool is mounted)"} — are addressed by name, by \`name [ref]\` when a name is ambiguous, or by their \`session.<id>\` address. A message to a peer is parked durably in its session box
|
|
178
|
+
? ` Peer SESSIONS — other sessions of this engine for the same user${opts.peerListingMounted === false ? "" : opts.peerListingMounted === true ? " (list them with ListAgents)" : " (list them with ListAgents where that tool is mounted)"} — are addressed by name, by \`name [ref]\` when a name is ambiguous, or by their \`session.<id>\` address. A message to a peer is parked durably in its session box; the receipt confirms the box accepted it, not that the peer read or acted on it.${opts.peerChannel !== undefined ? " A peer whose box is not in this host's mailbox store — a Claude Code session, or a session of this engine on another store — is reached over its socket instead: nothing is parked for it, the message is sent once and only while it runs, and its receipt says so." : ""}`
|
|
179
179
|
: ""),
|
|
180
180
|
parameters: sendMessageParameters,
|
|
181
181
|
execute: async (args, ctx) => {
|
|
@@ -297,7 +297,7 @@ export function createSendMessageTool(opts) {
|
|
|
297
297
|
catch {
|
|
298
298
|
}
|
|
299
299
|
if (boxFull) {
|
|
300
|
-
return { content: `Message not sent: ${inlineUntrusted(peerLabel, 200)}'s session box is at its queued-message limit (${admissionConfig.maxQueuedPeerMessages.toFixed(0)}) — the message was NOT queued
|
|
300
|
+
return { content: `Message not sent: ${inlineUntrusted(peerLabel, 200)}'s session box is at its queued-message limit (${admissionConfig.maxQueuedPeerMessages.toFixed(0)}) — the message was NOT queued. Resend later. ${DEDUP_RETRY_NOTE.slice(0, 200)}`, details: { error: "queue_full", code: "queue_full", to }, isError: true };
|
|
301
301
|
}
|
|
302
302
|
let seq;
|
|
303
303
|
if (message !== "") {
|
|
@@ -398,8 +398,8 @@ export function createSendMessageTool(opts) {
|
|
|
398
398
|
const verdict = { ok: true, disposition: offline ? "parked_offline" : "queued", via: "store" };
|
|
399
399
|
return {
|
|
400
400
|
content: offline
|
|
401
|
-
? `Message parked for ${peerLabel}: that session is offline, so the message was parked durably in its session box (seq ${seq})
|
|
402
|
-
: `Message queued for ${peerLabel} (seq ${seq}): it is parked durably in that session's box
|
|
401
|
+
? `Message parked for ${peerLabel}: that session is offline, so the message was parked durably in its session box (seq ${seq}) — subject to the deployment's mailbox retirement policy, which does not notify you. Continue with your task; do not resend the same content.${subscriptionNote}${rowNote}`
|
|
402
|
+
: `Message queued for ${peerLabel} (seq ${seq}): it is parked durably in that session's box. This receipt confirms acceptance into the box, not the peer's judgment of the message. Continue with your task; do not resend the same content.${subscriptionNote}${rowNote}`,
|
|
403
403
|
details: { type: "send-message", status: offline ? "peer_parked_offline" : "peer_queued", to, address: handle, seq, verdict, ...(subscription !== undefined ? { subscription } : {}), ...(subscriptionSeq !== undefined ? { subscriptionSeq } : {}), ...(rowRestored !== "present" ? { directoryRow: rowRestored } : {}), ...(doorbell !== undefined ? { doorbell } : {}) },
|
|
404
404
|
};
|
|
405
405
|
};
|
|
@@ -1135,6 +1135,7 @@ export function createSendMessageTool(opts) {
|
|
|
1135
1135
|
...(opts.taskArtifacts !== undefined ? { currentTaskArtifacts: opts.taskArtifacts } : {}),
|
|
1136
1136
|
...(ctx.onQuestion !== undefined && row.sessionScoped !== true ? { currentOnQuestion: ctx.onQuestion } : {}),
|
|
1137
1137
|
currentClamps: clampValuesOf(ctx, ctx.parentSpecSeat),
|
|
1138
|
+
...(ctx.parentSpecSeat?.project !== undefined ? { currentProject: ctx.parentSpecSeat.project } : {}),
|
|
1138
1139
|
...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
|
|
1139
1140
|
...(ctx.spendSeat !== undefined ? { currentSpendSeat: ctx.spendSeat } : {}),
|
|
1140
1141
|
continuationTier,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentTool } from "../internal/harness-types.js";
|
|
2
|
+
import type { RunLedger, RunLedgerBook } from "../core/run-ledger.js";
|
|
3
|
+
export declare const SEND_USER_MESSAGE_TOOL_NAME = "SendUserMessage";
|
|
4
|
+
export interface SendUserMessageSeats {
|
|
5
|
+
/** The run's ledger book. */
|
|
6
|
+
readonly book: RunLedgerBook;
|
|
7
|
+
/** Record the ledger snapshot a delivery carries in the run's session log (best effort: a failed write does not refuse the
|
|
8
|
+
* delivery — the snapshot still rides the call's result). */
|
|
9
|
+
readonly record: (ledger: RunLedger) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/** Build the report tool over the run's book. */
|
|
12
|
+
export declare function createSendUserMessageTool(seats: SendUserMessageSeats): AgentTool;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { defineTool } from "../core/tools.js";
|
|
3
|
+
import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
4
|
+
import { egressValue } from "../core/untrusted-egress.js";
|
|
5
|
+
export const SEND_USER_MESSAGE_TOOL_NAME = "SendUserMessage";
|
|
6
|
+
const DELIVERED = "Message delivered to user.";
|
|
7
|
+
const CLAIM = Type.Object({
|
|
8
|
+
about: Type.String({ description: "The task id of the member this conclusion is about, as the ledger lists it." }),
|
|
9
|
+
text: Type.String({ description: "The conclusion, in one or two sentences." }),
|
|
10
|
+
basis: Type.Union([Type.Literal("verified"), Type.Literal("relayed"), Type.Literal("inferred")], {
|
|
11
|
+
description: '"verified": you checked it yourself after that member reported (cite the check) — "relayed": it is what the member said, unchecked — "inferred": your own judgment.',
|
|
12
|
+
}),
|
|
13
|
+
verdict: Type.Optional(Type.Union([Type.Literal("confirms"), Type.Literal("refutes"), Type.Literal("partial")], { description: 'For "verified": whether your check confirms, refutes or partly confirms what the member reported.' })),
|
|
14
|
+
evidence: Type.Optional(Type.Array(Type.String(), { maxItems: 8, description: 'For "verified": the id of each check — a tool call you made after the member reported, or another member\'s task id (a verification worker).' })),
|
|
15
|
+
}, { additionalProperties: false });
|
|
16
|
+
const PARAMETERS = Type.Object({
|
|
17
|
+
message: Type.String({ description: "What the person reads. Markdown is fine." }),
|
|
18
|
+
status: Type.Union([Type.Literal("normal"), Type.Literal("proactive")], {
|
|
19
|
+
description: "'normal' when replying to what they just asked; 'proactive' when you are initiating — a phase finished, a blocker surfaced, a result was overturned, you need a decision. Set it honestly; downstream routing uses it.",
|
|
20
|
+
}),
|
|
21
|
+
report: Type.Optional(Type.Object({
|
|
22
|
+
kind: Type.Optional(Type.Union([Type.Literal("start"), Type.Literal("interim"), Type.Literal("final")])),
|
|
23
|
+
claims: Type.Optional(Type.Array(CLAIM, { maxItems: 32 })),
|
|
24
|
+
decisions: Type.Optional(Type.Array(Type.Object({ question: Type.String(), options: Type.Array(Type.String(), { maxItems: 8 }), recommend: Type.Optional(Type.String()) }, { additionalProperties: false }), { maxItems: 8 })),
|
|
25
|
+
next: Type.Optional(Type.String()),
|
|
26
|
+
}, { additionalProperties: false })),
|
|
27
|
+
}, { additionalProperties: false });
|
|
28
|
+
export function createSendUserMessageTool(seats) {
|
|
29
|
+
return defineTool({
|
|
30
|
+
name: SEND_USER_MESSAGE_TOOL_NAME,
|
|
31
|
+
...toolFace("send-user-message"),
|
|
32
|
+
ruleFace: mountRuleFace("send-user-message"),
|
|
33
|
+
description: "Send a message the person you work for will read. Use it to report — when you start, when a result is overturned, when you are blocked or need a decision, and at the end.\n\n" +
|
|
34
|
+
"`status` labels intent: 'normal' when replying to what they just asked; 'proactive' when you are initiating. Set it honestly; downstream routing uses it.\n\n" +
|
|
35
|
+
"`report.claims` is optional: one entry per conclusion about a member you dispatched (`about` = its task id), each saying what it rests on. " +
|
|
36
|
+
'A "verified" claim must cite evidence made AFTER that member reported — a tool call of your own, or another member that checked it — and state a verdict; ' +
|
|
37
|
+
"a report whose checks do not hold is not delivered and the reason comes back, so check again or mark the claim \"relayed\". " +
|
|
38
|
+
"Beside every message the engine delivers its own ledger of the members — how each ended, what each did, which ones nobody checked — whatever the message says.",
|
|
39
|
+
parameters: PARAMETERS,
|
|
40
|
+
execute: async (args, ctx) => {
|
|
41
|
+
const a = egressValue("same-principal", args);
|
|
42
|
+
const verdict = seats.book.acceptReport({
|
|
43
|
+
status: a.status,
|
|
44
|
+
message: a.message,
|
|
45
|
+
...(a.report !== undefined ? { report: { ...(a.report.kind !== undefined ? { kind: a.report.kind } : {}), ...(a.report.claims !== undefined ? { claims: a.report.claims } : {}) } } : {}),
|
|
46
|
+
...(ctx?.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}),
|
|
47
|
+
});
|
|
48
|
+
if (!verdict.ok) {
|
|
49
|
+
return { content: `Report not sent: ${verdict.why.slice(0, 1200)}`, details: { type: "send-user-message", status: a.status, delivered: false }, isError: true };
|
|
50
|
+
}
|
|
51
|
+
const ledger = seats.book.snapshot({ kind: "report", ...(ctx?.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}) });
|
|
52
|
+
await seats.record(ledger).catch(() => undefined);
|
|
53
|
+
return {
|
|
54
|
+
content: `${DELIVERED}\nLedger: ${ledger.headline}`,
|
|
55
|
+
details: {
|
|
56
|
+
type: "send-user-message",
|
|
57
|
+
status: a.status,
|
|
58
|
+
delivered: true,
|
|
59
|
+
message: a.message,
|
|
60
|
+
...(a.report?.kind !== undefined ? { kind: a.report.kind } : {}),
|
|
61
|
+
...(a.report !== undefined ? { report: a.report } : {}),
|
|
62
|
+
ledger,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Everything is BOUNDED (step ring ≤ {@link STEP_CAP}, fields truncated): a pathological child cannot balloon the parent's view.
|
|
19
19
|
*/
|
|
20
20
|
import type { TaskEvent } from "../core/types.js";
|
|
21
|
+
import { type SubagentActions } from "../core/actions-digest.js";
|
|
21
22
|
/** One completed tool step in the child's tail — enough for the parent to say "you stopped at X". */
|
|
22
23
|
export interface SubagentStep {
|
|
23
24
|
/** Tool name (or its distinct {@link ToolSpec.label} when set). */
|
|
@@ -49,6 +50,11 @@ export declare class SubagentStepRecorder {
|
|
|
49
50
|
private readonly steps;
|
|
50
51
|
private readonly pending;
|
|
51
52
|
private readonly edits;
|
|
53
|
+
/** The whole-stream counters the actions digest reads (never the ring): calls by tool, and the shell commands. */
|
|
54
|
+
private readonly toolCounts;
|
|
55
|
+
private toolCallTotal;
|
|
56
|
+
private readonly commands;
|
|
57
|
+
private commandsPast;
|
|
52
58
|
private action;
|
|
53
59
|
private actionTool;
|
|
54
60
|
private actionTarget;
|
|
@@ -76,6 +82,9 @@ export declare class SubagentStepRecorder {
|
|
|
76
82
|
recentSteps(): SubagentStep[] | undefined;
|
|
77
83
|
/** Files the child mutated with edit counts; undefined if none. */
|
|
78
84
|
editedFiles(): SubagentEditedFile[] | undefined;
|
|
85
|
+
/** The child's whole-stream actions digest ({@link SubagentActions}) — present even when the child called no tool (a
|
|
86
|
+
* zero digest is the fact a self-report of work is read against). */
|
|
87
|
+
actions(): SubagentActions;
|
|
79
88
|
/** The child's most recent tool intent as one human line ("Bash npm test", "Edit src/x.ts"); undefined if none. */
|
|
80
89
|
currentAction(): string | undefined;
|
|
81
90
|
/** {@link currentAction} pre-formatted into a fleet-view Progress-section
|
|
@@ -3,6 +3,16 @@ import { renderContentBlock } from "../internal/llm.js";
|
|
|
3
3
|
import { cutAt, redactThenCut } from "../core/untrusted-egress.js";
|
|
4
4
|
import { isProtectedWrite } from "../core/tool-registry.js";
|
|
5
5
|
import { writeTargetPath } from "../tools/fs/safety.js";
|
|
6
|
+
import { ACTIONS_COMMANDS_CAP, ACTIONS_TOOLS_CAP } from "../core/actions-digest.js";
|
|
7
|
+
const SHELL_TOOL_NAME = "Bash";
|
|
8
|
+
function shellExitCode(structured, output) {
|
|
9
|
+
const s = structured;
|
|
10
|
+
if (s !== null && typeof s === "object" && typeof s.exitCode === "number" && Number.isInteger(s.exitCode))
|
|
11
|
+
return s.exitCode;
|
|
12
|
+
const text = typeof output === "string" ? output : Array.isArray(output) ? output.map(renderContentBlock).join("\n") : "";
|
|
13
|
+
const m = /^exit code: (-?\d+)/.exec(text);
|
|
14
|
+
return m !== null ? Number(m[1]) : undefined;
|
|
15
|
+
}
|
|
6
16
|
export const STEP_CAP = 10;
|
|
7
17
|
const FIELD_MAX = 80;
|
|
8
18
|
const EDITED_FILES_CAP = 32;
|
|
@@ -55,6 +65,10 @@ export class SubagentStepRecorder {
|
|
|
55
65
|
steps = [];
|
|
56
66
|
pending = new Map();
|
|
57
67
|
edits = new Map();
|
|
68
|
+
toolCounts = new Map();
|
|
69
|
+
toolCallTotal = 0;
|
|
70
|
+
commands = [];
|
|
71
|
+
commandsPast = 0;
|
|
58
72
|
action;
|
|
59
73
|
actionTool;
|
|
60
74
|
actionTarget;
|
|
@@ -71,6 +85,10 @@ export class SubagentStepRecorder {
|
|
|
71
85
|
this.steps.length = 0;
|
|
72
86
|
this.pending.clear();
|
|
73
87
|
this.edits.clear();
|
|
88
|
+
this.toolCounts.clear();
|
|
89
|
+
this.toolCallTotal = 0;
|
|
90
|
+
this.commands.length = 0;
|
|
91
|
+
this.commandsPast = 0;
|
|
74
92
|
this.action = undefined;
|
|
75
93
|
this.actionTool = undefined;
|
|
76
94
|
this.actionTarget = undefined;
|
|
@@ -111,6 +129,16 @@ export class SubagentStepRecorder {
|
|
|
111
129
|
this.steps.push({ tool, target, outcome });
|
|
112
130
|
if (this.steps.length > STEP_CAP)
|
|
113
131
|
this.steps.shift();
|
|
132
|
+
this.toolCallTotal += 1;
|
|
133
|
+
this.toolCounts.set(e.toolName, (this.toolCounts.get(e.toolName) ?? 0) + 1);
|
|
134
|
+
if (e.toolName === SHELL_TOOL_NAME) {
|
|
135
|
+
if (this.commands.length < ACTIONS_COMMANDS_CAP) {
|
|
136
|
+
const exitCode = shellExitCode(e.structured, e.output);
|
|
137
|
+
this.commands.push({ command: target, ...(exitCode !== undefined ? { exitCode } : {}) });
|
|
138
|
+
}
|
|
139
|
+
else
|
|
140
|
+
this.commandsPast += 1;
|
|
141
|
+
}
|
|
114
142
|
const editPath = start?.edit;
|
|
115
143
|
if (editPath !== undefined && !e.isError) {
|
|
116
144
|
if (this.edits.has(editPath))
|
|
@@ -129,6 +157,16 @@ export class SubagentStepRecorder {
|
|
|
129
157
|
editedFiles() {
|
|
130
158
|
return this.edits.size > 0 ? [...this.edits].map(([path, edits]) => ({ path, edits })) : undefined;
|
|
131
159
|
}
|
|
160
|
+
actions() {
|
|
161
|
+
const byTool = [...this.toolCounts].map(([tool, calls]) => ({ tool, calls })).sort((a, b) => b.calls - a.calls).slice(0, ACTIONS_TOOLS_CAP);
|
|
162
|
+
return {
|
|
163
|
+
toolCalls: this.toolCallTotal,
|
|
164
|
+
byTool,
|
|
165
|
+
commands: this.commands.map((c) => ({ ...c })),
|
|
166
|
+
...(this.commandsPast > 0 ? { commandsUnlisted: this.commandsPast } : {}),
|
|
167
|
+
filesEdited: this.editedFiles() ?? [],
|
|
168
|
+
};
|
|
169
|
+
}
|
|
132
170
|
currentAction() {
|
|
133
171
|
return this.action;
|
|
134
172
|
}
|
|
@@ -433,6 +433,8 @@ export declare function createSubagentResume(deps: {
|
|
|
433
433
|
* has no live face and its `AskUserQuestion` mount falls back to the automatic criterion's other legs
|
|
434
434
|
* — never a call into a closed surface. */
|
|
435
435
|
currentOnQuestion?: import("../core/ask-question.js").OnQuestion;
|
|
436
|
+
/** The RESUMING caller's own project seat (`ParentSpecSeat.project`): a woken cycle runs under its WAKER's, as a tier-3 revival does; the spawn snapshot's is not kept (absent ⇒ none). */
|
|
437
|
+
currentProject?: import("../core/project-seat.js").ProjectSeat;
|
|
436
438
|
/** The RESUMING caller's own tighten-only CLAMPS (its trusted `ToolExecuteContext` seats), folded ON TOP
|
|
437
439
|
* of the frozen snapshot so a wake can only ever narrow the child. Without this the snapshot alone
|
|
438
440
|
* decides: a child spawned by a write-capable, interactive, long-lived run could be woken BY a
|
package/dist/agents/subagent.js
CHANGED
|
@@ -16,7 +16,7 @@ import { sanitizedTtlMs } from "../core/runner/park-commit.js";
|
|
|
16
16
|
import { ADVISOR_FORK_SENTENCE, ADVISOR_TOOL_NAME } from "../core/advisor-verdict.js";
|
|
17
17
|
import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf, clampValuesOf, engineHeadlessLegSeats, foldClampSources, postureUnderClamps, readClampFloor } from "../core/child-clamp-seats.js";
|
|
18
18
|
import { assertNoRetiredKeys } from "../core/retired-keys.js";
|
|
19
|
-
import { parkedResumeDoor, spawnDepthUnknownNotice, unresumableChainRefusal } from "./parked-resume-drive.js";
|
|
19
|
+
import { parkedResumeDoor, parkedResumeUnhanded, spawnDepthUnknownNotice, unresumableChainRefusal } from "./parked-resume-drive.js";
|
|
20
20
|
import { stripSpawnTurnQuestionFace } from "../core/ask-question.js";
|
|
21
21
|
import { withDelegationProvenance } from "../core/tool-policy.js";
|
|
22
22
|
import { errorResult } from "../core/tools.js";
|
|
@@ -104,7 +104,7 @@ import { childOwnerKeys, parkCompletionNotify, runningBackgroundUnder } from "./
|
|
|
104
104
|
import { placesSubagentTranscripts, subagentTranscriptPlacement } from "./subagent-transcript-placement.js";
|
|
105
105
|
import { OUTPUT_TOOL_NAME, mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
106
106
|
import { canonicalNameValue } from "../core/permission-rule-model.js";
|
|
107
|
-
import { definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, selectorLayerOf, wakeGate,
|
|
107
|
+
import { announceShadowedDefinitionServers, definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, mergeDefinitionServers, selectorLayerOf, wakeGate, withoutWakerSeats } from "./inherited-tool-pool.js";
|
|
108
108
|
import { codedRefusal, readMember, thrownMarksOf, thrownText } from "../core/thrown-value.js";
|
|
109
109
|
import { GIT_READ_ONLY } from "../core/git-read-only.js";
|
|
110
110
|
const BG_AGENT_RESULT_MAX = 4_000;
|
|
@@ -384,6 +384,22 @@ const ccElapsedTag = (ms) => {
|
|
|
384
384
|
};
|
|
385
385
|
const ccCompletionText = (desc, settled, rawStatus, elapsedMs) => `Agent "${desc}" ${settled === "killed" ? "stopped" : settled === "completed" ? "finished" : rawStatus}${ccElapsedTag(elapsedMs)}`;
|
|
386
386
|
const SYNC_ESCAPE_SENTENCE = "Pass `run_in_background: false` for a synchronous run when you need the result before continuing (a named agent always runs in the background).";
|
|
387
|
+
function reportInCallMember(ctx, member) {
|
|
388
|
+
const taskId = member.taskId ?? ctx.toolCallId;
|
|
389
|
+
if (taskId !== undefined) {
|
|
390
|
+
ctx.runLedgerBook?.memberSettled({
|
|
391
|
+
taskId,
|
|
392
|
+
kind: "subagent",
|
|
393
|
+
label: typeof member.description === "string" ? member.description : "",
|
|
394
|
+
...(member.name !== undefined ? { name: member.name } : {}),
|
|
395
|
+
outcome: member.outcome,
|
|
396
|
+
...(member.selfReport !== undefined ? { selfReport: member.selfReport } : {}),
|
|
397
|
+
actions: member.actions,
|
|
398
|
+
...(ctx.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}),
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
return member.outcome;
|
|
402
|
+
}
|
|
387
403
|
export const AGENT_RAN_SYNC_NO_CHANNEL_NOTE = "note: this agent ran synchronously — no completion would come back from a background agent on this mount, so the background lane is not used here.";
|
|
388
404
|
function continuationSentence(toolName, durableRevival, forkOffered) {
|
|
389
405
|
return (`Where the SendMessage tool is mounted, use it with the agent's ID or name to message a RUNNING agent, or — when session retention${durableRevival ? " or durable named-agent revival" : ""} is enabled — ` +
|
|
@@ -630,7 +646,7 @@ export function createSubagentResume(deps) {
|
|
|
630
646
|
const resumeResidual = () => {
|
|
631
647
|
const recentSteps = resumeStepRecorder.recentSteps();
|
|
632
648
|
const editedFiles = resumeStepRecorder.editedFiles();
|
|
633
|
-
return { ...(recentSteps !== undefined && recentSteps.length > 0 ? { recentSteps } : {}), ...(editedFiles !== undefined && editedFiles.length > 0 ? { editedFiles } : {}) };
|
|
649
|
+
return { ...(recentSteps !== undefined && recentSteps.length > 0 ? { recentSteps } : {}), ...(editedFiles !== undefined && editedFiles.length > 0 ? { editedFiles } : {}), ...(entry.actionsDigest === true ? { actions: resumeStepRecorder.actions() } : {}) };
|
|
634
650
|
};
|
|
635
651
|
const childRunner = entry.runner ?? deps.runner;
|
|
636
652
|
let stream;
|
|
@@ -733,10 +749,11 @@ export function createSubagentResume(deps) {
|
|
|
733
749
|
});
|
|
734
750
|
});
|
|
735
751
|
releaseCycleSlot = deps.entryGate?.occupy(reviveCycle !== undefined ? "registered" : "local") ?? noopRelease;
|
|
736
|
-
const { spendParent: _spawnerAccount, ...snapshotSeats } = entry.internalsSnapshot;
|
|
737
|
-
void _spawnerAccount;
|
|
752
|
+
const { spendParent: _spawnerAccount, parentProject: _spawnersProject, ...snapshotSeats } = entry.internalsSnapshot;
|
|
753
|
+
void _spawnerAccount, void _spawnersProject;
|
|
738
754
|
stream = childRunner.runTaskStream(resumeSpec, undefined, {
|
|
739
755
|
...snapshotSeats,
|
|
756
|
+
...(deps.currentProject !== undefined ? { parentProject: deps.currentProject } : {}),
|
|
740
757
|
...(deps.currentSpendSeat !== undefined ? { spendParent: { seat: deps.currentSpendSeat, link: "session" } } : {}),
|
|
741
758
|
...(deps.registry !== undefined && deps.taskId !== undefined ? { onSubtreeActivity: rowActivitySeat(deps.registry, deps.taskId) } : {}),
|
|
742
759
|
...inheritedHostSeats(deps.currentMcpHostSeats, resumeSpec.mcp ?? []),
|
|
@@ -2058,7 +2075,9 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2058
2075
|
const childCeiling = ctx.toolSelector?.layers ?? [];
|
|
2059
2076
|
const mountedMcpNow = ctx.mountedMcp?.();
|
|
2060
2077
|
const inheritedMcp = opts.tools === undefined && extraToolsNote === undefined && mountedMcpNow !== undefined ? inheritedMcpDeclarations(mountedMcpNow, compileToolSelector([...childCeiling, childOwnLayer])) : [];
|
|
2061
|
-
const
|
|
2078
|
+
const mergedMcp = mergeDefinitionServers(inheritedMcp, def?.mcp);
|
|
2079
|
+
announceShadowedDefinitionServers({ runner: opts.runner, leg: ctx.sessionId, root: { rootSessionId: ctx.rootSessionId ?? ctx.sessionId, rootSessionIncarnation: ctx.rootSessionIncarnation }, agent: def?.name, dropped: mergedMcp.dropped });
|
|
2080
|
+
const childMcp = mergedMcp.servers;
|
|
2062
2081
|
const childTools = [...childPool];
|
|
2063
2082
|
const childRoleBase = roleBaseOf([def !== undefined ? { systemPrompt: def.systemPrompt } : undefined, { promptRole: opts.promptRole, systemPrompt: opts.systemPrompt }]);
|
|
2064
2083
|
const childSystemPrompt = childRoleBase?.systemPrompt;
|
|
@@ -2307,7 +2326,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2307
2326
|
const residualFields = () => {
|
|
2308
2327
|
const recentSteps = stepRecorder.recentSteps();
|
|
2309
2328
|
const editedFiles = stepRecorder.editedFiles();
|
|
2310
|
-
return { ...(recentSteps ? { recentSteps } : {}), ...(editedFiles ? { editedFiles } : {}) };
|
|
2329
|
+
return { ...(recentSteps ? { recentSteps } : {}), ...(editedFiles ? { editedFiles } : {}), ...(ctx.runLedgerBook !== undefined ? { actions: stepRecorder.actions() } : {}) };
|
|
2311
2330
|
};
|
|
2312
2331
|
const entryCapPoolAnchor = backgroundRegistry ?? opts;
|
|
2313
2332
|
const entryCaps = ctx.delegationEntryCaps ?? { maxConcurrent: DELEGATION_MAX_CONCURRENT_DEFAULT, maxCumulativePerSession: DELEGATION_MAX_PER_SESSION_DEFAULT };
|
|
@@ -2358,7 +2377,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2358
2377
|
isDelegatedChild: true,
|
|
2359
2378
|
objectiveAuthor: reviveClaim !== undefined ? "peer" : "parent_model",
|
|
2360
2379
|
...(childPosture !== undefined ? { parentInteractionPosture: childPosture } : {}),
|
|
2361
|
-
...(parentSpecSeat?.
|
|
2380
|
+
...(parentSpecSeat?.project !== undefined ? { parentProject: parentSpecSeat.project } : {}),
|
|
2362
2381
|
...(reviveClaim === undefined
|
|
2363
2382
|
? {
|
|
2364
2383
|
...(liveCaptureFloor?.optedOut === true ? { memoryCaptureFloor: true } : {}),
|
|
@@ -2478,6 +2497,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2478
2497
|
})());
|
|
2479
2498
|
let entry = ledger.register(ctx.toolCallId, {
|
|
2480
2499
|
childSessionId,
|
|
2500
|
+
...(ctx.runLedgerBook !== undefined ? { actionsDigest: true } : {}),
|
|
2481
2501
|
rowVerified,
|
|
2482
2502
|
declarations: holdKeeperDeclarations(opts.runner)(plainSpec),
|
|
2483
2503
|
runner: opts.runner,
|
|
@@ -2547,6 +2567,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2547
2567
|
const { signal: _spawnSignal, ...plainSpec } = failedRetainStrip.spec;
|
|
2548
2568
|
const entry = ledger.register(ctx.toolCallId, {
|
|
2549
2569
|
childSessionId,
|
|
2570
|
+
...(ctx.runLedgerBook !== undefined ? { actionsDigest: true } : {}),
|
|
2550
2571
|
rowVerified: () => true,
|
|
2551
2572
|
declarations: holdKeeperDeclarations(opts.runner)(plainSpec),
|
|
2552
2573
|
runner: opts.runner,
|
|
@@ -3121,7 +3142,9 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3121
3142
|
catch {
|
|
3122
3143
|
}
|
|
3123
3144
|
const wt = await finishWorktree();
|
|
3124
|
-
|
|
3145
|
+
const rejection = childRejection(e);
|
|
3146
|
+
reportInCallMember(ctx, { taskId: forkedId, description: a.description, outcome: memberOutcomeOf("subagent", "live", { from: "ended", status: "failed", ...((code) => (code !== undefined ? { code } : {}))(childRowCode(childFailureOf(rejection))) }), actions: stepRecorder.actions() });
|
|
3147
|
+
return { isError: true, content: `Fork failed: the forked run threw (${childThrownText(e)}).${wt ? `\n${wt}` : ""}`, details: thrownMarksOf(rejection) ?? {} };
|
|
3125
3148
|
}
|
|
3126
3149
|
finally {
|
|
3127
3150
|
syncForkAdmission.release();
|
|
@@ -3140,6 +3163,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3140
3163
|
const forkFace = childTerminalFace(forkChild.terminal);
|
|
3141
3164
|
const forkErr = classifySubagentError(forkChild.terminal);
|
|
3142
3165
|
const forkOutcome = memberOutcomeOf("subagent", "live", { from: "result", result: forkChild, parked: false });
|
|
3166
|
+
reportInCallMember(ctx, { taskId: forkChild.taskId, description: a.description, outcome: forkOutcome, selfReport: forkChild.result, actions: stepRecorder.actions() });
|
|
3143
3167
|
const forkLines = [
|
|
3144
3168
|
...(forkHandbackLead !== undefined ? [forkHandbackLead, ""] : []),
|
|
3145
3169
|
`[Sub-agent report · ${FORK_SUBAGENT_TYPE}${a.description ? ` · ${String(a.description)}` : ""}] (forked session …${forkedId.slice(-8)})`,
|
|
@@ -3611,6 +3635,9 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3611
3635
|
if ("refusal" in door)
|
|
3612
3636
|
return rollbackAndThrow(door.refusal);
|
|
3613
3637
|
const gateSeat = door.seat;
|
|
3638
|
+
const unhanded = parkedResumeUnhanded(parentSpecSeat, gateSeat);
|
|
3639
|
+
if (unhanded !== undefined)
|
|
3640
|
+
return rollbackAndThrow(unhanded);
|
|
3614
3641
|
if (floorRefusal !== undefined)
|
|
3615
3642
|
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" }));
|
|
3616
3643
|
try {
|
|
@@ -4070,6 +4097,8 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
4070
4097
|
};
|
|
4071
4098
|
}
|
|
4072
4099
|
let child;
|
|
4100
|
+
const ledgerMember = (taskId, outcome, selfReport) => reportInCallMember(ctx, { taskId, description: a.description, name: agentName, outcome, selfReport, actions: stepRecorder.actions() });
|
|
4101
|
+
const ledgerThrown = (e, retained) => { const rejection = childRejection(e); ledgerMember(retained?.childSessionId ?? ctx.toolCallId, memberOutcomeOf("subagent", "live", { from: "ended", status: "failed", ...((code) => (code !== undefined ? { code } : {}))(childRowCode(childFailureOf(rejection))) })); return rejection; };
|
|
4073
4102
|
const syncEntryGate = await openEntryGate();
|
|
4074
4103
|
if (ctx.signal?.aborted) {
|
|
4075
4104
|
await cancelObserver();
|
|
@@ -4107,6 +4136,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
4107
4136
|
entryGate: syncEntryGate,
|
|
4108
4137
|
...(opts.onObserverError !== undefined ? { onNotifyError: (f) => opts.onObserverError?.(f.error, { site: f.site }) } : {}),
|
|
4109
4138
|
...(ctx.onQuestion !== undefined ? { currentOnQuestion: ctx.onQuestion } : {}),
|
|
4139
|
+
...(ctx.parentSpecSeat?.project !== undefined ? { currentProject: ctx.parentSpecSeat.project } : {}),
|
|
4110
4140
|
...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
|
|
4111
4141
|
...(ctx.spendSeat !== undefined ? { currentSpendSeat: ctx.spendSeat } : {}),
|
|
4112
4142
|
currentMcpHostSeats: ctx.mountedMcp?.().hostSeats,
|
|
@@ -4124,7 +4154,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
4124
4154
|
}
|
|
4125
4155
|
catch (e) {
|
|
4126
4156
|
await settleObserver("failed");
|
|
4127
|
-
throw
|
|
4157
|
+
throw ledgerThrown(e, retainEntry);
|
|
4128
4158
|
}
|
|
4129
4159
|
finally {
|
|
4130
4160
|
settleResolve();
|
|
@@ -4141,7 +4171,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
4141
4171
|
child = await opts.runner.runTask(buildChildSpec(ctx.signal), childInternals);
|
|
4142
4172
|
}
|
|
4143
4173
|
catch (e) {
|
|
4144
|
-
throw
|
|
4174
|
+
throw ledgerThrown(e, undefined);
|
|
4145
4175
|
}
|
|
4146
4176
|
}
|
|
4147
4177
|
}
|
|
@@ -4169,7 +4199,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
4169
4199
|
if (isDurablePause(child.terminal)) {
|
|
4170
4200
|
if (retainEntry)
|
|
4171
4201
|
ctx.subagentRetain?.abandon(ctx.toolCallId, "durable_pause");
|
|
4172
|
-
return durablePauseDelegationReport(def ? ` · ${def.name}` : "", child.terminal, memberOutcomeOf("subagent", "live", { from: "result", result: child }));
|
|
4202
|
+
return durablePauseDelegationReport(def ? ` · ${def.name}` : "", child.terminal, ledgerMember(child.taskId, memberOutcomeOf("subagent", "live", { from: "result", result: child }), child.result));
|
|
4173
4203
|
}
|
|
4174
4204
|
let failureRetained = false;
|
|
4175
4205
|
if (!retainEntry && namesVerifiedSession(child)) {
|
|
@@ -4189,6 +4219,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
4189
4219
|
return isolationUnavailable(WORKTREE_UNAVAILABLE.notHonored);
|
|
4190
4220
|
const errClass = classifySubagentError(child.terminal);
|
|
4191
4221
|
const childOutcome = memberOutcomeOf("subagent", "live", { from: "result", result: child, parked: false });
|
|
4222
|
+
ledgerMember(child.taskId, childOutcome, child.result);
|
|
4192
4223
|
const lines = [
|
|
4193
4224
|
...((lead) => (lead !== undefined ? [lead, ""] : []))(handbackLeadOf(handback)),
|
|
4194
4225
|
`[Sub-agent report${def ? ` · ${def.name}` : ""}${a.description ? ` · ${String(a.description)}` : ""}]`,
|