@tangle-network/agent-runtime 0.301.0 → 0.306.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-V6aaOlZV.js → activation-C5wesfzd.js} +3 -3
- package/dist/{activation-V6aaOlZV.js.map → activation-C5wesfzd.js.map} +1 -1
- package/dist/{activation-CRgEJutr.d.ts → activation-wZ-8vOjV.d.ts} +88 -13
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/{bundle-C9v5TH_H.js → bundle-C8EO05u3.js} +2 -2
- package/dist/{bundle-C9v5TH_H.js.map → bundle-C8EO05u3.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +3 -26
- package/dist/candidate-execution/index.js +6 -6
- package/dist/{coordination-driver-vNrdQBSH.js → coordination-driver-yj9HPXef.js} +9 -16
- package/dist/coordination-driver-yj9HPXef.js.map +1 -0
- package/dist/{delegate-B-jFJcbW.js → delegate-KtrL9HWq.js} +2 -2
- package/dist/{delegate-B-jFJcbW.js.map → delegate-KtrL9HWq.js.map} +1 -1
- package/dist/durable.d.ts +3 -15
- package/dist/durable.js +158 -124
- package/dist/durable.js.map +1 -1
- package/dist/{graph-Dwv_hQB_.js → graph-DcdyHbgf.js} +4 -5
- package/dist/graph-DcdyHbgf.js.map +1 -0
- package/dist/{improvement-cycle-Cf37Kexd.js → improvement-cycle-DsN-TVXR.js} +1129 -10
- package/dist/improvement-cycle-DsN-TVXR.js.map +1 -0
- package/dist/{index-CxBVmgqL.d.ts → index-DflDZq_I.d.ts} +50 -688
- package/dist/index.d.ts +378 -12
- package/dist/index.js +223 -320
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +5 -5
- package/dist/intelligence.js +7 -8
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-DiTNiJNs.d.ts → loop-runner-bin-DZfRUVWy.d.ts} +3 -3
- package/dist/{loop-runner-bin-C8MI8N1A.js → loop-runner-bin-rVrSX5l1.js} +3 -3
- package/dist/{loop-runner-bin-C8MI8N1A.js.map → loop-runner-bin-rVrSX5l1.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 +3 -3
- package/dist/mcp/index.d.ts +6 -35
- package/dist/mcp/index.js +311 -364
- package/dist/mcp/index.js.map +1 -1
- package/dist/model-policy-DydyWTQg.js.map +1 -1
- package/dist/{openai-tools-BeogJ6V8.d.ts → openai-tools-YO30D2s3.d.ts} +2 -2
- package/dist/{prepare-CGVNMb1o.js → prepare--nWcazPr.js} +7 -13
- package/dist/prepare--nWcazPr.js.map +1 -0
- package/dist/{profile-BetOB4_Q.js → profile-h04LDjV6.js} +2 -2
- package/dist/{profile-BetOB4_Q.js.map → profile-h04LDjV6.js.map} +1 -1
- package/dist/profiles.d.ts +2 -94
- package/dist/profiles.js +2 -451
- package/dist/profiles.js.map +1 -1
- package/dist/{protected-model-port-CAa0t1MT.d.ts → protected-model-port-C9QtEf3y.d.ts} +2 -2
- package/dist/{protected-model-port-CuVHkhti.js → protected-model-port-wwalbyXM.js} +4 -4
- package/dist/{protected-model-port-CuVHkhti.js.map → protected-model-port-wwalbyXM.js.map} +1 -1
- package/dist/{provision-supervisor-CS0fBIhp.js → provision-supervisor-WxFEFQeJ.js} +4 -3
- package/dist/{provision-supervisor-CS0fBIhp.js.map → provision-supervisor-WxFEFQeJ.js.map} +1 -1
- package/dist/{runtime-6VPSJVeg.js → runtime-B9eBIyws.js} +67 -469
- package/dist/runtime-B9eBIyws.js.map +1 -0
- package/dist/{search-method-wTTS7mGG.js → search-executor-2tWr38Qw.js} +239 -1132
- package/dist/search-executor-2tWr38Qw.js.map +1 -0
- package/dist/{server-BfHD5iLD.js → server-CpKcrOPj.js} +5 -12
- package/dist/server-CpKcrOPj.js.map +1 -0
- package/dist/{stream-agent-turn-B1ipFtOc.d.ts → stream-agent-turn-B1giFgOg.d.ts} +2 -2
- package/dist/{substrate-DKBMd0Dl.d.ts → substrate-L_sC7jCD.d.ts} +2 -2
- package/dist/{supervise-BJrEC2Mh.js → supervise-DllOHM4M.js} +14 -24
- package/dist/supervise-DllOHM4M.js.map +1 -0
- package/dist/{supervisor-DA_nvF-h.js → supervisor-gCfG6K1-.js} +488 -1407
- package/dist/supervisor-gCfG6K1-.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-jD9mNnJM.d.ts → types-DeuEkBhI.d.ts} +114 -258
- package/dist/{workspace-archive-pz8YJ1fr.d.ts → workspace-streams-CpSmt3zx.d.ts} +67 -3
- package/dist/{workspace-streams-D5gHJdTb.js → workspace-streams-ILw0eWZ0.js} +694 -2
- package/dist/workspace-streams-ILw0eWZ0.js.map +1 -0
- package/package.json +8 -8
- package/skills/generate-eval/SKILL.md +1 -1
- package/skills/profile-authoring/SKILL.md +2 -2
- package/dist/coordination-driver-vNrdQBSH.js.map +0 -1
- package/dist/graph-Dwv_hQB_.js.map +0 -1
- package/dist/improvement-cycle-Cf37Kexd.js.map +0 -1
- package/dist/prepare-CGVNMb1o.js.map +0 -1
- package/dist/runtime-6VPSJVeg.js.map +0 -1
- package/dist/search-method-wTTS7mGG.js.map +0 -1
- package/dist/server-BfHD5iLD.js.map +0 -1
- package/dist/supervise-BJrEC2Mh.js.map +0 -1
- package/dist/supervisor-DA_nvF-h.js.map +0 -1
- package/dist/workspace-streams-D5gHJdTb.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { An as insideCursorNamespace, Bi as detachedSnapshot, Bn as isTraceAnalysisStore, D as verdictFromJudgeScore, Fn as prepareJsonlAppend, In as readCommittedJsonLines, Li as executableAgentProfileSnapshot, Ln as writeAllBytes, On as InMemoryResultBlobStore, Ri as executableAgentSpecSnapshot, St as createExecutorRegistry, W as settledToIteration, Zi as notifySandboxEventObserver, _ as CheckUnavailableError, an as runAgentRounds, br as contentAddress, dn as readPromptOptions, fn as routerBrain, gt as rollingDispatch, j as withDriverExecutor, kn as InMemorySpawnJournal, on as createSandboxLineage, pn as runBrainLoop, r as createSupervisor, rn as defaultSelectWinner, un as assertBoxlessPromptOptions, wt as createWorktreeCliExecutor, xt as createExecutor, zi as detachedFrozen } from "./supervisor-gCfG6K1-.js";
|
|
2
2
|
import { i as ConfigError, m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import {
|
|
3
|
+
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-2tWr38Qw.js";
|
|
4
|
+
import { F as immutableCandidateValue, G as errorMessage, H as cloneSpend, J as isAbortError, K as fnv1a32Hex, L as sha256Bytes$1, Q as randomSuffix, V as chargedTokens, Y as isAsyncIterable, _t as armDeadlineTimer, j as canonicalCandidateDigest$1, nt as stringifySafe, q as hasCompleteCacheBreakdown, st as zeroSpend, tt as sleep, v as WorkspaceScanLimitError, x as captureMaterializedWorkspace, z as addSpend } from "./workspace-streams-ILw0eWZ0.js";
|
|
4
5
|
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-DydyWTQg.js";
|
|
5
|
-
import { F as sha256Bytes$1, N as immutableCandidateValue, g as WorkspaceScanLimitError, k as canonicalCandidateDigest$1, y as captureMaterializedWorkspace } from "./workspace-streams-D5gHJdTb.js";
|
|
6
6
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
7
7
|
import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction-DylCC_ot.js";
|
|
8
|
-
import {
|
|
9
|
-
import { C as gateOnDeliverable, r as supervise, w as mapExecutorResult } from "./supervise-
|
|
8
|
+
import { C as createInMemoryRunContext, E as foldCoordinationRecords } from "./coordination-driver-yj9HPXef.js";
|
|
9
|
+
import { C as gateOnDeliverable, r as supervise, w as mapExecutorResult } from "./supervise-DllOHM4M.js";
|
|
10
10
|
import "./run-layout-DSCWdbX2.js";
|
|
11
|
-
import "./provision-supervisor-
|
|
12
|
-
import "./delegate-
|
|
13
|
-
import "./graph-
|
|
11
|
+
import "./provision-supervisor-WxFEFQeJ.js";
|
|
12
|
+
import "./delegate-KtrL9HWq.js";
|
|
13
|
+
import "./graph-DcdyHbgf.js";
|
|
14
14
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
15
15
|
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";
|
|
16
16
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
@@ -639,6 +639,10 @@ function inheritedStdioEnv(source = process.env) {
|
|
|
639
639
|
}
|
|
640
640
|
return env;
|
|
641
641
|
}
|
|
642
|
+
/** How long a stdin write failure waits for the server's exit, which reports its stderr. A
|
|
643
|
+
* dying server closes within milliseconds; a live server that dropped its stdin is failed after
|
|
644
|
+
* it, well inside any handshake timeout. */
|
|
645
|
+
const STDIN_FAILURE_GRACE_MS = 250;
|
|
642
646
|
/** A missing start binary / spawn fault: a SETUP bug, never a failed candidate.
|
|
643
647
|
* Graders (the serve verifier) must rethrow this instead of scoring it. */
|
|
644
648
|
var McpSpawnFault = class extends Error {};
|
|
@@ -680,7 +684,8 @@ async function connectStdioMcp(spec) {
|
|
|
680
684
|
failAllPending(spawnFault);
|
|
681
685
|
});
|
|
682
686
|
child.stdin.on("error", (err) => {
|
|
683
|
-
failAllPending(new Error(redactReason(`writing to MCP server stdin failed: ${err.message}${stderrTail()}`)));
|
|
687
|
+
const fail = () => failAllPending(new Error(redactReason(`writing to MCP server stdin failed: ${err.message}${stderrTail()}`)));
|
|
688
|
+
setTimeout(fail, STDIN_FAILURE_GRACE_MS).unref();
|
|
684
689
|
});
|
|
685
690
|
child.on("close", (code, signal) => {
|
|
686
691
|
failAllPending(spawnFault ?? new Error(redactReason(`MCP server exited (code ${code}, signal ${signal}) before serving${stderrTail()}`)));
|
|
@@ -849,173 +854,6 @@ async function materializeLocalMcp(profile, opts = {}) {
|
|
|
849
854
|
};
|
|
850
855
|
}
|
|
851
856
|
//#endregion
|
|
852
|
-
//#region src/durable/spawn-journal-sql.ts
|
|
853
|
-
/**
|
|
854
|
-
* SQL-backed durable stores for supervised runs — `SqlSpawnJournal` and `SqlResultBlobStore`
|
|
855
|
-
* over the same minimal statement seam `SqlConversationJournal` uses (D1, postgres, sqlite,
|
|
856
|
-
* libSQL; positional `?` placeholders). This closes the orchestration-durability gap recorded in
|
|
857
|
-
* `conformance/durability/STATUS.md`: until now the spawn layer was file-only.
|
|
858
|
-
*
|
|
859
|
-
* Parity with the JSONL file stores, by construction:
|
|
860
|
-
* • same corruption guards — `beginTree` precedes events (enforced by the schema: an event row
|
|
861
|
-
* names a tree row), duplicate cursor seqs and duplicate materialization receipts are refused
|
|
862
|
-
* by the same `SpawnEventIndex` the file journal replays through, on both append and load;
|
|
863
|
-
* • same content-address law for blobs — a `put` whose ref does not hash to the artifact is
|
|
864
|
-
* refused, a re-put of the same ref asserts the identical bytes;
|
|
865
|
-
* • load order is insertion order (`INTEGER PRIMARY KEY AUTOINCREMENT`), the SQL analogue of
|
|
866
|
-
* the JSONL append-only spine.
|
|
867
|
-
*
|
|
868
|
-
* Durability note: this suite and its process-kill test run against `node:sqlite`, whose
|
|
869
|
-
* autocommit commits survive SIGKILL (process death, not OS crash). A deployment that must
|
|
870
|
-
* survive power loss sets its driver's synchronous mode (`PRAGMA synchronous=FULL` + WAL) at the
|
|
871
|
-
* adapter; agent-runtime takes no opinion.
|
|
872
|
-
*
|
|
873
|
-
* @experimental — draft: cross-process ownership is single-writer by convention (the same
|
|
874
|
-
* limitation `createFileRunContext` documents); a machine-visible ownership lease is follow-up.
|
|
875
|
-
*/
|
|
876
|
-
const TREES_DDL = (table) => `
|
|
877
|
-
CREATE TABLE IF NOT EXISTS ${table}_trees (
|
|
878
|
-
root TEXT PRIMARY KEY,
|
|
879
|
-
begun_at TEXT NOT NULL
|
|
880
|
-
)
|
|
881
|
-
`;
|
|
882
|
-
const EVENTS_DDL = (table) => `
|
|
883
|
-
CREATE TABLE IF NOT EXISTS ${table}_events (
|
|
884
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
885
|
-
root TEXT NOT NULL REFERENCES ${table}_trees (root),
|
|
886
|
-
body TEXT NOT NULL
|
|
887
|
-
)
|
|
888
|
-
`;
|
|
889
|
-
const BLOBS_DDL = (table) => `
|
|
890
|
-
CREATE TABLE IF NOT EXISTS ${table}_blobs (
|
|
891
|
-
ref TEXT PRIMARY KEY,
|
|
892
|
-
body TEXT NOT NULL
|
|
893
|
-
)
|
|
894
|
-
`;
|
|
895
|
-
/** SQL-backed `SpawnJournal`. One row per event; insertion order is replay order. */
|
|
896
|
-
var SqlSpawnJournal = class {
|
|
897
|
-
db;
|
|
898
|
-
table;
|
|
899
|
-
cache = /* @__PURE__ */ new Map();
|
|
900
|
-
appendTail = Promise.resolve();
|
|
901
|
-
constructor(db, table = "runtime_spawn_journal") {
|
|
902
|
-
this.db = db;
|
|
903
|
-
this.table = table;
|
|
904
|
-
}
|
|
905
|
-
/** Create the journal's tables if absent. Idempotent. */
|
|
906
|
-
async migrate() {
|
|
907
|
-
await this.db.exec(TREES_DDL(this.table));
|
|
908
|
-
await this.db.exec(EVENTS_DDL(this.table));
|
|
909
|
-
}
|
|
910
|
-
async loadTree(root) {
|
|
911
|
-
if ((await this.db.query(`SELECT begun_at FROM ${this.table}_trees WHERE root = ?`, [root])).length === 0) return void 0;
|
|
912
|
-
const rows = await this.db.query(`SELECT id, body FROM ${this.table}_events WHERE root = ? ORDER BY id`, [root]);
|
|
913
|
-
const index = new SpawnEventIndex(root);
|
|
914
|
-
const events = [];
|
|
915
|
-
for (const row of rows) {
|
|
916
|
-
const event = JSON.parse(row.body);
|
|
917
|
-
index.assert(event);
|
|
918
|
-
index.add(event);
|
|
919
|
-
events.push(event);
|
|
920
|
-
}
|
|
921
|
-
return events;
|
|
922
|
-
}
|
|
923
|
-
async beginTree(root, at) {
|
|
924
|
-
return this.serializeAppend(async () => {
|
|
925
|
-
await this.ensureMigrated();
|
|
926
|
-
const existing = await this.db.query(`SELECT begun_at FROM ${this.table}_trees WHERE root = ?`, [root]);
|
|
927
|
-
if (existing.length > 0) {
|
|
928
|
-
const begunAt = existing[0]?.begun_at;
|
|
929
|
-
if (begunAt !== at) throw new Error(`spawn tree '${root}' already begun in SQL at ${begunAt}; refusing to overwrite with ${at}`);
|
|
930
|
-
return;
|
|
931
|
-
}
|
|
932
|
-
await this.db.exec(`INSERT INTO ${this.table}_trees (root, begun_at) VALUES (?, ?)`, [root, at]);
|
|
933
|
-
this.cache.set(root, {
|
|
934
|
-
maxId: 0,
|
|
935
|
-
index: new SpawnEventIndex(root)
|
|
936
|
-
});
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
async appendEvent(root, ev) {
|
|
940
|
-
const event = detachedSnapshot(ev, "spawn event");
|
|
941
|
-
return this.serializeAppend(async () => {
|
|
942
|
-
await this.ensureMigrated();
|
|
943
|
-
const state = await this.validationIndex(root);
|
|
944
|
-
state.index.assert(event);
|
|
945
|
-
if ((await this.db.exec(`INSERT INTO ${this.table}_events (root, body) VALUES (?, ?)`, [root, JSON.stringify(event)])).rowsAffected !== 1) throw new Error(`spawn journal SQL: append of an event for tree '${root}' affected no rows`);
|
|
946
|
-
state.index.add(event);
|
|
947
|
-
state.maxId = await this.maxEventId(root);
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
async validationIndex(root) {
|
|
951
|
-
if ((await this.db.query(`SELECT begun_at FROM ${this.table}_trees WHERE root = ?`, [root])).length === 0) throw new Error(`appendEvent called for unknown spawn tree '${root}'; call beginTree first`);
|
|
952
|
-
const max = await this.maxEventId(root);
|
|
953
|
-
const cached = this.cache.get(root);
|
|
954
|
-
if (cached && cached.maxId === max) return cached;
|
|
955
|
-
const index = new SpawnEventIndex(root);
|
|
956
|
-
if (max > 0) {
|
|
957
|
-
const rows = await this.db.query(`SELECT body FROM ${this.table}_events WHERE root = ? ORDER BY id`, [root]);
|
|
958
|
-
for (const row of rows) {
|
|
959
|
-
const event = JSON.parse(row.body);
|
|
960
|
-
index.assert(event);
|
|
961
|
-
index.add(event);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
const state = {
|
|
965
|
-
maxId: max,
|
|
966
|
-
index
|
|
967
|
-
};
|
|
968
|
-
this.cache.set(root, state);
|
|
969
|
-
return state;
|
|
970
|
-
}
|
|
971
|
-
async maxEventId(root) {
|
|
972
|
-
return (await this.db.query(`SELECT MAX(id) AS max FROM ${this.table}_events WHERE root = ?`, [root]))[0]?.max ?? 0;
|
|
973
|
-
}
|
|
974
|
-
migrated = false;
|
|
975
|
-
async ensureMigrated() {
|
|
976
|
-
if (this.migrated) return;
|
|
977
|
-
await this.migrate();
|
|
978
|
-
this.migrated = true;
|
|
979
|
-
}
|
|
980
|
-
serializeAppend(operation) {
|
|
981
|
-
const append = this.appendTail.then(operation);
|
|
982
|
-
this.appendTail = append.catch(() => void 0);
|
|
983
|
-
return append;
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
/** SQL-backed `ResultBlobStore`. One content-addressed row per settled result. */
|
|
987
|
-
var SqlResultBlobStore = class {
|
|
988
|
-
db;
|
|
989
|
-
table;
|
|
990
|
-
migrated = false;
|
|
991
|
-
constructor(db, table = "runtime_result_blobs") {
|
|
992
|
-
this.db = db;
|
|
993
|
-
this.table = table;
|
|
994
|
-
}
|
|
995
|
-
async migrate() {
|
|
996
|
-
await this.db.exec(BLOBS_DDL(this.table));
|
|
997
|
-
}
|
|
998
|
-
async put(outRef, artifact) {
|
|
999
|
-
await this.ensureMigrated();
|
|
1000
|
-
const { text } = encodeResultBlob(outRef, artifact);
|
|
1001
|
-
if ((await this.db.exec(`INSERT OR IGNORE INTO ${this.table}_blobs (ref, body) VALUES (?, ?)`, [outRef, text])).rowsAffected === 1) return;
|
|
1002
|
-
assertContentAddress(outRef, await this.get(outRef));
|
|
1003
|
-
}
|
|
1004
|
-
async get(outRef) {
|
|
1005
|
-
await this.ensureMigrated();
|
|
1006
|
-
const rows = await this.db.query(`SELECT body FROM ${this.table}_blobs WHERE ref = ?`, [outRef]);
|
|
1007
|
-
if (rows.length === 0) return void 0;
|
|
1008
|
-
const artifact = JSON.parse(rows[0]?.body ?? "null");
|
|
1009
|
-
assertContentAddress(outRef, artifact);
|
|
1010
|
-
return artifact;
|
|
1011
|
-
}
|
|
1012
|
-
async ensureMigrated() {
|
|
1013
|
-
if (this.migrated) return;
|
|
1014
|
-
await this.migrate();
|
|
1015
|
-
this.migrated = true;
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
1018
|
-
//#endregion
|
|
1019
857
|
//#region src/durable/sql-run-store.ts
|
|
1020
858
|
/** Refuses a competing or stale SQL run owner before it can publish new work. */
|
|
1021
859
|
var SqlRunOwnershipError = class extends Error {
|
|
@@ -1276,88 +1114,6 @@ function wait(ms, signal) {
|
|
|
1276
1114
|
});
|
|
1277
1115
|
}
|
|
1278
1116
|
//#endregion
|
|
1279
|
-
//#region src/runtime/audit-intent.ts
|
|
1280
|
-
/** Default system instruction for intent-auditor agents: diagnose diverged/drifting trajectories. */
|
|
1281
|
-
const defaultAuditorInstruction = "You audit whether an AI agent is on the RIGHT ROUTE — not whether it works hard, but whether its actions serve the stated intents. Infer the REVEALED intent from the action pattern (what the trajectory is actually optimizing). Compare against the declared task intent, the user intent when given, and the meta-intent when given. Flawless execution down the wrong route is DIVERGED. Busy-work that neither advances nor harms is DRIFTING. Judge only from the trajectory — be specific about which actions ground your verdict. Recommend abort only when continuing cannot serve the intent.";
|
|
1282
|
-
function summarize(trace, maxLines) {
|
|
1283
|
-
const lines = [];
|
|
1284
|
-
for (const ev of trace) {
|
|
1285
|
-
const e = ev;
|
|
1286
|
-
const role = e.role;
|
|
1287
|
-
if (role === "tool") lines.push(`RESULT ${String(e.content).slice(0, 200)}`);
|
|
1288
|
-
else if (role === "assistant") {
|
|
1289
|
-
const calls = e.tool_calls?.map((c) => `${c.function?.name}(${(c.function?.arguments ?? "").slice(0, 120)})`).join(", ");
|
|
1290
|
-
lines.push(calls ? `CALL ${calls}` : `SAY ${String(e.content).slice(0, 160)}`);
|
|
1291
|
-
} else if (role === "user") lines.push(`USER ${String(e.content).slice(0, 160)}`);
|
|
1292
|
-
}
|
|
1293
|
-
return lines.slice(-maxLines).join("\n");
|
|
1294
|
-
}
|
|
1295
|
-
const auditSchema = {
|
|
1296
|
-
name: "intent_audit",
|
|
1297
|
-
schema: {
|
|
1298
|
-
type: "object",
|
|
1299
|
-
additionalProperties: false,
|
|
1300
|
-
required: [
|
|
1301
|
-
"revealedIntent",
|
|
1302
|
-
"verdict",
|
|
1303
|
-
"evidence",
|
|
1304
|
-
"recommendation",
|
|
1305
|
-
"confidence"
|
|
1306
|
-
],
|
|
1307
|
-
properties: {
|
|
1308
|
-
revealedIntent: { type: "string" },
|
|
1309
|
-
verdict: {
|
|
1310
|
-
type: "string",
|
|
1311
|
-
enum: [
|
|
1312
|
-
"aligned",
|
|
1313
|
-
"drifting",
|
|
1314
|
-
"diverged"
|
|
1315
|
-
]
|
|
1316
|
-
},
|
|
1317
|
-
evidence: { type: "string" },
|
|
1318
|
-
recommendation: {
|
|
1319
|
-
type: "string",
|
|
1320
|
-
enum: [
|
|
1321
|
-
"continue",
|
|
1322
|
-
"steer",
|
|
1323
|
-
"abort"
|
|
1324
|
-
]
|
|
1325
|
-
},
|
|
1326
|
-
steer: { type: "string" },
|
|
1327
|
-
confidence: { type: "number" }
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
/** The route-rigor analyst: compare declared vs revealed vs user intent over a trajectory and return aligned / drifting / diverged with evidence and one recommended intervention. */
|
|
1332
|
-
async function auditIntent(input, opts) {
|
|
1333
|
-
const res = await profileChatClient({
|
|
1334
|
-
profile: opts.profile,
|
|
1335
|
-
executor: opts.executor,
|
|
1336
|
-
context: "intent auditor"
|
|
1337
|
-
}).chat({
|
|
1338
|
-
jsonSchema: auditSchema,
|
|
1339
|
-
messages: [{
|
|
1340
|
-
role: "user",
|
|
1341
|
-
content: `DECLARED INTENT (the task):\n${input.declaredIntent}\n\n` + (input.userIntent ? `USER INTENT (the principal's actual goal):\n${input.userIntent}\n\n` : "") + (input.metaIntent ? `META-INTENT (what the whole run is for):\n${input.metaIntent}\n\n` : "") + `TRAJECTORY (in order):\n${summarize(input.trace, opts.maxTraceLines ?? 80)}\n\nAudit the route: revealed intent, verdict, evidence, one recommendation.`
|
|
1342
|
-
}]
|
|
1343
|
-
}, { ...opts.signal ? { signal: opts.signal } : {} });
|
|
1344
|
-
let parsed;
|
|
1345
|
-
try {
|
|
1346
|
-
parsed = JSON.parse(res.content);
|
|
1347
|
-
} catch {
|
|
1348
|
-
throw new Error(`auditIntent: auditor returned non-JSON: ${res.content.slice(0, 200)}`);
|
|
1349
|
-
}
|
|
1350
|
-
if (!parsed.verdict || !parsed.recommendation) throw new Error(`auditIntent: missing verdict/recommendation: ${res.content.slice(0, 200)}`);
|
|
1351
|
-
return {
|
|
1352
|
-
revealedIntent: parsed.revealedIntent ?? "",
|
|
1353
|
-
verdict: parsed.verdict,
|
|
1354
|
-
evidence: parsed.evidence ?? "",
|
|
1355
|
-
recommendation: parsed.recommendation,
|
|
1356
|
-
...parsed.steer ? { steer: parsed.steer } : {},
|
|
1357
|
-
confidence: typeof parsed.confidence === "number" ? parsed.confidence : .5
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
//#endregion
|
|
1361
1117
|
//#region src/runtime/benchmark-report.ts
|
|
1362
1118
|
/**
|
|
1363
1119
|
* benchmark-report — turn a fleet of `RunRecord`s into a publishable, multi-axis benchmark report:
|
|
@@ -1736,12 +1492,7 @@ function completionAuthorizes(v, policy) {
|
|
|
1736
1492
|
* emit it VERBATIM when it judges itself done. Unguessable enough that content never trips it.
|
|
1737
1493
|
*/
|
|
1738
1494
|
function stopSentinel(seed) {
|
|
1739
|
-
|
|
1740
|
-
for (let i = 0; i < seed.length; i += 1) {
|
|
1741
|
-
h ^= seed.charCodeAt(i);
|
|
1742
|
-
h = Math.imul(h, 16777619);
|
|
1743
|
-
}
|
|
1744
|
-
return `<<<{{STOP:${(h >>> 0).toString(16).padStart(8, "0")}}}>>>`;
|
|
1495
|
+
return `<<<{{STOP:${fnv1a32Hex(seed)}}}>>>`;
|
|
1745
1496
|
}
|
|
1746
1497
|
/**
|
|
1747
1498
|
* Completion for a sandbox-agent node: done iff the latest output carries the node's stop
|
|
@@ -2368,9 +2119,17 @@ function assertDeclaredCheck(check, context) {
|
|
|
2368
2119
|
for (const name of check.secrets ?? []) if (!/^[A-Z_][A-Z0-9_]*$/u.test(name)) fail(`secret name ${JSON.stringify(name)} is not an env name`);
|
|
2369
2120
|
if (check.containers !== void 0 && typeof check.containers !== "boolean") fail("containers must be a boolean");
|
|
2370
2121
|
}
|
|
2371
|
-
/**
|
|
2122
|
+
/**
|
|
2123
|
+
* A check program's files as a commit holds them: every file under the directory except Python
|
|
2124
|
+
* bytecode caches, which running the program writes and Git ignores. The digest a record names a
|
|
2125
|
+
* program by, and the bytes a check box receives, both come from this capture.
|
|
2126
|
+
*/
|
|
2127
|
+
function captureProgram(dir) {
|
|
2128
|
+
return captureMaterializedWorkspace(dir, { skipPythonBytecode: true });
|
|
2129
|
+
}
|
|
2130
|
+
/** The canonical digest of a check program's files: the digest a record names a program by. */
|
|
2372
2131
|
async function checkProgramDigest(dir) {
|
|
2373
|
-
return canonicalCandidateDigest((await
|
|
2132
|
+
return canonicalCandidateDigest((await captureProgram(dir)).manifest);
|
|
2374
2133
|
}
|
|
2375
2134
|
/** The digest a version judge records: the program, the sealed cases, and how they are run. */
|
|
2376
2135
|
function declaredCheckDigest(check) {
|
|
@@ -2538,7 +2297,7 @@ function verdictOf(outcome, pass) {
|
|
|
2538
2297
|
/** Copy exactly the bytes whose digest was checked: the files are read once, verified, and those
|
|
2539
2298
|
* bytes are written, so a file changed after the check cannot reach the box. */
|
|
2540
2299
|
async function copyVerified(from, digest, to, label) {
|
|
2541
|
-
const captured = await
|
|
2300
|
+
const captured = await captureProgram(from);
|
|
2542
2301
|
const actual = canonicalCandidateDigest(captured.manifest);
|
|
2543
2302
|
if (actual !== digest) throw new ValidationError(`readDeclaredCheck: the ${label} at ${from} is ${actual}; the record names ${digest}`);
|
|
2544
2303
|
await writeFiles(captured.files, to);
|
|
@@ -2814,13 +2573,10 @@ function loopDispatch(opts) {
|
|
|
2814
2573
|
* There are no sessions, no fs,
|
|
2815
2574
|
* no fork (those degrade gracefully via the optional `SandboxClient` methods).
|
|
2816
2575
|
*/
|
|
2817
|
-
function isAsyncIterable$1(v) {
|
|
2818
|
-
return typeof v === "object" && v !== null && Symbol.asyncIterator in v;
|
|
2819
|
-
}
|
|
2820
2576
|
/** Drive a (possibly streaming) executor to its terminal artifact. */
|
|
2821
2577
|
async function settle(exec, task, signal) {
|
|
2822
2578
|
const r = exec.execute(task, signal);
|
|
2823
|
-
if (isAsyncIterable
|
|
2579
|
+
if (isAsyncIterable(r)) {
|
|
2824
2580
|
for await (const _ of r);
|
|
2825
2581
|
return exec.resultArtifact();
|
|
2826
2582
|
}
|
|
@@ -3538,9 +3294,6 @@ async function harvestCorpus(opts) {
|
|
|
3538
3294
|
* picks it up. No cast is needed on the events (the union is structural); only
|
|
3539
3295
|
* the box object is cast, once, inside this file.
|
|
3540
3296
|
*/
|
|
3541
|
-
function isAsyncIterable(v) {
|
|
3542
|
-
return typeof v === "object" && v !== null && Symbol.asyncIterator in v;
|
|
3543
|
-
}
|
|
3544
3297
|
/**
|
|
3545
3298
|
* Adapt a single `onPrompt(prompt, ctx)` callback into a `SandboxClient` for
|
|
3546
3299
|
* `runAgentRounds` / `openSandboxRun`. Returns a PROPERLY-TYPED `SandboxClient`: the
|
|
@@ -4769,8 +4522,8 @@ async function trajectoryReport(journal, blobs, root, options = {}) {
|
|
|
4769
4522
|
id: ev.id,
|
|
4770
4523
|
parent: ev.parent,
|
|
4771
4524
|
label: ev.label,
|
|
4772
|
-
runtime: ev.
|
|
4773
|
-
status:
|
|
4525
|
+
runtime: ev.runtime,
|
|
4526
|
+
status: "pending",
|
|
4774
4527
|
ownSpend: zeroSpend(),
|
|
4775
4528
|
children: []
|
|
4776
4529
|
});
|
|
@@ -4780,11 +4533,6 @@ async function trajectoryReport(journal, blobs, root, options = {}) {
|
|
|
4780
4533
|
node.status = "cancelled";
|
|
4781
4534
|
continue;
|
|
4782
4535
|
}
|
|
4783
|
-
if (ev.kind === "woken") {
|
|
4784
|
-
node.status = ev.by === "cancelled" ? "cancelled" : "done";
|
|
4785
|
-
node.outRef = ev.outRef;
|
|
4786
|
-
continue;
|
|
4787
|
-
}
|
|
4788
4536
|
node.status = ev.status === "done" ? "done" : "failed";
|
|
4789
4537
|
node.ownSpend = cloneSpend(ev.spent);
|
|
4790
4538
|
node.verdict = ev.verdict;
|
|
@@ -4909,8 +4657,7 @@ function countStatuses(reported) {
|
|
|
4909
4657
|
done: 0,
|
|
4910
4658
|
failed: 0,
|
|
4911
4659
|
cancelled: 0,
|
|
4912
|
-
pending: 0
|
|
4913
|
-
waiting: 0
|
|
4660
|
+
pending: 0
|
|
4914
4661
|
};
|
|
4915
4662
|
for (const node of reported) counts[node.status] += 1;
|
|
4916
4663
|
return counts;
|
|
@@ -4938,10 +4685,10 @@ function medianOf(values) {
|
|
|
4938
4685
|
if (sorted.length % 2 !== 0) return hi;
|
|
4939
4686
|
return (sorted[mid - 1] + hi) / 2;
|
|
4940
4687
|
}
|
|
4941
|
-
/** Node-CREATION events
|
|
4942
|
-
*
|
|
4688
|
+
/** Node-CREATION events: a spawned child mints a node in the ordinal namespace; its settlement
|
|
4689
|
+
* closes it in the cursor namespace. */
|
|
4943
4690
|
function isNodeCreation(ev) {
|
|
4944
|
-
return ev.kind === "spawned"
|
|
4691
|
+
return ev.kind === "spawned";
|
|
4945
4692
|
}
|
|
4946
4693
|
function isNode(node) {
|
|
4947
4694
|
return node !== void 0;
|
|
@@ -5365,6 +5112,31 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
|
|
|
5365
5112
|
async read(ref) {
|
|
5366
5113
|
return readRef(ref);
|
|
5367
5114
|
},
|
|
5115
|
+
async locate(object, options = {}) {
|
|
5116
|
+
options.signal?.throwIfAborted();
|
|
5117
|
+
const digest = object.sha256;
|
|
5118
|
+
const hex = hexOf(digest);
|
|
5119
|
+
const ref = {
|
|
5120
|
+
locator: {
|
|
5121
|
+
kind: "private-cas",
|
|
5122
|
+
namespace,
|
|
5123
|
+
digest
|
|
5124
|
+
},
|
|
5125
|
+
sha256: digest,
|
|
5126
|
+
byteLength: object.byteLength
|
|
5127
|
+
};
|
|
5128
|
+
try {
|
|
5129
|
+
await checkDirectories(join(store, hex.slice(0, 2)), false);
|
|
5130
|
+
const local = await lstat(destination(digest));
|
|
5131
|
+
if (local.isFile()) return local.size === object.byteLength ? ref : void 0;
|
|
5132
|
+
} catch (error) {
|
|
5133
|
+
if (!missing(error)) throw error;
|
|
5134
|
+
}
|
|
5135
|
+
if (durable === void 0) return void 0;
|
|
5136
|
+
const receipt = await readLocal(join(receipts, hex));
|
|
5137
|
+
if (receipt === void 0) return void 0;
|
|
5138
|
+
return JSON.parse(Buffer.from(receipt).toString("utf8")).byteLength === object.byteLength ? ref : void 0;
|
|
5139
|
+
},
|
|
5368
5140
|
offload
|
|
5369
5141
|
};
|
|
5370
5142
|
async function putBuffered(bytes, digest, sha, signal) {
|
|
@@ -5944,7 +5716,7 @@ async function openSandboxRun(client, options, deliverable) {
|
|
|
5944
5716
|
const now = options.now ?? Date.now;
|
|
5945
5717
|
const agentRunName = options.agentRun.name ?? options.agentRun.profile.name ?? "agent";
|
|
5946
5718
|
const promptOptions = readPromptOptions(options.promptOptions, "openSandboxRun: promptOptions");
|
|
5947
|
-
const lineage = createSandboxLineage(client,
|
|
5719
|
+
const lineage = createSandboxLineage(client, { ...options.maxConcurrency !== void 0 ? { maxConcurrency: options.maxConcurrency } : {} });
|
|
5948
5720
|
let handle;
|
|
5949
5721
|
let started = false;
|
|
5950
5722
|
let runStartedAt;
|
|
@@ -6175,9 +5947,6 @@ function hashText(value) {
|
|
|
6175
5947
|
}
|
|
6176
5948
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
6177
5949
|
}
|
|
6178
|
-
function errorMessage(error) {
|
|
6179
|
-
return error instanceof Error ? error.message : String(error);
|
|
6180
|
-
}
|
|
6181
5950
|
//#endregion
|
|
6182
5951
|
//#region src/runtime/authored-code.ts
|
|
6183
5952
|
/**
|
|
@@ -6811,7 +6580,8 @@ async function runStrategyEvolution(cfg) {
|
|
|
6811
6580
|
const { decision, reason } = runtimeShipDecision({
|
|
6812
6581
|
claim: claimResult,
|
|
6813
6582
|
verified: result.claimVerification.status === "verified",
|
|
6814
|
-
accountingComplete: spend.unknownCostCells === 0 && spend.unknownCostOperations === 0,
|
|
6583
|
+
cost: { accountingComplete: spend.unknownCostCells === 0 && spend.unknownCostOperations === 0 },
|
|
6584
|
+
costCeiling: void 0,
|
|
6815
6585
|
lowerBound: shipped?.test?.interval[0] ?? null,
|
|
6816
6586
|
minimumLift: 0
|
|
6817
6587
|
});
|
|
@@ -8047,66 +7817,12 @@ function worktreeFanout(options) {
|
|
|
8047
7817
|
});
|
|
8048
7818
|
}
|
|
8049
7819
|
//#endregion
|
|
8050
|
-
//#region src/runtime/supervise-
|
|
7820
|
+
//#region src/runtime/supervise-analysts.ts
|
|
8051
7821
|
/**
|
|
8052
|
-
*
|
|
8053
|
-
*
|
|
8054
|
-
*
|
|
8055
|
-
* check (settled ⟺ resolved — a worker that ran but didn't pass settles invalid, so a keep-best driver
|
|
8056
|
-
* never counts it done), and feed the driver a self-improvement lens (the still-FAILING tests, by default)
|
|
8057
|
-
* so the next spawn targets the persistently-hard cases. Returns the deployable outcome + the full
|
|
8058
|
-
* conserved spend.
|
|
8059
|
-
*
|
|
8060
|
-
* WHY this lives here and not as a `supervise()` backend: `runAgentic` depends on the supervise core
|
|
8061
|
-
* (`strategy.ts` → `supervise/`), so a surface-solving worker cannot be a supervise built-in without an
|
|
8062
|
-
* import cycle. It is therefore a COMPOSITION of `supervise()` + `runAgentic` at the layer above both —
|
|
8063
|
-
* the right home for "supervise over a graded surface". The within-run self-improvement is the analyst
|
|
8064
|
-
* (authored content, swap `analysts`); the across-run kind wraps this call in `improve()`.
|
|
7822
|
+
* Analyst lenses a supervised manager reads: the agent-eval trace-analyst registry adapted to the
|
|
7823
|
+
* `analysts` option (`analystsFromRegistry`), and `failuresAnalyst`, which reports the tests still
|
|
7824
|
+
* failing in the latest structured `run_tests` span and refuses to infer them from worker prose.
|
|
8065
7825
|
*/
|
|
8066
|
-
/** Instrument every real surface call with the shared push trace source. The last test report remains
|
|
8067
|
-
* available on `SurfaceWorkerOut` for compatibility, but analysts read only the persisted spans. */
|
|
8068
|
-
function traceSurfaceCalls(base) {
|
|
8069
|
-
let lastReport = "";
|
|
8070
|
-
const trace = createPushTraceSource();
|
|
8071
|
-
return {
|
|
8072
|
-
surface: {
|
|
8073
|
-
name: base.name,
|
|
8074
|
-
open: (t) => base.open(t),
|
|
8075
|
-
tools: (t, h) => base.tools(t, h),
|
|
8076
|
-
async call(h, name, args) {
|
|
8077
|
-
const startedAt = Date.now();
|
|
8078
|
-
const recordedArgs = structuredClone(args);
|
|
8079
|
-
try {
|
|
8080
|
-
const out = await base.call(h, name, args);
|
|
8081
|
-
trace.record({
|
|
8082
|
-
toolName: name,
|
|
8083
|
-
args: recordedArgs,
|
|
8084
|
-
result: out,
|
|
8085
|
-
status: out.startsWith("ERROR:") ? "error" : "ok",
|
|
8086
|
-
startedAt,
|
|
8087
|
-
endedAt: Date.now()
|
|
8088
|
-
});
|
|
8089
|
-
if (name === "run_tests") lastReport = out;
|
|
8090
|
-
return out;
|
|
8091
|
-
} catch (error) {
|
|
8092
|
-
trace.record({
|
|
8093
|
-
toolName: name,
|
|
8094
|
-
args: recordedArgs,
|
|
8095
|
-
result: `ERROR: ${error instanceof Error ? error.message : String(error)}`,
|
|
8096
|
-
status: "error",
|
|
8097
|
-
startedAt,
|
|
8098
|
-
endedAt: Date.now()
|
|
8099
|
-
});
|
|
8100
|
-
throw error;
|
|
8101
|
-
}
|
|
8102
|
-
},
|
|
8103
|
-
score: (t, h) => base.score(t, h),
|
|
8104
|
-
close: (h) => base.close(h)
|
|
8105
|
-
},
|
|
8106
|
-
failing: () => failingTestNames(lastReport),
|
|
8107
|
-
traceSource: trace.source
|
|
8108
|
-
};
|
|
8109
|
-
}
|
|
8110
7826
|
/**
|
|
8111
7827
|
* Adapt an `agent-eval` `AnalystRegistry` into the lens shape `supervise({ analysts })` takes.
|
|
8112
7828
|
*
|
|
@@ -8256,124 +7972,6 @@ function allTestsPassed(report) {
|
|
|
8256
7972
|
function missingRunTestsEvidence() {
|
|
8257
7973
|
return { summary: "Missing structured run_tests span evidence. Refusing to infer failing-test names from worker prose." };
|
|
8258
7974
|
}
|
|
8259
|
-
/** One spawned worker = one `runAgentic` attempt over the surface task. The driver's brief is threaded
|
|
8260
|
-
* into the attempt (so a re-spawn can take a targeted angle, not an identical retry); `runAgentic` stamps
|
|
8261
|
-
* real tokens/usd/ms, forwarded as `Spend`; the still-failing tests are captured for the analyst. */
|
|
8262
|
-
function surfaceWorkerExecutor(surface, task, worker, strategy) {
|
|
8263
|
-
let artifact;
|
|
8264
|
-
const traced = traceSurfaceCalls(surface);
|
|
8265
|
-
return {
|
|
8266
|
-
runtime: "surface-worker",
|
|
8267
|
-
async execute(brief) {
|
|
8268
|
-
const guidance = typeof brief === "string" ? brief.trim() : brief ? JSON.stringify(brief) : "";
|
|
8269
|
-
const attemptTask = guidance ? {
|
|
8270
|
-
...task,
|
|
8271
|
-
userPrompt: `${task.userPrompt}\n\n— Supervisor guidance for THIS attempt (incorporate it; do not just repeat a prior approach) —\n${guidance}`
|
|
8272
|
-
} : task;
|
|
8273
|
-
const r = await runAgentic({
|
|
8274
|
-
surface: traced.surface,
|
|
8275
|
-
task: attemptTask,
|
|
8276
|
-
strategy,
|
|
8277
|
-
budget: worker.budget ?? 1,
|
|
8278
|
-
routerBaseUrl: worker.routerBaseUrl,
|
|
8279
|
-
routerKey: worker.routerKey,
|
|
8280
|
-
workerProfile: worker.profile,
|
|
8281
|
-
...worker.analystProfile ? { analystProfile: worker.analystProfile } : {},
|
|
8282
|
-
...worker.innerTurns !== void 0 ? { innerTurns: worker.innerTurns } : {}
|
|
8283
|
-
});
|
|
8284
|
-
const out = {
|
|
8285
|
-
resolved: r.resolved,
|
|
8286
|
-
score: r.score,
|
|
8287
|
-
shots: r.shots,
|
|
8288
|
-
summary: `${strategy.name} ${r.shots} shot(s) → ${(100 * r.score).toFixed(0)}% (${r.resolved ? "resolved" : "unresolved"})`,
|
|
8289
|
-
failing: r.resolved ? [] : traced.failing()
|
|
8290
|
-
};
|
|
8291
|
-
const spent = {
|
|
8292
|
-
iterations: r.completions,
|
|
8293
|
-
tokens: r.tokens,
|
|
8294
|
-
...r.tokensKnown ? {} : { tokensKnown: false },
|
|
8295
|
-
usd: r.usd,
|
|
8296
|
-
...r.usdKnown ? {} : { usdKnown: false },
|
|
8297
|
-
ms: r.ms
|
|
8298
|
-
};
|
|
8299
|
-
artifact = {
|
|
8300
|
-
outRef: `surface-worker:${task.id}:${r.shots}:${r.resolved ? "ok" : "no"}`,
|
|
8301
|
-
out,
|
|
8302
|
-
verdict: {
|
|
8303
|
-
valid: r.resolved,
|
|
8304
|
-
score: r.score
|
|
8305
|
-
},
|
|
8306
|
-
spent
|
|
8307
|
-
};
|
|
8308
|
-
return artifact;
|
|
8309
|
-
},
|
|
8310
|
-
traceSource: () => traced.traceSource,
|
|
8311
|
-
teardown: () => Promise.resolve({ destroyed: true }),
|
|
8312
|
-
resultArtifact() {
|
|
8313
|
-
if (!artifact) throw new Error("surfaceWorkerExecutor: resultArtifact before execute");
|
|
8314
|
-
return artifact;
|
|
8315
|
-
}
|
|
8316
|
-
};
|
|
8317
|
-
}
|
|
8318
|
-
/** Drive a team of agents (spawned + steered by `profile`) to solve a graded `AgenticSurface` task, and
|
|
8319
|
-
* report the deployable outcome + the full conserved spend. This is `supervise()` configured for surfaces
|
|
8320
|
-
* — there is no other entrypoint to learn. */
|
|
8321
|
-
async function superviseSurface(profile, task, opts) {
|
|
8322
|
-
const strategy = opts.strategy ?? refine;
|
|
8323
|
-
const innerTurns = opts.worker.innerTurns ?? 6;
|
|
8324
|
-
const router = opts.router ?? {
|
|
8325
|
-
routerBaseUrl: opts.worker.routerBaseUrl,
|
|
8326
|
-
routerKey: opts.worker.routerKey
|
|
8327
|
-
};
|
|
8328
|
-
const budget = opts.budget ?? {
|
|
8329
|
-
maxIterations: (innerTurns + 2) * 5 + 16,
|
|
8330
|
-
maxTokens: 1e9
|
|
8331
|
-
};
|
|
8332
|
-
const workerMaxTokens = Math.max(1, Math.floor(budget.maxTokens / 8));
|
|
8333
|
-
const makeWorkerAgent = (rawProfile) => {
|
|
8334
|
-
const p = rawProfile ?? {};
|
|
8335
|
-
return {
|
|
8336
|
-
name: typeof p.name === "string" && p.name.length > 0 ? p.name : "surface-worker",
|
|
8337
|
-
act: async () => "",
|
|
8338
|
-
executorSpec: {
|
|
8339
|
-
profile: rawProfile,
|
|
8340
|
-
harness: null,
|
|
8341
|
-
executor: surfaceWorkerExecutor(opts.surface, task, opts.worker, strategy)
|
|
8342
|
-
}
|
|
8343
|
-
};
|
|
8344
|
-
};
|
|
8345
|
-
const deliverable = {
|
|
8346
|
-
describe: `resolve the surface task ${task.id} (every required check passes)`,
|
|
8347
|
-
check: (out) => out?.resolved === true
|
|
8348
|
-
};
|
|
8349
|
-
const analysts = opts.analysts === null ? void 0 : opts.analysts ?? failuresAnalyst();
|
|
8350
|
-
const result = await supervise(profile, task, {
|
|
8351
|
-
makeWorkerAgent,
|
|
8352
|
-
deliverable,
|
|
8353
|
-
budget,
|
|
8354
|
-
workerSlots: opts.workerSlots ?? 1,
|
|
8355
|
-
perWorker: {
|
|
8356
|
-
maxIterations: innerTurns + 2,
|
|
8357
|
-
maxTokens: workerMaxTokens
|
|
8358
|
-
},
|
|
8359
|
-
router,
|
|
8360
|
-
...analysts ? {
|
|
8361
|
-
analysts,
|
|
8362
|
-
analyzeOnSettle: analysts.kinds.map((k) => k.id)
|
|
8363
|
-
} : {}
|
|
8364
|
-
});
|
|
8365
|
-
const out = result.kind === "winner" ? result.out : void 0;
|
|
8366
|
-
const sp = result.spentTotal;
|
|
8367
|
-
return {
|
|
8368
|
-
resolved: out?.resolved ?? false,
|
|
8369
|
-
score: out?.score ?? 0,
|
|
8370
|
-
usd: sp.usd,
|
|
8371
|
-
tokensIn: sp.tokens.input,
|
|
8372
|
-
tokensOut: sp.tokens.output,
|
|
8373
|
-
ms: sp.ms,
|
|
8374
|
-
completions: sp.iterations
|
|
8375
|
-
};
|
|
8376
|
-
}
|
|
8377
7975
|
//#endregion
|
|
8378
7976
|
//#region src/runtime/surface-diff.ts
|
|
8379
7977
|
/**
|
|
@@ -8988,6 +8586,6 @@ function tail(s) {
|
|
|
8988
8586
|
return s.slice(-400);
|
|
8989
8587
|
}
|
|
8990
8588
|
//#endregion
|
|
8991
|
-
export {
|
|
8589
|
+
export { renderCorpusToInstructions as $, chatWorkerSeam as A, completionAuthorizes as At, createS3PrivateCasStore as B, SqlRunOwnershipError as Bt, analyzeTrace as C, assertDeclaredCheck as Ct, codeModeSupervisorTools as D, declaredCheckJudge as Dt, runCoderChecks as E, declaredCheckDigest as Et, authorStrategy as F, pairwiseSignificance as Ft, trajectoryReport as G, createMcpEnvironment as Gt, runBenchmark as H, McpSpawnFault as Ht, strategyAuthorContract as I, renderLeaderboardHtml as It, builtinShapes as J, mcpSecretEnvMetadataKey as Jt, definePersona as K, sanitizeMcpToolSchema as Kt, strategyAuthorSystemPrompt as L, renderLeaderboardMarkdown as Lt, runStrategyEvolution as M, sentinelCompletion as Mt, strategyTournament as N, stopSentinel as Nt, unsafeInProcessRunner as O, readDeclaredCheck as Ot, assertStrategyContract as P, leaderboard as Pt, InMemoryCorpus as Q, createTangleSandboxExactProcessProvider as Qt, SandboxRunAbortError as R, renderLeaderboardSvg as Rt, withUntrackedArtifacts as S, superviseDispatch as St, patchDelivered as T, declaredCheckDeliverable as Tt, createPrivateCasArtifactPort as U, connectStdioMcp as Ut, printBenchmarkReport as V, openSqlRunStore as Vt, equalKOnCost as W, materializeLocalMcp as Wt, registerShape as X, resolveSecretEnv as Xt, createShapeRegistry as Y, resolveMcpServerLaunch as Yt, FileCorpus as Z, secretEnvOfMcpServer as Zt, VERIFY_TAIL_CHARS as _, resolveSandboxClient as _t, localShell as a, selectValidWinner as at, settledWorkerOut as b, loopCampaignDispatch as bt, createVerifierEnvironment as c, assertTraceDerivedFindings as ct, harvestSurfaceDiffs as d, registryScopeAnalyst as dt, fanout as et, analystsFromRegistry as f, observationFromRegistry as ft, NOTE_MAX_CHARS as g, defineLeaderboard as gt, EVIDENCE_MAX_CHARS as h, harvestCorpus as ht, jjWorkspace as i, pipeline as it, createChatSessionStore as j, deterministicCompletion as jt, chatTransportExecutor as k, runIsolatedCheck as kt, boxSurfaceReader as l, buildSteerContext as lt, worktreeFanout as m, HarvestError as mt, makeFinding$1 as n, loopUntil as nt, runInWorkspace as o, verify as ot, failuresAnalyst as p, inProcessSandboxClient as pt, runPersonified as q, envKeyProvider as qt, gitWorkspace as r, panel as rt, createWaterfallCollector as s, widen as st, computeFindingId$1 as t, flatWidenGate as tt, fsSurfaceReader as u, createScopeAnalyst as ut, closingWorkerNote as v, localSandboxClient as vt, createFencedSqlRunContext as w, checkProgramDigest as wt, copyUntrackedIntoClone as x, loopDispatch as xt, composeWorkerEvidence as y, inlineSandboxClient as yt, openSandboxRun as z, renderPairwiseMarkdown as zt };
|
|
8992
8590
|
|
|
8993
|
-
//# sourceMappingURL=runtime-
|
|
8591
|
+
//# sourceMappingURL=runtime-B9eBIyws.js.map
|