@tangle-network/agent-runtime 0.266.0 → 0.271.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 (66) hide show
  1. package/dist/{activation-VpxSbDKJ.d.ts → activation-BrJmwTLB.d.ts} +4 -4
  2. package/dist/{activation-BERiJjx5.js → activation-DGbFPGR3.js} +2 -2
  3. package/dist/{activation-BERiJjx5.js.map → activation-DGbFPGR3.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-DdZ-nh_4.js → coordination-driver-iBGMKDvB.js} +20 -14
  7. package/dist/coordination-driver-iBGMKDvB.js.map +1 -0
  8. package/dist/{delegate-Ajx_PVyu.js → delegate-DOqUvaIz.js} +2 -2
  9. package/dist/{delegate-Ajx_PVyu.js.map → delegate-DOqUvaIz.js.map} +1 -1
  10. package/dist/durable.d.ts +5 -4
  11. package/dist/durable.js +3 -3
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-CK50N9vG.js → graph-DnMcepkN.js} +8 -5
  14. package/dist/graph-DnMcepkN.js.map +1 -0
  15. package/dist/{improvement-cycle-GRPoHLm1.js → improvement-cycle-1IyRJo5h.js} +9 -9
  16. package/dist/improvement-cycle-1IyRJo5h.js.map +1 -0
  17. package/dist/{index-CU2mlMfc.d.ts → index-CL1dduJd.d.ts} +70 -6
  18. package/dist/index.d.ts +7 -7
  19. package/dist/index.js +7 -7
  20. package/dist/intelligence.d.ts +9 -3
  21. package/dist/intelligence.js +11 -5
  22. package/dist/intelligence.js.map +1 -1
  23. package/dist/kernel.d.ts +4 -4
  24. package/dist/kernel.js +9 -9
  25. package/dist/{loop-runner-bin-cC16EPUq.js → loop-runner-bin-BPZ9tt1W.js} +3 -3
  26. package/dist/{loop-runner-bin-cC16EPUq.js.map → loop-runner-bin-BPZ9tt1W.js.map} +1 -1
  27. package/dist/{loop-runner-bin-XKZXM08Q.d.ts → loop-runner-bin-O_vM1w8Y.d.ts} +3 -3
  28. package/dist/loop-runner-bin.d.ts +1 -1
  29. package/dist/loop-runner-bin.js +1 -1
  30. package/dist/mcp/bin.js +3 -3
  31. package/dist/mcp/index.d.ts +12 -6
  32. package/dist/mcp/index.js +7 -7
  33. package/dist/mcp/memory-bin.js +1 -1
  34. package/dist/{memory-server-Cn8LbAxO.js → memory-server-DXQ8IxGR.js} +2 -2
  35. package/dist/{memory-server-Cn8LbAxO.js.map → memory-server-DXQ8IxGR.js.map} +1 -1
  36. package/dist/{openai-tools-D3ajI_D2.d.ts → openai-tools-DWHxpwx2.d.ts} +2 -2
  37. package/dist/profiles.d.ts +2 -2
  38. package/dist/{provision-supervisor-Bf_bPaCv.js → provision-supervisor-Cy8pqE95.js} +3 -3
  39. package/dist/{provision-supervisor-Bf_bPaCv.js.map → provision-supervisor-Cy8pqE95.js.map} +1 -1
  40. package/dist/{runtime-hOLlAc1i.js → runtime-DVjIH1eo.js} +233 -11
  41. package/dist/runtime-DVjIH1eo.js.map +1 -0
  42. package/dist/{server-DOb67ohd.js → server-CN9vzbSe.js} +4 -4
  43. package/dist/{server-DOb67ohd.js.map → server-CN9vzbSe.js.map} +1 -1
  44. package/dist/{stream-agent-turn-Gw9hLpBn.d.ts → stream-agent-turn-DbEsKgb_.d.ts} +21 -3
  45. package/dist/{structural-rollout-DV9YoQF6.js → structural-rollout-I92sIfNl.js} +2 -2
  46. package/dist/{structural-rollout-DV9YoQF6.js.map → structural-rollout-I92sIfNl.js.map} +1 -1
  47. package/dist/{substrate-CLt9S9ym.d.ts → substrate-CbC03Vzo.d.ts} +2 -2
  48. package/dist/{supervise--njTtSL3.js → supervise-DJ_1i9vj.js} +13 -8
  49. package/dist/{supervise--njTtSL3.js.map → supervise-DJ_1i9vj.js.map} +1 -1
  50. package/dist/{supervisor-B8UMAXya.js → supervisor-Cvd5mf7x.js} +285 -86
  51. package/dist/supervisor-Cvd5mf7x.js.map +1 -0
  52. package/dist/testing.d.ts +2 -2
  53. package/dist/testing.js +14 -14
  54. package/dist/testing.js.map +1 -1
  55. package/dist/{tool-server-x9NEhvHZ.js → tool-server-Dqer2M4_.js} +30 -12
  56. package/dist/tool-server-Dqer2M4_.js.map +1 -0
  57. package/dist/tui/index.d.ts +1 -1
  58. package/dist/tui/index.js +1 -1
  59. package/dist/{types-CrnwLVYQ.d.ts → types-Bo7z5aG5.d.ts} +109 -43
  60. package/package.json +2 -1
  61. package/dist/coordination-driver-DdZ-nh_4.js.map +0 -1
  62. package/dist/graph-CK50N9vG.js.map +0 -1
  63. package/dist/improvement-cycle-GRPoHLm1.js.map +0 -1
  64. package/dist/runtime-hOLlAc1i.js.map +0 -1
  65. package/dist/supervisor-B8UMAXya.js.map +0 -1
  66. package/dist/tool-server-x9NEhvHZ.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { $i as cloneSpend, An as routerBrain, Bn as sandboxClientAsProvider, Dt as insideCursorNamespace, En as probeSandboxCapabilities, Et as InMemorySpawnJournal, Fi as detachedFrozen, Fn as LEAF_CONTINUATION_TASK, Hn as unavailableSignalOfFailure, Hr as harnessInvocation, M as settledToIteration, Mn as canonicalObservedModelParts, Ni as executableAgentProfileSnapshot, On as assertBoxlessPromptOptions, Pi as executableAgentSpecSnapshot, Pt as isTraceAnalysisStore, Qi as chargedTokens, Sn as defaultSelectWinner, Tn as createSandboxLineage, Tt as InMemoryResultBlobStore, Un as createPushTraceSource, Vn as unavailablePauseMs, Zi as addSpend, _t as createExecutorRegistry, aa as sleep, b as withDriverExecutor, da as zeroSpend, dt as rollingDispatch, fi as prepareJsonlAppend, fr as contentAddress, gt as createExecutor, ia as randomSuffix, jn as runBrainLoop, kn as readPromptOptions, mi as writeAllBytes, na as isAbortError, oa as stringifySafe, pi as readCommittedJsonLines, qi as notifySandboxEventObserver, r as createSupervisor, ta as hasCompleteCacheBreakdown, wn as runAgentRounds, ya as armDeadlineTimer, yt as createWorktreeCliExecutor } from "./supervisor-B8UMAXya.js";
1
+ import { At as insideCursorNamespace, Dn as runAgentRounds, Dt as SpawnEventIndex, Et as InMemorySpawnJournal, Fn as canonicalObservedModelParts, Gn as unavailableSignalOfFailure, Gr as harnessInvocation, Ii as executableAgentProfileSnapshot, Kn as createPushTraceSource, Li as executableAgentSpecSnapshot, Lt as isTraceAnalysisStore, M as settledToIteration, Mn as readPromptOptions, Nn as routerBrain, On as createSandboxLineage, Ot as assertContentAddress, Pn as runBrainLoop, Ri as detachedFrozen, Rn as LEAF_CONTINUATION_TASK, Sa as armDeadlineTimer, Tn as defaultSelectWinner, Tt as InMemoryResultBlobStore, Un as sandboxClientAsProvider, Wn as unavailablePauseMs, Xi as notifySandboxEventObserver, _i as writeAllBytes, _t as createExecutorRegistry, aa as isAbortError, b as withDriverExecutor, ca as sleep, dt as rollingDispatch, ea as addSpend, gi as readCommittedJsonLines, gt as createExecutor, hi as prepareJsonlAppend, hr as contentAddress, ia as hasCompleteCacheBreakdown, jn as assertBoxlessPromptOptions, kn as probeSandboxCapabilities, kt as encodeResultBlob, la as stringifySafe, ma as zeroSpend, na as cloneSpend, r as createSupervisor, sa as randomSuffix, ta as chargedTokens, yt as createWorktreeCliExecutor, zi as detachedSnapshot } from "./supervisor-Cvd5mf7x.js";
2
2
  import { m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
3
- import { E as profileChatClient, S as ObservationError, T as renderReport, b as sample, k as strategyAuthorMethod, v as refine, w as observe, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-DV9YoQF6.js";
3
+ import { E as profileChatClient, S as ObservationError, T as renderReport, b as sample, k as strategyAuthorMethod, v as refine, w as observe, x as sampleThenRefine, y as runAgentic } from "./structural-rollout-I92sIfNl.js";
4
4
  import { a as concreteProfileModel, c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
5
5
  import { C as canonicalCandidateDigest$1, D as immutableCandidateValue, k as sha256Bytes$1, m as captureMaterializedWorkspace } from "./workspace-archive-C9lgf77y.js";
6
6
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
7
7
  import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction--F3v1oo8.js";
8
- import "./coordination-driver-DdZ-nh_4.js";
9
- import { C as gateOnDeliverable, r as supervise, w as mapExecutorResult } from "./supervise--njTtSL3.js";
8
+ import "./coordination-driver-iBGMKDvB.js";
9
+ import { C as gateOnDeliverable, r as supervise, w as mapExecutorResult } from "./supervise-DJ_1i9vj.js";
10
10
  import "./run-layout-vwd4SwX_.js";
11
- import "./provision-supervisor-Bf_bPaCv.js";
12
- import "./delegate-Ajx_PVyu.js";
13
- import "./graph-CK50N9vG.js";
11
+ import "./provision-supervisor-Cy8pqE95.js";
12
+ import "./delegate-DOqUvaIz.js";
13
+ import "./graph-DnMcepkN.js";
14
14
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
15
15
  import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, createTraceAnalyst, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
16
16
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
@@ -848,6 +848,173 @@ async function materializeLocalMcp(profile, opts = {}) {
848
848
  };
849
849
  }
850
850
  //#endregion
851
+ //#region src/durable/spawn-journal-sql.ts
852
+ /**
853
+ * SQL-backed durable stores for supervised runs — `SqlSpawnJournal` and `SqlResultBlobStore`
854
+ * over the same minimal statement seam `SqlConversationJournal` uses (D1, postgres, sqlite,
855
+ * libSQL; positional `?` placeholders). This closes the orchestration-durability gap recorded in
856
+ * `conformance/durability/STATUS.md`: until now the spawn layer was file-only.
857
+ *
858
+ * Parity with the JSONL file stores, by construction:
859
+ * • same corruption guards — `beginTree` precedes events (enforced by the schema: an event row
860
+ * names a tree row), duplicate cursor seqs and duplicate materialization receipts are refused
861
+ * by the same `SpawnEventIndex` the file journal replays through, on both append and load;
862
+ * • same content-address law for blobs — a `put` whose ref does not hash to the artifact is
863
+ * refused, a re-put of the same ref asserts the identical bytes;
864
+ * • load order is insertion order (`INTEGER PRIMARY KEY AUTOINCREMENT`), the SQL analogue of
865
+ * the JSONL append-only spine.
866
+ *
867
+ * Durability note: this suite and its process-kill test run against `node:sqlite`, whose
868
+ * autocommit commits survive SIGKILL (process death, not OS crash). A deployment that must
869
+ * survive power loss sets its driver's synchronous mode (`PRAGMA synchronous=FULL` + WAL) at the
870
+ * adapter; agent-runtime takes no opinion.
871
+ *
872
+ * @experimental — draft: cross-process ownership is single-writer by convention (the same
873
+ * limitation `createFileRunContext` documents); a machine-visible ownership lease is follow-up.
874
+ */
875
+ const TREES_DDL = (table) => `
876
+ CREATE TABLE IF NOT EXISTS ${table}_trees (
877
+ root TEXT PRIMARY KEY,
878
+ begun_at TEXT NOT NULL
879
+ )
880
+ `;
881
+ const EVENTS_DDL = (table) => `
882
+ CREATE TABLE IF NOT EXISTS ${table}_events (
883
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
884
+ root TEXT NOT NULL REFERENCES ${table}_trees (root),
885
+ body TEXT NOT NULL
886
+ )
887
+ `;
888
+ const BLOBS_DDL = (table) => `
889
+ CREATE TABLE IF NOT EXISTS ${table}_blobs (
890
+ ref TEXT PRIMARY KEY,
891
+ body TEXT NOT NULL
892
+ )
893
+ `;
894
+ /** SQL-backed `SpawnJournal`. One row per event; insertion order is replay order. */
895
+ var SqlSpawnJournal = class {
896
+ db;
897
+ table;
898
+ cache = /* @__PURE__ */ new Map();
899
+ appendTail = Promise.resolve();
900
+ constructor(db, table = "runtime_spawn_journal") {
901
+ this.db = db;
902
+ this.table = table;
903
+ }
904
+ /** Create the journal's tables if absent. Idempotent. */
905
+ async migrate() {
906
+ await this.db.exec(TREES_DDL(this.table));
907
+ await this.db.exec(EVENTS_DDL(this.table));
908
+ }
909
+ async loadTree(root) {
910
+ if ((await this.db.query(`SELECT begun_at FROM ${this.table}_trees WHERE root = ?`, [root])).length === 0) return void 0;
911
+ const rows = await this.db.query(`SELECT id, body FROM ${this.table}_events WHERE root = ? ORDER BY id`, [root]);
912
+ const index = new SpawnEventIndex(root);
913
+ const events = [];
914
+ for (const row of rows) {
915
+ const event = JSON.parse(row.body);
916
+ index.assert(event);
917
+ index.add(event);
918
+ events.push(event);
919
+ }
920
+ return events;
921
+ }
922
+ async beginTree(root, at) {
923
+ return this.serializeAppend(async () => {
924
+ await this.ensureMigrated();
925
+ const existing = await this.db.query(`SELECT begun_at FROM ${this.table}_trees WHERE root = ?`, [root]);
926
+ if (existing.length > 0) {
927
+ const begunAt = existing[0]?.begun_at;
928
+ if (begunAt !== at) throw new Error(`spawn tree '${root}' already begun in SQL at ${begunAt}; refusing to overwrite with ${at}`);
929
+ return;
930
+ }
931
+ await this.db.exec(`INSERT INTO ${this.table}_trees (root, begun_at) VALUES (?, ?)`, [root, at]);
932
+ this.cache.set(root, {
933
+ maxId: 0,
934
+ index: new SpawnEventIndex(root)
935
+ });
936
+ });
937
+ }
938
+ async appendEvent(root, ev) {
939
+ const event = detachedSnapshot(ev, "spawn event");
940
+ return this.serializeAppend(async () => {
941
+ await this.ensureMigrated();
942
+ const state = await this.validationIndex(root);
943
+ state.index.assert(event);
944
+ if ((await this.db.exec(`INSERT INTO ${this.table}_events (root, body) VALUES (?, ?)`, [root, JSON.stringify(event)])).rowsAffected !== 1) throw new Error(`spawn journal SQL: append of an event for tree '${root}' affected no rows`);
945
+ state.index.add(event);
946
+ state.maxId = await this.maxEventId(root);
947
+ });
948
+ }
949
+ async validationIndex(root) {
950
+ if ((await this.db.query(`SELECT begun_at FROM ${this.table}_trees WHERE root = ?`, [root])).length === 0) throw new Error(`appendEvent called for unknown spawn tree '${root}'; call beginTree first`);
951
+ const max = await this.maxEventId(root);
952
+ const cached = this.cache.get(root);
953
+ if (cached && cached.maxId === max) return cached;
954
+ const index = new SpawnEventIndex(root);
955
+ if (max > 0) {
956
+ const rows = await this.db.query(`SELECT body FROM ${this.table}_events WHERE root = ? ORDER BY id`, [root]);
957
+ for (const row of rows) {
958
+ const event = JSON.parse(row.body);
959
+ index.assert(event);
960
+ index.add(event);
961
+ }
962
+ }
963
+ const state = {
964
+ maxId: max,
965
+ index
966
+ };
967
+ this.cache.set(root, state);
968
+ return state;
969
+ }
970
+ async maxEventId(root) {
971
+ return (await this.db.query(`SELECT MAX(id) AS max FROM ${this.table}_events WHERE root = ?`, [root]))[0]?.max ?? 0;
972
+ }
973
+ migrated = false;
974
+ async ensureMigrated() {
975
+ if (this.migrated) return;
976
+ await this.migrate();
977
+ this.migrated = true;
978
+ }
979
+ serializeAppend(operation) {
980
+ const append = this.appendTail.then(operation);
981
+ this.appendTail = append.catch(() => void 0);
982
+ return append;
983
+ }
984
+ };
985
+ /** SQL-backed `ResultBlobStore`. One content-addressed row per settled result. */
986
+ var SqlResultBlobStore = class {
987
+ db;
988
+ table;
989
+ migrated = false;
990
+ constructor(db, table = "runtime_result_blobs") {
991
+ this.db = db;
992
+ this.table = table;
993
+ }
994
+ async migrate() {
995
+ await this.db.exec(BLOBS_DDL(this.table));
996
+ }
997
+ async put(outRef, artifact) {
998
+ await this.ensureMigrated();
999
+ const { text } = encodeResultBlob(outRef, artifact);
1000
+ if ((await this.db.exec(`INSERT OR IGNORE INTO ${this.table}_blobs (ref, body) VALUES (?, ?)`, [outRef, text])).rowsAffected === 1) return;
1001
+ assertContentAddress(outRef, await this.get(outRef));
1002
+ }
1003
+ async get(outRef) {
1004
+ await this.ensureMigrated();
1005
+ const rows = await this.db.query(`SELECT body FROM ${this.table}_blobs WHERE ref = ?`, [outRef]);
1006
+ if (rows.length === 0) return void 0;
1007
+ const artifact = JSON.parse(rows[0]?.body ?? "null");
1008
+ assertContentAddress(outRef, artifact);
1009
+ return artifact;
1010
+ }
1011
+ async ensureMigrated() {
1012
+ if (this.migrated) return;
1013
+ await this.migrate();
1014
+ this.migrated = true;
1015
+ }
1016
+ };
1017
+ //#endregion
851
1018
  //#region src/runtime/audit-intent.ts
852
1019
  /** Default system instruction for intent-auditor agents: diagnose diverged/drifting trajectories. */
853
1020
  const defaultAuditorInstruction = "You audit whether an AI agent is on the RIGHT ROUTE — not whether it works hard, but whether its actions serve the stated intents. Infer the REVEALED intent from the action pattern (what the trajectory is actually optimizing). Compare against the declared task intent, the user intent when given, and the meta-intent when given. Flawless execution down the wrong route is DIVERGED. Busy-work that neither advances nor harms is DRIFTING. Judge only from the trajectory — be specific about which actions ground your verdict. Recommend abort only when continuing cannot serve the intent.";
@@ -5438,6 +5605,7 @@ async function createWorker(lease, root, createProfile, placement) {
5438
5605
  const timeoutMs = options?.timeoutMs ?? 0;
5439
5606
  const turnDeadline = timeoutMs > 0 ? Date.now() + timeoutMs : void 0;
5440
5607
  let sessionId;
5608
+ const subagents = /* @__PURE__ */ new Set();
5441
5609
  let refusalsInARow = 0;
5442
5610
  let prompt = message;
5443
5611
  for (let invocation = 1;; invocation += 1) {
@@ -5465,12 +5633,14 @@ async function createWorker(lease, root, createProfile, placement) {
5465
5633
  running = void 0;
5466
5634
  }
5467
5635
  sessionId = parsed.sessionId() ?? sessionId;
5636
+ for (const child of parsed.subagentSessionIds()) subagents.add(child);
5468
5637
  const failure = parsed.failure(exitCode, errorText);
5469
5638
  const refusal = failure === void 0 || unavailablePause === false || signal?.aborted ? void 0 : unavailableSignalOfFailure({ error: failure });
5470
5639
  refusalsInARow = parsed.madeProgress() ? 1 : refusalsInARow + 1;
5471
5640
  const pauseMs = refusal === void 0 || unavailablePause === false ? 0 : unavailablePauseMs(refusalsInARow, unavailablePause);
5472
5641
  if (refusal === void 0 || turnDeadline !== void 0 && Date.now() + pauseMs >= turnDeadline) {
5473
5642
  if (sessionId !== void 0) await exportSession(run, collect, paths, sessionId);
5643
+ for (const child of subagents) if (child !== sessionId) await exportSession(run, collect, paths, child);
5474
5644
  signal?.throwIfAborted();
5475
5645
  yield* parsed.finish(exitCode, errorText, invocation);
5476
5646
  return;
@@ -5494,7 +5664,7 @@ async function createWorker(lease, root, createProfile, placement) {
5494
5664
  if (released) throw new ValidationError("sharedBoxPlacement: this worker was released");
5495
5665
  if (turnActive) throw new ValidationError("sharedBoxPlacement: a worker runs one turn at a time");
5496
5666
  const turnProfile = options?.backend?.profile === void 0 ? createProfile : agentProfileSchema.parse(options.backend.profile);
5497
- if (canonicalCandidateDigest(turnProfile) !== canonicalCandidateDigest(createProfile) && sharedBoxRefusal(turnProfile) !== void 0) throw new ValidationError(`sharedBoxPlacement: ${sharedBoxRefusal(turnProfile)}`);
5667
+ if (canonicalAgentProfileDigest(turnProfile) !== canonicalAgentProfileDigest(createProfile) && sharedBoxRefusal(turnProfile) !== void 0) throw new ValidationError(`sharedBoxPlacement: ${sharedBoxRefusal(turnProfile)}`);
5498
5668
  if (options?.backend?.type !== void 0 && options.backend.type !== HARNESS) throw new ValidationError(`sharedBoxPlacement: backend ${options.backend.type} is not ${HARNESS}`);
5499
5669
  turnActive = true;
5500
5670
  try {
@@ -5688,7 +5858,7 @@ async function materializeWorker(box, paths, profile, task, turnModel, clientNam
5688
5858
  * `opencode export` writes the same session as JSON.
5689
5859
  */
5690
5860
  async function exportSession(run, collect, paths, sessionId) {
5691
- if (!/^[A-Za-z0-9_-]+$/u.test(sessionId)) return;
5861
+ if (!SESSION_ID.test(sessionId)) return;
5692
5862
  await collect(await run([
5693
5863
  "/bin/sh",
5694
5864
  "-c",
@@ -5698,6 +5868,29 @@ async function exportSession(run, collect, paths, sessionId) {
5698
5868
  `${paths.home}/.local/share/opencode/export/${sessionId}.json`
5699
5869
  ], DEFAULT_EXEC_TIMEOUT_MS));
5700
5870
  }
5871
+ const SESSION_ID = /^[A-Za-z0-9_-]+$/u;
5872
+ /** A subagent's session id in a `task` result (`<task id="ses_…">`) or failure (`task_id: ses_…`). */
5873
+ const TASK_SESSION = /(?:<task id="|task_id: )(ses_[A-Za-z0-9]+)/u;
5874
+ /**
5875
+ * The session a harness subagent ran in, named by its parent's `task` tool part.
5876
+ *
5877
+ * opencode starts each subagent in a child session and refuses a nested one unless the
5878
+ * configuration raises `subagent_depth` above 1, so under the default the parent's parts name
5879
+ * every subagent session. A running part carries the id in `state.metadata.sessionId`; a finished
5880
+ * one also carries it in its output, and a failed one in its error.
5881
+ */
5882
+ function subagentSessionOf(part) {
5883
+ if (part.type !== "tool" || part.tool !== "task") return void 0;
5884
+ const state = part.state;
5885
+ if (state === void 0 || state === null || typeof state !== "object") return void 0;
5886
+ const { metadata, output, error } = state;
5887
+ const named = metadata !== null && typeof metadata === "object" ? metadata.sessionId : void 0;
5888
+ if (typeof named === "string" && SESSION_ID.test(named)) return named;
5889
+ for (const text of [output, error]) {
5890
+ const match = typeof text === "string" ? TASK_SESSION.exec(text) : null;
5891
+ if (match !== null) return match[1];
5892
+ }
5893
+ }
5701
5894
  /**
5702
5895
  * Translate opencode's JSON event lines into the Sandbox event wire the provider executor reads.
5703
5896
  *
@@ -5711,6 +5904,7 @@ function createOpencodeEventParser(model) {
5711
5904
  let sessionId;
5712
5905
  let finalMessageId;
5713
5906
  const textByMessage = /* @__PURE__ */ new Map();
5907
+ const subagentSessions = /* @__PURE__ */ new Set();
5714
5908
  const errors = [];
5715
5909
  let malformed = 0;
5716
5910
  let spentTokens = false;
@@ -5723,6 +5917,7 @@ function createOpencodeEventParser(model) {
5723
5917
  };
5724
5918
  return {
5725
5919
  sessionId: () => sessionId,
5920
+ subagentSessionIds: () => [...subagentSessions],
5726
5921
  /** Why this run failed, or `undefined` when it answered. */
5727
5922
  failure: failureOf,
5728
5923
  /** Whether this run spent any model tokens before it ended. */
@@ -5747,6 +5942,8 @@ function createOpencodeEventParser(model) {
5747
5942
  }
5748
5943
  const part = event.part;
5749
5944
  if (part === void 0 || part === null || typeof part !== "object") return;
5945
+ const subagent = subagentSessionOf(part);
5946
+ if (subagent !== void 0) subagentSessions.add(subagent);
5750
5947
  yield {
5751
5948
  type: "message.part.updated",
5752
5949
  data: { part }
@@ -7001,6 +7198,31 @@ function signalPass(value, required) {
7001
7198
  return !required;
7002
7199
  }
7003
7200
  //#endregion
7201
+ //#region src/runtime/supervise/run-context-sql.ts
7202
+ /**
7203
+ *
7204
+ * `createSqlRunContext` — the SQL-backed durable bundle a `createSupervisor().run` (or a
7205
+ * `runGraph`/`supervise` call that accepts injected stores) needs: a `SqlSpawnJournal`, a
7206
+ * `SqlResultBlobStore` (both over one `SqlStatements` seam — the same adapter shape
7207
+ * `SqlConversationJournal` takes), and a fresh `createExecutorRegistry()`, with `resume: true`
7208
+ * so spreading the context makes the run loadTree-first.
7209
+ *
7210
+ * The SQL analogue of `createFileRunContext`: where that bundle owns a directory, this one owns
7211
+ * tables in a database the caller already operates. The durable coordination side-log and
7212
+ * cancellation observers remain file-based behind `runDir`; a SQL coordination log is follow-up.
7213
+ *
7214
+ * @experimental
7215
+ */
7216
+ /** Build a durable run context over one SQL statement seam. Tables are created on first use. */
7217
+ function createSqlRunContext(db) {
7218
+ return {
7219
+ journal: new SqlSpawnJournal(db),
7220
+ blobs: new SqlResultBlobStore(db),
7221
+ executors: createExecutorRegistry(),
7222
+ resume: true
7223
+ };
7224
+ }
7225
+ //#endregion
7004
7226
  //#region src/runtime/supervise/trajectory-recorder.ts
7005
7227
  /**
7006
7228
  *
@@ -8284,6 +8506,6 @@ function tail(s) {
8284
8506
  return s.slice(-400);
8285
8507
  }
8286
8508
  //#endregion
8287
- export { definePersona as $, createTangleSandboxExactProcessProvider as $t, chatWorkerSeam as A, superviseDispatch as At, DEFAULT_SHARED_BOX_RESOURCES as B, renderPairwiseMarkdown as Bt, withUntrackedArtifacts as C, harvestCorpus as Ct, codeModeSupervisorTools as D, inlineSandboxClient as Dt, runCoderChecks as E, localSandboxClient as Et, selectChampion as F, leaderboard as Ft, sharedWorkerClientName as G, materializeLocalMcp as Gt, ROUTER_CLIENT_HEADER as H, defaultAuditorInstruction as Ht, assertStrategyContract as I, pairwiseSignificance as It, printBenchmarkReport as J, envKeyProvider as Jt, SandboxRunAbortError as K, createMcpEnvironment as Kt, authorStrategy as L, renderLeaderboardHtml as Lt, discriminatingMeans as M, deterministicCompletion as Mt, pickChampion as N, sentinelCompletion as Nt, unsafeInProcessRunner as O, loopCampaignDispatch as Ot, runStrategyEvolution as P, stopSentinel as Pt, trajectoryReport as Q, secretEnvOfMcpServer as Qt, strategyAuthorContract as R, renderLeaderboardMarkdown as Rt, copyUntrackedIntoClone as S, HarvestError as St, patchDelivered as T, resolveSandboxClient as Tt, sharedBoxPlacement as U, McpSpawnFault as Ut, DEFAULT_SHARED_BOX_WORKERS as V, auditIntent as Vt, sharedBoxRefusal as W, connectStdioMcp as Wt, promotionGate as X, resolveMcpServerLaunch as Xt, runBenchmark as Y, mcpSecretEnvMetadataKey as Yt, equalKOnCost as Z, resolveSecretEnv as Zt, NOTE_MAX_CHARS as _, createScopeAnalyst as _t, localShell as a, InMemoryCorpus as at, composeWorkerEvidence as b, runIsolatedCheck as bt, createVerifierEnvironment as c, flatWidenGate as ct, harvestSurfaceDiffs as d, pipeline as dt, runPersonified as et, analystsFromRegistry as f, selectValidWinner as ft, EVIDENCE_MAX_CHARS as g, buildSteerContext as gt, worktreeFanout as h, assertTraceDerivedFindings as ht, jjWorkspace as i, FileCorpus as it, createChatSessionStore as j, completionAuthorizes as jt, chatTransportExecutor as k, loopDispatch as kt, boxSurfaceReader as l, loopUntil as lt, superviseSurface as m, widen as mt, makeFinding$1 as n, createShapeRegistry as nt, runInWorkspace as o, renderCorpusToInstructions as ot, failuresAnalyst as p, verify as pt, openSandboxRun as q, sanitizeMcpToolSchema as qt, gitWorkspace as r, registerShape as rt, createWaterfallCollector as s, fanout as st, computeFindingId$1 as t, builtinShapes as tt, fsSurfaceReader as u, panel as ut, VERIFY_TAIL_CHARS as v, registryScopeAnalyst as vt, analyzeTrace as w, defineLeaderboard as wt, settledWorkerOut as x, inProcessSandboxClient as xt, closingWorkerNote as y, observationFromRegistry as yt, strategyAuthorSystemPrompt as z, renderLeaderboardSvg as zt };
8509
+ export { trajectoryReport as $, resolveMcpServerLaunch as $t, chatTransportExecutor as A, loopDispatch as At, strategyAuthorSystemPrompt as B, renderLeaderboardSvg as Bt, withUntrackedArtifacts as C, HarvestError as Ct, runCoderChecks as D, localSandboxClient as Dt, patchDelivered as E, resolveSandboxClient as Et, runStrategyEvolution as F, stopSentinel as Ft, sharedBoxRefusal as G, SqlSpawnJournal as Gt, DEFAULT_SHARED_BOX_WORKERS as H, auditIntent as Ht, selectChampion as I, leaderboard as It, openSandboxRun as J, materializeLocalMcp as Jt, sharedWorkerClientName as K, McpSpawnFault as Kt, assertStrategyContract as L, pairwiseSignificance as Lt, createChatSessionStore as M, completionAuthorizes as Mt, discriminatingMeans as N, deterministicCompletion as Nt, codeModeSupervisorTools as O, inlineSandboxClient as Ot, pickChampion as P, sentinelCompletion as Pt, equalKOnCost as Q, mcpSecretEnvMetadataKey as Qt, authorStrategy as R, renderLeaderboardHtml as Rt, copyUntrackedIntoClone as S, inProcessSandboxClient as St, createSqlRunContext as T, defineLeaderboard as Tt, ROUTER_CLIENT_HEADER as U, defaultAuditorInstruction as Ut, DEFAULT_SHARED_BOX_RESOURCES as V, renderPairwiseMarkdown as Vt, sharedBoxPlacement as W, SqlResultBlobStore as Wt, runBenchmark as X, sanitizeMcpToolSchema as Xt, printBenchmarkReport as Y, createMcpEnvironment as Yt, promotionGate as Z, envKeyProvider as Zt, NOTE_MAX_CHARS as _, buildSteerContext as _t, localShell as a, FileCorpus as at, composeWorkerEvidence as b, observationFromRegistry as bt, createVerifierEnvironment as c, fanout as ct, harvestSurfaceDiffs as d, panel as dt, resolveSecretEnv as en, definePersona as et, analystsFromRegistry as f, pipeline as ft, EVIDENCE_MAX_CHARS as g, assertTraceDerivedFindings as gt, worktreeFanout as h, widen as ht, jjWorkspace as i, registerShape as it, chatWorkerSeam as j, superviseDispatch as jt, unsafeInProcessRunner as k, loopCampaignDispatch as kt, boxSurfaceReader as l, flatWidenGate as lt, superviseSurface as m, verify as mt, makeFinding$1 as n, createTangleSandboxExactProcessProvider as nn, builtinShapes as nt, runInWorkspace as o, InMemoryCorpus as ot, failuresAnalyst as p, selectValidWinner as pt, SandboxRunAbortError as q, connectStdioMcp as qt, gitWorkspace as r, createShapeRegistry as rt, createWaterfallCollector as s, renderCorpusToInstructions as st, computeFindingId$1 as t, secretEnvOfMcpServer as tn, runPersonified as tt, fsSurfaceReader as u, loopUntil as ut, VERIFY_TAIL_CHARS as v, createScopeAnalyst as vt, analyzeTrace as w, harvestCorpus as wt, settledWorkerOut as x, runIsolatedCheck as xt, closingWorkerNote as y, registryScopeAnalyst as yt, strategyAuthorContract as z, renderLeaderboardMarkdown as zt };
8288
8510
 
8289
- //# sourceMappingURL=runtime-hOLlAc1i.js.map
8511
+ //# sourceMappingURL=runtime-DVjIH1eo.js.map