@tangle-network/agent-runtime 0.90.0 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +4 -4
  3. package/dist/analyst-loop.d.ts +1 -1
  4. package/dist/{chunk-4WXGK6GV.js → chunk-7ON74BQO.js} +2 -2
  5. package/dist/{chunk-4IBAMGBE.js → chunk-AD7JW4QG.js} +420 -23
  6. package/dist/chunk-AD7JW4QG.js.map +1 -0
  7. package/dist/{chunk-7LO5GMAO.js → chunk-CMYMTRGA.js} +14 -5
  8. package/dist/chunk-CMYMTRGA.js.map +1 -0
  9. package/dist/{chunk-XQEISTK2.js → chunk-DWWII6N2.js} +2 -2
  10. package/dist/{chunk-XMOU4WEY.js → chunk-FF77IBQM.js} +15 -3
  11. package/dist/chunk-FF77IBQM.js.map +1 -0
  12. package/dist/{chunk-MHK62APK.js → chunk-IOUUITQA.js} +3 -3
  13. package/dist/{chunk-UD4BHQMI.js → chunk-IVGYLCFH.js} +2 -2
  14. package/dist/{chunk-UD4BHQMI.js.map → chunk-IVGYLCFH.js.map} +1 -1
  15. package/dist/{chunk-74SBMDTO.js → chunk-JRS3YSRZ.js} +2 -2
  16. package/dist/{chunk-QSNSMJSZ.js → chunk-NC66AM3S.js} +1487 -1481
  17. package/dist/chunk-NC66AM3S.js.map +1 -0
  18. package/dist/{completion-gate-BDaBP8dd.d.ts → completion-gate-DkAnUmpb.d.ts} +2 -2
  19. package/dist/{coordination-DxHduZg7.d.ts → coordination-rRj5hjJK.d.ts} +5 -5
  20. package/dist/environment-provider.d.ts +2 -2
  21. package/dist/index.d.ts +915 -18
  22. package/dist/index.js +5742 -33
  23. package/dist/index.js.map +1 -1
  24. package/dist/intelligence.d.ts +227 -83
  25. package/dist/intelligence.js +259 -166
  26. package/dist/intelligence.js.map +1 -1
  27. package/dist/knowledge.d.ts +6 -6
  28. package/dist/knowledge.js +4 -4
  29. package/dist/lifecycle.d.ts +2 -2
  30. package/dist/lifecycle.js +2 -2
  31. package/dist/{local-harness-sI0S_XNA.d.ts → local-harness-dcD5WTTr.d.ts} +3 -0
  32. package/dist/{loop-runner-bin-D3GmB2Ru.d.ts → loop-runner-bin-DTbZVGfM.d.ts} +2 -2
  33. package/dist/loop-runner-bin.d.ts +6 -6
  34. package/dist/loop-runner-bin.js +5 -5
  35. package/dist/loops.d.ts +16 -256
  36. package/dist/loops.js +30 -4
  37. package/dist/mcp/bin.js +4 -4
  38. package/dist/mcp/index.d.ts +9 -9
  39. package/dist/mcp/index.js +6 -6
  40. package/dist/{mcp-serve-verifier-FL7-ZEb_.d.ts → mcp-serve-verifier-XsX8rkB9.d.ts} +12 -1
  41. package/dist/{openai-tools-D0xmzo0y.d.ts → openai-tools-C4ZfUD4L.d.ts} +1 -1
  42. package/dist/profiles.d.ts +1 -1
  43. package/dist/structural-rollout-MwlpgQ-6.d.ts +446 -0
  44. package/dist/{supervise-BpCdssu0.d.ts → supervise-DPmYPk0j.d.ts} +3 -3
  45. package/dist/{types-Dnk189QA.d.ts → types-SyuwunY_.d.ts} +1 -1
  46. package/dist/{types-DAJQRIUD.d.ts → types-eMNgWgFi.d.ts} +2 -2
  47. package/dist/{worktree-fanout-CfRXYmgV.d.ts → worktree-fanout-BDFQIO-Y.d.ts} +234 -234
  48. package/package.json +6 -7
  49. package/skills/build-with-agent-runtime/SKILL.md +20 -17
  50. package/dist/chunk-4IBAMGBE.js.map +0 -1
  51. package/dist/chunk-7LO5GMAO.js.map +0 -1
  52. package/dist/chunk-QSNSMJSZ.js.map +0 -1
  53. package/dist/chunk-XMOU4WEY.js.map +0 -1
  54. /package/dist/{chunk-4WXGK6GV.js.map → chunk-7ON74BQO.js.map} +0 -0
  55. /package/dist/{chunk-XQEISTK2.js.map → chunk-DWWII6N2.js.map} +0 -0
  56. /package/dist/{chunk-MHK62APK.js.map → chunk-IOUUITQA.js.map} +0 -0
  57. /package/dist/{chunk-74SBMDTO.js.map → chunk-JRS3YSRZ.js.map} +0 -0
package/dist/agent.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _tangle_network_agent_eval from '@tangle-network/agent-eval';
2
2
  import { TraceAnalystKindSpec, AnalystFinding } from '@tangle-network/agent-eval';
3
3
  import { A as ArtifactKind, C as CandidateGenerator, P as PromotionGate } from './generator-YkAQrOoD.js';
4
- import { a as RuntimeStreamEvent, S as SandboxClient, b as OutputAdapter, A as AgentRunSpec } from './types-Dnk189QA.js';
4
+ import { b as RuntimeStreamEvent, S as SandboxClient, c as OutputAdapter, A as AgentRunSpec } from './types-SyuwunY_.js';
5
5
  import { A as AgentSurfaces } from './improvement-adapter-CDR8QNVM.js';
6
6
  export { C as CreateSurfaceImprovementAdapterOpts, D as DraftPatchInput, a as DraftPatchOutput, R as ResolvedSurface, S as SurfaceImprovementEdit, b as SurfaceValidationIssue, c as createSurfaceImprovementAdapter, r as renderSurfaceIssues, d as resolveSubjectPath, v as validateSurfaces } from './improvement-adapter-CDR8QNVM.js';
7
7
  import { K as KnowledgeAdapter, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
package/dist/agent.js CHANGED
@@ -1,14 +1,14 @@
1
- import "./chunk-4IBAMGBE.js";
1
+ import "./chunk-AD7JW4QG.js";
2
2
  import {
3
3
  createSandboxForSpec
4
- } from "./chunk-QSNSMJSZ.js";
4
+ } from "./chunk-NC66AM3S.js";
5
5
  import "./chunk-DPEUKJRO.js";
6
- import "./chunk-UD4BHQMI.js";
6
+ import "./chunk-IVGYLCFH.js";
7
7
  import "./chunk-BZF3KQ6G.js";
8
8
  import {
9
9
  mapSandboxEvent
10
10
  } from "./chunk-FVJ7M3DA.js";
11
- import "./chunk-7LO5GMAO.js";
11
+ import "./chunk-CMYMTRGA.js";
12
12
  import {
13
13
  ValidationError
14
14
  } from "./chunk-YEJR7IXO.js";
@@ -1,5 +1,5 @@
1
1
  import { TraceAnalystByteBudgets, TraceAnalysisStore } from '@tangle-network/agent-eval';
2
- import { I as Iteration } from './types-Dnk189QA.js';
2
+ import { I as Iteration } from './types-SyuwunY_.js';
3
3
  import { R as RunAnalystLoopOpts, a as RunAnalystLoopResult } from './types-BC3bZpH0.js';
4
4
  export { A as AnalystLoopEvent, b as AnalystRegistryLike, c as AnalystRegistryStreamingLike, d as AutoApplyPolicy, F as FindingsStoreLike, I as ImprovementAdapter, e as ImprovementEditBatch, f as ImprovementReport, K as KnowledgeAdapter, g as KnowledgeProposalBatch, h as KnowledgeReport } from './types-BC3bZpH0.js';
5
5
  import '@tangle-network/sandbox';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildLoopOtelSpans,
3
3
  createOtelExporter
4
- } from "./chunk-UD4BHQMI.js";
4
+ } from "./chunk-IVGYLCFH.js";
5
5
 
6
6
  // src/mcp/trace-propagation.ts
7
7
  function readTraceContextFromEnv() {
@@ -49,4 +49,4 @@ export {
49
49
  createPropagatingTraceEmitter,
50
50
  traceContextToEnv
51
51
  };
52
- //# sourceMappingURL=chunk-4WXGK6GV.js.map
52
+ //# sourceMappingURL=chunk-7ON74BQO.js.map
@@ -15,7 +15,7 @@ import {
15
15
  settledToIteration,
16
16
  supervise,
17
17
  withDriverExecutor
18
- } from "./chunk-QSNSMJSZ.js";
18
+ } from "./chunk-NC66AM3S.js";
19
19
  import {
20
20
  addTokenUsage,
21
21
  isAbortError,
@@ -2738,20 +2738,29 @@ async function consultAnalyst(task, messages, instruction, opts) {
2738
2738
  const trajectory = compactTrajectory(messages);
2739
2739
  const analystModel = opts.analystModel ?? opts.model;
2740
2740
  const chat = analystChat(opts, analystModel);
2741
+ const consultMessages = trajectory ? [
2742
+ { role: "system", content: instruction },
2743
+ {
2744
+ role: "user",
2745
+ content: `TASK: ${task.userPrompt.slice(0, 1500)}
2746
+
2747
+ TRAJECTORY:
2748
+ ${trajectory}`
2749
+ }
2750
+ ] : [
2751
+ {
2752
+ role: "user",
2753
+ content: `${instruction}
2754
+
2755
+ TASK:
2756
+ ${task.userPrompt.slice(0, 1500)}`
2757
+ }
2758
+ ];
2741
2759
  const res = await chat.chat({
2742
2760
  model: analystModel,
2743
2761
  temperature: 0.2,
2744
2762
  maxTokens: 1024,
2745
- messages: [
2746
- { role: "system", content: instruction },
2747
- {
2748
- role: "user",
2749
- content: `TASK: ${task.userPrompt.slice(0, 1500)}
2750
-
2751
- TRAJECTORY:
2752
- ${trajectory}`
2753
- }
2754
- ]
2763
+ messages: consultMessages
2755
2764
  });
2756
2765
  const usage = res.usage;
2757
2766
  return {
@@ -5029,6 +5038,381 @@ function deriveTurnSignal(callerSignal, timeoutMs) {
5029
5038
  };
5030
5039
  }
5031
5040
 
5041
+ // src/runtime/structural-rollout.ts
5042
+ import { randomBytes } from "crypto";
5043
+ var defaultStructuralRolloutPolicy = {
5044
+ k: 5,
5045
+ repairRounds: 2,
5046
+ testgen: 6
5047
+ };
5048
+ function resolvePolicy(overrides) {
5049
+ const policy = { ...defaultStructuralRolloutPolicy, ...overrides };
5050
+ if (!Number.isInteger(policy.k) || policy.k < 1) {
5051
+ throw new Error(`structuralRollout: policy.k must be an integer >= 1, got ${policy.k}`);
5052
+ }
5053
+ if (!Number.isInteger(policy.repairRounds) || policy.repairRounds < 0) {
5054
+ throw new Error(
5055
+ `structuralRollout: policy.repairRounds must be an integer >= 0, got ${policy.repairRounds}`
5056
+ );
5057
+ }
5058
+ if (!Number.isInteger(policy.testgen) || policy.testgen < 0) {
5059
+ throw new Error(
5060
+ `structuralRollout: policy.testgen must be an integer >= 0, got ${policy.testgen}`
5061
+ );
5062
+ }
5063
+ return policy;
5064
+ }
5065
+ var authorInstruction = (count, entry) => `Read the task below. Write exactly ${count} single-line assert statements that test the function \`${entry}\`, based ONLY on the behavior the task itself describes. Each assert must be one physical line of the form \`assert ${entry}(...) == expected\` (or a True/False check). Do NOT implement the function. Do NOT copy shown examples verbatim if you can test other cases too. Output ONLY the assert lines inside a single \`\`\`python code block.`;
5066
+ function filterAuthoredAsserts(reply, entrySymbol, count) {
5067
+ const fences = [...reply.matchAll(/```(?:python|py)?\s*\n([\s\S]*?)```/gi)].map(
5068
+ (m) => (m[1] ?? "").trim()
5069
+ );
5070
+ const block = fences.length > 0 ? fences.join("\n") : reply;
5071
+ const balanced = (s) => {
5072
+ let d = 0;
5073
+ for (const ch of s) {
5074
+ if (ch === "(" || ch === "[" || ch === "{") d += 1;
5075
+ else if (ch === ")" || ch === "]" || ch === "}") d -= 1;
5076
+ if (d < 0) return false;
5077
+ }
5078
+ return d === 0;
5079
+ };
5080
+ return block.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("assert ") && l.includes(entrySymbol) && balanced(l)).slice(0, count);
5081
+ }
5082
+ function modelAuthoredChecks(overrides = {}) {
5083
+ return {
5084
+ async generate(_task, ctx) {
5085
+ const count = overrides.count ?? ctx.count;
5086
+ if (count <= 0 || !ctx.entrySymbol) return [];
5087
+ const entry = ctx.entrySymbol;
5088
+ const reply = await ctx.consult(authorInstruction(count, entry));
5089
+ if (!reply) return [];
5090
+ return filterAuthoredAsserts(reply, entry, count).map((code) => ({
5091
+ code,
5092
+ kind: "authored"
5093
+ }));
5094
+ }
5095
+ };
5096
+ }
5097
+ function officialChecksFromMeta(key = "visibleChecks") {
5098
+ return {
5099
+ async generate(task) {
5100
+ const raw = task.meta?.[key];
5101
+ if (!Array.isArray(raw)) return [];
5102
+ return raw.filter((c) => typeof c === "string" && c.trim().length > 0).map((code) => ({ code, kind: "official" }));
5103
+ }
5104
+ };
5105
+ }
5106
+ function composeCheckSources(...sources) {
5107
+ return {
5108
+ async generate(task, ctx) {
5109
+ const all = [];
5110
+ for (const source of sources) all.push(...await source.generate(task, ctx));
5111
+ return all;
5112
+ }
5113
+ };
5114
+ }
5115
+ function resolveEntrySymbol(task) {
5116
+ const meta = task.meta?.entryPoint;
5117
+ if (typeof meta === "string" && meta.trim().length > 0) return meta.trim();
5118
+ const defs = [...task.userPrompt.matchAll(/(?:^|\n)\s*def\s+([A-Za-z_]\w*)\s*\(/g)];
5119
+ const last = defs[defs.length - 1];
5120
+ return last?.[1];
5121
+ }
5122
+ function buildCheckProgram(candidate, official, authored, nonce) {
5123
+ const officialB64 = Buffer.from(JSON.stringify(official), "utf8").toString("base64");
5124
+ const authoredB64 = Buffer.from(JSON.stringify(authored), "utf8").toString("base64");
5125
+ return `${candidate}
5126
+
5127
+ import base64 as _b64, json as _json, sys as _sys
5128
+ _official = _json.loads(_b64.b64decode("${officialB64}").decode("utf8"))
5129
+ _authored = _json.loads(_b64.b64decode("${authoredB64}").decode("utf8"))
5130
+ _lines = []
5131
+ def _run(_tests):
5132
+ _att, _fail = 0, 0
5133
+ for _t in _tests:
5134
+ _att += 1
5135
+ try:
5136
+ exec(_t, dict(globals()))
5137
+ except Exception as _e:
5138
+ _fail += 1
5139
+ _lines.append("CHECK FAILED: %s -> %s: %s" % (_t.strip()[:200], type(_e).__name__, str(_e)[:200]))
5140
+ return _att, _fail
5141
+ _o_att, _o_fail = _run(_official)
5142
+ _a_att, _a_fail = _run(_authored)
5143
+ print("SRCK-${nonce} official=%d/%d authored=%d/%d" % (_o_att - _o_fail, _o_att, _a_att - _a_fail, _a_att))
5144
+ _sys.stdout.write("\\n".join(_lines)[-1500:])
5145
+ _sys.exit(0 if (_o_fail + _a_fail) == 0 and (_o_att + _a_att) > 0 else 1)
5146
+ `;
5147
+ }
5148
+ function sandboxCheckRunner(options = {}) {
5149
+ const python = options.python ?? "python3";
5150
+ const timeoutMs = options.timeoutMs ?? 2e4;
5151
+ return {
5152
+ async run(candidate, checks, ctx) {
5153
+ if (checks.length === 0) {
5154
+ return {
5155
+ passedOfficial: 0,
5156
+ totalOfficial: 0,
5157
+ passedAuthored: 0,
5158
+ totalAuthored: 0,
5159
+ failureOutput: ""
5160
+ };
5161
+ }
5162
+ const box = ctx.box ?? options.box;
5163
+ if (!box) {
5164
+ throw new Error(
5165
+ "sandboxCheckRunner: no execution channel \u2014 bind one via sandboxCheckRunner({ box }) or CheckRunContext.box (ValidationCtx.box / a sandbox instance). Refusing to score without executing: a silent 0 would poison selection."
5166
+ );
5167
+ }
5168
+ const nonce = randomBytes(8).toString("hex");
5169
+ const official = checks.filter((c) => c.kind === "official").map((c) => c.code);
5170
+ const authored = checks.filter((c) => c.kind === "authored").map((c) => c.code);
5171
+ const program = buildCheckProgram(candidate, official, authored, nonce);
5172
+ const b64 = Buffer.from(program, "utf8").toString("base64");
5173
+ const r = await box.exec(`printf '%s' '${b64}' | base64 -d | ${python} -`, { timeoutMs });
5174
+ const summary = new RegExp(
5175
+ `SRCK-${nonce} official=(\\d+)/(\\d+) authored=(\\d+)/(\\d+)`
5176
+ ).exec(r.stdout);
5177
+ if (!summary) {
5178
+ const detail = (r.stderr || r.stdout).slice(-1500) || "no output (crashed or timed out before the checks could run)";
5179
+ return {
5180
+ passedOfficial: 0,
5181
+ totalOfficial: 0,
5182
+ passedAuthored: 0,
5183
+ totalAuthored: 0,
5184
+ failureOutput: detail,
5185
+ crashed: true
5186
+ };
5187
+ }
5188
+ const failureOutput = r.stdout.replace(summary[0], "").slice(-1500).trim();
5189
+ return {
5190
+ passedOfficial: Number(summary[1]),
5191
+ totalOfficial: Number(summary[2]),
5192
+ passedAuthored: Number(summary[3]),
5193
+ totalAuthored: Number(summary[4]),
5194
+ failureOutput
5195
+ };
5196
+ }
5197
+ };
5198
+ }
5199
+ var frac = (passed, total) => total > 0 ? passed / total : 0;
5200
+ function compareCheckOutcomes(a, b) {
5201
+ const aCrashed = a.crashed === true;
5202
+ const bCrashed = b.crashed === true;
5203
+ if (aCrashed !== bCrashed) return aCrashed ? -1 : 1;
5204
+ if (aCrashed) return 0;
5205
+ const official = frac(a.passedOfficial, a.totalOfficial) - frac(b.passedOfficial, b.totalOfficial);
5206
+ if (official !== 0) return official;
5207
+ return frac(a.passedAuthored, a.totalAuthored) - frac(b.passedAuthored, b.totalAuthored);
5208
+ }
5209
+ function visibleCheckScore(o) {
5210
+ if (o.crashed) return -1;
5211
+ return frac(o.passedOfficial, o.totalOfficial) + 1e-3 * frac(o.passedAuthored, o.totalAuthored);
5212
+ }
5213
+ function selectBestIndex(outcomes) {
5214
+ let best = 0;
5215
+ for (let i = 1; i < outcomes.length; i += 1) {
5216
+ if (compareCheckOutcomes(outcomes[i], outcomes[best]) > 0) {
5217
+ best = i;
5218
+ }
5219
+ }
5220
+ return best;
5221
+ }
5222
+ function canDisplace(challenger, incumbent) {
5223
+ if (challenger.crashed === true) return false;
5224
+ if (challenger.passedOfficial < incumbent.passedOfficial) return false;
5225
+ return compareCheckOutcomes(challenger, incumbent) > 0;
5226
+ }
5227
+ var totalChecks = (o) => o.totalOfficial + o.totalAuthored;
5228
+ var passesAllChecks = (o) => o.crashed !== true && totalChecks(o) > 0 && o.passedOfficial === o.totalOfficial && o.passedAuthored === o.totalAuthored;
5229
+ function defaultExtractCandidate(messages) {
5230
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
5231
+ const calls = messages[i]?.tool_calls;
5232
+ if (!calls) continue;
5233
+ for (let j = calls.length - 1; j >= 0; j -= 1) {
5234
+ const call = calls[j];
5235
+ if (call?.function?.name !== "submit_answer") continue;
5236
+ try {
5237
+ const args = JSON.parse(call.function.arguments ?? "{}");
5238
+ if (typeof args.answer === "string" && args.answer.trim()) return args.answer.trim();
5239
+ } catch {
5240
+ }
5241
+ }
5242
+ }
5243
+ const contents = [];
5244
+ for (const m of messages) {
5245
+ if (m.role === "assistant" && typeof m.content === "string" && m.content.trim()) {
5246
+ contents.push(m.content);
5247
+ }
5248
+ }
5249
+ const fencesOf = (text) => [...text.matchAll(/```(?:python|py)?\s*\n([\s\S]*?)```/gi)].map((m) => (m[1] ?? "").trim());
5250
+ for (let i = contents.length - 1; i >= 0; i -= 1) {
5251
+ const fences = fencesOf(contents[i]);
5252
+ for (let j = fences.length - 1; j >= 0; j -= 1) {
5253
+ if (/(^|\n)\s*def\s+\w+/.test(fences[j])) return fences[j];
5254
+ }
5255
+ }
5256
+ for (let i = contents.length - 1; i >= 0; i -= 1) {
5257
+ const fences = fencesOf(contents[i]);
5258
+ if (fences.length > 0) return fences[fences.length - 1];
5259
+ }
5260
+ return (contents[contents.length - 1] ?? "").trim();
5261
+ }
5262
+ var DIVERSE_LENSES = [
5263
+ "Answer directly and decisively from what you already know. State the single best answer without hedging.",
5264
+ "Decompose the question into the sub-facts it depends on. Establish each sub-fact explicitly, then compose them into the answer.",
5265
+ "Reason from first principles. Ignore the most obvious or popular guess; derive the answer from underlying facts and relationships.",
5266
+ "Name the most plausible WRONG answer and the trap that makes it tempting. Rule it out, then commit to the answer that survives."
5267
+ ];
5268
+ function slotLens(slot) {
5269
+ const lens = DIVERSE_LENSES[slot % DIVERSE_LENSES.length];
5270
+ const tag = slot < DIVERSE_LENSES.length ? "" : ` (variant ${Math.floor(slot / DIVERSE_LENSES.length) + 1})`;
5271
+ return `${lens}${tag}`;
5272
+ }
5273
+ function repairSteer(outcome) {
5274
+ return [
5275
+ "Your latest solution failed some of the task-visible checks.",
5276
+ "Result of running the visible checks against it:",
5277
+ "```",
5278
+ outcome.failureOutput.trim() || "(the code crashed before the checks could run)",
5279
+ "```",
5280
+ "Fix the solution so the visible checks pass. Provide the COMPLETE corrected solution the",
5281
+ "same way you provided the original (same tool or format) \u2014 not a fragment or a diff."
5282
+ ].join("\n");
5283
+ }
5284
+ function describeOutcome(label, o) {
5285
+ if (o.crashed) return `${label}: crashed before the checks could run`;
5286
+ return `${label}: official ${o.passedOfficial}/${o.totalOfficial}, authored ${o.passedAuthored}/${o.totalAuthored}`;
5287
+ }
5288
+ function structuralRollout(config = {}) {
5289
+ const policy = resolvePolicy(config.policy);
5290
+ const checkSource = config.checkSource ?? composeCheckSources(officialChecksFromMeta(), modelAuthoredChecks());
5291
+ const checkRunner = config.checkRunner ?? sandboxCheckRunner();
5292
+ const extract = config.extractCandidate ?? defaultExtractCandidate;
5293
+ const inner = defineStrategy(
5294
+ "structuralRollout",
5295
+ async (ctx) => {
5296
+ const { task, shot } = ctx;
5297
+ const progression = [];
5298
+ const receipts = [];
5299
+ let completions = 0;
5300
+ let shots = 0;
5301
+ const consult = async (instruction) => {
5302
+ const reply = await ctx.consult([], instruction);
5303
+ completions += 1;
5304
+ return reply;
5305
+ };
5306
+ const entrySymbol = resolveEntrySymbol(task);
5307
+ const checks = await checkSource.generate(task, {
5308
+ count: policy.testgen,
5309
+ ...entrySymbol ? { entrySymbol } : {},
5310
+ consult
5311
+ });
5312
+ const officialChecks = checks.filter((c) => c.kind === "official").length;
5313
+ const authoredChecks = checks.length - officialChecks;
5314
+ const runCtx = { task, ...config.box ? { box: config.box } : {} };
5315
+ const candidates = [];
5316
+ for (let i = 0; i < policy.k; i += 1) {
5317
+ const out = await shot(policy.diverse ? { steer: slotLens(i) } : void 0);
5318
+ if (!out) break;
5319
+ shots += 1;
5320
+ completions += out.completions;
5321
+ progression.push(out.score);
5322
+ const outcome = await checkRunner.run(extract(out.messages), checks, runCtx);
5323
+ candidates.push({
5324
+ index: candidates.length,
5325
+ messages: out.messages,
5326
+ outcome,
5327
+ shotScore: out.score,
5328
+ shotResolved: out.total > 0 && out.passes === out.total
5329
+ });
5330
+ }
5331
+ if (candidates.length === 0) {
5332
+ return {
5333
+ score: 0,
5334
+ resolved: false,
5335
+ completions,
5336
+ progression,
5337
+ shots,
5338
+ selection: receipts,
5339
+ repairStop: "no-candidates",
5340
+ officialChecks,
5341
+ authoredChecks
5342
+ };
5343
+ }
5344
+ let best = candidates[selectBestIndex(candidates.map((c) => c.outcome))];
5345
+ for (const c of candidates) {
5346
+ receipts.push({
5347
+ candidateIndex: c.index,
5348
+ selected: false,
5349
+ score: visibleCheckScore(c.outcome),
5350
+ reason: describeOutcome("sample", c.outcome),
5351
+ selector: "driver"
5352
+ });
5353
+ }
5354
+ let seq = candidates.length;
5355
+ let repairStop = "already-passing";
5356
+ if (!passesAllChecks(best.outcome)) {
5357
+ if (best.outcome.crashed !== true && totalChecks(best.outcome) === 0) {
5358
+ repairStop = "no-signal";
5359
+ } else {
5360
+ repairStop = "rounds-exhausted";
5361
+ for (let r = 0; r < policy.repairRounds; r += 1) {
5362
+ const out = await shot({ messages: best.messages, steer: repairSteer(best.outcome) });
5363
+ if (!out) break;
5364
+ shots += 1;
5365
+ completions += out.completions;
5366
+ progression.push(out.score);
5367
+ const outcome = await checkRunner.run(extract(out.messages), checks, runCtx);
5368
+ const displaced = canDisplace(outcome, best.outcome);
5369
+ 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)";
5370
+ receipts.push({
5371
+ candidateIndex: seq,
5372
+ selected: false,
5373
+ score: visibleCheckScore(outcome),
5374
+ reason: describeOutcome(label, outcome),
5375
+ selector: "driver"
5376
+ });
5377
+ if (displaced) {
5378
+ best = {
5379
+ index: seq,
5380
+ messages: out.messages,
5381
+ outcome,
5382
+ shotScore: out.score,
5383
+ shotResolved: out.total > 0 && out.passes === out.total
5384
+ };
5385
+ }
5386
+ seq += 1;
5387
+ if (passesAllChecks(best.outcome)) {
5388
+ repairStop = "repaired-pass";
5389
+ break;
5390
+ }
5391
+ }
5392
+ }
5393
+ }
5394
+ const winner = receipts.find((r) => r.candidateIndex === best.index);
5395
+ if (winner) winner.selected = true;
5396
+ return {
5397
+ score: best.shotScore,
5398
+ resolved: best.shotResolved,
5399
+ completions,
5400
+ progression,
5401
+ shots,
5402
+ selection: receipts,
5403
+ repairStop,
5404
+ officialChecks,
5405
+ authoredChecks
5406
+ };
5407
+ }
5408
+ );
5409
+ if (policy.temperature === void 0) return inner;
5410
+ return {
5411
+ name: inner.name,
5412
+ driver: (surface, task, opts, budget) => inner.driver(surface, task, { ...opts, temperature: policy.temperature }, budget)
5413
+ };
5414
+ }
5415
+
5032
5416
  // src/runtime/supervise/detector-monitor.ts
5033
5417
  import {
5034
5418
  argHash,
@@ -5845,6 +6229,30 @@ export {
5845
6229
  createSandboxPromptBackend,
5846
6230
  createOpenAICompatibleBackend,
5847
6231
  normalizeBackendStreamEvent,
6232
+ defaultAnalystInstruction,
6233
+ observe,
6234
+ renderReport,
6235
+ depthStrategy,
6236
+ breadthStrategy,
6237
+ sample,
6238
+ refine,
6239
+ defineStrategy,
6240
+ adaptiveRefine,
6241
+ sampleThenRefine,
6242
+ runAgentic,
6243
+ defaultStructuralRolloutPolicy,
6244
+ filterAuthoredAsserts,
6245
+ modelAuthoredChecks,
6246
+ officialChecksFromMeta,
6247
+ composeCheckSources,
6248
+ resolveEntrySymbol,
6249
+ sandboxCheckRunner,
6250
+ compareCheckOutcomes,
6251
+ visibleCheckScore,
6252
+ selectBestIndex,
6253
+ canDisplace,
6254
+ defaultExtractCandidate,
6255
+ structuralRollout,
5848
6256
  anytimeReport,
5849
6257
  renderAnytimeTable,
5850
6258
  defaultAuditorInstruction,
@@ -5867,9 +6275,6 @@ export {
5867
6275
  naiveDriver,
5868
6276
  dumbDriver,
5869
6277
  defineLeaderboard,
5870
- defaultAnalystInstruction,
5871
- observe,
5872
- renderReport,
5873
6278
  harvestCorpus,
5874
6279
  inProcessSandboxClient,
5875
6280
  createMcpEnvironment,
@@ -5896,14 +6301,6 @@ export {
5896
6301
  trajectoryReport,
5897
6302
  equalKOnCost,
5898
6303
  promotionGate,
5899
- depthStrategy,
5900
- breadthStrategy,
5901
- sample,
5902
- refine,
5903
- defineStrategy,
5904
- adaptiveRefine,
5905
- sampleThenRefine,
5906
- runAgentic,
5907
6304
  runBenchmark,
5908
6305
  printBenchmarkReport,
5909
6306
  SandboxRunAbortError,
@@ -5937,4 +6334,4 @@ export {
5937
6334
  computeFindingId,
5938
6335
  makeFinding2 as makeFinding
5939
6336
  };
5940
- //# sourceMappingURL=chunk-4IBAMGBE.js.map
6337
+ //# sourceMappingURL=chunk-AD7JW4QG.js.map