@tangle-network/agent-runtime 0.348.1 → 0.350.2

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 (130) hide show
  1. package/dist/{activation-BEGalhOL.js → activation-CfJMyzEs.js} +12 -14
  2. package/dist/{activation-BEGalhOL.js.map → activation-CfJMyzEs.js.map} +1 -1
  3. package/dist/{activation-NQZP_mdI.d.ts → activation-DyiHrTlS.d.ts} +2 -24
  4. package/dist/agent.d.ts +8 -12
  5. package/dist/agent.js +9 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
  8. package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +3 -5
  10. package/dist/analyst-loop.js +1 -2
  11. package/dist/{bundle-DKQtOO9d.js → bundle-Ze8pd07a.js} +3 -4
  12. package/dist/{bundle-DKQtOO9d.js.map → bundle-Ze8pd07a.js.map} +1 -1
  13. package/dist/candidate-execution/index.d.ts +13 -33
  14. package/dist/candidate-execution/index.js +16 -18
  15. package/dist/candidate-execution/index.js.map +1 -1
  16. package/dist/{coordination-manager-Bm6leXc6.js → coordination-manager-BkVfWlMz.js} +101 -132
  17. package/dist/coordination-manager-BkVfWlMz.js.map +1 -0
  18. package/dist/{delegate-Cp5-PsaX.js → delegate-DgEie4ad.js} +19 -21
  19. package/dist/delegate-DgEie4ad.js.map +1 -0
  20. package/dist/durable.d.ts +13 -23
  21. package/dist/durable.js +48 -43
  22. package/dist/durable.js.map +1 -1
  23. package/dist/{errors-DodWX-cb.js → errors-wuhGvpE3.js} +2 -3
  24. package/dist/{errors-DodWX-cb.js.map → errors-wuhGvpE3.js.map} +1 -1
  25. package/dist/{graph-CE_pzU31.js → graph-Cx0FhKSE.js} +192 -15
  26. package/dist/graph-Cx0FhKSE.js.map +1 -0
  27. package/dist/{improve-wT11zteg.js → improve-i0HU1-aa.js} +35 -53
  28. package/dist/{improve-wT11zteg.js.map → improve-i0HU1-aa.js.map} +1 -1
  29. package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
  30. package/dist/index.d.ts +41 -89
  31. package/dist/index.js +43 -61
  32. package/dist/index.js.map +1 -1
  33. package/dist/intelligence.d.ts +39 -59
  34. package/dist/intelligence.js +23 -33
  35. package/dist/intelligence.js.map +1 -1
  36. package/dist/kernel.d.ts +5 -5
  37. package/dist/kernel.js +11 -11
  38. package/dist/{loop-runner-CZzeeJTG.js → loop-runner-BwN9MhdP.js} +5 -6
  39. package/dist/{loop-runner-CZzeeJTG.js.map → loop-runner-BwN9MhdP.js.map} +1 -1
  40. package/dist/{loop-runner-CY5HHhtR.d.ts → loop-runner-DvfOXVx9.d.ts} +3 -5
  41. package/dist/loop-runner-bin.d.ts +5 -8
  42. package/dist/loop-runner-bin.js +2 -3
  43. package/dist/mcp/bin.js +6 -8
  44. package/dist/mcp/bin.js.map +1 -1
  45. package/dist/mcp/index.d.ts +8 -18
  46. package/dist/mcp/index.js +17 -25
  47. package/dist/mcp/index.js.map +1 -1
  48. package/dist/mcp/memory-bin.js +4 -6
  49. package/dist/mcp/memory-bin.js.map +1 -1
  50. package/dist/{model-policy-CyCUwHed.js → model-policy-GSxWwP-b.js} +11 -13
  51. package/dist/model-policy-GSxWwP-b.js.map +1 -0
  52. package/dist/placement.d.ts +12 -14
  53. package/dist/placement.js +1 -2
  54. package/dist/platform.d.ts +7 -13
  55. package/dist/platform.js +3 -6
  56. package/dist/platform.js.map +1 -1
  57. package/dist/{prepare-TEEHSJwq.js → prepare-DE8TQnLu.js} +49 -69
  58. package/dist/{prepare-TEEHSJwq.js.map → prepare-DE8TQnLu.js.map} +1 -1
  59. package/dist/{profile-6OLpbjvV.js → profile-CAhZDW2T.js} +58 -92
  60. package/dist/profile-CAhZDW2T.js.map +1 -0
  61. package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
  62. package/dist/profiles.d.ts +25 -12
  63. package/dist/profiles.js +52 -11
  64. package/dist/profiles.js.map +1 -1
  65. package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
  66. package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
  67. package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
  68. package/dist/{provision-supervisor-CC0HdOHo.js → provision-supervisor-Bde_FF0R.js} +11 -15
  69. package/dist/{provision-supervisor-CC0HdOHo.js.map → provision-supervisor-Bde_FF0R.js.map} +1 -1
  70. package/dist/{record-events-D93DkpAx.js → record-events-B2GUgYdz.js} +12 -14
  71. package/dist/{record-events-D93DkpAx.js.map → record-events-B2GUgYdz.js.map} +1 -1
  72. package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-BLy_Zz-w.js} +6 -7
  73. package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-BLy_Zz-w.js.map} +1 -1
  74. package/dist/{runtime-B_40dXlF.js → runtime-6Ec9sHRe.js} +833 -215
  75. package/dist/runtime-6Ec9sHRe.js.map +1 -0
  76. package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
  77. package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
  78. package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
  79. package/dist/{sandbox-profile-compat-_fEtHPCj.js → sandbox-profile-compat-BxMQ1VXv.js} +62 -44
  80. package/dist/sandbox-profile-compat-BxMQ1VXv.js.map +1 -0
  81. package/dist/{search-executor-COd2F2wp.js → search-executor-B7g_5Wjl.js} +12 -17
  82. package/dist/search-executor-B7g_5Wjl.js.map +1 -0
  83. package/dist/{server-BGB4R4wQ.js → server-fvEMwGMQ.js} +19 -30
  84. package/dist/{server-BGB4R4wQ.js.map → server-fvEMwGMQ.js.map} +1 -1
  85. package/dist/{structural-rollout-Wl_rCuzM.js → structural-rollout-B86bSixU.js} +69 -70
  86. package/dist/structural-rollout-B86bSixU.js.map +1 -0
  87. package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
  88. package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
  89. package/dist/{supervise-BUOeThuB.js → supervise-CaeZcgAW.js} +615 -203
  90. package/dist/supervise-CaeZcgAW.js.map +1 -0
  91. package/dist/{supervisor-DDy0aEtR.js → supervisor-C1OePYE-.js} +526 -642
  92. package/dist/supervisor-C1OePYE-.js.map +1 -0
  93. package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
  94. package/dist/task-queue.d.ts +1 -1
  95. package/dist/task-queue.js +1 -2
  96. package/dist/testing.d.ts +8 -16
  97. package/dist/testing.js +241 -244
  98. package/dist/testing.js.map +1 -1
  99. package/dist/tool-loop.d.ts +16 -19
  100. package/dist/tool-loop.js +2 -3
  101. package/dist/{tool-server-XV4aJwoQ.js → tool-server-CwuYeW_Z.js} +3 -4
  102. package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CwuYeW_Z.js.map} +1 -1
  103. package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-ChwpTr7A.js} +4 -5
  104. package/dist/{top-snapshot-CflmaDgk.js.map → top-snapshot-ChwpTr7A.js.map} +1 -1
  105. package/dist/tui/bin.js +7 -9
  106. package/dist/tui/bin.js.map +1 -1
  107. package/dist/tui/index.d.ts +3 -5
  108. package/dist/tui/index.js +2 -2
  109. package/dist/{types-hc4cmSc7.d.ts → types-Fowuwdz2.d.ts} +555 -503
  110. package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
  111. package/dist/workspace-store/index.d.ts +12 -22
  112. package/dist/workspace-store/index.js +4 -7
  113. package/dist/workspace-store/index.js.map +1 -1
  114. package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
  115. package/package.json +25 -25
  116. package/skills/agent-graphs/SKILL.md +19 -4
  117. package/skills/be-ambitious/SKILL.md +46 -0
  118. package/skills/graph-designer/SKILL.md +15 -2
  119. package/skills/profile-authoring/SKILL.md +1 -1
  120. package/dist/coordination-manager-Bm6leXc6.js.map +0 -1
  121. package/dist/delegate-Cp5-PsaX.js.map +0 -1
  122. package/dist/graph-CE_pzU31.js.map +0 -1
  123. package/dist/model-policy-CyCUwHed.js.map +0 -1
  124. package/dist/profile-6OLpbjvV.js.map +0 -1
  125. package/dist/runtime-B_40dXlF.js.map +0 -1
  126. package/dist/sandbox-profile-compat-_fEtHPCj.js.map +0 -1
  127. package/dist/search-executor-COd2F2wp.js.map +0 -1
  128. package/dist/structural-rollout-Wl_rCuzM.js.map +0 -1
  129. package/dist/supervise-BUOeThuB.js.map +0 -1
  130. package/dist/supervisor-DDy0aEtR.js.map +0 -1
@@ -1,13 +1,13 @@
1
- import { i as ConfigError } from "./errors-DodWX-cb.js";
2
- import { t as supervise } from "./supervise-BUOeThuB.js";
1
+ import { i as ConfigError } from "./errors-wuhGvpE3.js";
2
+ import { t as supervise } from "./supervise-CaeZcgAW.js";
3
3
  import { agentProfileSchema } from "@tangle-network/agent-interface";
4
4
  import { computeFindingId, makeFinding } from "@tangle-network/agent-eval";
5
- //#region src/runtime/supervise/authoring.ts
5
+ // src/runtime/supervise/authoring.ts
6
6
  /**
7
7
  *
8
8
  * The supervisor's intelligence is AUTHORING the agents it spawns — not pressing buttons.
9
9
  *
10
- * Every agent here is three things: instructions (system prompt), tools, and a model — its
10
+ * Every agent here is three things: instructions, tools, and a model — its
11
11
  * `AgentProfile`. The supervisor's job is to WRITE those profiles: read the task, decompose it,
12
12
  * and for each sub-task author a tailored worker recipe. `supervisorInstructions` is the how-to the
13
13
  * supervisor reads; canonical Runtime executors materialize the resulting profile.
@@ -22,15 +22,11 @@ import { computeFindingId, makeFinding } from "@tangle-network/agent-eval";
22
22
  function asAuthoredProfile(raw) {
23
23
  const parsed = agentProfileSchema.safeParse(raw);
24
24
  if (!parsed.success) return null;
25
- const systemPrompt = parsed.data.prompt?.systemPrompt;
26
- if (typeof systemPrompt !== "string" || systemPrompt.trim().length === 0) return null;
25
+ if (!resolveSystemPrompt(parsed.data).trim()) return null;
27
26
  return {
28
27
  ...parsed.data,
29
28
  name: typeof parsed.data.name === "string" && parsed.data.name.length > 0 ? parsed.data.name : "worker",
30
- prompt: {
31
- ...parsed.data.prompt,
32
- systemPrompt
33
- }
29
+ prompt: { ...parsed.data.prompt }
34
30
  };
35
31
  }
36
32
  /** The supervisor skill: an explicit profile-authoring instruction, never an implicit Runtime
@@ -43,7 +39,7 @@ function supervisorInstructions(opts) {
43
39
  "1. DECOMPOSE it into the smallest set of sub-tasks a single focused worker can each deliver.",
44
40
  "2. For EACH sub-task, AUTHOR a worker by calling spawn_worker with a COMPLETE `profile`:",
45
41
  " • name and description: who this specialist is and why it exists.",
46
- " • prompt.systemPrompt: rich instructions for THIS sub-task — exact output, process, evidence, and what \"done\" means.",
42
+ " • prompt.appendSystemPrompt: rich additive instructions for THIS sub-task — exact output, process, evidence, and what \"done\" means.",
47
43
  " • model.default, model.reasoningEffort, and harness: choose the execution system deliberately when the task benefits from it.",
48
44
  " • tools, mcp, resources.skills/files/instructions, hooks, subagents, permissions, and modes: grant or attach every capability the worker needs; omit an axis only when it is intentionally unnecessary.",
49
45
  " • tools.agent_runtime_coordination_spawn_worker: true ONLY when this child should author and drive descendants. Add only the other agent_runtime_coordination_<verb> tools it will call, such as observe_agent or steer_agent.",
@@ -51,7 +47,7 @@ function supervisorInstructions(opts) {
51
47
  " • metadata may describe the work, but it never grants recursion or selects a Runtime execution path.",
52
48
  " NEVER spawn a worker with an empty profile. The quality of the worker IS the quality of the profile you write.",
53
49
  "3. End your turn while your workers run: Runtime wakes you with each settled worker. A settlement says valid:true only if the deployable check passed.",
54
- "4. If a worker did NOT deliver, AUTHOR A NEW profile whose prompt.systemPrompt names the SPECIFIC failure and how to fix it — never just retry the same profile.",
50
+ "4. If a worker did NOT deliver, AUTHOR A NEW profile whose prompt.appendSystemPrompt names the SPECIFIC failure and how to fix it — never just retry the same profile.",
55
51
  "5. read_journal to re-read YOUR OWN record before you decide the next move: every spawn you made, every settle, every question and answer, every steer, every analyst finding — oldest first, this node only, including what you did before a restart. Use it to see what you already tried instead of trying it again. It is paged: pass the returned nextRow as the next call's sinceRow, narrow with kinds, and raise limit/maxBytes only as far as you will actually read. A truncated:true page means a bound cut it short — keep paging before you conclude you have read everything.",
56
52
  "6. AUTHOR YOUR OWN LENS when the questions you can already ask of a settled trace do not cover the failure you are chasing: define_analyst takes an id, a description, an area, the question in your own words, the instructions for answering it with trace evidence, and the smallest toolGroup that can answer it (model is the seat it runs on; omit it for the run default). It is DATA, never code. Then run_analyst it on any settled worker like a lens the run shipped with, and read the finding. list_analysts shows what you have. Define a lens when you need a different question asked — not a second copy of a question already on the menu.",
57
53
  "7. EVERY refusal you get back carries a `reason` naming the exact unmet condition. Read it and change that condition — a spawn refused for budget-exhausted needs a smaller budget or the refund of a settled worker, an invalid-profile needs the named field fixed, a submit_result refused because the check THREW is a broken check to report, not a result to resubmit. Never repeat a call that was refused without changing what it was refused for.",
@@ -65,15 +61,18 @@ const defaultProfileRichnessThresholds = {
65
61
  minSystemPromptChars: 600,
66
62
  minSystemPromptLines: 6
67
63
  };
68
- /** Read the system prompt from any authored shape: canonical `prompt.systemPrompt`, the sandbox
69
- * `prompt.system` convention, or a bare-string `prompt`. */
64
+ /** Read authored guidance without requiring replacement of native coding instructions. */
70
65
  function resolveSystemPrompt(profile) {
71
66
  const pr = profile.prompt;
72
67
  if (typeof pr === "string") return pr;
73
68
  if (pr && typeof pr === "object") {
74
69
  const o = pr;
75
- if (typeof o.systemPrompt === "string") return o.systemPrompt;
76
- if (typeof o.system === "string") return o.system;
70
+ return [
71
+ Reflect.get(o, "systemPrompt"),
72
+ Reflect.get(o, "appendSystemPrompt"),
73
+ ...Array.isArray(Reflect.get(o, "instructions")) ? Reflect.get(o, "instructions") : [],
74
+ Reflect.get(o, "system")
75
+ ].filter((value) => typeof value === "string").join("\n\n");
77
76
  }
78
77
  return "";
79
78
  }
@@ -136,9 +135,10 @@ function profileRichnessFinding(richness, opts) {
136
135
  const analyst_id = opts?.analystId ?? "profile-richness";
137
136
  const subject = richness.name;
138
137
  const claim = richness.thin ? `Worker "${richness.name}" was authored as a THIN profile: ${richness.reasons.join("; ")}.` : `Worker "${richness.name}" was authored as a rich profile (richness ${(richness.richness * 100).toFixed(0)}%).`;
138
+ const severity = richness.thin ? richness.richness < .25 ? "high" : "medium" : "info";
139
139
  return makeFinding({
140
140
  analyst_id,
141
- severity: richness.thin ? richness.richness < .25 ? "high" : "medium" : "info",
141
+ severity,
142
142
  area: "profile-quality",
143
143
  claim,
144
144
  subject,
@@ -157,8 +157,7 @@ function profileRichnessFinding(richness, opts) {
157
157
  })
158
158
  });
159
159
  }
160
- //#endregion
161
- //#region src/runtime/supervise/delegate.ts
160
+ // src/runtime/supervise/delegate.ts
162
161
  /**
163
162
  *
164
163
  * `delegate` — the one generic delegation verb. You hand it an INTENT (what you want done) and it
@@ -204,7 +203,6 @@ async function delegate(intent, opts) {
204
203
  ...opts.runId ? { runId: opts.runId } : {}
205
204
  });
206
205
  }
207
- //#endregion
208
206
  export { defaultProfileRichnessThresholds as a, assessAuthoredProfile as i, delegate as n, profileRichnessFinding as o, asAuthoredProfile as r, supervisorInstructions as s, defaultDelegateBudget as t };
209
207
 
210
- //# sourceMappingURL=delegate-Cp5-PsaX.js.map
208
+ //# sourceMappingURL=delegate-DgEie4ad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegate-DgEie4ad.js","names":[],"sources":["../src/runtime/supervise/authoring.ts","../src/runtime/supervise/delegate.ts"],"sourcesContent":["/**\n *\n * The supervisor's intelligence is AUTHORING the agents it spawns — not pressing buttons.\n *\n * Every agent here is three things: instructions, tools, and a model — its\n * `AgentProfile`. The supervisor's job is to WRITE those profiles: read the task, decompose it,\n * and for each sub-task author a tailored worker recipe. `supervisorInstructions` is the how-to the\n * supervisor reads; canonical Runtime executors materialize the resulting profile.\n *\n * The skill is the single OPTIMIZABLE surface: edit it → the supervisor designs better agents.\n * That is the self-improvement lever (the prompt/skill lever), not the execution plumbing.\n *\n * @experimental\n */\n\nimport { type AnalystFinding, computeFindingId, makeFinding } from '@tangle-network/agent-eval'\nimport {\n type AgentProfile,\n type AgentProfilePrompt,\n agentProfileSchema,\n} from '@tangle-network/agent-interface'\n\n/** What the supervisor AUTHORS per sub-task: one complete canonical profile whose name and\n * task-specific guidance are present. Every other `AgentProfile` axis is preserved exactly. */\nexport type AuthoredProfile = AgentProfile & {\n readonly name: string\n readonly prompt: AgentProfilePrompt\n}\n\n/** Narrow an untyped `spawn_worker` profile argument to an `AuthoredProfile`, or null if the\n * supervisor failed to author one (empty/placeholder profile — a skill violation worth catching). */\nexport function asAuthoredProfile(raw: unknown): AuthoredProfile | null {\n const parsed = agentProfileSchema.safeParse(raw)\n if (!parsed.success) return null\n if (!resolveSystemPrompt(parsed.data).trim()) return null\n return {\n ...parsed.data,\n name:\n typeof parsed.data.name === 'string' && parsed.data.name.length > 0\n ? parsed.data.name\n : 'worker',\n prompt: { ...parsed.data.prompt },\n }\n}\n\n/** The supervisor skill: an explicit profile-authoring instruction, never an implicit Runtime\n * policy. Editing this text changes how a profile designs the descendants it spawns. */\nexport function supervisorInstructions(opts?: { goal?: string }): string {\n return [\n 'Your delegation craft is AUTHORING: a spawned worker is exactly as good as the profile you write.',\n '',\n 'For the task you are given:',\n '1. DECOMPOSE it into the smallest set of sub-tasks a single focused worker can each deliver.',\n '2. For EACH sub-task, AUTHOR a worker by calling spawn_worker with a COMPLETE `profile`:',\n ' • name and description: who this specialist is and why it exists.',\n ' • prompt.appendSystemPrompt: rich additive instructions for THIS sub-task — exact output, process, evidence, and what \"done\" means.',\n ' • model.default, model.reasoningEffort, and harness: choose the execution system deliberately when the task benefits from it.',\n ' • tools, mcp, resources.skills/files/instructions, hooks, subagents, permissions, and modes: grant or attach every capability the worker needs; omit an axis only when it is intentionally unnecessary.',\n ' • tools.agent_runtime_coordination_spawn_worker: true ONLY when this child should author and drive descendants. Add only the other agent_runtime_coordination_<verb> tools it will call, such as observe_agent or steer_agent.',\n ' • A child with spawn_worker MUST carry this complete profile-authoring instruction as an immutable resources.skills entry with resources.failOnError: true, so it can author its own descendants from the same contract.',\n ' • metadata may describe the work, but it never grants recursion or selects a Runtime execution path.',\n ' NEVER spawn a worker with an empty profile. The quality of the worker IS the quality of the profile you write.',\n '3. End your turn while your workers run: Runtime wakes you with each settled worker. A settlement says valid:true only if the deployable check passed.',\n '4. If a worker did NOT deliver, AUTHOR A NEW profile whose prompt.appendSystemPrompt names the SPECIFIC failure and how to fix it — never just retry the same profile.',\n \"5. read_journal to re-read YOUR OWN record before you decide the next move: every spawn you made, every settle, every question and answer, every steer, every analyst finding — oldest first, this node only, including what you did before a restart. Use it to see what you already tried instead of trying it again. It is paged: pass the returned nextRow as the next call's sinceRow, narrow with kinds, and raise limit/maxBytes only as far as you will actually read. A truncated:true page means a bound cut it short — keep paging before you conclude you have read everything.\",\n '6. AUTHOR YOUR OWN LENS when the questions you can already ask of a settled trace do not cover the failure you are chasing: define_analyst takes an id, a description, an area, the question in your own words, the instructions for answering it with trace evidence, and the smallest toolGroup that can answer it (model is the seat it runs on; omit it for the run default). It is DATA, never code. Then run_analyst it on any settled worker like a lens the run shipped with, and read the finding. list_analysts shows what you have. Define a lens when you need a different question asked — not a second copy of a question already on the menu.',\n '7. EVERY refusal you get back carries a `reason` naming the exact unmet condition. Read it and change that condition — a spawn refused for budget-exhausted needs a smaller budget or the refund of a settled worker, an invalid-profile needs the named field fixed, a submit_result refused because the check THREW is a broken check to report, not a result to resubmit. Never repeat a call that was refused without changing what it was refused for.',\n '8. ask_parent ONLY when you genuinely cannot decide, and then READ ITS OUTCOME. \"queued-for-parent\" means an inbox above you now holds the question. \"no-parent\" means no inbox above you is configured to receive it: the question is still on the run record for anyone watching, but nothing will route an answer back to you, so do not block. Decide it with answer_question, or answer_question with deferReason to record that it stays open, and carry on — a blocking question left undecided also refuses your stop.',\n '9. Once the work is delivered, end your turn with nothing left running.',\n ...(opts?.goal ? ['', `The goal: ${opts.goal}`] : []),\n ].join('\\n')\n}\n\n// ── Profile-richness gate ────────────────────────────────────────────────────\n//\n// The supervisor's product is the worker PROFILE it authors. The failure mode the existing\n// gates miss: `asAuthoredProfile` / `local-harness` only reject a FULLY EMPTY system prompt —\n// a two-sentence stub passes. `assessAuthoredProfile` OBSERVES the authored artifact (it reads\n// no judge verdict, so it steers cleanly past `assertTraceDerivedFindings`) and flags THIN:\n// a short/few-line system prompt, OR no tools, OR no skills, OR no MCP when the task needs one.\n// It emits a real `AnalystFinding` so it rides the SAME coordination bus the driver pulls via\n// receives in its next wake — the supervisor can self-correct and re-author richer.\n\n/** Thresholds below which a system prompt is treated as a thin stub. Tunable per call. */\nexport interface ProfileRichnessThresholds {\n /** A prompt shorter than this many characters is thin (default 600). */\n readonly minSystemPromptChars: number\n /** A prompt with fewer than this many non-blank lines is thin (default 6). */\n readonly minSystemPromptLines: number\n}\n\n/** Default thresholds for `ProfileRichnessThresholds` — 600 chars / 6 lines minimum system prompt. */\nexport const defaultProfileRichnessThresholds: ProfileRichnessThresholds = {\n minSystemPromptChars: 600,\n minSystemPromptLines: 6,\n}\n\n/** Per-field verdict on one authored profile — the raw material the bench renders + scores. */\nexport interface ProfileRichness {\n readonly name: string\n /** Resolved authored guidance from replacement, addition and instruction sections. */\n readonly systemPrompt: string\n readonly systemPromptChars: number\n readonly systemPromptLines: number\n readonly sentenceCount: number\n readonly hasDescription: boolean\n readonly hasTools: boolean\n readonly hasSkills: boolean\n readonly hasMcp: boolean\n readonly hasSubagents: boolean\n /** 0..1 — fraction of richness signals present (prompt-depth + the four levers). */\n readonly richness: number\n /** True when the supervisor authored a stub instead of a real profile. */\n readonly thin: boolean\n /** The specific reasons it is thin (empty when rich) — used in the finding's action. */\n readonly reasons: string[]\n}\n\n/** Read authored guidance without requiring replacement of native coding instructions. */\nfunction resolveSystemPrompt(profile: AgentProfile): string {\n const pr = (profile as { prompt?: unknown }).prompt\n if (typeof pr === 'string') return pr\n if (pr && typeof pr === 'object') {\n const o = pr as { systemPrompt?: unknown; system?: unknown }\n return [\n Reflect.get(o, 'systemPrompt'),\n Reflect.get(o, 'appendSystemPrompt'),\n ...(Array.isArray(Reflect.get(o, 'instructions')) ? Reflect.get(o, 'instructions') : []),\n Reflect.get(o, 'system'),\n ]\n .filter((value) => typeof value === 'string')\n .join('\\n\\n')\n }\n return ''\n}\n\n/** OBSERVE one authored `AgentProfile` and score its richness (no judge verdict is read). The task\n * context (`needsMcp`) lets a domain say \"this work needs a data/tool MCP\" so a missing MCP counts. */\nexport function assessAuthoredProfile(\n profile: AgentProfile,\n opts?: { needsMcp?: boolean; thresholds?: Partial<ProfileRichnessThresholds> },\n): ProfileRichness {\n const th = { ...defaultProfileRichnessThresholds, ...(opts?.thresholds ?? {}) }\n const systemPrompt = resolveSystemPrompt(profile)\n const trimmed = systemPrompt.trim()\n const systemPromptChars = trimmed.length\n const systemPromptLines = trimmed\n ? trimmed.split('\\n').filter((l) => l.trim().length > 0).length\n : 0\n const sentenceCount = trimmed\n ? (trimmed.match(/[.!?](\\s|$)/g) ?? []).length || (trimmed ? 1 : 0)\n : 0\n const hasDescription =\n typeof profile.description === 'string' && profile.description.trim().length > 0\n const tools = (profile as { tools?: Record<string, unknown> }).tools\n const hasTools = !!tools && Object.keys(tools).length > 0\n const skills = (profile.resources as { skills?: unknown[] } | undefined)?.skills\n const hasSkills = Array.isArray(skills) && skills.length > 0\n const mcp = (profile as { mcp?: Record<string, unknown> }).mcp\n const hasMcp = !!mcp && Object.keys(mcp).length > 0\n const subagents = (profile as { subagents?: Record<string, unknown> }).subagents\n const hasSubagents = !!subagents && Object.keys(subagents).length > 0\n\n const reasons: string[] = []\n const promptThin =\n systemPromptChars < th.minSystemPromptChars || systemPromptLines < th.minSystemPromptLines\n if (promptThin)\n reasons.push(\n `system prompt is thin (${systemPromptChars} chars, ${systemPromptLines} lines; need ≥${th.minSystemPromptChars} chars and ≥${th.minSystemPromptLines} lines)`,\n )\n if (!hasTools)\n reasons.push('no tools granted (a worker can only act through the tools you grant it)')\n if (!hasSkills) reasons.push('no skills attached (no reusable how-to notes injected)')\n if (opts?.needsMcp && !hasMcp) reasons.push('no MCP server, but the task needs data/tool access')\n\n // Richness = fraction of signals present. Prompt-depth is one signal; the four levers are the rest.\n const signals = [!promptThin, hasTools, hasSkills, hasDescription, opts?.needsMcp ? hasMcp : true]\n const richness = signals.filter(Boolean).length / signals.length\n // THIN ⟺ the prompt is a stub OR the worker has no levers at all (no tools AND no skills AND no mcp).\n const thin = promptThin || (!hasTools && !hasSkills && !hasMcp)\n\n return {\n name: profile.name ?? 'worker',\n systemPrompt,\n systemPromptChars,\n systemPromptLines,\n sentenceCount,\n hasDescription,\n hasTools,\n hasSkills,\n hasMcp,\n hasSubagents,\n richness,\n thin,\n reasons,\n }\n}\n\n/** Turn a {@link ProfileRichness} verdict into a bus-routable `AnalystFinding` (area `profile-quality`).\n * Severity scales with thinness; the recommended action names the MISSING lever so the supervisor can\n * re-author. `subject` = the worker name so per-worker findings diff cleanly across re-authors. */\nexport function profileRichnessFinding(\n richness: ProfileRichness,\n opts?: { analystId?: string; runId?: string },\n): AnalystFinding {\n const analyst_id = opts?.analystId ?? 'profile-richness'\n const subject = richness.name\n const claim = richness.thin\n ? `Worker \"${richness.name}\" was authored as a THIN profile: ${richness.reasons.join('; ')}.`\n : `Worker \"${richness.name}\" was authored as a rich profile (richness ${(richness.richness * 100).toFixed(0)}%).`\n const severity: AnalystFinding['severity'] = richness.thin\n ? richness.richness < 0.25\n ? 'high'\n : 'medium'\n : 'info'\n return makeFinding({\n analyst_id,\n severity,\n area: 'profile-quality',\n claim,\n subject,\n confidence: 0.9,\n evidence_refs: [\n {\n kind: 'metric',\n uri: `profile:${subject}`,\n excerpt: `chars=${richness.systemPromptChars} lines=${richness.systemPromptLines} tools=${richness.hasTools} skills=${richness.hasSkills} mcp=${richness.hasMcp} richness=${richness.richness.toFixed(2)}`,\n },\n ],\n ...(richness.thin\n ? { recommended_action: `Re-author \"${richness.name}\" with: ${richness.reasons.join('; ')}.` }\n : {}),\n id_basis: computeFindingId({\n analyst_id,\n area: 'profile-quality',\n subject,\n claim: `richness:${richness.thin ? 'thin' : 'rich'}`,\n }),\n })\n}\n","/**\n *\n * `delegate` — the one generic delegation verb. You hand it an INTENT (what you want done) and it\n * hands that intent to a default AUTHORING supervisor: a router-brained supervisor whose standing\n * instruction is `supervisorInstructions()` (the authoring-agent-profiles skill). The supervisor\n * DECOMPOSES the intent and AUTHORS the worker profile it needs per sub-task — there is NO hardcoded\n * coder/researcher profile here. That is the whole point: `delegate('fix the failing test', …)` and\n * `delegate('research X and cite sources', …)` route through the SAME front door; the supervisor\n * writes a code-shaped or research-shaped worker on its own.\n *\n * It is a thin wrapper over `supervise()` — the one front door — so the conserved-budget pool, the\n * completion oracle (`deliverable`), the coordination toolbox, and equal-compute accounting all come\n * for free; nothing is hand-rolled. The result is `supervise()`'s `SupervisedResult` returned\n * UNCHANGED, so its `spentTotal` (`{ iterations, tokens, usd, ms }`) rides straight back to the\n * caller on BOTH paths — a `winner` carries the delivered worker's spend, a `no-winner` carries the\n * spend incurred before it failed. That cost channel means a `delegate()` caller always learns what\n * the delegation actually spent.\n *\n * @experimental\n */\n\nimport { ConfigError } from '../../errors'\nimport type { RouterTransportConfig } from '../router-http-transport'\nimport type { DeliverableSpec } from './completion-gate'\nimport type { ExecutorConfig } from './runtime'\nimport { supervise } from './supervise'\nimport type { SupervisorProfile } from './supervisor-agent'\nimport type { Budget, SupervisedResult } from './types'\n\n/** The conserved pool a `delegate()` call applies when the caller does not pass its own `budget`.\n * A modest token ceiling + a small iteration ceiling — generous enough for a few-worker decompose,\n * bounded enough that an unsupervised intent cannot run away. Callers override via `opts.budget`. */\nexport const defaultDelegateBudget: Budget = { maxIterations: 50, maxTokens: 200_000 }\n\n/** Inputs to {@link delegate}. The intent is the first positional arg; everything here is optional\n * with explicit execution identity, so the common call names one exact supervisor profile. */\nexport interface DelegateOptions<Out = unknown> {\n /** The completion oracle (settled ⟺ delivered) the authored workers settle against. Strongly\n * recommended — without it the supervisor trusts a worker's self-report. For a code intent,\n * `patchDelivered()` is the canonical example; for a free-form answer, a content check. */\n readonly deliverable?: DeliverableSpec<Out>\n /** WHERE the authored workers run — the worker-execution backend (`router-tools` / `sandbox` /\n * `cli-worktree` / …). The supervisor authors the worker PROFILE; this is the substrate it runs\n * on. Provide this OR `makeWorkerAgent`-style wiring through `supervise()` is unavailable. */\n readonly backend?: ExecutorConfig\n /** The conserved compute pool for the whole delegation. Defaults to {@link defaultDelegateBudget}. */\n readonly budget?: Budget\n /** Exact executable authoring supervisor. Model, prompt, harness, and provider live here. */\n readonly supervisorProfile: SupervisorProfile\n /** Router endpoint/auth for a `cli-base` supervisor; contains no behavioral settings. */\n readonly router: RouterTransportConfig\n /** Restrict the run to this subset of models (forwarded to `supervise()`). */\n readonly allowedModels?: readonly string[]\n readonly runId?: string\n}\n\n/**\n * Delegate an INTENT to a default authoring supervisor and return its `SupervisedResult` unchanged.\n *\n * The supervisor authors + spawns whatever worker the intent needs over the conserved-budget pool;\n * `result.spentTotal` reports what the whole delegation actually cost. A `winner` result carries the\n * authored worker's delivered output; a `no-winner` result names why (never a fabricated success).\n */\nexport async function delegate<Out = unknown>(\n intent: string,\n opts: DelegateOptions<Out>,\n): Promise<SupervisedResult<Out>> {\n if (typeof intent !== 'string' || intent.trim().length === 0) {\n throw new ConfigError('delegate: `intent` must be a non-empty string')\n }\n return supervise(opts.supervisorProfile, intent, {\n budget: opts.budget ?? defaultDelegateBudget,\n ...(opts.backend ? { backend: opts.backend } : {}),\n ...(opts.deliverable ? { deliverable: opts.deliverable as DeliverableSpec<unknown> } : {}),\n router: opts.router,\n ...(opts.allowedModels ? { allowedModels: opts.allowedModels } : {}),\n ...(opts.runId ? { runId: opts.runId } : {}),\n }) as Promise<SupervisedResult<Out>>\n}\n"],"mappings":"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"}
package/dist/durable.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { $f as CoordinationAuthentication, $l as NextPursuitVersionInput, Ad as SelectSeat, Au as observerRecordDigest, Bv as DownMessageAuthorizationInput, Cu as PursuitRunTotals, D as RetainedPendingCause, Dd as SeatSelection, Df as ManagerWakePolicy, Du as ObserverJournal, Dv as QuestionEscalationOutcome, Eu as FileObserverJournal, Gd as DeadlineCheckIn, Jd as RunParkingPolicy, Kd as ParkedRun, Kv as MapOnSettleRoute, Lv as AuthorizedDownMessage, My as AnalyzeOnSettleRoute, Od as SeatSelectionInput, Ou as ObserverRecord, Ql as NextPursuitVersion, Su as PursuitRunProjection, Tu as projectPursuit, V as NodeId, Xd as readRunParking, Yd as RunParkingRecord, Zl as JudgedPursuitVersion, _f as DriveHarnessOwnerContext, _u as PursuitNodePlatform, ad as RUN_FORK_CORRELATION_KEYS, ap as CoordinationHttpAudit, au as VersionVerdict, bu as PursuitNodeUsage, cu as SupervisePursuitError, dd as AuthorizedSpawnContext, df as readRootStreamReceipt, du as superviseGraphPursuit, eh as ToolLoopCompactionOptions, eu as PursuitVersionChain, fu as supervisePursuit, gu as PursuitNodeCost, hu as PursuitCostProvenance, id as PursuitFork, it as SupervisedResult, iu as VersionJudge, ku as ObserverRecordKind, lf as RootStreamRecord, lu as SupervisePursuitOptions, md as WorkerSlots, mu as PursuitObserverDelivery, mv as WorkerWatchOptions, np as CoordinationReadAccess, nu as PursuitVersions, op as CoordinationRejectReason, ou as assertPursuitVersions, pu as RunReopen, qd as RunParkedError, rp as CoordinationTransportOptions, rt as RootStreamReceipt, ru as SettledPursuitVersion, su as SuperviseGraphPursuitOptions, tp as CoordinationPublicAddress, tu as PursuitVersionStop, ud as AuthorizedSpawn, uf as readRootStream, uu as SupervisedPursuitResult, vu as PursuitNodeProjection, wu as PursuitStatus, wv as EscalateQuestion, xu as PursuitProjection, yf as ResolveDriveHarness, yu as PursuitNodeTiming, zv as ContinuityMode } from "./types-hc4cmSc7.js";
2
- import { n as RuntimeDecisionKind, r as RuntimeDecisionPoint, t as RuntimeDecisionEvidenceRef } from "./runtime-hooks-nsqxSUFL.js";
1
+ import { $d as SeatSelectionInput, $u as observerRecordDigest, Ad as RUN_FORK_CORRELATION_KEYS, Au as SuperviseGraphPursuitOptions, Bu as PursuitNodePlatform, Cu as PursuitVersionChain, D as RetainedPendingCause, Dp as CoordinationPublicAddress, Du as VersionJudge, Eh as ToolLoopCompactionOptions, Eu as SettledPursuitVersion, Fd as AuthorizedSpawn, Ff as readRootStream, Fu as supervisePursuit, Gu as PursuitRunProjection, Hf as DriveHarnessOwnerContext, Hu as PursuitNodeTiming, Id as AuthorizedSpawnContext, If as readRootStreamReceipt, Iu as RunReopen, Ju as projectPursuit, Ku as PursuitRunTotals, Lu as PursuitObserverDelivery, Mp as CoordinationRejectReason, Mu as SupervisePursuitOptions, Nu as SupervisedPursuitResult, Op as CoordinationReadAccess, Ou as VersionVerdict, Pf as RootStreamRecord, Pu as superviseGraphPursuit, Qd as SeatSelection, Qf as ManagerWakePolicy, Qu as ObserverRecordKind, Ru as PursuitCostProvenance, Su as NextPursuitVersionInput, Tu as PursuitVersions, Uu as PursuitNodeUsage, V as NodeId, Vu as PursuitNodeProjection, Vv as WorkerWatchOptions, Wf as ResolveDriveHarness, Wu as PursuitProjection, Xu as ObserverJournal, Yu as FileObserverJournal, Zu as ObserverRecord, Zv as EscalateQuestion, _f as ParkedRun, ab as AnalyzeOnSettleRoute, bf as RunParkingRecord, bu as JudgedPursuitVersion, ey as QuestionEscalationOutcome, fy as ContinuityMode, gf as DeadlineCheckIn, it as SupervisedResult, jp as CoordinationHttpAudit, ju as SupervisePursuitError, kd as PursuitFork, kp as CoordinationTransportOptions, ku as assertPursuitVersions, py as DownMessageAuthorizationInput, qu as PursuitStatus, rt as RootStreamReceipt, tf as SelectSeat, uy as AuthorizedDownMessage, vf as RunParkedError, wp as CoordinationAuthentication, wu as PursuitVersionStop, xf as readRunParking, xu as NextPursuitVersion, yf as RunParkingPolicy, yy as MapOnSettleRoute, zd as WorkerSlots, zu as PursuitNodeCost } from "./types-Fowuwdz2.js";
2
+ import { n as RuntimeDecisionKind, r as RuntimeDecisionPoint, t as RuntimeDecisionEvidenceRef } from "./runtime-hooks-ZQqPw-0g.js";
3
3
  import { LockIdentity } from "@tangle-network/agent-eval/lock-holder";
4
- //#region src/durable/chat-engine.d.ts
5
4
  /**
6
5
  * `handleChatTurn` is a framework-neutral chat-turn HTTP orchestrator.
7
6
  * Owns the NDJSON `ChatStreamEvent` line protocol, the `session.run.*`
@@ -100,9 +99,7 @@ interface ChatTurnResult {
100
99
  * execution starts while the stream is constructed. Backend
101
100
  * failures surface as `error` + `session.run.failed` events.
102
101
  */
103
- declare function handleChatTurn(input: RunChatTurnInput): ChatTurnResult;
104
- //#endregion
105
- //#region src/durable/execution-handle.d.ts
102
+ export declare function handleChatTurn(input: RunChatTurnInput): ChatTurnResult;
106
103
  /**
107
104
  * Derive a stable execution id from the run identity.
108
105
  * The same `(projectId, sessionId, turnIndex)` tuple yields the same id.
@@ -127,13 +124,11 @@ declare function handleChatTurn(input: RunChatTurnInput): ChatTurnResult;
127
124
  * @throws `TypeError` when either string id is blank.
128
125
  * @throws `RangeError` when `turnIndex` is invalid or the result exceeds 256 bytes.
129
126
  */
130
- declare function deriveExecutionId(input: {
127
+ export declare function deriveExecutionId(input: {
131
128
  projectId: string;
132
129
  sessionId: string;
133
130
  turnIndex: number;
134
131
  }): string;
135
- //#endregion
136
- //#region src/durable/run-lock.d.ts
137
132
  /** What the lock file records about its holder. */
138
133
  interface RunDirectoryLockHolder {
139
134
  readonly pid: number;
@@ -160,7 +155,7 @@ interface RunDirectoryLock extends RunDirectoryLockHolder {
160
155
  release(): Promise<void>;
161
156
  }
162
157
  /** The directory is held by a live process. `holder` is what that process recorded. */
163
- declare class RunDirectoryLockedError extends Error {
158
+ export declare class RunDirectoryLockedError extends Error {
164
159
  readonly path: string;
165
160
  readonly holder: RunDirectoryLockHolder;
166
161
  constructor(path: string, holder: RunDirectoryLockHolder);
@@ -175,9 +170,9 @@ declare class RunDirectoryLockedError extends Error {
175
170
  * names no holder and is reclaimed. A file with unreadable content is left in place and refused:
176
171
  * reclaiming it could evict a live holder written by something other than this module.
177
172
  */
178
- declare function acquireRunDirectoryLock(runDir: string, runId: string, now?: () => number): Promise<RunDirectoryLock>;
173
+ export declare function acquireRunDirectoryLock(runDir: string, runId: string, now?: () => number): Promise<RunDirectoryLock>;
179
174
  /** Read the holder a lock file names, or `undefined` when no lock file names one. */
180
- declare function readRunDirectoryLock(runDir: string): Promise<RunDirectoryLockHolder | undefined>;
175
+ export declare function readRunDirectoryLock(runDir: string): Promise<RunDirectoryLockHolder | undefined>;
181
176
  /** What {@link runDirectoryHolderIsLive} proved about a run directory's recorded holder. */
182
177
  interface RunDirectoryHolderLiveness {
183
178
  /** False only when the holder that took the lock is proved dead; a holder that cannot be proved dead reads as live. */
@@ -200,9 +195,7 @@ interface RunDirectoryHolderLiveness {
200
195
  * TAKE the directory calls `acquireRunDirectoryLock`, which evaluates the same rule under the
201
196
  * guard and refuses atomically.
202
197
  */
203
- declare function runDirectoryHolderIsLive(runDir: string): Promise<RunDirectoryHolderLiveness>;
204
- //#endregion
205
- //#region src/durable/settle-record.d.ts
198
+ export declare function runDirectoryHolderIsLive(runDir: string): Promise<RunDirectoryHolderLiveness>;
206
199
  /** What `failure.json` records about the most recent throw. */
207
200
  interface DurableFailureRecord {
208
201
  readonly runId: string;
@@ -218,7 +211,7 @@ interface DurableFailureRecord {
218
211
  readonly rootStream?: RootStreamReceipt;
219
212
  }
220
213
  /** The directory already holds a settle record, so the run it records must not be re-entered. */
221
- declare class SettledRunDirectoryError extends Error {
214
+ export declare class SettledRunDirectoryError extends Error {
222
215
  readonly path: string;
223
216
  /** The root of the recorded run, which is its `runId`. */
224
217
  readonly recordedRunId: string;
@@ -228,11 +221,9 @@ declare class SettledRunDirectoryError extends Error {
228
221
  * Read the settle record a run directory holds, or `undefined` when it holds none. A file that
229
222
  * is present but is not a settle record is corruption and fails loud.
230
223
  */
231
- declare function readSettleRecord(runDir: string): Promise<SupervisedResult<unknown> | undefined>;
224
+ export declare function readSettleRecord(runDir: string): Promise<SupervisedResult<unknown> | undefined>;
232
225
  /** Read the most recent failure record, or `undefined` when the directory holds none. */
233
- declare function readFailureRecord(runDir: string): Promise<DurableFailureRecord | undefined>;
234
- //#endregion
235
- //#region src/durable/supervision-discovery.d.ts
226
+ export declare function readFailureRecord(runDir: string): Promise<DurableFailureRecord | undefined>;
236
227
  interface DurableCoordinationStreamIdentity {
237
228
  readonly runId: string;
238
229
  /** Exact owner ids present in the side-log, sorted for deterministic display. */
@@ -264,7 +255,6 @@ interface DurableSupervisionDiscovery {
264
255
  * still fails loud through the same parser used by the runtime; a torn final
265
256
  * append is ignored because it was never acknowledged as committed.
266
257
  */
267
- declare function discoverDurableSupervisionRun(runDir: string): Promise<DurableSupervisionDiscovery>;
268
- //#endregion
269
- export { type AnalyzeOnSettleRoute, type AuthorizedDownMessage, type AuthorizedSpawn, type AuthorizedSpawnContext, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, type ContinuityMode, type CoordinationAuthentication, type CoordinationHttpAudit, type CoordinationPublicAddress, type CoordinationReadAccess, type CoordinationRejectReason, type CoordinationTransportOptions, type DeadlineCheckIn, type DownMessageAuthorizationInput, type DriveHarnessOwnerContext, type DurableCoordinationStreamIdentity, type DurableFailureRecord, type DurableSupervisionDiscovery, type EscalateQuestion, FileObserverJournal, type JudgedPursuitVersion, type ManagerWakePolicy, type MapOnSettleRoute, type NextPursuitVersion, type NextPursuitVersionInput, type ObserverJournal, type ObserverRecord, type ObserverRecordKind, type ParkedRun, type PursuitCostProvenance, type PursuitFork, type PursuitNodeCost, type PursuitNodePlatform, type PursuitNodeProjection, type PursuitNodeTiming, type PursuitNodeUsage, type PursuitObserverDelivery, type PursuitProjection, type PursuitRunProjection, type PursuitRunTotals, type PursuitStatus, type PursuitVersionChain, type PursuitVersionStop, type PursuitVersions, type QuestionEscalationOutcome, RUN_FORK_CORRELATION_KEYS, type ResolveDriveHarness, type RetainedPendingCause, type RootStreamRecord, type RunChatTurnInput, type RunDirectoryHolderLiveness, type RunDirectoryLock, type RunDirectoryLockHolder, RunDirectoryLockedError, RunParkedError, type RunParkingPolicy, type RunParkingRecord, type RunReopen, type RuntimeDecisionEvidenceRef, type RuntimeDecisionKind, type RuntimeDecisionPoint, type SeatSelection, type SeatSelectionInput, type SelectSeat, type SettledPursuitVersion, SettledRunDirectoryError, type SuperviseGraphPursuitOptions, SupervisePursuitError, type SupervisePursuitOptions, type SupervisedPursuitResult, type ToolLoopCompactionOptions, type VersionJudge, type VersionVerdict, type WorkerSlots, type WorkerWatchOptions, acquireRunDirectoryLock, assertPursuitVersions, deriveExecutionId, discoverDurableSupervisionRun, handleChatTurn, observerRecordDigest, projectPursuit, readFailureRecord, readRootStream, readRootStreamReceipt, readRunDirectoryLock, readRunParking, readSettleRecord, runDirectoryHolderIsLive, superviseGraphPursuit, supervisePursuit };
258
+ export declare function discoverDurableSupervisionRun(runDir: string): Promise<DurableSupervisionDiscovery>;
259
+ export { type AnalyzeOnSettleRoute, type AuthorizedDownMessage, type AuthorizedSpawn, type AuthorizedSpawnContext, type ChatStreamEvent, type ChatTurnHooks, type ChatTurnIdentity, type ChatTurnProducer, type ChatTurnResult, type ContinuityMode, type CoordinationAuthentication, type CoordinationHttpAudit, type CoordinationPublicAddress, type CoordinationReadAccess, type CoordinationRejectReason, type CoordinationTransportOptions, type DeadlineCheckIn, type DownMessageAuthorizationInput, type DriveHarnessOwnerContext, type DurableCoordinationStreamIdentity, type DurableFailureRecord, type DurableSupervisionDiscovery, type EscalateQuestion, FileObserverJournal, type JudgedPursuitVersion, type ManagerWakePolicy, type MapOnSettleRoute, type NextPursuitVersion, type NextPursuitVersionInput, type ObserverJournal, type ObserverRecord, type ObserverRecordKind, type ParkedRun, type PursuitCostProvenance, type PursuitFork, type PursuitNodeCost, type PursuitNodePlatform, type PursuitNodeProjection, type PursuitNodeTiming, type PursuitNodeUsage, type PursuitObserverDelivery, type PursuitProjection, type PursuitRunProjection, type PursuitRunTotals, type PursuitStatus, type PursuitVersionChain, type PursuitVersionStop, type PursuitVersions, type QuestionEscalationOutcome, RUN_FORK_CORRELATION_KEYS, type ResolveDriveHarness, type RetainedPendingCause, type RootStreamRecord, type RunChatTurnInput, type RunDirectoryHolderLiveness, type RunDirectoryLock, type RunDirectoryLockHolder, RunParkedError, type RunParkingPolicy, type RunParkingRecord, type RunReopen, type RuntimeDecisionEvidenceRef, type RuntimeDecisionKind, type RuntimeDecisionPoint, type SeatSelection, type SeatSelectionInput, type SelectSeat, type SettledPursuitVersion, type SuperviseGraphPursuitOptions, SupervisePursuitError, type SupervisePursuitOptions, type SupervisedPursuitResult, type ToolLoopCompactionOptions, type VersionJudge, type VersionVerdict, type WorkerSlots, type WorkerWatchOptions, assertPursuitVersions, observerRecordDigest, projectPursuit, readRootStream, readRootStreamReceipt, readRunParking, superviseGraphPursuit, supervisePursuit };
270
260
  //# sourceMappingURL=durable.d.ts.map
package/dist/durable.js CHANGED
@@ -1,12 +1,12 @@
1
- import { a as publishExclusiveDurableFile, c as captureRunWriteContext, d as runGenerationPath, f as runWithWriteClaim, l as fenceRunWrite, o as syncDurableDirectory, s as writeAtomicDurableFile, t as spawnJournalRecordEvents, u as mutateRunClaim } from "./record-events-D93DkpAx.js";
2
- import { Ct as readCommittedJsonLines, Ri as detachedSnapshot, Sr as isFiniteNumber, ai as authoredProfileDigest, bt as isNoEntError, i as RunParkedError, k as FileSpawnJournal, mt as loadSpawnForest, qi as assertValidBudget, r as assertResumeLimits, s as readRunParking, xr as failedItems, yt as appendCommittedJsonLine, zi as contentAddress } from "./supervisor-DDy0aEtR.js";
3
- import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DodWX-cb.js";
4
- import { W as addSpend, X as errorMessage, ft as zeroSpend, q as cloneSpend } from "./sandbox-profile-compat-_fEtHPCj.js";
5
- import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
6
- import { a as applyExactAgentProfileDiff } from "./profile-6OLpbjvV.js";
7
- import { a as superviseRootProfile, ot as readRootStream, st as readRootStreamReceipt, t as supervise } from "./supervise-BUOeThuB.js";
8
- import { a as runCancelRequestFile, o as runCancellationFile, v as supervisorRunDir, x as workerCancellationsDir } from "./run-cancellation-CzFhQGMa.js";
9
- import { i as superviseAgentGraph } from "./graph-CE_pzU31.js";
1
+ import { a as publishExclusiveDurableFile, c as captureRunWriteContext, d as runGenerationPath, f as runWithWriteClaim, l as fenceRunWrite, o as syncDurableDirectory, s as writeAtomicDurableFile, t as spawnJournalRecordEvents, u as mutateRunClaim } from "./record-events-B2GUgYdz.js";
2
+ import { Bi as detachedSnapshot, Ct as readCommittedJsonLines, Di as runtimeFailureCauseSchema, Sr as isFiniteNumber, Vi as contentAddress, Yi as assertValidBudget, bt as isNoEntError, i as RunParkedError, k as FileSpawnJournal, mt as loadSpawnForest, oi as authoredProfileDigest, r as assertResumeLimits, s as readRunParking, xr as failedItems, yt as appendCommittedJsonLine } from "./supervisor-C1OePYE-.js";
3
+ import { f as RuntimeRunStateError, m as ValidationError } from "./errors-wuhGvpE3.js";
4
+ import { G as addSpend, J as cloneSpend, Z as errorMessage, pt as zeroSpend } from "./sandbox-profile-compat-BxMQ1VXv.js";
5
+ import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
6
+ import { a as applyExactAgentProfileDiff } from "./profile-CAhZDW2T.js";
7
+ import { a as superviseRootProfile, gt as readRootStreamReceipt, ht as readRootStream, t as supervise } from "./supervise-CaeZcgAW.js";
8
+ import { a as runCancelRequestFile, o as runCancellationFile, v as supervisorRunDir, x as workerCancellationsDir } from "./run-cancellation-BLy_Zz-w.js";
9
+ import { a as graphExecutionOptions, i as superviseAgentGraph } from "./graph-Cx0FhKSE.js";
10
10
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, sha256Bytes } from "@tangle-network/agent-interface";
11
11
  import { isRecord } from "@tangle-network/agent-core";
12
12
  import { createHash } from "node:crypto";
@@ -17,7 +17,7 @@ import { SearchRecorder, developmentClaim, incumbent, openSearchLedger, parseSea
17
17
  import { pathToFileURL } from "node:url";
18
18
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
19
19
  import { lockHolderVerdict, lockIdentity, parseLockHolderRecord, readLockHolderIdentity } from "@tangle-network/agent-eval/lock-holder";
20
- //#region src/durable/chat-engine.ts
20
+ // src/durable/chat-engine.ts
21
21
  const encoder = new TextEncoder();
22
22
  function encodeLine(event) {
23
23
  return encoder.encode(`${JSON.stringify(event)}\n`);
@@ -144,8 +144,7 @@ function handleChatTurn(input) {
144
144
  contentType: "application/x-ndjson"
145
145
  };
146
146
  }
147
- //#endregion
148
- //#region src/durable/execution-handle.ts
147
+ // src/durable/execution-handle.ts
149
148
  /**
150
149
  * Derive a stable execution id from the run identity.
151
150
  * The same `(projectId, sessionId, turnIndex)` tuple yields the same id.
@@ -182,8 +181,7 @@ function deriveExecutionId(input) {
182
181
  if (executionId.length > 256) throw new RangeError("derived execution id must not exceed 256 bytes");
183
182
  return executionId;
184
183
  }
185
- //#endregion
186
- //#region src/durable/observer-journal.ts
184
+ // src/durable/observer-journal.ts
187
185
  /**
188
186
  * Durable, append-only third-person history for one concrete Runtime execution.
189
187
  * It consumes Runtime's existing hook stream and does not participate in execution
@@ -341,8 +339,7 @@ function createFileObserverHooks(path, pursuitId) {
341
339
  function toError(error) {
342
340
  return error instanceof Error ? error : new Error(String(error));
343
341
  }
344
- //#endregion
345
- //#region src/durable/observer-projection.ts
342
+ // src/durable/observer-projection.ts
346
343
  /**
347
344
  * Fold one append-only execution journal into a deterministic operator projection.
348
345
  *
@@ -593,6 +590,8 @@ function projectNodeActivity(nodes, record) {
593
590
  if (valid !== void 0) node.valid = valid;
594
591
  const reason = stringField(payload, "reason");
595
592
  if (reason) node.reason = reason;
593
+ if (status === "done") node.failure = void 0;
594
+ else if (payload && Object.hasOwn(payload, "failure")) node.failure = runtimeFailureCauseSchema.parse(payload.failure);
596
595
  const infra = booleanField(payload, "infra");
597
596
  if (infra !== void 0) node.infra = infra;
598
597
  const retained = stringField(payload, "retainedExecution");
@@ -885,8 +884,7 @@ function booleanField(value, key) {
885
884
  const field = value?.[key];
886
885
  return typeof field === "boolean" ? field : void 0;
887
886
  }
888
- //#endregion
889
- //#region src/durable/settle-record.ts
887
+ // src/durable/settle-record.ts
890
888
  /** The settle record: the returned `SupervisedResult` as canonical JSON, written once. */
891
889
  const SETTLE_RECORD_FILE = "result.json";
892
890
  /** The failure record: the most recent throw, replaced by a later throw. */
@@ -1012,8 +1010,7 @@ async function readFailureRecord(runDir) {
1012
1010
  if (typeof record !== "object" || record === null || typeof record.runId !== "string" || typeof record.pursuitId !== "string" || typeof record.at !== "string" || typeof record.error?.name !== "string" || typeof record.error.message !== "string" || record.rootStream !== void 0 && (typeof record.rootStream.ref !== "string" || typeof record.rootStream.events !== "number")) throw new Error(`supervisePursuit: ${path} is not a failure record`);
1013
1011
  return parsed;
1014
1012
  }
1015
- //#endregion
1016
- //#region src/durable/pursuit-version-evidence.ts
1013
+ // src/durable/pursuit-version-evidence.ts
1017
1014
  /** The chain's directory beside the first version's: the ledger and its content blobs. */
1018
1015
  function pursuitVersionsLedgerPath(runDir) {
1019
1016
  return resolve(`${resolve(runDir.trim())}.search`, "ledger.jsonl");
@@ -1142,8 +1139,7 @@ async function exists(path) {
1142
1139
  function isSha256(value) {
1143
1140
  return typeof value === "string" && /^sha256:[0-9a-f]{64}$/u.test(value);
1144
1141
  }
1145
- //#endregion
1146
- //#region src/durable/pursuit-version-review.ts
1142
+ // src/durable/pursuit-version-review.ts
1147
1143
  /** Where `'review-of-best'` mounts a review: `inputs/review/version-<n>.md`. One review lives in
1148
1144
  * a profile at a time. */
1149
1145
  const REVIEW_DIR = "inputs/review/";
@@ -1220,8 +1216,7 @@ function reviewPage(version, score, verdict) {
1220
1216
  ]
1221
1217
  ].join("\n");
1222
1218
  }
1223
- //#endregion
1224
- //#region src/durable/pursuit-version-run.ts
1219
+ // src/durable/pursuit-version-run.ts
1225
1220
  /**
1226
1221
  * One pursuit version chain at run time: running a version in its directory, reading it back
1227
1222
  * and checking it is this node's run, judging it, turning it into the kernel's cell result, and
@@ -1483,8 +1478,7 @@ var VersionChainRun = class {
1483
1478
  return chain;
1484
1479
  }
1485
1480
  };
1486
- //#endregion
1487
- //#region src/durable/pursuit-versions.ts
1481
+ // src/durable/pursuit-versions.ts
1488
1482
  /**
1489
1483
  * The pursuit version chain, on Eval's search kernel (`runSearch`).
1490
1484
  *
@@ -1923,8 +1917,7 @@ function identicalFailureStreak(versions, count) {
1923
1917
  const [first] = failures;
1924
1918
  return first !== null && first !== void 0 && failures.every((failure) => failure === first) ? first : null;
1925
1919
  }
1926
- //#endregion
1927
- //#region src/durable/run-fork.ts
1920
+ // src/durable/run-fork.ts
1928
1921
  /**
1929
1922
  * The `execution.correlation` keys a fork records on its root. Runtime writes them; a caller that
1930
1923
  * supplies one is refused. `lineageRootRunId` is the first run of the chain of parents, so the
@@ -2025,8 +2018,7 @@ function contains(outer, inner) {
2025
2018
  const path = relative(outer, inner);
2026
2019
  return path === "" || !isAbsolute(path) && path !== ".." && !path.startsWith(`..${sep}`);
2027
2020
  }
2028
- //#endregion
2029
- //#region src/durable/run-lock.ts
2021
+ // src/durable/run-lock.ts
2030
2022
  /** The lock file `supervisePursuit` holds inside a run directory for the life of one call. */
2031
2023
  const RUN_DIRECTORY_LOCK_FILE = "supervise.lock";
2032
2024
  /** The directory is held by a live process. `holder` is what that process recorded. */
@@ -2198,8 +2190,7 @@ function removeIfPresent(path) {
2198
2190
  if (!isNoEntError(error)) throw error;
2199
2191
  }
2200
2192
  }
2201
- //#endregion
2202
- //#region src/durable/pursuit-observer-delivery.ts
2193
+ // src/durable/pursuit-observer-delivery.ts
2203
2194
  /** The Intelligence route that persists a delivered projection on its run spine. */
2204
2195
  const PURSUIT_OBSERVER_DELIVERY_PATH = "/v1/ingest/pursuit-observer";
2205
2196
  const DEFAULT_INTERVAL_MS = 6e4;
@@ -2305,8 +2296,7 @@ function startPursuitObserverDelivery(delivery, read, warn = (message) => consol
2305
2296
  }
2306
2297
  };
2307
2298
  }
2308
- //#endregion
2309
- //#region src/durable/run-reopen.ts
2299
+ // src/durable/run-reopen.ts
2310
2300
  /** The directory that holds a run's archived settle records. */
2311
2301
  const SETTLE_ARCHIVE_DIR = "settles";
2312
2302
  /** Refuse a reopen that names no operator or reason, or that is combined with a fork or versions. */
@@ -2420,8 +2410,7 @@ async function readBytes(path) {
2420
2410
  throw error;
2421
2411
  }
2422
2412
  }
2423
- //#endregion
2424
- //#region src/durable/supervise-pursuit.ts
2413
+ // src/durable/supervise-pursuit.ts
2425
2414
  /** A failed Runtime execution whose complete third-person projection was retained. */
2426
2415
  var SupervisePursuitError = class extends Error {
2427
2416
  pursuit;
@@ -2496,18 +2485,36 @@ async function supervisePursuit(profile, task, opts) {
2496
2485
  * the graph from its spawn journal. `result.json` holds the graph's supervised result, the same
2497
2486
  * record every supervised run leaves; the edge ledger is the journal's `edge` events and the
2498
2487
  * returned `result.ledger`. Version chains and forks are `supervisePursuit` features and are not
2499
- * offered here.
2488
+ * offered here. An explicit `reopen` uses the same archived-settle and resume contract as
2489
+ * `supervisePursuit`; ordinary re-entry of a settled graph stays refused.
2500
2490
  */
2501
2491
  async function superviseGraphPursuit(graph, opts) {
2502
2492
  assertPursuitDirectory(opts, "superviseGraphPursuit");
2503
- const { pursuitId: _pursuitId, hooks: _hooks, observerDelivery: _observerDelivery, brain, ...graphOptions } = opts;
2504
- return runDurablePursuit(opts, ({ hooks, steerDir }) => superviseAgentGraph(graph, {
2493
+ if (opts.reopen !== void 0) assertRunReopen(opts.reopen, {});
2494
+ const { pursuitId: _pursuitId, hooks: _hooks, observerDelivery: _observerDelivery, brain, reopen, ...graphOptions } = opts;
2495
+ return runDurablePursuit(opts, ({ hooks, steerDir }) => superviseAgentGraph(reopen?.budget === void 0 ? graph : {
2496
+ ...graph,
2497
+ budget: reopen.budget
2498
+ }, graphExecutionOptions({
2505
2499
  ...graphOptions,
2506
2500
  runId: graphOptions.runId ?? "supervise",
2501
+ ...reopen === void 0 ? {} : { resume: true },
2507
2502
  steerDir,
2508
2503
  retainedAtSettlement: "release",
2509
2504
  hooks
2510
- }, brain), (result) => result.result);
2505
+ }), brain), (result) => result.result, reopen === void 0 ? void 0 : (observer) => reopenSettledRun({
2506
+ runDir: opts.runDir.trim(),
2507
+ runId: opts.runId ?? "supervise",
2508
+ reopen,
2509
+ journal: opts.journal,
2510
+ limits: {
2511
+ budget: graph.budget,
2512
+ ...opts.reservationPolicy === void 0 ? {} : { reservationPolicy: opts.reservationPolicy }
2513
+ },
2514
+ observer,
2515
+ pursuitId: opts.pursuitId.trim(),
2516
+ now: opts.now ?? Date.now
2517
+ }));
2511
2518
  }
2512
2519
  /** The pursuit identity and run directory both durable entries require. */
2513
2520
  function assertPursuitDirectory(opts, entry) {
@@ -2614,8 +2621,7 @@ function rootEvent(pursuitId, runId, phase, timestamp, payload) {
2614
2621
  function errorName(error) {
2615
2622
  return error instanceof Error ? error.name : "NonError";
2616
2623
  }
2617
- //#endregion
2618
- //#region src/durable/supervision-discovery.ts
2624
+ // src/durable/supervision-discovery.ts
2619
2625
  /**
2620
2626
  * Discover the stable identities recorded by Runtime's durable supervision
2621
2627
  * files. This is the developer-facing first step before calling
@@ -2681,7 +2687,6 @@ async function discoverDurableSupervisionRun(runDir) {
2681
2687
  function compareText(left, right) {
2682
2688
  return left < right ? -1 : left > right ? 1 : 0;
2683
2689
  }
2684
- //#endregion
2685
2690
  export { FileObserverJournal, RUN_FORK_CORRELATION_KEYS, RunDirectoryLockedError, RunParkedError, SettledRunDirectoryError, SupervisePursuitError, acquireRunDirectoryLock, assertPursuitVersions, deriveExecutionId, discoverDurableSupervisionRun, handleChatTurn, observerRecordDigest, projectPursuit, readFailureRecord, readRootStream, readRootStreamReceipt, readRunDirectoryLock, readRunParking, readSettleRecord, runDirectoryHolderIsLive, superviseGraphPursuit, supervisePursuit };
2686
2691
 
2687
2692
  //# sourceMappingURL=durable.js.map