@tangle-network/agent-runtime 0.324.0 → 0.325.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-CB2npL7F.d.ts → activation-BMsOQxMD.d.ts} +2 -2
- package/dist/{activation-CmWGOW1x.js → activation-C1O2zCvn.js} +3 -3
- package/dist/{activation-CmWGOW1x.js.map → activation-C1O2zCvn.js.map} +1 -1
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{bundle-BJJmfEsw.js → bundle-KZGUQqRM.js} +2 -2
- package/dist/{bundle-BJJmfEsw.js.map → bundle-KZGUQqRM.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-driver-CNEeqMoh.js → coordination-driver-Bx7nXmOs.js} +243 -140
- package/dist/coordination-driver-Bx7nXmOs.js.map +1 -0
- package/dist/{delegate-C6oOTFB6.js → delegate-BK-2bX4e.js} +2 -2
- package/dist/{delegate-C6oOTFB6.js.map → delegate-BK-2bX4e.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +62 -23
- package/dist/durable.js.map +1 -1
- package/dist/graph-C8Ot8__B.js +348 -0
- package/dist/graph-C8Ot8__B.js.map +1 -0
- package/dist/{improvement-cycle-U74a-YKi.js → improvement-cycle-IncBZK-W.js} +6 -6
- package/dist/{improvement-cycle-U74a-YKi.js.map → improvement-cycle-IncBZK-W.js.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +7 -7
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +10 -10
- package/dist/{loop-runner-bin-BfcTX4-n.js → loop-runner-bin-Ch9FgmrJ.js} +3 -3
- package/dist/{loop-runner-bin-BfcTX4-n.js.map → loop-runner-bin-Ch9FgmrJ.js.map} +1 -1
- package/dist/{loop-runner-bin-CkchKbaB.d.ts → loop-runner-bin-ECJA--ZN.d.ts} +2 -2
- 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 +3 -3
- package/dist/mcp/index.js +5 -5
- package/dist/{openai-tools-BR3rRmmC.d.ts → openai-tools-C_dJoluR.d.ts} +2 -2
- package/dist/placement.d.ts +1 -1
- package/dist/{prepare-DpavgJT8.js → prepare-BrgoOJmU.js} +8 -7
- package/dist/{prepare-DpavgJT8.js.map → prepare-BrgoOJmU.js.map} +1 -1
- package/dist/{profile-ZS7_KLwK.js → profile-ChWlsNCI.js} +30 -55
- package/dist/profile-ChWlsNCI.js.map +1 -0
- package/dist/{profile-materialization-C5-t3HJ7.d.ts → profile-materialization-BnoEf1co.d.ts} +3 -8
- package/dist/profiles.d.ts +1 -1
- package/dist/{protected-model-port-BLyyfL3l.js → protected-model-port-CJzC-FRs.js} +4 -4
- package/dist/{protected-model-port-BLyyfL3l.js.map → protected-model-port-CJzC-FRs.js.map} +1 -1
- package/dist/{provision-supervisor-DhPJqazM.js → provision-supervisor-GqVnQ_oy.js} +4 -4
- package/dist/{provision-supervisor-DhPJqazM.js.map → provision-supervisor-GqVnQ_oy.js.map} +1 -1
- package/dist/{runtime-B9-ZiYFa.js → runtime-9ZwTmnhQ.js} +10 -10
- package/dist/{runtime-B9-ZiYFa.js.map → runtime-9ZwTmnhQ.js.map} +1 -1
- package/dist/{workspace-streams-CcoARX4v.js → sandbox-profile-compat-Dq7ujONv.js} +40 -6
- package/dist/sandbox-profile-compat-Dq7ujONv.js.map +1 -0
- package/dist/{search-executor-CtNb_lIB.js → search-executor-CKIXXaiX.js} +3 -3
- package/dist/{search-executor-CtNb_lIB.js.map → search-executor-CKIXXaiX.js.map} +1 -1
- package/dist/{server-BLYiq6fK.js → server-BSWvux-R.js} +4 -4
- package/dist/{server-BLYiq6fK.js.map → server-BSWvux-R.js.map} +1 -1
- package/dist/{supervise-FOCAUADN.js → supervise-Dt_bZSVY.js} +736 -20
- package/dist/supervise-Dt_bZSVY.js.map +1 -0
- package/dist/{supervisor-DnKhkhKc.js → supervisor-CESg1FQx.js} +36 -18
- package/dist/supervisor-CESg1FQx.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-ytkoP4VV.d.ts → types-CTjiMrcF.d.ts} +578 -509
- package/package.json +9 -9
- package/skills/profile-authoring/SKILL.md +1 -1
- package/dist/coordination-driver-CNEeqMoh.js.map +0 -1
- package/dist/graph-BKmo7d42.js +0 -805
- package/dist/graph-BKmo7d42.js.map +0 -1
- package/dist/profile-ZS7_KLwK.js.map +0 -1
- package/dist/supervise-FOCAUADN.js.map +0 -1
- package/dist/supervisor-DnKhkhKc.js.map +0 -1
- package/dist/workspace-streams-CcoARX4v.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $i as InMemoryResultBlobStore, Bt as createRouterTranscript, Ct as checkVerdictOf, Dt as failedItems, En as runBrainLoop, Ft as createExecutorRegistry, J as scopeRetainedOwnerResourceReader, Qi as FileSpawnJournal, T as meterRuntimeOwnedProviderAttempt, Ta as resolveRedactor, Zi as FileResultBlobStore, Zt as createInbox, _a as assertValidBudget, at as runtimeGraphMetadataKey, c as runTree, ca as parseWorkerToolTraceArtifact, da as detachedFrozen, ea as InMemorySpawnJournal, i as bestDelivered, ji as settlementFailureCause, la as workerTraceAnalysisStore, ma as errMessage, mi as providerAttemptEvidence, nn as createPeerMailbox, o as pickBestDelivered, on as isLiveNodeStatus, s as runFinalizer, sn as isTerminalNodeStatus, tt as resolveSpawnResourcePaths, ua as contentAddress, v as withDriverExecutor, w as meterRuntimeOwnedAccounting, yt as CheckUnavailableError } from "./supervisor-CESg1FQx.js";
|
|
2
2
|
import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import {
|
|
3
|
+
import { G as chargedTokens, gt as withBudgetResources, lt as unmeteredSpend, pt as addResourceSpend, tt as promptCacheTokenClasses } from "./sandbox-profile-compat-Dq7ujONv.js";
|
|
4
4
|
import { a as readCommittedJsonLines, t as appendCommittedJsonLine } from "./jsonl-file-DBv31uPi.js";
|
|
5
5
|
import { A as writeWorkerCancellation, M as writeWorkerSteerAcknowledgement, b as workerCancellationsDir, c as readWorkerCancelRequests, d as readWorkerSteerRequests, k as writeRunCancellation, l as readWorkerCancellation, o as readRunCancelRequest, r as claimWorkerSteerDelivery, s as readRunCancellation, u as readWorkerSteerAcknowledgement } from "./run-layout-Cu8H7aeh.js";
|
|
6
6
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
@@ -550,7 +550,8 @@ const coordinationVerbNames = [
|
|
|
550
550
|
"read_journal",
|
|
551
551
|
"list_analysts",
|
|
552
552
|
"run_analyst",
|
|
553
|
-
"define_analyst"
|
|
553
|
+
"define_analyst",
|
|
554
|
+
"run_graph"
|
|
554
555
|
];
|
|
555
556
|
/**
|
|
556
557
|
* The `CoordinationEvent` kinds that wake a waiting manager. The queue carries the UP-leg only:
|
|
@@ -569,6 +570,47 @@ const idArg = {
|
|
|
569
570
|
type: "string",
|
|
570
571
|
description: "The workerId returned by spawn_worker."
|
|
571
572
|
};
|
|
573
|
+
/** The optional per-spawn budget `spawn_worker` and `run_graph` take. */
|
|
574
|
+
const spawnBudgetArg = {
|
|
575
|
+
type: "object",
|
|
576
|
+
description: "Optional per-spawn budget that merges over the per-worker default (per field). Only set the ceilings this sub-task needs raised; the conserved pool still fences.",
|
|
577
|
+
properties: {
|
|
578
|
+
maxIterations: {
|
|
579
|
+
type: "number",
|
|
580
|
+
minimum: 0
|
|
581
|
+
},
|
|
582
|
+
maxTokens: {
|
|
583
|
+
type: "number",
|
|
584
|
+
minimum: 0
|
|
585
|
+
},
|
|
586
|
+
maxUsd: {
|
|
587
|
+
type: "number",
|
|
588
|
+
minimum: 0
|
|
589
|
+
},
|
|
590
|
+
deadlineMs: {
|
|
591
|
+
type: "number",
|
|
592
|
+
minimum: 0
|
|
593
|
+
},
|
|
594
|
+
resources: {
|
|
595
|
+
type: "object",
|
|
596
|
+
additionalProperties: {
|
|
597
|
+
type: "object",
|
|
598
|
+
properties: {
|
|
599
|
+
unit: {
|
|
600
|
+
type: "string",
|
|
601
|
+
minLength: 1
|
|
602
|
+
},
|
|
603
|
+
limit: {
|
|
604
|
+
type: "integer",
|
|
605
|
+
minimum: 0,
|
|
606
|
+
maximum: Number.MAX_SAFE_INTEGER
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
required: ["unit", "limit"]
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
};
|
|
572
614
|
/**
|
|
573
615
|
* Strip zod's object-KEY CODEC artifact from a derived JSON Schema, at every depth.
|
|
574
616
|
*
|
|
@@ -2136,6 +2178,107 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2136
2178
|
idleMs: Date.now() - startedAt
|
|
2137
2179
|
});
|
|
2138
2180
|
};
|
|
2181
|
+
const admitSpawn = async (input) => {
|
|
2182
|
+
const { profile, key, continuity, successorOf } = input;
|
|
2183
|
+
const a = input.args;
|
|
2184
|
+
const task = detachedFrozen(input.task);
|
|
2185
|
+
const label = typeof a.label === "string" ? a.label : input.defaultLabel;
|
|
2186
|
+
if (opts.preflightSpawn) {
|
|
2187
|
+
const refusal = await opts.preflightSpawn(input.preflightProfile(), {
|
|
2188
|
+
label,
|
|
2189
|
+
...key !== void 0 ? { key } : {},
|
|
2190
|
+
task
|
|
2191
|
+
});
|
|
2192
|
+
if (refusal) {
|
|
2193
|
+
preflightCounts[refusal.cause] += 1;
|
|
2194
|
+
return {
|
|
2195
|
+
error: "preflight-refused",
|
|
2196
|
+
reason: `the spawn pre-flight refused this profile (${refusal.cause}): ${refusal.detail}`,
|
|
2197
|
+
cause: refusal.cause,
|
|
2198
|
+
detail: refusal.detail,
|
|
2199
|
+
live: liveWorkerCount(),
|
|
2200
|
+
freeSlots: freeWorkerSlots()
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
const budget = Object.freeze(a.budget === void 0 ? opts.perWorker : mergeBudget(opts.perWorker, a.budget));
|
|
2205
|
+
const assignmentId = key !== void 0 ? `key:${key}` : `ordinal:${unkeyedAssignmentOrdinal++}`;
|
|
2206
|
+
const peerMailUrl = peerMail?.mintCapability(assignmentId);
|
|
2207
|
+
const context = Object.freeze({
|
|
2208
|
+
assignmentId,
|
|
2209
|
+
parentNodeId: opts.scope.view.root,
|
|
2210
|
+
budget,
|
|
2211
|
+
task,
|
|
2212
|
+
label,
|
|
2213
|
+
...key !== void 0 ? { key } : {},
|
|
2214
|
+
continuity: continuity.continuity,
|
|
2215
|
+
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
2216
|
+
...successorOf !== void 0 ? { successorOf } : {},
|
|
2217
|
+
...peerMailUrl !== void 0 ? { peerMailUrl } : {}
|
|
2218
|
+
});
|
|
2219
|
+
const res = opts.scope.spawn(() => opts.makeWorkerAgent(profile, context), task, {
|
|
2220
|
+
budget,
|
|
2221
|
+
label,
|
|
2222
|
+
assignmentId,
|
|
2223
|
+
...key !== void 0 ? { key } : {},
|
|
2224
|
+
...successorOf !== void 0 ? { successorOf } : {}
|
|
2225
|
+
});
|
|
2226
|
+
if (res.ok && res.prior?.state === "completed") {
|
|
2227
|
+
const s = res.prior.settled;
|
|
2228
|
+
const { id, status, resumed: _resumed, ...evidence } = projectSettled(s);
|
|
2229
|
+
return Promise.resolve({
|
|
2230
|
+
workerId: id,
|
|
2231
|
+
resumed: "completed",
|
|
2232
|
+
status,
|
|
2233
|
+
...evidence,
|
|
2234
|
+
...evidence.outRef === void 0 ? {} : { outputRead: {
|
|
2235
|
+
tool: "observe_agent",
|
|
2236
|
+
arguments: { workerId: id }
|
|
2237
|
+
} },
|
|
2238
|
+
live: liveWorkerCount(),
|
|
2239
|
+
freeSlots: freeWorkerSlots()
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
if (res.ok) {
|
|
2243
|
+
watchWorker(res.handle.id);
|
|
2244
|
+
liveHandles.set(res.handle.id, res.handle);
|
|
2245
|
+
peerMail?.bindCapability(assignmentId, res.handle.id);
|
|
2246
|
+
if (typeof profile.name === "string" && profile.name.length > 0) profileNameByWorker.set(res.handle.id, profile.name);
|
|
2247
|
+
}
|
|
2248
|
+
const priorHistory = res.ok && res.prior !== void 0 && res.prior.state !== "completed" ? {
|
|
2249
|
+
resumed: res.prior.state,
|
|
2250
|
+
priorWorkerId: res.prior.priorId,
|
|
2251
|
+
...res.prior.state === "retried" ? { priorReason: res.prior.reason } : {}
|
|
2252
|
+
} : {};
|
|
2253
|
+
return Promise.resolve(res.ok ? {
|
|
2254
|
+
workerId: res.handle.id,
|
|
2255
|
+
assignmentId: res.handle.assignmentId ?? assignmentId,
|
|
2256
|
+
...res.handle.identity === void 0 ? {} : { identity: res.handle.identity },
|
|
2257
|
+
...res.handle.materialization === void 0 ? {} : { materialization: res.handle.materialization },
|
|
2258
|
+
...res.handle.executionBindings === void 0 ? {} : { executionBindings: res.handle.executionBindings },
|
|
2259
|
+
continuity: continuity.continuity,
|
|
2260
|
+
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
2261
|
+
...successorOf !== void 0 ? { successorOf } : {},
|
|
2262
|
+
status: res.handle.status,
|
|
2263
|
+
live: liveWorkerCount(),
|
|
2264
|
+
queued: queuedWorkerCount(),
|
|
2265
|
+
freeSlots: freeWorkerSlots(),
|
|
2266
|
+
...priorHistory,
|
|
2267
|
+
...input.resourcesFromPath.length === 0 ? {} : { resourcesFromPath: input.resourcesFromPath },
|
|
2268
|
+
...input.accepted
|
|
2269
|
+
} : {
|
|
2270
|
+
error: res.reason,
|
|
2271
|
+
reason: spawnRefusalReason(res.reason, res.shortfalls, {
|
|
2272
|
+
usdUnbudgeted: "this run's root budget declares no maxUsd, so a child budget naming maxUsd can never be admitted at any amount — spawn with a budget that omits maxUsd",
|
|
2273
|
+
inDoubt: "this key has a prior worker recorded as started without a terminal receipt; no replacement was started because that remote worker may still be running — inspect or recover the exact prior execution before retrying",
|
|
2274
|
+
scopeSettled: "this run has already reached its join barrier — its driver returned and the supervisor is settling, so no further worker can be started, joined, or paid for; record this stage as not started"
|
|
2275
|
+
}),
|
|
2276
|
+
...res.shortfalls === void 0 ? {} : { shortfalls: res.shortfalls },
|
|
2277
|
+
...res.reason === "usd-unbudgeted" ? { hint: "This run's root budget declares no maxUsd, so a child budget naming maxUsd can never be admitted — at any amount. Retrying with a smaller maxUsd will fail identically. Spawn with a budget that omits maxUsd, or ask the caller to give the run a root maxUsd." } : res.reason === "in-doubt" ? { hint: "Do not retry this key. Use the recorded prior worker identity to inspect or recover that exact execution. A terminal receipt or explicit recovery is required before replacement work can start." } : {},
|
|
2278
|
+
live: liveWorkerCount(),
|
|
2279
|
+
freeSlots: freeWorkerSlots()
|
|
2280
|
+
});
|
|
2281
|
+
};
|
|
2139
2282
|
const tools = [
|
|
2140
2283
|
{
|
|
2141
2284
|
name: "spawn_worker",
|
|
@@ -2162,46 +2305,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2162
2305
|
type: "string",
|
|
2163
2306
|
description: "The workerId of a SETTLED worker you spawned that this new worker replaces — for example one that failed, stalled, or finished with a weak result, restarted with a changed profile or task. The run record then names the predecessor on the new worker. Refused for an id you did not spawn (`error: \"successor-unknown\"`) and for a worker still live (`error: \"successor-live\"` — end your turn until it settles). Put what the successor needs from its predecessor in `task`."
|
|
2164
2307
|
},
|
|
2165
|
-
budget:
|
|
2166
|
-
type: "object",
|
|
2167
|
-
description: "Optional per-spawn budget that merges over the per-worker default (per field). Only set the ceilings this sub-task needs raised; the conserved pool still fences.",
|
|
2168
|
-
properties: {
|
|
2169
|
-
maxIterations: {
|
|
2170
|
-
type: "number",
|
|
2171
|
-
minimum: 0
|
|
2172
|
-
},
|
|
2173
|
-
maxTokens: {
|
|
2174
|
-
type: "number",
|
|
2175
|
-
minimum: 0
|
|
2176
|
-
},
|
|
2177
|
-
maxUsd: {
|
|
2178
|
-
type: "number",
|
|
2179
|
-
minimum: 0
|
|
2180
|
-
},
|
|
2181
|
-
deadlineMs: {
|
|
2182
|
-
type: "number",
|
|
2183
|
-
minimum: 0
|
|
2184
|
-
},
|
|
2185
|
-
resources: {
|
|
2186
|
-
type: "object",
|
|
2187
|
-
additionalProperties: {
|
|
2188
|
-
type: "object",
|
|
2189
|
-
properties: {
|
|
2190
|
-
unit: {
|
|
2191
|
-
type: "string",
|
|
2192
|
-
minLength: 1
|
|
2193
|
-
},
|
|
2194
|
-
limit: {
|
|
2195
|
-
type: "integer",
|
|
2196
|
-
minimum: 0,
|
|
2197
|
-
maximum: Number.MAX_SAFE_INTEGER
|
|
2198
|
-
}
|
|
2199
|
-
},
|
|
2200
|
-
required: ["unit", "limit"]
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2308
|
+
budget: spawnBudgetArg
|
|
2205
2309
|
},
|
|
2206
2310
|
required: ["profile", "task"]
|
|
2207
2311
|
},
|
|
@@ -2240,6 +2344,17 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2240
2344
|
message: issue.message
|
|
2241
2345
|
}))
|
|
2242
2346
|
});
|
|
2347
|
+
if (parsedProfile.data.metadata?.["agentRuntimeGraph"] !== void 0) {
|
|
2348
|
+
const reason = `metadata.${runtimeGraphMetadataKey} is written by Runtime for the root of a run_graph subtask; call run_graph to run a graph`;
|
|
2349
|
+
return {
|
|
2350
|
+
error: "invalid-profile",
|
|
2351
|
+
reason,
|
|
2352
|
+
issues: [{
|
|
2353
|
+
path: `metadata.${runtimeGraphMetadataKey}`,
|
|
2354
|
+
message: reason
|
|
2355
|
+
}]
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2243
2358
|
const profile = detachedFrozen(opts.composeSpawnProfile ? agentProfileSchema.parse(opts.composeSpawnProfile(parsedProfile.data)) : parsedProfile.data);
|
|
2244
2359
|
const continuity = resolveContinuity(parseContinuity(a.continuity), profile.name, key);
|
|
2245
2360
|
if ("error" in continuity) return Promise.resolve({
|
|
@@ -2265,102 +2380,16 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2265
2380
|
freeSlots: freeWorkerSlots()
|
|
2266
2381
|
};
|
|
2267
2382
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
preflightCounts[refusal.cause] += 1;
|
|
2279
|
-
return {
|
|
2280
|
-
error: "preflight-refused",
|
|
2281
|
-
reason: `the spawn pre-flight refused this profile (${refusal.cause}): ${refusal.detail}`,
|
|
2282
|
-
cause: refusal.cause,
|
|
2283
|
-
detail: refusal.detail,
|
|
2284
|
-
live: liveWorkerCount(),
|
|
2285
|
-
freeSlots: freeWorkerSlots()
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
const budget = Object.freeze(a.budget === void 0 ? opts.perWorker : mergeBudget(opts.perWorker, a.budget));
|
|
2290
|
-
const assignmentId = key !== void 0 ? `key:${key}` : `ordinal:${unkeyedAssignmentOrdinal++}`;
|
|
2291
|
-
const peerMailUrl = peerMail?.mintCapability(assignmentId);
|
|
2292
|
-
const context = Object.freeze({
|
|
2293
|
-
assignmentId,
|
|
2294
|
-
parentNodeId: opts.scope.view.root,
|
|
2295
|
-
budget,
|
|
2296
|
-
task,
|
|
2297
|
-
label,
|
|
2298
|
-
...key !== void 0 ? { key } : {},
|
|
2299
|
-
continuity: continuity.continuity,
|
|
2300
|
-
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
2301
|
-
...successorOf !== void 0 ? { successorOf } : {},
|
|
2302
|
-
...peerMailUrl !== void 0 ? { peerMailUrl } : {}
|
|
2303
|
-
});
|
|
2304
|
-
const res = opts.scope.spawn(() => opts.makeWorkerAgent(profile, context), task, {
|
|
2305
|
-
budget,
|
|
2306
|
-
label,
|
|
2307
|
-
assignmentId,
|
|
2308
|
-
...key !== void 0 ? { key } : {},
|
|
2309
|
-
...successorOf !== void 0 ? { successorOf } : {}
|
|
2310
|
-
});
|
|
2311
|
-
if (res.ok && res.prior?.state === "completed") {
|
|
2312
|
-
const s = res.prior.settled;
|
|
2313
|
-
const { id, status, resumed: _resumed, ...evidence } = projectSettled(s);
|
|
2314
|
-
return Promise.resolve({
|
|
2315
|
-
workerId: id,
|
|
2316
|
-
resumed: "completed",
|
|
2317
|
-
status,
|
|
2318
|
-
...evidence,
|
|
2319
|
-
...evidence.outRef === void 0 ? {} : { outputRead: {
|
|
2320
|
-
tool: "observe_agent",
|
|
2321
|
-
arguments: { workerId: id }
|
|
2322
|
-
} },
|
|
2323
|
-
live: liveWorkerCount(),
|
|
2324
|
-
freeSlots: freeWorkerSlots()
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2327
|
-
if (res.ok) {
|
|
2328
|
-
watchWorker(res.handle.id);
|
|
2329
|
-
liveHandles.set(res.handle.id, res.handle);
|
|
2330
|
-
peerMail?.bindCapability(assignmentId, res.handle.id);
|
|
2331
|
-
if (typeof profile.name === "string" && profile.name.length > 0) profileNameByWorker.set(res.handle.id, profile.name);
|
|
2332
|
-
}
|
|
2333
|
-
const priorHistory = res.ok && res.prior !== void 0 && res.prior.state !== "completed" ? {
|
|
2334
|
-
resumed: res.prior.state,
|
|
2335
|
-
priorWorkerId: res.prior.priorId,
|
|
2336
|
-
...res.prior.state === "retried" ? { priorReason: res.prior.reason } : {}
|
|
2337
|
-
} : {};
|
|
2338
|
-
return Promise.resolve(res.ok ? {
|
|
2339
|
-
workerId: res.handle.id,
|
|
2340
|
-
assignmentId: res.handle.assignmentId ?? assignmentId,
|
|
2341
|
-
...res.handle.identity === void 0 ? {} : { identity: res.handle.identity },
|
|
2342
|
-
...res.handle.materialization === void 0 ? {} : { materialization: res.handle.materialization },
|
|
2343
|
-
...res.handle.executionBindings === void 0 ? {} : { executionBindings: res.handle.executionBindings },
|
|
2344
|
-
continuity: continuity.continuity,
|
|
2345
|
-
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
2346
|
-
...successorOf !== void 0 ? { successorOf } : {},
|
|
2347
|
-
status: res.handle.status,
|
|
2348
|
-
live: liveWorkerCount(),
|
|
2349
|
-
queued: queuedWorkerCount(),
|
|
2350
|
-
freeSlots: freeWorkerSlots(),
|
|
2351
|
-
...priorHistory,
|
|
2352
|
-
...resourcePaths.resolved.length === 0 ? {} : { resourcesFromPath: resourcePaths.resolved }
|
|
2353
|
-
} : {
|
|
2354
|
-
error: res.reason,
|
|
2355
|
-
reason: spawnRefusalReason(res.reason, res.shortfalls, {
|
|
2356
|
-
usdUnbudgeted: "this run's root budget declares no maxUsd, so a child budget naming maxUsd can never be admitted at any amount — spawn with a budget that omits maxUsd",
|
|
2357
|
-
inDoubt: "this key has a prior worker recorded as started without a terminal receipt; no replacement was started because that remote worker may still be running — inspect or recover the exact prior execution before retrying",
|
|
2358
|
-
scopeSettled: "this run has already reached its join barrier — its driver returned and the supervisor is settling, so no further worker can be started, joined, or paid for; record this stage as not started"
|
|
2359
|
-
}),
|
|
2360
|
-
...res.shortfalls === void 0 ? {} : { shortfalls: res.shortfalls },
|
|
2361
|
-
...res.reason === "usd-unbudgeted" ? { hint: "This run's root budget declares no maxUsd, so a child budget naming maxUsd can never be admitted — at any amount. Retrying with a smaller maxUsd will fail identically. Spawn with a budget that omits maxUsd, or ask the caller to give the run a root maxUsd." } : res.reason === "in-doubt" ? { hint: "Do not retry this key. Use the recorded prior worker identity to inspect or recover that exact execution. A terminal receipt or explicit recovery is required before replacement work can start." } : {},
|
|
2362
|
-
live: liveWorkerCount(),
|
|
2363
|
-
freeSlots: freeWorkerSlots()
|
|
2383
|
+
return admitSpawn({
|
|
2384
|
+
profile,
|
|
2385
|
+
args: a,
|
|
2386
|
+
task: a.task,
|
|
2387
|
+
key,
|
|
2388
|
+
continuity,
|
|
2389
|
+
successorOf,
|
|
2390
|
+
preflightProfile: () => opts.resolveSpawnProfile ? detachedFrozen(opts.resolveSpawnProfile(profile)) : profile,
|
|
2391
|
+
resourcesFromPath: resourcePaths.resolved,
|
|
2392
|
+
defaultLabel: "worker"
|
|
2364
2393
|
});
|
|
2365
2394
|
}
|
|
2366
2395
|
},
|
|
@@ -3031,6 +3060,79 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
3031
3060
|
handler: async (raw) => readJournal(raw, false)
|
|
3032
3061
|
} : tool));
|
|
3033
3062
|
}
|
|
3063
|
+
if (opts.graphs) {
|
|
3064
|
+
const graphs = opts.graphs;
|
|
3065
|
+
tools.push({
|
|
3066
|
+
name: "run_graph",
|
|
3067
|
+
description: "Run an agent graph as ONE subtask instead of one worker: a fixed topology whose nodes are profiles and whose edges carry directives, driven by its root node. Pass `graph` ({ nodes: [{ id, profile }], edges: [{ kind: 'delegates', from, to, directive: 'delegates/worker-brief/v1' }] }, where each profile.name equals its node id and the root node grants agent_runtime_coordination_spawn_worker) or `graphDigest` (a graph stored in this run's graph registry). `deliverable` is what the graph must deliver; it becomes the root node's task. The subtask reserves `budget` (merged over the per-worker default, as for spawn_worker) from your conserved pool, and the whole graph spends only that. Every node runs its own pinned profile; the run keeps its checks and graders, which are never graph nodes. Returns a workerId as spawn_worker does; end your turn and you are woken when the graph settles. Its output is { deliverable, edges }: the root node's result and the edge ledger (every traversal, also recorded in the run journal).",
|
|
3068
|
+
inputSchema: {
|
|
3069
|
+
type: "object",
|
|
3070
|
+
properties: {
|
|
3071
|
+
graph: {
|
|
3072
|
+
type: "object",
|
|
3073
|
+
description: "The graph as data: { nodes: [{ id, profile }], edges: [...] }. Delegates edges run from the root to each worker node; an optional analyzes edge ({ kind: 'analyzes', analyst, over, to, directive }) names an analyst node.",
|
|
3074
|
+
additionalProperties: true
|
|
3075
|
+
},
|
|
3076
|
+
graphDigest: {
|
|
3077
|
+
type: "string",
|
|
3078
|
+
description: "A stored graph's digest in this run's graph registry, instead of graph."
|
|
3079
|
+
},
|
|
3080
|
+
deliverable: {
|
|
3081
|
+
type: "string",
|
|
3082
|
+
description: "What the graph must deliver. It becomes the root node's task."
|
|
3083
|
+
},
|
|
3084
|
+
budget: spawnBudgetArg,
|
|
3085
|
+
label: {
|
|
3086
|
+
type: "string",
|
|
3087
|
+
description: "Optional trace label."
|
|
3088
|
+
},
|
|
3089
|
+
key: {
|
|
3090
|
+
type: "string",
|
|
3091
|
+
description: "Optional semantic name for this subtask. The same key never runs twice, as for spawn_worker: a completed key returns its committed result."
|
|
3092
|
+
}
|
|
3093
|
+
},
|
|
3094
|
+
required: ["deliverable"]
|
|
3095
|
+
},
|
|
3096
|
+
handler: async (raw) => {
|
|
3097
|
+
const a = obj(raw);
|
|
3098
|
+
const deliverable = typeof a.deliverable === "string" ? a.deliverable.trim() : "";
|
|
3099
|
+
if (deliverable.length === 0) return {
|
|
3100
|
+
error: "invalid-graph",
|
|
3101
|
+
reason: "deliverable must be a non-empty string: what the graph must deliver"
|
|
3102
|
+
};
|
|
3103
|
+
if (a.graph === void 0 === (a.graphDigest === void 0)) return {
|
|
3104
|
+
error: "invalid-graph",
|
|
3105
|
+
reason: "pass exactly one of graph (the graph as data) or graphDigest (a stored graph)"
|
|
3106
|
+
};
|
|
3107
|
+
if (a.graphDigest !== void 0 && typeof a.graphDigest !== "string") return {
|
|
3108
|
+
error: "invalid-graph",
|
|
3109
|
+
reason: "graphDigest must be a string"
|
|
3110
|
+
};
|
|
3111
|
+
const key = a.key === void 0 ? void 0 : str(a.key, "key");
|
|
3112
|
+
const prepared = await graphs.prepare(typeof a.graphDigest === "string" ? { graphDigest: a.graphDigest } : { graph: a.graph });
|
|
3113
|
+
if (!prepared.ok) return {
|
|
3114
|
+
error: "invalid-graph",
|
|
3115
|
+
reason: prepared.reason
|
|
3116
|
+
};
|
|
3117
|
+
const profile = detachedFrozen(prepared.profile);
|
|
3118
|
+
return admitSpawn({
|
|
3119
|
+
profile,
|
|
3120
|
+
args: a,
|
|
3121
|
+
task: deliverable,
|
|
3122
|
+
key,
|
|
3123
|
+
continuity: { continuity: "fresh" },
|
|
3124
|
+
successorOf: void 0,
|
|
3125
|
+
preflightProfile: () => opts.resolveSpawnProfile ? detachedFrozen(opts.resolveSpawnProfile(profile)) : profile,
|
|
3126
|
+
resourcesFromPath: [],
|
|
3127
|
+
defaultLabel: `graph:${prepared.root}`,
|
|
3128
|
+
accepted: { graph: {
|
|
3129
|
+
root: prepared.root,
|
|
3130
|
+
nodes: prepared.nodes
|
|
3131
|
+
} }
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
});
|
|
3135
|
+
}
|
|
3034
3136
|
if (opts.analysts) {
|
|
3035
3137
|
tools.push({
|
|
3036
3138
|
name: "list_analysts",
|
|
@@ -4600,6 +4702,7 @@ function driverAgent(opts) {
|
|
|
4600
4702
|
scope,
|
|
4601
4703
|
blobs: opts.blobs,
|
|
4602
4704
|
makeWorkerAgent: opts.makeWorkerAgent,
|
|
4705
|
+
...opts.graphs ? { graphs: opts.graphs } : {},
|
|
4603
4706
|
...opts.authorizeDownMessage ? { authorizeDownMessage: opts.authorizeDownMessage } : {},
|
|
4604
4707
|
perWorker: opts.perWorker,
|
|
4605
4708
|
...opts.deliverable ? { deliverable: opts.deliverable } : {},
|
|
@@ -5008,4 +5111,4 @@ function safeJson(v) {
|
|
|
5008
5111
|
//#endregion
|
|
5009
5112
|
export { ANALYST_DEFINITION_BOUNDS as A, createEventBus as B, createFileRunContext as C, foldCoordinationRecords as D, FileCoordinationLog as E, createCoordinationToolsForManager as F, watchTrace as H, downMessageRefusalReasons as I, normalizeAnalyzeOnSettle as L, canonicalFindingEvent as M, coordinationVerbNames as N, applyRunCancellation as O, createCoordinationTools as P, parseAuthoredAnalystDefinition as R, renderAnytimeTable as S, withRunContext as T, defaultToolDetectors as V, sampleFromSettled as _, DEFAULT_DEADLINE_WARNING_MS as a, bestSoFar as b, refreshedWake as c, allWorkersStalled as d, anyOf as f, progressStop as g, plateau as h, finalizeBestDelivered as i, analystToolGroupNames as j, watchRunCancellation as k, resolveWakePolicy as l, noProgressFor as m, createSteerAcknowledger as n, composeWakeInput as o, createProgressTracker as p, driverAgent as r, deadlineWarningAt as s, createCancelAcknowledger as t, allOf as u, anytimeReport as v, createInMemoryRunContext as w, plateauLength as x, areaUnderCurve as y, questionEscalationTargets as z };
|
|
5010
5113
|
|
|
5011
|
-
//# sourceMappingURL=coordination-driver-
|
|
5114
|
+
//# sourceMappingURL=coordination-driver-Bx7nXmOs.js.map
|