@sema-agent/core 7.59.0 → 7.60.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 +564 -0
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +2 -1
- package/dist/agents/agent-transcript-tool.js +3 -1
- package/dist/agents/child-model-seat.js +6 -3
- package/dist/agents/cumulative-stats.js +0 -1
- package/dist/agents/inherited-tool-pool.d.ts +26 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +13 -2
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +3 -1
- package/dist/agents/send-message-tool.d.ts +8 -19
- package/dist/agents/send-message-tool.js +11 -38
- package/dist/agents/subagent.d.ts +51 -17
- package/dist/agents/subagent.js +117 -78
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/route-adjudicator.js +3 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/timeout.d.ts +3 -1
- package/dist/brain/timeout.js +18 -5
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/allow-entry.d.ts +2 -0
- package/dist/core/allow-entry.js +3 -1
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +63 -12
- package/dist/core/background-agent-store.d.ts +10 -1
- package/dist/core/background-agent-store.js +3 -2
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-store.d.ts +8 -13
- package/dist/core/checkpoint-store.js +4 -3
- package/dist/core/compliance.d.ts +1 -1
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +4 -5
- package/dist/core/engine-notice.d.ts +58 -15
- package/dist/core/frame-settlement.d.ts +5 -0
- package/dist/core/frame-settlement.js +4 -0
- package/dist/core/gate-fold.js +7 -5
- package/dist/core/gate-lanes.js +39 -8
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +12 -0
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +39 -56
- package/dist/core/hooks.js +123 -77
- package/dist/core/image-admission.d.ts +104 -51
- package/dist/core/image-admission.js +170 -46
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/locked-config.d.ts +54 -3
- package/dist/core/locked-config.js +81 -50
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-failure.d.ts +9 -3
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-host-seat.d.ts +92 -0
- package/dist/core/mcp-host-seat.js +131 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +7 -2
- package/dist/core/mcp-server-spec.d.ts +38 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp.d.ts +17 -6
- package/dist/core/mcp.js +67 -55
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/index.d.ts +2 -1
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +45 -11
- package/dist/core/memory-engine/sync-client.js +82 -11
- package/dist/core/memory-engine/sync-report.d.ts +103 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +4 -2
- package/dist/core/mode-policy.d.ts +9 -1
- package/dist/core/mode-policy.js +11 -1
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +65 -0
- package/dist/core/mods/agent-stations.js +105 -0
- package/dist/core/mods/kernel/dispatch.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +10 -4
- package/dist/core/mods/kernel/events.js +10 -6
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/stations.d.ts +51 -59
- package/dist/core/mods/stations.js +32 -42
- package/dist/core/mods/tool-call.d.ts +10 -4
- package/dist/core/mods/tool-call.js +28 -12
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/own-property-receipt.d.ts +3 -0
- package/dist/core/own-property-receipt.js +3 -0
- package/dist/core/park-selfcheck.js +8 -8
- package/dist/core/peer-seat.d.ts +63 -8
- package/dist/core/peer-seat.js +179 -34
- package/dist/core/permission-rule-consent.d.ts +0 -21
- package/dist/core/permission-rule-consent.js +1 -2
- package/dist/core/permission-rule-model.d.ts +4 -2
- package/dist/core/permission-rule-model.js +7 -6
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +146 -98
- package/dist/core/remote-env.js +113 -14
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +6 -1
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +12 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +37 -3
- package/dist/core/roles.js +126 -78
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/assemble-result.d.ts +0 -5
- package/dist/core/runner/assemble-result.js +0 -1
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +21 -10
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/construction-doors.js +5 -0
- package/dist/core/runner/contracts.d.ts +62 -41
- package/dist/core/runner/cross-boundary-lane.d.ts +3 -5
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +75 -7
- package/dist/core/runner/gate-exit.js +20 -1
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +3 -4
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/permission-rule-lanes.js +1 -1
- package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
- package/dist/core/runner/prepare-boundary-parks.js +3 -3
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +14 -9
- package/dist/core/runner/prepare-delegation-surface.d.ts +5 -3
- package/dist/core/runner/prepare-delegation-surface.js +4 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -3
- package/dist/core/runner/prepare-gate-stations.js +4 -3
- package/dist/core/runner/prepare-hands-readface.d.ts +3 -1
- package/dist/core/runner/prepare-hands-readface.js +15 -7
- package/dist/core/runner/prepare-inherited-gate.d.ts +5 -4
- package/dist/core/runner/prepare-inherited-gate.js +9 -5
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +3 -5
- package/dist/core/runner/prepare-park-ask.js +3 -8
- package/dist/core/runner/prepare-policy-chain.d.ts +5 -4
- package/dist/core/runner/prepare-policy-chain.js +120 -108
- package/dist/core/runner/prepare-project-context.js +8 -5
- package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -1
- package/dist/core/runner/prepare-prompt-inputs.js +3 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +9 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +0 -2
- package/dist/core/runner/prepare-suspend-saga.js +5 -7
- package/dist/core/runner/prepare-task.js +41 -27
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +4 -3
- package/dist/core/runner/prepare-wiring-manifest.js +32 -18
- package/dist/core/runner/prepare-workspace-restore.js +3 -3
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/retired-runner-deps.js +4 -1
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +1 -1
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +3 -1
- package/dist/core/runner/run-identity-wiring.js +1 -1
- package/dist/core/runner/run-leg.js +26 -28
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +16 -10
- package/dist/core/runner/run-settle-and-teardown.js +5 -1
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +12 -4
- package/dist/core/runner/run-turn-boundary.js +12 -7
- package/dist/core/runner/runtask.d.ts +7 -4
- package/dist/core/runner/runtask.js +19 -11
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.js +10 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/tool-disclosure.js +0 -2
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/turn-attachments.d.ts +3 -5
- package/dist/core/runner/turn-attachments.js +3 -16
- package/dist/core/runner-deps.d.ts +31 -18
- package/dist/core/secret-env.d.ts +3 -2
- package/dist/core/session-policy-store.d.ts +9 -2
- package/dist/core/session-policy-store.js +16 -1
- package/dist/core/session-store.d.ts +3 -2
- package/dist/core/session-store.js +50 -11
- package/dist/core/skill-grant.d.ts +9 -0
- package/dist/core/skill-grant.js +18 -0
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +37 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/task-event.d.ts +18 -2
- package/dist/core/task-notification.d.ts +88 -5
- package/dist/core/task-notification.js +130 -7
- package/dist/core/task-registry-agent.d.ts +18 -12
- package/dist/core/task-registry-agent.js +18 -6
- package/dist/core/task-registry-monitor.d.ts +7 -0
- package/dist/core/task-registry-monitor.js +28 -1
- package/dist/core/task-registry-shared.d.ts +38 -3
- package/dist/core/task-registry-shared.js +21 -7
- package/dist/core/task-registry-workflow.js +1 -1
- package/dist/core/task-registry.d.ts +50 -35
- package/dist/core/task-registry.js +64 -23
- package/dist/core/task-result.d.ts +3 -12
- package/dist/core/task-spec.d.ts +3 -6
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +1 -1
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +4 -3
- package/dist/core/tool-name-aliases.d.ts +19 -0
- package/dist/core/tool-name-aliases.js +54 -2
- package/dist/core/tool-policy.d.ts +5 -4
- package/dist/core/tool-policy.js +1 -1
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +88 -5
- package/dist/core/tool-result-store.js +51 -12
- package/dist/core/tool-spec.d.ts +20 -4
- package/dist/core/trace.d.ts +0 -1
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +14 -6
- package/dist/engine/execution-env/node-execution-env.d.ts +7 -2
- package/dist/engine/execution-env/node-execution-env.js +12 -1
- package/dist/engine/harness/agent-harness.d.ts +1 -1
- package/dist/engine/harness/agent-harness.js +8 -4
- package/dist/engine/harness/types.d.ts +112 -29
- package/dist/engine/loop/agent-loop.d.ts +12 -12
- package/dist/engine/loop/agent-loop.js +153 -21
- package/dist/engine/loop/types.d.ts +9 -2
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/index.d.ts +22 -14
- package/dist/index.js +15 -10
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +9 -3
- package/dist/orchestration/run-workflow-tool.js +59 -29
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow.d.ts +4 -0
- package/dist/orchestration/workflow.js +25 -4
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +3 -1
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +19 -14
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +3 -1
- package/dist/stores/file/index.d.ts +4 -3
- package/dist/stores/file/index.js +17 -8
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +3 -1
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +3 -1
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +3 -1
- package/dist/stores/file/session-store.d.ts +1 -1
- package/dist/stores/file/session-store.js +3 -1
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +20 -2
- package/dist/stores/file/tool-result-store.js +74 -6
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +3 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -11
- package/dist/stores/file/workflow-journal-store.js +3 -2
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +7 -0
- package/dist/tools/fs/fs-bash-background-text.js +1 -0
- package/dist/tools/fs/fs-bash.d.ts +8 -4
- package/dist/tools/fs/fs-bash.js +26 -35
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +26 -21
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +11 -13
- package/dist/tools/fs/fs-shared.js +11 -7
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +14 -8
- package/dist/tools/fs/index.js +8 -4
- package/dist/tools/fs/read-floor.d.ts +44 -1
- package/dist/tools/fs/read-floor.js +35 -0
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +3 -3
- package/dist/tools/fs/search.js +4 -4
- package/dist/tools/monitor.d.ts +5 -4
- package/dist/tools/monitor.js +15 -8
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/package.json +4 -2
- package/test/export-surface.snapshot.json +75 -21
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
package/dist/agents/subagent.js
CHANGED
|
@@ -21,8 +21,9 @@ import { childModelSeat, childThinkingSeat, deploymentStatesSubagentModel, deplo
|
|
|
21
21
|
export { childThinkingSeat, deploymentSubagentThinking, deploymentSubagentTierModel } from "./child-model-seat.js";
|
|
22
22
|
import { REPORT_BLOCKED_TOOL_NAME } from "../core/runner/synthetic-tools.js";
|
|
23
23
|
import { TOOL_SEARCH_NAME } from "../core/runner/tool-disclosure.js";
|
|
24
|
-
import { OFFLOAD_TOOL_NAME } from "../core/tool-result-store.js";
|
|
25
|
-
import { compileToolSelector, delegationListWhere, namesEveryTool,
|
|
24
|
+
import { OFFLOAD_TOOL_NAME, persistTaskArtifact } from "../core/tool-result-store.js";
|
|
25
|
+
import { compileToolSelector, delegationListWhere, namesEveryTool, toolListsDigest, toolNameAllowed, toolNameListFlaw } from "./tool-filter.js";
|
|
26
|
+
import { snapshotDefinitionLists } from "./agent-definition.js";
|
|
26
27
|
import { readToolNameList, snapshotToolNameList } from "../core/tool-name-list.js";
|
|
27
28
|
import { EXTRA_TOOL_NAMES_CODE, delegationPoolFace, extraToolNamesError, firstUndeclaredExtraTool, readExtraToolNames } from "./extra-tool-names.js";
|
|
28
29
|
import { builtinAgentDefinitions } from "./builtin-agents.js";
|
|
@@ -44,7 +45,7 @@ import { BG_AGENT_REAP_STOP_ERROR, chosenAgentName } from "../core/task-registry
|
|
|
44
45
|
import { readDurableOrgAdmission } from "../core/memory-admission.js";
|
|
45
46
|
import { governanceRetryClass } from "../core/governance-codes.js";
|
|
46
47
|
import { readSkillGrantCapture } from "../core/skill-grant.js";
|
|
47
|
-
import {
|
|
48
|
+
import { completionResultField, oweTerminalDelivery, resolveCompletionSink, retireTerminalDelivery, terminalFrameFacets } from "../core/task-notification.js";
|
|
48
49
|
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";
|
|
49
50
|
function rollupDelegatedCost(stats, nested) {
|
|
50
51
|
if (stats.costMicroUsd === undefined)
|
|
@@ -71,15 +72,15 @@ function providerFaultField(child) {
|
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
export { RETAIN_DEFAULT_TTL_MS, RETAIN_DEFAULT_MAX };
|
|
74
|
-
import { SUBAGENT_RESUME_CAP, SubagentRetainLedger, getOrCreateSessionRetainLedger, ensureSessionReapHook, createResumePrompt, } from "./retain-ledger.js";
|
|
75
|
+
import { SUBAGENT_RESUME_CAP, SubagentRetainLedger, getOrCreateSessionRetainLedger, ensureSessionReapHook, createResumePrompt, holdChildDeclarations, } from "./retain-ledger.js";
|
|
75
76
|
import { createPeerInboundChainRef, createPeerSelfRef } from "./peer-admission.js";
|
|
76
77
|
import { recordRosterSpawn } from "./roster-store.js";
|
|
77
78
|
import { LAUNCH_RECEIPT_OWN_WORDS_CLAUSE, launchReceiptNoQuoteClause } from "./launch-receipt-contract.js";
|
|
78
79
|
import { ObserverDigestTap, ObserverPairing, createObserverReportToolSpec, markObserverTaskId, unmarkObserverTaskId, isObserverTaskId, ObserverResumeStateError, ObserverStoppedByUserError, observerFramingPrompt, observerSlug, resolveObserverDeclaration, } from "./observer.js";
|
|
79
|
-
import { SubagentStepRecorder } from "./subagent-steps.js";
|
|
80
|
+
import { SubagentStepRecorder, redactThenCut } from "./subagent-steps.js";
|
|
80
81
|
import { OUTPUT_TOOL_NAME, mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
|
|
81
82
|
import { canonicalNameValue } from "../core/permission-rule-model.js";
|
|
82
|
-
import { inheritedChildPool, inheritedMcpDeclarations } from "./inherited-tool-pool.js";
|
|
83
|
+
import { definitionAllowTools, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, withDefinitionServers, withoutHostSeats } from "./inherited-tool-pool.js";
|
|
83
84
|
import { readMember, thrownText } from "../core/thrown-value.js";
|
|
84
85
|
const BG_AGENT_RESULT_MAX = 4_000;
|
|
85
86
|
const BG_AGENT_RESULT_FULL_MAX = 200_000;
|
|
@@ -552,6 +553,7 @@ export function createSubagentResume(deps) {
|
|
|
552
553
|
let stream;
|
|
553
554
|
let reviveCycle;
|
|
554
555
|
let reviveEmit;
|
|
556
|
+
let releaseCycleSlot = noopRelease;
|
|
555
557
|
let marker;
|
|
556
558
|
let reviveStartedAt = Date.now();
|
|
557
559
|
try {
|
|
@@ -650,8 +652,10 @@ export function createSubagentResume(deps) {
|
|
|
650
652
|
usage: { toolUses: toolStarts },
|
|
651
653
|
});
|
|
652
654
|
}, deps.registry !== undefined && deps.taskId !== undefined ? () => deps.registry.noteBackgroundAgentActivity(deps.taskId) : undefined);
|
|
655
|
+
releaseCycleSlot = deps.entryGate?.occupy(reviveCycle !== undefined ? "registered" : "local") ?? noopRelease;
|
|
653
656
|
stream = childRunner.runTaskStream(resumeSpec, undefined, {
|
|
654
657
|
...entry.internalsSnapshot,
|
|
658
|
+
...inheritedHostSeats(deps.currentMcpHostSeats, resumeSpec.mcp ?? []),
|
|
655
659
|
...(peerOrigin === undefined ? { operatorObjective: true } : {}),
|
|
656
660
|
cycleSeq: entry.cycleSeq,
|
|
657
661
|
parentInteractionPosture: postureUnderClamps(entry.internalsSnapshot.parentInteractionPosture, { interactiveTools: resumeSpec.interactiveTools, approvalReach: resumeSpec.approvalReach }),
|
|
@@ -707,12 +711,15 @@ export function createSubagentResume(deps) {
|
|
|
707
711
|
catch (err) {
|
|
708
712
|
entry.running = false;
|
|
709
713
|
entry.activeAbort = undefined;
|
|
714
|
+
releaseCycleSlot();
|
|
710
715
|
throw err;
|
|
711
716
|
}
|
|
712
717
|
if (entry.deferredNotify !== undefined) {
|
|
713
|
-
entry.deferredNotify
|
|
718
|
+
const parked = entry.deferredNotify;
|
|
714
719
|
entry.deferredNotify = undefined;
|
|
720
|
+
notifier.notify(() => parked.cancel(), "subagent.resume.park_cancel");
|
|
715
721
|
}
|
|
722
|
+
oweTerminalDelivery(deps.notify, { task_id: deps.taskId ?? entry.childSessionId, task_type: "background_agent" });
|
|
716
723
|
let settleResolve;
|
|
717
724
|
const settled = new Promise((r) => {
|
|
718
725
|
settleResolve = r;
|
|
@@ -771,6 +778,9 @@ export function createSubagentResume(deps) {
|
|
|
771
778
|
named: deps.rowName !== undefined,
|
|
772
779
|
});
|
|
773
780
|
const ownsTerminalFacesRevive = deps.registry !== undefined && deps.taskId !== undefined ? deps.registry.claimAgentTerminalNotify(deps.taskId) : true;
|
|
781
|
+
const resumeResultField = await completionResultField(resumeHandbackResult, (report) => persistTaskArtifact(deps.currentTaskArtifacts, deps.taskId ?? entry.childSessionId, report));
|
|
782
|
+
if (resumeResultField?.ref !== undefined && deps.taskId !== undefined && reviveCycle !== undefined)
|
|
783
|
+
deps.registry?.recordArtifactRef(deps.taskId, resumeResultField.ref, reviveCycle);
|
|
774
784
|
const resumeFrame = {
|
|
775
785
|
task_id: deps.taskId ?? entry.childSessionId,
|
|
776
786
|
...(entry.childSessionId !== undefined ? { sessionId: entry.childSessionId } : {}),
|
|
@@ -784,7 +794,7 @@ export function createSubagentResume(deps) {
|
|
|
784
794
|
...(failReasonRevive !== undefined ? { error: failReasonRevive.slice(0, REPORT_FIELD_MAX) } : {}),
|
|
785
795
|
...(status === "failed" && errCodeRevive !== undefined ? { errorCode: errCodeRevive } : {}),
|
|
786
796
|
...providerFaultField(child),
|
|
787
|
-
...(
|
|
797
|
+
...(resumeResultField !== undefined ? { result: resumeResultField.text } : {}),
|
|
788
798
|
...(status === "killed" && child.result ? { partial: true } : {}),
|
|
789
799
|
...resumeResidual(),
|
|
790
800
|
resumable: resumableRevive,
|
|
@@ -860,6 +870,7 @@ export function createSubagentResume(deps) {
|
|
|
860
870
|
finally {
|
|
861
871
|
entry.running = false;
|
|
862
872
|
entry.activeAbort = undefined;
|
|
873
|
+
releaseCycleSlot();
|
|
863
874
|
entry.settledAt = Date.now();
|
|
864
875
|
ledger.markSettled(deps.parentToolCallId);
|
|
865
876
|
settleResolve();
|
|
@@ -897,6 +908,7 @@ function parkCompletionNotify(deps) {
|
|
|
897
908
|
return;
|
|
898
909
|
done = true;
|
|
899
910
|
unsubscribe();
|
|
911
|
+
retireTerminalDelivery(notify, payload);
|
|
900
912
|
};
|
|
901
913
|
entry.deferredNotify = { ...(payload.seq !== undefined ? { seq: payload.seq } : {}), cancel, flush: () => deliver(false) };
|
|
902
914
|
}
|
|
@@ -1112,9 +1124,10 @@ async function untilAbort(p, signal) {
|
|
|
1112
1124
|
async function openDelegationEntryGate(input) {
|
|
1113
1125
|
const { poolAnchor, registry, store, root, caps, revival, signal } = input;
|
|
1114
1126
|
if (root === undefined)
|
|
1115
|
-
return { key: undefined, admit: () => ({ admitted: true, release: noopRelease }) };
|
|
1127
|
+
return { key: undefined, admit: () => ({ admitted: true, release: noopRelease }), occupy: () => noopRelease };
|
|
1116
1128
|
const scope = input.scope ?? DELEGATION_POOL_DEFAULT_SCOPE;
|
|
1117
1129
|
const key = JSON.stringify([scope, root]);
|
|
1130
|
+
const occupy = (kind) => (kind === "local" ? chargeLocalDelegationInFlight(poolAnchor, key) : noopRelease);
|
|
1118
1131
|
let storedHandles = [];
|
|
1119
1132
|
let storedEnumerationOk = false;
|
|
1120
1133
|
if (store !== undefined && !revival) {
|
|
@@ -1173,9 +1186,9 @@ async function openDelegationEntryGate(input) {
|
|
|
1173
1186
|
};
|
|
1174
1187
|
}
|
|
1175
1188
|
}
|
|
1176
|
-
return { admitted: true, release: kind
|
|
1189
|
+
return { admitted: true, release: occupy(kind) };
|
|
1177
1190
|
};
|
|
1178
|
-
return { key, admit };
|
|
1191
|
+
return { key, admit, occupy };
|
|
1179
1192
|
}
|
|
1180
1193
|
function chargeDelegationEntryHandle(registry, key, store, handle) {
|
|
1181
1194
|
if (handle !== undefined)
|
|
@@ -1184,6 +1197,16 @@ function chargeDelegationEntryHandle(registry, key, store, handle) {
|
|
|
1184
1197
|
armDelegationLedgerLifecycle(registry);
|
|
1185
1198
|
sweepDelegationLedgerRound(registry, 3);
|
|
1186
1199
|
}
|
|
1200
|
+
async function releaseBoundChildSession(bound, sessionId, release) {
|
|
1201
|
+
try {
|
|
1202
|
+
await release();
|
|
1203
|
+
}
|
|
1204
|
+
catch {
|
|
1205
|
+
return false;
|
|
1206
|
+
}
|
|
1207
|
+
bound?.registry.releaseDurableTranscriptAnchor(bound.taskId, sessionId);
|
|
1208
|
+
return true;
|
|
1209
|
+
}
|
|
1187
1210
|
export { normalizeSubagentType } from "../core/permission-rule-model.js";
|
|
1188
1211
|
function canonicalSubagentTypeArgs(args, accepted, generalPurposeShadowed) {
|
|
1189
1212
|
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
@@ -1246,20 +1269,15 @@ export function forkWorktreeTranslationNote(parentCwd, worktreeDir) {
|
|
|
1246
1269
|
}
|
|
1247
1270
|
export function asyncLaunchedReceipt(p) {
|
|
1248
1271
|
const noteLines = (p.notes ?? []).filter((n) => n !== undefined && n !== "");
|
|
1249
|
-
const oneShotBlocked = p.notify && p.oneShot === true;
|
|
1250
1272
|
return (`Async agent launched successfully. (${launchReceiptNoQuoteClause(", including the task_id below,")})\n` +
|
|
1251
1273
|
`task_id: ${p.taskId} (internal ID - do not mention to user. ${launchContinuationSentence(p.taskId)})\n` +
|
|
1252
|
-
(
|
|
1253
|
-
? `${p.workingLine}
|
|
1254
|
-
: p.
|
|
1255
|
-
? `${p.workingLine} You will be notified automatically when it completes. You know nothing about its results until that notification arrives — do not report, assume, or predict them; continue other work or respond to the user in the meantime.\n`
|
|
1256
|
-
: `${p.workingLine} Its result is NOT pushed automatically — retrieve progress and results with TaskOutput(task_id) where mounted.\n`) +
|
|
1274
|
+
(p.notify
|
|
1275
|
+
? `${p.workingLine} You will be notified automatically when it completes. You know nothing about its results until that notification arrives — do not report, assume, or predict them; continue other work or respond to the user in the meantime.\n`
|
|
1276
|
+
: `${p.workingLine} Its result is NOT pushed automatically — retrieve progress and results with TaskOutput(task_id) where mounted.\n`) +
|
|
1257
1277
|
noteLines.map((n) => `${n}\n`).join("") +
|
|
1258
|
-
(
|
|
1259
|
-
? `${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE}
|
|
1260
|
-
:
|
|
1261
|
-
? `${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE} Agent results will arrive in a subsequent message. If the user asks for progress, say the agent is still running.`
|
|
1262
|
-
: `${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE} The result will NOT arrive on its own — retrieve it with TaskOutput(task_id) where mounted before relying on it.`));
|
|
1278
|
+
(p.notify
|
|
1279
|
+
? `${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE} Agent results will arrive in a subsequent message. If the user asks for progress, say the agent is still running.`
|
|
1280
|
+
: `${LAUNCH_RECEIPT_OWN_WORDS_CLAUSE} The result will NOT arrive on its own — retrieve it with TaskOutput(task_id) where mounted before relying on it.`));
|
|
1263
1281
|
}
|
|
1264
1282
|
function runnerModelCatalog(runner) {
|
|
1265
1283
|
try {
|
|
@@ -1387,10 +1405,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1387
1405
|
const depthPermitsNesting = depth + 1 < maxDepth;
|
|
1388
1406
|
const agentToolFaces = [
|
|
1389
1407
|
...(generalPurposeShadowed ? [] : [{ name: GENERAL_PURPOSE_SUBAGENT_TYPE, ...(depthPermitsNesting ? { canRedelegate: true } : {}) }]),
|
|
1390
|
-
...available.map((a) => ({
|
|
1408
|
+
...available.map((a) => ({ a, allow: definitionAllowTools(a) })).map(({ a, allow }) => ({
|
|
1391
1409
|
name: a.name,
|
|
1392
|
-
...(
|
|
1410
|
+
...(allow !== undefined ? { allowTools: allow } : {}),
|
|
1393
1411
|
...(a.denyTools !== undefined ? { denyTools: a.denyTools } : {}),
|
|
1412
|
+
...(a.mcp !== undefined && a.mcp.length > 0 ? { servers: a.mcp.map((s) => ({ name: s.name, ...(s.contentOrigin !== undefined ? { contentOrigin: s.contentOrigin } : {}) })) } : {}),
|
|
1394
1413
|
...(depthPermitsNesting && toolNameAllowed(delegationToolName, a.allowTools, a.denyTools) ? { canRedelegate: true } : {}),
|
|
1395
1414
|
...(depth === 0 && !builtins.includes(a) ? { authored: true } : {}),
|
|
1396
1415
|
})),
|
|
@@ -1726,6 +1745,30 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1726
1745
|
details: { error: "skill_grants.unreadable" },
|
|
1727
1746
|
});
|
|
1728
1747
|
}
|
|
1748
|
+
const stations = reviveClaim === undefined ? ctx.agentStations : undefined;
|
|
1749
|
+
if (stations?.listens("agent.offer") === true) {
|
|
1750
|
+
const listed = agentListing.find((entry) => entry.name === spawnAgentType);
|
|
1751
|
+
const offered = await stations.offered([{ name: spawnAgentType, description: listed?.description ?? "" }], ctx.signal);
|
|
1752
|
+
if (offered.length === 0) {
|
|
1753
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: subagent_type "${inlineUntrusted(spawnAgentType, 80)}" is not offered here. Available subagent_type values are the ones the agent listing names.`, details: { error: "unknown subagent_type" } });
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
if (stations?.listens("agent.spawn") === true) {
|
|
1757
|
+
const verdict = await stations.spawn({
|
|
1758
|
+
toolCallId: ctx.toolCallId,
|
|
1759
|
+
prompt,
|
|
1760
|
+
description: typeof a.description === "string" ? a.description : "",
|
|
1761
|
+
subagentType: spawnAgentType,
|
|
1762
|
+
...(spawnModel !== undefined ? { model: spawnModel } : {}),
|
|
1763
|
+
...(ctx.model?.id !== undefined ? { parentModel: ctx.model.id } : {}),
|
|
1764
|
+
background: wantsBackground,
|
|
1765
|
+
fork: wantsFork,
|
|
1766
|
+
...(agentName !== undefined ? { name: agentName } : {}),
|
|
1767
|
+
...(childCwd !== undefined ? { cwd: childCwd } : {}),
|
|
1768
|
+
}, ctx.signal);
|
|
1769
|
+
if (!verdict.go)
|
|
1770
|
+
return notStartedResult({ isError: true, content: `Sub-agent not started: ${verdict.reason.slice(0, 600)}`, details: { error: "mods.spawn_refused", refusedBy: verdict.by } });
|
|
1771
|
+
}
|
|
1729
1772
|
let worktreeDir;
|
|
1730
1773
|
if (reviveClaim === undefined && (a.isolation ?? def?.isolation) === "worktree") {
|
|
1731
1774
|
const iso = ctx.worktreeIsolation;
|
|
@@ -1848,13 +1891,14 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
1848
1891
|
}
|
|
1849
1892
|
childPool = [...(opts.tools ?? inherited.filter((t) => ![t.name, ...(t.aliases ?? [])].some((n) => taken.has(n)))), ...accepted];
|
|
1850
1893
|
}
|
|
1851
|
-
const governingLists = def !== undefined ? { allow: def
|
|
1894
|
+
const governingLists = def !== undefined ? { allow: definitionAllowTools(def), deny: def.denyTools } : { allow: opts.allowTools, deny: opts.denyTools };
|
|
1852
1895
|
const childOwnLayer = Object.freeze({ ...(governingLists.allow != null ? { allow: Object.freeze([...governingLists.allow]) } : {}), deny: Object.freeze([...(governingLists.deny ?? [])]) });
|
|
1853
1896
|
const childListsDigest = toolListsDigest(childOwnLayer.allow, childOwnLayer.deny);
|
|
1854
1897
|
const childListsJudged = agentToolPool !== undefined ? childListsDigest : undefined;
|
|
1855
1898
|
const childCeiling = ctx.toolSelector?.layers ?? [];
|
|
1856
|
-
const
|
|
1857
|
-
const
|
|
1899
|
+
const mountedMcpNow = ctx.mountedMcp?.();
|
|
1900
|
+
const parentMcp = opts.tools === undefined && extraToolsNote === undefined ? mountedMcpNow : undefined;
|
|
1901
|
+
const childMcp = withDefinitionServers(parentMcp !== undefined ? inheritedMcpDeclarations(parentMcp, compileToolSelector([...childCeiling, childOwnLayer])) : undefined, def?.mcp);
|
|
1858
1902
|
const childTools = [...childPool];
|
|
1859
1903
|
const childRoleBase = roleBaseOf([def !== undefined ? { systemPrompt: def.systemPrompt } : undefined, { promptRole: opts.promptRole, systemPrompt: opts.systemPrompt }]);
|
|
1860
1904
|
const childSystemPrompt = childRoleBase?.systemPrompt;
|
|
@@ -2123,7 +2167,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2123
2167
|
const childInternals = {
|
|
2124
2168
|
...(ctx.toolSelector !== undefined ? { toolCeiling: childCeiling, ...(childListsJudged !== undefined ? { toolListsJudged: childListsJudged } : {}) } : {}),
|
|
2125
2169
|
...(childListsDigest !== undefined ? { ownToolLists: { toolName, ...(def !== undefined ? { definition: def.name } : {}), lists: childListsDigest } } : {}),
|
|
2126
|
-
...(
|
|
2170
|
+
...(mountedMcpNow?.pool !== undefined && childMcp.length > 0 ? { mcpPool: mountedMcpNow.pool } : {}),
|
|
2171
|
+
...inheritedHostSeats(mountedMcpNow?.hostSeats, childMcp),
|
|
2127
2172
|
...(childPick.modelRef !== undefined ? { inheritedModelRef: childPick.modelRef } : {}),
|
|
2128
2173
|
...(inheritedSkillGrants.length > 0 ? { inheritedSkillGrants } : {}),
|
|
2129
2174
|
...(inheritedAllowedTools !== undefined && inheritedAllowedTools.length > 0 ? { inheritedAllowedTools: [...inheritedAllowedTools] } : {}),
|
|
@@ -2215,7 +2260,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2215
2260
|
...childSeat,
|
|
2216
2261
|
...childThinking,
|
|
2217
2262
|
tools: childTools,
|
|
2218
|
-
...(childMcp
|
|
2263
|
+
...(childMcp.length > 0 ? { mcp: childMcp } : {}),
|
|
2219
2264
|
systemPrompt: childSystemPrompt,
|
|
2220
2265
|
...(childRoleBase?.promptRole !== undefined ? { promptRole: childRoleBase.promptRole } : {}),
|
|
2221
2266
|
...(def?.memory ? { memory: def.memory } : {}),
|
|
@@ -2236,14 +2281,27 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2236
2281
|
signal,
|
|
2237
2282
|
}, parentSpecSeat));
|
|
2238
2283
|
const spawnPolicyFloor = () => clampSeatsOf(buildChildSpec(undefined));
|
|
2239
|
-
const tryRetainChild = async (ledger, entryTtlMs, preMintedSessionId, durableProbe,
|
|
2284
|
+
const tryRetainChild = async (ledger, entryTtlMs, preMintedSessionId, durableProbe, bound, internalsExtra) => {
|
|
2240
2285
|
if (!ledger)
|
|
2241
2286
|
return undefined;
|
|
2242
2287
|
const childSessionId = preMintedSessionId ?? uuidv7();
|
|
2243
2288
|
const retainStrip = stripSpawnTurnQuestionFace(buildChildSpec(undefined));
|
|
2244
2289
|
const { signal: _spawnSignal, ...plainSpec } = retainStrip.spec;
|
|
2290
|
+
const launchesOnThisId = preMintedSessionId !== undefined;
|
|
2291
|
+
let releasing;
|
|
2292
|
+
const releaseEntry = () => (releasing ??= (async () => {
|
|
2293
|
+
try {
|
|
2294
|
+
await opts.runner.sessions.unpin?.(childSessionId);
|
|
2295
|
+
}
|
|
2296
|
+
catch {
|
|
2297
|
+
}
|
|
2298
|
+
if (durableProbe && (await durableProbe().catch(() => false)))
|
|
2299
|
+
return;
|
|
2300
|
+
await releaseBoundChildSession(bound, childSessionId, () => opts.runner.sessions.release(childSessionId));
|
|
2301
|
+
})());
|
|
2245
2302
|
let entry = ledger.register(ctx.toolCallId, {
|
|
2246
2303
|
childSessionId,
|
|
2304
|
+
declarations: holdChildDeclarations(opts.runner, plainSpec),
|
|
2247
2305
|
runner: opts.runner,
|
|
2248
2306
|
...(entryTtlMs !== undefined ? { ttlMs: entryTtlMs } : {}),
|
|
2249
2307
|
...(childAgentName !== undefined ? { agentName: childAgentName } : {}),
|
|
@@ -2260,22 +2318,8 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2260
2318
|
...(plainSpec.alwaysLoadTools !== undefined ? { alwaysLoadTools: [...plainSpec.alwaysLoadTools] } : {}),
|
|
2261
2319
|
...(Array.isArray(plainSpec.restoreGatedTools) ? { restoreGatedTools: [...plainSpec.restoreGatedTools] } : {}),
|
|
2262
2320
|
}),
|
|
2263
|
-
internalsSnapshot: { ...childInternals, ...retainStrip.internalsFlag, ...(internalsExtra ?? {}) },
|
|
2264
|
-
release:
|
|
2265
|
-
try {
|
|
2266
|
-
await opts.runner.sessions.unpin?.(childSessionId);
|
|
2267
|
-
}
|
|
2268
|
-
catch {
|
|
2269
|
-
}
|
|
2270
|
-
if (durableProbe && (await durableProbe().catch(() => false)))
|
|
2271
|
-
return;
|
|
2272
|
-
try {
|
|
2273
|
-
await opts.runner.sessions.release(childSessionId);
|
|
2274
|
-
releaseAnchor?.();
|
|
2275
|
-
}
|
|
2276
|
-
catch {
|
|
2277
|
-
}
|
|
2278
|
-
},
|
|
2321
|
+
internalsSnapshot: { ...withoutHostSeats(childInternals), ...retainStrip.internalsFlag, ...(internalsExtra ?? {}) },
|
|
2322
|
+
release: releaseEntry,
|
|
2279
2323
|
});
|
|
2280
2324
|
if (entry) {
|
|
2281
2325
|
try {
|
|
@@ -2283,21 +2327,20 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2283
2327
|
}
|
|
2284
2328
|
catch {
|
|
2285
2329
|
await ledger.evict(ctx.toolCallId);
|
|
2330
|
+
if (launchesOnThisId)
|
|
2331
|
+
await releaseEntry();
|
|
2286
2332
|
entry = undefined;
|
|
2287
2333
|
}
|
|
2288
2334
|
if (entry !== undefined && (ledger.disposed || ledger.get(ctx.toolCallId) !== entry)) {
|
|
2335
|
+
if (launchesOnThisId)
|
|
2336
|
+
await releaseEntry();
|
|
2289
2337
|
try {
|
|
2290
2338
|
await opts.runner.sessions.unpin?.(childSessionId);
|
|
2291
2339
|
}
|
|
2292
2340
|
catch {
|
|
2293
2341
|
}
|
|
2294
2342
|
if (!(durableProbe && (await durableProbe().catch(() => false)))) {
|
|
2295
|
-
|
|
2296
|
-
await opts.runner.sessions.release(childSessionId);
|
|
2297
|
-
releaseAnchor?.();
|
|
2298
|
-
}
|
|
2299
|
-
catch {
|
|
2300
|
-
}
|
|
2343
|
+
await releaseBoundChildSession(bound, childSessionId, () => opts.runner.sessions.release(childSessionId));
|
|
2301
2344
|
}
|
|
2302
2345
|
entry = undefined;
|
|
2303
2346
|
}
|
|
@@ -2327,6 +2370,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2327
2370
|
const { signal: _spawnSignal, ...plainSpec } = failedRetainStrip.spec;
|
|
2328
2371
|
const entry = ledger.register(ctx.toolCallId, {
|
|
2329
2372
|
childSessionId,
|
|
2373
|
+
declarations: holdChildDeclarations(opts.runner, plainSpec),
|
|
2330
2374
|
runner: opts.runner,
|
|
2331
2375
|
ttlMs: FAILED_SESSION_RETAIN_TTL_MS,
|
|
2332
2376
|
...(childAgentName !== undefined ? { agentName: childAgentName } : {}),
|
|
@@ -2343,7 +2387,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2343
2387
|
...(plainSpec.alwaysLoadTools !== undefined ? { alwaysLoadTools: [...plainSpec.alwaysLoadTools] } : {}),
|
|
2344
2388
|
...(Array.isArray(plainSpec.restoreGatedTools) ? { restoreGatedTools: [...plainSpec.restoreGatedTools] } : {}),
|
|
2345
2389
|
}),
|
|
2346
|
-
internalsSnapshot: { ...childInternals, ...failedRetainStrip.internalsFlag },
|
|
2390
|
+
internalsSnapshot: { ...withoutHostSeats(childInternals), ...failedRetainStrip.internalsFlag },
|
|
2347
2391
|
release: releaseChild,
|
|
2348
2392
|
});
|
|
2349
2393
|
if (entry) {
|
|
@@ -2445,7 +2489,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2445
2489
|
const forkObjective = `${FORK_DIRECTIVE_FRAME}${prompt}${forkWorktreeNote !== undefined ? `\n\n${forkWorktreeNote}` : ""}${parentSpecSeat?.advisorModel !== undefined ? `\n\n${ADVISOR_FORK_SENTENCE}` : ""}`;
|
|
2446
2490
|
if (wantsBackground) {
|
|
2447
2491
|
const bg = opts.background;
|
|
2448
|
-
const notify = ctx.onTaskNotification
|
|
2492
|
+
const notify = resolveCompletionSink(ctx.onTaskNotification, bg.notify);
|
|
2449
2493
|
const abort = new AbortController();
|
|
2450
2494
|
const sessionScopedBg = ctx.backgroundScope === "session" && ctx.sessionId !== undefined;
|
|
2451
2495
|
const onHostAbort = () => abort.abort();
|
|
@@ -2456,7 +2500,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2456
2500
|
else if (!sessionScopedBg)
|
|
2457
2501
|
ctx.signal.addEventListener("abort", onHostAbort, { once: true });
|
|
2458
2502
|
}
|
|
2459
|
-
const shortDesc = `fork: ${(typeof a.description === "string" && a.description.trim() ? a.description.trim() : prompt
|
|
2503
|
+
const shortDesc = `fork: ${redactThenCut(typeof a.description === "string" && a.description.trim() ? a.description.trim() : prompt, 180)}`;
|
|
2460
2504
|
const bgOwner = sessionScopedBg ? ctx.sessionId : ctx.taskId ?? bg.owner;
|
|
2461
2505
|
const bgScope = treeScope;
|
|
2462
2506
|
const forkEntryGate = await openEntryGate();
|
|
@@ -2557,6 +2601,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2557
2601
|
}
|
|
2558
2602
|
if (forkEntryGate.key !== undefined)
|
|
2559
2603
|
chargeDelegationEntryHandle(bg.registry, forkEntryGate.key, bg.agentStore, taskId);
|
|
2604
|
+
oweTerminalDelivery(notify, { task_id: taskId, task_type: "background_agent" });
|
|
2560
2605
|
childInternals.peerSelfRef?.addAxis("h", taskId);
|
|
2561
2606
|
bg.registry.bindBackgroundAgentSession(taskId, forkedId);
|
|
2562
2607
|
const forkBgHangAt = Date.now();
|
|
@@ -2731,11 +2776,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2731
2776
|
const completionIdFork = bg.registry.getCompletionId(taskId);
|
|
2732
2777
|
const stillbornFork = child.terminal.kind === "failed" && child.terminal.code === "resume.session_not_found";
|
|
2733
2778
|
if (stillbornFork) {
|
|
2734
|
-
|
|
2735
|
-
await (releaseForked ? releaseForked() : opts.runner.sessions.release?.(forkedId));
|
|
2736
|
-
}
|
|
2737
|
-
catch {
|
|
2738
|
-
}
|
|
2779
|
+
await releaseBoundChildSession({ registry: bg.registry, taskId }, forkedId, () => (releaseForked ? releaseForked() : opts.runner.sessions.release?.(forkedId)));
|
|
2739
2780
|
}
|
|
2740
2781
|
const residualFork = residualFields();
|
|
2741
2782
|
const resumableFork = false;
|
|
@@ -2746,6 +2787,9 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2746
2787
|
? `Agent "${shortDesc}" failed: ${failReasonFork}${ccElapsedTag(forkElapsedMs)}`.slice(0, 300) + errorKindClause(errClassFork)
|
|
2747
2788
|
: `${ccCompletionText(shortDesc, settledBg, childFace.status, forkElapsedMs)}`;
|
|
2748
2789
|
const ownsTerminalFacesFork = bg.registry.claimAgentTerminalNotify(taskId);
|
|
2790
|
+
const forkResultField = await completionResultField(forkBgResult, (report) => persistTaskArtifact(ctx.taskArtifacts, taskId, report));
|
|
2791
|
+
if (forkResultField?.ref !== undefined)
|
|
2792
|
+
bg.registry.recordArtifactRef(taskId, forkResultField.ref, 0);
|
|
2749
2793
|
const forkFrame = {
|
|
2750
2794
|
task_id: taskId,
|
|
2751
2795
|
task_type: "background_agent",
|
|
@@ -2758,7 +2802,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2758
2802
|
...(settledBg === "failed" && errCodeFork !== undefined ? { errorCode: errCodeFork } : {}),
|
|
2759
2803
|
...providerFaultField(child),
|
|
2760
2804
|
...(child.sessionId ? { sessionId: child.sessionId } : {}),
|
|
2761
|
-
...(
|
|
2805
|
+
...(forkResultField !== undefined ? { result: forkResultField.text } : {}),
|
|
2762
2806
|
...(settledBg === "killed" && child.result ? { partial: true } : {}),
|
|
2763
2807
|
...residualFork,
|
|
2764
2808
|
resumable: resumableFork,
|
|
@@ -2820,7 +2864,6 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2820
2864
|
taskId,
|
|
2821
2865
|
workingLine: `The forked agent inherits your full current context and works on its prompt in the background.`,
|
|
2822
2866
|
notify: Boolean(notify),
|
|
2823
|
-
oneShot: ctx.oneShot === true,
|
|
2824
2867
|
notes: [
|
|
2825
2868
|
modelNote,
|
|
2826
2869
|
extraToolsNote,
|
|
@@ -2944,7 +2987,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
2944
2987
|
if (ctx.checkpointStoreForChildren !== undefined && ctx.checkpointStoreForChildren !== "disabled" && bg.checkpointStore !== undefined && bg.checkpointStore !== ctx.checkpointStoreForChildren)
|
|
2945
2988
|
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");
|
|
2946
2989
|
const childParkStore = ctx.checkpointStoreForChildren === undefined ? bg.checkpointStore : ctx.checkpointStoreForChildren === "disabled" ? undefined : ctx.checkpointStoreForChildren;
|
|
2947
|
-
const notify = ctx.onTaskNotification
|
|
2990
|
+
const notify = resolveCompletionSink(ctx.onTaskNotification, bg.notify);
|
|
2948
2991
|
const abort = new AbortController();
|
|
2949
2992
|
const reviveRow = reviveClaim?.row;
|
|
2950
2993
|
const parkedResume = reviveClaim?.parkedResume;
|
|
@@ -3087,6 +3130,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3087
3130
|
}
|
|
3088
3131
|
if (capLedgerKey !== undefined)
|
|
3089
3132
|
chargeDelegationEntryHandle(bg.registry, capLedgerKey, bg.agentStore, reviveRow === undefined ? taskId : undefined);
|
|
3133
|
+
oweTerminalDelivery(notify, { task_id: taskId, task_type: "background_agent" });
|
|
3090
3134
|
childInternals.peerSelfRef?.addAxis("h", taskId);
|
|
3091
3135
|
if (agentName !== undefined) {
|
|
3092
3136
|
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.rootSessionId ?? reviveRow.parentSessionId) !== undefined ? { rootSessionId: reviveRow.rootSessionId ?? reviveRow.parentSessionId } : {}) : (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" }));
|
|
@@ -3161,7 +3205,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3161
3205
|
: ctx.subagentRetain;
|
|
3162
3206
|
if (sessionScopedBg && bgRetainLedger)
|
|
3163
3207
|
ensureSessionReapHook(bg.registry);
|
|
3164
|
-
const bgRetain = await tryRetainChild(bgRetainLedger, sessionScopedBg && ctx.subagentRetain ? ctx.subagentRetain.ttlMs : undefined, bgChildSessionId, bgDurableProbe,
|
|
3208
|
+
const bgRetain = await tryRetainChild(bgRetainLedger, sessionScopedBg && ctx.subagentRetain ? ctx.subagentRetain.ttlMs : undefined, bgChildSessionId, bgDurableProbe, { registry: bg.registry, taskId }, {
|
|
3165
3209
|
delegationTaskType: "background_agent",
|
|
3166
3210
|
});
|
|
3167
3211
|
if (bgRetain) {
|
|
@@ -3172,6 +3216,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3172
3216
|
await origRelease();
|
|
3173
3217
|
};
|
|
3174
3218
|
}
|
|
3219
|
+
bg.registry.bindBackgroundAgentSession(taskId, bgChildSessionId);
|
|
3175
3220
|
const forwardDurableApproval = ctx.durableApprovalForChildren !== undefined &&
|
|
3176
3221
|
bg.agentStore !== undefined &&
|
|
3177
3222
|
childParkStore !== undefined &&
|
|
@@ -3538,12 +3583,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3538
3583
|
}) ??
|
|
3539
3584
|
(abort.signal.aborted ? "killed" : ok ? "completed" : "failed");
|
|
3540
3585
|
if (!bgRetain && reviveRow === undefined && !(await bgRowConfirmed())) {
|
|
3541
|
-
|
|
3542
|
-
await opts.runner.sessions.release(child.sessionId);
|
|
3543
|
-
bg.registry.releaseDurableTranscriptAnchor(taskId);
|
|
3544
|
-
}
|
|
3545
|
-
catch {
|
|
3546
|
-
}
|
|
3586
|
+
await releaseBoundChildSession({ registry: bg.registry, taskId }, child.sessionId, () => opts.runner.sessions.release(child.sessionId));
|
|
3547
3587
|
}
|
|
3548
3588
|
const stoppedBy = settled === "killed" ? bg.registry.getStopAttribution(taskId) ?? "system" : undefined;
|
|
3549
3589
|
const completionIdBg = bg.registry.getCompletionId(taskId);
|
|
@@ -3564,6 +3604,9 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3564
3604
|
? `Agent "${shortDesc}" failed: ${failReasonBg}${ccElapsedTag(bgElapsedMs)}${observerNote}`.slice(0, 300) + errorKindClause(errClassBg)
|
|
3565
3605
|
: `${ccCompletionText(shortDesc, settled, childFace.status, bgElapsedMs)}${observerNote}`;
|
|
3566
3606
|
const ownsTerminalFaces = bg.registry.claimAgentTerminalNotify(taskId);
|
|
3607
|
+
const bgResultField = await completionResultField(bgHandbackResult, (report) => persistTaskArtifact(ctx.taskArtifacts, taskId, report));
|
|
3608
|
+
if (bgResultField?.ref !== undefined)
|
|
3609
|
+
bg.registry.recordArtifactRef(taskId, bgResultField.ref, 0);
|
|
3567
3610
|
const completionFrame = {
|
|
3568
3611
|
task_id: taskId,
|
|
3569
3612
|
task_type: "background_agent",
|
|
@@ -3577,7 +3620,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3577
3620
|
...(settled === "failed" && errCodeBg !== undefined ? { errorCode: errCodeBg } : {}),
|
|
3578
3621
|
...providerFaultField(child),
|
|
3579
3622
|
...(child.sessionId ? { sessionId: child.sessionId } : {}),
|
|
3580
|
-
...(
|
|
3623
|
+
...(bgResultField !== undefined ? { result: bgResultField.text } : {}),
|
|
3581
3624
|
...(settled === "killed" && child.result ? { partial: true } : {}),
|
|
3582
3625
|
...residual,
|
|
3583
3626
|
resumable: resumableBg,
|
|
@@ -3631,12 +3674,7 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3631
3674
|
...(errClassBgReject !== undefined ? { retryable: errClassBgReject.retryable, errorKind: errClassBgReject.errorKind } : {}),
|
|
3632
3675
|
}) ?? (killed ? "killed" : "failed");
|
|
3633
3676
|
if (!bgRetain && reviveRow === undefined && !(await bgRowConfirmed())) {
|
|
3634
|
-
|
|
3635
|
-
await opts.runner.sessions.release(bgChildSessionId);
|
|
3636
|
-
bg.registry.releaseDurableTranscriptAnchor(taskId);
|
|
3637
|
-
}
|
|
3638
|
-
catch {
|
|
3639
|
-
}
|
|
3677
|
+
await releaseBoundChildSession({ registry: bg.registry, taskId }, bgChildSessionId, () => opts.runner.sessions.release(bgChildSessionId));
|
|
3640
3678
|
}
|
|
3641
3679
|
const stoppedBy = settled === "killed" ? bg.registry.getStopAttribution(taskId) ?? "system" : undefined;
|
|
3642
3680
|
const completionIdBgReject = bg.registry.getCompletionId(taskId);
|
|
@@ -3696,7 +3734,6 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3696
3734
|
taskId,
|
|
3697
3735
|
workingLine: `The agent is working in the background.`,
|
|
3698
3736
|
notify: Boolean(notify),
|
|
3699
|
-
oneShot: ctx.oneShot === true,
|
|
3700
3737
|
notes: [
|
|
3701
3738
|
modelNote,
|
|
3702
3739
|
extraToolsNote,
|
|
@@ -3743,9 +3780,11 @@ function createSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
|
|
|
3743
3780
|
...(opts.background?.notify ? { notify: opts.background.notify } : {}),
|
|
3744
3781
|
sink: ctx.onSubagentSpawn,
|
|
3745
3782
|
...(opts.background ? { registry: opts.background.registry } : {}),
|
|
3783
|
+
entryGate: syncEntryGate,
|
|
3746
3784
|
...(opts.onObserverError !== undefined ? { onNotifyError: (f) => opts.onObserverError?.(f.error, { site: f.site }) } : {}),
|
|
3747
3785
|
...(ctx.onQuestion !== undefined ? { currentOnQuestion: ctx.onQuestion } : {}),
|
|
3748
3786
|
...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
|
|
3787
|
+
currentMcpHostSeats: ctx.mountedMcp?.().hostSeats,
|
|
3749
3788
|
});
|
|
3750
3789
|
notifier.notify(() => ctx.onSubagentSpawn?.(createSteerHandle(stream, ctx.toolCallId, childAgentName, settled, {
|
|
3751
3790
|
resume,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolSpec } from "../core/types.js";
|
|
2
2
|
import { type ToolLegKind, type ToolSelector, type ToolSelectorLayer } from "../core/tool-face.js";
|
|
3
3
|
import { type ToolNameListReading } from "../core/tool-name-list.js";
|
|
4
4
|
/**
|
|
@@ -62,8 +62,6 @@ export declare function toolListsDigest(allow: readonly unknown[] | undefined, d
|
|
|
62
62
|
* of strings. The one reading the judgment before the run and the spawn-time check of a tool that never went through prepare share.
|
|
63
63
|
*/
|
|
64
64
|
export declare function toolNameListFlaw(where: string, side: ToolNameListSide, value: unknown): string | undefined;
|
|
65
|
-
/** A definition with its two tool-name lists replaced by their one copy — the copy every later reader takes instead of the host's container. */
|
|
66
|
-
export declare function snapshotDefinitionLists(def: AgentDefinition): AgentDefinition;
|
|
67
65
|
/**
|
|
68
66
|
* What ONE tool-name list reaches — the single reading every consumer of an allowed or a denied list takes: `names` are exact
|
|
69
67
|
* spellings (a tool answers to its wire name and every alias it declares); `covering` the spellings that cover a SET
|
|
@@ -5,7 +5,7 @@ import { ruleSpellingOf } from "../core/permission-rule-syntax.js";
|
|
|
5
5
|
import { TOOL_CATALOG_ENTRIES } from "../core/tool-catalog-entries.js";
|
|
6
6
|
import { isCoveringRuleName, ruleNameCovers, ruleNameReachIntoPeer } from "../core/namespaced-rule-name.js";
|
|
7
7
|
import { splitNamespacedName } from "../core/tool-name-aliases.js";
|
|
8
|
-
import { readToolNameList,
|
|
8
|
+
import { readToolNameList, valueTypeLabel } from "../core/tool-name-list.js";
|
|
9
9
|
export function readDeniedEntry(entry) {
|
|
10
10
|
if (typeof entry !== "string")
|
|
11
11
|
return { kind: "not_a_string", type: valueTypeLabel(entry) };
|
|
@@ -44,14 +44,6 @@ export function toolNameListFlaw(where, side, value) {
|
|
|
44
44
|
}
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
47
|
-
export function snapshotDefinitionLists(def) {
|
|
48
|
-
const copy = { ...def };
|
|
49
|
-
if (copy.allowTools !== undefined)
|
|
50
|
-
copy.allowTools = snapshotToolNameList(copy.allowTools);
|
|
51
|
-
if (copy.denyTools !== undefined)
|
|
52
|
-
copy.denyTools = snapshotToolNameList(copy.denyTools);
|
|
53
|
-
return copy;
|
|
54
|
-
}
|
|
55
47
|
export function toolNameOfEntry(entry, side) {
|
|
56
48
|
const read = readDeniedEntry(entry);
|
|
57
49
|
return read.kind === "name" && (side === "denied" || !read.content) ? read.name : undefined;
|
|
@@ -117,11 +109,11 @@ export function protocolToolNames(legs) {
|
|
|
117
109
|
return [...new Set(PROTOCOL_ROWS.filter((r) => r.legs.some((l) => legs.includes(l))).map((r) => r.name))];
|
|
118
110
|
}
|
|
119
111
|
function reachTouchesPeer(reach, peer) {
|
|
120
|
-
const into = (spelling) => ruleNameReachIntoPeer(spelling, peer.ns, peer.peer) !== "none";
|
|
121
|
-
return [...reach.names].some(into) || reach.covering.some(into);
|
|
112
|
+
const into = (spelling, covering) => ruleNameReachIntoPeer(spelling, peer.ns, peer.peer, covering) !== "none";
|
|
113
|
+
return [...reach.names].some((n) => into(n, false)) || reach.covering.some((c) => into(c, true));
|
|
122
114
|
}
|
|
123
115
|
function reachCoversPeer(reach, peer) {
|
|
124
|
-
return reach.covering.some((pattern) => ruleNameReachIntoPeer(pattern, peer.ns, peer.peer) === "all");
|
|
116
|
+
return reach.covering.some((pattern) => ruleNameReachIntoPeer(pattern, peer.ns, peer.peer, true) === "all");
|
|
125
117
|
}
|
|
126
118
|
export function isToolSelectorLayer(layer) {
|
|
127
119
|
return typeof layer === "object" && layer !== null && !Array.isArray(layer);
|
package/dist/bench/metrics.d.ts
CHANGED
|
@@ -156,7 +156,6 @@ export interface CoreStatsSubset {
|
|
|
156
156
|
costBreakdown?: {
|
|
157
157
|
llmRootMicroUsd: number;
|
|
158
158
|
nestedSubagentMicroUsd: number;
|
|
159
|
-
memoryConsolidationMicroUsd: number;
|
|
160
159
|
compactionMicroUsd: number;
|
|
161
160
|
sideCallMicroUsd?: number;
|
|
162
161
|
};
|
|
@@ -225,10 +224,9 @@ export interface CostComponents {
|
|
|
225
224
|
c4InfraMicroUsd: number;
|
|
226
225
|
}
|
|
227
226
|
/**
|
|
228
|
-
* §2.3 — derive C1 from `stats.costBreakdown` (design/80 D-E-core)
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* same unit); it never reaches across to C2.
|
|
227
|
+
* §2.3 — derive C1 from `stats.costBreakdown` (design/80 D-E-core): the LLM-token-derived total, the sum of the three
|
|
228
|
+
* breakdown lines. Falls back to `costMicroUsd` (+ nested) when `costBreakdown` is absent (older runs), then 0. The ONLY
|
|
229
|
+
* composition done is WITHIN C1 (all µUSD, same unit); it never reaches across to C2.
|
|
232
230
|
*/
|
|
233
231
|
export declare function deriveC1(stats: CoreStatsSubset): number;
|
|
234
232
|
/** §2.4 — derive C2 (count, seconds) from `stats.humanReview` (design/91). Absent ⇒ no gate ⇒ (0,0). */
|
package/dist/bench/metrics.js
CHANGED
package/dist/brain/degrading.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createAssistantMessageEventStream, } from "../internal/llm.js";
|
|
|
2
2
|
import { abortLikeName, ZERO_USAGE, extractErrorCode } from "./errors.js";
|
|
3
3
|
import { CIRCUIT_OPEN_MARKER } from "./circuit-breaker.js";
|
|
4
4
|
import { thrownText } from "../core/thrown-value.js";
|
|
5
|
+
import { receiveModel } from "../core/model-receipt.js";
|
|
5
6
|
export const DEGRADED_DIAGNOSTIC_TYPE = "degraded";
|
|
6
7
|
const VALID_REASONS = new Set([
|
|
7
8
|
"breaker_open",
|
|
@@ -116,8 +117,9 @@ export function passthroughStream(brain, model, context, options) {
|
|
|
116
117
|
export function createDegradingBrain(opts) {
|
|
117
118
|
const triggers = new Set(opts.downgradeOn ?? ["rate_limit", "breaker_open", "server_error", "last_resort"]);
|
|
118
119
|
const rawHops = opts.fallbacks ?? [];
|
|
120
|
+
const received = rawHops.map((h, i) => ({ brain: h.brain, model: receiveModel(h.model, `fallbacks[${i}].model`) }));
|
|
119
121
|
const seenIds = new Set();
|
|
120
|
-
const hops =
|
|
122
|
+
const hops = received.filter((h) => (seenIds.has(h.model.id) ? false : (seenIds.add(h.model.id), true))).slice(0, MAX_CHAIN);
|
|
121
123
|
if (hops.length === 0) {
|
|
122
124
|
throw new Error("createDegradingBrain: `fallbacks` needs at least one {brain, model} hop (RB-482 #3: the legacy fallback+fallbackModel pair is retired — a chain-of-one is `fallbacks: [{brain, model}]`)");
|
|
123
125
|
}
|