@tangle-network/agent-runtime 0.123.0 → 0.126.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-B7sTehZB.js → activation-DhWJ3p8N.js} +2 -2
- package/dist/{activation-B7sTehZB.js.map → activation-DhWJ3p8N.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{environment-provider-CY22kUQH.js → environment-provider-DqFS6FSZ.js} +3 -2
- package/dist/environment-provider-DqFS6FSZ.js.map +1 -0
- package/dist/{environment-provider-CEjwunXO.d.ts → environment-provider-PM9PeW_J.d.ts} +5 -1
- package/dist/environment-provider.d.ts +1 -1
- package/dist/environment-provider.js +1 -1
- package/dist/{improvement-cycle-BcwsSbT-.js → improvement-cycle-IJgCbKWQ.js} +5 -5
- package/dist/improvement-cycle-IJgCbKWQ.js.map +1 -0
- package/dist/{index-CKply5aj.d.ts → index-DIV33AF5.d.ts} +3 -3
- package/dist/{index-BKSzgMvA.d.ts → index-D_M4d1_B.d.ts} +5 -5
- package/dist/{index-CyXinqJw.d.ts → index-EdjCQBV9.d.ts} +52 -128
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +1 -1
- package/dist/intelligence.js +4 -4
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +6 -6
- package/dist/{knowledge-Cuvb21T7.js → knowledge-EnuEqm_Y.js} +3 -3
- package/dist/{knowledge-Cuvb21T7.js.map → knowledge-EnuEqm_Y.js.map} +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.js +1 -1
- package/dist/{loop-runner-bin-BjnNpN5m.d.ts → loop-runner-bin-Bo29_fiD.d.ts} +3 -3
- package/dist/{loop-runner-bin-Clhj8gy5.js → loop-runner-bin-qwT_4F5I.js} +3 -3
- package/dist/{loop-runner-bin-Clhj8gy5.js.map → loop-runner-bin-qwT_4F5I.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +2 -2
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-BwTsBfd-.js → openai-tools-Bp1KSkP6.js} +2 -2
- package/dist/{openai-tools-BwTsBfd-.js.map → openai-tools-Bp1KSkP6.js.map} +1 -1
- package/dist/primeintellect/index.d.ts +1 -1
- package/dist/{runtime-OI7oLLec.js → runtime-BzXz7OjS.js} +92 -130
- package/dist/runtime-BzXz7OjS.js.map +1 -0
- package/dist/{structural-rollout-C4Jv_7vt.js → structural-rollout-zY0oqQzO.js} +2 -2
- package/dist/{structural-rollout-C4Jv_7vt.js.map → structural-rollout-zY0oqQzO.js.map} +1 -1
- package/dist/{supervise-Dwq16u8n.js → supervise-Ds8FtyI9.js} +144 -49
- package/dist/supervise-Ds8FtyI9.js.map +1 -0
- package/dist/{supervisor-DjZ82HIB.js → supervisor-DpjO0Gmy.js} +67 -8
- package/dist/supervisor-DpjO0Gmy.js.map +1 -0
- package/dist/testing.js +9 -9
- package/package.json +4 -4
- package/dist/environment-provider-CY22kUQH.js.map +0 -1
- package/dist/improvement-cycle-BcwsSbT-.js.map +0 -1
- package/dist/runtime-OI7oLLec.js.map +0 -1
- package/dist/supervise-Dwq16u8n.js.map +0 -1
- package/dist/supervisor-DjZ82HIB.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
import { 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, St as runWorktreeChecks, T as buildLoopSpanNodes, Tt as captureWorktreeDiff, Vt as worktreeCliProfileMaterialization, Y as describeToolArgs, _ 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, 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, tt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, ut as inheritRuntimeOwnedExecutorAttestation, wt as worktreeProfileExecutionPlan } from "./supervisor-
|
|
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";
|
|
6
6
|
import { a as notifySandboxEventObserver, n as extractLlmCallEvent } from "./sandbox-events-Yhd1GYWl.js";
|
|
7
|
-
import { i as resolveAgentEnvironmentProvider, n as providerAsExecutor, r as providerAsSandboxClient } from "./environment-provider-
|
|
7
|
+
import { i as resolveAgentEnvironmentProvider, n as providerAsExecutor, r as providerAsSandboxClient } from "./environment-provider-DqFS6FSZ.js";
|
|
8
8
|
import { t as createStdioToolServer } from "./tool-server-RcWgLIsL.js";
|
|
9
9
|
import { n as UI_LENSES } from "./substrate-B0TYNrXn.js";
|
|
10
10
|
import { argHash, computeFindingId, errorStreakDetector, estimateCost, isModelPriced, makeFinding, observeAll, repeatedActionDetector } from "@tangle-network/agent-eval";
|
|
@@ -405,7 +405,7 @@ function supervisorInstructions(opts) {
|
|
|
405
405
|
/** Build a router-only worker from an authored profile. This helper executes the prompt/model axes;
|
|
406
406
|
* use `workerFromBackend` for full materialization of tools, MCP, resources, hooks, and subagents. */
|
|
407
407
|
function authoredWorker(profile, opts) {
|
|
408
|
-
const model = profile
|
|
408
|
+
const model = concreteProfileModel(profile) ?? opts.cfg.model;
|
|
409
409
|
const executorFactory = (spec, ctx) => {
|
|
410
410
|
let artifact;
|
|
411
411
|
const executionId = ctx.node?.nodeId ?? `authored-router-${profile.name}`;
|
|
@@ -587,25 +587,6 @@ function profileRichnessFinding(richness, opts) {
|
|
|
587
587
|
});
|
|
588
588
|
}
|
|
589
589
|
//#endregion
|
|
590
|
-
//#region src/runtime/supervise/model-policy.ts
|
|
591
|
-
/**
|
|
592
|
-
* Throw a `ConfigError` when `allowed` is set, `model` is defined, and `model` is not a
|
|
593
|
-
* member of `allowed`. No-op when `allowed` is unset (the unrestricted default) or when
|
|
594
|
-
* `model` is undefined (nothing was configured to check).
|
|
595
|
-
*/
|
|
596
|
-
function assertModelAllowed(model, allowed) {
|
|
597
|
-
if (!allowed || model === void 0) return;
|
|
598
|
-
if (!allowed.includes(model)) throw new ConfigError(`model ${JSON.stringify(model)} is not in the allowed set ${JSON.stringify([...allowed])}`);
|
|
599
|
-
}
|
|
600
|
-
/** Check every canonical model-bearing field in a complete profile, including the models a
|
|
601
|
-
* backend may select for cheap work, named subagents, or modes. */
|
|
602
|
-
function assertProfileModelsAllowed(profile, allowed) {
|
|
603
|
-
assertModelAllowed(profile.model?.default, allowed);
|
|
604
|
-
assertModelAllowed(profile.model?.small, allowed);
|
|
605
|
-
for (const subagent of Object.values(profile.subagents ?? {})) assertModelAllowed(subagent.model, allowed);
|
|
606
|
-
for (const mode of Object.values(profile.modes ?? {})) assertModelAllowed(mode.model, allowed);
|
|
607
|
-
}
|
|
608
|
-
//#endregion
|
|
609
590
|
//#region src/runtime/supervise/otel-spans.ts
|
|
610
591
|
/**
|
|
611
592
|
* Supervisor tree → OTLP spans. OPT-IN, off by default.
|
|
@@ -1195,7 +1176,7 @@ function buildBackendOptions(profile, overrides) {
|
|
|
1195
1176
|
...base,
|
|
1196
1177
|
backend: {
|
|
1197
1178
|
type: resolveBackendType(profile, overrideBackend),
|
|
1198
|
-
profile,
|
|
1179
|
+
profile: profileForExecution(profile),
|
|
1199
1180
|
...overrideBackend?.model ? { model: overrideBackend.model } : {},
|
|
1200
1181
|
...overrideBackend?.server ? { server: overrideBackend.server } : {}
|
|
1201
1182
|
}
|
|
@@ -2677,6 +2658,7 @@ function createWorktreeCliExecutor(options) {
|
|
|
2677
2658
|
let run;
|
|
2678
2659
|
let artifact;
|
|
2679
2660
|
const profilePlan = worktreeProfileExecutionPlan(options.profile, options.harness);
|
|
2661
|
+
const profileModel = concreteProfileModel(options.profile);
|
|
2680
2662
|
return attestRuntimeOwnedExecutor({
|
|
2681
2663
|
runtime: "cli",
|
|
2682
2664
|
budgetExempt,
|
|
@@ -2747,9 +2729,9 @@ function createWorktreeCliExecutor(options) {
|
|
|
2747
2729
|
}, {
|
|
2748
2730
|
effectiveProfile: options.profile,
|
|
2749
2731
|
backend: `cli-worktree:${options.harness}`,
|
|
2750
|
-
model:
|
|
2732
|
+
model: profileModel ? {
|
|
2751
2733
|
status: "known",
|
|
2752
|
-
id:
|
|
2734
|
+
id: profileModel
|
|
2753
2735
|
} : {
|
|
2754
2736
|
status: "unknown",
|
|
2755
2737
|
reason: `${options.harness} selected its configured default model`
|
|
@@ -2778,7 +2760,7 @@ function createWorktreeCliExecutor(options) {
|
|
|
2778
2760
|
repoRoot: options.repoRoot,
|
|
2779
2761
|
runId,
|
|
2780
2762
|
harness: options.harness,
|
|
2781
|
-
model:
|
|
2763
|
+
model: profileModel ?? null,
|
|
2782
2764
|
baseRef: options.baseRef ?? "HEAD"
|
|
2783
2765
|
},
|
|
2784
2766
|
descriptor: {
|
|
@@ -2916,7 +2898,7 @@ function unmeteredSpend(ms) {
|
|
|
2916
2898
|
*/
|
|
2917
2899
|
const routerInlineExecutor = (spec, ctx) => {
|
|
2918
2900
|
const seam = readSeam(ctx, routerSeamKey, "router/inline");
|
|
2919
|
-
const model = spec.profile
|
|
2901
|
+
const model = concreteProfileModel(spec.profile) ?? concreteModelId(seam.model);
|
|
2920
2902
|
if (!model) throw new ValidationError("routerInlineExecutor: no model — set RouterSeam.model or AgentProfile.model.default");
|
|
2921
2903
|
if (!seam.routerBaseUrl || !seam.routerKey) throw new ValidationError("routerInlineExecutor: RouterSeam.routerBaseUrl + routerKey required");
|
|
2922
2904
|
const controller = new AbortController();
|
|
@@ -3009,7 +2991,7 @@ const routerToolsSeamKey = "router-tools";
|
|
|
3009
2991
|
*/
|
|
3010
2992
|
const routerToolsInlineExecutor = (spec, ctx) => {
|
|
3011
2993
|
const seam = readSeam(ctx, routerToolsSeamKey, "router-tools");
|
|
3012
|
-
const model = spec.profile
|
|
2994
|
+
const model = concreteProfileModel(spec.profile) ?? concreteModelId(seam.model);
|
|
3013
2995
|
if (!model) throw new ValidationError("routerToolsInlineExecutor: no model — set RouterToolsSeam.model or AgentProfile.model.default");
|
|
3014
2996
|
if (!seam.routerBaseUrl || !seam.routerKey) throw new ValidationError("routerToolsInlineExecutor: RouterToolsSeam.routerBaseUrl + routerKey required");
|
|
3015
2997
|
const maxTurns = seam.maxTurns ?? 200;
|
|
@@ -3236,12 +3218,13 @@ const sandboxExecutor = (spec, ctx) => {
|
|
|
3236
3218
|
let artifact;
|
|
3237
3219
|
const executionId = ctx.node?.nodeId ?? `sandbox-run-${randomUUID()}`;
|
|
3238
3220
|
const attemptId = ctx.node?.attemptId ?? newExecutionAttemptId(executionId);
|
|
3221
|
+
const profileModel = concreteProfileModel(spec.profile);
|
|
3239
3222
|
const sandboxMaterialization = {
|
|
3240
3223
|
effectiveProfile: spec.profile,
|
|
3241
3224
|
backend: harness,
|
|
3242
|
-
model:
|
|
3225
|
+
model: profileModel ? {
|
|
3243
3226
|
status: "known",
|
|
3244
|
-
id:
|
|
3227
|
+
id: profileModel
|
|
3245
3228
|
} : {
|
|
3246
3229
|
status: "unknown",
|
|
3247
3230
|
reason: "sandbox harness selected its default model"
|
|
@@ -3263,7 +3246,7 @@ const sandboxExecutor = (spec, ctx) => {
|
|
|
3263
3246
|
binding: {
|
|
3264
3247
|
executionId,
|
|
3265
3248
|
harness,
|
|
3266
|
-
model:
|
|
3249
|
+
model: profileModel ?? null
|
|
3267
3250
|
},
|
|
3268
3251
|
descriptor: {
|
|
3269
3252
|
kind: "sandbox-run",
|
|
@@ -3623,7 +3606,7 @@ function killWithGrace(proc, grace) {
|
|
|
3623
3606
|
* IS the caller's declared intent rather than a gap to fill.
|
|
3624
3607
|
*/
|
|
3625
3608
|
function qualifyProviderModel(model) {
|
|
3626
|
-
const id = model?.default;
|
|
3609
|
+
const id = concreteModelId(model?.default);
|
|
3627
3610
|
if (!id) return void 0;
|
|
3628
3611
|
const provider = model?.provider;
|
|
3629
3612
|
if (!provider || id.includes("/")) return id;
|
|
@@ -3633,11 +3616,16 @@ function bridgeCellModel(seamModel, ctx, profile) {
|
|
|
3633
3616
|
const backend = ctx.seams.createOptions?.backend;
|
|
3634
3617
|
const profileHarness = agentHarness(profile.harness);
|
|
3635
3618
|
const harness = backend?.type ?? profileHarness;
|
|
3636
|
-
const
|
|
3637
|
-
|
|
3619
|
+
const backendModel = backend?.model?.model;
|
|
3620
|
+
const hasBackendModel = backendModel !== void 0;
|
|
3621
|
+
if (hasBackendModel && isHarnessNativeModel(backendModel)) return harness ?? concreteModelId(seamModel);
|
|
3622
|
+
const model = hasBackendModel ? concreteModelId(backendModel) : qualifyProviderModel(profile.model);
|
|
3623
|
+
const fallback = concreteModelId(seamModel);
|
|
3624
|
+
if (!harness && !model) return fallback;
|
|
3638
3625
|
if (!harness) return model;
|
|
3639
3626
|
if (model) return model.startsWith(`${harness}/`) ? model : `${harness}/${model}`;
|
|
3640
|
-
|
|
3627
|
+
if (!fallback) return void 0;
|
|
3628
|
+
return fallback.startsWith(`${harness}/`) ? fallback : `${harness}/${fallback}`;
|
|
3641
3629
|
}
|
|
3642
3630
|
const bridgeExecutor = (spec, ctx) => {
|
|
3643
3631
|
const base = readSeam(ctx, bridgeSeamKey, "bridge");
|
|
@@ -4644,12 +4632,13 @@ function snapshotExecutorConfig(config) {
|
|
|
4644
4632
|
});
|
|
4645
4633
|
}
|
|
4646
4634
|
case "provider": {
|
|
4647
|
-
const { provider, registry, taskToTurn, ...decisionData } = config;
|
|
4635
|
+
const { provider, registry, profileForCreate, taskToTurn, ...decisionData } = config;
|
|
4648
4636
|
const snapshot = detachedSnapshot(decisionData, "createExecutor provider config");
|
|
4649
4637
|
const resolvedProvider = resolveAgentEnvironmentProvider(provider, registry);
|
|
4650
4638
|
return Object.freeze({
|
|
4651
4639
|
...snapshot,
|
|
4652
4640
|
provider: resolvedProvider,
|
|
4641
|
+
...profileForCreate === void 0 ? {} : { profileForCreate },
|
|
4653
4642
|
...taskToTurn === void 0 ? {} : { taskToTurn }
|
|
4654
4643
|
});
|
|
4655
4644
|
}
|
|
@@ -4776,7 +4765,11 @@ function createExecutor(config) {
|
|
|
4776
4765
|
runtime: providerSeam.runtime ?? provider.name
|
|
4777
4766
|
};
|
|
4778
4767
|
}
|
|
4779
|
-
|
|
4768
|
+
const profileForCreate = providerSeam.profileForCreate;
|
|
4769
|
+
return providerAsExecutor(provider, {
|
|
4770
|
+
...providerSeam,
|
|
4771
|
+
profileForCreate: (profile) => profileForExecution(profileForCreate?.(profile) ?? profile)
|
|
4772
|
+
})(spec, seamed);
|
|
4780
4773
|
}
|
|
4781
4774
|
case "sandbox": {
|
|
4782
4775
|
const harness = spec.harness ?? captured.harness ?? null;
|
|
@@ -5479,6 +5472,81 @@ function createCoordinationTools(opts) {
|
|
|
5479
5472
|
unwatchWorker(w.id);
|
|
5480
5473
|
};
|
|
5481
5474
|
let pendingSettlement;
|
|
5475
|
+
const analystRuns = /* @__PURE__ */ new Map();
|
|
5476
|
+
let analystRunOrdinal = 0;
|
|
5477
|
+
/** The `finding` event an analyst-agent settlement becomes: its settle OUTPUT is the findings
|
|
5478
|
+
* (a failed run publishes the failure as findings — degraded beats vanished). */
|
|
5479
|
+
const analystRunFinding = (run, settled) => deepFreezeDetached({
|
|
5480
|
+
type: "finding",
|
|
5481
|
+
finding: canonicalFindingEvent({
|
|
5482
|
+
fromWorker: run.sourceWorker,
|
|
5483
|
+
analyst: run.route.kind,
|
|
5484
|
+
findings: settled.kind === "done" ? settled.out : { analystRunFailed: settled.reason }
|
|
5485
|
+
})
|
|
5486
|
+
});
|
|
5487
|
+
/**
|
|
5488
|
+
* Spawn one analyst-AGENT run over a settled worker's evidence, through the SAME spawn
|
|
5489
|
+
* machinery a driver spawn uses (`scope.spawn` + `makeWorkerAgent`): the analyst's spend
|
|
5490
|
+
* reserves from the conserved pool, its node is journaled/traced like any worker, and a
|
|
5491
|
+
* node-pinning seam sees `context.analyst`. Its task is the route directive plus the settled
|
|
5492
|
+
* worker's persisted tool-trace spans. A refused spawn publishes a finding RECORDING the
|
|
5493
|
+
* refusal — observable, never silent — and must never take down the settlement path.
|
|
5494
|
+
*/
|
|
5495
|
+
const spawnAnalystRun = async (route, worker) => {
|
|
5496
|
+
let spansText = "";
|
|
5497
|
+
let spanCount = 0;
|
|
5498
|
+
if (worker.trace.status === "available") try {
|
|
5499
|
+
const artifact = parseWorkerToolTraceArtifact(await opts.blobs.get(worker.trace.traceRef), worker.trace.traceRef);
|
|
5500
|
+
spanCount = artifact.spans.length;
|
|
5501
|
+
spansText = safeJsonText(artifact.spans);
|
|
5502
|
+
} catch {
|
|
5503
|
+
spansText = "";
|
|
5504
|
+
}
|
|
5505
|
+
const task = [
|
|
5506
|
+
...route.directive === void 0 || route.directive.length === 0 ? [] : [route.directive],
|
|
5507
|
+
`Evidence — settled worker '${worker.id}' tool trace (${spanCount} spans):`,
|
|
5508
|
+
spansText.length === 0 ? "(no tool spans available)" : spansText
|
|
5509
|
+
].join("\n\n");
|
|
5510
|
+
const assignmentId = `analyst:${route.kind}:o${analystRunOrdinal++}`;
|
|
5511
|
+
const label = `analyst:${route.kind}`;
|
|
5512
|
+
const context = Object.freeze({
|
|
5513
|
+
assignmentId,
|
|
5514
|
+
parentNodeId: opts.scope.view.root,
|
|
5515
|
+
budget: opts.perWorker,
|
|
5516
|
+
task,
|
|
5517
|
+
label,
|
|
5518
|
+
analyst: route.kind
|
|
5519
|
+
});
|
|
5520
|
+
let refusal;
|
|
5521
|
+
let spawnedId;
|
|
5522
|
+
try {
|
|
5523
|
+
const res = opts.scope.spawn(() => opts.makeWorkerAgent(route.agent, context), task, {
|
|
5524
|
+
budget: opts.perWorker,
|
|
5525
|
+
label,
|
|
5526
|
+
assignmentId
|
|
5527
|
+
});
|
|
5528
|
+
if (res.ok) spawnedId = res.handle.id;
|
|
5529
|
+
else refusal = String(res.reason);
|
|
5530
|
+
} catch (cause) {
|
|
5531
|
+
refusal = cause instanceof Error ? cause.message : String(cause);
|
|
5532
|
+
}
|
|
5533
|
+
if (spawnedId === void 0) {
|
|
5534
|
+
await bus.publish({
|
|
5535
|
+
type: "finding",
|
|
5536
|
+
finding: canonicalFindingEvent({
|
|
5537
|
+
fromWorker: worker.id,
|
|
5538
|
+
analyst: route.kind,
|
|
5539
|
+
findings: { analystSpawnRefused: refusal ?? "unknown" }
|
|
5540
|
+
})
|
|
5541
|
+
});
|
|
5542
|
+
return;
|
|
5543
|
+
}
|
|
5544
|
+
analystRuns.set(spawnedId, {
|
|
5545
|
+
route,
|
|
5546
|
+
sourceWorker: worker.id
|
|
5547
|
+
});
|
|
5548
|
+
watchWorker(spawnedId);
|
|
5549
|
+
};
|
|
5482
5550
|
const workerRouteNames = (workerId) => {
|
|
5483
5551
|
const names = /* @__PURE__ */ new Set();
|
|
5484
5552
|
const profileName = profileNameByWorker.get(workerId);
|
|
@@ -5550,15 +5618,28 @@ function createCoordinationTools(opts) {
|
|
|
5550
5618
|
const pending = pendingSettlement;
|
|
5551
5619
|
if (!pending) return false;
|
|
5552
5620
|
await bus.publish(pending.event);
|
|
5621
|
+
if (pending.analystRun) {
|
|
5622
|
+
analystRuns.delete(pending.worker.id);
|
|
5623
|
+
unwatchWorker(pending.worker.id);
|
|
5624
|
+
pendingSettlement = void 0;
|
|
5625
|
+
const { route } = pending.analystRun;
|
|
5626
|
+
if (route.to !== void 0 && pending.event.type === "finding") await deliverRoutedFinding({
|
|
5627
|
+
kind: route.kind,
|
|
5628
|
+
to: route.to
|
|
5629
|
+
}, pending.event.finding.findings);
|
|
5630
|
+
return true;
|
|
5631
|
+
}
|
|
5553
5632
|
commitSettled(pending.settled, pending.worker);
|
|
5554
5633
|
pendingSettlement = void 0;
|
|
5555
|
-
if (pending.analyze && pending.worker.status === "done" && pending.worker.trace.status === "available" && opts.
|
|
5634
|
+
if (pending.analyze && pending.worker.status === "done" && pending.worker.trace.status === "available" && opts.analyzeOnSettle?.length) {
|
|
5556
5635
|
const routes = opts.analyzeOnSettle.map(normalizeAnalyzeOnSettle);
|
|
5557
5636
|
const sourceNames = workerRouteNames(pending.worker.id);
|
|
5558
5637
|
const applicable = routes.filter((route) => route.over === void 0 || route.over.some((name) => sourceNames.has(name)));
|
|
5559
|
-
|
|
5638
|
+
const lensRoutes = applicable.filter((route) => route.agent === void 0);
|
|
5639
|
+
const agentRoutes = applicable.filter((route) => route.agent !== void 0);
|
|
5640
|
+
if (lensRoutes.length > 0 && opts.analysts) {
|
|
5560
5641
|
const trace = await workerTraceAnalysisStore(pending.worker.trace, opts.blobs);
|
|
5561
|
-
for (const route of
|
|
5642
|
+
for (const route of lensRoutes) {
|
|
5562
5643
|
const findings = await opts.analysts.run(route.kind, trace);
|
|
5563
5644
|
await bus.publish({
|
|
5564
5645
|
type: "finding",
|
|
@@ -5571,6 +5652,7 @@ function createCoordinationTools(opts) {
|
|
|
5571
5652
|
if (route.to !== void 0) await deliverRoutedFinding(route, findings);
|
|
5572
5653
|
}
|
|
5573
5654
|
}
|
|
5655
|
+
for (const route of agentRoutes) await spawnAnalystRun(route, pending.worker);
|
|
5574
5656
|
}
|
|
5575
5657
|
return true;
|
|
5576
5658
|
};
|
|
@@ -5579,7 +5661,14 @@ function createCoordinationTools(opts) {
|
|
|
5579
5661
|
const settled = await opts.scope.next();
|
|
5580
5662
|
if (!settled) return false;
|
|
5581
5663
|
const worker = projectSettled(settled);
|
|
5582
|
-
|
|
5664
|
+
const run = analystRuns.get(settled.handle.id);
|
|
5665
|
+
pendingSettlement = run ? {
|
|
5666
|
+
settled,
|
|
5667
|
+
worker,
|
|
5668
|
+
event: analystRunFinding(run, settled),
|
|
5669
|
+
analyze: false,
|
|
5670
|
+
analystRun: run
|
|
5671
|
+
} : {
|
|
5583
5672
|
settled,
|
|
5584
5673
|
worker,
|
|
5585
5674
|
event: deepFreezeDetached({
|
|
@@ -5598,7 +5687,14 @@ function createCoordinationTools(opts) {
|
|
|
5598
5687
|
const settled = await opts.scope.nextResolved();
|
|
5599
5688
|
if (!settled) return drained;
|
|
5600
5689
|
const worker = projectSettled(settled);
|
|
5601
|
-
|
|
5690
|
+
const run = analystRuns.get(settled.handle.id);
|
|
5691
|
+
pendingSettlement = run ? {
|
|
5692
|
+
settled,
|
|
5693
|
+
worker,
|
|
5694
|
+
event: analystRunFinding(run, settled),
|
|
5695
|
+
analyze: false,
|
|
5696
|
+
analystRun: run
|
|
5697
|
+
} : {
|
|
5602
5698
|
settled,
|
|
5603
5699
|
worker,
|
|
5604
5700
|
event: deepFreezeDetached({
|
|
@@ -6901,7 +6997,7 @@ function progressStop(tracker, rule, coord, scope, now, stallAfterMs) {
|
|
|
6901
6997
|
function driverAgent(opts) {
|
|
6902
6998
|
if (typeof opts.brain !== "function") throw new ValidationError("driverAgent: opts.brain must be a function");
|
|
6903
6999
|
if ((opts.extraTools?.length ?? 0) > 0 && typeof opts.executeExtraTool !== "function") throw new ValidationError("driverAgent: extraTools requires executeExtraTool (how to run a work-tool call)");
|
|
6904
|
-
if ((opts.analyzeOnSettle
|
|
7000
|
+
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)");
|
|
6905
7001
|
const reserved = new Set(coordinationVerbNames);
|
|
6906
7002
|
for (const tool of opts.nodeTools ?? []) {
|
|
6907
7003
|
if (reserved.has(tool.name)) throw new ValidationError(`driverAgent: node tool "${tool.name}" collides with a coordination verb or another node tool`);
|
|
@@ -9068,9 +9164,8 @@ function resolveSupervisorSystemPrompt(profile, activePrompt) {
|
|
|
9068
9164
|
* applies, exactly as when `model` is absent.
|
|
9069
9165
|
*/
|
|
9070
9166
|
function resolveSupervisorModelId(profile) {
|
|
9071
|
-
if (typeof profile.model === "string") return profile.model;
|
|
9072
|
-
|
|
9073
|
-
return typeof fromHints === "string" && fromHints.length > 0 ? fromHints : void 0;
|
|
9167
|
+
if (typeof profile.model === "string") return concreteModelId(profile.model);
|
|
9168
|
+
return concreteModelId(profile.model?.default);
|
|
9074
9169
|
}
|
|
9075
9170
|
/**
|
|
9076
9171
|
* Reduce either profile spelling — a hand-written `SupervisorProfile` or a canonical `AgentProfile`
|
|
@@ -10116,6 +10211,6 @@ function supervise(profile, task, opts) {
|
|
|
10116
10211
|
return start();
|
|
10117
10212
|
}
|
|
10118
10213
|
//#endregion
|
|
10119
|
-
export { allOf as $,
|
|
10214
|
+
export { allOf as $, naiveContinuationPrompt as $t, DELEGATE_DESCRIPTION as A, createSandboxForSpec as At, DELEGATION_TRACE_MAX_SPANS as B, assessAuthoredProfile as Bt, createDelegateUiAuditHandler as C, createWorktreeCliExecutor as Ct, DELEGATE_FEEDBACK_TOOL_NAME as D, decodeToolPart as Dt, DELEGATE_FEEDBACK_INPUT_SCHEMA as E, createPushTraceSource as Et, defaultDelegateBudget as F, probeSandboxCapabilities as Ft, DelegationPersistenceError as G, supervisorInstructions as Gt, capDelegationTrace as H, canonicalizeAuthoredProfile as Ht, delegate as I, acquireSandbox as It, InMemoryDelegationStore as J, delegatesWorkerBriefPrompt as Jt, DelegationStateCorruptError as K, analyzesFindingsReportPrompt as Kt, DelegationTaskQueue as L, FileCoordinationLog as Lt, DELEGATE_TOOL_NAME as M, runAgentRounds as Mt, createDelegateHandler as N, runLoop as Nt, createDelegateFeedbackHandler as O, sandboxSessionTraceSource as Ot, validateDelegateArgs as P, createSandboxLineage as Pt, finalizeBestDelivered as Q, kernelPromptRegistry as Qt, hashIdempotencyInput as R, createSupervisorSpanRecorder as Rt, DELEGATE_UI_AUDIT_TOOL_NAME as S, createExecutorRegistry as St, DELEGATE_FEEDBACK_DESCRIPTION as T, createSteerableSandboxSession as Tt, composeLoopTraceEmitters as U, defaultProfileRichnessThresholds as Ut, buildDelegationTraceSpans as V, authoredWorker as Vt, createDelegationTraceCollector as W, profileRichnessFinding as Wt, eventToSnapshot as X, dumbContinuationPassPrompt as Xt, InMemoryFeedbackStore as Y, dumbContinuationFailPrompt as Yt, driverAgent as Z, formatPromptHandle 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, promptHandle 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, defaultSelectWinner as jt, validateDelegateFeedbackArgs as k, createInbox as kt, createMcpServer as l, plateauLength as lt, validateDelegationStatusArgs as m, normalizeAnalyzeOnSettle as mt, supervise as n, gateOnDeliverable as nn, createProgressTracker as nt, supervisorAgent as o, anytimeReport as ot, createDelegationStatusHandler as p, createCoordinationTools as pt, FileDelegationStore as q, createPromptRegistry as qt, workerFromBackend as r, noProgressFor as rt, serveCoordinationMcp as s, areaUnderCurve as st, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, supervisorPolicyPrompt as tn, anyOf as tt, DELEGATION_STATUS_DESCRIPTION as u, renderAnytimeTable as ut, createDelegationHistoryHandler as v, createFileRunContext as vt, validateDelegateUiAuditArgs as w, DEFAULT_SANDBOX_STEERING_MAX_TURNS as wt, DELEGATE_UI_AUDIT_INPUT_SCHEMA as x, createExecutor as xt, validateDelegationHistoryArgs as y, createInMemoryRunContext as yt, DELEGATION_TRACE_MAX_BYTES as z, asAuthoredProfile as zt };
|
|
10120
10215
|
|
|
10121
|
-
//# sourceMappingURL=supervise-
|
|
10216
|
+
//# sourceMappingURL=supervise-Ds8FtyI9.js.map
|