@tangle-network/agent-runtime 0.274.0 → 0.279.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.
Files changed (61) hide show
  1. package/dist/{activation-DiW4KBY-.d.ts → activation-B5NExoOz.d.ts} +137 -105
  2. package/dist/{activation-t5vg1Zyu.js → activation-BkUdrvqh.js} +2 -2
  3. package/dist/{activation-t5vg1Zyu.js.map → activation-BkUdrvqh.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-B2GTcMvx.js → coordination-driver-BBL_OgRw.js} +95 -28
  7. package/dist/coordination-driver-BBL_OgRw.js.map +1 -0
  8. package/dist/{delegate-Bmt7uynp.js → delegate-CZc7B-Tl.js} +2 -2
  9. package/dist/{delegate-Bmt7uynp.js.map → delegate-CZc7B-Tl.js.map} +1 -1
  10. package/dist/durable.d.ts +2 -2
  11. package/dist/durable.js +2 -2
  12. package/dist/{graph-9khZscYU.js → graph-Ci8Ufs_f.js} +4 -4
  13. package/dist/{graph-9khZscYU.js.map → graph-Ci8Ufs_f.js.map} +1 -1
  14. package/dist/{improvement-cycle-oQFOTgLd.js → improvement-cycle-Bi43xCVa.js} +649 -213
  15. package/dist/improvement-cycle-Bi43xCVa.js.map +1 -0
  16. package/dist/{index-CjLtO4B3.d.ts → index-Dm8SHDGW.d.ts} +51 -17
  17. package/dist/index.d.ts +9 -9
  18. package/dist/index.js +55 -14
  19. package/dist/index.js.map +1 -1
  20. package/dist/intelligence.d.ts +3 -3
  21. package/dist/intelligence.js +3 -3
  22. package/dist/kernel.d.ts +4 -4
  23. package/dist/kernel.js +8 -8
  24. package/dist/{loop-runner-bin-C-rco77U.js → loop-runner-bin-C9FJshTP.js} +3 -3
  25. package/dist/{loop-runner-bin-C-rco77U.js.map → loop-runner-bin-C9FJshTP.js.map} +1 -1
  26. package/dist/{loop-runner-bin-Ceehl2oB.d.ts → loop-runner-bin-D6khQtoC.d.ts} +3 -3
  27. package/dist/loop-runner-bin.d.ts +1 -1
  28. package/dist/loop-runner-bin.js +1 -1
  29. package/dist/mcp/bin.js +3 -3
  30. package/dist/mcp/index.d.ts +5 -5
  31. package/dist/mcp/index.js +4 -4
  32. package/dist/{openai-tools-D8ZYHReZ.d.ts → openai-tools-H8QPhTVE.d.ts} +2 -2
  33. package/dist/platform.d.ts +91 -1
  34. package/dist/platform.js +162 -6
  35. package/dist/platform.js.map +1 -1
  36. package/dist/profiles.d.ts +2 -2
  37. package/dist/{provision-supervisor-Ds43T8XY.js → provision-supervisor-BvnihiyB.js} +3 -3
  38. package/dist/{provision-supervisor-Ds43T8XY.js.map → provision-supervisor-BvnihiyB.js.map} +1 -1
  39. package/dist/{runtime-CtrgIqQm.js → runtime-DsAHXig2.js} +73 -26
  40. package/dist/runtime-DsAHXig2.js.map +1 -0
  41. package/dist/{server-DnSzxChA.js → server-Dyc1zvug.js} +3 -3
  42. package/dist/{server-DnSzxChA.js.map → server-Dyc1zvug.js.map} +1 -1
  43. package/dist/{stream-agent-turn-C2rtL6P2.d.ts → stream-agent-turn-Bk79CnTw.d.ts} +2 -2
  44. package/dist/{structural-rollout-DN8CVdpp.js → structural-rollout-D-0X6lsU.js} +2 -2
  45. package/dist/{structural-rollout-DN8CVdpp.js.map → structural-rollout-D-0X6lsU.js.map} +1 -1
  46. package/dist/{substrate-DPIUXsZ5.d.ts → substrate-CHQ5GYnU.d.ts} +2 -2
  47. package/dist/{supervise-CFyAWebz.js → supervise-DBQdrp7H.js} +171 -13
  48. package/dist/supervise-DBQdrp7H.js.map +1 -0
  49. package/dist/{supervisor-C50SI_Ww.js → supervisor-DtlPj9me.js} +372 -77
  50. package/dist/supervisor-DtlPj9me.js.map +1 -0
  51. package/dist/testing.d.ts +2 -2
  52. package/dist/testing.js +60 -60
  53. package/dist/tui/index.d.ts +1 -1
  54. package/dist/tui/index.js +1 -1
  55. package/dist/{types-r7Fzum3M.d.ts → types-D56jQad-.d.ts} +92 -66
  56. package/package.json +10 -7
  57. package/dist/coordination-driver-B2GTcMvx.js.map +0 -1
  58. package/dist/improvement-cycle-oQFOTgLd.js.map +0 -1
  59. package/dist/runtime-CtrgIqQm.js.map +0 -1
  60. package/dist/supervise-CFyAWebz.js.map +0 -1
  61. package/dist/supervisor-C50SI_Ww.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Ca as OutputAdapter, Oa as Validator, ea as AgentRunSpec, na as Driver } from "./types-r7Fzum3M.js";
1
+ import { Ca as Validator, Yi as AgentRunSpec, Zi as Driver, va as OutputAdapter } from "./types-D56jQad-.js";
2
2
  import { AgentProfile } from "@tangle-network/agent-interface";
3
3
  //#region src/profiles/coder.d.ts
4
4
  /**
@@ -281,4 +281,4 @@ interface UiFinding {
281
281
  }
282
282
  //#endregion
283
283
  export { CoderTask as _, UiFindingSeverity as a, KnowledgeUpdate as c, ResearchSource as d, ResearchTask as f, researcherProfile as g, multiHarnessResearcherFanout as h, UiFindingScreenshot as i, MultiHarnessResearcherFanoutOptions as l, createResearcherValidator as m, UI_LENSES as n, UiLens as o, ResearcherProfileOptions as p, UiFinding as r, KnowledgeItem as s, UI_FINDING_SEVERITIES as t, ResearchOutput as u, coderTaskToPrompt as v };
284
- //# sourceMappingURL=substrate-DPIUXsZ5.d.ts.map
284
+ //# sourceMappingURL=substrate-CHQ5GYnU.d.ts.map
@@ -1,15 +1,16 @@
1
- import { $ as bindScopeRetainedOwnerProvider, $i as detachedSnapshot, A as driverExecutorFactory, Aa as resourceTelemetry, Ai as readCommittedJsonLines, At as snapshotExecutorConfig, B as recordScopeOwnerMaterialization, Bi as providerAttemptEvidence, C as createContinuationKeeper, Da as withTimeout, Di as isNoEntError, Dn as executorFailure, Dr as persistHarnessTranscript, Ea as unmeteredSpend, Ei as worktreeCliProfileMaterialization, F as beginScopeOwnerAttempt, Fa as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Fn as bridgeStopSignalKey, Gi as runtimeOwnedExecutorProviderEvidence, H as restoreScopeOwnerAcceptedExecution, Hi as runtimeOwnedDriveHarnessProviderEvidence, Hr as generateSpanId, Ii as inheritRuntimeOwnedExecutorAttestation, Ki as runtimeOwnedPendingExecutorMaterialization, Kn as routerBrain, Kr as toOtelAttributes, L as deriveNodeExecutionIdentity, La as teardownExecutor, Ni as attestRuntimeOwnedScopeOwner, Oa as zeroSpend, On as bridgeAdmissionRefusal, Or as readHarnessTranscript, Ot as createExecutor, P as assertRecursiveReservationPolicy, Pn as bridgeRuntimeAttachmentsKey, Pt as createRouterTranscript, Q as bindScopeRetainedOwnerEnvironmentId, R as meterRuntimeOwnedAccounting, Ra as teardownSurfaces, Sa as sleep, Si as renderUnsupported, Tt as captureReusableExecutorConfig, U as scopeOwnerExecutorNodeContext, Ui as runtimeOwnedExecutorExecutionBinding, V as recordScopeOwnerPause, Vi as recordRuntimeOwnedDriveHarnessProviderEvidence, Wi as runtimeOwnedExecutorMaterialization, _ as CheckUnavailableError, _i as promptControlProfileMaterialization, at as scopeRetainedOwnerResourceReader, b as bestComposite, br as linkAbort, c as runTree, cr as registerRetainedExecutorPreparation, et as consumeScopeRetainedOwnerResult, f as runDriverWithRetry, fi as assertProfileMaterialization, gi as profileMaterializationAxes$1, gn as createInbox, h as CONTINUATIONS_DIR, hi as fullProfileMaterialization, i as bestDelivered, in as newUsageTotals, it as scopeRetainedOwnerPriorSpend, j as isDriverSpec, ja as withBudgetResources, k as driverChild, ka as addResourceSpend, ki as prepareJsonlAppend, kn as bridgeModelRouteRefusal, kr as contentAddress, lr as retainedExecutorSeamKey, ma as addSpend, mi as defineProfileMaterializationContract, n as createRootHandle, nt as reconcileScopeRetainedOwnerEnvironment, on as spendFromUsageTotals, ot as scopeRetainedOwnerResult, p as summarizeDriverAttempts, pi as controlProfileMaterialization, qi as runtimeOwnedScopeOwnerRuntime, r as createSupervisor, rn as meterUsageEvent, rt as scopeRetainedOwnerContext, s as runFinalizer, sn as WORKER_TRACE_PROPAGATION, tn as assertValidBudget, tr as resolveAgentEnvironmentProvider, tt as prepareScopeRetainedOwnerTask, u as HarnessTurnFailedError, ur as errMessage, v as admitContinuationPolicy, vi as promptModelProfileMaterialization, vr as RunCancellationReason, wi as unsupportedProfileDimensions, wt as bindReusableExecutorExecutionId, x as checkVerdictOf, xr as runAbortable, z as meterRuntimeOwnedProviderAttempt, zr as createOtelExporter } from "./supervisor-C50SI_Ww.js";
1
+ import { $ as bindScopeRetainedOwnerProvider, $i as detachedSnapshot, $t as parseWorkerToolTraceArtifact, A as driverExecutorFactory, Aa as resourceTelemetry, Ai as readCommittedJsonLines, An as bridgeAdmissionRefusal, Ar as readHarnessTranscript, At as createExecutor, B as recordScopeOwnerMaterialization, Bi as providerAttemptEvidence, Br as createOtelExporter, C as createContinuationKeeper, Cr as runAbortable, Da as withTimeout, Di as isNoEntError, Dt as captureReusableExecutorConfig, Ea as unmeteredSpend, Ei as worktreeCliProfileMaterialization, Et as bindReusableExecutorExecutionId, F as beginScopeOwnerAttempt, Fa as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Gi as runtimeOwnedExecutorProviderEvidence, H as restoreScopeOwnerAcceptedExecution, Hi as runtimeOwnedDriveHarnessProviderEvidence, Hr as generateSpanId, Ii as inheritRuntimeOwnedExecutorAttestation, In as bridgeRuntimeAttachmentsKey, It as createRouterTranscript, Jn as routerBrain, Ki as runtimeOwnedPendingExecutorMaterialization, Kr as toOtelAttributes, L as deriveNodeExecutionIdentity, La as teardownExecutor, Ln as bridgeStopSignalKey, Mt as snapshotExecutorConfig, Ni as attestRuntimeOwnedScopeOwner, Oa as zeroSpend, P as assertRecursiveReservationPolicy, Q as bindScopeRetainedOwnerEnvironmentId, R as meterRuntimeOwnedAccounting, Ra as teardownSurfaces, Sa as sleep, Si as renderUnsupported, Sr as linkAbort, U as scopeOwnerExecutorNodeContext, Ui as runtimeOwnedExecutorExecutionBinding, V as recordScopeOwnerPause, Vi as recordRuntimeOwnedDriveHarnessProviderEvidence, Wi as runtimeOwnedExecutorMaterialization, _ as CheckUnavailableError, _i as promptControlProfileMaterialization, an as meterUsageEvent, at as scopeRetainedOwnerPriorSpend, b as bestComposite, br as RunCancellationReason, c as runTree, cn as spendFromUsageTotals, ct as scopeRetainedOwnerResult, dr as retainedExecutorSeamKey, et as consumeScopeRetainedOwnerResult, f as runDriverWithRetry, fi as assertProfileMaterialization, fr as errMessage, gi as profileMaterializationAxes$1, h as CONTINUATIONS_DIR, hi as fullProfileMaterialization, i as bestDelivered, it as scopeRetainedOwnerContext, j as isDriverSpec, ja as withBudgetResources, jn as bridgeModelRouteRefusal, jr as contentAddress, k as driverChild, ka as addResourceSpend, ki as prepareJsonlAppend, kn as executorFailure, kr as persistHarnessTranscript, ln as WORKER_TRACE_PROPAGATION, ma as addSpend, mi as defineProfileMaterializationContract, n as createRootHandle, nt as prepareScopeRetainedOwnerTask, on as newUsageTotals, ot as scopeRetainedOwnerResourceReader, p as summarizeDriverAttempts, pi as controlProfileMaterialization, qi as runtimeOwnedScopeOwnerRuntime, r as createSupervisor, rn as assertValidBudget, rr as resolveAgentEnvironmentProvider, rt as reconcileScopeRetainedOwnerEnvironment, s as runFinalizer, st as scopeRetainedOwnerRestorePoint, tt as noteScopeRetainedOwnerCoordination, u as HarnessTurnFailedError, ur as registerRetainedExecutorPreparation, v as admitContinuationPolicy, vi as promptModelProfileMaterialization, vn as createInbox, wi as unsupportedProfileDimensions, x as checkVerdictOf, z as meterRuntimeOwnedProviderAttempt } from "./supervisor-DtlPj9me.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
4
4
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
5
5
  import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
6
- import { C as applyRunCancellation, E as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, b as withRunContext, c as createProgressTracker, d as progressStop, j as createCoordinationToolsForManager, k as coordinationVerbNames, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, u as plateau, v as createFileRunContext, w as watchRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-B2GTcMvx.js";
6
+ import { C as applyRunCancellation, E as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, b as withRunContext, c as createProgressTracker, d as progressStop, j as createCoordinationToolsForManager, k as coordinationVerbNames, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, u as plateau, v as createFileRunContext, w as watchRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-BBL_OgRw.js";
7
7
  import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
8
8
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-vwd4SwX_.js";
9
9
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
10
+ import { toolSpansToTraceAnalysisStore } from "@tangle-network/agent-eval";
10
11
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
11
12
  import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
12
- import { resolve } from "node:path";
13
+ import { dirname, resolve } from "node:path";
13
14
  import { mkdir } from "node:fs/promises";
14
15
  import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
15
16
  import { ATTR } from "@tangle-network/agent-trace-contract";
@@ -745,7 +746,11 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
745
746
  options: opts,
746
747
  identity,
747
748
  toolNames: new Set(servedTools.map((tool) => tool.name)),
748
- handle: (message) => mcp.handle(message),
749
+ handle: async (message) => {
750
+ const response = await mcp.handle(message);
751
+ if (message.method === "tools/call") noteScopeRetainedOwnerCoordination(opts.scope);
752
+ return response;
753
+ },
749
754
  backgroundActions: () => nodeTools.background() + fencedVerbs.background(),
750
755
  authorize: (req) => {
751
756
  if (!paths.has(req.url ?? "")) return 404;
@@ -1311,6 +1316,7 @@ function composeReentryTask(input) {
1311
1316
  "## What to do now",
1312
1317
  "",
1313
1318
  "Continue the run from this state.",
1319
+ ...continuity.workspace === "kept" || continuity.workspace === "restored" ? ["Read the files you already wrote before you repeat any step of the task. A step whose file is there is done, and its content stands."] : [],
1314
1320
  "Receive the waiting events with await_event, and read the output of every settled worker before you spawn anything new.",
1315
1321
  "Do not spawn a replacement for a worker that is running or has settled.",
1316
1322
  "Your coordination tools are served by the same coordinator as before, and the state above comes from it."
@@ -1328,7 +1334,7 @@ function whyLine(reentry) {
1328
1334
  }
1329
1335
  function environmentLine(continuity) {
1330
1336
  if (continuity.environment === "same") return `You run in the same environment as before${continuity.environmentId === void 0 ? "" : ` (${continuity.environmentId})`}, and your files are where you left them.`;
1331
- if (continuity.environment === "replaced") return `Your previous environment${continuity.previousEnvironmentId === void 0 ? "" : ` (${continuity.previousEnvironmentId})`} is gone, and you run in a new one. ` + (continuity.workspace === "kept" ? "Its files were carried over." : "Files you wrote there are not here. The coordinator and the knowledge store kept everything below.");
1337
+ if (continuity.environment === "replaced") return `Your previous environment${continuity.previousEnvironmentId === void 0 ? "" : ` (${continuity.previousEnvironmentId})`} is gone, and you run in a new one. ` + (continuity.workspace === "kept" ? "Its files were carried over." : continuity.workspace === "restored" ? `Its files were restored from a checkpoint taken at ${continuity.checkpointAt ?? "your last coordination call"}; anything you wrote after that is not here. The coordinator and the knowledge store kept everything below.` : "Files you wrote there are not here. The coordinator and the knowledge store kept everything below.");
1332
1338
  return "You may be in a new environment. Check for files before you rely on them; the coordinator kept everything below.";
1333
1339
  }
1334
1340
  function stateLines(state, full) {
@@ -1516,6 +1522,139 @@ function errorMessage(error) {
1516
1522
  return error instanceof Error ? error.message : String(error);
1517
1523
  }
1518
1524
  //#endregion
1525
+ //#region src/runtime/supervise/run-traces.ts
1526
+ /**
1527
+ * A manager's own run as one trace store: what the continuation's question panel reads.
1528
+ *
1529
+ * The panel asks about the director's own work and about its workers' (discovery
1530
+ * `docs/38-one-loop-and-continuation.md`, section 5), so it reads both: the director's root stream
1531
+ * (`root-stream.jsonl`) and each settled worker's structured tool trace. Each agent is one trace,
1532
+ * named by its node id, so a `{worker}` question and a `trace://<worker id>/<span id>` citation
1533
+ * name the same worker.
1534
+ *
1535
+ * The root stream is progress events, not spans. Each tool call becomes one span with its result,
1536
+ * and each run of the director's text, and of its reasoning, between two other events becomes one
1537
+ * span named for what it is (`assistant_text`, `assistant_reasoning`): the director's claims live in
1538
+ * its text, and a panel that saw only its tool calls could not check them. Span ids are the
1539
+ * record's `seq`, which is unique in the file and stable across reads.
1540
+ */
1541
+ /** The span a run of the director's text becomes. */
1542
+ const ASSISTANT_TEXT_SPAN = "assistant_text";
1543
+ /** The span a run of the director's reasoning becomes. */
1544
+ const ASSISTANT_REASONING_SPAN = "assistant_reasoning";
1545
+ /** The director's root stream as tool spans in one trace named `traceId`. */
1546
+ function rootStreamToolSpans(records, traceId) {
1547
+ const spans = [];
1548
+ const open = /* @__PURE__ */ new Map();
1549
+ let prose;
1550
+ const at = (record) => {
1551
+ const ms = Date.parse(record.at);
1552
+ if (!Number.isFinite(ms)) throw new ValidationError(`root stream line ${record.seq} has no valid time`);
1553
+ return ms;
1554
+ };
1555
+ const base = (record, name) => ({
1556
+ kind: "tool",
1557
+ spanId: `s${record.seq}`,
1558
+ runId: traceId,
1559
+ name,
1560
+ toolName: name,
1561
+ startedAt: at(record),
1562
+ attributes: {
1563
+ attempt: record.attempt,
1564
+ seq: record.seq
1565
+ }
1566
+ });
1567
+ for (const record of records) {
1568
+ if (!("event" in record)) {
1569
+ prose = void 0;
1570
+ continue;
1571
+ }
1572
+ const { event } = record;
1573
+ if (event.kind === "text_delta" || event.kind === "reasoning_delta") {
1574
+ if (prose !== void 0 && prose.kind === event.kind && prose.attempt === record.attempt) {
1575
+ prose.text += event.text;
1576
+ prose.span.result = prose.text;
1577
+ prose.span.endedAt = at(record);
1578
+ continue;
1579
+ }
1580
+ const span = {
1581
+ ...base(record, event.kind === "text_delta" ? ASSISTANT_TEXT_SPAN : ASSISTANT_REASONING_SPAN),
1582
+ args: {},
1583
+ result: event.text,
1584
+ endedAt: at(record)
1585
+ };
1586
+ spans.push(span);
1587
+ prose = {
1588
+ span,
1589
+ text: event.text,
1590
+ kind: event.kind,
1591
+ attempt: record.attempt
1592
+ };
1593
+ continue;
1594
+ }
1595
+ prose = void 0;
1596
+ if (event.kind === "tool_call") {
1597
+ const span = {
1598
+ ...base(record, event.toolName),
1599
+ args: event.args,
1600
+ ...event.args === void 0 ? { argsCaptured: false } : {},
1601
+ endedAt: at(record)
1602
+ };
1603
+ if (event.toolCallId !== void 0) span.attributes = {
1604
+ ...span.attributes,
1605
+ toolCallId: event.toolCallId
1606
+ };
1607
+ spans.push(span);
1608
+ open.set(`${record.attempt}\u0000${event.toolCallId ?? `name:${event.toolName}`}`, span);
1609
+ continue;
1610
+ }
1611
+ if (event.kind === "tool_result") {
1612
+ const key = `${record.attempt}\u0000${event.toolCallId ?? `name:${event.toolName}`}`;
1613
+ const call = open.get(key);
1614
+ if (call !== void 0) {
1615
+ open.delete(key);
1616
+ call.result = event.result;
1617
+ call.endedAt = at(record);
1618
+ continue;
1619
+ }
1620
+ spans.push({
1621
+ ...base(record, event.toolName),
1622
+ args: void 0,
1623
+ argsCaptured: false,
1624
+ result: event.result,
1625
+ endedAt: at(record)
1626
+ });
1627
+ }
1628
+ }
1629
+ return spans;
1630
+ }
1631
+ /** One worker's persisted tool spans, re-keyed to the worker's node id. Unavailable: none. */
1632
+ async function workerSpans(worker, blobs) {
1633
+ if (worker.trace.status !== "available") return [];
1634
+ const raw = await blobs.get(worker.trace.traceRef);
1635
+ if (raw === void 0) throw new ValidationError(`worker ${worker.id}'s trace blob '${worker.trace.traceRef}' is missing; its settlement evidence is incomplete`);
1636
+ const { spans } = parseWorkerToolTraceArtifact(raw, worker.trace.traceRef);
1637
+ return spans.map((span) => ({
1638
+ ...span,
1639
+ runId: worker.id,
1640
+ ...span.runId === worker.id ? {} : { attributes: {
1641
+ ...span.attributes,
1642
+ sourceRunId: span.runId
1643
+ } }
1644
+ }));
1645
+ }
1646
+ /**
1647
+ * The store over a manager's run: its own root stream when it has one, and every settled worker's
1648
+ * tool trace. `undefined` when the run has recorded no span yet, which is not a store a panel can
1649
+ * read: agent-eval refuses an empty trace, because it cannot tell a tool-free run from a failed
1650
+ * capture.
1651
+ */
1652
+ async function runTraceAnalysisStore(input) {
1653
+ const records = input.root === void 0 ? void 0 : await input.root.read();
1654
+ const spans = [...records === void 0 || input.root === void 0 ? [] : rootStreamToolSpans(records, input.root.id), ...(await Promise.all(input.workers.map((worker) => workerSpans(worker, input.blobs)))).flat()];
1655
+ return spans.length === 0 ? void 0 : toolSpansToTraceAnalysisStore(spans);
1656
+ }
1657
+ //#endregion
1519
1658
  //#region src/runtime/supervise/worker-control-observer.ts
1520
1659
  /** Observe durable worker controls while the native harness owns the manager's turn loop. */
1521
1660
  function observeWorkerControls(options) {
@@ -1999,7 +2138,17 @@ function buildSupervisorAgent(profile, deps, testBrain) {
1999
2138
  }));
2000
2139
  },
2001
2140
  ...deps.continuationDir === void 0 ? {} : { dir: deps.continuationDir },
2002
- ...deps.rootStreamPath === void 0 ? {} : { rootStreamPath: deps.rootStreamPath },
2141
+ traces: () => {
2142
+ const rootStreamPath = deps.rootStreamPath;
2143
+ return runTraceAnalysisStore({
2144
+ ...rootStreamPath === void 0 ? {} : { root: {
2145
+ id: scope.view.root,
2146
+ read: () => readRootStream(dirname(rootStreamPath))
2147
+ } },
2148
+ workers: mcp.settled(),
2149
+ blobs: deps.blobs
2150
+ });
2151
+ },
2003
2152
  canReadMore: runtimeToolNames.includes("read_continuation")
2004
2153
  });
2005
2154
  let candidate;
@@ -2072,6 +2221,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2072
2221
  };
2073
2222
  const loopRecords = [];
2074
2223
  let environmentReplacements = 0;
2224
+ let workspaceRestores = 0;
2075
2225
  const describe = deps.deliverable?.describe;
2076
2226
  const settleLoop = () => {
2077
2227
  const stopReason = controls.stopReason() ?? progressStopReason;
@@ -2079,6 +2229,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2079
2229
  deps.onDriverLoopSettled?.({
2080
2230
  ...summarizeDriverAttempts(loopRecords),
2081
2231
  environmentReplacements,
2232
+ workspaceRestores,
2082
2233
  ...closedBy === void 0 ? {} : { closedBy },
2083
2234
  ...stopReason === void 0 ? {} : { stopReason },
2084
2235
  continuations: keeper?.entries() ?? []
@@ -2112,6 +2263,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
2112
2263
  compose,
2113
2264
  onContinuity: (continuity) => {
2114
2265
  if (continuity.environment === "replaced") environmentReplacements += 1;
2266
+ if (continuity.workspace === "restored") workspaceRestores += 1;
2115
2267
  }
2116
2268
  } },
2117
2269
  scope,
@@ -3331,12 +3483,18 @@ async function reentryContinuity(backend, scope, retainedOwner) {
3331
3483
  environmentId: environment.environmentId,
3332
3484
  workspace: "kept"
3333
3485
  };
3334
- if (environment.state === "lost") return {
3335
- session: "new",
3336
- environment: "replaced",
3337
- previousEnvironmentId: environment.environmentId,
3338
- workspace: "lost"
3339
- };
3486
+ if (environment.state === "lost") {
3487
+ const restorePoint = await scopeRetainedOwnerRestorePoint(scope);
3488
+ return {
3489
+ session: "new",
3490
+ environment: "replaced",
3491
+ previousEnvironmentId: environment.environmentId,
3492
+ ...restorePoint === void 0 ? { workspace: "lost" } : {
3493
+ workspace: "restored",
3494
+ checkpointAt: restorePoint.takenAt
3495
+ }
3496
+ };
3497
+ }
3340
3498
  return UNPROVEN_CONTINUITY;
3341
3499
  }
3342
3500
  function isAsyncIterable(value) {
@@ -4358,4 +4516,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
4358
4516
  //#endregion
4359
4517
  export { gateOnDeliverable as C, serveCoordinationMcp as S, readRootStream as _, superviseWithTestBrain as a, composeReentryTask as b, resolveWorkerSpawnRetry as c, assertCoordinationBinding as d, coordinationProfileToolPrefix as f, ROOT_STREAM_FILE as g, supervisorAgentWithTestBrain as h, superviseRootProfile as i, retryPreSpawnRefusals as l, supervisorAgent as m, profileGuidanceComposer as n, workerFromBackend as o, resolveSupervisorProfile as p, supervise as r, isPreSpawnExecutorFailure as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, withWorkerSpawnRetry as u, readRootStreamReceipt as v, mapExecutorResult as w, createSupervisorSpanRecorder as x, UNPROVEN_CONTINUITY as y };
4360
4518
 
4361
- //# sourceMappingURL=supervise-CFyAWebz.js.map
4519
+ //# sourceMappingURL=supervise-DBQdrp7H.js.map