@tangle-network/agent-runtime 0.323.0 → 0.325.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/dist/{activation-DpipXGti.js → activation--9-iyGR8.js} +3 -3
- package/dist/{activation-DpipXGti.js.map → activation--9-iyGR8.js.map} +1 -1
- package/dist/{activation-D4hHi27J.d.ts → activation-Q3CJgiCu.d.ts} +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{bundle-Cw-QdGmH.js → bundle-BJJmfEsw.js} +2 -2
- package/dist/{bundle-Cw-QdGmH.js.map → bundle-BJJmfEsw.js.map} +1 -1
- package/dist/candidate-execution/index.js +5 -5
- package/dist/{coordination-driver-COSL19sL.js → coordination-driver-DkkUVe9g.js} +271 -156
- package/dist/coordination-driver-DkkUVe9g.js.map +1 -0
- package/dist/{delegate-silSKPSB.js → delegate-BDsaIl2K.js} +2 -2
- package/dist/{delegate-silSKPSB.js.map → delegate-BDsaIl2K.js.map} +1 -1
- package/dist/{durable-file-DWQA4ooo.js → durable-file-B_eJr6Mb.js} +40 -8
- package/dist/durable-file-B_eJr6Mb.js.map +1 -0
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +70 -40
- package/dist/durable.js.map +1 -1
- package/dist/graph-Cuz6Ubzd.js +348 -0
- package/dist/graph-Cuz6Ubzd.js.map +1 -0
- package/dist/{graph-registry-BuJbzTzF.js → graph-registry-DAI6KNXB.js} +19 -34
- package/dist/graph-registry-DAI6KNXB.js.map +1 -0
- package/dist/{improvement-cycle-BeN9wahG.js → improvement-cycle-B5Z8cHKx.js} +10 -10
- package/dist/{improvement-cycle-BeN9wahG.js.map → improvement-cycle-B5Z8cHKx.js.map} +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +3 -3
- package/dist/intelligence.js +7 -7
- package/dist/jsonl-file-DBv31uPi.js +206 -0
- package/dist/jsonl-file-DBv31uPi.js.map +1 -0
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +13 -13
- package/dist/{loop-runner-bin-DkhIbFBp.js → loop-runner-bin-C16VR9cI.js} +3 -3
- package/dist/{loop-runner-bin-DkhIbFBp.js.map → loop-runner-bin-C16VR9cI.js.map} +1 -1
- package/dist/{loop-runner-bin-Bsux_MGx.d.ts → loop-runner-bin-Co7JKSwi.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 +6 -6
- package/dist/{model-policy-CNe257pB.js → model-policy-CyCUwHed.js} +2 -2
- package/dist/model-policy-CyCUwHed.js.map +1 -0
- package/dist/{openai-tools-e02ABKl0.d.ts → openai-tools-CbgZrQJ_.d.ts} +2 -2
- package/dist/{prepare-CFQLx9e3.js → prepare-DpavgJT8.js} +4 -4
- package/dist/{prepare-CFQLx9e3.js.map → prepare-DpavgJT8.js.map} +1 -1
- package/dist/{profile-BTbpdL9h.js → profile-ZS7_KLwK.js} +2 -2
- package/dist/{profile-BTbpdL9h.js.map → profile-ZS7_KLwK.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{protected-model-port-f1N2f0Uq.js → protected-model-port-BLyyfL3l.js} +4 -4
- package/dist/{protected-model-port-f1N2f0Uq.js.map → protected-model-port-BLyyfL3l.js.map} +1 -1
- package/dist/{protected-redaction-DylCC_ot.js → protected-redaction-DFCeo4vg.js} +2 -2
- package/dist/{protected-redaction-DylCC_ot.js.map → protected-redaction-DFCeo4vg.js.map} +1 -1
- package/dist/{provision-supervisor-DdWu6mqu.js → provision-supervisor-4BoHpGFJ.js} +7 -7
- package/dist/{provision-supervisor-DdWu6mqu.js.map → provision-supervisor-4BoHpGFJ.js.map} +1 -1
- package/dist/{run-layout-DSCWdbX2.js → run-layout-Cu8H7aeh.js} +2 -2
- package/dist/{run-layout-DSCWdbX2.js.map → run-layout-Cu8H7aeh.js.map} +1 -1
- package/dist/{runtime-DhPIc7XV.js → runtime-B9X_U-aV.js} +84 -80
- package/dist/runtime-B9X_U-aV.js.map +1 -0
- package/dist/{search-executor-BS-WJpti.js → search-executor-C-b4NaFl.js} +13 -5
- package/dist/search-executor-C-b4NaFl.js.map +1 -0
- package/dist/{server-CEDOUOdz.js → server-CcHaXgUT.js} +4 -4
- package/dist/{server-CEDOUOdz.js.map → server-CcHaXgUT.js.map} +1 -1
- package/dist/{supervise-CwWI7kIk.js → supervise-BlaB4CeL.js} +739 -22
- package/dist/supervise-BlaB4CeL.js.map +1 -0
- package/dist/{supervisor-CSKkm-e1.js → supervisor-fq4JGynd.js} +10940 -10787
- package/dist/supervisor-fq4JGynd.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +14 -14
- package/dist/{top-app-DaiR4LXM.js → top-app-BaMw1W2z.js} +2 -2
- package/dist/{top-app-DaiR4LXM.js.map → top-app-BaMw1W2z.js.map} +1 -1
- package/dist/tui/bin.js +1 -1
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{index-7h7-L6Tk.d.ts → types-5r334mcg.d.ts} +17425 -17267
- package/dist/{workspace-streams-DFAhW7hF.js → workspace-streams-CcoARX4v.js} +2 -2
- package/dist/{workspace-streams-DFAhW7hF.js.map → workspace-streams-CcoARX4v.js.map} +1 -1
- package/package.json +3 -3
- package/skills/profile-authoring/SKILL.md +1 -1
- package/dist/coordination-driver-COSL19sL.js.map +0 -1
- package/dist/durable-file-DWQA4ooo.js.map +0 -1
- package/dist/graph-DbQ-BXKr.js +0 -805
- package/dist/graph-DbQ-BXKr.js.map +0 -1
- package/dist/graph-registry-BuJbzTzF.js.map +0 -1
- package/dist/model-policy-CNe257pB.js.map +0 -1
- package/dist/runtime-DhPIc7XV.js.map +0 -1
- package/dist/search-executor-BS-WJpti.js.map +0 -1
- package/dist/supervise-CwWI7kIk.js.map +0 -1
- package/dist/supervisor-CSKkm-e1.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $i as InMemorySpawnJournal, Ai as settlementFailureCause, Bt as createRouterTranscript, Ct as checkVerdictOf, Dt as failedItems, En as runBrainLoop, Ft as createExecutorRegistry, J as scopeRetainedOwnerResourceReader, Qi as InMemoryResultBlobStore, T as meterRuntimeOwnedProviderAttempt, Xi as FileResultBlobStore, Zi as FileSpawnJournal, Zt as createInbox, at as runtimeGraphMetadataKey, c as runTree, ca as workerTraceAnalysisStore, ga as assertValidBudget, i as bestDelivered, la as contentAddress, nn as createPeerMailbox, o as pickBestDelivered, on as isLiveNodeStatus, pa as errMessage, pi as providerAttemptEvidence, s as runFinalizer, sa as parseWorkerToolTraceArtifact, sn as isTerminalNodeStatus, tt as resolveSpawnResourcePaths, ua as detachedFrozen, v as withDriverExecutor, w as meterRuntimeOwnedAccounting, wa as resolveRedactor, yt as CheckUnavailableError } from "./supervisor-fq4JGynd.js";
|
|
2
2
|
import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import { $ as promptCacheTokenClasses, U as chargedTokens, dt as addResourceSpend, mt as withBudgetResources, st as unmeteredSpend } from "./workspace-streams-
|
|
4
|
-
import {
|
|
3
|
+
import { $ as promptCacheTokenClasses, U as chargedTokens, dt as addResourceSpend, mt as withBudgetResources, st as unmeteredSpend } from "./workspace-streams-CcoARX4v.js";
|
|
4
|
+
import { a as readCommittedJsonLines, t as appendCommittedJsonLine } from "./jsonl-file-DBv31uPi.js";
|
|
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";
|
|
5
6
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
6
7
|
import { argHash, errorStreakDetector, observeAll, repeatedActionDetector } from "@tangle-network/agent-eval";
|
|
8
|
+
import { registry } from "zod";
|
|
7
9
|
import { randomUUID } from "node:crypto";
|
|
8
10
|
import { mkdirSync, readFileSync, watch } from "node:fs";
|
|
9
11
|
import { join } from "node:path";
|
|
10
|
-
import { registry } from "zod";
|
|
11
12
|
//#region src/runtime/supervise/detector-monitor.ts
|
|
12
13
|
/**
|
|
13
14
|
*
|
|
@@ -549,7 +550,8 @@ const coordinationVerbNames = [
|
|
|
549
550
|
"read_journal",
|
|
550
551
|
"list_analysts",
|
|
551
552
|
"run_analyst",
|
|
552
|
-
"define_analyst"
|
|
553
|
+
"define_analyst",
|
|
554
|
+
"run_graph"
|
|
553
555
|
];
|
|
554
556
|
/**
|
|
555
557
|
* The `CoordinationEvent` kinds that wake a waiting manager. The queue carries the UP-leg only:
|
|
@@ -568,6 +570,47 @@ const idArg = {
|
|
|
568
570
|
type: "string",
|
|
569
571
|
description: "The workerId returned by spawn_worker."
|
|
570
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
|
+
};
|
|
571
614
|
/**
|
|
572
615
|
* Strip zod's object-KEY CODEC artifact from a derived JSON Schema, at every depth.
|
|
573
616
|
*
|
|
@@ -873,7 +916,8 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
873
916
|
status: "down",
|
|
874
917
|
...settled.outRef === void 0 ? {} : { outRef: settled.outRef },
|
|
875
918
|
...node?.spent === void 0 ? {} : { spent: node.spent },
|
|
876
|
-
reason: settled.reason
|
|
919
|
+
reason: settled.reason,
|
|
920
|
+
failure: settlementFailureCause(settled)
|
|
877
921
|
});
|
|
878
922
|
};
|
|
879
923
|
const analysisRoutes = (opts.analyzeOnSettle ?? []).map(normalizeAnalyzeOnSettle);
|
|
@@ -1294,6 +1338,11 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1294
1338
|
}, { analyst: route.kind });
|
|
1295
1339
|
} catch {}
|
|
1296
1340
|
};
|
|
1341
|
+
const analystRunContext = (kind, sourceWorker) => ({ charge: (spend) => meterRuntimeOwnedAccounting(opts.scope, spend, {
|
|
1342
|
+
role: "analyst",
|
|
1343
|
+
analyst: kind,
|
|
1344
|
+
sourceWorker
|
|
1345
|
+
}, { alreadySpent: true }) });
|
|
1297
1346
|
let flushing = 0;
|
|
1298
1347
|
const flushPendingSettlement = async () => {
|
|
1299
1348
|
flushing += 1;
|
|
@@ -1327,9 +1376,21 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1327
1376
|
const lensRoutes = applicable.filter((route) => route.agent === void 0);
|
|
1328
1377
|
const agentRoutes = applicable.filter((route) => route.agent !== void 0);
|
|
1329
1378
|
if (lensRoutes.length > 0 && opts.analysts && pending.worker.trace.status === "available") {
|
|
1330
|
-
|
|
1379
|
+
let trace;
|
|
1380
|
+
let traceFailure;
|
|
1381
|
+
try {
|
|
1382
|
+
trace = await workerTraceAnalysisStore(pending.worker.trace, opts.blobs);
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
traceFailure = error;
|
|
1385
|
+
}
|
|
1331
1386
|
for (const route of lensRoutes) {
|
|
1332
|
-
|
|
1387
|
+
let findings;
|
|
1388
|
+
try {
|
|
1389
|
+
if (trace === void 0) throw traceFailure;
|
|
1390
|
+
findings = await opts.analysts.run(route.kind, trace, analystRunContext(route.kind, pending.worker.id));
|
|
1391
|
+
} catch (error) {
|
|
1392
|
+
findings = { analystRunFailed: errMessage(error) };
|
|
1393
|
+
}
|
|
1333
1394
|
await bus.publish({
|
|
1334
1395
|
type: "finding",
|
|
1335
1396
|
finding: canonicalFindingEvent({
|
|
@@ -2117,6 +2178,107 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2117
2178
|
idleMs: Date.now() - startedAt
|
|
2118
2179
|
});
|
|
2119
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
|
+
};
|
|
2120
2282
|
const tools = [
|
|
2121
2283
|
{
|
|
2122
2284
|
name: "spawn_worker",
|
|
@@ -2143,46 +2305,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2143
2305
|
type: "string",
|
|
2144
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`."
|
|
2145
2307
|
},
|
|
2146
|
-
budget:
|
|
2147
|
-
type: "object",
|
|
2148
|
-
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.",
|
|
2149
|
-
properties: {
|
|
2150
|
-
maxIterations: {
|
|
2151
|
-
type: "number",
|
|
2152
|
-
minimum: 0
|
|
2153
|
-
},
|
|
2154
|
-
maxTokens: {
|
|
2155
|
-
type: "number",
|
|
2156
|
-
minimum: 0
|
|
2157
|
-
},
|
|
2158
|
-
maxUsd: {
|
|
2159
|
-
type: "number",
|
|
2160
|
-
minimum: 0
|
|
2161
|
-
},
|
|
2162
|
-
deadlineMs: {
|
|
2163
|
-
type: "number",
|
|
2164
|
-
minimum: 0
|
|
2165
|
-
},
|
|
2166
|
-
resources: {
|
|
2167
|
-
type: "object",
|
|
2168
|
-
additionalProperties: {
|
|
2169
|
-
type: "object",
|
|
2170
|
-
properties: {
|
|
2171
|
-
unit: {
|
|
2172
|
-
type: "string",
|
|
2173
|
-
minLength: 1
|
|
2174
|
-
},
|
|
2175
|
-
limit: {
|
|
2176
|
-
type: "integer",
|
|
2177
|
-
minimum: 0,
|
|
2178
|
-
maximum: Number.MAX_SAFE_INTEGER
|
|
2179
|
-
}
|
|
2180
|
-
},
|
|
2181
|
-
required: ["unit", "limit"]
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2308
|
+
budget: spawnBudgetArg
|
|
2186
2309
|
},
|
|
2187
2310
|
required: ["profile", "task"]
|
|
2188
2311
|
},
|
|
@@ -2221,6 +2344,17 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2221
2344
|
message: issue.message
|
|
2222
2345
|
}))
|
|
2223
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
|
+
}
|
|
2224
2358
|
const profile = detachedFrozen(opts.composeSpawnProfile ? agentProfileSchema.parse(opts.composeSpawnProfile(parsedProfile.data)) : parsedProfile.data);
|
|
2225
2359
|
const continuity = resolveContinuity(parseContinuity(a.continuity), profile.name, key);
|
|
2226
2360
|
if ("error" in continuity) return Promise.resolve({
|
|
@@ -2246,102 +2380,16 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2246
2380
|
freeSlots: freeWorkerSlots()
|
|
2247
2381
|
};
|
|
2248
2382
|
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
preflightCounts[refusal.cause] += 1;
|
|
2260
|
-
return {
|
|
2261
|
-
error: "preflight-refused",
|
|
2262
|
-
reason: `the spawn pre-flight refused this profile (${refusal.cause}): ${refusal.detail}`,
|
|
2263
|
-
cause: refusal.cause,
|
|
2264
|
-
detail: refusal.detail,
|
|
2265
|
-
live: liveWorkerCount(),
|
|
2266
|
-
freeSlots: freeWorkerSlots()
|
|
2267
|
-
};
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
const budget = Object.freeze(a.budget === void 0 ? opts.perWorker : mergeBudget(opts.perWorker, a.budget));
|
|
2271
|
-
const assignmentId = key !== void 0 ? `key:${key}` : `ordinal:${unkeyedAssignmentOrdinal++}`;
|
|
2272
|
-
const peerMailUrl = peerMail?.mintCapability(assignmentId);
|
|
2273
|
-
const context = Object.freeze({
|
|
2274
|
-
assignmentId,
|
|
2275
|
-
parentNodeId: opts.scope.view.root,
|
|
2276
|
-
budget,
|
|
2277
|
-
task,
|
|
2278
|
-
label,
|
|
2279
|
-
...key !== void 0 ? { key } : {},
|
|
2280
|
-
continuity: continuity.continuity,
|
|
2281
|
-
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
2282
|
-
...successorOf !== void 0 ? { successorOf } : {},
|
|
2283
|
-
...peerMailUrl !== void 0 ? { peerMailUrl } : {}
|
|
2284
|
-
});
|
|
2285
|
-
const res = opts.scope.spawn(() => opts.makeWorkerAgent(profile, context), task, {
|
|
2286
|
-
budget,
|
|
2287
|
-
label,
|
|
2288
|
-
assignmentId,
|
|
2289
|
-
...key !== void 0 ? { key } : {},
|
|
2290
|
-
...successorOf !== void 0 ? { successorOf } : {}
|
|
2291
|
-
});
|
|
2292
|
-
if (res.ok && res.prior?.state === "completed") {
|
|
2293
|
-
const s = res.prior.settled;
|
|
2294
|
-
const { id, status, resumed: _resumed, ...evidence } = projectSettled(s);
|
|
2295
|
-
return Promise.resolve({
|
|
2296
|
-
workerId: id,
|
|
2297
|
-
resumed: "completed",
|
|
2298
|
-
status,
|
|
2299
|
-
...evidence,
|
|
2300
|
-
...evidence.outRef === void 0 ? {} : { outputRead: {
|
|
2301
|
-
tool: "observe_agent",
|
|
2302
|
-
arguments: { workerId: id }
|
|
2303
|
-
} },
|
|
2304
|
-
live: liveWorkerCount(),
|
|
2305
|
-
freeSlots: freeWorkerSlots()
|
|
2306
|
-
});
|
|
2307
|
-
}
|
|
2308
|
-
if (res.ok) {
|
|
2309
|
-
watchWorker(res.handle.id);
|
|
2310
|
-
liveHandles.set(res.handle.id, res.handle);
|
|
2311
|
-
peerMail?.bindCapability(assignmentId, res.handle.id);
|
|
2312
|
-
if (typeof profile.name === "string" && profile.name.length > 0) profileNameByWorker.set(res.handle.id, profile.name);
|
|
2313
|
-
}
|
|
2314
|
-
const priorHistory = res.ok && res.prior !== void 0 && res.prior.state !== "completed" ? {
|
|
2315
|
-
resumed: res.prior.state,
|
|
2316
|
-
priorWorkerId: res.prior.priorId,
|
|
2317
|
-
...res.prior.state === "retried" ? { priorReason: res.prior.reason } : {}
|
|
2318
|
-
} : {};
|
|
2319
|
-
return Promise.resolve(res.ok ? {
|
|
2320
|
-
workerId: res.handle.id,
|
|
2321
|
-
assignmentId: res.handle.assignmentId ?? assignmentId,
|
|
2322
|
-
...res.handle.identity === void 0 ? {} : { identity: res.handle.identity },
|
|
2323
|
-
...res.handle.materialization === void 0 ? {} : { materialization: res.handle.materialization },
|
|
2324
|
-
...res.handle.executionBindings === void 0 ? {} : { executionBindings: res.handle.executionBindings },
|
|
2325
|
-
continuity: continuity.continuity,
|
|
2326
|
-
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
2327
|
-
...successorOf !== void 0 ? { successorOf } : {},
|
|
2328
|
-
status: res.handle.status,
|
|
2329
|
-
live: liveWorkerCount(),
|
|
2330
|
-
queued: queuedWorkerCount(),
|
|
2331
|
-
freeSlots: freeWorkerSlots(),
|
|
2332
|
-
...priorHistory,
|
|
2333
|
-
...resourcePaths.resolved.length === 0 ? {} : { resourcesFromPath: resourcePaths.resolved }
|
|
2334
|
-
} : {
|
|
2335
|
-
error: res.reason,
|
|
2336
|
-
reason: spawnRefusalReason(res.reason, res.shortfalls, {
|
|
2337
|
-
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",
|
|
2338
|
-
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",
|
|
2339
|
-
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"
|
|
2340
|
-
}),
|
|
2341
|
-
...res.shortfalls === void 0 ? {} : { shortfalls: res.shortfalls },
|
|
2342
|
-
...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." } : {},
|
|
2343
|
-
live: liveWorkerCount(),
|
|
2344
|
-
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"
|
|
2345
2393
|
});
|
|
2346
2394
|
}
|
|
2347
2395
|
},
|
|
@@ -3012,6 +3060,79 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
3012
3060
|
handler: async (raw) => readJournal(raw, false)
|
|
3013
3061
|
} : tool));
|
|
3014
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
|
+
}
|
|
3015
3136
|
if (opts.analysts) {
|
|
3016
3137
|
tools.push({
|
|
3017
3138
|
name: "list_analysts",
|
|
@@ -3067,7 +3188,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
3067
3188
|
error: "unknown-analyst",
|
|
3068
3189
|
reason: `no lens named ${JSON.stringify(kind)} is on this manager's menu; call list_analysts to see what you may run`
|
|
3069
3190
|
};
|
|
3070
|
-
return { findings: await opts.analysts?.run(kind, store) };
|
|
3191
|
+
return { findings: await opts.analysts?.run(kind, store, analystRunContext(kind, id)) };
|
|
3071
3192
|
}
|
|
3072
3193
|
});
|
|
3073
3194
|
if (opts.analysts.register) tools.push({
|
|
@@ -3498,21 +3619,14 @@ var FileCoordinationLog = class {
|
|
|
3498
3619
|
}
|
|
3499
3620
|
async appendRecord(runId, busRecord, ownerId) {
|
|
3500
3621
|
const fs = await import("node:fs/promises");
|
|
3501
|
-
const
|
|
3502
|
-
await fs.mkdir(
|
|
3622
|
+
const { dirname } = await import("node:path");
|
|
3623
|
+
await fs.mkdir(dirname(this.path), { recursive: true });
|
|
3503
3624
|
const record = {
|
|
3504
3625
|
runId,
|
|
3505
3626
|
...ownerId !== void 0 ? { ownerId } : {},
|
|
3506
3627
|
...busRecord
|
|
3507
3628
|
};
|
|
3508
|
-
|
|
3509
|
-
const fh = await fs.open(this.path, "a");
|
|
3510
|
-
try {
|
|
3511
|
-
await writeAllBytes(fh, `${needsSeparator ? "\n" : ""}${JSON.stringify(record)}\n`);
|
|
3512
|
-
await fh.sync();
|
|
3513
|
-
} finally {
|
|
3514
|
-
await fh.close();
|
|
3515
|
-
}
|
|
3629
|
+
await appendCommittedJsonLine(this.path, record);
|
|
3516
3630
|
}
|
|
3517
3631
|
async load(runId, ownerId) {
|
|
3518
3632
|
return foldCoordinationRecords(readCommittedJsonLines(this.path, { allowMissing: true }), runId, ownerId);
|
|
@@ -4588,6 +4702,7 @@ function driverAgent(opts) {
|
|
|
4588
4702
|
scope,
|
|
4589
4703
|
blobs: opts.blobs,
|
|
4590
4704
|
makeWorkerAgent: opts.makeWorkerAgent,
|
|
4705
|
+
...opts.graphs ? { graphs: opts.graphs } : {},
|
|
4591
4706
|
...opts.authorizeDownMessage ? { authorizeDownMessage: opts.authorizeDownMessage } : {},
|
|
4592
4707
|
perWorker: opts.perWorker,
|
|
4593
4708
|
...opts.deliverable ? { deliverable: opts.deliverable } : {},
|
|
@@ -4996,4 +5111,4 @@ function safeJson(v) {
|
|
|
4996
5111
|
//#endregion
|
|
4997
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 };
|
|
4998
5113
|
|
|
4999
|
-
//# sourceMappingURL=coordination-driver-
|
|
5114
|
+
//# sourceMappingURL=coordination-driver-DkkUVe9g.js.map
|