@tangle-network/agent-runtime 0.123.1 → 0.128.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/README.md +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{environment-provider-PM9PeW_J.d.ts → environment-provider-CUFsyymu.d.ts} +7 -1
- package/dist/environment-provider.d.ts +1 -1
- package/dist/{index-xP27vtnt.d.ts → index-BhZhQw77.d.ts} +247 -145
- package/dist/{index-4NcThsDc.d.ts → index-BhuzfG2r.d.ts} +3 -3
- package/dist/{index-CQBioeAj.d.ts → index-DLM0W1h1.d.ts} +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +1 -1
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +3 -3
- package/dist/{knowledge-BOHj6nGh.js → knowledge-DF63xPr4.js} +2 -2
- package/dist/{knowledge-BOHj6nGh.js.map → knowledge-DF63xPr4.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-DUM37LLw.js → loop-runner-bin-CWqOpCEw.js} +3 -3
- package/dist/{loop-runner-bin-DUM37LLw.js.map → loop-runner-bin-CWqOpCEw.js.map} +1 -1
- package/dist/{loop-runner-bin-DMnNxZHw.d.ts → loop-runner-bin-Ckp_9tmD.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +1 -1
- package/dist/mcp/index.d.ts +3 -7
- package/dist/mcp/index.js +3 -3
- package/dist/{openai-tools-Bm1SDJIp.js → openai-tools-D3XfrrQ6.js} +2 -2
- package/dist/{openai-tools-Bm1SDJIp.js.map → openai-tools-D3XfrrQ6.js.map} +1 -1
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/{runtime-DZblIf3R.js → runtime-5uDVVfER.js} +444 -132
- package/dist/runtime-5uDVVfER.js.map +1 -0
- package/dist/{supervise-Cx24b3lw.js → supervise-CsTKbH9R.js} +209 -24
- package/dist/supervise-CsTKbH9R.js.map +1 -0
- package/dist/testing.js +8 -8
- package/package.json +4 -4
- package/skills/agent-graphs/IMPROVE.md +58 -0
- package/skills/agent-graphs/SKILL.md +140 -0
- package/skills/agent-graphs/cases/artifact-mission-release-notes.json +10 -0
- package/skills/agent-graphs/cases/audited-single-writer.json +9 -0
- package/skills/agent-graphs/cases/cap-as-stop-mistake.json +8 -0
- package/skills/agent-graphs/cases/floor-trap-pi.json +11 -0
- package/skills/agent-graphs/cases/mission-in-deliverable.json +8 -0
- package/skills/agent-graphs/cases/review-pipeline.json +14 -0
- package/skills/agent-graphs/cases/runtime-discovered-fanout.json +8 -0
- package/skills/agent-graphs/cases/single-agent-suffices.json +7 -0
- package/skills/agent-graphs/cases/steer-heavy-drafting.json +9 -0
- package/skills/agent-graphs/cases/unmeasured-harness.json +9 -0
- package/skills/agent-graphs/generations/gen1-baseline.json +248 -0
- package/skills/agent-graphs/generations/gen2.json +375 -0
- package/skills/agent-graphs/generations/gen3.json +702 -0
- package/skills/build-with-agent-runtime/SKILL.md +1 -0
- package/dist/runtime-DZblIf3R.js.map +0 -1
- package/dist/supervise-Cx24b3lw.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as RuntimeRunStateError, i as ConfigError, o as NotFoundError, t as AgentEvalError$1, u as ValidationError } from "./errors-DEAvWQPy.js";
|
|
2
|
-
import { S as detachedSnapshot, b as workerTraceAnalysisStore, d as writeAllBytes, i as InMemorySpawnJournal, l as parseCommittedJsonLines, n as FileSpawnJournal, r as InMemoryResultBlobStore, t as FileResultBlobStore, u as prepareJsonlAppend, x as contentAddress } from "./spawn-journal-DsZKDqeh.js";
|
|
2
|
+
import { S as detachedSnapshot, b as workerTraceAnalysisStore, d as writeAllBytes, i as InMemorySpawnJournal, l as parseCommittedJsonLines, n as FileSpawnJournal, r as InMemoryResultBlobStore, t as FileResultBlobStore, u as prepareJsonlAppend, x as contentAddress, y as parseWorkerToolTraceArtifact } from "./spawn-journal-DsZKDqeh.js";
|
|
3
3
|
import { a as randomSuffix, c as stringifySafe, d as withTimeout, f as zeroTokenUsage, i as mapWithConcurrency, l as throwAbort, n as deleteBoxSafe, o as randomUuid, s as sleep, t as addTokenUsage, u as throwIfAborted } from "./util-MVgdwuIS.js";
|
|
4
4
|
import { $t as concreteProfileModel, At as controlProfileMaterialization, Ct as runWorktreeHarness, Dt as removeWorktree, Et as createWorktree, F as toOtelAttributes, Ft as promptModelProfileMaterialization, J as createActivityLog, Mt as fullProfileMaterialization, Nt as profileMaterializationAxes, O as createOtelExporter, Pt as promptControlProfileMaterialization, Q as freeSlots, Qt as concreteModelId, St as runWorktreeChecks, T as buildLoopSpanNodes, Tt as captureWorktreeDiff, Vt as worktreeCliProfileMaterialization, Xt as assertModelAllowed, Y as describeToolArgs, Zt as assertProfileModelsAllowed, _ as workerTraceEnv, _t as routerChatWithUsage, a as pickBestDelivered, at as assertValidBudget, b as mergeTraceEnv, bt as runBrainLoop, c as driverChild, ct as attestRuntimeOwnedExecutor, d as deriveNodeExecutionIdentity, dt as newExecutionAttemptId, en as isHarnessNativeModel, f as recordScopeOwnerMaterialization, ft as runtimeOwnedExecutorExecutionBinding, h as WORKER_TRACE_PROPAGATION, ht as routerBrain, it as workerTokenFloor, j as generateSpanId, jt as defineProfileMaterializationContract, kt as assertProfileMaterialization, l as withDriverExecutor, lt as attestRuntimeOwnedScopeOwner, mt as runtimeOwnedScopeOwnerRuntime, n as createSupervisor, nt as teardownExecutor, o as runFinalizer, p as scopeOwnerExecutorNodeContext, pt as runtimeOwnedExecutorMaterialization, r as bestDelivered, rt as WORKER_TOKEN_FLOOR, s as runTree, st as spendFromUsageEvents, tn as profileForExecution, tt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, ut as inheritRuntimeOwnedExecutorAttestation, wt as worktreeProfileExecutionPlan } from "./supervisor-DpjO0Gmy.js";
|
|
5
5
|
import { i as notifyRuntimeHookEvent, t as composeRuntimeHooks } from "./runtime-hooks-C7iJOWm3.js";
|
|
@@ -1594,17 +1594,6 @@ async function runAgentRounds(options) {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
1596
|
/**
|
|
1597
|
-
* Pre-rename name for {@link runAgentRounds}; identical function, kept so existing
|
|
1598
|
-
* call sites keep working.
|
|
1599
|
-
*
|
|
1600
|
-
* @deprecated Use {@link runAgentRounds}. The clearer name says what it is: the
|
|
1601
|
-
* multi-agent fanout/vote/refine kernel over sandboxes, NOT the one-turn tool loop
|
|
1602
|
-
* (`runToolLoop` / `streamToolLoop`, `/tool-loop`). `runLoop` shipped on `/kernel`
|
|
1603
|
-
* next to `routerToolLoop`, which made the two read as variants of one thing. The alias
|
|
1604
|
-
* is removed in the next major.
|
|
1605
|
-
*/
|
|
1606
|
-
const runLoop = runAgentRounds;
|
|
1607
|
-
/**
|
|
1608
1597
|
* Build the lineage when either lineage flag is set. Probes the platform's fork
|
|
1609
1598
|
* capability once per run (the lineage degrades gracefully when it's absent).
|
|
1610
1599
|
* Rejects the lineage + `onWorkerBox` combination: both claim the same
|
|
@@ -2831,6 +2820,7 @@ const routerSeamKey = "router";
|
|
|
2831
2820
|
const sandboxSeamKey = "sandbox";
|
|
2832
2821
|
const cliSeamKey = "cli";
|
|
2833
2822
|
const bridgeSeamKey = "bridge";
|
|
2823
|
+
const maxBridgeTimeoutMs = 2147483647;
|
|
2834
2824
|
const cliWorktreeSeamKey = "cli-worktree";
|
|
2835
2825
|
const providerSeamKey = "provider";
|
|
2836
2826
|
/** Deterministic content hash for an `outRef`. FNV-1a 32-bit over the canonical
|
|
@@ -3635,6 +3625,7 @@ const bridgeExecutor = (spec, ctx) => {
|
|
|
3635
3625
|
model: bridgeCellModel(base.model, ctx, effectiveProfile)
|
|
3636
3626
|
};
|
|
3637
3627
|
if (!seam.bridgeUrl || !seam.bridgeBearer || !seam.model) throw new ValidationError("bridgeExecutor: bridgeUrl + bridgeBearer and a profile or bridge model are required");
|
|
3628
|
+
if (seam.timeoutMs !== void 0 && (!Number.isSafeInteger(seam.timeoutMs) || seam.timeoutMs < 1 || seam.timeoutMs > maxBridgeTimeoutMs)) throw new ValidationError(`bridgeExecutor: timeoutMs must be an integer from 1 to ${maxBridgeTimeoutMs}`);
|
|
3638
3629
|
const maxTurns = seam.maxTurns ?? 200;
|
|
3639
3630
|
const sessionId = seam.sessionId ?? `bridge-${spec.profile.name ?? "worker"}-${randomUUID()}`;
|
|
3640
3631
|
const attemptId = ctx.node?.attemptId ?? newExecutionAttemptId(sessionId);
|
|
@@ -3896,7 +3887,7 @@ async function* streamBridgeSession(args) {
|
|
|
3896
3887
|
else external.addEventListener("abort", abortTurn);
|
|
3897
3888
|
interruptSig.addEventListener("abort", abortTurn, { once: true });
|
|
3898
3889
|
let timedOut = false;
|
|
3899
|
-
const timer = seam.timeoutMs ? setTimeout(() => {
|
|
3890
|
+
const timer = seam.timeoutMs !== void 0 ? setTimeout(() => {
|
|
3900
3891
|
timedOut = true;
|
|
3901
3892
|
abortTurn();
|
|
3902
3893
|
}, seam.timeoutMs) : void 0;
|
|
@@ -3916,6 +3907,10 @@ async function* streamBridgeSession(args) {
|
|
|
3916
3907
|
run_id: activeRun.id,
|
|
3917
3908
|
session_id: args.sessionId,
|
|
3918
3909
|
...seam.cwd ? { cwd: seam.cwd } : {},
|
|
3910
|
+
execution: {
|
|
3911
|
+
kind: "host",
|
|
3912
|
+
...seam.timeoutMs !== void 0 ? { timeoutMs: seam.timeoutMs } : {}
|
|
3913
|
+
},
|
|
3919
3914
|
agent_profile: args.profile,
|
|
3920
3915
|
messages
|
|
3921
3916
|
};
|
|
@@ -4854,7 +4849,9 @@ function readSeam(ctx, key, who) {
|
|
|
4854
4849
|
return seam;
|
|
4855
4850
|
}
|
|
4856
4851
|
/** A leaf task is opaque (`unknown`). A string is the prompt verbatim; an object
|
|
4857
|
-
* with a `prompt`/`content`/`task` string field uses it; otherwise it serializes.
|
|
4852
|
+
* with a `prompt`/`content`/`task` string field uses it; otherwise it serializes.
|
|
4853
|
+
* Module-exported (not package surface) so sibling leaf executors read a task
|
|
4854
|
+
* identically instead of re-deriving the rule. */
|
|
4858
4855
|
function taskToPrompt(task) {
|
|
4859
4856
|
if (typeof task === "string") return task;
|
|
4860
4857
|
if (task && typeof task === "object") {
|
|
@@ -4910,7 +4907,8 @@ function linkSignals(a, b) {
|
|
|
4910
4907
|
return c.signal;
|
|
4911
4908
|
}
|
|
4912
4909
|
/** Combine N abort signals into one that fires when ANY does. Node-portable (no `AbortSignal.any`,
|
|
4913
|
-
* which needs >=20.3 — the package floor is >=20).
|
|
4910
|
+
* which needs >=20.3 — the package floor is >=20). Module-exported (not package surface) so
|
|
4911
|
+
* sibling leaf executors share the one portable implementation. */
|
|
4914
4912
|
function mergeAbortSignals(...signals) {
|
|
4915
4913
|
const c = new AbortController();
|
|
4916
4914
|
const onAbort = () => c.abort();
|
|
@@ -5472,6 +5470,82 @@ function createCoordinationTools(opts) {
|
|
|
5472
5470
|
unwatchWorker(w.id);
|
|
5473
5471
|
};
|
|
5474
5472
|
let pendingSettlement;
|
|
5473
|
+
const analystRuns = /* @__PURE__ */ new Map();
|
|
5474
|
+
let analystRunOrdinal = 0;
|
|
5475
|
+
/** The `finding` event an analyst-agent settlement becomes: its settle OUTPUT is the findings
|
|
5476
|
+
* (a failed run publishes the failure as findings — degraded beats vanished). */
|
|
5477
|
+
const analystRunFinding = (run, settled) => deepFreezeDetached({
|
|
5478
|
+
type: "finding",
|
|
5479
|
+
finding: canonicalFindingEvent({
|
|
5480
|
+
fromWorker: run.sourceWorker,
|
|
5481
|
+
analyst: run.route.kind,
|
|
5482
|
+
findings: settled.kind === "done" ? settled.out : { analystRunFailed: settled.reason }
|
|
5483
|
+
})
|
|
5484
|
+
});
|
|
5485
|
+
/**
|
|
5486
|
+
* Spawn one analyst-AGENT run over a settled worker's evidence, through the SAME spawn
|
|
5487
|
+
* machinery a driver spawn uses (`scope.spawn` + `makeWorkerAgent`): the analyst's spend
|
|
5488
|
+
* reserves from the conserved pool, its node is journaled/traced like any worker, and a
|
|
5489
|
+
* node-pinning seam sees `context.analyst`. Its task is the route directive plus the settled
|
|
5490
|
+
* worker's persisted tool-trace spans. A refused spawn publishes a finding RECORDING the
|
|
5491
|
+
* refusal — observable, never silent — and must never take down the settlement path.
|
|
5492
|
+
*/
|
|
5493
|
+
const spawnAnalystRun = async (route, worker) => {
|
|
5494
|
+
let spansText = "";
|
|
5495
|
+
let spanCount = 0;
|
|
5496
|
+
if (worker.trace.status === "available") try {
|
|
5497
|
+
const artifact = parseWorkerToolTraceArtifact(await opts.blobs.get(worker.trace.traceRef), worker.trace.traceRef);
|
|
5498
|
+
spanCount = artifact.spans.length;
|
|
5499
|
+
spansText = safeJsonText(artifact.spans);
|
|
5500
|
+
} catch {
|
|
5501
|
+
spansText = "";
|
|
5502
|
+
}
|
|
5503
|
+
const task = [
|
|
5504
|
+
...route.directive === void 0 || route.directive.length === 0 ? [] : [route.directive],
|
|
5505
|
+
`Evidence — settled worker '${worker.id}' tool trace (${spanCount} spans):`,
|
|
5506
|
+
spansText.length === 0 ? "(no tool spans available)" : spansText
|
|
5507
|
+
].join("\n\n");
|
|
5508
|
+
const assignmentId = `analyst:${route.kind}:o${analystRunOrdinal++}`;
|
|
5509
|
+
const label = `analyst:${route.kind}`;
|
|
5510
|
+
const context = Object.freeze({
|
|
5511
|
+
assignmentId,
|
|
5512
|
+
parentNodeId: opts.scope.view.root,
|
|
5513
|
+
budget: opts.perWorker,
|
|
5514
|
+
task,
|
|
5515
|
+
label,
|
|
5516
|
+
analyst: route.kind,
|
|
5517
|
+
continuity: "fresh"
|
|
5518
|
+
});
|
|
5519
|
+
let refusal;
|
|
5520
|
+
let spawnedId;
|
|
5521
|
+
try {
|
|
5522
|
+
const res = opts.scope.spawn(() => opts.makeWorkerAgent(route.agent, context), task, {
|
|
5523
|
+
budget: opts.perWorker,
|
|
5524
|
+
label,
|
|
5525
|
+
assignmentId
|
|
5526
|
+
});
|
|
5527
|
+
if (res.ok) spawnedId = res.handle.id;
|
|
5528
|
+
else refusal = String(res.reason);
|
|
5529
|
+
} catch (cause) {
|
|
5530
|
+
refusal = cause instanceof Error ? cause.message : String(cause);
|
|
5531
|
+
}
|
|
5532
|
+
if (spawnedId === void 0) {
|
|
5533
|
+
await bus.publish({
|
|
5534
|
+
type: "finding",
|
|
5535
|
+
finding: canonicalFindingEvent({
|
|
5536
|
+
fromWorker: worker.id,
|
|
5537
|
+
analyst: route.kind,
|
|
5538
|
+
findings: { analystSpawnRefused: refusal ?? "unknown" }
|
|
5539
|
+
})
|
|
5540
|
+
});
|
|
5541
|
+
return;
|
|
5542
|
+
}
|
|
5543
|
+
analystRuns.set(spawnedId, {
|
|
5544
|
+
route,
|
|
5545
|
+
sourceWorker: worker.id
|
|
5546
|
+
});
|
|
5547
|
+
watchWorker(spawnedId);
|
|
5548
|
+
};
|
|
5475
5549
|
const workerRouteNames = (workerId) => {
|
|
5476
5550
|
const names = /* @__PURE__ */ new Set();
|
|
5477
5551
|
const profileName = profileNameByWorker.get(workerId);
|
|
@@ -5485,6 +5559,66 @@ function createCoordinationTools(opts) {
|
|
|
5485
5559
|
const live = opts.scope.view.nodes.filter((node) => isLive(node.status));
|
|
5486
5560
|
return live.find((node) => profileNameByWorker.get(node.id) === destination)?.id ?? live.find((node) => node.label === destination)?.id;
|
|
5487
5561
|
};
|
|
5562
|
+
const liveWorkerForNode = (name) => opts.scope.view.nodes.find((node) => isLive(node.status) && profileNameByWorker.get(node.id) === name)?.id;
|
|
5563
|
+
const latestSettledWorkerForNode = (name) => {
|
|
5564
|
+
for (let i = ledger.length - 1; i >= 0; i -= 1) {
|
|
5565
|
+
const worker = ledger[i];
|
|
5566
|
+
if (profileNameByWorker.get(worker.id) === name) return worker.id;
|
|
5567
|
+
}
|
|
5568
|
+
};
|
|
5569
|
+
const nodeSpawnCount = (name) => {
|
|
5570
|
+
let count = 0;
|
|
5571
|
+
for (const profileName of profileNameByWorker.values()) if (profileName === name) count += 1;
|
|
5572
|
+
return count;
|
|
5573
|
+
};
|
|
5574
|
+
const parseContinuity = (v) => {
|
|
5575
|
+
if (v === void 0) return void 0;
|
|
5576
|
+
if (v === "fresh" || v === "resume") return v;
|
|
5577
|
+
throw new Error("coordination tools: \"continuity\" must be \"fresh\" or \"resume\"");
|
|
5578
|
+
};
|
|
5579
|
+
/**
|
|
5580
|
+
* Resolve the EFFECTIVE continuity of one spawn: the per-call request wins, else the profile
|
|
5581
|
+
* name's declared default, else `'fresh'`. Every refusal is loud and actionable:
|
|
5582
|
+
* - an EXPLICIT `'resume'` with no settled prior worker refuses (`resume-no-prior`) — the
|
|
5583
|
+
* DECLARED default degrades to `'fresh'` instead, so a resume edge's first traversal is
|
|
5584
|
+
* simply the first spawn;
|
|
5585
|
+
* - resume while a prior worker of the node is still LIVE refuses (`resume-while-live`) —
|
|
5586
|
+
* that is what steer is for, and the error says so;
|
|
5587
|
+
* - resume under a semantic `key` refuses (`resume-with-key`) — a key makes an assignment
|
|
5588
|
+
* run-once, resume explicitly runs the node again.
|
|
5589
|
+
*/
|
|
5590
|
+
const resolveContinuity = (requested, profileName, key) => {
|
|
5591
|
+
const declared = profileName === void 0 ? "fresh" : opts.continuityByProfile?.[profileName] ?? "fresh";
|
|
5592
|
+
if (!(requested === "resume" || requested === void 0 && declared === "resume")) return { continuity: "fresh" };
|
|
5593
|
+
if (profileName === void 0 || profileName.length === 0) return {
|
|
5594
|
+
error: "resume-unnamed-profile",
|
|
5595
|
+
hint: "Resume targets a node by profile.name — the stable node identity — and this profile has none. Name the profile, or spawn fresh."
|
|
5596
|
+
};
|
|
5597
|
+
if (key !== void 0) return {
|
|
5598
|
+
error: "resume-with-key",
|
|
5599
|
+
hint: "A semantic key makes an assignment run-once (a completed key returns its committed result instead of running again); resume explicitly runs the node AGAIN. Drop the key to resume, or keep the key and spawn fresh."
|
|
5600
|
+
};
|
|
5601
|
+
const live = liveWorkerForNode(profileName);
|
|
5602
|
+
if (live !== void 0) return {
|
|
5603
|
+
error: "resume-while-live",
|
|
5604
|
+
hint: `Worker '${live}' on node '${profileName}' is still LIVE — resume re-attaches to a SETTLED session. To redirect the live worker, use steer_agent (that is the live-worker channel); to run a parallel sibling instead, pass continuity: 'fresh'.`
|
|
5605
|
+
};
|
|
5606
|
+
const prior = latestSettledWorkerForNode(profileName);
|
|
5607
|
+
if (prior === void 0) {
|
|
5608
|
+
if (requested === void 0) return { continuity: "fresh" };
|
|
5609
|
+
return {
|
|
5610
|
+
error: "resume-no-prior",
|
|
5611
|
+
hint: `Node '${profileName}' has no settled prior worker in this process to resume — resume continues a FINISHED session. Spawn the node fresh first (omit continuity or pass 'fresh').`
|
|
5612
|
+
};
|
|
5613
|
+
}
|
|
5614
|
+
return {
|
|
5615
|
+
continuity: "resume",
|
|
5616
|
+
resume: {
|
|
5617
|
+
ofWorker: prior,
|
|
5618
|
+
sequence: nodeSpawnCount(profileName) + 1
|
|
5619
|
+
}
|
|
5620
|
+
};
|
|
5621
|
+
};
|
|
5488
5622
|
/**
|
|
5489
5623
|
* Deliver one routed analyst finding to its destination worker through the SAME authorized
|
|
5490
5624
|
* steer machinery a driver steer uses, so the delivery is recorded (`steer` event carrying
|
|
@@ -5543,15 +5677,28 @@ function createCoordinationTools(opts) {
|
|
|
5543
5677
|
const pending = pendingSettlement;
|
|
5544
5678
|
if (!pending) return false;
|
|
5545
5679
|
await bus.publish(pending.event);
|
|
5680
|
+
if (pending.analystRun) {
|
|
5681
|
+
analystRuns.delete(pending.worker.id);
|
|
5682
|
+
unwatchWorker(pending.worker.id);
|
|
5683
|
+
pendingSettlement = void 0;
|
|
5684
|
+
const { route } = pending.analystRun;
|
|
5685
|
+
if (route.to !== void 0 && pending.event.type === "finding") await deliverRoutedFinding({
|
|
5686
|
+
kind: route.kind,
|
|
5687
|
+
to: route.to
|
|
5688
|
+
}, pending.event.finding.findings);
|
|
5689
|
+
return true;
|
|
5690
|
+
}
|
|
5546
5691
|
commitSettled(pending.settled, pending.worker);
|
|
5547
5692
|
pendingSettlement = void 0;
|
|
5548
|
-
if (pending.analyze && pending.worker.status === "done" && pending.worker.trace.status === "available" && opts.
|
|
5693
|
+
if (pending.analyze && pending.worker.status === "done" && pending.worker.trace.status === "available" && opts.analyzeOnSettle?.length) {
|
|
5549
5694
|
const routes = opts.analyzeOnSettle.map(normalizeAnalyzeOnSettle);
|
|
5550
5695
|
const sourceNames = workerRouteNames(pending.worker.id);
|
|
5551
5696
|
const applicable = routes.filter((route) => route.over === void 0 || route.over.some((name) => sourceNames.has(name)));
|
|
5552
|
-
|
|
5697
|
+
const lensRoutes = applicable.filter((route) => route.agent === void 0);
|
|
5698
|
+
const agentRoutes = applicable.filter((route) => route.agent !== void 0);
|
|
5699
|
+
if (lensRoutes.length > 0 && opts.analysts) {
|
|
5553
5700
|
const trace = await workerTraceAnalysisStore(pending.worker.trace, opts.blobs);
|
|
5554
|
-
for (const route of
|
|
5701
|
+
for (const route of lensRoutes) {
|
|
5555
5702
|
const findings = await opts.analysts.run(route.kind, trace);
|
|
5556
5703
|
await bus.publish({
|
|
5557
5704
|
type: "finding",
|
|
@@ -5564,6 +5711,7 @@ function createCoordinationTools(opts) {
|
|
|
5564
5711
|
if (route.to !== void 0) await deliverRoutedFinding(route, findings);
|
|
5565
5712
|
}
|
|
5566
5713
|
}
|
|
5714
|
+
for (const route of agentRoutes) await spawnAnalystRun(route, pending.worker);
|
|
5567
5715
|
}
|
|
5568
5716
|
return true;
|
|
5569
5717
|
};
|
|
@@ -5572,7 +5720,14 @@ function createCoordinationTools(opts) {
|
|
|
5572
5720
|
const settled = await opts.scope.next();
|
|
5573
5721
|
if (!settled) return false;
|
|
5574
5722
|
const worker = projectSettled(settled);
|
|
5575
|
-
|
|
5723
|
+
const run = analystRuns.get(settled.handle.id);
|
|
5724
|
+
pendingSettlement = run ? {
|
|
5725
|
+
settled,
|
|
5726
|
+
worker,
|
|
5727
|
+
event: analystRunFinding(run, settled),
|
|
5728
|
+
analyze: false,
|
|
5729
|
+
analystRun: run
|
|
5730
|
+
} : {
|
|
5576
5731
|
settled,
|
|
5577
5732
|
worker,
|
|
5578
5733
|
event: deepFreezeDetached({
|
|
@@ -5591,7 +5746,14 @@ function createCoordinationTools(opts) {
|
|
|
5591
5746
|
const settled = await opts.scope.nextResolved();
|
|
5592
5747
|
if (!settled) return drained;
|
|
5593
5748
|
const worker = projectSettled(settled);
|
|
5594
|
-
|
|
5749
|
+
const run = analystRuns.get(settled.handle.id);
|
|
5750
|
+
pendingSettlement = run ? {
|
|
5751
|
+
settled,
|
|
5752
|
+
worker,
|
|
5753
|
+
event: analystRunFinding(run, settled),
|
|
5754
|
+
analyze: false,
|
|
5755
|
+
analystRun: run
|
|
5756
|
+
} : {
|
|
5595
5757
|
settled,
|
|
5596
5758
|
worker,
|
|
5597
5759
|
event: deepFreezeDetached({
|
|
@@ -5934,6 +6096,11 @@ function createCoordinationTools(opts) {
|
|
|
5934
6096
|
type: "string",
|
|
5935
6097
|
description: "Optional semantic name for this assignment (e.g. \"summarize-ch3\"). The same key never runs twice: completed keys return their committed result, even after a coordinator restart."
|
|
5936
6098
|
},
|
|
6099
|
+
continuity: {
|
|
6100
|
+
type: "string",
|
|
6101
|
+
enum: ["fresh", "resume"],
|
|
6102
|
+
description: "How this spawn continues the node's prior work. \"fresh\" (the default) starts a brand-new session. \"resume\" re-attaches to the node's most recent SETTLED worker: a NEW live worker is spawned whose session continues where that worker stopped (the backend receives the prior workerId and the resume sequence). Resume fails closed when the node has no settled prior worker (`error: \"resume-no-prior\"` — spawn it fresh first), while a prior worker of the node is still live (`error: \"resume-while-live\"` — steer_agent is the live-worker channel), and under a `key` (`error: \"resume-with-key\"` — keys are run-once, resume runs again). Omit to use the run's declared default for this profile name."
|
|
6103
|
+
},
|
|
5937
6104
|
budget: {
|
|
5938
6105
|
type: "object",
|
|
5939
6106
|
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." + measuredFloorSentence,
|
|
@@ -5976,6 +6143,13 @@ function createCoordinationTools(opts) {
|
|
|
5976
6143
|
}))
|
|
5977
6144
|
});
|
|
5978
6145
|
const profile = deepFreezeDetached(parsedProfile.data);
|
|
6146
|
+
const continuity = resolveContinuity(parseContinuity(a.continuity), profile.name, key);
|
|
6147
|
+
if ("error" in continuity) return Promise.resolve({
|
|
6148
|
+
error: continuity.error,
|
|
6149
|
+
hint: continuity.hint,
|
|
6150
|
+
live: liveWorkerCount(),
|
|
6151
|
+
freeSlots: freeWorkerSlots()
|
|
6152
|
+
});
|
|
5979
6153
|
const task = deepFreezeDetached(a.task);
|
|
5980
6154
|
const label = typeof a.label === "string" ? a.label : "worker";
|
|
5981
6155
|
const budget = Object.freeze(a.budget === void 0 ? opts.perWorker : mergeBudget(opts.perWorker, a.budget));
|
|
@@ -5986,7 +6160,9 @@ function createCoordinationTools(opts) {
|
|
|
5986
6160
|
budget,
|
|
5987
6161
|
task,
|
|
5988
6162
|
label,
|
|
5989
|
-
...key !== void 0 ? { key } : {}
|
|
6163
|
+
...key !== void 0 ? { key } : {},
|
|
6164
|
+
continuity: continuity.continuity,
|
|
6165
|
+
...continuity.continuity === "resume" ? { resume: continuity.resume } : {}
|
|
5990
6166
|
});
|
|
5991
6167
|
const res = opts.scope.spawn(() => opts.makeWorkerAgent(profile, context), task, {
|
|
5992
6168
|
budget,
|
|
@@ -6023,6 +6199,8 @@ function createCoordinationTools(opts) {
|
|
|
6023
6199
|
...res.handle.identity === void 0 ? {} : { identity: res.handle.identity },
|
|
6024
6200
|
...res.handle.materialization === void 0 ? {} : { materialization: res.handle.materialization },
|
|
6025
6201
|
...res.handle.executionBindings === void 0 ? {} : { executionBindings: res.handle.executionBindings },
|
|
6202
|
+
continuity: continuity.continuity,
|
|
6203
|
+
...continuity.continuity === "resume" ? { resume: continuity.resume } : {},
|
|
6026
6204
|
live: liveWorkerCount(),
|
|
6027
6205
|
freeSlots: freeWorkerSlots(),
|
|
6028
6206
|
...priorHistory
|
|
@@ -6894,7 +7072,7 @@ function progressStop(tracker, rule, coord, scope, now, stallAfterMs) {
|
|
|
6894
7072
|
function driverAgent(opts) {
|
|
6895
7073
|
if (typeof opts.brain !== "function") throw new ValidationError("driverAgent: opts.brain must be a function");
|
|
6896
7074
|
if ((opts.extraTools?.length ?? 0) > 0 && typeof opts.executeExtraTool !== "function") throw new ValidationError("driverAgent: extraTools requires executeExtraTool (how to run a work-tool call)");
|
|
6897
|
-
if ((opts.analyzeOnSettle
|
|
7075
|
+
if ((opts.analyzeOnSettle ?? []).map(normalizeAnalyzeOnSettle).some((route) => route.agent === void 0) && !opts.analysts) throw new ValidationError("driverAgent: analyzeOnSettle requires analysts (the lens registry the kinds resolve against)");
|
|
6898
7076
|
const reserved = new Set(coordinationVerbNames);
|
|
6899
7077
|
for (const tool of opts.nodeTools ?? []) {
|
|
6900
7078
|
if (reserved.has(tool.name)) throw new ValidationError(`driverAgent: node tool "${tool.name}" collides with a coordination verb or another node tool`);
|
|
@@ -6926,6 +7104,7 @@ function driverAgent(opts) {
|
|
|
6926
7104
|
...opts.analyzeOnSettle ? { analyzeOnSettle: opts.analyzeOnSettle } : {},
|
|
6927
7105
|
...opts.watchWorkers ? { watchWorkers: opts.watchWorkers } : {},
|
|
6928
7106
|
...opts.stallAfterMs !== void 0 ? { stallAfterMs: opts.stallAfterMs } : {},
|
|
7107
|
+
...opts.continuityByProfile ? { continuityByProfile: opts.continuityByProfile } : {},
|
|
6929
7108
|
...opts.onEvent ? { onEvent: opts.onEvent } : {},
|
|
6930
7109
|
...opts.replaySettlements ? { replaySettlements: true } : {},
|
|
6931
7110
|
...opts.priorCoordination?.questions.length ? { priorQuestions: opts.priorCoordination.questions } : {}
|
|
@@ -8934,6 +9113,7 @@ async function serveCoordinationMcp(opts) {
|
|
|
8934
9113
|
...opts.analyzeOnSettle ? { analyzeOnSettle: opts.analyzeOnSettle } : {},
|
|
8935
9114
|
...opts.watchWorkers ? { watchWorkers: opts.watchWorkers } : {},
|
|
8936
9115
|
...opts.stallAfterMs !== void 0 ? { stallAfterMs: opts.stallAfterMs } : {},
|
|
9116
|
+
...opts.continuityByProfile ? { continuityByProfile: opts.continuityByProfile } : {},
|
|
8937
9117
|
...opts.onEvent ? { onEvent: opts.onEvent } : {},
|
|
8938
9118
|
...opts.replaySettlements ? { replaySettlements: true } : {},
|
|
8939
9119
|
...opts.questionPolicy ? { questionPolicy: opts.questionPolicy } : {},
|
|
@@ -9133,6 +9313,7 @@ function supervisorAgent(profile, deps) {
|
|
|
9133
9313
|
...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
|
|
9134
9314
|
...deps.watchWorkers ? { watchWorkers: deps.watchWorkers } : {},
|
|
9135
9315
|
...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {},
|
|
9316
|
+
...deps.continuityByProfile ? { continuityByProfile: deps.continuityByProfile } : {},
|
|
9136
9317
|
...deps.stopRule ? { stopRule: deps.stopRule } : {},
|
|
9137
9318
|
...deps.onProgressStop ? { onProgressStop: deps.onProgressStop } : {},
|
|
9138
9319
|
...deps.maxTurns !== void 0 ? { maxTurns: deps.maxTurns } : {},
|
|
@@ -9186,6 +9367,7 @@ function supervisorAgent(profile, deps) {
|
|
|
9186
9367
|
...deps.analyzeOnSettle ? { analyzeOnSettle: deps.analyzeOnSettle } : {},
|
|
9187
9368
|
...deps.watchWorkers ? { watchWorkers: deps.watchWorkers } : {},
|
|
9188
9369
|
...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {},
|
|
9370
|
+
...deps.continuityByProfile ? { continuityByProfile: deps.continuityByProfile } : {},
|
|
9189
9371
|
...onEvent ? { onEvent } : {},
|
|
9190
9372
|
...deps.replaySettlements ? { replaySettlements: true } : {},
|
|
9191
9373
|
...priorCoordination?.questions.length ? { priorQuestions: priorCoordination.questions } : {},
|
|
@@ -9312,6 +9494,7 @@ function workerFromBackend(backend, deliverable, seams) {
|
|
|
9312
9494
|
if (!parsed.success) throw new ValidationError(`workerFromBackend: invalid AgentProfile: ${parsed.error.message}`);
|
|
9313
9495
|
const profile = parsed.data;
|
|
9314
9496
|
assertBackendProfileMaterialization(profile, capturedBackend, "workerFromBackend");
|
|
9497
|
+
if (spawnContext?.continuity === "resume") throw new ValidationError("workerFromBackend: this backend seam does not re-attach sessions and cannot honor continuity: 'resume' — provide a makeWorkerAgent that resumes (it receives spawnContext.resume.ofWorker), or use continuity: 'fresh'");
|
|
9315
9498
|
const name = profile.name ?? "worker";
|
|
9316
9499
|
const assignmentId = spawnContext?.assignmentId ?? `unscoped:${unscopedNamespace}:${unscopedOrdinal++}`;
|
|
9317
9500
|
const baseFactory = createExecutor(bindReusableExecutorExecutionId(capturedBackend, externalExecutionId("supervised-worker", { assignmentId })));
|
|
@@ -10008,6 +10191,7 @@ function supervise(profile, task, opts) {
|
|
|
10008
10191
|
...options.analyzeOnSettle ? { analyzeOnSettle: options.analyzeOnSettle } : {},
|
|
10009
10192
|
...options.watchWorkers ? { watchWorkers: options.watchWorkers } : {},
|
|
10010
10193
|
...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
|
|
10194
|
+
...options.continuityByProfile ? { continuityByProfile: options.continuityByProfile } : {},
|
|
10011
10195
|
...options.stopRule ? { stopRule: options.stopRule } : {},
|
|
10012
10196
|
...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
|
|
10013
10197
|
...options.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : {},
|
|
@@ -10059,6 +10243,7 @@ function supervise(profile, task, opts) {
|
|
|
10059
10243
|
...options.analyzeOnSettle ? { analyzeOnSettle: options.analyzeOnSettle } : {},
|
|
10060
10244
|
...options.watchWorkers ? { watchWorkers: options.watchWorkers } : {},
|
|
10061
10245
|
...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
|
|
10246
|
+
...options.continuityByProfile ? { continuityByProfile: options.continuityByProfile } : {},
|
|
10062
10247
|
...options.stopRule ? { stopRule: options.stopRule } : {},
|
|
10063
10248
|
...options.onProgressStop ? { onProgressStop: options.onProgressStop } : {},
|
|
10064
10249
|
...options.maxTurns !== void 0 ? { maxTurns: options.maxTurns } : {},
|
|
@@ -10108,6 +10293,6 @@ function supervise(profile, task, opts) {
|
|
|
10108
10293
|
return start();
|
|
10109
10294
|
}
|
|
10110
10295
|
//#endregion
|
|
10111
|
-
export { allOf as $,
|
|
10296
|
+
export { allOf as $, kernelPromptRegistry as $t, DELEGATE_DESCRIPTION as A, sandboxSessionTraceSource as At, DELEGATION_TRACE_MAX_SPANS as B, asAuthoredProfile as Bt, createDelegateUiAuditHandler as C, mergeAbortSignals as Ct, DELEGATE_FEEDBACK_TOOL_NAME as D, createSteerableSandboxSession as Dt, DELEGATE_FEEDBACK_INPUT_SCHEMA as E, DEFAULT_SANDBOX_STEERING_MAX_TURNS as Et, defaultDelegateBudget as F, createSandboxLineage as Ft, DelegationPersistenceError as G, profileRichnessFinding as Gt, capDelegationTrace as H, authoredWorker as Ht, delegate as I, probeSandboxCapabilities as It, InMemoryDelegationStore as J, createPromptRegistry as Jt, DelegationStateCorruptError as K, supervisorInstructions as Kt, DelegationTaskQueue as L, acquireSandbox as Lt, DELEGATE_TOOL_NAME as M, createSandboxForSpec as Mt, createDelegateHandler as N, defaultSelectWinner as Nt, createDelegateFeedbackHandler as O, createPushTraceSource as Ot, validateDelegateArgs as P, runAgentRounds as Pt, finalizeBestDelivered as Q, formatPromptHandle as Qt, hashIdempotencyInput as R, FileCoordinationLog as Rt, DELEGATE_UI_AUDIT_TOOL_NAME as S, createExecutorRegistry as St, DELEGATE_FEEDBACK_DESCRIPTION as T, createWorktreeCliExecutor as Tt, composeLoopTraceEmitters as U, canonicalizeAuthoredProfile as Ut, buildDelegationTraceSpans as V, assessAuthoredProfile as Vt, createDelegationTraceCollector as W, defaultProfileRichnessThresholds as Wt, eventToSnapshot as X, dumbContinuationFailPrompt as Xt, InMemoryFeedbackStore as Y, delegatesWorkerBriefPrompt as Yt, driverAgent as Z, dumbContinuationPassPrompt as Zt, DELEGATION_HISTORY_TOOL_NAME as _, watchTrace as _t, resolveSupervisorProfile as a, sampleFromSettled as at, DELEGATE_UI_AUDIT_DESCRIPTION as b, cliWorktreeExecutor as bt, createInProcessTransport as c, bestSoFar as ct, DELEGATION_STATUS_INPUT_SCHEMA as d, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as dt, naiveContinuationPrompt as en, allWorkersStalled as et, DELEGATION_STATUS_TOOL_NAME as f, canonicalFindingEvent as ft, DELEGATION_HISTORY_INPUT_SCHEMA as g, defaultToolDetectors as gt, DELEGATION_HISTORY_DESCRIPTION as h, createEventBus as ht, assertCoordinationBinding as i, plateau as it, DELEGATE_INPUT_SCHEMA as j, createInbox as jt, validateDelegateFeedbackArgs as k, decodeToolPart as kt, createMcpServer as l, plateauLength as lt, validateDelegationStatusArgs as m, normalizeAnalyzeOnSettle as mt, supervise as n, supervisorPolicyPrompt as nn, createProgressTracker as nt, supervisorAgent as o, anytimeReport as ot, createDelegationStatusHandler as p, createCoordinationTools as pt, FileDelegationStore as q, analyzesFindingsReportPrompt as qt, workerFromBackend as r, gateOnDeliverable as rn, noProgressFor as rt, serveCoordinationMcp as s, areaUnderCurve as st, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, promptHandle as tn, anyOf as tt, DELEGATION_STATUS_DESCRIPTION as u, renderAnytimeTable as ut, createDelegationHistoryHandler as v, createFileRunContext as vt, validateDelegateUiAuditArgs as w, taskToPrompt as wt, DELEGATE_UI_AUDIT_INPUT_SCHEMA as x, createExecutor as xt, validateDelegationHistoryArgs as y, createInMemoryRunContext as yt, DELEGATION_TRACE_MAX_BYTES as z, createSupervisorSpanRecorder as zt };
|
|
10112
10297
|
|
|
10113
|
-
//# sourceMappingURL=supervise-
|
|
10298
|
+
//# sourceMappingURL=supervise-CsTKbH9R.js.map
|