@tangle-network/agent-runtime 0.70.1 → 0.71.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/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/{chunk-CRAH5EY2.js → chunk-4KGQHS7U.js} +2 -2
- package/dist/{chunk-YFOPWG74.js → chunk-5ISW5JUF.js} +275 -145
- package/dist/chunk-5ISW5JUF.js.map +1 -0
- package/dist/{chunk-LJZ5GC6C.js → chunk-74UAWZXE.js} +4 -4
- package/dist/{chunk-HY4YOQM2.js → chunk-INXDNX2W.js} +2 -2
- package/dist/{chunk-BGOLR66M.js → chunk-K3RM4MPM.js} +3 -3
- package/dist/{chunk-G3RGMA7C.js → chunk-VMNEQHJR.js} +6 -1
- package/dist/chunk-VMNEQHJR.js.map +1 -0
- package/dist/{coordination-C7WxwHXq.d.ts → coordination-BPQmuwv8.d.ts} +280 -2
- package/dist/{delegates-DqAgo32T.d.ts → delegates-CsXJPZDH.d.ts} +48 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -5
- package/dist/intelligence.d.ts +1 -1
- package/dist/intelligence.js +1 -1
- package/dist/{loop-runner-bin-a8bu4O5-.d.ts → loop-runner-bin-DLM_bVQO.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +4 -4
- package/dist/loop-runner-bin.js +4 -4
- package/dist/loops.d.ts +120 -241
- package/dist/loops.js +6 -2
- package/dist/mcp/bin.js +4 -4
- package/dist/mcp/index.d.ts +7 -6
- package/dist/mcp/index.js +15 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-DPx9Gzvn.d.ts → openai-tools-kdCS-T12.d.ts} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{types-BYa2ZOAx.d.ts → types-CdnEAE3U.d.ts} +1 -1
- package/dist/{worktree-fanout-gNfl0Byj.d.ts → worktree-fanout-CK2ypmEm.d.ts} +3 -45
- package/package.json +1 -1
- package/dist/chunk-G3RGMA7C.js.map +0 -1
- package/dist/chunk-YFOPWG74.js.map +0 -1
- /package/dist/{chunk-CRAH5EY2.js.map → chunk-4KGQHS7U.js.map} +0 -0
- /package/dist/{chunk-LJZ5GC6C.js.map → chunk-74UAWZXE.js.map} +0 -0
- /package/dist/{chunk-HY4YOQM2.js.map → chunk-INXDNX2W.js.map} +0 -0
- /package/dist/{chunk-BGOLR66M.js.map → chunk-K3RM4MPM.js.map} +0 -0
package/dist/agent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _tangle_network_agent_eval from '@tangle-network/agent-eval';
|
|
2
2
|
import { TraceAnalystKindSpec, AnalystFinding } from '@tangle-network/agent-eval';
|
|
3
|
-
import { R as RuntimeStreamEvent, S as SandboxClient, a as OutputAdapter, A as AgentRunSpec } from './types-
|
|
3
|
+
import { R as RuntimeStreamEvent, S as SandboxClient, a as OutputAdapter, A as AgentRunSpec } from './types-CdnEAE3U.js';
|
|
4
4
|
import { A as AgentSurfaces } from './improvement-adapter-CioiEE2z.js';
|
|
5
5
|
export { C as CreateSurfaceImprovementAdapterOpts, D as DraftPatchInput, a as DraftPatchOutput, R as ResolvedSurface, S as SurfaceImprovementEdit, b as SurfaceValidationIssue, c as createSurfaceImprovementAdapter, r as renderSurfaceIssues, d as resolveSubjectPath, v as validateSurfaces } from './improvement-adapter-CioiEE2z.js';
|
|
6
6
|
import { K as KnowledgeAdapter, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
|
package/dist/agent.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
} from "./chunk-XRYEZPR6.js";
|
|
4
4
|
import {
|
|
5
5
|
createSandboxForSpec
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-5ISW5JUF.js";
|
|
7
|
+
import "./chunk-VMNEQHJR.js";
|
|
8
8
|
import {
|
|
9
9
|
mapSandboxEvent
|
|
10
10
|
} from "./chunk-VLF5RHEQ.js";
|
package/dist/analyst-loop.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceAnalystByteBudgets, TraceAnalysisStore } from '@tangle-network/agent-eval';
|
|
2
|
-
import { I as Iteration } from './types-
|
|
2
|
+
import { I as Iteration } from './types-CdnEAE3U.js';
|
|
3
3
|
import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
|
|
4
4
|
export { A as AnalystLoopEvent, b as AnalystRegistryLike, c as AnalystRegistryStreamingLike, d as AutoApplyPolicy, F as FindingsStoreLike, I as ImprovementAdapter, e as ImprovementEditBatch, f as ImprovementReport, K as KnowledgeAdapter, g as KnowledgeProposalBatch, h as KnowledgeReport } from './types-BC3bZpH0.js';
|
|
5
5
|
import '@tangle-network/sandbox';
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
DELEGATION_STATUS_DESCRIPTION,
|
|
15
15
|
DELEGATION_STATUS_INPUT_SCHEMA,
|
|
16
16
|
DELEGATION_STATUS_TOOL_NAME
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5ISW5JUF.js";
|
|
18
18
|
|
|
19
19
|
// src/mcp/openai-tools.ts
|
|
20
20
|
function buildTool(name, description, parameters) {
|
|
@@ -61,4 +61,4 @@ export {
|
|
|
61
61
|
mcpToolsForRuntimeMcp,
|
|
62
62
|
mcpToolsForRuntimeMcpSubset
|
|
63
63
|
};
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
64
|
+
//# sourceMappingURL=chunk-4KGQHS7U.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildLoopSpanNodes
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VMNEQHJR.js";
|
|
4
4
|
import {
|
|
5
5
|
AgentEvalError,
|
|
6
6
|
AnalystError,
|
|
@@ -4641,19 +4641,19 @@ function createSupervisor() {
|
|
|
4641
4641
|
...isNonEmptySpend(driverInference) ? { spentBreakdown: { driverInference, childWork } } : {}
|
|
4642
4642
|
};
|
|
4643
4643
|
}
|
|
4644
|
+
return noWinner();
|
|
4645
|
+
}
|
|
4646
|
+
return noWinner();
|
|
4647
|
+
async function noWinner() {
|
|
4648
|
+
const { childWork, driverInference } = await spentFromJournal(journal, opts.runId);
|
|
4644
4649
|
return {
|
|
4645
4650
|
kind: "no-winner",
|
|
4646
4651
|
reason: classifyNoWinner(controller, pool2, opts, breaker),
|
|
4647
4652
|
tree,
|
|
4648
|
-
downCount: breaker.downCount()
|
|
4653
|
+
downCount: breaker.downCount(),
|
|
4654
|
+
spentTotal: addSpend(childWork, driverInference)
|
|
4649
4655
|
};
|
|
4650
4656
|
}
|
|
4651
|
-
return {
|
|
4652
|
-
kind: "no-winner",
|
|
4653
|
-
reason: classifyNoWinner(controller, pool2, opts, breaker),
|
|
4654
|
-
tree,
|
|
4655
|
-
downCount: breaker.downCount()
|
|
4656
|
-
};
|
|
4657
4657
|
}
|
|
4658
4658
|
function attach(h) {
|
|
4659
4659
|
const control = rootControls.get(h);
|
|
@@ -8359,6 +8359,253 @@ function canonicalize(value) {
|
|
|
8359
8359
|
return out;
|
|
8360
8360
|
}
|
|
8361
8361
|
|
|
8362
|
+
// src/runtime/supervise/model-policy.ts
|
|
8363
|
+
function assertModelAllowed(model, allowed) {
|
|
8364
|
+
if (!allowed || model === void 0) return;
|
|
8365
|
+
if (!allowed.includes(model)) {
|
|
8366
|
+
throw new ConfigError(
|
|
8367
|
+
`model ${JSON.stringify(model)} is not in the allowed set ${JSON.stringify([...allowed])}`
|
|
8368
|
+
);
|
|
8369
|
+
}
|
|
8370
|
+
}
|
|
8371
|
+
|
|
8372
|
+
// src/runtime/supervise/run-context.ts
|
|
8373
|
+
function createInMemoryRunContext(opts = {}) {
|
|
8374
|
+
const base = createExecutorRegistry();
|
|
8375
|
+
return {
|
|
8376
|
+
journal: new InMemorySpawnJournal(),
|
|
8377
|
+
blobs: new InMemoryResultBlobStore(),
|
|
8378
|
+
executors: opts.withDriver ? withDriverExecutor(base) : base
|
|
8379
|
+
};
|
|
8380
|
+
}
|
|
8381
|
+
|
|
8382
|
+
// src/runtime/supervise/supervisor-agent.ts
|
|
8383
|
+
function supervisorAgent(profile, deps) {
|
|
8384
|
+
const name = profile.name ?? "supervisor";
|
|
8385
|
+
const systemPrompt = profile.systemPrompt ?? "";
|
|
8386
|
+
const harness = profile.harness ?? null;
|
|
8387
|
+
if (harness === null) {
|
|
8388
|
+
const brain = deps.brain ?? routerBrainFromProfile(profile, deps);
|
|
8389
|
+
return driverAgent({
|
|
8390
|
+
name,
|
|
8391
|
+
brain,
|
|
8392
|
+
blobs: deps.blobs,
|
|
8393
|
+
makeWorkerAgent: deps.makeWorkerAgent,
|
|
8394
|
+
perWorker: deps.perWorker,
|
|
8395
|
+
systemPrompt,
|
|
8396
|
+
...deps.extraTools ? { extraTools: deps.extraTools } : {},
|
|
8397
|
+
...deps.executeExtraTool ? { executeExtraTool: deps.executeExtraTool } : {},
|
|
8398
|
+
...deps.maxTurns !== void 0 ? { maxTurns: deps.maxTurns } : {}
|
|
8399
|
+
});
|
|
8400
|
+
}
|
|
8401
|
+
const driveHarness = deps.driveHarness;
|
|
8402
|
+
if (!driveHarness) {
|
|
8403
|
+
throw new ValidationError(
|
|
8404
|
+
`supervisorAgent: profile.harness="${harness}" needs deps.driveHarness (how to run the harness with the coordination MCP mounted)`
|
|
8405
|
+
);
|
|
8406
|
+
}
|
|
8407
|
+
return {
|
|
8408
|
+
name,
|
|
8409
|
+
async act(task, scope) {
|
|
8410
|
+
const mcp = await serveCoordinationMcp({
|
|
8411
|
+
scope,
|
|
8412
|
+
blobs: deps.blobs,
|
|
8413
|
+
makeWorkerAgent: deps.makeWorkerAgent,
|
|
8414
|
+
perWorker: deps.perWorker
|
|
8415
|
+
});
|
|
8416
|
+
try {
|
|
8417
|
+
await driveHarness({ profile, task, scope, coordinationMcpUrl: mcp.url });
|
|
8418
|
+
return await finalizeBestDelivered(mcp.settled(), deps.blobs);
|
|
8419
|
+
} finally {
|
|
8420
|
+
await mcp.close();
|
|
8421
|
+
}
|
|
8422
|
+
}
|
|
8423
|
+
};
|
|
8424
|
+
}
|
|
8425
|
+
function routerBrainFromProfile(profile, deps) {
|
|
8426
|
+
if (!deps.router) {
|
|
8427
|
+
throw new ValidationError(
|
|
8428
|
+
"supervisorAgent: a router-brained supervisor (harness null) needs deps.router (or deps.brain)"
|
|
8429
|
+
);
|
|
8430
|
+
}
|
|
8431
|
+
return routerBrain({ ...deps.router, model: profile.model ?? deps.router.model });
|
|
8432
|
+
}
|
|
8433
|
+
|
|
8434
|
+
// src/runtime/supervise/supervise.ts
|
|
8435
|
+
function workerFromBackend(backend, deliverable) {
|
|
8436
|
+
return (rawProfile) => {
|
|
8437
|
+
const p = rawProfile ?? {};
|
|
8438
|
+
const name = typeof p.name === "string" && p.name.length > 0 ? p.name : "worker";
|
|
8439
|
+
const spec = { profile: rawProfile, harness: null };
|
|
8440
|
+
const ctx = { signal: new AbortController().signal, seams: {} };
|
|
8441
|
+
const built = createExecutor(backend)(spec, ctx);
|
|
8442
|
+
const executor = deliverable ? gateOnDeliverable(built, deliverable) : built;
|
|
8443
|
+
return { name, act: async () => "", executorSpec: { ...spec, executor } };
|
|
8444
|
+
};
|
|
8445
|
+
}
|
|
8446
|
+
function defaultPerWorker(budget) {
|
|
8447
|
+
return {
|
|
8448
|
+
maxIterations: budget.maxIterations,
|
|
8449
|
+
maxTokens: Math.max(1, Math.floor(budget.maxTokens / 4))
|
|
8450
|
+
};
|
|
8451
|
+
}
|
|
8452
|
+
function supervise(profile, task, opts) {
|
|
8453
|
+
const backendModel = opts.backend?.model;
|
|
8454
|
+
assertModelAllowed(opts.router?.model, opts.allowedModels);
|
|
8455
|
+
assertModelAllowed(profile.model, opts.allowedModels);
|
|
8456
|
+
assertModelAllowed(
|
|
8457
|
+
typeof backendModel === "string" ? backendModel : void 0,
|
|
8458
|
+
opts.allowedModels
|
|
8459
|
+
);
|
|
8460
|
+
const ctx = createInMemoryRunContext({ withDriver: true });
|
|
8461
|
+
const blobs = opts.blobs ?? ctx.blobs;
|
|
8462
|
+
const perWorker = opts.perWorker ?? defaultPerWorker(opts.budget);
|
|
8463
|
+
let makeWorkerAgent = opts.makeWorkerAgent;
|
|
8464
|
+
if (!makeWorkerAgent) {
|
|
8465
|
+
if (!opts.backend) {
|
|
8466
|
+
throw new ValidationError(
|
|
8467
|
+
"supervise: provide opts.backend (where workers run) or opts.makeWorkerAgent"
|
|
8468
|
+
);
|
|
8469
|
+
}
|
|
8470
|
+
makeWorkerAgent = workerFromBackend(opts.backend, opts.deliverable);
|
|
8471
|
+
}
|
|
8472
|
+
const agent = supervisorAgent(profile, {
|
|
8473
|
+
blobs,
|
|
8474
|
+
makeWorkerAgent,
|
|
8475
|
+
perWorker,
|
|
8476
|
+
...opts.router ? { router: opts.router } : {},
|
|
8477
|
+
...opts.brain ? { brain: opts.brain } : {},
|
|
8478
|
+
...opts.driveHarness ? { driveHarness: opts.driveHarness } : {},
|
|
8479
|
+
...opts.extraTools ? { extraTools: opts.extraTools } : {},
|
|
8480
|
+
...opts.executeExtraTool ? { executeExtraTool: opts.executeExtraTool } : {},
|
|
8481
|
+
...opts.maxTurns !== void 0 ? { maxTurns: opts.maxTurns } : {}
|
|
8482
|
+
});
|
|
8483
|
+
return createSupervisor().run(agent, task, {
|
|
8484
|
+
budget: opts.budget,
|
|
8485
|
+
runId: opts.runId ?? "supervise",
|
|
8486
|
+
journal: ctx.journal,
|
|
8487
|
+
blobs,
|
|
8488
|
+
executors: ctx.executors,
|
|
8489
|
+
maxDepth: opts.maxDepth ?? 8,
|
|
8490
|
+
...opts.now ? { now: opts.now } : {}
|
|
8491
|
+
});
|
|
8492
|
+
}
|
|
8493
|
+
|
|
8494
|
+
// src/runtime/supervise/delegate.ts
|
|
8495
|
+
var defaultDelegateBudget = { maxIterations: 50, maxTokens: 2e5 };
|
|
8496
|
+
function authoringSupervisorProfile(model, override) {
|
|
8497
|
+
return {
|
|
8498
|
+
name: override?.name ?? "delegate-supervisor",
|
|
8499
|
+
harness: null,
|
|
8500
|
+
...model ? { model } : {},
|
|
8501
|
+
systemPrompt: override?.systemPrompt ?? supervisorInstructions()
|
|
8502
|
+
};
|
|
8503
|
+
}
|
|
8504
|
+
async function delegate(intent, opts = {}) {
|
|
8505
|
+
if (typeof intent !== "string" || intent.trim().length === 0) {
|
|
8506
|
+
throw new ConfigError("delegate: `intent` must be a non-empty string");
|
|
8507
|
+
}
|
|
8508
|
+
if (!opts.brain && !opts.router) {
|
|
8509
|
+
throw new ConfigError(
|
|
8510
|
+
"delegate: provide opts.router (the supervisor brain substrate) or opts.brain (tests)"
|
|
8511
|
+
);
|
|
8512
|
+
}
|
|
8513
|
+
const profile = authoringSupervisorProfile(opts.model, opts.supervisor);
|
|
8514
|
+
return supervise(profile, intent, {
|
|
8515
|
+
budget: opts.budget ?? defaultDelegateBudget,
|
|
8516
|
+
...opts.backend ? { backend: opts.backend } : {},
|
|
8517
|
+
...opts.deliverable ? { deliverable: opts.deliverable } : {},
|
|
8518
|
+
...opts.router ? { router: opts.router } : {},
|
|
8519
|
+
...opts.brain ? { brain: opts.brain } : {},
|
|
8520
|
+
...opts.allowedModels ? { allowedModels: opts.allowedModels } : {},
|
|
8521
|
+
...opts.runId ? { runId: opts.runId } : {}
|
|
8522
|
+
});
|
|
8523
|
+
}
|
|
8524
|
+
|
|
8525
|
+
// src/mcp/tools/delegate.ts
|
|
8526
|
+
var DELEGATE_TOOL_NAME = "delegate";
|
|
8527
|
+
var DELEGATE_DESCRIPTION = [
|
|
8528
|
+
"Delegate an INTENT to a supervisor that AUTHORS and drives whatever worker the intent needs.",
|
|
8529
|
+
"",
|
|
8530
|
+
'Use when: you want a task done but do not want to specify HOW. State the outcome \u2014 "fix the',
|
|
8531
|
+
'failing auth test", "research competitor pricing with citations", "refactor the parser for',
|
|
8532
|
+
'clarity" \u2014 and the supervisor decomposes it, writes a tailored worker profile per sub-task, runs',
|
|
8533
|
+
"the workers over a conserved compute budget, and settles only when a deployable check passes.",
|
|
8534
|
+
"",
|
|
8535
|
+
"There is no fixed worker type: this ONE verb replaces separate code / research delegation. The",
|
|
8536
|
+
"supervisor picks the worker shape from your intent.",
|
|
8537
|
+
"",
|
|
8538
|
+
"Returns synchronously with the delivered result AND the real cost of the whole delegation",
|
|
8539
|
+
"(spentTotal: iterations, input/output tokens, usd, ms) \u2014 so you always know what it spent. A run",
|
|
8540
|
+
'that produced no delivered worker returns status "no-winner" with the reason; it never fabricates',
|
|
8541
|
+
"a success."
|
|
8542
|
+
].join("\n");
|
|
8543
|
+
var DELEGATE_INPUT_SCHEMA = {
|
|
8544
|
+
type: "object",
|
|
8545
|
+
properties: {
|
|
8546
|
+
intent: {
|
|
8547
|
+
type: "string",
|
|
8548
|
+
description: "What you want accomplished, as an outcome. The supervisor authors the worker."
|
|
8549
|
+
},
|
|
8550
|
+
model: {
|
|
8551
|
+
type: "string",
|
|
8552
|
+
description: "Optional per-call override for the supervisor brain model."
|
|
8553
|
+
},
|
|
8554
|
+
runId: {
|
|
8555
|
+
type: "string",
|
|
8556
|
+
description: "Optional trace-correlation id for this delegation."
|
|
8557
|
+
}
|
|
8558
|
+
},
|
|
8559
|
+
required: ["intent"],
|
|
8560
|
+
additionalProperties: false
|
|
8561
|
+
};
|
|
8562
|
+
function validateDelegateArgs(raw) {
|
|
8563
|
+
if (raw === null || typeof raw !== "object") {
|
|
8564
|
+
throw new TypeError("delegate: arguments must be an object");
|
|
8565
|
+
}
|
|
8566
|
+
const value = raw;
|
|
8567
|
+
const intent = value.intent;
|
|
8568
|
+
if (typeof intent !== "string" || intent.trim().length === 0) {
|
|
8569
|
+
throw new TypeError("delegate: `intent` must be a non-empty string");
|
|
8570
|
+
}
|
|
8571
|
+
const args = { intent: intent.trim() };
|
|
8572
|
+
if (value.model !== void 0) {
|
|
8573
|
+
if (typeof value.model !== "string") throw new TypeError("delegate: `model` must be a string");
|
|
8574
|
+
args.model = value.model;
|
|
8575
|
+
}
|
|
8576
|
+
if (value.runId !== void 0) {
|
|
8577
|
+
if (typeof value.runId !== "string") throw new TypeError("delegate: `runId` must be a string");
|
|
8578
|
+
args.runId = value.runId;
|
|
8579
|
+
}
|
|
8580
|
+
return args;
|
|
8581
|
+
}
|
|
8582
|
+
function toDelegateResult(result) {
|
|
8583
|
+
if (result.kind === "no-winner") {
|
|
8584
|
+
return { status: "no-winner", reason: result.reason, spentTotal: result.spentTotal };
|
|
8585
|
+
}
|
|
8586
|
+
return {
|
|
8587
|
+
status: "winner",
|
|
8588
|
+
out: result.out,
|
|
8589
|
+
outRef: result.outRef,
|
|
8590
|
+
spentTotal: result.spentTotal
|
|
8591
|
+
};
|
|
8592
|
+
}
|
|
8593
|
+
function createDelegateHandler(options) {
|
|
8594
|
+
return async (raw) => {
|
|
8595
|
+
const args = validateDelegateArgs(raw);
|
|
8596
|
+
const opts = {
|
|
8597
|
+
backend: options.backend,
|
|
8598
|
+
router: options.router,
|
|
8599
|
+
model: args.model ?? options.model,
|
|
8600
|
+
...options.deliverable ? { deliverable: options.deliverable } : {},
|
|
8601
|
+
...options.allowedModels ? { allowedModels: options.allowedModels } : {},
|
|
8602
|
+
...args.runId ? { runId: args.runId } : {}
|
|
8603
|
+
};
|
|
8604
|
+
const result = await delegate(args.intent, opts);
|
|
8605
|
+
return toDelegateResult(result);
|
|
8606
|
+
};
|
|
8607
|
+
}
|
|
8608
|
+
|
|
8362
8609
|
// src/mcp/detached-turn.ts
|
|
8363
8610
|
var DEFAULT_TICK_INTERVAL_MS = 5e3;
|
|
8364
8611
|
function formatDetachedSessionRef(parts) {
|
|
@@ -9513,6 +9760,14 @@ function createMcpServer(options = {}) {
|
|
|
9513
9760
|
const serverName = options.serverName ?? DEFAULT_SERVER_NAME;
|
|
9514
9761
|
const serverVersion = options.serverVersion ?? DEFAULT_SERVER_VERSION;
|
|
9515
9762
|
const tools = /* @__PURE__ */ new Map();
|
|
9763
|
+
if (options.delegateSupervisor) {
|
|
9764
|
+
tools.set(DELEGATE_TOOL_NAME, {
|
|
9765
|
+
name: DELEGATE_TOOL_NAME,
|
|
9766
|
+
description: DELEGATE_DESCRIPTION,
|
|
9767
|
+
inputSchema: DELEGATE_INPUT_SCHEMA,
|
|
9768
|
+
handler: createDelegateHandler(options.delegateSupervisor)
|
|
9769
|
+
});
|
|
9770
|
+
}
|
|
9516
9771
|
if (options.coderDelegate) {
|
|
9517
9772
|
tools.set(DELEGATE_CODE_TOOL_NAME, {
|
|
9518
9773
|
name: DELEGATE_CODE_TOOL_NAME,
|
|
@@ -9810,16 +10065,6 @@ function watchTrace(source, opts = {}) {
|
|
|
9810
10065
|
});
|
|
9811
10066
|
}
|
|
9812
10067
|
|
|
9813
|
-
// src/runtime/supervise/model-policy.ts
|
|
9814
|
-
function assertModelAllowed(model, allowed) {
|
|
9815
|
-
if (!allowed || model === void 0) return;
|
|
9816
|
-
if (!allowed.includes(model)) {
|
|
9817
|
-
throw new ConfigError(
|
|
9818
|
-
`model ${JSON.stringify(model)} is not in the allowed set ${JSON.stringify([...allowed])}`
|
|
9819
|
-
);
|
|
9820
|
-
}
|
|
9821
|
-
}
|
|
9822
|
-
|
|
9823
10068
|
// src/runtime/supervise/patch-checks.ts
|
|
9824
10069
|
var DEFAULT_MAX_DIFF_LINES = 400;
|
|
9825
10070
|
var secretPathPattern = /(^|\/)(\.env(\.|$)|.*\.(pem|key|p12|pfx|keystore|wallet)|id_rsa|id_ed25519|secrets?\.json|credentials?\.json)$/i;
|
|
@@ -9930,128 +10175,6 @@ function signalPass(value, required) {
|
|
|
9930
10175
|
return !required;
|
|
9931
10176
|
}
|
|
9932
10177
|
|
|
9933
|
-
// src/runtime/supervise/run-context.ts
|
|
9934
|
-
function createInMemoryRunContext(opts = {}) {
|
|
9935
|
-
const base = createExecutorRegistry();
|
|
9936
|
-
return {
|
|
9937
|
-
journal: new InMemorySpawnJournal(),
|
|
9938
|
-
blobs: new InMemoryResultBlobStore(),
|
|
9939
|
-
executors: opts.withDriver ? withDriverExecutor(base) : base
|
|
9940
|
-
};
|
|
9941
|
-
}
|
|
9942
|
-
|
|
9943
|
-
// src/runtime/supervise/supervisor-agent.ts
|
|
9944
|
-
function supervisorAgent(profile, deps) {
|
|
9945
|
-
const name = profile.name ?? "supervisor";
|
|
9946
|
-
const systemPrompt = profile.systemPrompt ?? "";
|
|
9947
|
-
const harness = profile.harness ?? null;
|
|
9948
|
-
if (harness === null) {
|
|
9949
|
-
const brain = deps.brain ?? routerBrainFromProfile(profile, deps);
|
|
9950
|
-
return driverAgent({
|
|
9951
|
-
name,
|
|
9952
|
-
brain,
|
|
9953
|
-
blobs: deps.blobs,
|
|
9954
|
-
makeWorkerAgent: deps.makeWorkerAgent,
|
|
9955
|
-
perWorker: deps.perWorker,
|
|
9956
|
-
systemPrompt,
|
|
9957
|
-
...deps.extraTools ? { extraTools: deps.extraTools } : {},
|
|
9958
|
-
...deps.executeExtraTool ? { executeExtraTool: deps.executeExtraTool } : {},
|
|
9959
|
-
...deps.maxTurns !== void 0 ? { maxTurns: deps.maxTurns } : {}
|
|
9960
|
-
});
|
|
9961
|
-
}
|
|
9962
|
-
const driveHarness = deps.driveHarness;
|
|
9963
|
-
if (!driveHarness) {
|
|
9964
|
-
throw new ValidationError(
|
|
9965
|
-
`supervisorAgent: profile.harness="${harness}" needs deps.driveHarness (how to run the harness with the coordination MCP mounted)`
|
|
9966
|
-
);
|
|
9967
|
-
}
|
|
9968
|
-
return {
|
|
9969
|
-
name,
|
|
9970
|
-
async act(task, scope) {
|
|
9971
|
-
const mcp = await serveCoordinationMcp({
|
|
9972
|
-
scope,
|
|
9973
|
-
blobs: deps.blobs,
|
|
9974
|
-
makeWorkerAgent: deps.makeWorkerAgent,
|
|
9975
|
-
perWorker: deps.perWorker
|
|
9976
|
-
});
|
|
9977
|
-
try {
|
|
9978
|
-
await driveHarness({ profile, task, scope, coordinationMcpUrl: mcp.url });
|
|
9979
|
-
return await finalizeBestDelivered(mcp.settled(), deps.blobs);
|
|
9980
|
-
} finally {
|
|
9981
|
-
await mcp.close();
|
|
9982
|
-
}
|
|
9983
|
-
}
|
|
9984
|
-
};
|
|
9985
|
-
}
|
|
9986
|
-
function routerBrainFromProfile(profile, deps) {
|
|
9987
|
-
if (!deps.router) {
|
|
9988
|
-
throw new ValidationError(
|
|
9989
|
-
"supervisorAgent: a router-brained supervisor (harness null) needs deps.router (or deps.brain)"
|
|
9990
|
-
);
|
|
9991
|
-
}
|
|
9992
|
-
return routerBrain({ ...deps.router, model: profile.model ?? deps.router.model });
|
|
9993
|
-
}
|
|
9994
|
-
|
|
9995
|
-
// src/runtime/supervise/supervise.ts
|
|
9996
|
-
function workerFromBackend(backend, deliverable) {
|
|
9997
|
-
return (rawProfile) => {
|
|
9998
|
-
const p = rawProfile ?? {};
|
|
9999
|
-
const name = typeof p.name === "string" && p.name.length > 0 ? p.name : "worker";
|
|
10000
|
-
const spec = { profile: rawProfile, harness: null };
|
|
10001
|
-
const ctx = { signal: new AbortController().signal, seams: {} };
|
|
10002
|
-
const built = createExecutor(backend)(spec, ctx);
|
|
10003
|
-
const executor = deliverable ? gateOnDeliverable(built, deliverable) : built;
|
|
10004
|
-
return { name, act: async () => "", executorSpec: { ...spec, executor } };
|
|
10005
|
-
};
|
|
10006
|
-
}
|
|
10007
|
-
function defaultPerWorker(budget) {
|
|
10008
|
-
return {
|
|
10009
|
-
maxIterations: budget.maxIterations,
|
|
10010
|
-
maxTokens: Math.max(1, Math.floor(budget.maxTokens / 4))
|
|
10011
|
-
};
|
|
10012
|
-
}
|
|
10013
|
-
function supervise(profile, task, opts) {
|
|
10014
|
-
const backendModel = opts.backend?.model;
|
|
10015
|
-
assertModelAllowed(opts.router?.model, opts.allowedModels);
|
|
10016
|
-
assertModelAllowed(profile.model, opts.allowedModels);
|
|
10017
|
-
assertModelAllowed(
|
|
10018
|
-
typeof backendModel === "string" ? backendModel : void 0,
|
|
10019
|
-
opts.allowedModels
|
|
10020
|
-
);
|
|
10021
|
-
const ctx = createInMemoryRunContext({ withDriver: true });
|
|
10022
|
-
const blobs = opts.blobs ?? ctx.blobs;
|
|
10023
|
-
const perWorker = opts.perWorker ?? defaultPerWorker(opts.budget);
|
|
10024
|
-
let makeWorkerAgent = opts.makeWorkerAgent;
|
|
10025
|
-
if (!makeWorkerAgent) {
|
|
10026
|
-
if (!opts.backend) {
|
|
10027
|
-
throw new ValidationError(
|
|
10028
|
-
"supervise: provide opts.backend (where workers run) or opts.makeWorkerAgent"
|
|
10029
|
-
);
|
|
10030
|
-
}
|
|
10031
|
-
makeWorkerAgent = workerFromBackend(opts.backend, opts.deliverable);
|
|
10032
|
-
}
|
|
10033
|
-
const agent = supervisorAgent(profile, {
|
|
10034
|
-
blobs,
|
|
10035
|
-
makeWorkerAgent,
|
|
10036
|
-
perWorker,
|
|
10037
|
-
...opts.router ? { router: opts.router } : {},
|
|
10038
|
-
...opts.brain ? { brain: opts.brain } : {},
|
|
10039
|
-
...opts.driveHarness ? { driveHarness: opts.driveHarness } : {},
|
|
10040
|
-
...opts.extraTools ? { extraTools: opts.extraTools } : {},
|
|
10041
|
-
...opts.executeExtraTool ? { executeExtraTool: opts.executeExtraTool } : {},
|
|
10042
|
-
...opts.maxTurns !== void 0 ? { maxTurns: opts.maxTurns } : {}
|
|
10043
|
-
});
|
|
10044
|
-
return createSupervisor().run(agent, task, {
|
|
10045
|
-
budget: opts.budget,
|
|
10046
|
-
runId: opts.runId ?? "supervise",
|
|
10047
|
-
journal: ctx.journal,
|
|
10048
|
-
blobs,
|
|
10049
|
-
executors: ctx.executors,
|
|
10050
|
-
maxDepth: opts.maxDepth ?? 8,
|
|
10051
|
-
...opts.now ? { now: opts.now } : {}
|
|
10052
|
-
});
|
|
10053
|
-
}
|
|
10054
|
-
|
|
10055
10178
|
// src/runtime/supervise/trace-source.ts
|
|
10056
10179
|
function toToolSpan(input, runId, seq, at) {
|
|
10057
10180
|
const startedAt = typeof input.startedAt === "number" ? input.startedAt : at;
|
|
@@ -10690,6 +10813,17 @@ export {
|
|
|
10690
10813
|
composeLoopTraceEmitters,
|
|
10691
10814
|
DelegationTaskQueue,
|
|
10692
10815
|
hashIdempotencyInput,
|
|
10816
|
+
createInMemoryRunContext,
|
|
10817
|
+
supervisorAgent,
|
|
10818
|
+
workerFromBackend,
|
|
10819
|
+
supervise,
|
|
10820
|
+
defaultDelegateBudget,
|
|
10821
|
+
delegate,
|
|
10822
|
+
DELEGATE_TOOL_NAME,
|
|
10823
|
+
DELEGATE_DESCRIPTION,
|
|
10824
|
+
DELEGATE_INPUT_SCHEMA,
|
|
10825
|
+
validateDelegateArgs,
|
|
10826
|
+
createDelegateHandler,
|
|
10693
10827
|
formatDetachedSessionRef,
|
|
10694
10828
|
parseDetachedSessionRef,
|
|
10695
10829
|
detachedTurnEvents,
|
|
@@ -10732,10 +10866,6 @@ export {
|
|
|
10732
10866
|
watchTrace,
|
|
10733
10867
|
runCoderChecks,
|
|
10734
10868
|
patchDelivered,
|
|
10735
|
-
createInMemoryRunContext,
|
|
10736
|
-
supervisorAgent,
|
|
10737
|
-
workerFromBackend,
|
|
10738
|
-
supervise,
|
|
10739
10869
|
decodeToolPart,
|
|
10740
10870
|
createPushTraceSource,
|
|
10741
10871
|
sandboxSessionTraceSource,
|
|
@@ -10750,4 +10880,4 @@ export {
|
|
|
10750
10880
|
computeFindingId2 as computeFindingId,
|
|
10751
10881
|
makeFinding3 as makeFinding
|
|
10752
10882
|
};
|
|
10753
|
-
//# sourceMappingURL=chunk-
|
|
10883
|
+
//# sourceMappingURL=chunk-5ISW5JUF.js.map
|