@tangle-network/agent-eval 0.209.1 → 0.211.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 +20 -0
- package/README.md +1 -1
- package/dist/adapters/http.d.ts +1 -1
- package/dist/analyst/index.d.ts +2 -2
- package/dist/analyst/index.js +1 -1
- package/dist/{analyze-runs-0cdYMgob.js → analyze-runs-3xpby3p2.js} +4 -4
- package/dist/analyze-runs-3xpby3p2.js.map +1 -0
- package/dist/{benchmark-command-Cve7mHNC.js → benchmark-command-S8tCtkxh.js} +3 -3
- package/dist/{benchmark-command-Cve7mHNC.js.map → benchmark-command-S8tCtkxh.js.map} +1 -1
- package/dist/benchmarks/index.d.ts +1 -1
- package/dist/benchmarks/index.js +2 -2
- package/dist/campaign/index.d.ts +2 -2
- package/dist/campaign/index.js +9 -9
- package/dist/{campaign-evidence-B5qsCHEn.js → campaign-evidence-OcUciD-N.js} +2 -2
- package/dist/campaign-evidence-OcUciD-N.js.map +1 -0
- package/dist/{campaign-CvhmiLKa.js → campaign-wvvJA1ps.js} +10 -10
- package/dist/{campaign-CvhmiLKa.js.map → campaign-wvvJA1ps.js.map} +1 -1
- package/dist/claude-jsonl-dZir12m6.js +86 -0
- package/dist/claude-jsonl-dZir12m6.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/contract/index.d.ts +5 -5
- package/dist/contract/index.js +90 -14
- package/dist/contract/index.js.map +1 -1
- package/dist/counterfactual-DtMWvn7D.js.map +1 -1
- package/dist/{define-agent-eval-_nyV5nev.d.ts → define-agent-eval-B_zZY2AZ.d.ts} +3 -3
- package/dist/{define-agent-eval-_nyV5nev.d.ts.map → define-agent-eval-B_zZY2AZ.d.ts.map} +1 -1
- package/dist/{define-agent-eval-Csd47ur_.js → define-agent-eval-CoXXDCMu.js} +4 -4
- package/dist/{define-agent-eval-Csd47ur_.js.map → define-agent-eval-CoXXDCMu.js.map} +1 -1
- package/dist/diagnosis/index.js +1 -1
- package/dist/{eval-campaign-C31Qbv77.js → eval-campaign-4byTtqrf.js} +2 -2
- package/dist/{eval-campaign-C31Qbv77.js.map → eval-campaign-4byTtqrf.js.map} +1 -1
- package/dist/experiment/index.d.ts +1 -1
- package/dist/experiment/index.js +6 -6
- package/dist/feedback-trajectory-CX01700m.d.ts.map +1 -1
- package/dist/{index-H-u7f-w3.d.ts → index-D0_l25We.d.ts} +20 -41
- package/dist/{index-H-u7f-w3.d.ts.map → index-D0_l25We.d.ts.map} +1 -1
- package/dist/{index-BHh9Z9El.d.ts → index-DnZdBxCL.d.ts} +9 -6
- package/dist/{index-BHh9Z9El.d.ts.map → index-DnZdBxCL.d.ts.map} +1 -1
- package/dist/{index-Ddi5M-TQ.d.ts → index-xnhRdqik.d.ts} +3 -14
- package/dist/{index-Ddi5M-TQ.d.ts.map → index-xnhRdqik.d.ts.map} +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/judge-gate-B1_O0QIs.d.ts +454 -0
- package/dist/judge-gate-B1_O0QIs.d.ts.map +1 -0
- package/dist/judge-gate-B1qYnkpi.js +658 -0
- package/dist/judge-gate-B1qYnkpi.js.map +1 -0
- package/dist/{llm-judge-C0256VT_.js → llm-judge-Tr7MBUnf.js} +6 -6
- package/dist/llm-judge-Tr7MBUnf.js.map +1 -0
- package/dist/meta-eval/index.d.ts +2 -132
- package/dist/meta-eval/index.d.ts.map +1 -1
- package/dist/meta-eval/index.js +2 -275
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{paired-arms-B5v-X7No.js → paired-arms-DzKn0TfY.js} +2 -2
- package/dist/{paired-arms-B5v-X7No.js.map → paired-arms-DzKn0TfY.js.map} +1 -1
- package/dist/{paired-binary-b2L3WKqr.js → paired-binary-Q36bhn2R.js} +13 -9
- package/dist/paired-binary-Q36bhn2R.js.map +1 -0
- package/dist/{paired-promotion-decision-2deJ7sDX.js → paired-promotion-decision-BN6IQTiu.js} +2 -2
- package/dist/{paired-promotion-decision-2deJ7sDX.js.map → paired-promotion-decision-BN6IQTiu.js.map} +1 -1
- package/dist/{produced-state-CgB9g0VX.js → produced-state-CKybuR9F.js} +3 -3
- package/dist/produced-state-CKybuR9F.js.map +1 -0
- package/dist/{promotion-policy-CCmyEH_c.js → promotion-policy-CWW35UWq.js} +3 -3
- package/dist/{promotion-policy-CCmyEH_c.js.map → promotion-policy-CWW35UWq.js.map} +1 -1
- package/dist/reporting.js +2 -2
- package/dist/rl.js +3 -3
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +3 -3
- package/dist/{rollout-BZqQc0YY.js → rollout-D9bKKBnZ.js} +29 -164
- package/dist/rollout-D9bKKBnZ.js.map +1 -0
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-Bfe3kzRk.js → search-kernel-BIXWM7YV.js} +3 -3
- package/dist/search-kernel-BIXWM7YV.js.map +1 -0
- package/dist/{search-summary-DK1bwTAf.js → search-summary-nwrtXxC_.js} +3 -3
- package/dist/{search-summary-DK1bwTAf.js.map → search-summary-nwrtXxC_.js.map} +1 -1
- package/dist/{sequential-BOzBND4t.js → sequential-D-1PPCmM.js} +2 -2
- package/dist/{sequential-BOzBND4t.js.map → sequential-D-1PPCmM.js.map} +1 -1
- package/dist/{skillopt-optimization-method-BCojvoP1.js → skillopt-optimization-method-DujPOiwD.js} +4 -4
- package/dist/{skillopt-optimization-method-BCojvoP1.js.map → skillopt-optimization-method-DujPOiwD.js.map} +1 -1
- package/dist/{statistical-heldout-BP6iEJvR.js → statistical-heldout-1Gbmex7v.js} +2 -2
- package/dist/{statistical-heldout-BP6iEJvR.js.map → statistical-heldout-1Gbmex7v.js.map} +1 -1
- package/dist/{statistical-heldout-D0rX_IDl.d.ts → statistical-heldout-8RGPIeyo.d.ts} +14 -10
- package/dist/statistical-heldout-8RGPIeyo.d.ts.map +1 -0
- package/dist/{summary-report-BsaEFEwA.js → summary-report-DtdRucM0.js} +2 -2
- package/dist/{summary-report-BsaEFEwA.js.map → summary-report-DtdRucM0.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +34 -69
- package/dist/supervisor-run/index.js.map +1 -1
- package/dist/{tree-CZ78tiPg.js → tree-kc1d80yF.js} +3 -3
- package/dist/{tree-CZ78tiPg.js.map → tree-kc1d80yF.js.map} +1 -1
- package/docs/concepts.md +14 -0
- package/docs/experiment.md +10 -0
- package/docs/trace-analysis.md +3 -0
- package/package.json +4 -3
- package/dist/analyze-runs-0cdYMgob.js.map +0 -1
- package/dist/campaign-evidence-B5qsCHEn.js.map +0 -1
- package/dist/claude-jsonl-CG3JUbTJ.js +0 -211
- package/dist/claude-jsonl-CG3JUbTJ.js.map +0 -1
- package/dist/llm-judge-C0256VT_.js.map +0 -1
- package/dist/paired-binary-b2L3WKqr.js.map +0 -1
- package/dist/produced-state-CgB9g0VX.js.map +0 -1
- package/dist/rollout-BZqQc0YY.js.map +0 -1
- package/dist/search-kernel-Bfe3kzRk.js.map +0 -1
- package/dist/series-convergence-CjO2QdRW.js +0 -43
- package/dist/series-convergence-CjO2QdRW.js.map +0 -1
- package/dist/series-convergence-hEfKdoi-.d.ts +0 -126
- package/dist/series-convergence-hEfKdoi-.d.ts.map +0 -1
- package/dist/statistical-heldout-D0rX_IDl.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/supervisor-run/claude-code-reader.ts"],"sourcesContent":["/**\n * Supervision-tree reader over a THIRD-PARTY harness: Claude Code.\n *\n * The Runtime reader reads a supervisor journal designed for this analysis.\n * for this analysis. This reader reads a harness we do not control, whose\n * transcript was designed for replaying a chat — and recovers the same tree\n * from it. If both produce a `SupervisorRunSources`, the tree model is a\n * property of multi-agent runs, not of our journal format.\n *\n * ## Where the tree hides in a Claude Code transcript\n *\n * | Tree fact | Claude Code evidence |\n * |---|---|\n * | spawn | assistant `tool_use` (`Agent` / `Task`), answered by a `tool_result` whose `toolUseResult.agentId` names the child |\n * | settle | a `<task-notification>` block in a later user line: `<task-id>` = agentId, `<status>` |\n * | steer | assistant `tool_use` (`SendMessage`) with `input.to` = agentId — mid-task, to a LIVE child |\n * | delivered | that steer's `tool_result` carrying `success` / `resumedAgentId` |\n * | cancel | assistant `tool_use` (`TaskStop`) targeting an agentId |\n * | brain spend| `message.usage` on the main thread's assistant lines |\n * | worker spend| `message.usage` inside `<session>/subagents/agent-<id>.jsonl` |\n * | depth | a child transcript that itself contains `Agent` tool_use lines |\n *\n * Every one of those is read through `parseClaudeEntries` — the SAME line\n * parser `src/rollout/readers/claude-jsonl.ts` uses for solo rollouts. There\n * is no second transcript parser.\n *\n * ## What Claude Code cannot say\n *\n * It records tokens but never a price, runs no per-worker verify, and keeps no\n * per-worker patch. Those are declared once in `limits`, so the analyzer\n * reports `unavailable — <reason>` instead of the $0 / 0-accepted that summing\n * an empty field would produce. See `SourceLimits`.\n *\n * ## Metric coverage vs the Runtime journal\n *\n * Measured on a real 52-agent session (fixture:\n * `tests/fixtures/supervisor-run/claude-code-session-*`).\n *\n * | Metric | Runtime | Claude Code | Why |\n * |---|---|---|---|\n * | workersSpawned / Settled / Cancelled | full | full | spawn tool_use + task-notification + TaskStop |\n * | steers / steersDelivered / steersByWorker | full | full | `SendMessage`; delivery from its tool_result |\n * | waves / waveSizes / maxConcurrency | full | full | derived from spawn/settle instants |\n * | respawns / repeatedLabels | full | full | same derivation |\n * | delegationDepth | full | full | a child transcript's own spawn calls |\n * | timeToFirstSpawn / supervisorWall | full | full | transcript instants |\n * | idleMs / idlePct / workerUtilization | full | PARTIAL | an agent that never notifies is counted live to the end of the transcript |\n * | observeThenRespawn / respawnWithoutEvidence | full | full | ordering of spawn vs settle instants |\n * | workerEvidenceBytes | full | PARTIAL | the child's closing message; 0 for pruned transcripts |\n * | brain tokens in/out + cache | full | full | main-thread `message.usage` |\n * | worker tokens in/out + cache | via harness join | full or unavailable | totals are refused if any spawned transcript was pruned; retained per-worker rows remain available |\n * | perWorker wall | full | full | spawn → settle instants |\n * | accepted / rejected / emptyPass / settledVerdicts | full | NONE | no per-worker verify step exists |\n * | brain/worker/total usd, costPerAcceptedPatch | full | NONE | transcripts carry no price |\n * | patch stats, delivered, verifyPass/Rc | full | NONE | no diff is handed back |\n * | judgeResolved / Score / Passed / Total | full | NONE | no judge in the loop |\n * | driverSteerCalls, brainTruncations | full | NONE | no outer driver log, no per-call finish_reason tap |\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\nimport {\n type ClaudeEntry,\n parseClaudeEntries,\n transcriptFromEntries,\n} from '../rollout/readers/claude-jsonl'\nimport type { SupervisorRunReader, SupervisorRunSources, WorkerLogSource } from './types'\n\n/** Tool names that spawn a child agent. `Task` is the older name for `Agent`. */\nconst DEFAULT_SPAWN_TOOLS = ['Agent', 'Task'] as const\n/** Tool names that deliver a message to an ALREADY-RUNNING child agent. */\nconst DEFAULT_STEER_TOOLS = ['SendMessage'] as const\n/** Tool names that stop a running child agent. */\nconst DEFAULT_CANCEL_TOOLS = ['TaskStop', 'KillAgent'] as const\n\nconst SPEND_UNPRICED =\n 'Claude Code transcripts record token usage but never a price — usd is not in the store'\nconst NO_VERDICTS =\n 'Claude Code runs no per-worker verify step — a subagent reports prose, not pass/fail'\nconst NO_DELIVERABLES =\n 'Claude Code retains no per-worker patch — subagents commit to git, they do not hand back a diff'\n\nexport interface ClaudeCodeReaderOptions {\n /** The main session transcript: `~/.claude/projects/<slug>/<sessionId>.jsonl`. */\n readonly transcriptPath: string\n /**\n * Directory of child transcripts. Defaults to `<transcript-dir>/<sessionId>/subagents`.\n * `null` skips the join, and every per-worker token count becomes unavailable.\n */\n readonly subagentsDir?: string | null\n readonly runRef?: string\n readonly instanceId?: string | null\n readonly arm?: string | null\n readonly spawnTools?: readonly string[]\n readonly steerTools?: readonly string[]\n readonly cancelTools?: readonly string[]\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\ninterface ToolUse {\n readonly id: string\n readonly name: string\n readonly input: Record<string, unknown>\n readonly at: string | null\n}\n\ninterface ToolResult {\n readonly id: string\n readonly at: string | null\n readonly structured: unknown\n readonly text: string\n}\n\n/** Every tool call and tool result on one thread, in order, with instants. */\ninterface ThreadCalls {\n readonly uses: ToolUse[]\n readonly results: Map<string, ToolResult>\n readonly notifications: TaskNotification[]\n readonly firstAt: string | null\n readonly lastAt: string | null\n}\n\ninterface TaskNotification {\n readonly taskId: string\n readonly toolUseId: string | null\n readonly status: string\n readonly summary: string | null\n readonly at: string | null\n}\n\nfunction blockText(content: unknown): string {\n if (typeof content === 'string') return content\n if (!Array.isArray(content)) return ''\n const parts: string[] = []\n for (const b of content) {\n if (isRecord(b) && b.type === 'text' && typeof b.text === 'string') parts.push(b.text)\n }\n return parts.join('\\n')\n}\n\nconst tag = (xml: string, name: string): string | null => {\n const m = xml.match(new RegExp(`<${name}>([\\\\s\\\\S]*?)</${name}>`))\n return m === null ? null : (m[1] as string)\n}\n\n/**\n * Task notifications are the settle instants. A notification fires each time an\n * agent stops, so a resumed agent produces several — they are kept in order and\n * the LAST one is the settle the analyzer sees, with the earlier ones acting as\n * the intermediate stops they actually were.\n */\nfunction parseNotifications(text: string, at: string | null): TaskNotification[] {\n const out: TaskNotification[] = []\n for (const m of text.matchAll(/<task-notification>[\\s\\S]*?<\\/task-notification>/g)) {\n const xml = m[0]\n const taskId = tag(xml, 'task-id')\n if (taskId === null) continue\n out.push({\n taskId: taskId.trim(),\n toolUseId: tag(xml, 'tool-use-id')?.trim() ?? null,\n status: tag(xml, 'status')?.trim() ?? 'unknown',\n summary: tag(xml, 'summary')?.trim() ?? null,\n at,\n })\n }\n return out\n}\n\n/** Project entries of ONE thread (main or a single sidechain) into tool traffic. */\nfunction threadCalls(entries: readonly ClaudeEntry[]): ThreadCalls {\n const uses: ToolUse[] = []\n const results = new Map<string, ToolResult>()\n const notifications: TaskNotification[] = []\n let firstAt: string | null = null\n let lastAt: string | null = null\n\n for (const entry of entries) {\n if (entry.timestamp !== null) {\n if (firstAt === null) firstAt = entry.timestamp\n lastAt = entry.timestamp\n }\n const content = entry.message.content\n if (entry.type === 'assistant') {\n if (!Array.isArray(content)) continue\n for (const block of content) {\n if (!isRecord(block) || block.type !== 'tool_use') continue\n const id = str(block.id)\n const name = str(block.name)\n if (id === null || name === null) continue\n uses.push({\n id,\n name,\n input: isRecord(block.input) ? block.input : {},\n at: entry.timestamp,\n })\n }\n continue\n }\n if (typeof content === 'string') {\n notifications.push(...parseNotifications(content, entry.timestamp))\n continue\n }\n if (!Array.isArray(content)) continue\n for (const block of content) {\n if (!isRecord(block)) continue\n if (block.type === 'tool_result' && typeof block.tool_use_id === 'string') {\n results.set(block.tool_use_id, {\n id: block.tool_use_id,\n at: entry.timestamp,\n structured: entry.toolUseResult,\n text: blockText(block.content),\n })\n } else if (block.type === 'text' && typeof block.text === 'string') {\n notifications.push(...parseNotifications(block.text, entry.timestamp))\n }\n }\n }\n return { uses, results, notifications, firstAt, lastAt }\n}\n\n/**\n * The agent id a spawn produced. Claude Code puts it in the structured\n * `toolUseResult`; the same id is echoed in the result text for transcripts\n * written before that field existed, so both are tried before giving up.\n */\nfunction spawnedAgentId(result: ToolResult | undefined): string | null {\n if (result === undefined) return null\n if (isRecord(result.structured)) {\n const id = str(result.structured.agentId)\n if (id !== null) return id\n }\n return result.text.match(/agentId:\\s*([A-Za-z0-9_-]+)/)?.[1] ?? null\n}\n\ninterface ChildTranscript {\n readonly agentId: string\n readonly path: string\n readonly description: string | null\n readonly spawnToolUseId: string | null\n readonly spawnDepth: number | null\n readonly entries: ClaudeEntry[]\n readonly tokensIn: number | null\n readonly tokensOut: number | null\n readonly cacheRead: number | null\n readonly cacheWrite: number | null\n readonly gaps: readonly string[]\n readonly firstAt: string | null\n readonly lastAt: string | null\n readonly model: string | null\n /**\n * The child's closing assistant message — what it actually handed back. This\n * is the Claude Code analogue of a worker's `evidence` blob.\n */\n readonly finalReport: string | null\n}\n\nasync function readChildren(dir: string): Promise<ChildTranscript[]> {\n const names = await readdir(dir).catch(() => null)\n if (names === null) return []\n const out: ChildTranscript[] = []\n for (const name of names.filter((n) => n.endsWith('.jsonl')).sort()) {\n const path = join(dir, name)\n const raw = await readFile(path, 'utf8').catch(() => null)\n if (raw === null) continue\n const sourceGaps: string[] = []\n const entries = parseClaudeEntries(raw, (gap) => sourceGaps.push(gap))\n // A subagent transcript is sidechain end to end — that flag is what marks it\n // a separate invocation rather than a turn of the parent.\n const projected = transcriptFromEntries(entries, { includeSidechain: true, sourceGaps })\n const metaRaw = await readFile(path.replace(/\\.jsonl$/, '.meta.json'), 'utf8').catch(() => null)\n let meta: Record<string, unknown> = {}\n if (metaRaw !== null) {\n try {\n const parsed: unknown = JSON.parse(metaRaw)\n if (isRecord(parsed)) meta = parsed\n } catch {\n meta = {}\n }\n }\n const agentId =\n entries.find((e) => e.agentId !== null)?.agentId ??\n name.replace(/^agent-/, '').replace(/\\.jsonl$/, '')\n out.push({\n agentId,\n path,\n description: str(meta.description),\n spawnToolUseId: str(meta.toolUseId),\n spawnDepth: typeof meta.spawnDepth === 'number' ? meta.spawnDepth : null,\n entries,\n tokensIn: projected.usage.tokensIn,\n tokensOut: projected.usage.tokensOut,\n cacheRead: projected.usage.cacheRead,\n cacheWrite: projected.usage.cacheWrite,\n gaps: projected.gaps,\n firstAt: projected.startedAt,\n lastAt: projected.endedAt,\n model: projected.model,\n finalReport:\n [...projected.messages]\n .reverse()\n .find((m) => m.role === 'assistant' && typeof m.content === 'string')?.content ?? null,\n })\n }\n return out\n}\n\ninterface SpawnFact {\n readonly agentId: string\n readonly parentId: string\n readonly label: string\n readonly at: string | null\n readonly model: string | null\n}\n\n/** A journal line in the dialect `parseSupervisorTree` reads. */\nconst line = (obj: Record<string, unknown>): string => JSON.stringify(obj)\n\n/**\n * Read a Claude Code session (plus its subagent transcripts) as supervision-tree\n * source bytes. Never throws on a missing artifact.\n */\nexport async function readClaudeCodeSupervisorRun(\n opts: ClaudeCodeReaderOptions,\n): Promise<SupervisorRunSources> {\n const spawnTools = new Set(opts.spawnTools ?? DEFAULT_SPAWN_TOOLS)\n const steerTools = new Set(opts.steerTools ?? DEFAULT_STEER_TOOLS)\n const cancelTools = new Set(opts.cancelTools ?? DEFAULT_CANCEL_TOOLS)\n\n const raw = await readFile(opts.transcriptPath, 'utf8').catch(() => null)\n const sessionId = basename(opts.transcriptPath).replace(/\\.jsonl$/, '')\n const runRef = opts.runRef ?? opts.transcriptPath\n const limits = {\n managerTokens: null,\n workerTokens: null,\n spendUsd: SPEND_UNPRICED,\n workerVerdicts: NO_VERDICTS,\n deliverables: null,\n }\n const traceCommand = `npx --yes @tangle-network/traces@latest analyze --harness claude-code --session ${sessionId}`\n\n if (raw === null) {\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: null,\n journal: null,\n brainLog: null,\n state: null,\n progress: null,\n workers: null,\n workersMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens: null,\n harnessMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n limits: {\n ...limits,\n managerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n workerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n deliverables: NO_DELIVERABLES,\n },\n traceCommand,\n }\n }\n\n const mainSourceGaps: string[] = []\n const allEntries = parseClaudeEntries(raw, (gap) => mainSourceGaps.push(gap))\n const main = threadCalls(allEntries.filter((e) => !e.isSidechain))\n const mainTranscript = transcriptFromEntries(allEntries, { sourceGaps: mainSourceGaps })\n\n const subagentsDir =\n opts.subagentsDir === undefined\n ? join(dirname(opts.transcriptPath), sessionId, 'subagents')\n : opts.subagentsDir\n const children = subagentsDir === null ? [] : await readChildren(subagentsDir)\n const childByAgentId = new Map(children.map((c) => [c.agentId, c]))\n const childBySpawnToolUseId = new Map(\n children.filter((c) => c.spawnToolUseId !== null).map((c) => [c.spawnToolUseId as string, c]),\n )\n\n // Every thread that can spawn: the session itself, plus each child transcript\n // (a child that calls the spawn tool is a second delegation level).\n const threads: Array<{ id: string; calls: ThreadCalls }> = [{ id: sessionId, calls: main }]\n for (const child of children) {\n threads.push({ id: child.agentId, calls: threadCalls(child.entries) })\n }\n\n const spawns: SpawnFact[] = []\n const steersByTarget = new Map<\n string,\n Array<{ requestId: string; at: string | null; delivered: boolean }>\n >()\n const cancels: Array<{ agentId: string; at: string | null }> = []\n const settles: TaskNotification[] = []\n\n for (const thread of threads) {\n for (const use of thread.calls.uses) {\n if (spawnTools.has(use.name)) {\n const result = thread.calls.results.get(use.id)\n const agentId = spawnedAgentId(result) ?? childBySpawnToolUseId.get(use.id)?.agentId ?? null\n if (agentId === null) continue\n const label =\n str(use.input.description) ?? childByAgentId.get(agentId)?.description ?? agentId\n spawns.push({\n agentId,\n parentId: thread.id,\n label,\n // The spawn is complete when the launch call is answered; the tool_use\n // instant is the fallback for a call that never got a result line.\n at: result?.at ?? use.at,\n model: isRecord(result?.structured) ? str(result.structured.resolvedModel) : null,\n })\n continue\n }\n if (steerTools.has(use.name)) {\n const target = str(use.input.to) ?? str(use.input.recipient)\n if (target === null) continue\n const result = thread.calls.results.get(use.id)\n const structured = isRecord(result?.structured) ? result.structured : null\n // `success` is the harness confirming the message reached a live agent;\n // absent, the steer is counted queued but not delivered.\n const delivered = structured?.success === true || str(structured?.resumedAgentId) === target\n const rows = steersByTarget.get(target) ?? []\n rows.push({ requestId: use.id, at: use.at, delivered })\n steersByTarget.set(target, rows)\n continue\n }\n if (cancelTools.has(use.name)) {\n const target = str(use.input.agentId) ?? str(use.input.to) ?? str(use.input.taskId)\n if (target !== null) cancels.push({ agentId: target, at: use.at })\n }\n }\n settles.push(...thread.calls.notifications)\n }\n\n const spawnedIds = new Set(spawns.map((s) => s.agentId))\n const cancelledIds = new Set(\n cancels.filter((c) => spawnedIds.has(c.agentId)).map((c) => c.agentId),\n )\n const startedAt = main.firstAt\n const completedAt = main.lastAt\n\n const journalLines: string[] = [\n line({\n kind: 'spawned',\n id: sessionId,\n parent: null,\n label: `session:${sessionId}`,\n role: 'supervisor',\n at: startedAt,\n }),\n ]\n for (const s of spawns) {\n journalLines.push(\n line({\n kind: 'spawned',\n id: s.agentId,\n parent: s.parentId,\n label: s.label,\n role: 'worker',\n at: s.at,\n }),\n )\n }\n\n // Only the LAST notification per agent is its settle; an earlier one is a stop\n // the supervisor resumed from, which the steer count already records.\n const lastNotification = new Map<string, TaskNotification>()\n for (const n of settles) {\n if (!spawnedIds.has(n.taskId)) continue\n lastNotification.set(n.taskId, n)\n }\n for (const [agentId, n] of lastNotification) {\n if (cancelledIds.has(agentId)) continue\n journalLines.push(\n line({\n kind: 'settled',\n id: agentId,\n status: n.status,\n verdict: n.summary,\n at: n.at,\n // No `spent` key: Claude Code prices nothing, and a zeroed spend object\n // would read as a $0 worker. `limits.spendUsd` carries the reason.\n }),\n )\n }\n // One cancel per agent: Claude Code can emit a stop then a retry-stop for the\n // same agentId, and each raw entry would otherwise mint a duplicate `cancelled`\n // line that double-counts in `workersCancelled`. Keep the last, mirroring the\n // last-notification dedup the settle path already does.\n const lastCancel = new Map<string, { agentId: string; at: string | null }>()\n for (const c of cancels) {\n if (!spawnedIds.has(c.agentId)) continue\n lastCancel.set(c.agentId, c)\n }\n for (const c of lastCancel.values()) {\n journalLines.push(\n line({ kind: 'cancelled', id: c.agentId, reason: 'stopped by supervisor', at: c.at }),\n )\n }\n // `metered` carries the brain's own inference. The token counts are real; the\n // usd stays absent and `limits.spendUsd` explains why.\n if (\n mainTranscript.gaps.length === 0 &&\n mainTranscript.usage.tokensIn !== null &&\n mainTranscript.usage.tokensOut !== null &&\n mainTranscript.usage.cacheRead !== null &&\n mainTranscript.usage.cacheWrite !== null\n ) {\n journalLines.push(\n line({\n kind: 'metered',\n id: sessionId,\n spend: {\n tokens: {\n input: mainTranscript.usage.tokensIn,\n output: mainTranscript.usage.tokensOut,\n cacheRead: mainTranscript.usage.cacheRead,\n cacheWrite: mainTranscript.usage.cacheWrite,\n },\n },\n at: completedAt,\n }),\n )\n }\n\n const settleAtByAgent = new Map(\n [...lastNotification.entries()].map(([id, n]) => [id, n.at] as const),\n )\n const spawnAtByAgent = new Map(spawns.map((s) => [s.agentId, s.at] as const))\n\n const workers: WorkerLogSource[] = []\n for (const spawn of spawns) {\n const { agentId, label } = spawn\n const events: string[] = []\n const inbox: string[] = []\n const child = childByAgentId.get(agentId) ?? null\n const startAt = child?.firstAt ?? spawnAtByAgent.get(agentId) ?? null\n const endAt = settleAtByAgent.get(agentId) ?? child?.lastAt ?? null\n if (startAt !== null) events.push(line({ kind: 'started', label, at: startAt, agentId }))\n for (const steer of steersByTarget.get(agentId) ?? []) {\n inbox.push(line({ id: steer.requestId, at: steer.at, worker: label, message: 'steer' }))\n events.push(\n line({\n kind: 'message',\n label,\n direction: 'down',\n at: steer.at,\n requestId: steer.requestId,\n delivered: steer.delivered,\n }),\n )\n }\n if (endAt !== null) {\n events.push(\n line({\n kind: 'finished',\n label,\n at: endAt,\n agentId,\n // No `passed` / `patchBytes`: this harness has neither. Emitting\n // `passed: false` here would invent a failed worker.\n // `evidence` is the child's closing message — what it handed back.\n ...(child?.finalReport === null || child?.finalReport === undefined\n ? {}\n : { evidence: child.finalReport }),\n }),\n )\n }\n workers.push({\n workerId: agentId,\n label,\n events: events.length === 0 ? '' : `${events.join('\\n')}\\n`,\n inbox: inbox.length === 0 ? '' : `${inbox.join('\\n')}\\n`,\n patchBytes: null,\n transcriptRef: child?.path ?? null,\n patchPath: null,\n tokensIn: child?.tokensIn ?? null,\n tokensOut: child?.tokensOut ?? null,\n cacheRead: child?.cacheRead ?? null,\n cacheWrite: child?.cacheWrite ?? null,\n })\n }\n\n const joined = children.length\n const missingChildren = spawns.filter((spawn) => !childByAgentId.has(spawn.agentId)).length\n const incompleteChildren = children.filter(\n (child) =>\n child.gaps.length > 0 ||\n child.tokensIn === null ||\n child.tokensOut === null ||\n child.cacheRead === null ||\n child.cacheWrite === null,\n ).length\n const harnessMissingReason =\n subagentsDir === null\n ? 'subagent transcript join disabled'\n : joined === 0\n ? `no subagent transcripts under ${subagentsDir}`\n : missingChildren > 0\n ? `${missingChildren}/${spawns.length} spawned agents have no retained transcript under ${subagentsDir}`\n : incompleteChildren > 0\n ? `${incompleteChildren}/${joined} subagent transcripts have malformed lines or unknown usage`\n : null\n const harnessWorkerTokens =\n joined === 0 || incompleteChildren > 0\n ? null\n : {\n store: 'claude-code subagent transcripts',\n sessions: joined,\n input: children.reduce((a, child) => a + (child.tokensIn ?? 0), 0),\n output: children.reduce((a, child) => a + (child.tokensOut ?? 0), 0),\n cacheRead: children.reduce((a, child) => a + (child.cacheRead ?? 0), 0),\n cacheWrite: children.reduce((a, child) => a + (child.cacheWrite ?? 0), 0),\n }\n\n const liveWorkers = spawns.filter(\n (s) => !lastNotification.has(s.agentId) && !cancelledIds.has(s.agentId),\n ).length\n const state = JSON.stringify({\n id: sessionId,\n // Derived, not asserted: a spawned agent with no notification and no stop\n // is still running, which is exactly what a live transcript looks like.\n status: liveWorkers > 0 ? 'running' : 'idle',\n startedAt,\n completedAt,\n result: { delivered: null },\n })\n\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: subagentsDir,\n journal: `${journalLines.join('\\n')}\\n`,\n brainLog: null,\n state,\n progress: null,\n workers,\n workersMissingReason: null,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens,\n harnessMissingReason,\n limits: {\n ...limits,\n managerTokens:\n mainTranscript.gaps.length > 0\n ? `main transcript has ${mainTranscript.gaps.length} parse or usage gaps`\n : null,\n workerTokens: spawns.length === 0 ? null : harnessMissingReason,\n deliverables: NO_DELIVERABLES,\n },\n rootTranscriptRef: opts.transcriptPath,\n traceCommand,\n }\n}\n\n/** A `SupervisorRunReader` over a Claude Code session — the same contract Runtime implements. */\nexport function claudeCodeSupervisorRunReader(opts: ClaudeCodeReaderOptions): SupervisorRunReader {\n return {\n runRef: opts.runRef ?? opts.transcriptPath,\n read: () => readClaudeCodeSupervisorRun(opts),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,MAAM,sBAAsB,CAAC,SAAS,MAAM;;AAE5C,MAAM,sBAAsB,CAAC,aAAa;;AAE1C,MAAM,uBAAuB,CAAC,YAAY,WAAW;AAErD,MAAM,iBACJ;AACF,MAAM,cACJ;AACF,MAAM,kBACJ;AAkBF,MAAM,YAAY,MAChB,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAEzD,MAAM,OAAO,MAA+B,OAAO,MAAM,WAAW,IAAI;AAiCxE,SAAS,UAAU,SAA0B;CAC3C,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG,OAAO;CACpC,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,SACd,IAAI,SAAS,CAAC,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS,UAAU,MAAM,KAAK,EAAE,IAAI;CAEvF,OAAO,MAAM,KAAK,IAAI;AACxB;AAEA,MAAM,OAAO,KAAa,SAAgC;CACxD,MAAM,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,KAAK,iBAAiB,KAAK,EAAE,CAAC;CACjE,OAAO,MAAM,OAAO,OAAQ,EAAE;AAChC;;;;;;;AAQA,SAAS,mBAAmB,MAAc,IAAuC;CAC/E,MAAM,MAA0B,CAAC;CACjC,KAAK,MAAM,KAAK,KAAK,SAAS,mDAAmD,GAAG;EAClF,MAAM,MAAM,EAAE;EACd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AAI,CAAC;EACnE,WAAW,SAAS,QAAQ,GAAG,UAAU,KAAK,MAAM,aAAa,IAAI,CAAC;EACtE,YAAY,SAAS,QAAQ,GAAG,UAAU,KAAK,MAAM,cAAc,IAAI,CAAC;CAC1E;CAEN,MAAM,cAAc,OAAO,QACxB,MAAM,CAAC,iBAAiB,IAAI,EAAE,OAAO,KAAK,CAAC,aAAa,IAAI,EAAE,OAAO,CACxE,CAAC,CAAC;CACF,MAAM,QAAQ,KAAK,UAAU;EAC3B,IAAI;EAGJ,QAAQ,cAAc,IAAI,YAAY;EACtC;EACA;EACA,QAAQ,EAAE,WAAW,KAAK;CAC5B,CAAC;CAED,OAAO;EACL;EACA,YAAY,KAAK,cAAc;EAC/B,KAAK,KAAK,OAAO;EACjB,WAAW;EACX,SAAS,GAAG,aAAa,KAAK,IAAI,EAAE;EACpC,UAAU;EACV;EACA,UAAU;EACV;EACA,sBAAsB;EACtB,QAAQ;EACR,OAAO;EACP,aAAa;EACb,OAAO;EACP,WAAW;EACX;EACA;EACA,QAAQ;GACN,GAAG;GACH,eACE,eAAe,KAAK,SAAS,IACzB,uBAAuB,eAAe,KAAK,OAAO,wBAClD;GACN,cAAc,OAAO,WAAW,IAAI,OAAO;GAC3C,cAAc;EAChB;EACA,mBAAmB,KAAK;EACxB;CACF;AACF;;AAGA,SAAgB,8BAA8B,MAAoD;CAChG,OAAO;EACL,QAAQ,KAAK,UAAU,KAAK;EAC5B,YAAY,4BAA4B,IAAI;CAC9C;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/supervisor-run/claude-code-reader.ts"],"sourcesContent":["/**\n * Supervision-tree reader over a THIRD-PARTY harness: Claude Code.\n *\n * The Runtime reader reads a supervisor journal designed for this analysis.\n * for this analysis. This reader reads a harness we do not control, whose\n * transcript was designed for replaying a chat — and recovers the same tree\n * from it. If both produce a `SupervisorRunSources`, the tree model is a\n * property of multi-agent runs, not of our journal format.\n *\n * ## Where the tree hides in a Claude Code transcript\n *\n * | Tree fact | Claude Code evidence |\n * |---|---|\n * | spawn | assistant `tool_use` (`Agent` / `Task`), answered by a `tool_result` whose `toolUseResult.agentId` names the child |\n * | settle | a `<task-notification>` block in a later user line: `<task-id>` = agentId, `<status>` |\n * | steer | assistant `tool_use` (`SendMessage`) with `input.to` = agentId — mid-task, to a LIVE child |\n * | delivered | that steer's `tool_result` carrying `success` / `resumedAgentId` |\n * | cancel | assistant `tool_use` (`TaskStop`) targeting an agentId |\n * | brain spend| `message.usage` on the main thread's assistant lines |\n * | worker spend| `message.usage` inside `<session>/subagents/agent-<id>.jsonl` |\n * | depth | a child transcript that itself contains `Agent` tool_use lines |\n *\n * Every one of those is read from the normalized session of @tangle-network/harness-sessions — the SAME\n * parser `src/rollout/readers/claude-jsonl.ts` uses for solo rollouts. There\n * is no second transcript parser.\n *\n * ## What Claude Code cannot say\n *\n * It records tokens but never a price, runs no per-worker verify, and keeps no\n * per-worker patch. Those are declared once in `limits`, so the analyzer\n * reports `unavailable — <reason>` instead of the $0 / 0-accepted that summing\n * an empty field would produce. See `SourceLimits`.\n *\n * ## Metric coverage vs the Runtime journal\n *\n * Measured on a real 52-agent session (fixture:\n * `tests/fixtures/supervisor-run/claude-code-session-*`).\n *\n * | Metric | Runtime | Claude Code | Why |\n * |---|---|---|---|\n * | workersSpawned / Settled / Cancelled | full | full | spawn tool_use + task-notification + TaskStop |\n * | steers / steersDelivered / steersByWorker | full | full | `SendMessage`; delivery from its tool_result |\n * | waves / waveSizes / maxConcurrency | full | full | derived from spawn/settle instants |\n * | respawns / repeatedLabels | full | full | same derivation |\n * | delegationDepth | full | full | a child transcript's own spawn calls |\n * | timeToFirstSpawn / supervisorWall | full | full | transcript instants |\n * | idleMs / idlePct / workerUtilization | full | PARTIAL | an agent that never notifies is counted live to the end of the transcript |\n * | observeThenRespawn / respawnWithoutEvidence | full | full | ordering of spawn vs settle instants |\n * | workerEvidenceBytes | full | PARTIAL | the child's closing message; 0 for pruned transcripts |\n * | brain tokens in/out + cache | full | full | main-thread `message.usage` |\n * | worker tokens in/out + cache | via harness join | full or unavailable | totals are refused if any spawned transcript was pruned; retained per-worker rows remain available |\n * | perWorker wall | full | full | spawn → settle instants |\n * | accepted / rejected / emptyPass / settledVerdicts | full | NONE | no per-worker verify step exists |\n * | brain/worker/total usd, costPerAcceptedPatch | full | NONE | transcripts carry no price |\n * | patch stats, delivered, verifyPass/Rc | full | NONE | no diff is handed back |\n * | judgeResolved / Score / Passed / Total | full | NONE | no judge in the loop |\n * | driverSteerCalls, brainTruncations | full | NONE | no outer driver log, no per-call finish_reason tap |\n */\n\nimport { readdir, readFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\nimport {\n claudeCodeReader,\n claudeCodeRefForFile,\n type HarnessSession,\n} from '@tangle-network/harness-sessions'\nimport { type ClaudeTranscript, transcriptFromSession } from '../rollout/readers/claude-jsonl'\nimport type { SupervisorRunReader, SupervisorRunSources, WorkerLogSource } from './types'\n\n/** Tool names that spawn a child agent. `Task` is the older name for `Agent`. */\nconst DEFAULT_SPAWN_TOOLS = ['Agent', 'Task'] as const\n/** Tool names that deliver a message to an ALREADY-RUNNING child agent. */\nconst DEFAULT_STEER_TOOLS = ['SendMessage'] as const\n/** Tool names that stop a running child agent. */\nconst DEFAULT_CANCEL_TOOLS = ['TaskStop', 'KillAgent'] as const\n\nconst SPEND_UNPRICED =\n 'Claude Code transcripts record token usage but never a price — usd is not in the store'\nconst NO_VERDICTS =\n 'Claude Code runs no per-worker verify step — a subagent reports prose, not pass/fail'\nconst NO_DELIVERABLES =\n 'Claude Code retains no per-worker patch — subagents commit to git, they do not hand back a diff'\n\nexport interface ClaudeCodeReaderOptions {\n /** The main session transcript: `~/.claude/projects/<slug>/<sessionId>.jsonl`. */\n readonly transcriptPath: string\n /**\n * Directory of child transcripts. Defaults to `<transcript-dir>/<sessionId>/subagents`.\n * `null` skips the join, and every per-worker token count becomes unavailable.\n */\n readonly subagentsDir?: string | null\n readonly runRef?: string\n readonly instanceId?: string | null\n readonly arm?: string | null\n readonly spawnTools?: readonly string[]\n readonly steerTools?: readonly string[]\n readonly cancelTools?: readonly string[]\n}\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\nconst str = (v: unknown): string | null => (typeof v === 'string' ? v : null)\n\ninterface ToolUse {\n readonly id: string\n readonly name: string\n readonly input: Record<string, unknown>\n readonly at: string | null\n}\n\ninterface ToolResult {\n readonly id: string\n readonly at: string | null\n readonly structured: unknown\n readonly text: string\n}\n\n/** Every tool call and tool result on one thread, in order, with instants. */\ninterface ThreadCalls {\n readonly uses: ToolUse[]\n readonly results: Map<string, ToolResult>\n readonly notifications: TaskNotification[]\n readonly firstAt: string | null\n readonly lastAt: string | null\n}\n\ninterface TaskNotification {\n readonly taskId: string\n readonly toolUseId: string | null\n readonly status: string\n readonly summary: string | null\n readonly at: string | null\n}\n\nconst tag = (xml: string, name: string): string | null => {\n const m = xml.match(new RegExp(`<${name}>([\\\\s\\\\S]*?)</${name}>`))\n return m === null ? null : (m[1] as string)\n}\n\n/**\n * Task notifications are the settle instants. A notification fires each time an\n * agent stops, so a resumed agent produces several — they are kept in order and\n * the LAST one is the settle the analyzer sees, with the earlier ones acting as\n * the intermediate stops they actually were.\n */\nfunction parseNotifications(text: string, at: string | null): TaskNotification[] {\n const out: TaskNotification[] = []\n for (const m of text.matchAll(/<task-notification>[\\s\\S]*?<\\/task-notification>/g)) {\n const xml = m[0]\n const taskId = tag(xml, 'task-id')\n if (taskId === null) continue\n out.push({\n taskId: taskId.trim(),\n toolUseId: tag(xml, 'tool-use-id')?.trim() ?? null,\n status: tag(xml, 'status')?.trim() ?? 'unknown',\n summary: tag(xml, 'summary')?.trim() ?? null,\n at,\n })\n }\n return out\n}\n\n/** Project ONE thread's session (main or a single subagent) into tool traffic. */\nfunction threadCalls(session: HarnessSession): ThreadCalls {\n const uses: ToolUse[] = []\n const results = new Map<string, ToolResult>()\n const notifications: TaskNotification[] = []\n for (const call of session.toolCalls) {\n uses.push({\n id: call.id,\n name: call.name,\n input: isRecord(call.input) ? call.input : {},\n at: call.startedAt,\n })\n if (call.result !== null) {\n results.set(call.id, {\n id: call.id,\n at: call.result.at,\n structured: call.result.details,\n text: call.result.text ?? '',\n })\n }\n }\n for (const message of session.messages) {\n if (message.role !== 'user') continue\n for (const part of message.parts) {\n if (part.type === 'text') notifications.push(...parseNotifications(part.text, message.at))\n }\n }\n return { uses, results, notifications, firstAt: session.startedAt, lastAt: session.endedAt }\n}\n\n/**\n * The agent id a spawn produced. Claude Code puts it in the structured\n * `toolUseResult`; the same id is echoed in the result text for transcripts\n * written before that field existed, so both are tried before giving up.\n */\nfunction spawnedAgentId(result: ToolResult | undefined): string | null {\n if (result === undefined) return null\n if (isRecord(result.structured)) {\n const id = str(result.structured.agentId)\n if (id !== null) return id\n }\n return result.text.match(/agentId:\\s*([A-Za-z0-9_-]+)/)?.[1] ?? null\n}\n\ninterface ChildTranscript {\n readonly agentId: string\n readonly path: string\n readonly description: string | null\n readonly spawnToolUseId: string | null\n readonly spawnDepth: number | null\n readonly session: HarnessSession\n readonly tokensIn: number | null\n readonly tokensOut: number | null\n readonly cacheRead: number | null\n readonly cacheWrite: number | null\n readonly gaps: readonly string[]\n readonly firstAt: string | null\n readonly lastAt: string | null\n readonly model: string | null\n /**\n * The child's closing assistant message — what it actually handed back. This\n * is the Claude Code analogue of a worker's `evidence` blob.\n */\n readonly finalReport: string | null\n}\n\nasync function readChildren(dir: string): Promise<ChildTranscript[]> {\n const names = await readdir(dir).catch(() => null)\n if (names === null) return []\n const out: ChildTranscript[] = []\n for (const name of names.filter((n) => n.endsWith('.jsonl')).sort()) {\n const path = join(dir, name)\n // A subagent transcript is sidechain end to end: read it as the subagent's own session.\n const session = await claudeCodeReader\n .read(claudeCodeRefForFile(path, 'parent'))\n .catch(() => null)\n if (session === null) continue\n const projected: ClaudeTranscript = transcriptFromSession(session)\n const metaRaw = await readFile(path.replace(/\\.jsonl$/, '.meta.json'), 'utf8').catch(() => null)\n let meta: Record<string, unknown> = {}\n if (metaRaw !== null) {\n try {\n const parsed: unknown = JSON.parse(metaRaw)\n if (isRecord(parsed)) meta = parsed\n } catch {\n meta = {}\n }\n }\n // The records name the agent; the file name is the fallback for a transcript that does not.\n const agentId = session.nativeSessionId\n out.push({\n agentId,\n path,\n description: str(meta.description),\n spawnToolUseId: str(meta.toolUseId),\n spawnDepth: typeof meta.spawnDepth === 'number' ? meta.spawnDepth : null,\n session,\n tokensIn: projected.usage.tokensIn,\n tokensOut: projected.usage.tokensOut,\n cacheRead: projected.usage.cacheRead,\n cacheWrite: projected.usage.cacheWrite,\n gaps: projected.gaps,\n firstAt: projected.startedAt,\n lastAt: projected.endedAt,\n model: projected.model,\n finalReport:\n [...projected.messages]\n .reverse()\n .find((m) => m.role === 'assistant' && typeof m.content === 'string')?.content ?? null,\n })\n }\n return out\n}\n\ninterface SpawnFact {\n readonly agentId: string\n readonly parentId: string\n readonly label: string\n readonly at: string | null\n readonly model: string | null\n}\n\n/** A journal line in the dialect `parseSupervisorTree` reads. */\nconst line = (obj: Record<string, unknown>): string => JSON.stringify(obj)\n\n/**\n * Read a Claude Code session (plus its subagent transcripts) as supervision-tree\n * source bytes. Never throws on a missing artifact.\n */\nexport async function readClaudeCodeSupervisorRun(\n opts: ClaudeCodeReaderOptions,\n): Promise<SupervisorRunSources> {\n const spawnTools = new Set(opts.spawnTools ?? DEFAULT_SPAWN_TOOLS)\n const steerTools = new Set(opts.steerTools ?? DEFAULT_STEER_TOOLS)\n const cancelTools = new Set(opts.cancelTools ?? DEFAULT_CANCEL_TOOLS)\n\n const mainSession = await claudeCodeReader\n .read(claudeCodeRefForFile(opts.transcriptPath))\n .catch(() => null)\n const sessionId = basename(opts.transcriptPath).replace(/\\.jsonl$/, '')\n const runRef = opts.runRef ?? opts.transcriptPath\n const limits = {\n managerTokens: null,\n workerTokens: null,\n spendUsd: SPEND_UNPRICED,\n workerVerdicts: NO_VERDICTS,\n deliverables: null,\n }\n const traceCommand = `npx --yes @tangle-network/traces@latest analyze --harness claude-code --session ${sessionId}`\n\n if (mainSession === null) {\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: null,\n journal: null,\n brainLog: null,\n state: null,\n progress: null,\n workers: null,\n workersMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens: null,\n harnessMissingReason: `session transcript unreadable at ${opts.transcriptPath}`,\n limits: {\n ...limits,\n managerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n workerTokens: `session transcript unreadable at ${opts.transcriptPath}`,\n deliverables: NO_DELIVERABLES,\n },\n traceCommand,\n }\n }\n\n const main = threadCalls(mainSession)\n const mainTranscript = transcriptFromSession(mainSession)\n\n const subagentsDir =\n opts.subagentsDir === undefined\n ? join(dirname(opts.transcriptPath), sessionId, 'subagents')\n : opts.subagentsDir\n const children = subagentsDir === null ? [] : await readChildren(subagentsDir)\n const childByAgentId = new Map(children.map((c) => [c.agentId, c]))\n const childBySpawnToolUseId = new Map(\n children.filter((c) => c.spawnToolUseId !== null).map((c) => [c.spawnToolUseId as string, c]),\n )\n\n // Every thread that can spawn: the session itself, plus each child transcript\n // (a child that calls the spawn tool is a second delegation level).\n const threads: Array<{ id: string; calls: ThreadCalls }> = [{ id: sessionId, calls: main }]\n for (const child of children) {\n threads.push({ id: child.agentId, calls: threadCalls(child.session) })\n }\n\n const spawns: SpawnFact[] = []\n const steersByTarget = new Map<\n string,\n Array<{ requestId: string; at: string | null; delivered: boolean }>\n >()\n const cancels: Array<{ agentId: string; at: string | null }> = []\n const settles: TaskNotification[] = []\n\n for (const thread of threads) {\n for (const use of thread.calls.uses) {\n if (spawnTools.has(use.name)) {\n const result = thread.calls.results.get(use.id)\n const agentId = spawnedAgentId(result) ?? childBySpawnToolUseId.get(use.id)?.agentId ?? null\n if (agentId === null) continue\n const label =\n str(use.input.description) ?? childByAgentId.get(agentId)?.description ?? agentId\n spawns.push({\n agentId,\n parentId: thread.id,\n label,\n // The spawn is complete when the launch call is answered; the tool_use\n // instant is the fallback for a call that never got a result line.\n at: result?.at ?? use.at,\n model: isRecord(result?.structured) ? str(result.structured.resolvedModel) : null,\n })\n continue\n }\n if (steerTools.has(use.name)) {\n const target = str(use.input.to) ?? str(use.input.recipient)\n if (target === null) continue\n const result = thread.calls.results.get(use.id)\n const structured = isRecord(result?.structured) ? result.structured : null\n // `success` is the harness confirming the message reached a live agent;\n // absent, the steer is counted queued but not delivered.\n const delivered = structured?.success === true || str(structured?.resumedAgentId) === target\n const rows = steersByTarget.get(target) ?? []\n rows.push({ requestId: use.id, at: use.at, delivered })\n steersByTarget.set(target, rows)\n continue\n }\n if (cancelTools.has(use.name)) {\n const target = str(use.input.agentId) ?? str(use.input.to) ?? str(use.input.taskId)\n if (target !== null) cancels.push({ agentId: target, at: use.at })\n }\n }\n settles.push(...thread.calls.notifications)\n }\n\n const spawnedIds = new Set(spawns.map((s) => s.agentId))\n const cancelledIds = new Set(\n cancels.filter((c) => spawnedIds.has(c.agentId)).map((c) => c.agentId),\n )\n const startedAt = main.firstAt\n const completedAt = main.lastAt\n\n const journalLines: string[] = [\n line({\n kind: 'spawned',\n id: sessionId,\n parent: null,\n label: `session:${sessionId}`,\n role: 'supervisor',\n at: startedAt,\n }),\n ]\n for (const s of spawns) {\n journalLines.push(\n line({\n kind: 'spawned',\n id: s.agentId,\n parent: s.parentId,\n label: s.label,\n role: 'worker',\n at: s.at,\n }),\n )\n }\n\n // Only the LAST notification per agent is its settle; an earlier one is a stop\n // the supervisor resumed from, which the steer count already records.\n const lastNotification = new Map<string, TaskNotification>()\n for (const n of settles) {\n if (!spawnedIds.has(n.taskId)) continue\n lastNotification.set(n.taskId, n)\n }\n for (const [agentId, n] of lastNotification) {\n if (cancelledIds.has(agentId)) continue\n journalLines.push(\n line({\n kind: 'settled',\n id: agentId,\n status: n.status,\n verdict: n.summary,\n at: n.at,\n // No `spent` key: Claude Code prices nothing, and a zeroed spend object\n // would read as a $0 worker. `limits.spendUsd` carries the reason.\n }),\n )\n }\n // One cancel per agent: Claude Code can emit a stop then a retry-stop for the\n // same agentId, and each raw entry would otherwise mint a duplicate `cancelled`\n // line that double-counts in `workersCancelled`. Keep the last, mirroring the\n // last-notification dedup the settle path already does.\n const lastCancel = new Map<string, { agentId: string; at: string | null }>()\n for (const c of cancels) {\n if (!spawnedIds.has(c.agentId)) continue\n lastCancel.set(c.agentId, c)\n }\n for (const c of lastCancel.values()) {\n journalLines.push(\n line({ kind: 'cancelled', id: c.agentId, reason: 'stopped by supervisor', at: c.at }),\n )\n }\n // `metered` carries the brain's own inference. The token counts are real; the\n // usd stays absent and `limits.spendUsd` explains why.\n if (\n mainTranscript.gaps.length === 0 &&\n mainTranscript.usage.tokensIn !== null &&\n mainTranscript.usage.tokensOut !== null &&\n mainTranscript.usage.cacheRead !== null &&\n mainTranscript.usage.cacheWrite !== null\n ) {\n journalLines.push(\n line({\n kind: 'metered',\n id: sessionId,\n spend: {\n tokens: {\n input: mainTranscript.usage.tokensIn,\n output: mainTranscript.usage.tokensOut,\n cacheRead: mainTranscript.usage.cacheRead,\n cacheWrite: mainTranscript.usage.cacheWrite,\n },\n },\n at: completedAt,\n }),\n )\n }\n\n const settleAtByAgent = new Map(\n [...lastNotification.entries()].map(([id, n]) => [id, n.at] as const),\n )\n const spawnAtByAgent = new Map(spawns.map((s) => [s.agentId, s.at] as const))\n\n const workers: WorkerLogSource[] = []\n for (const spawn of spawns) {\n const { agentId, label } = spawn\n const events: string[] = []\n const inbox: string[] = []\n const child = childByAgentId.get(agentId) ?? null\n const startAt = child?.firstAt ?? spawnAtByAgent.get(agentId) ?? null\n const endAt = settleAtByAgent.get(agentId) ?? child?.lastAt ?? null\n if (startAt !== null) events.push(line({ kind: 'started', label, at: startAt, agentId }))\n for (const steer of steersByTarget.get(agentId) ?? []) {\n inbox.push(line({ id: steer.requestId, at: steer.at, worker: label, message: 'steer' }))\n events.push(\n line({\n kind: 'message',\n label,\n direction: 'down',\n at: steer.at,\n requestId: steer.requestId,\n delivered: steer.delivered,\n }),\n )\n }\n if (endAt !== null) {\n events.push(\n line({\n kind: 'finished',\n label,\n at: endAt,\n agentId,\n // No `passed` / `patchBytes`: this harness has neither. Emitting\n // `passed: false` here would invent a failed worker.\n // `evidence` is the child's closing message — what it handed back.\n ...(child?.finalReport === null || child?.finalReport === undefined\n ? {}\n : { evidence: child.finalReport }),\n }),\n )\n }\n workers.push({\n workerId: agentId,\n label,\n events: events.length === 0 ? '' : `${events.join('\\n')}\\n`,\n inbox: inbox.length === 0 ? '' : `${inbox.join('\\n')}\\n`,\n patchBytes: null,\n transcriptRef: child?.path ?? null,\n patchPath: null,\n tokensIn: child?.tokensIn ?? null,\n tokensOut: child?.tokensOut ?? null,\n cacheRead: child?.cacheRead ?? null,\n cacheWrite: child?.cacheWrite ?? null,\n })\n }\n\n const joined = children.length\n const missingChildren = spawns.filter((spawn) => !childByAgentId.has(spawn.agentId)).length\n const incompleteChildren = children.filter(\n (child) =>\n child.gaps.length > 0 ||\n child.tokensIn === null ||\n child.tokensOut === null ||\n child.cacheRead === null ||\n child.cacheWrite === null,\n ).length\n const harnessMissingReason =\n subagentsDir === null\n ? 'subagent transcript join disabled'\n : joined === 0\n ? `no subagent transcripts under ${subagentsDir}`\n : missingChildren > 0\n ? `${missingChildren}/${spawns.length} spawned agents have no retained transcript under ${subagentsDir}`\n : incompleteChildren > 0\n ? `${incompleteChildren}/${joined} subagent transcripts have malformed lines or unknown usage`\n : null\n const harnessWorkerTokens =\n joined === 0 || incompleteChildren > 0\n ? null\n : {\n store: 'claude-code subagent transcripts',\n sessions: joined,\n input: children.reduce((a, child) => a + (child.tokensIn ?? 0), 0),\n output: children.reduce((a, child) => a + (child.tokensOut ?? 0), 0),\n cacheRead: children.reduce((a, child) => a + (child.cacheRead ?? 0), 0),\n cacheWrite: children.reduce((a, child) => a + (child.cacheWrite ?? 0), 0),\n }\n\n const liveWorkers = spawns.filter(\n (s) => !lastNotification.has(s.agentId) && !cancelledIds.has(s.agentId),\n ).length\n const state = JSON.stringify({\n id: sessionId,\n // Derived, not asserted: a spawned agent with no notification and no stop\n // is still running, which is exactly what a live transcript looks like.\n status: liveWorkers > 0 ? 'running' : 'idle',\n startedAt,\n completedAt,\n result: { delivered: null },\n })\n\n return {\n runRef,\n instanceId: opts.instanceId ?? sessionId,\n arm: opts.arm ?? null,\n supRunDir: subagentsDir,\n journal: `${journalLines.join('\\n')}\\n`,\n brainLog: null,\n state,\n progress: null,\n workers,\n workersMissingReason: null,\n result: null,\n judge: null,\n judgeSource: null,\n patch: null,\n driverLog: null,\n harnessWorkerTokens,\n harnessMissingReason,\n limits: {\n ...limits,\n managerTokens:\n mainTranscript.gaps.length > 0\n ? `main transcript has ${mainTranscript.gaps.length} parse or usage gaps`\n : null,\n workerTokens: spawns.length === 0 ? null : harnessMissingReason,\n deliverables: NO_DELIVERABLES,\n },\n rootTranscriptRef: opts.transcriptPath,\n traceCommand,\n }\n}\n\n/** A `SupervisorRunReader` over a Claude Code session — the same contract Runtime implements. */\nexport function claudeCodeSupervisorRunReader(opts: ClaudeCodeReaderOptions): SupervisorRunReader {\n return {\n runRef: opts.runRef ?? opts.transcriptPath,\n read: () => readClaudeCodeSupervisorRun(opts),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA,MAAM,sBAAsB,CAAC,SAAS,MAAM;;AAE5C,MAAM,sBAAsB,CAAC,aAAa;;AAE1C,MAAM,uBAAuB,CAAC,YAAY,WAAW;AAErD,MAAM,iBACJ;AACF,MAAM,cACJ;AACF,MAAM,kBACJ;AAkBF,MAAM,YAAY,MAChB,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,MAAM,QAAQ,CAAC;AAEzD,MAAM,OAAO,MAA+B,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U;EACV;EACA,sBAAsB;EACtB,QAAQ;EACR,OAAO;EACP,aAAa;EACb,OAAO;EACP,WAAW;EACX;EACA;EACA,QAAQ;GACN,GAAG;GACH,eACE,eAAe,KAAK,SAAS,IACzB,uBAAuB,eAAe,KAAK,OAAO,wBAClD;GACN,cAAc,OAAO,WAAW,IAAI,OAAO;GAC3C,cAAc;EAChB;EACA,mBAAmB,KAAK;EACxB;CACF;AACF;;AAGA,SAAgB,8BAA8B,MAAoD;CAChG,OAAO;EACL,QAAQ,KAAK,UAAU,KAAK;EAC5B,YAAY,4BAA4B,IAAI;CAC9C;AACF"}
|
|
@@ -3,8 +3,8 @@ import { a as medianInPlace, s as zQuantile } from "./internal-CRHwS9iz.js";
|
|
|
3
3
|
import { t as mulberry32 } from "./random-Dn5fPWkt.js";
|
|
4
4
|
import { r as holm } from "./multiplicity-D9cjmStq.js";
|
|
5
5
|
import { a as pairedSignTest, n as DECISION_PAIRED_DELTA_STATISTIC } from "./paired-tests-jbwPdSz5.js";
|
|
6
|
-
import { i as pairedDeltaTest, r as minimumPairsForPairedDeltaTest } from "./paired-promotion-decision-
|
|
7
|
-
import { E as seedFromDigest, O as paretoFrontier, T as searchPosterior, _ as INSUFFICIENT_FROM, a as searchPolicyView, d as verifySearchClaim, v as rankingSplit, w as searchEstimateMethod, x as estimateNode, y as summarizeSamples } from "./search-kernel-
|
|
6
|
+
import { i as pairedDeltaTest, r as minimumPairsForPairedDeltaTest } from "./paired-promotion-decision-BN6IQTiu.js";
|
|
7
|
+
import { E as seedFromDigest, O as paretoFrontier, T as searchPosterior, _ as INSUFFICIENT_FROM, a as searchPolicyView, d as verifySearchClaim, v as rankingSplit, w as searchEstimateMethod, x as estimateNode, y as summarizeSamples } from "./search-kernel-BIXWM7YV.js";
|
|
8
8
|
import { f as searchUnitScores } from "./search-ledger-aMTNQn_m.js";
|
|
9
9
|
import { defineInlineResource } from "@tangle-network/agent-interface";
|
|
10
10
|
//#region src/search/lenses/edit-credit.ts
|
|
@@ -4092,4 +4092,4 @@ function tree(state) {
|
|
|
4092
4092
|
//#endregion
|
|
4093
4093
|
export { editCredit as C, front as S, surfaceTextEdits as _, skillCalibration as a, searchPlateau as b, metaSearch as c, renderMetaSearchText as d, searchPolicyGenome as f, lineageEdits as g, lineEditDistance as h, nextUnitExtension as i, metaSearchScore as l, landscape as m, taskMatrix as n, skillManifold as o, formatLandscape as p, formatSkillManifold as r, META_SEARCH_SCORE_SOURCE as s, tree as t, objectiveKey as u, vectorEmbedding as v, editCreditText as w, screenedNodes as x, draftOnPlateau as y };
|
|
4094
4094
|
|
|
4095
|
-
//# sourceMappingURL=tree-
|
|
4095
|
+
//# sourceMappingURL=tree-kc1d80yF.js.map
|