@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,7 +1,7 @@
1
- import { $i as mapSandboxToolEvent, At as createExecutor, Ci as projectSandboxOutcome, Dt as createExecutorRegistry, Qi as mapSandboxEvent, Ti as runtimeFailureCause, Zi as createSandboxToolPartState, _ as withDriverExecutor, _i as runtimeOwnedPendingExecutorMaterialization, _t as InMemorySpawnJournal, ai as authoredProfileDigest, bi as unknownMaterializationReceipt, ca as awaitAbortable, ci as knownExecutionBindingReceipt, da as providerMessageText, ea as terminalTextFromSandboxEvent, gt as InMemoryResultBlobStore, hi as runtimeOwnedExecutorMaterialization, kt as captureReusableExecutorConfig, la as promptFromAgentTurnInput, li as knownMaterializationReceipt, mi as runtimeOwnedExecutorExecutionBinding, n as createSupervisor, ra as createSandboxUsageLedger, ta as canonicalStreamEventFromSandboxEvent, ua as promptOptionsFromAgentTurnInput, wi as readSandboxOutcome, xi as executableAgentProfileSnapshot, yi as unknownExecutionBindingReceipt } from "./supervisor-DDy0aEtR.js";
2
- import { m as ValidationError, p as SessionMismatchError, r as BackendTransportError } from "./errors-DodWX-cb.js";
3
- import { B as sha256Bytes$1, Ct as armDeadlineTimer, X as errorMessage, et as isAsyncIterable } from "./sandbox-profile-compat-_fEtHPCj.js";
4
- import { c as profileModelExecutionSettings, g as observedModelMatchesDeclared, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-CyCUwHed.js";
1
+ import { $i as createSandboxToolPartState, At as createExecutor, Dt as createExecutorRegistry, Ei as runtimeFailureCause, Si as executableAgentProfileSnapshot, Ti as readSandboxOutcome, _ as withDriverExecutor, _t as InMemorySpawnJournal, aa as createSandboxUsageLedger, bi as unknownExecutionBindingReceipt, da as promptFromAgentTurnInput, ea as mapSandboxEvent, fa as promptOptionsFromAgentTurnInput, gi as runtimeOwnedExecutorMaterialization, gt as InMemoryResultBlobStore, hi as runtimeOwnedExecutorExecutionBinding, kt as captureReusableExecutorConfig, li as knownExecutionBindingReceipt, n as createSupervisor, na as terminalTextFromSandboxEvent, oi as authoredProfileDigest, pa as providerMessageText, ra as canonicalStreamEventFromSandboxEvent, ta as mapSandboxToolEvent, ua as awaitAbortable, ui as knownMaterializationReceipt, vi as runtimeOwnedPendingExecutorMaterialization, wi as projectSandboxOutcome, xi as unknownMaterializationReceipt } from "./supervisor-C1OePYE-.js";
2
+ import { m as ValidationError, p as SessionMismatchError, r as BackendTransportError } from "./errors-wuhGvpE3.js";
3
+ import { B as sha256Bytes$1, Z as errorMessage, tt as isAsyncIterable, wt as armDeadlineTimer } from "./sandbox-profile-compat-BxMQ1VXv.js";
4
+ import { c as profileModelExecutionSettings, g as observedModelMatchesDeclared, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-GSxWwP-b.js";
5
5
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, renderInputPartsAsText } from "@tangle-network/agent-interface";
6
6
  import { costForTokenPricing, makeProposalFinding, scoreKnowledgeReadiness } from "@tangle-network/agent-eval";
7
7
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
@@ -10,7 +10,7 @@ import { existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
10
10
  import { join } from "node:path";
11
11
  import { assertProposalFindings } from "@tangle-network/agent-eval/analyst";
12
12
  import { pathToFileURL } from "node:url";
13
- //#region src/sessions.ts
13
+ // src/sessions.ts
14
14
  /**
15
15
  *
16
16
  * Session helpers + an in-memory `RuntimeSessionStore` implementation suitable
@@ -101,8 +101,7 @@ var InMemoryRuntimeSessionStore = class {
101
101
  return [...this.events.get(sessionId) ?? []];
102
102
  }
103
103
  };
104
- //#endregion
105
- //#region src/backends.ts
104
+ // src/backends.ts
106
105
  /**
107
106
  * Provider-neutral backend adapters for `runAgentTaskStream`.
108
107
  *
@@ -240,8 +239,7 @@ function mapCommonBackendEvent(event, context) {
240
239
  function stringValue(value) {
241
240
  return typeof value === "string" && value.length > 0 ? value : void 0;
242
241
  }
243
- //#endregion
244
- //#region src/runtime/agent-turn-backend-events.ts
242
+ // src/runtime/agent-turn-backend-events.ts
245
243
  function turnBackendInput(task, input) {
246
244
  return {
247
245
  task,
@@ -687,8 +685,10 @@ function deriveTurnSignal(callerSignal, timeoutMs) {
687
685
  const controller = new AbortController();
688
686
  const clearTimer = timeoutMs > 0 ? armDeadlineTimer(timeoutMs, () => controller.abort(/* @__PURE__ */ new Error(`agent turn timed out after ${timeoutMs}ms`))) : void 0;
689
687
  const onCallerAbort = () => controller.abort(callerSignal?.reason ?? /* @__PURE__ */ new Error("agent turn aborted"));
690
- if (callerSignal) if (callerSignal.aborted) onCallerAbort();
691
- else callerSignal.addEventListener("abort", onCallerAbort, { once: true });
688
+ if (callerSignal) {
689
+ if (callerSignal.aborted) onCallerAbort();
690
+ else callerSignal.addEventListener("abort", onCallerAbort, { once: true });
691
+ }
692
692
  return {
693
693
  signal: controller.signal,
694
694
  dispose: () => {
@@ -697,8 +697,7 @@ function deriveTurnSignal(callerSignal, timeoutMs) {
697
697
  }
698
698
  };
699
699
  }
700
- //#endregion
701
- //#region src/runtime/stream-agent-turn.ts
700
+ // src/runtime/stream-agent-turn.ts
702
701
  /**
703
702
  * `streamAgentTurn` — the ONE run-a-turn event-stream contract over every
704
703
  * execution substrate: a sandbox box (`SandboxInstance.streamPrompt`), a
@@ -1099,8 +1098,7 @@ function materializedModel(receipt, profile) {
1099
1098
  const fallback = profile.model?.default;
1100
1099
  return typeof fallback === "string" && fallback.length > 0 ? fallback : void 0;
1101
1100
  }
1102
- //#endregion
1103
- //#region src/runtime/profile-chat-client.ts
1101
+ // src/runtime/profile-chat-client.ts
1104
1102
  /** Profile-exact adapter for packages that consume agent-eval's ChatClient contract.
1105
1103
  * Every call still enters Runtime through createExecutor -> streamAgentTurn, and every
1106
1104
  * behavioral field is checked against the exact AgentProfile before any transport runs. */
@@ -1435,8 +1433,7 @@ function optimizerTokenCount(value, label) {
1435
1433
  if (!Number.isSafeInteger(value) || value < 0) throw new Error(`profile optimizer ${label} must be a non-negative integer`);
1436
1434
  return value;
1437
1435
  }
1438
- //#endregion
1439
- //#region src/runtime/observe.ts
1436
+ // src/runtime/observe.ts
1440
1437
  /**
1441
1438
  * The third-person observer — the connective tissue that closes the loop.
1442
1439
  *
@@ -1593,7 +1590,8 @@ async function analyzeWithProfile(input, opts) {
1593
1590
  };
1594
1591
  validateUsage(usage);
1595
1592
  try {
1596
- const findings = assertProposalFindings(parseFindings(res.content).map((f) => makeProposalFinding({
1593
+ const parsed = parseFindings(res.content);
1594
+ const findings = assertProposalFindings(parsed.map((f) => makeProposalFinding({
1597
1595
  analyst_id: observerId,
1598
1596
  area: f.area,
1599
1597
  severity: f.severity,
@@ -1687,8 +1685,7 @@ function renderReport(findings) {
1687
1685
  const block = (title, fs) => fs.length === 0 ? "" : `**${title}**\n${fs.map((f) => `- [${f.severity}] ${f.claim}\n → ${f.recommended_action ?? ""}`).join("\n")}\n`;
1688
1686
  return [block("For the agent (fix skills / prompt / tools)", forAgent), block("For you (the operator)", forOperator)].filter(Boolean).join("\n");
1689
1687
  }
1690
- //#endregion
1691
- //#region src/runtime/strategy.ts
1688
+ // src/runtime/strategy.ts
1692
1689
  const taskNudge = "Use the available tools to bring the artifact to the required final state. Address EVERY distinct change the request implies. After each tool result, check what remains and continue. Re-read the values you set to confirm they took. Reply DONE only once every required change is made and verified.";
1693
1690
  function exactAgenticProfile(profile, context) {
1694
1691
  const parsed = agentProfileSchema.safeParse(profile);
@@ -1702,7 +1699,11 @@ function requiredProfileModel(profile, context) {
1702
1699
  return model;
1703
1700
  }
1704
1701
  function profileSystemPrompt(profile) {
1705
- const sections = [profile.prompt?.systemPrompt, ...profile.prompt?.instructions ?? []].filter((value) => typeof value === "string" && value.trim().length > 0);
1702
+ const sections = [
1703
+ profile.prompt?.systemPrompt,
1704
+ profile.prompt?.appendSystemPrompt,
1705
+ ...profile.prompt?.instructions ?? []
1706
+ ].filter((value) => typeof value === "string" && value.trim().length > 0);
1706
1707
  const instructions = profile.resources?.instructions;
1707
1708
  if (typeof instructions === "string" && instructions.trim()) sections.push(instructions);
1708
1709
  else if (instructions && typeof instructions === "object" && instructions.kind === "inline" && instructions.content.trim()) sections.push(instructions.content);
@@ -2176,8 +2177,7 @@ async function runAgentic(opts) {
2176
2177
  ms: Date.now() - started
2177
2178
  };
2178
2179
  }
2179
- //#endregion
2180
- //#region src/improvement/optimizer-prompt.ts
2180
+ // src/improvement/optimizer-prompt.ts
2181
2181
  /**
2182
2182
  * The senior scientific-method optimizer doctrine — the ONE substantial prompt
2183
2183
  * core shared by every builder/author surface (tool build, MCP build, codebase
@@ -2252,8 +2252,7 @@ const strategyAuthorMethod = [
2252
2252
  "6. PREDICT, THEN REFLECT: put the hypothesis, the mechanism, and the predicted lift in a",
2253
2253
  " comment at the top of the module — the holdout verdict will be read against it."
2254
2254
  ].join("\n");
2255
- //#endregion
2256
- //#region src/runtime/authored-code.ts
2255
+ // src/runtime/authored-code.ts
2257
2256
  /**
2258
2257
  * The ONE lint over model-authored source.
2259
2258
  *
@@ -2284,8 +2283,7 @@ function assertAuthoredCode(code, options = {}) {
2284
2283
  [/child_process|node:fs|node:net|node:http|worker_threads/, "node builtin access"]
2285
2284
  ]) if (pattern.test(code)) throw new ValidationError(`${context} rejected: ${what}`);
2286
2285
  }
2287
- //#endregion
2288
- //#region src/runtime/strategy-author.ts
2286
+ // src/runtime/strategy-author.ts
2289
2287
  /**
2290
2288
  * authorStrategy — the agent-authored layer as a package primitive (software-3.0): an
2291
2289
  * LLM reads a benchmark's per-task LOSSES + the defineStrategy contract and writes a NEW
@@ -2313,10 +2311,10 @@ spend a compute budget to beat a task's deployable check. You compose exactly tw
2313
2311
  - steer => a corrective instruction injected before the shot.
2314
2312
  - profile => a complete AgentProfile — give THIS shot its own instructions,
2315
2313
  model, skills, tools, hooks, and subagents. Include name, harness, and
2316
- model: { provider, default }; put standing instructions in prompt.systemPrompt.
2314
+ model: { provider, default }; put standing instructions in prompt.appendSystemPrompt.
2317
2315
  For example: { ...opts.workerProfile, name: 'researcher',
2318
2316
  prompt: { ...opts.workerProfile.prompt,
2319
- systemPrompt: 'Inspect the evidence before proposing a change.' } }.
2317
+ appendSystemPrompt: 'Inspect the evidence before proposing a change.' } }.
2320
2318
  Choose an available model from the current execution setup. Omit profile to use
2321
2319
  the worker's exact profile. Every shot spends from the same conserved budget.
2322
2320
  - tools => string[] — restrict THIS shot to a subset of the task's tools by
@@ -2387,7 +2385,7 @@ async function requestStrategySource(opts) {
2387
2385
  context: "strategy author"
2388
2386
  }).chat({ messages: [{
2389
2387
  role: "user",
2390
- content: `${opts.contract ?? strategyAuthorContract}\n\nBASELINE RESULTS on the "${opts.environmentName}" environment (budget=${opts.budget}) — the per-task losses are your gradient:\n${opts.lossesJson}\n\nAuthor ONE new strategy that you expect to beat the baselines on THIS environment at the same budget.\n${strategyAuthorMethod}\n\nOutput only the module code block.`
2388
+ content: `${opts.contract ?? "\nYou author an OPTIMIZATION STRATEGY for an agentic loop system. A strategy decides how to\nspend a compute budget to beat a task's deployable check. You compose exactly two steps:\n\n shot(spec?: { handle?, messages?, steer?, profile?, tools? }): Promise<ShotResult | null>\n Runs ONE worker attempt (a bounded tool loop) over an artifact.\n - omit handle => the shot opens its OWN fresh artifact and closes it after (a sample).\n - pass handle => the shot CONTINUES that artifact (state accumulates across shots).\n - messages => the carried conversation (pass the previous ShotResult.messages to continue).\n - steer => a corrective instruction injected before the shot.\n - profile => a complete AgentProfile — give THIS shot its own instructions,\n model, skills, tools, hooks, and subagents. Include name, harness, and\n model: { provider, default }; put standing instructions in prompt.appendSystemPrompt.\n For example: { ...opts.workerProfile, name: 'researcher',\n prompt: { ...opts.workerProfile.prompt,\n appendSystemPrompt: 'Inspect the evidence before proposing a change.' } }.\n Choose an available model from the current execution setup. Omit profile to use\n the worker's exact profile. Every shot spends from the same conserved budget.\n - tools => string[] — restrict THIS shot to a subset of the task's tools by\n name (focus an explore shot on read-only tools, an execute shot on write tools).\n Restriction-only; unknown names make the shot fail. ALWAYS select from\n await listTools(handle) — never hardcode. Omitted => the shot sees every tool.\n ShotResult = { messages, score (0..1 on the task's check), passes, total, completions, toolErrors }\n Returns null if the attempt failed infra-wise.\n\n critique(messages): Promise<string | null>\n A firewalled trace-analyst reads the attempt's trajectory and returns ONE corrective\n instruction (or null when it judges the work complete). Costs ~1 completion.\n\n consult(messages, instruction): Promise<string | null>\n The RAW analyst channel: the same firewalled critic answers YOUR instruction over the\n trajectory verbatim (no reformatting) — use it when you need a specific reply format\n (a decision, a prediction). Costs ~1 completion.\n\n surface.open(task) / surface.close(handle)\n Open a persistent artifact you manage yourself (remember to close in a finally).\n close is idempotent — closing an already-closed handle is a safe no-op.\n\n listTools(handle): Promise<Array<{ name, description? }>>\n The tools THIS task actually offers. TOOL SETS VARY PER TASK — if you restrict a\n shot with `tools`, you MUST pick names from await listTools(handle); hardcoding\n names from an example kills your shots on every task whose tools differ.\n\nRules:\n- ALWAYS await every shot/critique/surface call — a floating promise that rejects\n crashes the whole benchmark run.\n- Stay within ~budget total shots; every shot/critique spends from a conserved pool.\n- For a FRESH attempt OMIT `messages` entirely (never pass `[]` — an empty array is a\n fresh conversation too, but be explicit). To CONTINUE, pass the previous\n ShotResult.messages unchanged.\n- Return { score, resolved, completions, progression, shots } — score = the BEST checkpoint\n you reached (keep-best, never final-state), progression = score after each shot.\n- The module must be EXACTLY this shape (no other imports, no commentary outside code):\n\nimport { defineStrategy } from '@tangle-network/agent-runtime/kernel'\nexport default defineStrategy('your-strategy-name', async ({ surface, task, opts, budget, shot, critique, listTools }) => {\n // your composition (listTools comes from the destructured context — it is NOT a global)\n})\n"}\n\nBASELINE RESULTS on the "${opts.environmentName}" environment (budget=${opts.budget}) — the per-task losses are your gradient:\n${opts.lossesJson}\n\nAuthor ONE new strategy that you expect to beat the baselines on THIS environment at the same budget.\n${strategyAuthorMethod}\n\nOutput only the module code block.`
2391
2389
  }] }, { ...opts.signal ? { signal: opts.signal } : {} });
2392
2390
  turns.push({
2393
2391
  content: res.content,
@@ -2418,7 +2416,8 @@ async function requestStrategySource(opts) {
2418
2416
  * module breaks the contract or exports no Strategy. */
2419
2417
  async function loadAuthoredStrategy(code, outDir) {
2420
2418
  assertStrategyContract(code);
2421
- const file = join(outDir, `strategy-${sha256Bytes$1(Buffer.from(code, "utf8")).slice(7)}.mts`);
2419
+ const digest = sha256Bytes$1(Buffer.from(code, "utf8")).slice(7);
2420
+ const file = join(outDir, `strategy-${digest}.mts`);
2422
2421
  if (!existsSync(file)) {
2423
2422
  mkdirSync(outDir, { recursive: true });
2424
2423
  const partial = `${file}.${process.pid}.tmp`;
@@ -2663,8 +2662,7 @@ const sampleThenRefine = defineStrategy("sampleThenRefine", async ({ surface, ta
2663
2662
  for (const h of open) await surface.close(h);
2664
2663
  }
2665
2664
  });
2666
- //#endregion
2667
- //#region src/runtime/structural-rollout.ts
2665
+ // src/runtime/structural-rollout.ts
2668
2666
  /**
2669
2667
  * structuralRollout — the measured structural lever as a fourth member of the
2670
2668
  * sample/refine/sampleThenRefine strategy family: k independent samples, selection by
@@ -3011,41 +3009,43 @@ function structuralRollout(config = {}) {
3011
3009
  });
3012
3010
  let seq = candidates.length;
3013
3011
  let repairStop = "already-passing";
3014
- if (!passesAllChecks(best.outcome)) if (best.outcome.crashed !== true && totalChecks(best.outcome) === 0) repairStop = "no-signal";
3015
- else {
3016
- repairStop = "rounds-exhausted";
3017
- for (let r = 0; r < policy.repairRounds; r += 1) {
3018
- const out = await shot({
3019
- messages: best.messages,
3020
- steer: repairSteer(best.outcome)
3021
- });
3022
- if (!out) break;
3023
- shots += 1;
3024
- completions += out.completions;
3025
- progression.push(out.score);
3026
- const artifact = extract(out.messages);
3027
- const outcome = await checkRunner.run(artifact, checks, runCtx);
3028
- const displaced = canDisplace(outcome, best.outcome);
3029
- const label = displaced ? "repair (displaced the incumbent)" : outcome.crashed !== true && outcome.passedOfficial < best.outcome.passedOfficial ? "repair (held out: passes fewer official checks than the incumbent)" : "repair (held out: no improvement)";
3030
- receipts.push({
3031
- candidateIndex: seq,
3032
- selected: false,
3033
- score: visibleCheckScore(outcome),
3034
- reason: describeOutcome(label, outcome),
3035
- selector: "driver"
3036
- });
3037
- if (displaced) best = {
3038
- index: seq,
3039
- messages: out.messages,
3040
- artifact,
3041
- outcome,
3042
- shotScore: out.score,
3043
- shotResolved: out.total > 0 && out.passes === out.total
3044
- };
3045
- seq += 1;
3046
- if (passesAllChecks(best.outcome)) {
3047
- repairStop = "repaired-pass";
3048
- break;
3012
+ if (!passesAllChecks(best.outcome)) {
3013
+ if (best.outcome.crashed !== true && totalChecks(best.outcome) === 0) repairStop = "no-signal";
3014
+ else {
3015
+ repairStop = "rounds-exhausted";
3016
+ for (let r = 0; r < policy.repairRounds; r += 1) {
3017
+ const out = await shot({
3018
+ messages: best.messages,
3019
+ steer: repairSteer(best.outcome)
3020
+ });
3021
+ if (!out) break;
3022
+ shots += 1;
3023
+ completions += out.completions;
3024
+ progression.push(out.score);
3025
+ const artifact = extract(out.messages);
3026
+ const outcome = await checkRunner.run(artifact, checks, runCtx);
3027
+ const displaced = canDisplace(outcome, best.outcome);
3028
+ const label = displaced ? "repair (displaced the incumbent)" : outcome.crashed !== true && outcome.passedOfficial < best.outcome.passedOfficial ? "repair (held out: passes fewer official checks than the incumbent)" : "repair (held out: no improvement)";
3029
+ receipts.push({
3030
+ candidateIndex: seq,
3031
+ selected: false,
3032
+ score: visibleCheckScore(outcome),
3033
+ reason: describeOutcome(label, outcome),
3034
+ selector: "driver"
3035
+ });
3036
+ if (displaced) best = {
3037
+ index: seq,
3038
+ messages: out.messages,
3039
+ artifact,
3040
+ outcome,
3041
+ shotScore: out.score,
3042
+ shotResolved: out.total > 0 && out.passes === out.total
3043
+ };
3044
+ seq += 1;
3045
+ if (passesAllChecks(best.outcome)) {
3046
+ repairStop = "repaired-pass";
3047
+ break;
3048
+ }
3049
3049
  }
3050
3050
  }
3051
3051
  }
@@ -3065,7 +3065,6 @@ function structuralRollout(config = {}) {
3065
3065
  };
3066
3066
  });
3067
3067
  }
3068
- //#endregion
3069
3068
  export { defaultAnalystInstruction as A, InMemoryRuntimeSessionStore as B, optimizerMethod as C, runAgentic as D, refine as E, collectAgentTurn as F, nowIso as H, streamAgentTurn as I, createIterableBackend as L, renderReport as M, profileChatClient as N, sample as O, profileOptimizerModelCall as P, createSandboxPromptBackend as R, strategyAuthorSystemPrompt as S, depthStrategy as T, startOrResumeRuntimeSession as U, newRuntimeSession as V, touchSession as W, defineStrategy as _, defaultStructuralRolloutPolicy as a, sampleThenRefine as b, officialChecksFromMeta as c, selectBestIndex as d, structuralRollout as f, authorStrategy as g, assertStrategyContract as h, defaultExtractCandidate as i, observe as j, ObservationError as k, resolveEntrySymbol as l, adaptiveRefine as m, compareCheckOutcomes as n, filterAuthoredAsserts as o, visibleCheckScore as p, composeCheckSources as r, modelAuthoredChecks as s, canDisplace as t, sandboxCheckRunner as u, loadAuthoredStrategy as v, breadthStrategy as w, strategyAuthorContract as x, requestStrategySource as y, normalizeBackendStreamEvent as z };
3070
3069
 
3071
- //# sourceMappingURL=structural-rollout-Wl_rCuzM.js.map
3070
+ //# sourceMappingURL=structural-rollout-B86bSixU.js.map