@tangle-network/agent-runtime 0.320.1 → 0.322.1
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-BKglRwjB.js → activation-CBv_0LUh.js} +2 -2
- package/dist/{activation-BKglRwjB.js.map → activation-CBv_0LUh.js.map} +1 -1
- package/dist/{activation-BSwcsNSQ.d.ts → activation-CZGz2kuu.d.ts} +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.js +3 -3
- package/dist/{coordination-driver-D85RWATT.js → coordination-driver-C2Zm5lU4.js} +71 -3
- package/dist/coordination-driver-C2Zm5lU4.js.map +1 -0
- package/dist/{delegate-BHRR-4hh.js → delegate-BV7AVmbB.js} +2 -2
- package/dist/{delegate-BHRR-4hh.js.map → delegate-BV7AVmbB.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +3 -3
- package/dist/{graph-BGMcJJP1.js → graph-CH3YiPog.js} +4 -4
- package/dist/{graph-BGMcJJP1.js.map → graph-CH3YiPog.js.map} +1 -1
- package/dist/{improvement-cycle-0cnwWPFY.js → improvement-cycle-CD1h5GSM.js} +5 -5
- package/dist/{improvement-cycle-0cnwWPFY.js.map → improvement-cycle-CD1h5GSM.js.map} +1 -1
- package/dist/{index-t672ISFX.d.ts → index-CGNQWpge.d.ts} +877 -551
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +6 -6
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-CFudOt5T.js → loop-runner-bin-CFxE376A.js} +3 -3
- package/dist/{loop-runner-bin-CFudOt5T.js.map → loop-runner-bin-CFxE376A.js.map} +1 -1
- package/dist/{loop-runner-bin-Fgmf_PQU.d.ts → loop-runner-bin-C_jaLCUO.d.ts} +2 -2
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-DCfdg0UD.d.ts → openai-tools-D1PDoBOz.d.ts} +2 -2
- package/dist/{prepare-DjCLEN-q.js → prepare-CFQLx9e3.js} +2 -2
- package/dist/{prepare-DjCLEN-q.js.map → prepare-CFQLx9e3.js.map} +1 -1
- package/dist/{profile-DmVM4Gxb.js → profile-BTbpdL9h.js} +40 -4
- package/dist/profile-BTbpdL9h.js.map +1 -0
- package/dist/profiles.d.ts +1 -1
- package/dist/{protected-model-port-D1fcnYdj.js → protected-model-port-f1N2f0Uq.js} +3 -3
- package/dist/{protected-model-port-D1fcnYdj.js.map → protected-model-port-f1N2f0Uq.js.map} +1 -1
- package/dist/{provision-supervisor-BUMhF1yb.js → provision-supervisor-ftJZhqBU.js} +3 -3
- package/dist/{provision-supervisor-BUMhF1yb.js.map → provision-supervisor-ftJZhqBU.js.map} +1 -1
- package/dist/{runtime-B47V5Omi.js → runtime-EiTCboO2.js} +465 -12
- package/dist/runtime-EiTCboO2.js.map +1 -0
- package/dist/{search-executor-DjKdQluM.js → search-executor-ECJ2TmC-.js} +2 -2
- package/dist/{search-executor-DjKdQluM.js.map → search-executor-ECJ2TmC-.js.map} +1 -1
- package/dist/{server-Gpgr0WP-.js → server-C2k5wX4k.js} +3 -3
- package/dist/{server-Gpgr0WP-.js.map → server-C2k5wX4k.js.map} +1 -1
- package/dist/{supervise-C2ThvLgZ.js → supervise-BjrRk-AN.js} +194 -133
- package/dist/supervise-BjrRk-AN.js.map +1 -0
- package/dist/{supervisor-CCtmmmOz.js → supervisor-BMMdI4T-.js} +606 -81
- package/dist/supervisor-BMMdI4T-.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +6 -6
- package/skills/profile-authoring/SKILL.md +1 -0
- package/dist/coordination-driver-D85RWATT.js.map +0 -1
- package/dist/profile-DmVM4Gxb.js.map +0 -1
- package/dist/runtime-B47V5Omi.js.map +0 -1
- package/dist/supervise-C2ThvLgZ.js.map +0 -1
- package/dist/supervisor-CCtmmmOz.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { a as graphRunsFor, d as recordGraphRun, i as graphRegistry, l as lookupGraph, p as taskShapeDigest, r as graphFromStored, t as digestOfGraph } from "./graph-registry-BuJbzTzF.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Cn as readPromptOptions, Hn as InMemoryResultBlobStore, It as createWorktreeCliExecutor, Nt as createExecutor, Ot as verdictFromJudgeScore, Pr as contentAddress, Pt as createExecutorRegistry, Sn as assertBoxlessPromptOptions, Tn as runBrainLoop, Un as InMemorySpawnJournal, Wn as insideCursorNamespace, Xn as readCommittedJsonLines, Yn as prepareJsonlAppend, Zn as writeAllBytes, _n as runAgentRounds, aa as executableAgentSpecSnapshot, er as isTraceAnalysisStore, hn as defaultSelectWinner, ht as mapExecutorResult, ia as executableAgentProfileSnapshot, j as settledToIteration, mt as gateOnDeliverable, oa as detachedFrozen, pt as rollingDispatch, r as createSupervisor, rt as coordinationProfileToolPrefix, sa as detachedSnapshot, v as withDriverExecutor, va as notifySandboxEventObserver, vn as createSandboxLineage, vt as CheckUnavailableError, wn as routerBrain } from "./supervisor-BMMdI4T-.js";
|
|
3
3
|
import { i as ConfigError, m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
|
|
4
|
-
import { B as runAgentic, G as observe, K as renderReport, U as ObservationError, V as sample, X as strategyAuthorMethod, a as reconcileInterruptedSearchCalls, c as searchExecutor, q as profileChatClient, r as dedicatedLane, x as runtimeShipDecision, z as refine } from "./search-executor-
|
|
4
|
+
import { B as runAgentic, G as observe, K as renderReport, U as ObservationError, V as sample, X as strategyAuthorMethod, a as reconcileInterruptedSearchCalls, c as searchExecutor, q as profileChatClient, r as dedicatedLane, x as runtimeShipDecision, z as refine } from "./search-executor-ECJ2TmC-.js";
|
|
5
5
|
import { A as markPutStreamVerified, J as fnv1a32Hex, L as immutableCandidateValue, N as canonicalCandidateDigest$1, S as captureMaterializedWorkspace, U as chargedTokens, V as addSpend, W as cloneSpend, X as isAbortError, Y as hasCompleteCacheBreakdown, Z as isAsyncIterable, et as randomSuffix, it as stringifySafe, lt as zeroSpend, q as errorMessage, rt as sleep, xt as armDeadlineTimer, y as WorkspaceScanLimitError, z as sha256Bytes$1 } from "./workspace-streams-DFAhW7hF.js";
|
|
6
|
-
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-CNe257pB.js";
|
|
6
|
+
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CNe257pB.js";
|
|
7
7
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
8
8
|
import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction-DylCC_ot.js";
|
|
9
|
-
import { D as foldCoordinationRecords, w as createInMemoryRunContext } from "./coordination-driver-
|
|
10
|
-
import { r as supervise } from "./supervise-
|
|
9
|
+
import { D as foldCoordinationRecords, w as createInMemoryRunContext } from "./coordination-driver-C2Zm5lU4.js";
|
|
10
|
+
import { r as supervise } from "./supervise-BjrRk-AN.js";
|
|
11
11
|
import "./run-layout-DSCWdbX2.js";
|
|
12
|
-
import "./provision-supervisor-
|
|
13
|
-
import "./delegate-
|
|
14
|
-
import "./graph-
|
|
12
|
+
import "./provision-supervisor-ftJZhqBU.js";
|
|
13
|
+
import "./delegate-BV7AVmbB.js";
|
|
14
|
+
import "./graph-CH3YiPog.js";
|
|
15
15
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
16
16
|
import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, createTraceAnalyst, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
|
|
17
17
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
@@ -23,6 +23,7 @@ import { chmod, link, lstat, mkdir, mkdtemp, open, opendir, readFile, readdir, r
|
|
|
23
23
|
import { tmpdir } from "node:os";
|
|
24
24
|
import { isDeepStrictEqual, promisify } from "node:util";
|
|
25
25
|
import { redact } from "@tangle-network/agent-eval/traces";
|
|
26
|
+
import { z } from "zod";
|
|
26
27
|
import { Readable } from "node:stream";
|
|
27
28
|
import { collectAgentResponseText } from "@tangle-network/sandbox";
|
|
28
29
|
import { SearchRecorder, asha, beam, createRunCostLedger, estimateNode, fsCampaignStorage, openSearchLedger, renderSearchSummary, runProfileMatrix, runSearch, searchClaimReserveUsd, searchModelIdentity, surfaceDiff } from "@tangle-network/agent-eval/campaign";
|
|
@@ -456,8 +457,9 @@ async function connectHttpMcp(spec) {
|
|
|
456
457
|
let sessionId;
|
|
457
458
|
let nextId = 1;
|
|
458
459
|
let closed = false;
|
|
459
|
-
const post = async (path, body, method = "POST") => fetchImpl(`${endpoint.origin}${endpoint.pathname}${endpoint.search}${path}`, {
|
|
460
|
+
const post = async (path, body, method = "POST", signal) => fetchImpl(`${endpoint.origin}${endpoint.pathname}${endpoint.search}${path}`, {
|
|
460
461
|
method,
|
|
462
|
+
...signal ? { signal } : {},
|
|
461
463
|
headers: {
|
|
462
464
|
accept: "application/json, text/event-stream",
|
|
463
465
|
...body !== void 0 ? { "content-type": "application/json" } : {},
|
|
@@ -479,7 +481,7 @@ async function connectHttpMcp(spec) {
|
|
|
479
481
|
id,
|
|
480
482
|
method,
|
|
481
483
|
params
|
|
482
|
-
}, "POST");
|
|
484
|
+
}, "POST", controller.signal);
|
|
483
485
|
const sessionHeader = res.headers.get("mcp-session-id");
|
|
484
486
|
if (sessionHeader) sessionId = sessionHeader;
|
|
485
487
|
if (!res.ok) {
|
|
@@ -7539,6 +7541,457 @@ async function bestProfileFor(reg, name) {
|
|
|
7539
7541
|
} : void 0;
|
|
7540
7542
|
}
|
|
7541
7543
|
//#endregion
|
|
7544
|
+
//#region src/runtime/supervise/remote-supervisor.ts
|
|
7545
|
+
const agentSchema = z.object({
|
|
7546
|
+
id: z.string(),
|
|
7547
|
+
parent: z.string().optional(),
|
|
7548
|
+
label: z.string(),
|
|
7549
|
+
status: z.string(),
|
|
7550
|
+
runtime: z.string()
|
|
7551
|
+
}).passthrough();
|
|
7552
|
+
const treeSchema = z.object({
|
|
7553
|
+
root: z.string(),
|
|
7554
|
+
nodes: z.array(agentSchema),
|
|
7555
|
+
inFlight: z.number().int().nonnegative()
|
|
7556
|
+
});
|
|
7557
|
+
const eventPageSchema = z.discriminatedUnion("status", [z.object({
|
|
7558
|
+
status: z.literal("unavailable"),
|
|
7559
|
+
reason: z.enum(["unknown-worker", "not-captured"])
|
|
7560
|
+
}), z.object({
|
|
7561
|
+
status: z.literal("available"),
|
|
7562
|
+
entries: z.array(z.object({
|
|
7563
|
+
sequence: z.number().int().nonnegative(),
|
|
7564
|
+
at: z.number(),
|
|
7565
|
+
event: z.unknown(),
|
|
7566
|
+
omitted: z.enum(["event-too-large", "event-not-serializable"]).optional()
|
|
7567
|
+
})),
|
|
7568
|
+
cursor: z.object({
|
|
7569
|
+
epoch: z.string(),
|
|
7570
|
+
next: z.number().int().nonnegative()
|
|
7571
|
+
}),
|
|
7572
|
+
reset: z.boolean(),
|
|
7573
|
+
historyExpired: z.boolean(),
|
|
7574
|
+
remaining: z.number().int().nonnegative()
|
|
7575
|
+
})]);
|
|
7576
|
+
/** Connect with the server's readOnly URL and protected headers; credentials never enter a profile. */
|
|
7577
|
+
async function connectRemoteSupervisor(spec) {
|
|
7578
|
+
const connection = await connectHttpMcp(spec);
|
|
7579
|
+
if (!connection.tools.some((tool) => tool.name === "observe_agent")) {
|
|
7580
|
+
await connection.close();
|
|
7581
|
+
throw new ValidationError("remote supervisor does not expose observe_agent");
|
|
7582
|
+
}
|
|
7583
|
+
const call = async (args) => {
|
|
7584
|
+
const text = await connection.callTool("observe_agent", args);
|
|
7585
|
+
if (text.startsWith("ERROR:")) throw new ValidationError(text);
|
|
7586
|
+
const result = z.record(z.string(), z.unknown()).parse(JSON.parse(text));
|
|
7587
|
+
if (result.error) throw new ValidationError(`remote supervisor refused observation: ${String(result.error)}`);
|
|
7588
|
+
return result;
|
|
7589
|
+
};
|
|
7590
|
+
return {
|
|
7591
|
+
tree: async () => treeSchema.parse((await call({ tree: true })).tree),
|
|
7592
|
+
observe: async (workerId, cursor) => {
|
|
7593
|
+
const agent = await call({
|
|
7594
|
+
workerId,
|
|
7595
|
+
events: true,
|
|
7596
|
+
...cursor ? { eventCursor: cursor } : {}
|
|
7597
|
+
});
|
|
7598
|
+
return {
|
|
7599
|
+
agent,
|
|
7600
|
+
events: eventPageSchema.parse(agent.events)
|
|
7601
|
+
};
|
|
7602
|
+
},
|
|
7603
|
+
close: () => connection.close()
|
|
7604
|
+
};
|
|
7605
|
+
}
|
|
7606
|
+
//#endregion
|
|
7607
|
+
//#region src/runtime/supervise/search-spec.ts
|
|
7608
|
+
/**
|
|
7609
|
+
* SearchSpec: one data value for a multi-agent research configuration, and the compiler that maps
|
|
7610
|
+
* it onto exactly one existing call, `supervise(profile, task, options)` or `runGraph(graph,
|
|
7611
|
+
* options)`. The design record is `docs/design/search-spec.md`.
|
|
7612
|
+
*
|
|
7613
|
+
* Nothing here runs anything. The compiler only chooses options those two calls already take, so
|
|
7614
|
+
* the control loop, the budget, the check, the continuation and the journal stay theirs. A spec is
|
|
7615
|
+
* plain data with a canonical digest; the compiled call records that digest on the run's root as
|
|
7616
|
+
* `execution.correlation.searchSpecDigest`, which the journal's root registration and the settle
|
|
7617
|
+
* record's tree both carry, so two runs can be compared as the same design on two problems.
|
|
7618
|
+
*
|
|
7619
|
+
* Every axis value compiles to an option, or to a refusal before any compute. An axis value the
|
|
7620
|
+
* compiled call would not read is refused rather than recorded, because a digest that names a knob
|
|
7621
|
+
* which changes nothing would make two different runs look like one design.
|
|
7622
|
+
*/
|
|
7623
|
+
/** The correlation key the compiled call records the spec's digest under. Runtime writes it; a
|
|
7624
|
+
* caller that supplies it is refused. */
|
|
7625
|
+
const SEARCH_SPEC_CORRELATION_KEY = "searchSpecDigest";
|
|
7626
|
+
const SPAWN_GRANT = `${coordinationProfileToolPrefix}spawn_worker`;
|
|
7627
|
+
function refuse(message) {
|
|
7628
|
+
throw new ValidationError(`SearchSpec: ${message}`);
|
|
7629
|
+
}
|
|
7630
|
+
const quoted = (values) => values.map((v) => `'${v}'`).join(", ");
|
|
7631
|
+
function record(value, where, required, optional = []) {
|
|
7632
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) refuse(`${where} must be an object`);
|
|
7633
|
+
const fields = value;
|
|
7634
|
+
const known = /* @__PURE__ */ new Set([...required, ...optional]);
|
|
7635
|
+
const unknown = Object.keys(fields).filter((key) => !known.has(key));
|
|
7636
|
+
if (unknown.length > 0) refuse(`${where} has unknown ${unknown.length === 1 ? "key" : "keys"} ${quoted(unknown)}; it takes ${quoted([...required, ...optional])}`);
|
|
7637
|
+
const missing = required.filter((key) => fields[key] === void 0);
|
|
7638
|
+
if (missing.length > 0) refuse(`${where} is missing ${quoted(missing)}`);
|
|
7639
|
+
return fields;
|
|
7640
|
+
}
|
|
7641
|
+
function oneOf(value, where, values) {
|
|
7642
|
+
if (typeof value === "string" && values.includes(value)) return value;
|
|
7643
|
+
return refuse(`${where} is ${JSON.stringify(value)}; it must be one of ${quoted(values)}`);
|
|
7644
|
+
}
|
|
7645
|
+
function names(value, where) {
|
|
7646
|
+
if (!Array.isArray(value) || value.length === 0 || !value.every((item) => typeof item === "string" && item.trim() !== "")) refuse(`${where} must be a non-empty list of non-empty strings`);
|
|
7647
|
+
const list = value;
|
|
7648
|
+
if (new Set(list).size !== list.length) refuse(`${where} lists a name twice`);
|
|
7649
|
+
return Object.freeze([...list].sort());
|
|
7650
|
+
}
|
|
7651
|
+
function integer(value, where, min) {
|
|
7652
|
+
if (!Number.isSafeInteger(value) || value < min) refuse(`${where} must be an integer >= ${min}`);
|
|
7653
|
+
return value;
|
|
7654
|
+
}
|
|
7655
|
+
/**
|
|
7656
|
+
* Check a spec and return its canonical frozen form: every axis present, no unknown key, no
|
|
7657
|
+
* contradictory pair of values. Lists are sorted, so two specs that mean the same digest the same.
|
|
7658
|
+
*/
|
|
7659
|
+
function assertSearchSpec(spec) {
|
|
7660
|
+
const axes = [
|
|
7661
|
+
"state",
|
|
7662
|
+
"context",
|
|
7663
|
+
"select",
|
|
7664
|
+
"workers",
|
|
7665
|
+
"comms",
|
|
7666
|
+
"evaluate",
|
|
7667
|
+
"stop"
|
|
7668
|
+
];
|
|
7669
|
+
if (typeof spec !== "object" || spec === null || Array.isArray(spec)) refuse("a spec must be an object with the axes state, context, select, workers, comms, evaluate and stop");
|
|
7670
|
+
const top = spec;
|
|
7671
|
+
const unknownAxes = Object.keys(top).filter((key) => !axes.includes(key));
|
|
7672
|
+
if (unknownAxes.length > 0) refuse(`unknown axis ${quoted(unknownAxes)}; the axes are ${quoted(axes)}`);
|
|
7673
|
+
const missingAxes = axes.filter((axis) => top[axis] === void 0);
|
|
7674
|
+
if (missingAxes.length > 0) refuse(`axis ${quoted(missingAxes)} is missing`);
|
|
7675
|
+
if (top.state === "conversation") refuse("state 'conversation' is not a value: research memory that lives only in a harness conversation cannot be checkpointed, inspected or ablated; it is always harness");
|
|
7676
|
+
const state = oneOf(top.state, "state", ["harness"]);
|
|
7677
|
+
const context = oneOf(top.context, "context", ["fresh", "native"]);
|
|
7678
|
+
const select = oneOf(top.select, "select", [
|
|
7679
|
+
"lead",
|
|
7680
|
+
"advisor",
|
|
7681
|
+
"code",
|
|
7682
|
+
"self",
|
|
7683
|
+
"fixed"
|
|
7684
|
+
]);
|
|
7685
|
+
const workersIn = record(top.workers, "workers", ["count", "isolation"], ["models"]);
|
|
7686
|
+
const count = integer(workersIn.count, "workers.count", 0);
|
|
7687
|
+
const isolation = oneOf(workersIn.isolation, "workers.isolation", ["isolated", "shared"]);
|
|
7688
|
+
const models = workersIn.models === void 0 ? void 0 : names(workersIn.models, "workers.models");
|
|
7689
|
+
const comms = oneOf(top.comms, "comms", [
|
|
7690
|
+
"none",
|
|
7691
|
+
"assignments",
|
|
7692
|
+
"messages"
|
|
7693
|
+
]);
|
|
7694
|
+
const evaluateIn = record(top.evaluate, "evaluate", ["feedback", "bar"], ["analysts"]);
|
|
7695
|
+
const feedback = oneOf(evaluateIn.feedback, "evaluate.feedback", ["verbatim", "off"]);
|
|
7696
|
+
const bar = oneOf(evaluateIn.bar, "evaluate.bar", ["on", "off"]);
|
|
7697
|
+
const analysts = evaluateIn.analysts === void 0 ? void 0 : names(evaluateIn.analysts, "evaluate.analysts");
|
|
7698
|
+
const stopIn = record(top.stop, "stop", ["maxBarren"], ["plateau"]);
|
|
7699
|
+
const maxBarren = integer(stopIn.maxBarren, "stop.maxBarren", 1);
|
|
7700
|
+
let plateau;
|
|
7701
|
+
if (stopIn.plateau !== void 0) {
|
|
7702
|
+
const plateauIn = record(stopIn.plateau, "stop.plateau", ["window", "minDelta"]);
|
|
7703
|
+
const minDelta = plateauIn.minDelta;
|
|
7704
|
+
if (typeof minDelta !== "number" || !Number.isFinite(minDelta) || minDelta < 0) refuse("stop.plateau.minDelta must be a finite number >= 0");
|
|
7705
|
+
plateau = Object.freeze({
|
|
7706
|
+
window: integer(plateauIn.window, "stop.plateau.window", 1),
|
|
7707
|
+
minDelta
|
|
7708
|
+
});
|
|
7709
|
+
}
|
|
7710
|
+
if (select === "advisor" && context === "native") refuse("select 'advisor' sees each epoch only through the coordinator's projection, so it needs context 'fresh'; with 'native' its earlier turns would stay in its context");
|
|
7711
|
+
if (select === "code" && context === "fresh") refuse("select 'code' runs the root in your brain, in process; it has no harness session for context 'fresh' to renew");
|
|
7712
|
+
if (select === "advisor" && count === 0) refuse("select 'advisor' only assigns work, so workers.count must be at least 1");
|
|
7713
|
+
if (count === 0 && comms !== "none") refuse(`workers.count 0 runs the root alone, so comms must be 'none', not '${comms}'`);
|
|
7714
|
+
if (count > 0 && comms === "none") refuse(`comms 'none' leaves ${count} worker(s) with no channel; use 'assignments' or 'messages'`);
|
|
7715
|
+
if (comms === "messages" && count < 2) refuse(`comms 'messages' needs at least two peers to message each other; workers.count is ${count}`);
|
|
7716
|
+
if (select === "self" && comms !== "messages") refuse("select 'self' lets the peers divide the work by messages, so comms must be 'messages'; use select 'fixed' for independent attempts");
|
|
7717
|
+
if (count === 0 && isolation === "shared") refuse("workers.isolation 'shared' places workers in shared boxes, and workers.count is 0");
|
|
7718
|
+
if (count === 0 && models !== void 0) refuse("workers.models lists the models workers may use, and workers.count is 0");
|
|
7719
|
+
return Object.freeze({
|
|
7720
|
+
state,
|
|
7721
|
+
context,
|
|
7722
|
+
select,
|
|
7723
|
+
workers: Object.freeze({
|
|
7724
|
+
count,
|
|
7725
|
+
...models === void 0 ? {} : { models },
|
|
7726
|
+
isolation
|
|
7727
|
+
}),
|
|
7728
|
+
comms,
|
|
7729
|
+
evaluate: Object.freeze({
|
|
7730
|
+
feedback,
|
|
7731
|
+
bar,
|
|
7732
|
+
...analysts === void 0 ? {} : { analysts }
|
|
7733
|
+
}),
|
|
7734
|
+
stop: Object.freeze({
|
|
7735
|
+
maxBarren,
|
|
7736
|
+
...plateau === void 0 ? {} : { plateau }
|
|
7737
|
+
})
|
|
7738
|
+
});
|
|
7739
|
+
}
|
|
7740
|
+
/** The canonical digest of a spec: equal for two specs that mean the same, different otherwise. */
|
|
7741
|
+
function searchSpecDigest(spec) {
|
|
7742
|
+
return canonicalCandidateDigest({
|
|
7743
|
+
kind: "agent-runtime.search-spec.v1",
|
|
7744
|
+
spec: assertSearchSpec(spec)
|
|
7745
|
+
});
|
|
7746
|
+
}
|
|
7747
|
+
const presetEvaluate = Object.freeze({
|
|
7748
|
+
feedback: "verbatim",
|
|
7749
|
+
bar: "off"
|
|
7750
|
+
});
|
|
7751
|
+
const presetStop = Object.freeze({ maxBarren: 2 });
|
|
7752
|
+
/**
|
|
7753
|
+
* The five configurations Runtime ships, as specs. Each is an ordinary spec: its digest is its
|
|
7754
|
+
* value's, and a consumer that changes any axis passes an inline spec with its own digest.
|
|
7755
|
+
*/
|
|
7756
|
+
const searchPresets = Object.freeze({
|
|
7757
|
+
/** One root alone in one session. */
|
|
7758
|
+
solo: () => assertSearchSpec({
|
|
7759
|
+
state: "harness",
|
|
7760
|
+
context: "native",
|
|
7761
|
+
select: "lead",
|
|
7762
|
+
workers: {
|
|
7763
|
+
count: 0,
|
|
7764
|
+
isolation: "isolated"
|
|
7765
|
+
},
|
|
7766
|
+
comms: "none",
|
|
7767
|
+
evaluate: presetEvaluate,
|
|
7768
|
+
stop: presetStop
|
|
7769
|
+
}),
|
|
7770
|
+
/** A doing lead with up to `width` workers at once, each in its own environment; any of them
|
|
7771
|
+
* may lead its own team within the same bound. */
|
|
7772
|
+
tree: (width) => assertSearchSpec({
|
|
7773
|
+
state: "harness",
|
|
7774
|
+
context: "native",
|
|
7775
|
+
select: "lead",
|
|
7776
|
+
workers: {
|
|
7777
|
+
count: width,
|
|
7778
|
+
isolation: "isolated"
|
|
7779
|
+
},
|
|
7780
|
+
comms: "assignments",
|
|
7781
|
+
evaluate: presetEvaluate,
|
|
7782
|
+
stop: presetStop
|
|
7783
|
+
}),
|
|
7784
|
+
/** A doing lead with up to `width` workers at once that may share boxes. */
|
|
7785
|
+
swarm: (width) => assertSearchSpec({
|
|
7786
|
+
state: "harness",
|
|
7787
|
+
context: "native",
|
|
7788
|
+
select: "lead",
|
|
7789
|
+
workers: {
|
|
7790
|
+
count: width,
|
|
7791
|
+
isolation: "shared"
|
|
7792
|
+
},
|
|
7793
|
+
comms: "assignments",
|
|
7794
|
+
evaluate: presetEvaluate,
|
|
7795
|
+
stop: presetStop
|
|
7796
|
+
}),
|
|
7797
|
+
/** `count` peers started by a convener, dividing the work by peer mail. */
|
|
7798
|
+
peers: (count) => assertSearchSpec({
|
|
7799
|
+
state: "harness",
|
|
7800
|
+
context: "native",
|
|
7801
|
+
select: "self",
|
|
7802
|
+
workers: {
|
|
7803
|
+
count,
|
|
7804
|
+
isolation: "isolated"
|
|
7805
|
+
},
|
|
7806
|
+
comms: "messages",
|
|
7807
|
+
evaluate: presetEvaluate,
|
|
7808
|
+
stop: presetStop
|
|
7809
|
+
}),
|
|
7810
|
+
/** Stateless Language Agents (arXiv 2610.07625): an assign-only advisor re-entered fresh every
|
|
7811
|
+
* epoch from the coordinator's projection, over `width` isolated leaf workers. */
|
|
7812
|
+
sla: (width) => assertSearchSpec({
|
|
7813
|
+
state: "harness",
|
|
7814
|
+
context: "fresh",
|
|
7815
|
+
select: "advisor",
|
|
7816
|
+
workers: {
|
|
7817
|
+
count: width,
|
|
7818
|
+
isolation: "isolated"
|
|
7819
|
+
},
|
|
7820
|
+
comms: "assignments",
|
|
7821
|
+
evaluate: presetEvaluate,
|
|
7822
|
+
stop: presetStop
|
|
7823
|
+
})
|
|
7824
|
+
});
|
|
7825
|
+
/** The `SuperviseOptions` an axis decides. A caller value for one is refused, naming the axis. */
|
|
7826
|
+
const ownedBy = Object.freeze({
|
|
7827
|
+
budget: "inputs.budget",
|
|
7828
|
+
deliverable: "inputs.deliverable",
|
|
7829
|
+
continuation: "context, evaluate, stop and inputs.continuation",
|
|
7830
|
+
workerSlots: "workers.count",
|
|
7831
|
+
allowedModels: "workers.models",
|
|
7832
|
+
peerMail: "comms 'messages'",
|
|
7833
|
+
analysts: "inputs.analysts",
|
|
7834
|
+
analyzeOnSettle: "evaluate.analysts",
|
|
7835
|
+
stopRule: "stop.plateau",
|
|
7836
|
+
maxDepth: "select 'advisor'",
|
|
7837
|
+
inheritSpawnRights: "select 'advisor'"
|
|
7838
|
+
});
|
|
7839
|
+
function grantsSpawn(profile) {
|
|
7840
|
+
return profile.tools?.[SPAWN_GRANT] === true;
|
|
7841
|
+
}
|
|
7842
|
+
function profileTable(entries) {
|
|
7843
|
+
const table = /* @__PURE__ */ new Map();
|
|
7844
|
+
for (const item of entries) {
|
|
7845
|
+
const entry = "profile" in item ? item : { profile: item };
|
|
7846
|
+
const name = entry.profile.name;
|
|
7847
|
+
if (typeof name !== "string" || name.trim() === "") refuse("every profile in inputs.workers needs a name, which the root spawns it by");
|
|
7848
|
+
if (table.has(name)) refuse(`inputs.workers names profile '${name}' twice`);
|
|
7849
|
+
table.set(name, entry);
|
|
7850
|
+
}
|
|
7851
|
+
const listed = Object.freeze([...table.keys()]);
|
|
7852
|
+
return Object.freeze({
|
|
7853
|
+
resolve: (name) => table.get(name),
|
|
7854
|
+
names: () => listed
|
|
7855
|
+
});
|
|
7856
|
+
}
|
|
7857
|
+
/** The worker backend with the spec's placement, refusing a placement the spec contradicts. */
|
|
7858
|
+
function placedBackend(spec, inputs) {
|
|
7859
|
+
const backend = inputs.options?.backend;
|
|
7860
|
+
const sharedAlready = backend?.backend === "provider" && backend.shared !== void 0;
|
|
7861
|
+
if (spec.workers.isolation === "isolated") {
|
|
7862
|
+
if (inputs.sharedPlacement !== void 0 || sharedAlready) refuse("workers.isolation 'isolated' gives every worker its own environment; drop the shared placement or use isolation 'shared'");
|
|
7863
|
+
return backend;
|
|
7864
|
+
}
|
|
7865
|
+
if (inputs.sharedPlacement === void 0) return backend;
|
|
7866
|
+
if (backend?.backend !== "provider") refuse(`inputs.sharedPlacement places workers through a 'provider' backend; options.backend is ${backend === void 0 ? "absent" : `'${backend.backend}'`}`);
|
|
7867
|
+
if (sharedAlready) refuse("options.backend already carries a shared placement; pass it once");
|
|
7868
|
+
return Object.freeze({
|
|
7869
|
+
...backend,
|
|
7870
|
+
shared: inputs.sharedPlacement
|
|
7871
|
+
});
|
|
7872
|
+
}
|
|
7873
|
+
/** The one root of a graph: the node that delegates and is never delegated to. */
|
|
7874
|
+
function graphRoot(graph) {
|
|
7875
|
+
const delegates = graph.edges.filter((edge) => edge.kind === "delegates");
|
|
7876
|
+
const targets = new Set(delegates.map((edge) => edge.to));
|
|
7877
|
+
const roots = [...new Set(delegates.map((edge) => edge.from))].filter((id) => !targets.has(id));
|
|
7878
|
+
return roots.length === 1 ? graph.nodes.find((node) => node.id === roots[0])?.profile : void 0;
|
|
7879
|
+
}
|
|
7880
|
+
/**
|
|
7881
|
+
* Compile a spec onto exactly one existing call. Every refusal names the axis or input and what
|
|
7882
|
+
* would have gone wrong, and happens before any compute.
|
|
7883
|
+
*
|
|
7884
|
+
* ```ts
|
|
7885
|
+
* const compiled = compileSearchSpec(searchPresets.sla(3), { profile, task, budget, deliverable,
|
|
7886
|
+
* deadline, continuation: { profile: words }, workers, options: { backend, coordination, runDir } })
|
|
7887
|
+
* const result = compiled.call === 'supervise'
|
|
7888
|
+
* ? await supervise(compiled.profile, compiled.task, compiled.options)
|
|
7889
|
+
* : (await runGraph(compiled.graph, compiled.options)).result
|
|
7890
|
+
* ```
|
|
7891
|
+
*/
|
|
7892
|
+
function compileSearchSpec(raw, inputs) {
|
|
7893
|
+
const spec = assertSearchSpec(raw);
|
|
7894
|
+
const digest = searchSpecDigest(spec);
|
|
7895
|
+
const passed = inputs.options ?? {};
|
|
7896
|
+
for (const [key, axis] of Object.entries(ownedBy)) if (passed[key] !== void 0) refuse(`options.${key} is decided by ${axis}; change the spec or that input instead`);
|
|
7897
|
+
if (inputs.deliverable === void 0) refuse("inputs.deliverable is required: a spec run is sent back by its check");
|
|
7898
|
+
const correlation = passed.execution?.correlation ?? {};
|
|
7899
|
+
if (Object.hasOwn(correlation, "searchSpecDigest")) refuse(`options.execution.correlation cannot set ${SEARCH_SPEC_CORRELATION_KEY}; Runtime records it`);
|
|
7900
|
+
const execution = Object.freeze({
|
|
7901
|
+
...passed.execution,
|
|
7902
|
+
correlation: Object.freeze({
|
|
7903
|
+
...correlation,
|
|
7904
|
+
[SEARCH_SPEC_CORRELATION_KEY]: digest
|
|
7905
|
+
})
|
|
7906
|
+
});
|
|
7907
|
+
const continuation = {
|
|
7908
|
+
deadline: inputs.deadline,
|
|
7909
|
+
maxBarren: spec.stop.maxBarren,
|
|
7910
|
+
profile: inputs.continuation.profile,
|
|
7911
|
+
failures: spec.evaluate.feedback,
|
|
7912
|
+
panel: "off",
|
|
7913
|
+
bar: spec.evaluate.bar,
|
|
7914
|
+
session: spec.context,
|
|
7915
|
+
...inputs.continuation.reference === void 0 ? {} : { reference: inputs.continuation.reference },
|
|
7916
|
+
...inputs.continuation.append === void 0 ? {} : { append: inputs.continuation.append }
|
|
7917
|
+
};
|
|
7918
|
+
const backend = placedBackend(spec, inputs);
|
|
7919
|
+
const callerOwnsLeaves = passed.makeLeafAgent !== void 0 || passed.makeWorkerAgent !== void 0;
|
|
7920
|
+
if (spec.comms === "messages" && backend !== void 0 && backend.backend !== "bridge" && backend.backend !== "provider" && !callerOwnsLeaves) refuse(`comms 'messages' needs workers that can call peer mail: Runtime mounts it on 'bridge' or capable 'provider' workers, and '${backend.backend}' workers run no client for it. Run the workers on a bridge, or mount WorkerSpawnContext.peerMailUrl through makeLeafAgent`);
|
|
7921
|
+
const analystKinds = spec.evaluate.analysts ?? [];
|
|
7922
|
+
if (analystKinds.length > 0 && inputs.analysts === void 0) refuse("evaluate.analysts names analyst kinds, and inputs.analysts holds no registry to run them");
|
|
7923
|
+
const axisOptions = {
|
|
7924
|
+
continuation,
|
|
7925
|
+
execution,
|
|
7926
|
+
...spec.workers.count > 0 ? { workerSlots: spec.workers.count } : {},
|
|
7927
|
+
...spec.workers.models === void 0 ? {} : { allowedModels: spec.workers.models },
|
|
7928
|
+
...spec.comms === "messages" ? { peerMail: true } : {},
|
|
7929
|
+
...spec.stop.plateau === void 0 ? {} : { stopRule: { plateau: spec.stop.plateau } },
|
|
7930
|
+
...backend === void 0 ? {} : { backend }
|
|
7931
|
+
};
|
|
7932
|
+
if (spec.select === "code" || spec.select === "fixed") {
|
|
7933
|
+
const graph = inputs.graph ?? refuse(`select '${spec.select}' needs inputs.graph`);
|
|
7934
|
+
if (inputs.profile !== void 0 || inputs.task !== void 0) refuse(`select '${spec.select}' runs inputs.graph, whose root is its own node and whose task is the deliverable's description; drop inputs.profile and inputs.task`);
|
|
7935
|
+
if (inputs.workers !== void 0) refuse(`select '${spec.select}' spawns the graph's nodes; drop inputs.workers`);
|
|
7936
|
+
if (analystKinds.length > 0) refuse(`select '${spec.select}' declares a graph's analysts as analyzes edges, not evaluate.analysts`);
|
|
7937
|
+
if (spec.workers.count === 0) refuse(`select '${spec.select}' runs a graph's worker nodes, so workers.count must be at least 1`);
|
|
7938
|
+
if (spec.select === "code" && inputs.brain === void 0) refuse("select 'code' needs inputs.brain, the caller's brain that drives the root");
|
|
7939
|
+
if (spec.select === "fixed" && inputs.brain !== void 0) refuse("select 'fixed' runs the graph's root profile; a brain is select 'code'");
|
|
7940
|
+
if (passed.registry !== void 0) refuse("options.registry is supervise's name table, which a graph cannot read; pass the graph's directive registry as inputs.directives");
|
|
7941
|
+
if (spec.context === "fresh" && !harnessRunsAgent(graphRoot(graph)?.harness)) refuse("context 'fresh' renews an external harness root's session at each re-entry, and the graph's root runs on the router brain");
|
|
7942
|
+
return Object.freeze({
|
|
7943
|
+
call: "runGraph",
|
|
7944
|
+
spec,
|
|
7945
|
+
digest,
|
|
7946
|
+
graph: Object.freeze({
|
|
7947
|
+
nodes: graph.nodes,
|
|
7948
|
+
edges: graph.edges,
|
|
7949
|
+
deliverable: inputs.deliverable,
|
|
7950
|
+
budget: inputs.budget
|
|
7951
|
+
}),
|
|
7952
|
+
options: Object.freeze({
|
|
7953
|
+
...passed,
|
|
7954
|
+
...axisOptions,
|
|
7955
|
+
...inputs.brain === void 0 ? {} : { brain: inputs.brain },
|
|
7956
|
+
...inputs.analysts === void 0 ? {} : { analysts: inputs.analysts },
|
|
7957
|
+
...inputs.directives === void 0 ? {} : { registry: inputs.directives }
|
|
7958
|
+
})
|
|
7959
|
+
});
|
|
7960
|
+
}
|
|
7961
|
+
const profile = inputs.profile ?? refuse(`select '${spec.select}' needs inputs.profile, the root`);
|
|
7962
|
+
if (inputs.task === void 0) refuse(`select '${spec.select}' needs inputs.task`);
|
|
7963
|
+
if (inputs.graph !== void 0 || inputs.brain !== void 0 || inputs.directives !== void 0) refuse(`select '${spec.select}' runs inputs.profile; a graph, brain or directives is select 'code' or 'fixed'`);
|
|
7964
|
+
if (!harnessRunsAgent(profile.harness)) refuse(`select '${spec.select}' runs the root under Runtime's continuation (context, evaluate and stop), which drives an external harness; profile '${profile.name}' runs on the router brain. Give it a harness such as claude-code or codex, or use select 'code'`);
|
|
7965
|
+
if (spec.workers.count === 0 && grantsSpawn(profile)) refuse(`workers.count 0 runs the root alone, but profile '${profile.name}' grants ${SPAWN_GRANT}`);
|
|
7966
|
+
if (spec.workers.count > 0 && !grantsSpawn(profile)) refuse(`workers.count ${spec.workers.count} needs a root that spawns, and profile '${profile.name}' does not grant ${SPAWN_GRANT}`);
|
|
7967
|
+
if (spec.select === "self" && inputs.workers?.length !== spec.workers.count) refuse(`select 'self' starts exactly workers.count peers; inputs.workers holds ${inputs.workers?.length ?? 0}, and workers.count is ${spec.workers.count}`);
|
|
7968
|
+
if (inputs.workers !== void 0 && passed.registry?.profiles !== void 0) refuse("inputs.workers and options.registry.profiles both name spawnable profiles; pass them once");
|
|
7969
|
+
const registry = inputs.workers === void 0 ? passed.registry : Object.freeze({
|
|
7970
|
+
...passed.registry,
|
|
7971
|
+
profiles: profileTable(inputs.workers)
|
|
7972
|
+
});
|
|
7973
|
+
return Object.freeze({
|
|
7974
|
+
call: "supervise",
|
|
7975
|
+
spec,
|
|
7976
|
+
digest,
|
|
7977
|
+
profile,
|
|
7978
|
+
task: inputs.task,
|
|
7979
|
+
options: Object.freeze({
|
|
7980
|
+
...passed,
|
|
7981
|
+
...axisOptions,
|
|
7982
|
+
budget: inputs.budget,
|
|
7983
|
+
deliverable: inputs.deliverable,
|
|
7984
|
+
...registry === void 0 ? {} : { registry },
|
|
7985
|
+
...inputs.analysts === void 0 ? {} : { analysts: inputs.analysts },
|
|
7986
|
+
...analystKinds.length > 0 ? { analyzeOnSettle: analystKinds } : {},
|
|
7987
|
+
...spec.select === "advisor" ? {
|
|
7988
|
+
maxDepth: 1,
|
|
7989
|
+
inheritSpawnRights: false
|
|
7990
|
+
} : {}
|
|
7991
|
+
})
|
|
7992
|
+
});
|
|
7993
|
+
}
|
|
7994
|
+
//#endregion
|
|
7542
7995
|
//#region src/runtime/supervise/sql-run-context.ts
|
|
7543
7996
|
/**
|
|
7544
7997
|
* A cross-machine run context on the existing autocommit SqlAdapter. Reuse the same database,
|
|
@@ -8824,6 +9277,6 @@ function tail(s) {
|
|
|
8824
9277
|
return s.slice(-400);
|
|
8825
9278
|
}
|
|
8826
9279
|
//#endregion
|
|
8827
|
-
export {
|
|
9280
|
+
export { runBenchmark as $, McpSpawnFault as $t, connectRemoteSupervisor as A, inlineSandboxClient as At, chatTransportExecutor as B, runIsolatedCheck as Bt, analyzeTrace as C, observationFromRegistry as Ct, compileSearchSpec as D, defineLeaderboard as Dt, assertSearchSpec as E, harvestCorpus as Et, profileRunsForName as F, checkProgramDigest as Ft, assertStrategyContract as G, leaderboard as Gt, createChatSessionStore as H, deterministicCompletion as Ht, recordProfileRun as I, declaredCheckDeliverable as It, strategyAuthorSystemPrompt as J, renderLeaderboardMarkdown as Jt, authorStrategy as K, pairwiseSignificance as Kt, patchDelivered as L, declaredCheckDigest as Lt, loadProfile as M, loopDispatch as Mt, pickBestProfile as N, superviseDispatch as Nt, searchPresets as O, resolveSandboxClient as Ot, profileRegistry as P, assertDeclaredCheck as Pt, printBenchmarkReport as Q, openSqlRunStore as Qt, runCoderChecks as R, declaredCheckJudge as Rt, withUntrackedArtifacts as S, registryScopeAnalyst as St, SEARCH_SPEC_CORRELATION_KEY as T, HarvestError as Tt, runStrategyEvolution as U, sentinelCompletion as Ut, chatWorkerSeam as V, completionAuthorizes as Vt, strategyTournament as W, stopSentinel as Wt, openSandboxRun as X, renderPairwiseMarkdown as Xt, SandboxRunAbortError as Y, renderLeaderboardSvg as Yt, createS3PrivateCasStore as Z, SqlRunOwnershipError as Zt, VERIFY_TAIL_CHARS as _, verify as _t, localShell as a, mcpSecretEnvMetadataKey as an, builtinShapes as at, settledWorkerOut as b, buildSteerContext as bt, createVerifierEnvironment as c, secretEnvOfMcpServer as cn, FileCorpus as ct, harvestSurfaceDiffs as d, fanout as dt, connectStdioMcp as en, createPrivateCasArtifactPort as et, analystsFromRegistry as f, flatWidenGate as ft, NOTE_MAX_CHARS as g, selectValidWinner as gt, EVIDENCE_MAX_CHARS as h, pipeline as ht, jjWorkspace as i, envKeyProvider as in, runPersonified as it, bestProfileFor as j, loopCampaignDispatch as jt, searchSpecDigest as k, localSandboxClient as kt, boxSurfaceReader as l, createTangleSandboxExactProcessProvider as ln, InMemoryCorpus as lt, worktreeFanout as m, panel as mt, makeFinding$1 as n, createMcpEnvironment as nn, trajectoryReport as nt, runInWorkspace as o, resolveMcpServerLaunch as on, createShapeRegistry as ot, failuresAnalyst as p, loopUntil as pt, strategyAuthorContract as q, renderLeaderboardHtml as qt, gitWorkspace as r, sanitizeMcpToolSchema as rn, definePersona as rt, createWaterfallCollector as s, resolveSecretEnv as sn, registerShape as st, computeFindingId$1 as t, materializeLocalMcp as tn, equalKOnCost as tt, fsSurfaceReader as u, renderCorpusToInstructions as ut, closingWorkerNote as v, widen as vt, createFencedSqlRunContext as w, inProcessSandboxClient as wt, copyUntrackedIntoClone as x, createScopeAnalyst as xt, composeWorkerEvidence as y, assertTraceDerivedFindings as yt, graphDesignerExtraTools as z, readDeclaredCheck as zt };
|
|
8828
9281
|
|
|
8829
|
-
//# sourceMappingURL=runtime-
|
|
9282
|
+
//# sourceMappingURL=runtime-EiTCboO2.js.map
|