@tangle-network/agent-runtime 0.306.1 → 0.307.2
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/dist/{activation-wZ-8vOjV.d.ts → activation-Bdugb7li.d.ts} +3 -3
- package/dist/{activation-C5wesfzd.js → activation-DNZrAzZM.js} +3 -3
- package/dist/{activation-C5wesfzd.js.map → activation-DNZrAzZM.js.map} +1 -1
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{bundle-C8EO05u3.js → bundle-E6mbRX2P.js} +2 -2
- package/dist/{bundle-C8EO05u3.js.map → bundle-E6mbRX2P.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-driver-yj9HPXef.js → coordination-driver-DCQUXZ54.js} +3 -3
- package/dist/{coordination-driver-yj9HPXef.js.map → coordination-driver-DCQUXZ54.js.map} +1 -1
- package/dist/{delegate-KtrL9HWq.js → delegate-BcMmgX_Y.js} +2 -2
- package/dist/{delegate-KtrL9HWq.js.map → delegate-BcMmgX_Y.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +57 -6
- package/dist/durable.js.map +1 -1
- package/dist/{graph-DcdyHbgf.js → graph-D2yO7Epi.js} +5 -4
- package/dist/graph-D2yO7Epi.js.map +1 -0
- package/dist/{improvement-cycle-DsN-TVXR.js → improvement-cycle-C6PDngmf.js} +10 -6
- package/dist/{improvement-cycle-DsN-TVXR.js.map → improvement-cycle-C6PDngmf.js.map} +1 -1
- package/dist/{index-DflDZq_I.d.ts → index-1T1fjIUs.d.ts} +72 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +7 -7
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-DZfRUVWy.d.ts → loop-runner-bin-Be2jWumB.d.ts} +3 -3
- package/dist/{loop-runner-bin-rVrSX5l1.js → loop-runner-bin-Bwxtx1go.js} +3 -3
- package/dist/{loop-runner-bin-rVrSX5l1.js.map → loop-runner-bin-Bwxtx1go.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/index.js +5 -5
- package/dist/{openai-tools-YO30D2s3.d.ts → openai-tools-C-lvIN3-.d.ts} +2 -2
- package/dist/{prepare--nWcazPr.js → prepare-CulUz6Wm.js} +3 -3
- package/dist/{prepare--nWcazPr.js.map → prepare-CulUz6Wm.js.map} +1 -1
- package/dist/{profile-h04LDjV6.js → profile-DY9lT3gH.js} +2 -2
- package/dist/{profile-h04LDjV6.js.map → profile-DY9lT3gH.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{protected-model-port-wwalbyXM.js → protected-model-port-BT2iYAsU.js} +4 -4
- package/dist/{protected-model-port-wwalbyXM.js.map → protected-model-port-BT2iYAsU.js.map} +1 -1
- package/dist/{provision-supervisor-WxFEFQeJ.js → provision-supervisor-De_3kjM3.js} +4 -4
- package/dist/{provision-supervisor-WxFEFQeJ.js.map → provision-supervisor-De_3kjM3.js.map} +1 -1
- package/dist/{runtime-B9eBIyws.js → runtime-B3dR7tdY.js} +9 -9
- package/dist/{runtime-B9eBIyws.js.map → runtime-B3dR7tdY.js.map} +1 -1
- package/dist/{search-executor-2tWr38Qw.js → search-executor-H1IRkoRg.js} +3 -3
- package/dist/{search-executor-2tWr38Qw.js.map → search-executor-H1IRkoRg.js.map} +1 -1
- package/dist/{server-CpKcrOPj.js → server-DATtZ0Q9.js} +4 -4
- package/dist/{server-CpKcrOPj.js.map → server-DATtZ0Q9.js.map} +1 -1
- package/dist/{stream-agent-turn-B1giFgOg.d.ts → stream-agent-turn-Ch1g6gYE.d.ts} +2 -2
- package/dist/{substrate-L_sC7jCD.d.ts → substrate-Buuxd_OX.d.ts} +2 -2
- package/dist/{supervise-DllOHM4M.js → supervise-D1qqMFAu.js} +164 -191
- package/dist/supervise-D1qqMFAu.js.map +1 -0
- package/dist/{supervisor-gCfG6K1-.js → supervisor-Dz4XXtK1.js} +1734 -1114
- package/dist/supervisor-Dz4XXtK1.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-DeuEkBhI.d.ts → types-CBcc0_5y.d.ts} +48 -1
- package/dist/{workspace-streams-ILw0eWZ0.js → workspace-streams-DaQceg2p.js} +7 -2
- package/dist/{workspace-streams-ILw0eWZ0.js.map → workspace-streams-DaQceg2p.js.map} +1 -1
- package/package.json +3 -3
- package/skills/profile-authoring/SKILL.md +6 -0
- package/dist/graph-DcdyHbgf.js.map +0 -1
- package/dist/supervise-DllOHM4M.js.map +0 -1
- package/dist/supervisor-gCfG6K1-.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as scopeOwnerExecutorNodeContext, B as noteScopeRetainedOwnerCoordination, Bi as runtimeOwnedDriveHarnessProviderEvidence, Bt as WORKER_TRACE_PROPAGATION, C as deriveNodeExecutionIdentity, Cn as routerBrain, Cr as linkAbort, D as recordScopeOwnerMaterialization, Di as unsupportedProfileDimensions, Dr as persistHarnessTranscript, E as recordScopeOwnerDriverAttempt, F as seatExecutionProfile, Fn as registerRetainedExecutorPreparation, G as scopeRetainedOwnerJournalRoot, Gi as runtimeOwnedScopeOwnerRuntime, Gn as isNoEntError, Gr as generateSpanId, H as prepareScopeRetainedOwnerTask, Hi as runtimeOwnedExecutorMaterialization, I as beginScopeRetainedOwnerDrive, In as retainedExecutorSeamKey, J as scopeRetainedOwnerRestorePoint, K as scopeRetainedOwnerPriorSpend, Kn as prepareJsonlAppend, L as bindScopeRetainedOwnerEnvironmentId, M as SeatChain, Mt as createExecutor, N as SeatChainExhaustedError, O as recordScopeOwnerPause, Or as readHarnessTranscript, Ot as bindReusableExecutorExecutionId, P as authoredSeatStages, Pi as inheritRuntimeOwnedExecutorAttestation, Pt as snapshotExecutorConfig, Qn as parseWorkerToolTraceArtifact, R as bindScopeRetainedOwnerProvider, Ri as providerAttemptEvidence, Rt as createRouterTranscript, St as createContinuationKeeper, T as meterRuntimeOwnedProviderAttempt, Ti as renderUnsupported, U as reconcileScopeRetainedOwnerEnvironment, Ui as runtimeOwnedExecutorProviderEvidence, Ur as createOtelExporter, V as prepareScopeRetainedOwnerSeatSwitch, Vi as runtimeOwnedExecutorExecutionBinding, W as scopeRetainedOwnerContext, Wi as runtimeOwnedPendingExecutorMaterialization, X as scopeRetainedOwnerTurnEnded, Y as scopeRetainedOwnerResult, Yr as toOtelAttributes, Yt as createInbox, Zi as detachedSnapshot, _ as isDriverSpec, _i as defineProfileMaterializationContract, _t as CheckUnavailableError, ar as meterUsageEvent, b as assertRecursiveReservationPolicy, bi as promptControlProfileMaterialization, bt as bestComposite, c as runTree, cr as spendFromUsageTotals, dr as errMessage, er as executorFailure, f as runDriverWithRetry, g as driverExecutorFactory, gi as controlProfileMaterialization, h as driverChild, hi as assertProfileMaterialization, ht as CONTINUATIONS_DIR, i as bestDelivered, in as isLiveNodeStatus, ji as attestRuntimeOwnedScopeOwner, jr as contentAddress, k as restoreScopeOwnerAcceptedExecution, ki as worktreeCliProfileMaterialization, kn as resolveAgentEnvironmentProvider, kt as captureReusableExecutorConfig, lr as bridgeRuntimeAttachmentsKey, n as createRootHandle, nt as coordinationProfileToolPrefix, on as bridgeAdmissionRefusal, or as newUsageTotals, p as summarizeDriverAttempts, pt as gateOnDeliverable, q as scopeRetainedOwnerResourceReader, qn as readCommittedJsonLines, qt as createActivityLog, r as createSupervisor, rr as assertValidBudget, rt as providerVisibleProfile, s as runFinalizer, sn as bridgeModelRouteRefusal, tt as coordinationMcpAlias, u as HarnessTurnFailedError, ur as bridgeStopSignalKey, vi as fullProfileMaterialization, vt as admitContinuationPolicy, w as meterRuntimeOwnedAccounting, wr as runAbortable, x as beginScopeOwnerAttempt, xi as promptModelProfileMaterialization, xr as RunCancellationReason, xt as checkVerdictOf, yi as profileMaterializationAxes$1, z as consumeScopeRetainedOwnerResult, zi as recordRuntimeOwnedDriveHarnessProviderEvidence } from "./supervisor-Dz4XXtK1.js";
|
|
2
2
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import { G as errorMessage, St as teardownSurfaces, Y as isAsyncIterable$1, at as unmeteredSpend, dt as resourceTelemetry, ft as withBudgetResources, ht as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, lt as addResourceSpend, ot as withTimeout, st as zeroSpend, tt as sleep, xt as teardownExecutor, z as addSpend } from "./workspace-streams-
|
|
3
|
+
import { G as errorMessage, St as teardownSurfaces, Y as isAsyncIterable$1, at as unmeteredSpend, dt as resourceTelemetry, ft as withBudgetResources, ht as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, lt as addResourceSpend, ot as withTimeout, st as zeroSpend, tt as sleep, xt as teardownExecutor, z as addSpend } from "./workspace-streams-DaQceg2p.js";
|
|
4
4
|
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-DydyWTQg.js";
|
|
5
5
|
import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
|
|
6
6
|
import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
|
|
7
|
-
import { C as createInMemoryRunContext, D as applyRunCancellation, M as coordinationVerbNames, O as watchRunCancellation, P as createCoordinationToolsForManager, S as createFileRunContext, c as resolveWakePolicy, f as createProgressTracker, h as progressStop, m as plateau, n as createSteerAcknowledger, o as composeWakeInput, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as withRunContext } from "./coordination-driver-
|
|
7
|
+
import { C as createInMemoryRunContext, D as applyRunCancellation, M as coordinationVerbNames, O as watchRunCancellation, P as createCoordinationToolsForManager, S as createFileRunContext, c as resolveWakePolicy, f as createProgressTracker, h as progressStop, m as plateau, n as createSteerAcknowledger, o as composeWakeInput, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as withRunContext } from "./coordination-driver-DCQUXZ54.js";
|
|
8
8
|
import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
|
|
9
9
|
import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-DSCWdbX2.js";
|
|
10
10
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
@@ -24,153 +24,6 @@ import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
|
|
|
24
24
|
* that holds its response for its whole fence is never cut off at the 60 s harness default. */
|
|
25
25
|
const COORDINATION_CLIENT_TOOL_TIMEOUT_MS = 3e5;
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region src/runtime/supervise/completion-gate.ts
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* The completion-oracle: **settled ⟺ DELIVERED.**
|
|
31
|
-
*
|
|
32
|
-
* Foreman's one hard lesson (0/18 self-improvement deliverables) — "done" must mean a check
|
|
33
|
-
* PASSED, not the agent's say-so. `gateOnDeliverable` wraps an `Executor` so its settlement
|
|
34
|
-
* is `valid` ONLY when the deliverable check passes. The child still RUNS and settles (its
|
|
35
|
-
* spend is conserved into the pool either way), but a child that ran WITHOUT delivering
|
|
36
|
-
* settles `valid:false` — so a keep-best driver never counts it as done, and a gate never
|
|
37
|
-
* inflates with self-judged wins.
|
|
38
|
-
*
|
|
39
|
-
* Dual-purpose by construction:
|
|
40
|
-
* - product: the agent fleet only advances on real, checked deliverables.
|
|
41
|
-
* - proof: the gate's `valid` is the honest settle — equal-k comparisons can't be gamed by an
|
|
42
|
-
* arm that "ran" without producing the artifact.
|
|
43
|
-
*
|
|
44
|
-
* The check is a DEPLOYABLE oracle — a test command, a state verifier, the commit0 judge —
|
|
45
|
-
* read off the child's output, never the model judging itself. A throwing check is
|
|
46
|
-
* fail-closed (not delivered), never a crash.
|
|
47
|
-
*
|
|
48
|
-
* @experimental
|
|
49
|
-
*/
|
|
50
|
-
/**
|
|
51
|
-
* Wrap an `Executor` so its settlement `valid` reflects the deliverable check, not the
|
|
52
|
-
* inner verdict. Handles both `execute` shapes (one-shot `Promise<ExecutorResult>` and
|
|
53
|
-
* streaming `AsyncIterable<UsageEvent>` + `resultArtifact()`); the check runs once the inner
|
|
54
|
-
* executor has produced its output. The inner `score` is preserved; only `valid` is gated.
|
|
55
|
-
*/
|
|
56
|
-
function gateOnDeliverable(inner, deliverable) {
|
|
57
|
-
let gated;
|
|
58
|
-
const check = async (out, baseScore) => {
|
|
59
|
-
let delivered;
|
|
60
|
-
try {
|
|
61
|
-
delivered = checkVerdictOf(await deliverable.check(out)).pass;
|
|
62
|
-
} catch {
|
|
63
|
-
delivered = false;
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
valid: delivered,
|
|
67
|
-
score: baseScore ?? (delivered ? 1 : 0)
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* Ask the delivery question once, from whatever the inner executor managed to produce.
|
|
72
|
-
*
|
|
73
|
-
* Fail-closed on the artifact being unavailable: an executor that never produced one delivered
|
|
74
|
-
* nothing, and leaving `gated` unset keeps the existing invalid-by-default reading.
|
|
75
|
-
*/
|
|
76
|
-
const settleVerdict = async () => {
|
|
77
|
-
let art;
|
|
78
|
-
try {
|
|
79
|
-
art = inner.resultArtifact();
|
|
80
|
-
} catch {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
gated = await check(art.out, art.verdict?.score);
|
|
84
|
-
};
|
|
85
|
-
return inheritRuntimeOwnedExecutorAttestation(inner, {
|
|
86
|
-
runtime: inner.runtime,
|
|
87
|
-
...inner.budgetExempt !== void 0 ? { budgetExempt: inner.budgetExempt } : {},
|
|
88
|
-
...inner.deliver ? { deliver: (m) => inner.deliver?.(m) } : {},
|
|
89
|
-
...inner.progress ? { progress: () => inner.progress?.() } : {},
|
|
90
|
-
...inner.traceSource ? { traceSource: () => inner.traceSource?.() } : {},
|
|
91
|
-
...inner.metered ? { metered: () => inner.metered?.() } : {},
|
|
92
|
-
...inner.harnessTranscript ? { harnessTranscript: () => inner.harnessTranscript?.() } : {},
|
|
93
|
-
...inner.harnessTranscriptSettled ? { harnessTranscriptSettled: () => inner.harnessTranscriptSettled?.() ?? Promise.resolve() } : {},
|
|
94
|
-
execute(task, signal) {
|
|
95
|
-
const r = inner.execute(task, signal);
|
|
96
|
-
if (isAsyncIterable$1(r)) return (async function* () {
|
|
97
|
-
try {
|
|
98
|
-
for await (const ev of r) yield ev;
|
|
99
|
-
} finally {
|
|
100
|
-
await settleVerdict();
|
|
101
|
-
}
|
|
102
|
-
})();
|
|
103
|
-
return (async () => {
|
|
104
|
-
let res;
|
|
105
|
-
try {
|
|
106
|
-
res = await r;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
await settleVerdict();
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
gated = await check(res.out, res.verdict?.score);
|
|
112
|
-
return {
|
|
113
|
-
...res,
|
|
114
|
-
verdict: gated
|
|
115
|
-
};
|
|
116
|
-
})();
|
|
117
|
-
},
|
|
118
|
-
teardown: (grace) => inner.teardown(grace),
|
|
119
|
-
...teardownSurfaces(inner),
|
|
120
|
-
resultArtifact() {
|
|
121
|
-
const art = inner.resultArtifact();
|
|
122
|
-
return {
|
|
123
|
-
...art,
|
|
124
|
-
verdict: gated ?? art.verdict
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Transform a Runtime executor's terminal artifact without losing its private
|
|
131
|
-
* profile-materialization attestation or altering its measured spend. This is
|
|
132
|
-
* the composition point for deterministic post-processing and grading; callers
|
|
133
|
-
* must not rebuild an Executor around a model transport merely to change `out`.
|
|
134
|
-
*/
|
|
135
|
-
function mapExecutorResult(inner, map) {
|
|
136
|
-
let mapped;
|
|
137
|
-
const settle = async (result, task) => {
|
|
138
|
-
const transformed = await map(result, task);
|
|
139
|
-
mapped = {
|
|
140
|
-
outRef: transformed.outRef,
|
|
141
|
-
out: transformed.out,
|
|
142
|
-
...transformed.verdict ? { verdict: transformed.verdict } : {},
|
|
143
|
-
spent: result.spent
|
|
144
|
-
};
|
|
145
|
-
return mapped;
|
|
146
|
-
};
|
|
147
|
-
return inheritRuntimeOwnedExecutorAttestation(inner, {
|
|
148
|
-
runtime: inner.runtime,
|
|
149
|
-
...inner.budgetExempt !== void 0 ? { budgetExempt: inner.budgetExempt } : {},
|
|
150
|
-
...inner.deliver ? { deliver: (message) => inner.deliver?.(message) } : {},
|
|
151
|
-
...inner.progress ? { progress: () => inner.progress?.() } : {},
|
|
152
|
-
...inner.traceSource ? { traceSource: () => inner.traceSource?.() } : {},
|
|
153
|
-
...inner.accounting ? { accounting: () => inner.accounting?.() } : {},
|
|
154
|
-
...inner.metered ? { metered: () => inner.metered?.() } : {},
|
|
155
|
-
...inner.harnessTranscript ? { harnessTranscript: () => inner.harnessTranscript?.() } : {},
|
|
156
|
-
...inner.harnessTranscriptSettled ? { harnessTranscriptSettled: () => inner.harnessTranscriptSettled?.() ?? Promise.resolve() } : {},
|
|
157
|
-
execute(task, signal) {
|
|
158
|
-
const execution = inner.execute(task, signal);
|
|
159
|
-
if (isAsyncIterable$1(execution)) return (async function* () {
|
|
160
|
-
for await (const event of execution) yield event;
|
|
161
|
-
await settle(inner.resultArtifact(), task);
|
|
162
|
-
})();
|
|
163
|
-
return (async () => settle(await execution, task))();
|
|
164
|
-
},
|
|
165
|
-
teardown: (grace) => inner.teardown(grace),
|
|
166
|
-
...teardownSurfaces(inner),
|
|
167
|
-
resultArtifact() {
|
|
168
|
-
if (!mapped) throw new Error("mapExecutorResult: resultArtifact() read before execute()");
|
|
169
|
-
return mapped;
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
//#endregion
|
|
174
27
|
//#region src/runtime/supervise/coordination-http.ts
|
|
175
28
|
function coordinationHttpLimits(options) {
|
|
176
29
|
const positive = (name, value, fallback) => {
|
|
@@ -1779,10 +1632,6 @@ function observeWorkerControls(options) {
|
|
|
1779
1632
|
* Both arms spawn children through the SAME `makeWorkerAgent` seam and apply the SAME independent
|
|
1780
1633
|
* deliverable check to direct submissions. Raw driver prose is never quality-accepted.
|
|
1781
1634
|
*/
|
|
1782
|
-
/** Runtime-owned coordination is mounted under this MCP alias. */
|
|
1783
|
-
const coordinationMcpAlias = "agent-runtime-coordination";
|
|
1784
|
-
/** A profile declares Runtime-owned tools with this provider-neutral prefix. */
|
|
1785
|
-
const coordinationProfileToolPrefix = `${coordinationMcpAlias.replaceAll("-", "_")}_`;
|
|
1786
1635
|
const coordinationVerbNameSet$1 = new Set(coordinationVerbNames);
|
|
1787
1636
|
/** Bare Runtime tool names explicitly enabled by one exact profile. */
|
|
1788
1637
|
function declaredRuntimeToolNames(profile) {
|
|
@@ -1803,25 +1652,6 @@ function assertNoReservedCoordinationMcpAlias(profile, context) {
|
|
|
1803
1652
|
throw new ValidationError(`${context}: profile MCP alias ${JSON.stringify(coordinationMcpAlias)} is reserved for Runtime coordination`);
|
|
1804
1653
|
}
|
|
1805
1654
|
/**
|
|
1806
|
-
* Project one canonical profile to the profile a provider may receive.
|
|
1807
|
-
*
|
|
1808
|
-
* The reserved prefix is Runtime-owned in its entirety. A `true` declaration must resolve to a
|
|
1809
|
-
* mounted Runtime or product descriptor before execution; a `false` declaration grants nothing.
|
|
1810
|
-
* Neither is a provider-native tool. Stripping the whole namespace keeps a false or refused grant
|
|
1811
|
-
* from becoming an invented harness capability during strict materialization.
|
|
1812
|
-
*/
|
|
1813
|
-
function providerVisibleProfile(profile) {
|
|
1814
|
-
if (profile.tools === void 0) return profile;
|
|
1815
|
-
const providerTools = Object.fromEntries(Object.entries(profile.tools).filter(([name]) => !name.startsWith(coordinationProfileToolPrefix)));
|
|
1816
|
-
if (Object.keys(providerTools).length === Object.keys(profile.tools).length) return profile;
|
|
1817
|
-
if (Object.keys(providerTools).length > 0) return {
|
|
1818
|
-
...profile,
|
|
1819
|
-
tools: providerTools
|
|
1820
|
-
};
|
|
1821
|
-
const { tools: _runtimeTools, ...withoutTools } = profile;
|
|
1822
|
-
return withoutTools;
|
|
1823
|
-
}
|
|
1824
|
-
/**
|
|
1825
1655
|
* The instruction lines a canonical `resources.instructions` contributes. A plain string and an
|
|
1826
1656
|
* `inline` resource are their own text; a `github` reference names bytes that live elsewhere and
|
|
1827
1657
|
* cannot be fetched while building a supervisor synchronously — that fails loud rather than
|
|
@@ -2299,6 +2129,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
2299
2129
|
continuations: keeper?.entries() ?? []
|
|
2300
2130
|
});
|
|
2301
2131
|
};
|
|
2132
|
+
let driverFailed = true;
|
|
2302
2133
|
try {
|
|
2303
2134
|
await runDriverWithRetry({
|
|
2304
2135
|
drive: async (attempt, reentry) => {
|
|
@@ -2325,6 +2156,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
2325
2156
|
...profilePrompt !== void 0 ? { systemPrompt: profilePrompt } : {},
|
|
2326
2157
|
task: compose === void 0 ? task : compose(UNPROVEN_CONTINUITY),
|
|
2327
2158
|
...compose === void 0 ? {} : { reentry: {
|
|
2159
|
+
reason: reentry,
|
|
2328
2160
|
compose,
|
|
2329
2161
|
onContinuity: (continuity) => {
|
|
2330
2162
|
if (continuity.environment === "replaced") environmentReplacements += 1;
|
|
@@ -2405,7 +2237,9 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
2405
2237
|
await deps.onDriverAttempt?.(record);
|
|
2406
2238
|
}
|
|
2407
2239
|
});
|
|
2240
|
+
driverFailed = false;
|
|
2408
2241
|
} finally {
|
|
2242
|
+
await driveHarness.closeSeatSegment?.(scope.signal.aborted ? "cancelled" : driverFailed ? "failed" : "completed");
|
|
2409
2243
|
settleLoop();
|
|
2410
2244
|
}
|
|
2411
2245
|
if (!contractDeclared) await mcp.drainResolved();
|
|
@@ -3205,12 +3039,12 @@ const CLAUDE_CODE_ONE_HOUR_CACHE = "ENABLE_PROMPT_CACHING_1H";
|
|
|
3205
3039
|
/** Run a harness-brained manager through the same executor factory as its children. The manager's
|
|
3206
3040
|
* full profile is preserved, the live coordination server is added under one reserved alias, and
|
|
3207
3041
|
* every streamed turn is charged to the manager's scope before it may continue. */
|
|
3208
|
-
function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns, rootStream) {
|
|
3042
|
+
function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns, rootStream, seatSelection) {
|
|
3209
3043
|
if (maxTurns !== void 0 && maxTurns < 0) throw new ValidationError("driveHarnessFromBackend: maxTurns must be >= 0 (0 lifts the turn cap; bounds become the conserved pool + deadline + abort)");
|
|
3210
3044
|
const turnCap = maxTurns ?? 0;
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3045
|
+
let boundBackend = bindReusableExecutorExecutionId(managerExecutorConfig(captureReusableExecutorConfig(backend, "driveHarnessFromBackend")), executionId);
|
|
3046
|
+
let baseFactory = createExecutor(boundBackend);
|
|
3047
|
+
let ownerRuntime = boundBackend.backend === "provider" ? boundBackend.runtime ?? resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry).name : "cli";
|
|
3214
3048
|
let activeExecutor;
|
|
3215
3049
|
const driveActivity = createActivityLog();
|
|
3216
3050
|
let driveTurns = 0;
|
|
@@ -3238,8 +3072,79 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
3238
3072
|
};
|
|
3239
3073
|
let managerTranscript;
|
|
3240
3074
|
let managerArtifact;
|
|
3075
|
+
const committedTranscriptDigest = (artifact) => {
|
|
3076
|
+
if (artifact === void 0) return "Prior committed transcript: no bounded turn content was captured.";
|
|
3077
|
+
const out = artifact.out;
|
|
3078
|
+
if (out === null || typeof out !== "object") return `Prior committed transcript ref: ${artifact.outRef}; no structured turn content was captured.`;
|
|
3079
|
+
const record = out;
|
|
3080
|
+
const events = Array.isArray(record.events) ? record.events : [];
|
|
3081
|
+
const kinds = events.slice(-16).flatMap((event) => {
|
|
3082
|
+
if (event === null || typeof event !== "object") return [];
|
|
3083
|
+
const kind = event.type;
|
|
3084
|
+
return typeof kind === "string" ? [kind.slice(0, 80)] : [];
|
|
3085
|
+
});
|
|
3086
|
+
const content = typeof record.content === "string" ? record.content.slice(-4e3) : "";
|
|
3087
|
+
return [
|
|
3088
|
+
`Prior committed transcript ref: ${artifact.outRef}; ${events.length} events captured.`,
|
|
3089
|
+
...kinds.length > 0 ? [`Recent event kinds: ${kinds.join(", ")}.`] : [],
|
|
3090
|
+
...content ? [`Last captured answer excerpt: ${content}`] : []
|
|
3091
|
+
].join("\n");
|
|
3092
|
+
};
|
|
3093
|
+
let seatChain;
|
|
3094
|
+
let activeSeat;
|
|
3095
|
+
let switchedProviderCheckpointAt;
|
|
3241
3096
|
const drive = async ({ profile, authoredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, stopSignal, coordinationTools, reentry }) => {
|
|
3097
|
+
const priorCommittedArtifact = managerArtifact;
|
|
3242
3098
|
managerArtifact = void 0;
|
|
3099
|
+
switchedProviderCheckpointAt = void 0;
|
|
3100
|
+
if (authoredSeatStages(authoredProfile) !== void 0) {
|
|
3101
|
+
if (!seatSelection) throw new ValidationError("AgentProfile.seats requires SuperviseOptions.selectSeat");
|
|
3102
|
+
if (activeSeat === void 0) {
|
|
3103
|
+
const accepted = await scopeRetainedOwnerResult(scope);
|
|
3104
|
+
const reported = accepted === void 0 ? void 0 : executorFailure(accepted);
|
|
3105
|
+
if (reported !== void 0) {
|
|
3106
|
+
await restoreScopeOwnerAcceptedExecution(scope);
|
|
3107
|
+
consumeScopeRetainedOwnerResult(scope);
|
|
3108
|
+
managerArtifact = accepted;
|
|
3109
|
+
throw new HarnessTurnFailedError(ownerRuntime, reported);
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
const seatJournalRoot = scopeRetainedOwnerJournalRoot(scope) ?? seatSelection.rootId;
|
|
3113
|
+
seatChain ??= new SeatChain(authoredProfile, scope.view.root, seatJournalRoot, seatSelection.journal, seatSelection.select, now, (segment, phase) => seatSelection.onSegment(scope.view.root, segment, phase), async (selection, previous) => {
|
|
3114
|
+
if (previous && previous.seat !== selection.seat) {
|
|
3115
|
+
const sameEnvironment = previous.provider === selection.stage.provider && previous.harness === selection.stage.harness;
|
|
3116
|
+
const checkpoint = await prepareScopeRetainedOwnerSeatSwitch(scope, sameEnvironment ? "same-environment" : "replace-environment");
|
|
3117
|
+
if (!sameEnvironment) switchedProviderCheckpointAt = checkpoint.checkpointAt;
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
const usageLimit = reentry?.reason.reason === "upstream-unavailable" && reentry.reason.signal === "subscription-usage-limit";
|
|
3121
|
+
if (activeSeat === void 0 || usageLimit) {
|
|
3122
|
+
let afterRecheck = false;
|
|
3123
|
+
for (;;) try {
|
|
3124
|
+
activeSeat = await seatChain.next(usageLimit && !afterRecheck, afterRecheck);
|
|
3125
|
+
if (afterRecheck) await seatSelection.onPause(scope.view.root, "", "resumed");
|
|
3126
|
+
break;
|
|
3127
|
+
} catch (error) {
|
|
3128
|
+
if (!(error instanceof SeatChainExhaustedError)) throw error;
|
|
3129
|
+
await seatSelection.journal.appendEvent(seatJournalRoot, {
|
|
3130
|
+
kind: "seat-paused",
|
|
3131
|
+
id: scope.view.root,
|
|
3132
|
+
resumeAt: error.resumeAt,
|
|
3133
|
+
seq: Date.parse(error.resumeAt),
|
|
3134
|
+
at: new Date(now()).toISOString()
|
|
3135
|
+
});
|
|
3136
|
+
await seatSelection.onPause(scope.view.root, error.resumeAt, "paused");
|
|
3137
|
+
await sleep(Math.max(1e3, Date.parse(error.resumeAt) - now()), scope.signal, false);
|
|
3138
|
+
afterRecheck = true;
|
|
3139
|
+
}
|
|
3140
|
+
boundBackend = bindReusableExecutorExecutionId(managerExecutorConfig(captureReusableExecutorConfig({
|
|
3141
|
+
...activeSeat.backend,
|
|
3142
|
+
unavailablePause: false
|
|
3143
|
+
}, "selectSeat")), `${executionId}:segment:${activeSeat.segmentIndex}`);
|
|
3144
|
+
baseFactory = createExecutor(boundBackend);
|
|
3145
|
+
ownerRuntime = boundBackend.backend === "provider" ? boundBackend.runtime ?? resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry).name : "cli";
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3243
3148
|
const retainedOwner = boundBackend.backend === "provider" ? scopeRetainedOwnerContext(scope) : void 0;
|
|
3244
3149
|
if (retainedOwner && boundBackend.backend === "provider") {
|
|
3245
3150
|
bindScopeRetainedOwnerProvider(scope, resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry), boundBackend.workspaceRetention === void 0 ? void 0 : {
|
|
@@ -3255,9 +3160,26 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
3255
3160
|
}
|
|
3256
3161
|
let driveTask = task;
|
|
3257
3162
|
if (reentry !== void 0) {
|
|
3258
|
-
const continuity = await reentryContinuity(boundBackend, scope, retainedOwner !== void 0)
|
|
3163
|
+
const continuity = switchedProviderCheckpointAt === void 0 ? await reentryContinuity(boundBackend, scope, retainedOwner !== void 0) : {
|
|
3164
|
+
session: "new",
|
|
3165
|
+
environment: "replaced",
|
|
3166
|
+
workspace: "restored",
|
|
3167
|
+
checkpointAt: switchedProviderCheckpointAt
|
|
3168
|
+
};
|
|
3169
|
+
if (activeSeat?.previous && activeSeat.previous.seat !== activeSeat.seat && activeSeat.previous.provider === activeSeat.stage.provider && activeSeat.previous.harness === activeSeat.stage.harness && (continuity.session !== "continued" || continuity.environment !== "same")) throw new ValidationError("same-provider seat continuation lost its native environment");
|
|
3259
3170
|
reentry.onContinuity?.(continuity);
|
|
3260
3171
|
driveTask = reentry.compose(continuity);
|
|
3172
|
+
if (activeSeat?.previous && (activeSeat.previous.provider !== activeSeat.stage.provider || activeSeat.previous.harness !== activeSeat.stage.harness)) driveTask = [
|
|
3173
|
+
String(driveTask),
|
|
3174
|
+
"",
|
|
3175
|
+
"## Harness handoff",
|
|
3176
|
+
"",
|
|
3177
|
+
"This is the same logical agent in a different harness or provider. Read the restored workspace,",
|
|
3178
|
+
"especially its STATE, NEXT, and RESULT pages and knowledge pages, before acting.",
|
|
3179
|
+
"A prior tool call may have executed. Check its committed output or workspace effect",
|
|
3180
|
+
"before repeating it.",
|
|
3181
|
+
committedTranscriptDigest(priorCommittedArtifact)
|
|
3182
|
+
].join("\n");
|
|
3261
3183
|
}
|
|
3262
3184
|
const originalTask = retainedOwner ? await prepareScopeRetainedOwnerTask(scope, driveTask) : driveTask;
|
|
3263
3185
|
const acceptedOwner = retainedOwner ? await scopeRetainedOwnerResult(scope) : void 0;
|
|
@@ -3274,8 +3196,13 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
3274
3196
|
const canonicalDriverProfile = agentProfileSchema.parse(authoredProfile);
|
|
3275
3197
|
assertNoReservedCoordinationMcpAlias(canonicalDriverProfile, "driveHarnessFromBackend");
|
|
3276
3198
|
const stableCoordinationTools = detachedSnapshot(coordinationTools, "driveHarnessFromBackend coordination tools");
|
|
3277
|
-
const expectedProviderProfile = providerVisibleProfile(canonicalDriverProfile);
|
|
3278
|
-
|
|
3199
|
+
const expectedProviderProfile = providerVisibleProfile(activeSeat ? seatExecutionProfile(canonicalDriverProfile, activeSeat.stage) : canonicalDriverProfile);
|
|
3200
|
+
if (activeSeat) {
|
|
3201
|
+
assertExecutableAgentProfile(expectedProviderProfile, "selected seat");
|
|
3202
|
+
assertBackendProfileMaterialization(expectedProviderProfile, boundBackend, "selected seat");
|
|
3203
|
+
assertBridgeProfileMaterializes(expectedProviderProfile, boundBackend, "selected seat");
|
|
3204
|
+
}
|
|
3205
|
+
const providerDriverProfile = activeSeat ? expectedProviderProfile : agentProfileSchema.parse(profile);
|
|
3279
3206
|
if (canonicalAgentProfileDigest(providerDriverProfile) !== canonicalAgentProfileDigest(expectedProviderProfile)) throw new ValidationError("driveHarnessFromBackend: supervisor passed a provider profile that does not match its canonical profile and mounted coordination tools");
|
|
3280
3207
|
const spec = {
|
|
3281
3208
|
profile: providerDriverProfile,
|
|
@@ -3624,7 +3551,10 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
3624
3551
|
endDrive();
|
|
3625
3552
|
}
|
|
3626
3553
|
if (failed) throw failure;
|
|
3627
|
-
if (turnFailure !== void 0)
|
|
3554
|
+
if (turnFailure !== void 0) {
|
|
3555
|
+
managerArtifact = terminalArtifact;
|
|
3556
|
+
throw turnFailure;
|
|
3557
|
+
}
|
|
3628
3558
|
managerArtifact = terminalArtifact;
|
|
3629
3559
|
};
|
|
3630
3560
|
drive.resultArtifact = () => managerArtifact;
|
|
@@ -3649,6 +3579,9 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
|
|
|
3649
3579
|
drive.harnessTranscript = () => managerTranscript ?? activeExecutor?.harnessTranscript?.();
|
|
3650
3580
|
drive.harnessTranscriptSettled = () => activeExecutor?.harnessTranscriptSettled?.() ?? Promise.resolve();
|
|
3651
3581
|
}
|
|
3582
|
+
drive.closeSeatSegment = async (reason) => {
|
|
3583
|
+
await seatChain?.close(reason);
|
|
3584
|
+
};
|
|
3652
3585
|
return attestRuntimeOwnedScopeOwner(drive, ownerRuntime);
|
|
3653
3586
|
}
|
|
3654
3587
|
/**
|
|
@@ -3759,6 +3692,7 @@ const superviseOptionKeySet = /* @__PURE__ */ new Set([
|
|
|
3759
3692
|
"authorizeMessage",
|
|
3760
3693
|
"authorizeSpawn",
|
|
3761
3694
|
"backend",
|
|
3695
|
+
"selectSeat",
|
|
3762
3696
|
"blobs",
|
|
3763
3697
|
"budget",
|
|
3764
3698
|
"childSettleGraceMs",
|
|
@@ -3864,6 +3798,7 @@ Object.freeze([...[
|
|
|
3864
3798
|
"resolveDeliverable",
|
|
3865
3799
|
"resolveDriveHarness",
|
|
3866
3800
|
"resolveSpawnProfile",
|
|
3801
|
+
"selectSeat",
|
|
3867
3802
|
"resolveSupervisorTools",
|
|
3868
3803
|
"stopRule"
|
|
3869
3804
|
]]);
|
|
@@ -3898,7 +3833,7 @@ function rootSpawnResourceRoot(backend) {
|
|
|
3898
3833
|
}
|
|
3899
3834
|
function captureSuperviseOptions(opts) {
|
|
3900
3835
|
assertSuperviseOptionKeys(opts, "supervise");
|
|
3901
|
-
const { backend, coordination, driverBackend, deliverable, resolveDeliverable, router, compaction, watchWorkers, analysts, makeWorkerAgent, makeLeafAgent, recoverExecutor, resume, resolveSpawnProfile, blobs, journal, runContext, registry, hooks, otel, authorizeSpawn, authorizeMessage, driveHarness, resolveDriveHarness, resolveSupervisorTools, escalateQuestion, onCoordinationEvent, executeExtraTool, stopRule, onProgressStop, onDriverAttempt, continuation, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, workerSlots, ...decisionData } = opts;
|
|
3836
|
+
const { backend, selectSeat, coordination, driverBackend, deliverable, resolveDeliverable, router, compaction, watchWorkers, analysts, makeWorkerAgent, makeLeafAgent, recoverExecutor, resume, resolveSpawnProfile, blobs, journal, runContext, registry, hooks, otel, authorizeSpawn, authorizeMessage, driveHarness, resolveDriveHarness, resolveSupervisorTools, escalateQuestion, onCoordinationEvent, executeExtraTool, stopRule, onProgressStop, onDriverAttempt, continuation, workerRetry, onWorkerRetry, finalizer, now, signal, rootHandle, workerSlots, ...decisionData } = opts;
|
|
3902
3837
|
assertNoUncapturedExecutableOption(decisionData);
|
|
3903
3838
|
const capturedData = detachedSnapshot(decisionData, "supervise options");
|
|
3904
3839
|
const capturedCoordination = coordination === void 0 ? void 0 : (() => {
|
|
@@ -3958,6 +3893,7 @@ function captureSuperviseOptions(opts) {
|
|
|
3958
3893
|
...capturedData,
|
|
3959
3894
|
...capturedCoordination === void 0 ? {} : { coordination: capturedCoordination },
|
|
3960
3895
|
...capturedBackend === void 0 ? {} : { backend: capturedBackend },
|
|
3896
|
+
...selectSeat === void 0 ? {} : { selectSeat },
|
|
3961
3897
|
...capturedDriverBackend === void 0 ? {} : { driverBackend: capturedDriverBackend },
|
|
3962
3898
|
...capturedDeliverable === void 0 ? {} : { deliverable: capturedDeliverable },
|
|
3963
3899
|
...resolveDeliverable === void 0 ? {} : { resolveDeliverable },
|
|
@@ -4231,6 +4167,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4231
4167
|
const composeSpawnProfile = profileGuidanceComposer(options.profileGuidance);
|
|
4232
4168
|
const canonicalProfile = superviseRootProfile(profile, options.profileGuidance);
|
|
4233
4169
|
assertExecutableAgentProfile(canonicalProfile, "supervise root");
|
|
4170
|
+
if (authoredSeatStages(canonicalProfile) !== void 0 && options.selectSeat === void 0) throw new ValidationError("supervise: AgentProfile.seats requires selectSeat before execution");
|
|
4234
4171
|
const canonicalTask = freezeDetached(task);
|
|
4235
4172
|
if (options.makeWorkerAgent && options.authorizeSpawn) throw new ValidationError("supervise: authorizeSpawn cannot be combined with caller-owned makeWorkerAgent; use makeLeafAgent to override leaf execution inside the authorized path, or use backend-derived workers");
|
|
4236
4173
|
if (options.makeWorkerAgent && options.makeLeafAgent) throw new ValidationError("supervise: makeWorkerAgent replaces the worker path and makeLeafAgent overrides a leaf inside it; pass one");
|
|
@@ -4251,6 +4188,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4251
4188
|
const backendModel = options.backend?.model;
|
|
4252
4189
|
const driverBackendModel = options.driverBackend?.model;
|
|
4253
4190
|
assertProfileModelsAllowed(canonicalProfile, options.allowedModels);
|
|
4191
|
+
for (const stage of authoredSeatStages(canonicalProfile) ?? []) assertModelAllowed(stage.model, options.allowedModels);
|
|
4254
4192
|
assertModelAllowed(typeof backendModel === "string" ? backendModel : void 0, options.allowedModels);
|
|
4255
4193
|
assertModelAllowed(typeof driverBackendModel === "string" ? driverBackendModel : void 0, options.allowedModels);
|
|
4256
4194
|
const deliverable = resolveNamed("deliverable", "deliverables", options.deliverable, options.registry?.deliverables);
|
|
@@ -4293,7 +4231,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4293
4231
|
if (options.inheritSpawnRights === false || options.makeWorkerAgent !== void 0 || !childrenCanSubmit) return composeSpawnProfile;
|
|
4294
4232
|
return (authored) => {
|
|
4295
4233
|
const composed = composeSpawnProfile ? composeSpawnProfile(authored) : authored;
|
|
4296
|
-
return canLead(composed) ? withInheritedSpawnRights(parent, composed)
|
|
4234
|
+
return composed.seats || !canLead(composed) ? composed : withInheritedSpawnRights(parent, composed);
|
|
4297
4235
|
};
|
|
4298
4236
|
};
|
|
4299
4237
|
const harnessClaims = /* @__PURE__ */ new WeakMap();
|
|
@@ -4323,7 +4261,41 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4323
4261
|
return managerBackend && automaticDriverBackendSupported(managerBackend, options.coordination) ? driveHarnessFromBackend(managerBackend, externalExecutionId("supervised-manager", {
|
|
4324
4262
|
runNamespace,
|
|
4325
4263
|
ownerId: context.ownerId
|
|
4326
|
-
}), options.now ?? Date.now, options.maxTurns, context.depth === 0 ? rootStreamSink : void 0
|
|
4264
|
+
}), options.now ?? Date.now, options.maxTurns, context.depth === 0 ? rootStreamSink : void 0, options.selectSeat === void 0 ? void 0 : {
|
|
4265
|
+
select: options.selectSeat,
|
|
4266
|
+
journal,
|
|
4267
|
+
rootId: runId,
|
|
4268
|
+
onSegment: async (nodeId, segment, phase) => {
|
|
4269
|
+
await options.hooks?.onEvent?.({
|
|
4270
|
+
id: `${nodeId}:seat:${segment.startedAt}:${phase}`,
|
|
4271
|
+
runId,
|
|
4272
|
+
target: "agent.seat",
|
|
4273
|
+
phase: "event",
|
|
4274
|
+
timestamp: options.now?.() ?? Date.now(),
|
|
4275
|
+
parentId: nodeId,
|
|
4276
|
+
payload: {
|
|
4277
|
+
nodeId,
|
|
4278
|
+
phase,
|
|
4279
|
+
segment
|
|
4280
|
+
}
|
|
4281
|
+
}, {});
|
|
4282
|
+
},
|
|
4283
|
+
onPause: async (nodeId, resumeAt, phase) => {
|
|
4284
|
+
await options.hooks?.onEvent?.({
|
|
4285
|
+
id: `${nodeId}:seat:${phase}:${resumeAt || (options.now?.() ?? Date.now())}`,
|
|
4286
|
+
runId,
|
|
4287
|
+
target: "agent.seat",
|
|
4288
|
+
phase: "event",
|
|
4289
|
+
timestamp: options.now?.() ?? Date.now(),
|
|
4290
|
+
parentId: nodeId,
|
|
4291
|
+
payload: {
|
|
4292
|
+
nodeId,
|
|
4293
|
+
phase,
|
|
4294
|
+
...resumeAt ? { resumeAt } : {}
|
|
4295
|
+
}
|
|
4296
|
+
}, {});
|
|
4297
|
+
}
|
|
4298
|
+
}) : void 0;
|
|
4327
4299
|
};
|
|
4328
4300
|
const rootDriveHarness = isExternalSupervisor(canonicalProfile) ? driveHarnessForOwner(freezeDetached({
|
|
4329
4301
|
runId,
|
|
@@ -4393,7 +4365,8 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4393
4365
|
assertProfileModelsAllowed(authorized, options.allowedModels);
|
|
4394
4366
|
const selectedDeliverable = options.resolveDeliverable?.(postAuthorizationContext);
|
|
4395
4367
|
const childDeliverable = selectedDeliverable === void 0 ? deliverable : selectedDeliverable === null ? void 0 : captureDeliverable(selectedDeliverable, `supervise deliverable for ${JSON.stringify(spawnContext.label)}`);
|
|
4396
|
-
|
|
4368
|
+
const seatManagedLeaf = authoredSeatStages(authorized) !== void 0 && declaredRuntimeToolNames(authorized).length === 0 && isExternalSupervisor(authorized);
|
|
4369
|
+
if (!(declaredRuntimeToolNames(authorized).length > 0 || seatManagedLeaf)) {
|
|
4397
4370
|
if (childDeliverable !== deliverable && !options.backend) throw new ValidationError("supervise: resolveDeliverable selected a per-spawn deliverable but there is no backend to derive that leaf from; makeLeafAgent owns its own completion check");
|
|
4398
4371
|
return (childDeliverable === deliverable ? makeLeaf : withRetry(workerFromBackend(options.backend, childDeliverable)))(authorized, Object.freeze({
|
|
4399
4372
|
...authorizedContext,
|
|
@@ -4464,11 +4437,11 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4464
4437
|
...options.compaction ? { compaction: options.compaction } : {},
|
|
4465
4438
|
...options.driverRetry ? { driverRetry: options.driverRetry } : {},
|
|
4466
4439
|
...options.onDriverAttempt ? { onDriverAttempt: options.onDriverAttempt } : {},
|
|
4467
|
-
...childDeliverable ? { deliverable: childDeliverable } : {},
|
|
4468
|
-
...childDeliverable ? { onAcceptedSubmission: () => {
|
|
4440
|
+
...childDeliverable && !seatManagedLeaf ? { deliverable: childDeliverable } : {},
|
|
4441
|
+
...childDeliverable && !seatManagedLeaf ? { onAcceptedSubmission: () => {
|
|
4469
4442
|
acceptedSubmission = true;
|
|
4470
4443
|
} } : {},
|
|
4471
|
-
...childDeliverable && options.continuation && isExternalSupervisor(authorized) ? {
|
|
4444
|
+
...childDeliverable && !seatManagedLeaf && options.continuation && isExternalSupervisor(authorized) ? {
|
|
4472
4445
|
continuation: options.continuation,
|
|
4473
4446
|
...options.runDir === void 0 ? {} : { continuationDir: resolve(options.runDir, CONTINUATIONS_DIR, "managers", encodeURIComponent(ownerId)) }
|
|
4474
4447
|
} : {},
|
|
@@ -4483,7 +4456,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4483
4456
|
},
|
|
4484
4457
|
...options.steerDir === void 0 ? {} : { steerDir: resolve(options.steerDir) },
|
|
4485
4458
|
...options.runDir === void 0 && options.steerDir === void 0 ? {} : { controlScope: "subtree" }
|
|
4486
|
-
}), journal, childExecution.ref, () => acceptedSubmission, recoveryFactories.get(childFactory), () => unassessedOutput);
|
|
4459
|
+
}), journal, childExecution.ref, () => acceptedSubmission, recoveryFactories.get(childFactory), () => unassessedOutput, seatManagedLeaf ? childDeliverable : void 0);
|
|
4487
4460
|
};
|
|
4488
4461
|
if (options.makeLeafAgent === void 0 && options.backend?.backend === "provider" && !options.backend.steering) {
|
|
4489
4462
|
const factory = registerRetainedExecutorPreparation(createExecutor(options.backend), ({ spawned, profile, task }) => {
|
|
@@ -4712,6 +4685,6 @@ function rootProviderModelEvidenceFromExecution(evidence) {
|
|
|
4712
4685
|
return evidence ?? rootProviderModelEvidence([]);
|
|
4713
4686
|
}
|
|
4714
4687
|
//#endregion
|
|
4715
|
-
export {
|
|
4688
|
+
export { readRootStreamReceipt as _, superviseWithTestBrain as a, createSupervisorSpanRecorder as b, resolveWorkerSpawnRetry as c, assertCoordinationBinding as d, resolveSupervisorProfile as f, readRootStream as g, ROOT_STREAM_FILE as h, superviseRootProfile as i, retryPreSpawnRefusals as l, supervisorAgentWithTestBrain as m, profileGuidanceComposer as n, workerFromBackend as o, supervisorAgent as p, supervise as r, isPreSpawnExecutorFailure as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, withWorkerSpawnRetry as u, UNPROVEN_CONTINUITY as v, serveCoordinationMcp as x, composeReentryTask as y };
|
|
4716
4689
|
|
|
4717
|
-
//# sourceMappingURL=supervise-
|
|
4690
|
+
//# sourceMappingURL=supervise-D1qqMFAu.js.map
|