@tangle-network/agent-eval 0.142.2 → 0.144.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/CHANGELOG.md +40 -0
- package/README.md +42 -8
- package/dist/analyst/index.d.ts +6 -6
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +3 -3
- package/dist/{benchmark-command-bTf4ibj-.js → benchmark-command-4c7N_rlw.js} +7 -6
- package/dist/benchmark-command-4c7N_rlw.js.map +1 -0
- package/dist/benchmarks/index.d.ts +1 -1
- package/dist/benchmarks/index.js +1 -1
- package/dist/{benchmarks-Ce8GdJbc.js → benchmarks-05UGZ8sZ.js} +4 -4
- package/dist/{benchmarks-Ce8GdJbc.js.map → benchmarks-05UGZ8sZ.js.map} +1 -1
- package/dist/campaign/index.d.ts +5 -4
- package/dist/campaign/index.js +4 -4
- package/dist/{campaign-COFTVy3Q.js → campaign-BKOtvRAB.js} +15 -11
- package/dist/campaign-BKOtvRAB.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/{client-BoqGxEqx.d.ts → client-Cgl6KasJ.d.ts} +2 -2
- package/dist/{client-BoqGxEqx.d.ts.map → client-Cgl6KasJ.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +5 -5
- package/dist/contract/index.js +4 -4
- package/dist/{default-registry-Ci7wAAR8.d.ts → default-registry-D3uqKbo6.d.ts} +2 -2
- package/dist/{default-registry-Ci7wAAR8.d.ts.map → default-registry-D3uqKbo6.d.ts.map} +1 -1
- package/dist/{default-registry-BupFSXSN.js → default-registry-DfHJEwYh.js} +2 -2
- package/dist/{default-registry-BupFSXSN.js.map → default-registry-DfHJEwYh.js.map} +1 -1
- package/dist/{dspy-rlm-engine-Bw8Zz9CX.js → dspy-rlm-engine-CBFwlyaY.js} +89 -7
- package/dist/dspy-rlm-engine-CBFwlyaY.js.map +1 -0
- package/dist/external-optimizer-contracts-iK0yu4AR.d.ts +128 -0
- package/dist/external-optimizer-contracts-iK0yu4AR.d.ts.map +1 -0
- package/dist/hosted/index.d.ts +2 -2
- package/dist/{index-BKjcUH13.d.ts → index-BZUe-ODI.d.ts} +41 -5
- package/dist/index-BZUe-ODI.d.ts.map +1 -0
- package/dist/{index-DCP4I2Qx.d.ts → index-DgbFl4cv.d.ts} +14 -11
- package/dist/{index-DCP4I2Qx.d.ts.map → index-DgbFl4cv.d.ts.map} +1 -1
- package/dist/{index-CKI1CXTL.d.ts → index-DtMpBKVF.d.ts} +4 -4
- package/dist/{index-CKI1CXTL.d.ts.map → index-DtMpBKVF.d.ts.map} +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/{integrity-hruKe6oe.js → integrity-DY6tIbl0.js} +48 -18
- package/dist/integrity-DY6tIbl0.js.map +1 -0
- package/dist/multishot/index.d.ts +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{replay-BqTgoioO.d.ts → replay-BuJM6kLh.d.ts} +2 -2
- package/dist/{replay-BqTgoioO.d.ts.map → replay-BuJM6kLh.d.ts.map} +1 -1
- package/dist/{reward-hacking-GyN0kMd8.js → reward-hacking-DjTi9HLb.js} +34 -14
- package/dist/reward-hacking-DjTi9HLb.js.map +1 -0
- package/dist/rl.d.ts +263 -2
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +332 -3
- package/dist/rl.js.map +1 -1
- package/dist/{single-run-lock-BcvPQY57.js → single-run-lock-t1si1ob7.js} +371 -153
- package/dist/single-run-lock-t1si1ob7.js.map +1 -0
- package/dist/{skill-usage-CNZTk_LT.d.ts → skill-usage-BiVEU0QY.d.ts} +5 -5
- package/dist/{skill-usage-CNZTk_LT.d.ts.map → skill-usage-BiVEU0QY.d.ts.map} +1 -1
- package/dist/{skillopt-optimization-method-D1dqGzzH.d.ts → skillopt-optimization-method-B7o01OdX.d.ts} +63 -13
- package/dist/skillopt-optimization-method-B7o01OdX.d.ts.map +1 -0
- package/dist/{skillopt-optimization-method-DV6c4ooy.js → skillopt-optimization-method-Ds8J1_K8.js} +440 -270
- package/dist/skillopt-optimization-method-Ds8J1_K8.js.map +1 -0
- package/dist/supervisor-run/index.d.ts +3 -3
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{supervisor-run-BEns49Nx.js → supervisor-run-DiyQVczd.js} +301 -25
- package/dist/supervisor-run-DiyQVczd.js.map +1 -0
- package/dist/{tool-groups-DVQTy9lq.d.ts → tool-groups-Bqy4A3QB.d.ts} +2 -2
- package/dist/{tool-groups-DVQTy9lq.d.ts.map → tool-groups-Bqy4A3QB.d.ts.map} +1 -1
- package/dist/traces.d.ts +2 -2
- package/dist/{types-Dk7PB7vh.d.ts → types-KEqL1pZc.d.ts} +6 -4
- package/dist/{types-Dk7PB7vh.d.ts.map → types-KEqL1pZc.d.ts.map} +1 -1
- package/dist/{types-Dea6tiVI.d.ts → types-yLK8gXE9.d.ts} +15 -2
- package/dist/types-yLK8gXE9.d.ts.map +1 -0
- package/docs/campaign-proposers.md +11 -7
- package/docs/verified-labels-flywheel.md +46 -0
- package/package.json +1 -1
- package/dist/benchmark-command-bTf4ibj-.js.map +0 -1
- package/dist/campaign-COFTVy3Q.js.map +0 -1
- package/dist/dspy-rlm-engine-Bw8Zz9CX.js.map +0 -1
- package/dist/external-optimizer-contracts-nb7c_WAR.d.ts +0 -42
- package/dist/external-optimizer-contracts-nb7c_WAR.d.ts.map +0 -1
- package/dist/index-BKjcUH13.d.ts.map +0 -1
- package/dist/integrity-hruKe6oe.js.map +0 -1
- package/dist/reward-hacking-GyN0kMd8.js.map +0 -1
- package/dist/single-run-lock-BcvPQY57.js.map +0 -1
- package/dist/skillopt-optimization-method-D1dqGzzH.d.ts.map +0 -1
- package/dist/skillopt-optimization-method-DV6c4ooy.js.map +0 -1
- package/dist/supervisor-run-BEns49Nx.js.map +0 -1
- package/dist/types-Dea6tiVI.d.ts.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as Unavailable, D as showMeasured, E as isUnavailable, O as unavailable, S as SupervisorRunTreeGapCode, T as WorkerLogSource, _ as SupervisorRunReport, a as OrchestrationMetrics, b as SupervisorRunTree, c as PerWorkerRow, d as SUPERVISOR_RUN_ROLLUP_SCHEMA, f as SUPERVISOR_RUN_SCHEMA, g as SupervisorRunReader, h as SupervisorRunNodeRole, i as NO_SOURCE_LIMITS, l as RoleSpend, m as SteerBreakdown, n as EconomicsMetrics, o as OutcomeMetrics, p as SourceLimits, r as Measured, s as PatchStats, t as DecisionMetrics, u as RollupCellRow, v as SupervisorRunRollup, w as WallDistribution, x as SupervisorRunTreeGap, y as SupervisorRunSources } from "../types-
|
|
2
|
-
import { A as
|
|
3
|
-
export { type ClaudeCodeReaderOptions, type CloseRow, DEFAULT_CANCEL_TOOLS, DEFAULT_SPAWN_TOOLS, DEFAULT_STEER_TOOLS, type DecisionMetrics, type EconomicsMetrics, type LoopsReaderOptions, type Measured, NO_SOURCE_LIMITS, type OrchestrationMetrics, type OutcomeMetrics, type PatchStats, type PerWorkerRow, type RoleSpend, type RollupCellRow, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, type SourceLimits, type SpawnRow, type SteerAcknowledgementFact, type SteerBreakdown, type SteerRequestFact, type SupervisorJournalDialect, type SupervisorRolloutOptions, type SupervisorRunIntegrityEvidence, type SupervisorRunIntegrityIssue, type SupervisorRunIntegrityIssueCode, type SupervisorRunIntegrityOptions, type SupervisorRunIntegrityReport, type SupervisorRunIntegritySeverity, type SupervisorRunNodeRole, type SupervisorRunReader, type SupervisorRunReport, type SupervisorRunRollup, type SupervisorRunSourceOnlyCheckCode, type SupervisorRunSources, type SupervisorRunTree, type SupervisorRunTreeGap, type SupervisorRunTreeGapCode, type SupervisorTreeFacts, type Unavailable, type WallDistribution, type WorkerLogFacts, type WorkerLogSource, type WriteSupervisorRunOptions, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirIn, findSupervisorRunDirs, isUnavailable, loopsSupervisorRunReader, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readLoopsSupervisorRun, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, showMeasured, supervisorReportStem, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
|
|
1
|
+
import { C as Unavailable, D as showMeasured, E as isUnavailable, O as unavailable, S as SupervisorRunTreeGapCode, T as WorkerLogSource, _ as SupervisorRunReport, a as OrchestrationMetrics, b as SupervisorRunTree, c as PerWorkerRow, d as SUPERVISOR_RUN_ROLLUP_SCHEMA, f as SUPERVISOR_RUN_SCHEMA, g as SupervisorRunReader, h as SupervisorRunNodeRole, i as NO_SOURCE_LIMITS, l as RoleSpend, m as SteerBreakdown, n as EconomicsMetrics, o as OutcomeMetrics, p as SourceLimits, r as Measured, s as PatchStats, t as DecisionMetrics, u as RollupCellRow, v as SupervisorRunRollup, w as WallDistribution, x as SupervisorRunTreeGap, y as SupervisorRunSources } from "../types-yLK8gXE9.js";
|
|
2
|
+
import { A as DEFAULT_CANCEL_TOOLS, B as SteerAcknowledgementFact, C as SupervisorRunIntegrityIssue, D as SupervisorRunIntegritySeverity, E as SupervisorRunIntegrityReport, F as analyzeSupervisorRunSources, G as parseSupervisorTree, H as SupervisorJournalDialect, I as parsePatch, L as rollupSupervisorRuns, M as DEFAULT_STEER_TOOLS, N as claudeCodeSupervisorRunReader, O as SupervisorRunSourceOnlyCheckCode, P as readClaudeCodeSupervisorRun, R as CloseRow, S as SupervisorRunIntegrityEvidence, T as SupervisorRunIntegrityOptions, U as SupervisorTreeFacts, V as SteerRequestFact, W as WorkerLogFacts, _ as supervisorReportStem, a as supervisorRunRolloutLines, b as analyzeSupervisorRunIntegrity, c as renderSupervisorRunMarkdown, d as analyzeSupervisorRun, f as findSupervisorRunDirIn, g as reportSupervisorRound, h as readLoopsSupervisorRun, i as SupervisorRolloutOptions, j as DEFAULT_SPAWN_TOOLS, k as ClaudeCodeReaderOptions, l as LoopsReaderOptions, m as loopsSupervisorRunReader, n as readRuntimeSupervisorRun, o as renderSupervisorRollupMarkdown, p as findSupervisorRunDirs, r as runtimeSupervisorRunReader, s as renderSupervisorRunHeadline, t as isRuntimeSupervisorRunDir, u as WriteSupervisorRunOptions, v as writeSupervisorRunReport, w as SupervisorRunIntegrityIssueCode, x as SUPERVISOR_RUN_INTEGRITY_SCHEMA, y as writeSupervisorRunReportSafe, z as SpawnRow } from "../index-BZUe-ODI.js";
|
|
3
|
+
export { type ClaudeCodeReaderOptions, type CloseRow, DEFAULT_CANCEL_TOOLS, DEFAULT_SPAWN_TOOLS, DEFAULT_STEER_TOOLS, type DecisionMetrics, type EconomicsMetrics, type LoopsReaderOptions, type Measured, NO_SOURCE_LIMITS, type OrchestrationMetrics, type OutcomeMetrics, type PatchStats, type PerWorkerRow, type RoleSpend, type RollupCellRow, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, type SourceLimits, type SpawnRow, type SteerAcknowledgementFact, type SteerBreakdown, type SteerRequestFact, type SupervisorJournalDialect, type SupervisorRolloutOptions, type SupervisorRunIntegrityEvidence, type SupervisorRunIntegrityIssue, type SupervisorRunIntegrityIssueCode, type SupervisorRunIntegrityOptions, type SupervisorRunIntegrityReport, type SupervisorRunIntegritySeverity, type SupervisorRunNodeRole, type SupervisorRunReader, type SupervisorRunReport, type SupervisorRunRollup, type SupervisorRunSourceOnlyCheckCode, type SupervisorRunSources, type SupervisorRunTree, type SupervisorRunTreeGap, type SupervisorRunTreeGapCode, type SupervisorTreeFacts, type Unavailable, type WallDistribution, type WorkerLogFacts, type WorkerLogSource, type WriteSupervisorRunOptions, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirIn, findSupervisorRunDirs, isRuntimeSupervisorRunDir, isUnavailable, loopsSupervisorRunReader, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readLoopsSupervisorRun, readRuntimeSupervisorRun, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, runtimeSupervisorRunReader, showMeasured, supervisorReportStem, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { c as SUPERVISOR_RUN_INTEGRITY_SCHEMA, n as supervisorRunRolloutLines, o as parseSupervisorTree, t as analyzeSupervisorRunIntegrity } from "../integrity-
|
|
2
|
-
import { C as
|
|
3
|
-
export { DEFAULT_CANCEL_TOOLS, DEFAULT_SPAWN_TOOLS, DEFAULT_STEER_TOOLS, NO_SOURCE_LIMITS, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirIn, findSupervisorRunDirs, isUnavailable, loopsSupervisorRunReader, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readLoopsSupervisorRun, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, showMeasured, supervisorReportStem, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
|
|
1
|
+
import { c as SUPERVISOR_RUN_INTEGRITY_SCHEMA, n as supervisorRunRolloutLines, o as parseSupervisorTree, t as analyzeSupervisorRunIntegrity } from "../integrity-DY6tIbl0.js";
|
|
2
|
+
import { C as rollupSupervisorRuns, D as isUnavailable, E as SUPERVISOR_RUN_SCHEMA, O as showMeasured, S as parsePatch, T as SUPERVISOR_RUN_ROLLUP_SCHEMA, _ as DEFAULT_SPAWN_TOOLS, a as readLoopsSupervisorRun, b as readClaudeCodeSupervisorRun, c as writeSupervisorRunReport, d as readRuntimeSupervisorRun, f as runtimeSupervisorRunReader, g as DEFAULT_CANCEL_TOOLS, h as renderSupervisorRunMarkdown, i as loopsSupervisorRunReader, k as unavailable, l as writeSupervisorRunReportSafe, m as renderSupervisorRunHeadline, n as findSupervisorRunDirIn, o as reportSupervisorRound, p as renderSupervisorRollupMarkdown, r as findSupervisorRunDirs, s as supervisorReportStem, t as analyzeSupervisorRun, u as isRuntimeSupervisorRunDir, v as DEFAULT_STEER_TOOLS, w as NO_SOURCE_LIMITS, x as analyzeSupervisorRunSources, y as claudeCodeSupervisorRunReader } from "../supervisor-run-DiyQVczd.js";
|
|
3
|
+
export { DEFAULT_CANCEL_TOOLS, DEFAULT_SPAWN_TOOLS, DEFAULT_STEER_TOOLS, NO_SOURCE_LIMITS, SUPERVISOR_RUN_INTEGRITY_SCHEMA, SUPERVISOR_RUN_ROLLUP_SCHEMA, SUPERVISOR_RUN_SCHEMA, analyzeSupervisorRun, analyzeSupervisorRunIntegrity, analyzeSupervisorRunSources, claudeCodeSupervisorRunReader, findSupervisorRunDirIn, findSupervisorRunDirs, isRuntimeSupervisorRunDir, isUnavailable, loopsSupervisorRunReader, parsePatch, parseSupervisorTree, readClaudeCodeSupervisorRun, readLoopsSupervisorRun, readRuntimeSupervisorRun, renderSupervisorRollupMarkdown, renderSupervisorRunHeadline, renderSupervisorRunMarkdown, reportSupervisorRound, rollupSupervisorRuns, runtimeSupervisorRunReader, showMeasured, supervisorReportStem, supervisorRunRolloutLines, unavailable, writeSupervisorRunReport, writeSupervisorRunReportSafe };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as parseJsonl, i as parseJson, o as parseSupervisorTree, r as asRecord, s as workerSourceKey } from "./integrity-
|
|
1
|
+
import { a as parseJsonl, i as parseJson, o as parseSupervisorTree, r as asRecord, s as workerSourceKey } from "./integrity-DY6tIbl0.js";
|
|
2
2
|
import { d as transcriptFromEntries, i as openOpencodeDb, l as parseClaudeEntries, r as findOpencodeSessionsByDirectory, t as DEFAULT_OPENCODE_DB } from "./opencode-sqlite-8r6WUfHc.js";
|
|
3
3
|
import { basename, dirname, join } from "node:path";
|
|
4
|
-
import { appendFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import { appendFile, mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
//#region src/supervisor-run/types.ts
|
|
6
6
|
function unavailable(reason) {
|
|
7
7
|
return { unavailable: reason };
|
|
@@ -51,6 +51,7 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
|
|
|
51
51
|
const result = parseJson(src.result);
|
|
52
52
|
const judge = parseJson(src.judge);
|
|
53
53
|
const { rootId, workerSpawns, workerCloses, startedAt, completedAt } = tree;
|
|
54
|
+
const rootSpawn = rootId === null ? null : tree.spawns.find((spawn) => spawn.id === rootId) ?? null;
|
|
54
55
|
const spawnById = new Map(workerSpawns.map((spawn) => [spawn.id, spawn]));
|
|
55
56
|
const spawnsByLabel = /* @__PURE__ */ new Map();
|
|
56
57
|
for (const spawn of workerSpawns) {
|
|
@@ -245,9 +246,11 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
|
|
|
245
246
|
reviewActions: src.workers === null ? unavailable(workersGapReason) : queuedGapReason === null ? steerQueuedTotal + upLegMessages : unavailable(queuedGapReason),
|
|
246
247
|
workerEvidenceBytes: src.workers === null ? unavailable(workersGapReason) : workerEventsGapReason === null ? evidenceBytes : unavailable(workerEventsGapReason)
|
|
247
248
|
};
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
const
|
|
249
|
+
const rootChildIds = new Set(workerSpawns.filter((spawn) => spawn.parent === rootId).map((spawn) => spawn.id));
|
|
250
|
+
const rootChildCloses = workerCloses.filter((close) => rootChildIds.has(close.id));
|
|
251
|
+
const journalWorkerIn = rootChildCloses.reduce((a, c) => a + c.spend.tokens.input, 0);
|
|
252
|
+
const journalWorkerOut = rootChildCloses.reduce((a, c) => a + c.spend.tokens.output, 0);
|
|
253
|
+
const journalWorkerUsd = rootChildCloses.reduce((a, c) => a + c.spend.usd, 0);
|
|
251
254
|
const workerUsdById = /* @__PURE__ */ new Map();
|
|
252
255
|
for (const c of workerCloses) workerUsdById.set(c.id, (workerUsdById.get(c.id) ?? 0) + c.spend.usd);
|
|
253
256
|
const labelById = new Map(workerSpawns.map((spawn) => [spawn.id, spawn.label]));
|
|
@@ -273,13 +276,21 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
|
|
|
273
276
|
const close = spawn === null ? null : closeById.get(spawn.id) ?? null;
|
|
274
277
|
const passed = close?.valid ?? f?.passed ?? null;
|
|
275
278
|
const matchingRoles = new Set(matchingSpawns.map((candidate) => candidate.role));
|
|
279
|
+
const matchingRuntimes = new Set(matchingSpawns.map((candidate) => candidate.runtime));
|
|
280
|
+
const matchingProfiles = new Set(matchingSpawns.map((candidate) => candidate.profileDigest));
|
|
281
|
+
const journalWallMs = spawn?.at !== null && spawn?.at !== void 0 && close?.at !== null && close?.at !== void 0 && close.at >= spawn.at ? close.at - spawn.at : null;
|
|
276
282
|
return {
|
|
277
283
|
workerId: w.workerId ?? null,
|
|
278
284
|
worker: w.label,
|
|
279
285
|
role: matchingRoles.size === 1 ? matchingSpawns[0]?.role ?? null : null,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
runtime: matchingRuntimes.size === 1 ? matchingSpawns[0]?.runtime ?? null : null,
|
|
287
|
+
profileDigest: matchingProfiles.size === 1 ? matchingSpawns[0]?.profileDigest ?? null : null,
|
|
288
|
+
status: close?.status ?? null,
|
|
289
|
+
failure: close?.reason ?? null,
|
|
290
|
+
infra: close?.infra ?? null,
|
|
291
|
+
wallMs: f?.started != null && f.finishedAt != null ? f.finishedAt - f.started : journalWallMs,
|
|
292
|
+
tokensIn: w.tokensIn ?? (close?.hasSpend ? close.spend.tokens.input : null),
|
|
293
|
+
tokensOut: w.tokensOut ?? (close?.hasSpend ? close.spend.tokens.output : null),
|
|
283
294
|
usd: usdLimit !== null ? null : w.workerId === void 0 ? workerUsdByLabel.get(w.label) ?? null : workerUsdById.get(w.workerId) ?? null,
|
|
284
295
|
patchBytes: w.patchBytes ?? f?.finishedPatchBytes ?? null,
|
|
285
296
|
passed,
|
|
@@ -298,7 +309,7 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
|
|
|
298
309
|
cacheWrite: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : tree.brain.hasCache ? tree.brain.cacheWrite : unavailable(NO_CACHE_COUNTERS),
|
|
299
310
|
source: managerTokenLimit ?? (haveJournal ? `journal metered events (n=${tree.brain.meteredCount})` : journalMissing)
|
|
300
311
|
},
|
|
301
|
-
brainTruncations: src.brainLog === null ? gap("brain.brainTruncations", src.supRunDir === null ? "no supervisor run dir under <ws>/.agent/supervisor (or legacy <ws>/.loops/supervisor)" : "brain.jsonl absent — loops predates the brain-call tap, so truncation cannot be ruled out") : brainCalls.filter((c) => c.finish_reason === "length").length,
|
|
312
|
+
brainTruncations: src.brainLog === null ? gap("brain.brainTruncations", src.brainLogMissingReason ?? (src.supRunDir === null ? "no supervisor run dir under <ws>/.agent/supervisor (or legacy <ws>/.loops/supervisor)" : "brain.jsonl absent — loops predates the brain-call tap, so truncation cannot be ruled out")) : brainCalls.filter((c) => c.finish_reason === "length").length,
|
|
302
313
|
workers: {
|
|
303
314
|
tokensIn: workerIn,
|
|
304
315
|
tokensOut: workerOut,
|
|
@@ -308,7 +319,7 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
|
|
|
308
319
|
source: workerTokenLimit !== null ? workerTokenLimit : sq !== null ? `journal settled spend + ${sq.store} sessions (n=${sq.sessions})` : `journal settled spend only — ${src.harnessMissingReason ?? "harness session store unavailable"}`
|
|
309
320
|
},
|
|
310
321
|
totalUsd,
|
|
311
|
-
totalUsdSource: usdLimit !== null ? usdLimit : stateUsd !== null ? `state.json result.spentUsd${journalWorkerUsd === 0 ? " — brain-priced only; worker CLI inference is unpriced (see worker token counts)" : ""}` : haveJournal ? "journal metered + settled usd" : journalMissing,
|
|
322
|
+
totalUsdSource: usdLimit !== null ? usdLimit : stateUsd !== null ? `state.json result.spentUsd${rootChildCloses.length > 0 && journalWorkerUsd === 0 ? " — brain-priced only; worker CLI inference is unpriced (see worker token counts)" : ""}` : haveJournal ? "journal metered + settled usd" : journalMissing,
|
|
312
323
|
costPerAcceptedPatchUsd: isUnavailable(totalUsd) ? unavailable(totalUsd.unavailable) : isUnavailable(decision.accepted) ? unavailable(decision.accepted.unavailable) : decision.accepted === 0 ? unavailable("no accepted worker patch (cost has no denominator)") : round(totalUsd / decision.accepted, 6),
|
|
313
324
|
workerWallMsDistribution: walls.length === 0 ? unavailable(src.workers === null ? workersGapReason : "no worker start/finish pairs captured") : {
|
|
314
325
|
n: walls.length,
|
|
@@ -340,6 +351,7 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
|
|
|
340
351
|
instanceId: src.instanceId,
|
|
341
352
|
arm: src.arm,
|
|
342
353
|
supervisorId: rootId !== null ? rootId : unavailable(journalMissing),
|
|
354
|
+
supervisorProfileDigest: rootSpawn?.profileDigest !== null && rootSpawn?.profileDigest !== void 0 ? rootSpawn.profileDigest : gap("supervisorProfileDigest", "root spawned event has no profile digest"),
|
|
343
355
|
generatedAt: new Date(now()).toISOString(),
|
|
344
356
|
orchestration,
|
|
345
357
|
decision,
|
|
@@ -976,6 +988,7 @@ function renderSupervisorRunMarkdown(r) {
|
|
|
976
988
|
out.push("");
|
|
977
989
|
out.push(`- Run: \`${r.runRef}\``);
|
|
978
990
|
out.push(`- Supervisor: \`${showMeasured(r.supervisorId)}\``);
|
|
991
|
+
out.push(`- Supervisor profile: \`${showMeasured(r.supervisorProfileDigest)}\``);
|
|
979
992
|
out.push(`- Generated: ${r.generatedAt}`);
|
|
980
993
|
out.push("");
|
|
981
994
|
out.push("## Orchestration");
|
|
@@ -1039,9 +1052,9 @@ function renderSupervisorRunMarkdown(r) {
|
|
|
1039
1052
|
}
|
|
1040
1053
|
out.push("");
|
|
1041
1054
|
if (!isUnavailable(e.perWorker) && e.perWorker.length > 0) {
|
|
1042
|
-
out.push("| Worker id | Label | Role | Wall | Tokens in | Tokens out | Patch bytes | Verify passed | Score |");
|
|
1043
|
-
out.push("
|
|
1044
|
-
for (const w of e.perWorker) out.push(`| ${w.workerId === null ? "unavailable — legacy label join" : `\`${w.workerId}\``} | \`${w.worker}\` | ${w.role ?? "unavailable — no
|
|
1055
|
+
out.push("| Worker id | Label | Role | Runtime | Profile digest | Status | Failure | Infra | Wall | Tokens in | Tokens out | Patch bytes | Verify passed | Score |");
|
|
1056
|
+
out.push("|---|---|---|---|---|---|---|---|---:|---:|---:|---:|---|---:|");
|
|
1057
|
+
for (const w of e.perWorker) out.push(`| ${w.workerId === null ? "unavailable — legacy label join" : `\`${w.workerId}\``} | \`${w.worker}\` | ${w.role ?? "unavailable — source recorded no role"} | ${w.runtime ?? "unavailable — source recorded no runtime"} | ${w.profileDigest === null ? "unavailable — source recorded no profile digest" : `\`${w.profileDigest}\``} | ${w.status ?? "unavailable — no terminal event"} | ${w.failure ?? "none recorded"} | ${w.infra ?? "unavailable"} | ${w.wallMs === null ? "unavailable — no spawn/finish pair" : fmtMs(w.wallMs)} | ${w.tokensIn ?? "unavailable — store does not attribute tokens per worker"} | ${w.tokensOut ?? "unavailable — store does not attribute tokens per worker"} | ${w.patchBytes ?? "unavailable — no worker patch file"} | ${w.passed === null ? "unavailable — no verdict" : String(w.passed)} | ${w.score ?? "unavailable — no numeric score"} |`);
|
|
1045
1058
|
out.push("");
|
|
1046
1059
|
}
|
|
1047
1060
|
out.push("## Outcome");
|
|
@@ -1096,6 +1109,268 @@ function renderSupervisorRollupMarkdown(rollup, title = "Round rollup") {
|
|
|
1096
1109
|
return out.join("\n");
|
|
1097
1110
|
}
|
|
1098
1111
|
//#endregion
|
|
1112
|
+
//#region src/supervisor-run/runtime-reader.ts
|
|
1113
|
+
/**
|
|
1114
|
+
* Reader for agent-runtime's file-backed supervision context.
|
|
1115
|
+
*
|
|
1116
|
+
* Runtime stores multiple recursive trees in one `spawn-journal.jsonl`.
|
|
1117
|
+
* Each line is an envelope whose `root` identifies the local tree. A nested
|
|
1118
|
+
* driver is represented twice: once as a child spawn in its parent's tree and
|
|
1119
|
+
* once as the parentless root marker of its own tree. This reader removes only
|
|
1120
|
+
* that duplicate root marker and passes the remaining events to the existing
|
|
1121
|
+
* supervisor-run analyzer.
|
|
1122
|
+
*/
|
|
1123
|
+
const JOURNAL_FILE = "spawn-journal.jsonl";
|
|
1124
|
+
const RESULT_FILE = "result.json";
|
|
1125
|
+
const TRAJECTORY_FILE = "trajectory.json";
|
|
1126
|
+
async function readMaybe$1(path) {
|
|
1127
|
+
return readFile(path, "utf8").catch((error) => {
|
|
1128
|
+
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") return null;
|
|
1129
|
+
throw error;
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
function record(value) {
|
|
1133
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
1134
|
+
}
|
|
1135
|
+
function nonEmptyString(value) {
|
|
1136
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
1137
|
+
}
|
|
1138
|
+
function formatError(path, line, detail) {
|
|
1139
|
+
return /* @__PURE__ */ new Error(`${path}:${line}: invalid Runtime spawn journal: ${detail}`);
|
|
1140
|
+
}
|
|
1141
|
+
function parseEnvelopeJournal(text, path) {
|
|
1142
|
+
const begins = [];
|
|
1143
|
+
const events = [];
|
|
1144
|
+
const begun = /* @__PURE__ */ new Map();
|
|
1145
|
+
for (const [index, sourceLine] of text.split("\n").entries()) {
|
|
1146
|
+
const line = index + 1;
|
|
1147
|
+
const trimmed = sourceLine.trim();
|
|
1148
|
+
if (trimmed.length === 0) continue;
|
|
1149
|
+
let parsed;
|
|
1150
|
+
try {
|
|
1151
|
+
parsed = JSON.parse(trimmed);
|
|
1152
|
+
} catch {
|
|
1153
|
+
throw formatError(path, line, "line is not JSON");
|
|
1154
|
+
}
|
|
1155
|
+
const envelope = record(parsed);
|
|
1156
|
+
if (envelope === null) throw formatError(path, line, "line is not an object");
|
|
1157
|
+
const kind = nonEmptyString(envelope.kind);
|
|
1158
|
+
const root = nonEmptyString(envelope.root);
|
|
1159
|
+
if (root === null) throw formatError(path, line, "root must be a non-empty string");
|
|
1160
|
+
if (kind === "begin") {
|
|
1161
|
+
const at = nonEmptyString(envelope.at);
|
|
1162
|
+
if (at === null || !Number.isFinite(Date.parse(at))) throw formatError(path, line, "begin.at must be an ISO timestamp");
|
|
1163
|
+
if (begun.has(root)) throw formatError(path, line, `tree ${JSON.stringify(root)} began twice`);
|
|
1164
|
+
const begin = {
|
|
1165
|
+
root,
|
|
1166
|
+
at,
|
|
1167
|
+
line
|
|
1168
|
+
};
|
|
1169
|
+
begun.set(root, begin);
|
|
1170
|
+
begins.push(begin);
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
if (kind !== "event") throw formatError(path, line, "kind must be 'begin' or 'event'");
|
|
1174
|
+
if (!begun.has(root)) throw formatError(path, line, `event for tree ${JSON.stringify(root)} precedes begin`);
|
|
1175
|
+
const event = record(envelope.event);
|
|
1176
|
+
if (event === null) throw formatError(path, line, "event must be an object");
|
|
1177
|
+
if (nonEmptyString(event.kind) === null) throw formatError(path, line, "event.kind must be a non-empty string");
|
|
1178
|
+
events.push({
|
|
1179
|
+
root,
|
|
1180
|
+
event: { ...event },
|
|
1181
|
+
line
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
if (begins.length === 0) throw formatError(path, 1, "no begin record");
|
|
1185
|
+
const parentSpawnsById = /* @__PURE__ */ new Map();
|
|
1186
|
+
const rootMarkersByTree = /* @__PURE__ */ new Map();
|
|
1187
|
+
for (const entry of events) {
|
|
1188
|
+
if (entry.event.kind !== "spawned") continue;
|
|
1189
|
+
const id = nonEmptyString(entry.event.id);
|
|
1190
|
+
if (id === null) continue;
|
|
1191
|
+
if (nonEmptyString(entry.event.parent) !== null) {
|
|
1192
|
+
const matches = parentSpawnsById.get(id) ?? [];
|
|
1193
|
+
matches.push(entry);
|
|
1194
|
+
parentSpawnsById.set(id, matches);
|
|
1195
|
+
}
|
|
1196
|
+
if (entry.root === id && entry.event.parent === void 0) {
|
|
1197
|
+
const markers = rootMarkersByTree.get(entry.root) ?? [];
|
|
1198
|
+
markers.push(entry);
|
|
1199
|
+
rootMarkersByTree.set(entry.root, markers);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
const nestedRoots = /* @__PURE__ */ new Set();
|
|
1203
|
+
const nestedParentSpawns = /* @__PURE__ */ new Map();
|
|
1204
|
+
for (const begin of begins) {
|
|
1205
|
+
const parentSpawns = (parentSpawnsById.get(begin.root) ?? []).filter((entry) => entry.root !== begin.root);
|
|
1206
|
+
if (parentSpawns.length > 1) throw formatError(path, begin.line, `tree ${JSON.stringify(begin.root)} has ${parentSpawns.length} parent spawns`);
|
|
1207
|
+
if (parentSpawns.length === 1) {
|
|
1208
|
+
nestedRoots.add(begin.root);
|
|
1209
|
+
nestedParentSpawns.set(begin.root, parentSpawns[0]);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
const topRoots = begins.filter((begin) => !nestedRoots.has(begin.root));
|
|
1213
|
+
if (topRoots.length !== 1) throw formatError(path, topRoots[0]?.line ?? 1, `expected one top-level tree, found ${topRoots.length}`);
|
|
1214
|
+
const top = topRoots[0];
|
|
1215
|
+
for (const nestedRoot of nestedRoots) {
|
|
1216
|
+
const marker = rootMarkersByTree.get(nestedRoot) ?? [];
|
|
1217
|
+
if (marker.length !== 1) throw formatError(path, begun.get(nestedRoot)?.line ?? 1, `nested tree ${JSON.stringify(nestedRoot)} must contain one root marker`);
|
|
1218
|
+
const parentSpawn = nestedParentSpawns.get(nestedRoot);
|
|
1219
|
+
if (parentSpawn === void 0) throw formatError(path, begun.get(nestedRoot)?.line ?? 1, `nested tree ${JSON.stringify(nestedRoot)} has no parent spawn`);
|
|
1220
|
+
const markerDigest = nonEmptyString(marker[0]?.event.profileDigest);
|
|
1221
|
+
const parentDigest = nonEmptyString(parentSpawn.event.profileDigest);
|
|
1222
|
+
if (markerDigest !== null && parentDigest !== null && markerDigest !== parentDigest) throw formatError(path, marker[0]?.line ?? 1, `nested tree ${JSON.stringify(nestedRoot)} disagrees with its parent profile digest`);
|
|
1223
|
+
if (parentDigest === null && markerDigest !== null) parentSpawn.event.profileDigest = markerDigest;
|
|
1224
|
+
}
|
|
1225
|
+
const normalized = events.filter((entry) => !(nestedRoots.has(entry.root) && entry.event.kind === "spawned" && entry.event.id === entry.root && entry.event.parent === void 0)).map((entry) => entry.event);
|
|
1226
|
+
if ((rootMarkersByTree.get(top.root) ?? []).length !== 1) throw formatError(path, top.line, `top-level tree ${JSON.stringify(top.root)} must contain one root marker`);
|
|
1227
|
+
return {
|
|
1228
|
+
root: top.root,
|
|
1229
|
+
startedAt: top.at,
|
|
1230
|
+
journal: `${normalized.map((event) => JSON.stringify(event)).join("\n")}\n`,
|
|
1231
|
+
events: normalized
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
function parseOptionalRecord(text, path) {
|
|
1235
|
+
if (text === null) return null;
|
|
1236
|
+
let parsed;
|
|
1237
|
+
try {
|
|
1238
|
+
parsed = JSON.parse(text);
|
|
1239
|
+
} catch {
|
|
1240
|
+
throw new Error(`${path}: invalid JSON`);
|
|
1241
|
+
}
|
|
1242
|
+
const value = record(parsed);
|
|
1243
|
+
if (value === null) throw new Error(`${path}: expected a JSON object`);
|
|
1244
|
+
return value;
|
|
1245
|
+
}
|
|
1246
|
+
function spendRecord(value) {
|
|
1247
|
+
const spend = record(value);
|
|
1248
|
+
if (spend === null) return null;
|
|
1249
|
+
const tokens = record(spend.tokens);
|
|
1250
|
+
if (tokens === null || typeof tokens.input !== "number" || !Number.isFinite(tokens.input) || tokens.input < 0 || typeof tokens.output !== "number" || !Number.isFinite(tokens.output) || tokens.output < 0 || typeof spend.usd !== "number" || !Number.isFinite(spend.usd) || spend.usd < 0 || spend.usdKnown !== void 0 && typeof spend.usdKnown !== "boolean") return null;
|
|
1251
|
+
return spend;
|
|
1252
|
+
}
|
|
1253
|
+
function sourceLimits(root, events, workerIds) {
|
|
1254
|
+
const rootMeters = events.filter((event) => event.kind === "metered" && event.id === root);
|
|
1255
|
+
const invalidRootMeters = rootMeters.filter((event) => spendRecord(event.spend) === null);
|
|
1256
|
+
const rootMeterReason = rootMeters.length === 0 ? "Runtime journal has no root metered event" : invalidRootMeters.length > 0 ? `${invalidRootMeters.length} root metered event(s) lack complete spend` : null;
|
|
1257
|
+
const closes = events.filter((event) => workerIds.has(nonEmptyString(event.id) ?? "") && (event.kind === "settled" || event.kind === "cancelled"));
|
|
1258
|
+
const settledById = /* @__PURE__ */ new Map();
|
|
1259
|
+
for (const event of closes) {
|
|
1260
|
+
const id = nonEmptyString(event.id);
|
|
1261
|
+
if (id === null) continue;
|
|
1262
|
+
const matches = settledById.get(id) ?? [];
|
|
1263
|
+
matches.push(event);
|
|
1264
|
+
settledById.set(id, matches);
|
|
1265
|
+
}
|
|
1266
|
+
const incompleteWorkers = [...workerIds].filter((id) => {
|
|
1267
|
+
const terminal = settledById.get(id);
|
|
1268
|
+
return terminal?.length !== 1 || terminal[0]?.kind !== "settled" || spendRecord(terminal[0]?.spent) === null;
|
|
1269
|
+
});
|
|
1270
|
+
const unknownUsd = [...rootMeters.map((event) => spendRecord(event.spend)), ...closes.filter((event) => event.kind === "settled").map((event) => spendRecord(event.spent))].filter((spend) => spend !== null).some((spend) => spend.usdKnown === false);
|
|
1271
|
+
const missingVerdicts = [...workerIds].filter((id) => {
|
|
1272
|
+
const terminal = settledById.get(id)?.[0];
|
|
1273
|
+
if (terminal?.kind !== "settled") return true;
|
|
1274
|
+
return typeof record(terminal.verdict)?.valid !== "boolean";
|
|
1275
|
+
});
|
|
1276
|
+
return {
|
|
1277
|
+
managerTokens: rootMeterReason,
|
|
1278
|
+
workerTokens: incompleteWorkers.length === 0 ? null : `${incompleteWorkers.length}/${workerIds.size} child invocation(s) lack one settled spend record`,
|
|
1279
|
+
spendUsd: rootMeterReason !== null ? rootMeterReason : unknownUsd ? "Runtime recorded usdKnown:false for at least one spend" : incompleteWorkers.length > 0 ? "at least one child invocation lacks a settled spend record" : null,
|
|
1280
|
+
workerVerdicts: missingVerdicts.length === 0 ? null : `${missingVerdicts.length}/${workerIds.size} child invocation(s) lack a structured validity verdict`,
|
|
1281
|
+
deliverables: workerIds.size === 0 ? null : "Runtime FileRunContext does not retain per-child delivered patches"
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
function runtimeState(root, startedAt, result, trajectory, resultPath, trajectoryPath) {
|
|
1285
|
+
const resultKind = result?.kind === "completed" || result?.kind === "interrupted" ? result.kind : null;
|
|
1286
|
+
if (resultKind !== null && result !== null) {
|
|
1287
|
+
const resultRoot = nonEmptyString(record(result.tree)?.root);
|
|
1288
|
+
if (resultRoot === null) throw new Error(`${resultPath}: Runtime ${resultKind} result has no tree.root`);
|
|
1289
|
+
if (resultRoot !== root) throw new Error(`${resultPath}: root ${JSON.stringify(resultRoot)} does not match journal root ${JSON.stringify(root)}`);
|
|
1290
|
+
}
|
|
1291
|
+
if (trajectory !== null && nonEmptyString(trajectory.root) === null) throw new Error(`${trajectoryPath}: Runtime trajectory has no root`);
|
|
1292
|
+
if (typeof trajectory?.root === "string" && trajectory.root !== root) throw new Error(`${trajectoryPath}: root ${JSON.stringify(trajectory.root)} does not match journal root ${JSON.stringify(root)}`);
|
|
1293
|
+
if (trajectory !== null && !Array.isArray(trajectory.nodes)) throw new Error(`${trajectoryPath}: Runtime trajectory nodes must be an array`);
|
|
1294
|
+
let status = null;
|
|
1295
|
+
if (resultKind === "completed") status = "completed";
|
|
1296
|
+
else if (resultKind === "interrupted") status = "interrupted";
|
|
1297
|
+
else if (Array.isArray(trajectory?.nodes)) {
|
|
1298
|
+
const rootNodes = trajectory.nodes.map((node) => record(node)).filter((node) => node?.id === root);
|
|
1299
|
+
if (rootNodes.length > 1) throw new Error(`${trajectoryPath}: Runtime trajectory contains duplicate root nodes`);
|
|
1300
|
+
status = nonEmptyString(rootNodes[0]?.status);
|
|
1301
|
+
}
|
|
1302
|
+
return JSON.stringify({
|
|
1303
|
+
id: root,
|
|
1304
|
+
startedAt,
|
|
1305
|
+
...status === null ? {} : { status }
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Read one agent-runtime `createFileRunContext(dir)` directory.
|
|
1310
|
+
*
|
|
1311
|
+
* The reader translates storage envelopes only. It does not assign research
|
|
1312
|
+
* roles, interpret artifacts, or turn process completion into a quality
|
|
1313
|
+
* verdict.
|
|
1314
|
+
*/
|
|
1315
|
+
async function readRuntimeSupervisorRun(runDir) {
|
|
1316
|
+
const journalPath = join(runDir, JOURNAL_FILE);
|
|
1317
|
+
const normalized = parseEnvelopeJournal(await readFile(journalPath, "utf8"), journalPath);
|
|
1318
|
+
const resultText = await readMaybe$1(join(runDir, RESULT_FILE));
|
|
1319
|
+
const trajectoryText = await readMaybe$1(join(runDir, TRAJECTORY_FILE));
|
|
1320
|
+
const result = parseOptionalRecord(resultText, join(runDir, RESULT_FILE));
|
|
1321
|
+
const trajectory = parseOptionalRecord(trajectoryText, join(runDir, TRAJECTORY_FILE));
|
|
1322
|
+
const resultPath = join(runDir, RESULT_FILE);
|
|
1323
|
+
const trajectoryPath = join(runDir, TRAJECTORY_FILE);
|
|
1324
|
+
const childSpawns = normalized.events.filter((event) => event.kind === "spawned" && nonEmptyString(event.id) !== null).filter((event) => event.id !== normalized.root);
|
|
1325
|
+
const workerIds = new Set(childSpawns.map((event) => nonEmptyString(event.id)).filter((id) => id !== null));
|
|
1326
|
+
const workers = childSpawns.map((event) => ({
|
|
1327
|
+
workerId: nonEmptyString(event.id),
|
|
1328
|
+
label: nonEmptyString(event.label) ?? String(event.id),
|
|
1329
|
+
events: null,
|
|
1330
|
+
inbox: null,
|
|
1331
|
+
patchBytes: null,
|
|
1332
|
+
transcriptRef: null,
|
|
1333
|
+
patchPath: null
|
|
1334
|
+
}));
|
|
1335
|
+
return {
|
|
1336
|
+
runRef: runDir,
|
|
1337
|
+
instanceId: normalized.root,
|
|
1338
|
+
arm: null,
|
|
1339
|
+
supRunDir: runDir,
|
|
1340
|
+
journal: normalized.journal,
|
|
1341
|
+
brainLog: null,
|
|
1342
|
+
brainLogMissingReason: "Runtime FileRunContext records spend but not model completion finish reasons",
|
|
1343
|
+
state: runtimeState(normalized.root, normalized.startedAt, result, trajectory, resultPath, trajectoryPath),
|
|
1344
|
+
progress: null,
|
|
1345
|
+
workers,
|
|
1346
|
+
workersMissingReason: null,
|
|
1347
|
+
result: resultText,
|
|
1348
|
+
judge: null,
|
|
1349
|
+
judgeSource: null,
|
|
1350
|
+
patch: null,
|
|
1351
|
+
driverLog: null,
|
|
1352
|
+
harnessWorkerTokens: null,
|
|
1353
|
+
harnessMissingReason: "Runtime FileRunContext has no external worker-token join",
|
|
1354
|
+
limits: sourceLimits(normalized.root, normalized.events, workerIds),
|
|
1355
|
+
rootTranscriptRef: null,
|
|
1356
|
+
traceCommand: "unavailable — Runtime FileRunContext records no provider-session trace identity"
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
/** The agent-runtime file-backed layout as a `SupervisorRunReader`. */
|
|
1360
|
+
function runtimeSupervisorRunReader(runDir) {
|
|
1361
|
+
return {
|
|
1362
|
+
runRef: runDir,
|
|
1363
|
+
read: () => readRuntimeSupervisorRun(runDir)
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
/** True when a directory contains Runtime's canonical file-backed journal. */
|
|
1367
|
+
async function isRuntimeSupervisorRunDir(runDir) {
|
|
1368
|
+
return stat(join(runDir, JOURNAL_FILE)).then((entry) => entry.isFile()).catch((error) => {
|
|
1369
|
+
if (typeof error === "object" && error !== null && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) return false;
|
|
1370
|
+
throw error;
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
//#endregion
|
|
1099
1374
|
//#region src/supervisor-run/loops-reader.ts
|
|
1100
1375
|
/**
|
|
1101
1376
|
* ONE implementation of `SupervisorRunReader`: the on-disk layout the loops
|
|
@@ -1277,7 +1552,7 @@ function instanceIdFromPath(runDir) {
|
|
|
1277
1552
|
* caller with its own store never has to touch the filesystem layout.
|
|
1278
1553
|
*/
|
|
1279
1554
|
async function analyzeSupervisorRun(input, opts = {}) {
|
|
1280
|
-
if (typeof input === "string") return analyzeSupervisorRunSources(await readLoopsSupervisorRun(input, opts));
|
|
1555
|
+
if (typeof input === "string") return analyzeSupervisorRunSources(await isRuntimeSupervisorRunDir(input) ? await readRuntimeSupervisorRun(input) : await readLoopsSupervisorRun(input, opts));
|
|
1281
1556
|
if (isReader(input)) return analyzeSupervisorRunSources(await input.read());
|
|
1282
1557
|
return analyzeSupervisorRunSources(input);
|
|
1283
1558
|
}
|
|
@@ -1291,7 +1566,7 @@ function isReader(input) {
|
|
|
1291
1566
|
* every metric says why.
|
|
1292
1567
|
*/
|
|
1293
1568
|
async function writeSupervisorRunReport(runDir, opts = {}) {
|
|
1294
|
-
const report = analyzeSupervisorRunSources(await readLoopsSupervisorRun(runDir, opts));
|
|
1569
|
+
const report = analyzeSupervisorRunSources(await isRuntimeSupervisorRunDir(runDir) ? await readRuntimeSupervisorRun(runDir) : await readLoopsSupervisorRun(runDir, opts));
|
|
1295
1570
|
const md = renderSupervisorRunMarkdown(report);
|
|
1296
1571
|
const dest = opts.reportDir ?? runDir;
|
|
1297
1572
|
const stem = opts.reportDir === void 0 ? "run-report" : supervisorReportStem(runDir);
|
|
@@ -1359,8 +1634,14 @@ async function reportSupervisorRound(outDir, opts = {}) {
|
|
|
1359
1634
|
if (opts.echo !== false) console.log(md);
|
|
1360
1635
|
return rollup;
|
|
1361
1636
|
}
|
|
1362
|
-
/**
|
|
1637
|
+
/**
|
|
1638
|
+
* Every loops or Runtime supervisor run below `root`.
|
|
1639
|
+
*
|
|
1640
|
+
* When `root` itself is one run, return no children so callers can distinguish
|
|
1641
|
+
* a single report from a parent-directory rollup.
|
|
1642
|
+
*/
|
|
1363
1643
|
async function findSupervisorRunDirs(root) {
|
|
1644
|
+
if (await isRuntimeSupervisorRunDir(root) || await findSupervisorRunDirIn(join(root, "ws")) !== null) return [];
|
|
1364
1645
|
const found = [];
|
|
1365
1646
|
const walk = async (dir, depth) => {
|
|
1366
1647
|
if (depth > 8) return;
|
|
@@ -1369,13 +1650,8 @@ async function findSupervisorRunDirs(root) {
|
|
|
1369
1650
|
if (!e.isDirectory()) continue;
|
|
1370
1651
|
if (e.name === "node_modules" || e.name === ".git") continue;
|
|
1371
1652
|
const full = join(dir, e.name);
|
|
1372
|
-
if (
|
|
1373
|
-
|
|
1374
|
-
for (const iid of iids) {
|
|
1375
|
-
if (!iid.isDirectory()) continue;
|
|
1376
|
-
const arms = await readdir(join(full, iid.name), { withFileTypes: true }).catch(() => []);
|
|
1377
|
-
for (const arm of arms) if (arm.isDirectory()) found.push(join(full, iid.name, arm.name));
|
|
1378
|
-
}
|
|
1653
|
+
if (await isRuntimeSupervisorRunDir(full) || await findSupervisorRunDirIn(join(full, "ws")) !== null) {
|
|
1654
|
+
found.push(full);
|
|
1379
1655
|
continue;
|
|
1380
1656
|
}
|
|
1381
1657
|
await walk(full, depth + 1);
|
|
@@ -1385,6 +1661,6 @@ async function findSupervisorRunDirs(root) {
|
|
|
1385
1661
|
return found.sort();
|
|
1386
1662
|
}
|
|
1387
1663
|
//#endregion
|
|
1388
|
-
export {
|
|
1664
|
+
export { rollupSupervisorRuns as C, isUnavailable as D, SUPERVISOR_RUN_SCHEMA as E, showMeasured as O, parsePatch as S, SUPERVISOR_RUN_ROLLUP_SCHEMA as T, DEFAULT_SPAWN_TOOLS as _, readLoopsSupervisorRun as a, readClaudeCodeSupervisorRun as b, writeSupervisorRunReport as c, readRuntimeSupervisorRun as d, runtimeSupervisorRunReader as f, DEFAULT_CANCEL_TOOLS as g, renderSupervisorRunMarkdown as h, loopsSupervisorRunReader as i, unavailable as k, writeSupervisorRunReportSafe as l, renderSupervisorRunHeadline as m, findSupervisorRunDirIn as n, reportSupervisorRound as o, renderSupervisorRollupMarkdown as p, findSupervisorRunDirs as r, supervisorReportStem as s, analyzeSupervisorRun as t, isRuntimeSupervisorRunDir as u, DEFAULT_STEER_TOOLS as v, NO_SOURCE_LIMITS as w, analyzeSupervisorRunSources as x, claudeCodeSupervisorRunReader as y };
|
|
1389
1665
|
|
|
1390
|
-
//# sourceMappingURL=supervisor-run-
|
|
1666
|
+
//# sourceMappingURL=supervisor-run-DiyQVczd.js.map
|