@tangle-network/agent-runtime 0.94.6 → 0.94.8

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 (63) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +4 -4
  3. package/dist/{agentic-generator-CL1q0H91.d.ts → agentic-generator-1g7GDba7.d.ts} +73 -6
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/analyst-loop.js +2 -2
  6. package/dist/{chunk-GKZ6DFDN.js → chunk-7HH22XN4.js} +105 -27
  7. package/dist/chunk-7HH22XN4.js.map +1 -0
  8. package/dist/{chunk-JMT5VYY3.js → chunk-7NCP74SL.js} +174 -48
  9. package/dist/chunk-7NCP74SL.js.map +1 -0
  10. package/dist/{chunk-WQA5Y6PD.js → chunk-EP6RVHMX.js} +3 -3
  11. package/dist/chunk-EP6RVHMX.js.map +1 -0
  12. package/dist/{chunk-LWNMCOEA.js → chunk-FRXDOBFP.js} +3 -3
  13. package/dist/chunk-GHXW56PO.js +526 -0
  14. package/dist/chunk-GHXW56PO.js.map +1 -0
  15. package/dist/{chunk-63TIZHMI.js → chunk-KYPVUEJ4.js} +4 -4
  16. package/dist/{chunk-FVJ7M3DA.js → chunk-M22PL4GH.js} +1 -1
  17. package/dist/chunk-M22PL4GH.js.map +1 -0
  18. package/dist/{chunk-4VMRCEI6.js → chunk-MSUWXCHD.js} +2 -2
  19. package/dist/{chunk-ZQZX77MM.js → chunk-QDSOD7RC.js} +2 -2
  20. package/dist/{chunk-RNWDH5Z3.js → chunk-TNUBPPZA.js} +2 -2
  21. package/dist/{completion-gate-CfX2thvL.d.ts → completion-gate-tzwyyD-E.d.ts} +2 -2
  22. package/dist/{coordination-pOGZuYS7.d.ts → coordination-o0TzS7Ms.d.ts} +5 -5
  23. package/dist/environment-provider.d.ts +2 -2
  24. package/dist/{improve-Ciuvu2jh.d.ts → improve-DZeatcs7.d.ts} +19 -8
  25. package/dist/index.d.ts +20 -17
  26. package/dist/index.js +37 -20
  27. package/dist/index.js.map +1 -1
  28. package/dist/intelligence.d.ts +6 -6
  29. package/dist/intelligence.js +41 -17
  30. package/dist/intelligence.js.map +1 -1
  31. package/dist/knowledge.d.ts +7 -7
  32. package/dist/knowledge.js +4 -4
  33. package/dist/lifecycle.d.ts +3 -3
  34. package/dist/lifecycle.js +2 -2
  35. package/dist/{local-harness-CePtFrwu.d.ts → local-harness-ZLMkKdZc.d.ts} +1 -1
  36. package/dist/{loop-runner-bin-B4PwjVaF.d.ts → loop-runner-bin-iTSxSmpv.d.ts} +2 -2
  37. package/dist/loop-runner-bin.d.ts +6 -6
  38. package/dist/loop-runner-bin.js +6 -6
  39. package/dist/loops.d.ts +36 -23
  40. package/dist/loops.js +4 -4
  41. package/dist/mcp/bin.js +3 -3
  42. package/dist/mcp/index.d.ts +10 -10
  43. package/dist/mcp/index.js +5 -5
  44. package/dist/{mcp-serve-verifier-D7hCZIkT.d.ts → mcp-serve-verifier-BO4MEsR3.d.ts} +1 -1
  45. package/dist/{openai-tools-BMOu1t3A.d.ts → openai-tools-0wACz8f8.d.ts} +1 -1
  46. package/dist/profiles.d.ts +1 -1
  47. package/dist/{sanitize-Dr3SliRC.d.ts → sanitize-Dcbjp0tU.d.ts} +1 -1
  48. package/dist/{supervise-Y3w878fN.d.ts → supervise-CRwaJIkd.d.ts} +4 -4
  49. package/dist/{types-Kjr5W6OF.d.ts → types-CKmyZ9TP.d.ts} +4 -7
  50. package/dist/{types-DHLXdLVN.d.ts → types-CogNCaw7.d.ts} +1 -1
  51. package/dist/{worktree-fanout-DmBvR-_O.d.ts → worktree-fanout-BJy24LYe.d.ts} +4 -4
  52. package/package.json +4 -4
  53. package/dist/chunk-4WWSICFY.js +0 -210
  54. package/dist/chunk-4WWSICFY.js.map +0 -1
  55. package/dist/chunk-FVJ7M3DA.js.map +0 -1
  56. package/dist/chunk-GKZ6DFDN.js.map +0 -1
  57. package/dist/chunk-JMT5VYY3.js.map +0 -1
  58. package/dist/chunk-WQA5Y6PD.js.map +0 -1
  59. /package/dist/{chunk-LWNMCOEA.js.map → chunk-FRXDOBFP.js.map} +0 -0
  60. /package/dist/{chunk-63TIZHMI.js.map → chunk-KYPVUEJ4.js.map} +0 -0
  61. /package/dist/{chunk-4VMRCEI6.js.map → chunk-MSUWXCHD.js.map} +0 -0
  62. /package/dist/{chunk-ZQZX77MM.js.map → chunk-QDSOD7RC.js.map} +0 -0
  63. /package/dist/{chunk-RNWDH5Z3.js.map → chunk-TNUBPPZA.js.map} +0 -0
@@ -0,0 +1,526 @@
1
+ import {
2
+ harnessInvocation,
3
+ runLocalHarness
4
+ } from "./chunk-EP6RVHMX.js";
5
+
6
+ // src/improvement/agentic-generator.ts
7
+ import { spawnSync } from "child_process";
8
+ import { createHash } from "crypto";
9
+ import { existsSync, readFileSync, rmSync } from "fs";
10
+ import { join, resolve, sep } from "path";
11
+ import {
12
+ applyWorkspacePlan,
13
+ materializeProfile
14
+ } from "@tangle-network/agent-profile-materialize";
15
+ var RAW_TRACE_ANALYST_ID = "raw-trace-distiller";
16
+ var RAW_TRACE_AREA = "raw-trace-context";
17
+ var RAW_TRACE_DIAGNOSIS_PATH = ".improve/raw-trace-diagnosis.md";
18
+ var AGENTIC_PROFILE_RESOURCE_ROOT = ".agent-runtime-profile-resources";
19
+ function agenticGenerator(opts = {}) {
20
+ const harness = opts.harness ?? "claude";
21
+ if (opts.codexReproducible && harness !== "codex") {
22
+ throw new Error("agenticGenerator: codexReproducible requires harness 'codex'");
23
+ }
24
+ if (opts.codexReproducible && !opts.profile) {
25
+ throw new Error("agenticGenerator: codexReproducible requires an explicit author profile");
26
+ }
27
+ if (opts.codexReadDeniedPaths && !opts.codexReproducible) {
28
+ throw new Error("agenticGenerator: codexReadDeniedPaths requires codexReproducible");
29
+ }
30
+ if (opts.maximumCharge && !opts.codexReproducible) {
31
+ throw new Error("agenticGenerator: maximumCharge requires codexReproducible");
32
+ }
33
+ const profileResourcePlan = opts.codexReproducible ? authorProfileResourcePlan(opts.profile) : null;
34
+ const buildPrompt = opts.buildPrompt ?? defaultBuildPrompt;
35
+ const run = opts.runHarness ?? runLocalHarness;
36
+ const dirty = opts.isDirty ?? worktreeDirty;
37
+ const verify = opts.verify;
38
+ return {
39
+ kind: `agentic:${harness}`,
40
+ // The seed repo + (in rawTraceContext mode) the raw-trace filesystem context
41
+ // are the change signal — an agentic coder proposes from them even when the
42
+ // distiller yielded zero findings. Without this, the improvementDriver's
43
+ // empty-findings guard short-circuits and generates ZERO candidates on the
44
+ // first (and, for a single-generation run, only) proposal round.
45
+ proposesWithoutFindings: true,
46
+ async generate({
47
+ worktreePath,
48
+ report,
49
+ findings,
50
+ maxShots,
51
+ signal,
52
+ generation,
53
+ candidateIndex,
54
+ costLedger,
55
+ costPhase
56
+ }) {
57
+ if (opts.codexReproducible && !costLedger) {
58
+ throw new Error(
59
+ "agenticGenerator: reproducible Codex requires the run-wide CostLedger supplied by agent-eval 0.117+"
60
+ );
61
+ }
62
+ const basePrompt = appendProfileResourcePaths(
63
+ buildPrompt({ report, findings }),
64
+ profileResourcePlan
65
+ );
66
+ const needsRawTraceEvidence = requiresRawTraceEvidence(findings);
67
+ const shots = Math.max(1, maxShots);
68
+ let attemptNote = "";
69
+ for (let shot = 0; shot < shots; shot++) {
70
+ if (signal.aborted) break;
71
+ const taskPrompt = attemptNote ? `${basePrompt}
72
+
73
+ ${attemptNote}` : basePrompt;
74
+ const invocation = opts.profile ? harnessInvocation(harness, opts.profile, taskPrompt, {
75
+ dangerouslySkipPermissions: harness === "claude",
76
+ ...opts.codexReproducible ? { codexReproducible: true } : {}
77
+ }) : void 0;
78
+ const exactPrompt = invocation?.prompt ?? taskPrompt;
79
+ const readDeniedPaths = typeof opts.codexReadDeniedPaths === "function" ? opts.codexReadDeniedPaths(worktreePath) : opts.codexReadDeniedPaths;
80
+ const startedAt = /* @__PURE__ */ new Date();
81
+ let harnessResult = null;
82
+ let profileWorkspaceReceipt = null;
83
+ let costReceipt = null;
84
+ let costCallId = null;
85
+ let shotError = null;
86
+ try {
87
+ const execute = async (executionSignal) => {
88
+ harnessResult = await withAuthorProfileResources(
89
+ profileResourcePlan,
90
+ worktreePath,
91
+ async (receipt) => {
92
+ profileWorkspaceReceipt = receipt;
93
+ const result2 = await run({
94
+ harness,
95
+ cwd: worktreePath,
96
+ taskPrompt,
97
+ ...invocation ? { invocation: { command: invocation.command, args: invocation.args } } : {},
98
+ // The candidate worktree is isolated and must be editable without an
99
+ // interactive permission prompt. Other runLocalHarness callers remain
100
+ // permission-safe by default.
101
+ dangerouslySkipPermissions: harness === "claude",
102
+ ...opts.codexReproducible ? { codexReproducible: true } : {},
103
+ ...readDeniedPaths ? { codexReadDeniedPaths: readDeniedPaths } : {},
104
+ timeoutMs: opts.timeoutMs,
105
+ signal: executionSignal
106
+ });
107
+ harnessResult = result2;
108
+ return result2;
109
+ }
110
+ );
111
+ const failure = shotFailure(harnessResult, exactPrompt, opts.codexReproducible === true);
112
+ if (failure) throw failure;
113
+ return harnessResult;
114
+ };
115
+ if (opts.codexReproducible) {
116
+ const ledger = costLedger;
117
+ const model = opts.profile?.model?.default;
118
+ if (!model) {
119
+ throw new Error("agenticGenerator: reproducible Codex requires profile.model.default");
120
+ }
121
+ const paid = await ledger.runPaidCall({
122
+ channel: "driver",
123
+ phase: costPhase ?? "search.proposal",
124
+ actor: `agentic-generator:${harness}`,
125
+ model,
126
+ tags: {
127
+ generation: String(generation ?? -1),
128
+ candidateIndex: String(candidateIndex ?? -1),
129
+ shot: String(shot + 1)
130
+ },
131
+ signal,
132
+ ...opts.maximumCharge ? { maximumCharge: opts.maximumCharge } : {},
133
+ execute,
134
+ receipt: (result2) => costReceiptFromHarness(result2, model),
135
+ receiptFromError: () => harnessResult?.usage ? costReceiptFromHarness(harnessResult, model) : void 0
136
+ });
137
+ costCallId = paid.callId ?? null;
138
+ costReceipt = paid.receipt ?? null;
139
+ if (!paid.succeeded) throw paid.error;
140
+ harnessResult = paid.value;
141
+ } else {
142
+ harnessResult = await execute(signal);
143
+ }
144
+ } catch (cause) {
145
+ shotError = cause instanceof Error ? cause : new Error(String(cause));
146
+ }
147
+ await emitShotReceipt(
148
+ opts.onShotCompleted,
149
+ shotReceipt({
150
+ generation,
151
+ candidateIndex,
152
+ shot,
153
+ maxShots: shots,
154
+ harness,
155
+ profile: opts.profile,
156
+ prompt: exactPrompt,
157
+ startedAt,
158
+ completedAt: /* @__PURE__ */ new Date(),
159
+ result: harnessResult,
160
+ profileWorkspaceReceipt,
161
+ costCallId,
162
+ costReceipt,
163
+ error: shotError
164
+ }),
165
+ shotError
166
+ );
167
+ if (!harnessResult) {
168
+ throw new Error("agenticGenerator: author shot completed without a harness result");
169
+ }
170
+ if (!dirty(worktreePath)) {
171
+ attemptNote = EMPTY_TREE_NOTE;
172
+ continue;
173
+ }
174
+ if (needsRawTraceEvidence) {
175
+ const problem = rawTraceEvidenceProblem(worktreePath, findings);
176
+ if (problem) {
177
+ attemptNote = problem;
178
+ continue;
179
+ }
180
+ }
181
+ if (!verify) {
182
+ return { applied: true, summary: summarize(findings) };
183
+ }
184
+ const result = await verify(worktreePath);
185
+ if (result.ok) {
186
+ return { applied: true, summary: summarize(findings) };
187
+ }
188
+ attemptNote = failureNote(result.feedback);
189
+ }
190
+ return { applied: false, summary: "" };
191
+ }
192
+ };
193
+ }
194
+ function authorProfileResourcePlan(profile) {
195
+ const resources = profile.resources;
196
+ if (!resources) return null;
197
+ const unsupportedKinds = [
198
+ resources.tools?.length ? "tools" : null,
199
+ resources.skills?.length ? "skills" : null,
200
+ resources.agents?.length ? "agents" : null
201
+ ].filter((kind) => kind !== null);
202
+ if (unsupportedKinds.length > 0) {
203
+ throw new Error(
204
+ `agenticGenerator: reproducible Codex author resources support files only; unsupported: ${unsupportedKinds.join(", ")}`
205
+ );
206
+ }
207
+ if (!resources.files || resources.files.length === 0) return null;
208
+ const plan = materializeProfile(
209
+ {
210
+ name: profile.name,
211
+ resources: { files: resources.files }
212
+ },
213
+ "codex"
214
+ );
215
+ if (plan.unsupported.length > 0) {
216
+ throw new Error(
217
+ `agenticGenerator: author profile files could not be materialized: ${plan.unsupported.map((item) => item.reason).join("; ")}`
218
+ );
219
+ }
220
+ if (Object.keys(plan.env).length > 0 || plan.flags.length > 0) {
221
+ throw new Error(
222
+ "agenticGenerator: generic author profile files unexpectedly changed spawn values"
223
+ );
224
+ }
225
+ const virtualRoot = resolve("/", AGENTIC_PROFILE_RESOURCE_ROOT);
226
+ const seen = /* @__PURE__ */ new Set();
227
+ for (const file of plan.files) {
228
+ const target = resolve("/", file.relPath);
229
+ if (!target.startsWith(`${virtualRoot}${sep}`)) {
230
+ throw new Error(
231
+ `agenticGenerator: author profile file must be below ${AGENTIC_PROFILE_RESOURCE_ROOT}: ${file.relPath}`
232
+ );
233
+ }
234
+ if (seen.has(target)) {
235
+ throw new Error(`agenticGenerator: duplicate author profile file path: ${file.relPath}`);
236
+ }
237
+ seen.add(target);
238
+ }
239
+ return plan;
240
+ }
241
+ function appendProfileResourcePaths(prompt, plan) {
242
+ if (!plan) return prompt;
243
+ return [
244
+ prompt,
245
+ "",
246
+ "Profile resource files available for this shot:",
247
+ ...plan.files.map((file) => `- ${file.relPath}`)
248
+ ].join("\n");
249
+ }
250
+ async function withAuthorProfileResources(plan, worktreePath, run) {
251
+ if (!plan) return run(null);
252
+ const rootPath = resolve(worktreePath, AGENTIC_PROFILE_RESOURCE_ROOT);
253
+ if (existsSync(rootPath)) {
254
+ throw new Error(
255
+ `agenticGenerator: ephemeral author profile root already exists: ${AGENTIC_PROFILE_RESOURCE_ROOT}`
256
+ );
257
+ }
258
+ let value;
259
+ let primaryError;
260
+ try {
261
+ const receipt = applyWorkspacePlan(plan, worktreePath);
262
+ value = await run(receipt);
263
+ } catch (cause) {
264
+ primaryError = cause;
265
+ }
266
+ let cleanupError;
267
+ try {
268
+ rmSync(rootPath, { recursive: true, force: true });
269
+ if (existsSync(rootPath)) {
270
+ throw new Error(
271
+ `agenticGenerator: ephemeral author profile root survived cleanup: ${AGENTIC_PROFILE_RESOURCE_ROOT}`
272
+ );
273
+ }
274
+ } catch (cause) {
275
+ cleanupError = cause;
276
+ }
277
+ if (primaryError !== void 0 && cleanupError !== void 0) {
278
+ throw new AggregateError(
279
+ [primaryError, cleanupError],
280
+ "agenticGenerator: author shot and profile resource cleanup both failed"
281
+ );
282
+ }
283
+ if (primaryError !== void 0) throw primaryError;
284
+ if (cleanupError !== void 0) throw cleanupError;
285
+ return value;
286
+ }
287
+ async function emitShotReceipt(callback, receipt, primaryError) {
288
+ try {
289
+ await callback?.(receipt);
290
+ } catch (callbackError) {
291
+ if (primaryError !== null) {
292
+ throw new AggregateError(
293
+ [primaryError, callbackError],
294
+ "agenticGenerator: author shot failed and its receipt could not be persisted"
295
+ );
296
+ }
297
+ throw callbackError;
298
+ }
299
+ if (primaryError !== null) throw primaryError;
300
+ }
301
+ function shotReceipt(input) {
302
+ const error = input.error ? {
303
+ name: input.error instanceof Error ? input.error.name : "Error",
304
+ message: input.error instanceof Error ? input.error.message : String(input.error)
305
+ } : null;
306
+ const result = input.result;
307
+ const costBasis = costBasisFor(input.costReceipt);
308
+ return {
309
+ schemaVersion: 1,
310
+ generation: input.generation ?? null,
311
+ candidateIndex: input.candidateIndex ?? null,
312
+ shot: input.shot + 1,
313
+ maxShots: input.maxShots,
314
+ harness: input.harness,
315
+ model: input.profile?.model?.default ?? null,
316
+ reasoningEffort: input.profile?.model?.reasoningEffort ?? null,
317
+ promptSha256: sha256(input.prompt),
318
+ startedAt: input.startedAt.toISOString(),
319
+ completedAt: input.completedAt.toISOString(),
320
+ durationMs: result?.durationMs ?? input.completedAt.getTime() - input.startedAt.getTime(),
321
+ exitCode: result?.exitCode ?? null,
322
+ timedOut: result?.timedOut ?? false,
323
+ killedBySignal: result?.killedBySignal ?? null,
324
+ stdoutBytes: result ? Buffer.byteLength(result.stdout) : null,
325
+ stdoutSha256: result ? sha256(result.stdout) : null,
326
+ stderrBytes: result ? Buffer.byteLength(result.stderr) : null,
327
+ stderrSha256: result ? sha256(result.stderr) : null,
328
+ usage: result?.usage ? { ...result.usage } : null,
329
+ profileWorkspacePlanDigest: input.profileWorkspaceReceipt?.workspacePlanDigest ?? null,
330
+ profileWorkspaceFileCount: input.profileWorkspaceReceipt?.written.length ?? 0,
331
+ costCallId: input.costCallId,
332
+ costBasis,
333
+ costUsd: costBasis === "unknown" ? null : input.costReceipt?.costUsd ?? null,
334
+ costUsdKnown: costBasis === "provider-reported",
335
+ evidence: result?.evidence ? {
336
+ ...result.evidence,
337
+ readDeniedPaths: [...result.evidence.readDeniedPaths],
338
+ policy: { ...result.evidence.policy }
339
+ } : null,
340
+ error
341
+ };
342
+ }
343
+ function costBasisFor(receipt) {
344
+ if (receipt === null || receipt.costUnknown) return "unknown";
345
+ return receipt.actualCostUsd === void 0 ? "estimated-pricing" : "provider-reported";
346
+ }
347
+ function shotFailure(result, exactPrompt, codexReproducible) {
348
+ if (result.timedOut) {
349
+ return new Error("agenticGenerator: author shot timed out");
350
+ }
351
+ if (result.killedBySignal) {
352
+ return new Error(`agenticGenerator: author shot was killed by ${result.killedBySignal}`);
353
+ }
354
+ if (result.exitCode !== 0) {
355
+ return new Error(`agenticGenerator: author shot exited with code ${String(result.exitCode)}`);
356
+ }
357
+ if (!codexReproducible) return null;
358
+ if (!result.usage || !result.evidence) {
359
+ return new Error(
360
+ "agenticGenerator: reproducible Codex shot completed without usage or execution evidence"
361
+ );
362
+ }
363
+ const expectedPromptSha256 = sha256(exactPrompt).slice("sha256:".length);
364
+ if (result.evidence.requestedPromptSha256 !== expectedPromptSha256) {
365
+ return new Error(
366
+ "agenticGenerator: reproducible Codex prompt evidence does not match the exact authored prompt"
367
+ );
368
+ }
369
+ return null;
370
+ }
371
+ function costReceiptFromHarness(result, model) {
372
+ if (!result.usage) {
373
+ throw new Error("agenticGenerator: author shot did not report terminal token usage");
374
+ }
375
+ return {
376
+ model,
377
+ inputTokens: result.usage.inputTokens - result.usage.cachedInputTokens,
378
+ outputTokens: result.usage.outputTokens,
379
+ ...result.usage.cachedInputTokens > 0 ? { cachedTokens: result.usage.cachedInputTokens } : {}
380
+ };
381
+ }
382
+ function sha256(value) {
383
+ return `sha256:${createHash("sha256").update(value).digest("hex")}`;
384
+ }
385
+ function defaultBuildPrompt(args) {
386
+ const lines = [
387
+ "You are improving this codebase based on an evaluation analysis.",
388
+ "Make the smallest set of edits that addresses the findings below, then stop.",
389
+ "Do not change unrelated code. Do not commit \u2014 leave changes in the working tree.",
390
+ "",
391
+ "Findings:"
392
+ ];
393
+ for (const f of args.findings) {
394
+ const where = f.subject ? ` [${f.subject}]` : "";
395
+ lines.push(`- (${f.severity})${where} ${f.claim}`);
396
+ if (f.recommended_action) lines.push(` \u2192 ${f.recommended_action}`);
397
+ }
398
+ if (requiresRawTraceEvidence(args.findings)) {
399
+ lines.push(
400
+ "",
401
+ "Raw trace evidence requirement:",
402
+ `- Inspect at least one raw trace path named above before editing.`,
403
+ `- Write ${RAW_TRACE_DIAGNOSIS_PATH} in this worktree.`,
404
+ "- Include the exact trace path(s) inspected, the failure mechanism, and the code change made.",
405
+ "- A candidate without this file, or with only this file changed, is discarded."
406
+ );
407
+ }
408
+ return lines.join("\n");
409
+ }
410
+ var EMPTY_TREE_NOTE = "NOTE: your previous attempt left the working tree unchanged. Make the concrete file edits now.";
411
+ function failureNote(feedback) {
412
+ const detail = feedback?.trim();
413
+ return [
414
+ "NOTE: your edits are in the working tree but verification FAILED.",
415
+ "Fix the problem in place \u2014 build on your existing edits, do not revert them.",
416
+ detail ? `Verifier output:
417
+ ${truncate(detail, 4e3)}` : "No verifier detail was captured."
418
+ ].join("\n");
419
+ }
420
+ function rawTraceEvidenceProblem(worktreePath, findings) {
421
+ const changedPaths = worktreeChangedPaths(worktreePath);
422
+ const substantive = changedPaths.filter((path) => path !== RAW_TRACE_DIAGNOSIS_PATH);
423
+ if (substantive.length === 0) {
424
+ return [
425
+ `NOTE: raw-trace mode requires a real code/config edit in addition to ${RAW_TRACE_DIAGNOSIS_PATH}.`,
426
+ "Your previous attempt only changed the diagnosis artifact. Inspect the cited traces and make the causal code change."
427
+ ].join("\n");
428
+ }
429
+ const diagnosisPath = join(worktreePath, RAW_TRACE_DIAGNOSIS_PATH);
430
+ if (!existsSync(diagnosisPath)) {
431
+ return [
432
+ `NOTE: raw-trace mode requires ${RAW_TRACE_DIAGNOSIS_PATH}.`,
433
+ "Before retrying, inspect at least one cited spans.jsonl/cached-result.json/artifact path, then write the diagnosis file with the exact path, failure mechanism, and code change."
434
+ ].join("\n");
435
+ }
436
+ const body = readFileSync(diagnosisPath, "utf8");
437
+ const evidencePaths = traceEvidencePaths(findings);
438
+ if (evidencePaths.length > 0 && !evidencePaths.some((path) => body.includes(path))) {
439
+ return [
440
+ `${RAW_TRACE_DIAGNOSIS_PATH} exists, but it does not cite any exact raw trace path from the findings.`,
441
+ `Cite at least one of these inspected paths exactly: ${evidencePaths.slice(0, 5).join(", ")}`
442
+ ].join("\n");
443
+ }
444
+ return null;
445
+ }
446
+ function requiresRawTraceEvidence(findings) {
447
+ return findings.some((finding) => {
448
+ const f = finding;
449
+ return f.analyst_id === RAW_TRACE_ANALYST_ID || f.area === RAW_TRACE_AREA;
450
+ });
451
+ }
452
+ function traceEvidencePaths(findings) {
453
+ const out = [];
454
+ for (const finding of findings) {
455
+ const refs = finding.evidence_refs;
456
+ if (!Array.isArray(refs)) continue;
457
+ for (const ref of refs) {
458
+ if (!ref || typeof ref !== "object") continue;
459
+ const uri = ref.uri;
460
+ if (typeof uri === "string" && uri.length > 0) out.push(uri);
461
+ }
462
+ }
463
+ return [...new Set(out)];
464
+ }
465
+ function commandVerifier(command, args = [], timeoutMs = 3e5) {
466
+ return (worktreePath) => {
467
+ const result = spawnSync(command, args, {
468
+ cwd: worktreePath,
469
+ encoding: "utf-8",
470
+ timeout: timeoutMs
471
+ });
472
+ if (result.signal) {
473
+ return {
474
+ ok: false,
475
+ feedback: `verifier '${command}' killed by ${result.signal} (likely timeout after ${timeoutMs}ms)`
476
+ };
477
+ }
478
+ if (result.error) {
479
+ const code = result.error.code;
480
+ if (code === "ENOENT") {
481
+ throw new Error(
482
+ `commandVerifier: '${command}' not found in PATH (setup bug, not a failed candidate)`
483
+ );
484
+ }
485
+ throw new Error(`commandVerifier: '${command}' failed to spawn: ${result.error.message}`);
486
+ }
487
+ if (result.status === 0) return { ok: true };
488
+ const out = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
489
+ return { ok: false, feedback: out.length > 0 ? out : `exit ${result.status}` };
490
+ };
491
+ }
492
+ function summarize(findings) {
493
+ if (findings.length === 0) return "agentic improvement";
494
+ if (findings.length === 1) return `agentic: ${truncate(findings[0].claim, 64)}`;
495
+ return `agentic: ${findings.length} findings addressed`;
496
+ }
497
+ function truncate(s, n) {
498
+ return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
499
+ }
500
+ function worktreeDirty(worktreePath) {
501
+ return worktreeChangedPaths(worktreePath).length > 0;
502
+ }
503
+ function worktreeChangedPaths(worktreePath) {
504
+ const result = spawnSync("git", ["status", "--porcelain", "--untracked-files=all"], {
505
+ cwd: worktreePath,
506
+ encoding: "utf-8"
507
+ });
508
+ if (result.error) {
509
+ throw new Error(
510
+ `agenticGenerator: git status failed to spawn in ${worktreePath}: ${result.error.message}`
511
+ );
512
+ }
513
+ if (result.status !== 0) {
514
+ throw new Error(
515
+ `agenticGenerator: git status exited ${result.status} in ${worktreePath}: ${result.stderr.trim()}`
516
+ );
517
+ }
518
+ return result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => line.slice(3).trim());
519
+ }
520
+
521
+ export {
522
+ AGENTIC_PROFILE_RESOURCE_ROOT,
523
+ agenticGenerator,
524
+ commandVerifier
525
+ };
526
+ //# sourceMappingURL=chunk-GHXW56PO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/improvement/agentic-generator.ts"],"sourcesContent":["/**\n *\n * `agenticGenerator` — the full-agentic `CandidateGenerator`: the\n * `shots=N, sandbox=on` setting of the one `improvementDriver`. It runs a real\n * coding harness (claude / codex / opencode) inside the candidate worktree the\n * driver already created, letting the agent read the codebase + the research\n * report and make the change in place. The driver then commits the worktree\n * into a `CodeSurface`.\n *\n * Mechanism: identical to the proven Phase-2.8 in-process executor — spawn the\n * harness as a subprocess with `cwd` = the worktree, on the same filesystem,\n * so edits land in place (no sandbox-mount round-trip). `runLocalHarness` is\n * the verified primitive. The OUTER sandbox is the improvement loop's own\n * execution context; the generator does not nest a second sandbox per\n * candidate (which would reintroduce a host↔sandbox worktree-transport\n * problem that does not need solving here).\n *\n * `maxShots` is the DEPTH dial — a multi-shot verify-in-session loop, NOT the\n * kernel `runLoop`. Each shot runs one full harness session in the (persistent)\n * worktree; between shots the loop refines based on what the last shot produced:\n * - empty tree → \"you changed nothing, make the edits\" → retry\n * - dirty + `verify` fails → feed the verifier's failure into the next shot\n * (the worktree persists, so the harness RESUMES atop its own failing\n * edits with the error in hand — no `--resume` session plumbing needed,\n * and harness-agnostic across claude/codex/opencode)\n * - dirty + `verify` ok (or no verifier configured) → return the candidate\n * A candidate that never verifies within `maxShots` is discarded (`applied:\n * false`), never shipped — if you configured a verifier, a non-passing tree is\n * not a candidate. With no verifier the legacy behavior holds: first dirty shot\n * is the candidate.\n *\n * @experimental\n */\n\nimport { spawnSync } from 'node:child_process'\nimport { createHash } from 'node:crypto'\nimport { existsSync, readFileSync, rmSync } from 'node:fs'\nimport { join, resolve, sep } from 'node:path'\nimport type {\n AnalystFinding,\n CostLedger,\n CostReceipt,\n CostReceiptInput,\n MaximumCharge,\n} from '@tangle-network/agent-eval'\nimport type { AgentProfile, ReasoningEffort } from '@tangle-network/agent-interface'\nimport {\n applyWorkspacePlan,\n materializeProfile,\n type WorkspacePlan,\n type WorkspacePlanReceipt,\n} from '@tangle-network/agent-profile-materialize'\nimport {\n type CodexExecutionEvidence,\n type CodexTokenUsage,\n harnessInvocation,\n type LocalHarness,\n type LocalHarnessResult,\n runLocalHarness,\n} from '../mcp/local-harness'\nimport type { CandidateGenerator } from './improvement-driver'\n\nconst RAW_TRACE_ANALYST_ID = 'raw-trace-distiller'\nconst RAW_TRACE_AREA = 'raw-trace-context'\nconst RAW_TRACE_DIAGNOSIS_PATH = '.improve/raw-trace-diagnosis.md'\n\n/** Dedicated ephemeral root for generic author-profile files. Every declared\n * file must live below this root so cleanup cannot alter candidate-owned files. */\nexport const AGENTIC_PROFILE_RESOURCE_ROOT = '.agent-runtime-profile-resources'\n\n/** Outcome of verifying a candidate worktree. `feedback` (compiler errors,\n * failing test output) is fed into the next shot when `ok` is false. */\nexport interface VerifyResult {\n ok: boolean\n feedback?: string\n}\n\n/** Verifies the edited worktree. Sync or async; throws only on a setup fault\n * (a candidate that fails verification returns `{ok:false}`, it does not\n * throw). */\nexport type Verifier = (worktreePath: string) => Promise<VerifyResult> | VerifyResult\n\nexport interface AgenticGeneratorShotReceipt {\n readonly schemaVersion: 1\n readonly generation: number | null\n readonly candidateIndex: number | null\n /** One-based shot number within this candidate. */\n readonly shot: number\n readonly maxShots: number\n readonly harness: LocalHarness\n readonly model: string | null\n readonly reasoningEffort: ReasoningEffort | null\n readonly promptSha256: `sha256:${string}`\n readonly startedAt: string\n readonly completedAt: string\n readonly durationMs: number\n readonly exitCode: number | null\n readonly timedOut: boolean\n readonly killedBySignal: NodeJS.Signals | null\n readonly stdoutBytes: number | null\n readonly stdoutSha256: `sha256:${string}` | null\n readonly stderrBytes: number | null\n readonly stderrSha256: `sha256:${string}` | null\n readonly usage: CodexTokenUsage | null\n /** Digest of the exact profile-file workspace plan applied for this shot. */\n readonly profileWorkspacePlanDigest: string | null\n readonly profileWorkspaceFileCount: number\n /** Shared run-ledger call id for this exact shot. */\n readonly costCallId: string | null\n /** Whether dollars came from the provider, the pricing table, or are unknown. */\n readonly costBasis: 'provider-reported' | 'estimated-pricing' | 'unknown'\n readonly costUsd: number | null\n /** True only for a provider-reported amount, never for a pricing estimate. */\n readonly costUsdKnown: boolean\n readonly evidence: CodexExecutionEvidence | null\n readonly error: { readonly name: string; readonly message: string } | null\n}\n\nexport interface AgenticGeneratorOptions {\n /** Local coding harness to run in the worktree. Default `claude`. */\n harness?: LocalHarness\n /** Author profile rendered through the canonical harness mapper. Required\n * for reproducible Codex so model and reasoning settings are explicit. */\n profile?: AgentProfile\n /** Run Codex with isolated configuration, exact prompt evidence, and required\n * terminal token usage. Requires `harness: 'codex'` and `profile`. */\n codexReproducible?: boolean\n /** Absolute paths reproducible Codex must not read. A function can derive\n * candidate-specific paths after the driver creates its worktree. */\n codexReadDeniedPaths?: ReadonlyArray<string> | ((worktreePath: string) => ReadonlyArray<string>)\n /** Awaited once for every attempted author shot, including process failures.\n * Throwing aborts the candidate so receipt persistence can fail closed. */\n onShotCompleted?: (receipt: AgenticGeneratorShotReceipt) => void | Promise<void>\n /** Optional hard upper bound passed to the run-wide CostLedger before each\n * author shot. This MUST be enforced by the provider or executor; a planning\n * estimate is not an admissible bound. Omit for an uncapped ledger. A capped\n * ledger rejects before model dispatch when this is absent. */\n maximumCharge?: MaximumCharge\n /** Per-shot wall-clock timeout (ms). Default = `runLocalHarness` default (5m). */\n timeoutMs?: number\n /** Build the harness task prompt from the report + findings. Override for\n * domain phrasing; the default turns findings into a concrete coder task. */\n buildPrompt?: (args: { report: unknown; findings: AnalystFinding[] }) => string\n /** Verify the worktree after each dirtying shot. When set, a candidate that\n * fails verification is NOT returned — the failure feeds the next shot\n * (verify-in-session), up to `maxShots`; a candidate that never verifies is\n * discarded (`applied:false`), never shipped. Omitted ⇒ legacy behavior:\n * the first dirty shot is the candidate. See `commandVerifier`. */\n verify?: Verifier\n /** Test seam — inject the harness runner (defaults to `runLocalHarness`). */\n runHarness?: typeof runLocalHarness\n /** Test seam — inject the worktree-dirty check (defaults to `git status`). */\n isDirty?: (worktreePath: string) => boolean\n}\n\n/** Full-agentic `CandidateGenerator` (the `shots=N, sandbox=on` setting): run a real coding harness inside the candidate worktree so the agent makes the change in place. */\nexport function agenticGenerator(opts: AgenticGeneratorOptions = {}): CandidateGenerator {\n const harness = opts.harness ?? 'claude'\n if (opts.codexReproducible && harness !== 'codex') {\n throw new Error(\"agenticGenerator: codexReproducible requires harness 'codex'\")\n }\n if (opts.codexReproducible && !opts.profile) {\n throw new Error('agenticGenerator: codexReproducible requires an explicit author profile')\n }\n if (opts.codexReadDeniedPaths && !opts.codexReproducible) {\n throw new Error('agenticGenerator: codexReadDeniedPaths requires codexReproducible')\n }\n if (opts.maximumCharge && !opts.codexReproducible) {\n throw new Error('agenticGenerator: maximumCharge requires codexReproducible')\n }\n const profileResourcePlan = opts.codexReproducible\n ? authorProfileResourcePlan(opts.profile as AgentProfile)\n : null\n const buildPrompt = opts.buildPrompt ?? defaultBuildPrompt\n const run = opts.runHarness ?? runLocalHarness\n const dirty = opts.isDirty ?? worktreeDirty\n const verify = opts.verify\n\n return {\n kind: `agentic:${harness}`,\n // The seed repo + (in rawTraceContext mode) the raw-trace filesystem context\n // are the change signal — an agentic coder proposes from them even when the\n // distiller yielded zero findings. Without this, the improvementDriver's\n // empty-findings guard short-circuits and generates ZERO candidates on the\n // first (and, for a single-generation run, only) proposal round.\n proposesWithoutFindings: true,\n async generate({\n worktreePath,\n report,\n findings,\n maxShots,\n signal,\n generation,\n candidateIndex,\n costLedger,\n costPhase,\n }) {\n if (opts.codexReproducible && !costLedger) {\n throw new Error(\n 'agenticGenerator: reproducible Codex requires the run-wide CostLedger supplied by agent-eval 0.117+',\n )\n }\n const basePrompt = appendProfileResourcePaths(\n buildPrompt({ report, findings }),\n profileResourcePlan,\n )\n const needsRawTraceEvidence = requiresRawTraceEvidence(findings)\n const shots = Math.max(1, maxShots)\n // Feedback appended to the base prompt for the NEXT shot — empty on shot 0.\n let attemptNote = ''\n\n for (let shot = 0; shot < shots; shot++) {\n if (signal.aborted) break\n const taskPrompt = attemptNote ? `${basePrompt}\\n\\n${attemptNote}` : basePrompt\n const invocation = opts.profile\n ? harnessInvocation(harness, opts.profile, taskPrompt, {\n dangerouslySkipPermissions: harness === 'claude',\n ...(opts.codexReproducible ? { codexReproducible: true } : {}),\n })\n : undefined\n const exactPrompt = invocation?.prompt ?? taskPrompt\n const readDeniedPaths =\n typeof opts.codexReadDeniedPaths === 'function'\n ? opts.codexReadDeniedPaths(worktreePath)\n : opts.codexReadDeniedPaths\n const startedAt = new Date()\n let harnessResult: LocalHarnessResult | null = null\n let profileWorkspaceReceipt: WorkspacePlanReceipt | null = null\n let costReceipt: CostReceipt | null = null\n let costCallId: string | null = null\n let shotError: Error | null = null\n try {\n const execute = async (executionSignal: AbortSignal): Promise<LocalHarnessResult> => {\n harnessResult = await withAuthorProfileResources(\n profileResourcePlan,\n worktreePath,\n async (receipt) => {\n profileWorkspaceReceipt = receipt\n const result = await run({\n harness,\n cwd: worktreePath,\n taskPrompt,\n ...(invocation\n ? { invocation: { command: invocation.command, args: invocation.args } }\n : {}),\n // The candidate worktree is isolated and must be editable without an\n // interactive permission prompt. Other runLocalHarness callers remain\n // permission-safe by default.\n dangerouslySkipPermissions: harness === 'claude',\n ...(opts.codexReproducible ? { codexReproducible: true } : {}),\n ...(readDeniedPaths ? { codexReadDeniedPaths: readDeniedPaths } : {}),\n timeoutMs: opts.timeoutMs,\n signal: executionSignal,\n })\n // Assign before profile cleanup so a cleanup failure still\n // settles the model usage already returned by the harness.\n harnessResult = result\n return result\n },\n )\n const failure = shotFailure(harnessResult, exactPrompt, opts.codexReproducible === true)\n if (failure) throw failure\n return harnessResult\n }\n\n if (opts.codexReproducible) {\n const ledger = costLedger as CostLedger\n const model = opts.profile?.model?.default\n if (!model) {\n throw new Error('agenticGenerator: reproducible Codex requires profile.model.default')\n }\n const paid = await ledger.runPaidCall({\n channel: 'driver',\n phase: costPhase ?? 'search.proposal',\n actor: `agentic-generator:${harness}`,\n model,\n tags: {\n generation: String(generation ?? -1),\n candidateIndex: String(candidateIndex ?? -1),\n shot: String(shot + 1),\n },\n signal,\n ...(opts.maximumCharge ? { maximumCharge: opts.maximumCharge } : {}),\n execute,\n receipt: (result) => costReceiptFromHarness(result, model),\n receiptFromError: () =>\n harnessResult?.usage ? costReceiptFromHarness(harnessResult, model) : undefined,\n })\n costCallId = paid.callId ?? null\n costReceipt = paid.receipt ?? null\n if (!paid.succeeded) throw paid.error\n harnessResult = paid.value\n } else {\n harnessResult = await execute(signal)\n }\n } catch (cause) {\n shotError = cause instanceof Error ? cause : new Error(String(cause))\n }\n await emitShotReceipt(\n opts.onShotCompleted,\n shotReceipt({\n generation,\n candidateIndex,\n shot,\n maxShots: shots,\n harness,\n profile: opts.profile,\n prompt: exactPrompt,\n startedAt,\n completedAt: new Date(),\n result: harnessResult,\n profileWorkspaceReceipt,\n costCallId,\n costReceipt,\n error: shotError,\n }),\n shotError,\n )\n\n if (!harnessResult) {\n throw new Error('agenticGenerator: author shot completed without a harness result')\n }\n\n // The worktree IS the signal: no edits ⇒ tell the next shot to act.\n if (!dirty(worktreePath)) {\n attemptNote = EMPTY_TREE_NOTE\n continue\n }\n\n if (needsRawTraceEvidence) {\n const problem = rawTraceEvidenceProblem(worktreePath, findings)\n if (problem) {\n attemptNote = problem\n continue\n }\n }\n\n // Dirty: with no verifier the diff IS the candidate (we trust the diff,\n // not the harness's stdout). With a verifier the candidate must pass it.\n if (!verify) {\n return { applied: true, summary: summarize(findings) }\n }\n const result = await verify(worktreePath)\n if (result.ok) {\n return { applied: true, summary: summarize(findings) }\n }\n // Dirty but failing — resume next shot atop these edits with the error.\n attemptNote = failureNote(result.feedback)\n }\n\n // Shots exhausted: no verified candidate (or, sans verifier, no edits).\n return { applied: false, summary: '' }\n },\n }\n}\n\nfunction authorProfileResourcePlan(profile: AgentProfile): WorkspacePlan | null {\n const resources = profile.resources\n if (!resources) return null\n const unsupportedKinds = [\n resources.tools?.length ? 'tools' : null,\n resources.skills?.length ? 'skills' : null,\n resources.agents?.length ? 'agents' : null,\n ].filter((kind): kind is string => kind !== null)\n if (unsupportedKinds.length > 0) {\n throw new Error(\n `agenticGenerator: reproducible Codex author resources support files only; unsupported: ${unsupportedKinds.join(', ')}`,\n )\n }\n if (!resources.files || resources.files.length === 0) return null\n\n const plan = materializeProfile(\n {\n name: profile.name,\n resources: { files: resources.files },\n },\n 'codex',\n )\n if (plan.unsupported.length > 0) {\n throw new Error(\n `agenticGenerator: author profile files could not be materialized: ${plan.unsupported.map((item) => item.reason).join('; ')}`,\n )\n }\n if (Object.keys(plan.env).length > 0 || plan.flags.length > 0) {\n throw new Error(\n 'agenticGenerator: generic author profile files unexpectedly changed spawn values',\n )\n }\n\n const virtualRoot = resolve('/', AGENTIC_PROFILE_RESOURCE_ROOT)\n const seen = new Set<string>()\n for (const file of plan.files) {\n const target = resolve('/', file.relPath)\n if (!target.startsWith(`${virtualRoot}${sep}`)) {\n throw new Error(\n `agenticGenerator: author profile file must be below ${AGENTIC_PROFILE_RESOURCE_ROOT}: ${file.relPath}`,\n )\n }\n if (seen.has(target)) {\n throw new Error(`agenticGenerator: duplicate author profile file path: ${file.relPath}`)\n }\n seen.add(target)\n }\n return plan\n}\n\nfunction appendProfileResourcePaths(prompt: string, plan: WorkspacePlan | null): string {\n if (!plan) return prompt\n return [\n prompt,\n '',\n 'Profile resource files available for this shot:',\n ...plan.files.map((file) => `- ${file.relPath}`),\n ].join('\\n')\n}\n\nasync function withAuthorProfileResources<T>(\n plan: WorkspacePlan | null,\n worktreePath: string,\n run: (receipt: WorkspacePlanReceipt | null) => Promise<T>,\n): Promise<T> {\n if (!plan) return run(null)\n\n const rootPath = resolve(worktreePath, AGENTIC_PROFILE_RESOURCE_ROOT)\n if (existsSync(rootPath)) {\n throw new Error(\n `agenticGenerator: ephemeral author profile root already exists: ${AGENTIC_PROFILE_RESOURCE_ROOT}`,\n )\n }\n\n let value: T | undefined\n let primaryError: unknown\n try {\n const receipt = applyWorkspacePlan(plan, worktreePath)\n value = await run(receipt)\n } catch (cause) {\n primaryError = cause\n }\n\n let cleanupError: unknown\n try {\n rmSync(rootPath, { recursive: true, force: true })\n if (existsSync(rootPath)) {\n throw new Error(\n `agenticGenerator: ephemeral author profile root survived cleanup: ${AGENTIC_PROFILE_RESOURCE_ROOT}`,\n )\n }\n } catch (cause) {\n cleanupError = cause\n }\n\n if (primaryError !== undefined && cleanupError !== undefined) {\n throw new AggregateError(\n [primaryError, cleanupError],\n 'agenticGenerator: author shot and profile resource cleanup both failed',\n )\n }\n if (primaryError !== undefined) throw primaryError\n if (cleanupError !== undefined) throw cleanupError\n return value as T\n}\n\nasync function emitShotReceipt(\n callback: AgenticGeneratorOptions['onShotCompleted'],\n receipt: AgenticGeneratorShotReceipt,\n primaryError: Error | null,\n): Promise<void> {\n try {\n await callback?.(receipt)\n } catch (callbackError) {\n if (primaryError !== null) {\n throw new AggregateError(\n [primaryError, callbackError],\n 'agenticGenerator: author shot failed and its receipt could not be persisted',\n )\n }\n throw callbackError\n }\n if (primaryError !== null) throw primaryError\n}\n\nfunction shotReceipt(input: {\n readonly generation: number | undefined\n readonly candidateIndex: number | undefined\n readonly shot: number\n readonly maxShots: number\n readonly harness: LocalHarness\n readonly profile: AgentProfile | undefined\n readonly prompt: string\n readonly startedAt: Date\n readonly completedAt: Date\n readonly result: LocalHarnessResult | null\n readonly profileWorkspaceReceipt: WorkspacePlanReceipt | null\n readonly costCallId: string | null\n readonly costReceipt: CostReceipt | null\n readonly error: unknown\n}): AgenticGeneratorShotReceipt {\n const error = input.error\n ? {\n name: input.error instanceof Error ? input.error.name : 'Error',\n message: input.error instanceof Error ? input.error.message : String(input.error),\n }\n : null\n const result = input.result\n const costBasis = costBasisFor(input.costReceipt)\n return {\n schemaVersion: 1,\n generation: input.generation ?? null,\n candidateIndex: input.candidateIndex ?? null,\n shot: input.shot + 1,\n maxShots: input.maxShots,\n harness: input.harness,\n model: input.profile?.model?.default ?? null,\n reasoningEffort: input.profile?.model?.reasoningEffort ?? null,\n promptSha256: sha256(input.prompt),\n startedAt: input.startedAt.toISOString(),\n completedAt: input.completedAt.toISOString(),\n durationMs: result?.durationMs ?? input.completedAt.getTime() - input.startedAt.getTime(),\n exitCode: result?.exitCode ?? null,\n timedOut: result?.timedOut ?? false,\n killedBySignal: result?.killedBySignal ?? null,\n stdoutBytes: result ? Buffer.byteLength(result.stdout) : null,\n stdoutSha256: result ? sha256(result.stdout) : null,\n stderrBytes: result ? Buffer.byteLength(result.stderr) : null,\n stderrSha256: result ? sha256(result.stderr) : null,\n usage: result?.usage ? { ...result.usage } : null,\n profileWorkspacePlanDigest: input.profileWorkspaceReceipt?.workspacePlanDigest ?? null,\n profileWorkspaceFileCount: input.profileWorkspaceReceipt?.written.length ?? 0,\n costCallId: input.costCallId,\n costBasis,\n costUsd: costBasis === 'unknown' ? null : (input.costReceipt?.costUsd ?? null),\n costUsdKnown: costBasis === 'provider-reported',\n evidence: result?.evidence\n ? {\n ...result.evidence,\n readDeniedPaths: [...result.evidence.readDeniedPaths],\n policy: { ...result.evidence.policy },\n }\n : null,\n error,\n }\n}\n\nfunction costBasisFor(receipt: CostReceipt | null): AgenticGeneratorShotReceipt['costBasis'] {\n if (receipt === null || receipt.costUnknown) return 'unknown'\n return receipt.actualCostUsd === undefined ? 'estimated-pricing' : 'provider-reported'\n}\n\nfunction shotFailure(\n result: LocalHarnessResult,\n exactPrompt: string,\n codexReproducible: boolean,\n): Error | null {\n if (result.timedOut) {\n return new Error('agenticGenerator: author shot timed out')\n }\n if (result.killedBySignal) {\n return new Error(`agenticGenerator: author shot was killed by ${result.killedBySignal}`)\n }\n if (result.exitCode !== 0) {\n return new Error(`agenticGenerator: author shot exited with code ${String(result.exitCode)}`)\n }\n if (!codexReproducible) return null\n if (!result.usage || !result.evidence) {\n return new Error(\n 'agenticGenerator: reproducible Codex shot completed without usage or execution evidence',\n )\n }\n const expectedPromptSha256 = sha256(exactPrompt).slice('sha256:'.length)\n if (result.evidence.requestedPromptSha256 !== expectedPromptSha256) {\n return new Error(\n 'agenticGenerator: reproducible Codex prompt evidence does not match the exact authored prompt',\n )\n }\n return null\n}\n\nfunction costReceiptFromHarness(result: LocalHarnessResult, model: string): CostReceiptInput {\n if (!result.usage) {\n throw new Error('agenticGenerator: author shot did not report terminal token usage')\n }\n return {\n model,\n inputTokens: result.usage.inputTokens - result.usage.cachedInputTokens,\n outputTokens: result.usage.outputTokens,\n ...(result.usage.cachedInputTokens > 0 ? { cachedTokens: result.usage.cachedInputTokens } : {}),\n }\n}\n\nfunction sha256(value: string): `sha256:${string}` {\n return `sha256:${createHash('sha256').update(value).digest('hex')}`\n}\n\n/** Turn the analyst's findings (+ optional report) into a concrete coder task. */\nfunction defaultBuildPrompt(args: { report: unknown; findings: AnalystFinding[] }): string {\n const lines: string[] = [\n 'You are improving this codebase based on an evaluation analysis.',\n 'Make the smallest set of edits that addresses the findings below, then stop.',\n 'Do not change unrelated code. Do not commit — leave changes in the working tree.',\n '',\n 'Findings:',\n ]\n for (const f of args.findings) {\n const where = f.subject ? ` [${f.subject}]` : ''\n lines.push(`- (${f.severity})${where} ${f.claim}`)\n if (f.recommended_action) lines.push(` → ${f.recommended_action}`)\n }\n if (requiresRawTraceEvidence(args.findings)) {\n lines.push(\n '',\n 'Raw trace evidence requirement:',\n `- Inspect at least one raw trace path named above before editing.`,\n `- Write ${RAW_TRACE_DIAGNOSIS_PATH} in this worktree.`,\n '- Include the exact trace path(s) inspected, the failure mechanism, and the code change made.',\n '- A candidate without this file, or with only this file changed, is discarded.',\n )\n }\n return lines.join('\\n')\n}\n\nconst EMPTY_TREE_NOTE =\n 'NOTE: your previous attempt left the working tree unchanged. Make the concrete file edits now.'\n\n/** Next-shot feedback when the worktree is dirty but failed verification. The\n * edits persist on disk, so the harness resumes atop them — tell it to fix in\n * place, not start over. Verifier detail is truncated to keep the prompt bounded. */\nfunction failureNote(feedback?: string): string {\n const detail = feedback?.trim()\n return [\n 'NOTE: your edits are in the working tree but verification FAILED.',\n 'Fix the problem in place — build on your existing edits, do not revert them.',\n detail ? `Verifier output:\\n${truncate(detail, 4000)}` : 'No verifier detail was captured.',\n ].join('\\n')\n}\n\nfunction rawTraceEvidenceProblem(worktreePath: string, findings: AnalystFinding[]): string | null {\n const changedPaths = worktreeChangedPaths(worktreePath)\n const substantive = changedPaths.filter((path) => path !== RAW_TRACE_DIAGNOSIS_PATH)\n if (substantive.length === 0) {\n return [\n `NOTE: raw-trace mode requires a real code/config edit in addition to ${RAW_TRACE_DIAGNOSIS_PATH}.`,\n 'Your previous attempt only changed the diagnosis artifact. Inspect the cited traces and make the causal code change.',\n ].join('\\n')\n }\n\n const diagnosisPath = join(worktreePath, RAW_TRACE_DIAGNOSIS_PATH)\n if (!existsSync(diagnosisPath)) {\n return [\n `NOTE: raw-trace mode requires ${RAW_TRACE_DIAGNOSIS_PATH}.`,\n 'Before retrying, inspect at least one cited spans.jsonl/cached-result.json/artifact path, then write the diagnosis file with the exact path, failure mechanism, and code change.',\n ].join('\\n')\n }\n\n const body = readFileSync(diagnosisPath, 'utf8')\n const evidencePaths = traceEvidencePaths(findings)\n if (evidencePaths.length > 0 && !evidencePaths.some((path) => body.includes(path))) {\n return [\n `${RAW_TRACE_DIAGNOSIS_PATH} exists, but it does not cite any exact raw trace path from the findings.`,\n `Cite at least one of these inspected paths exactly: ${evidencePaths.slice(0, 5).join(', ')}`,\n ].join('\\n')\n }\n\n return null\n}\n\nfunction requiresRawTraceEvidence(findings: AnalystFinding[]): boolean {\n return findings.some((finding) => {\n const f = finding as unknown as Record<string, unknown>\n return f.analyst_id === RAW_TRACE_ANALYST_ID || f.area === RAW_TRACE_AREA\n })\n}\n\nfunction traceEvidencePaths(findings: AnalystFinding[]): string[] {\n const out: string[] = []\n for (const finding of findings) {\n const refs = (finding as unknown as { evidence_refs?: unknown }).evidence_refs\n if (!Array.isArray(refs)) continue\n for (const ref of refs) {\n if (!ref || typeof ref !== 'object') continue\n const uri = (ref as { uri?: unknown }).uri\n if (typeof uri === 'string' && uri.length > 0) out.push(uri)\n }\n }\n return [...new Set(out)]\n}\n\n/** A `Verifier` that runs a command in the worktree: exit 0 ⇒ ok, any other\n * exit ⇒ failed with stdout+stderr as feedback. The common case — verify by\n * `tsc --noEmit`, `pnpm build`, or a test command. A timeout is treated as a\n * FAILED candidate (a change that hangs the build is a bad change); a missing\n * binary or spawn fault throws (a setup bug, not a failed candidate — no\n * silent fallback). */\nexport function commandVerifier(\n command: string,\n args: string[] = [],\n timeoutMs = 300_000,\n): Verifier {\n return (worktreePath: string): VerifyResult => {\n const result = spawnSync(command, args, {\n cwd: worktreePath,\n encoding: 'utf-8',\n timeout: timeoutMs,\n })\n if (result.signal) {\n return {\n ok: false,\n feedback: `verifier '${command}' killed by ${result.signal} (likely timeout after ${timeoutMs}ms)`,\n }\n }\n if (result.error) {\n const code = (result.error as NodeJS.ErrnoException).code\n if (code === 'ENOENT') {\n throw new Error(\n `commandVerifier: '${command}' not found in PATH (setup bug, not a failed candidate)`,\n )\n }\n throw new Error(`commandVerifier: '${command}' failed to spawn: ${result.error.message}`)\n }\n if (result.status === 0) return { ok: true }\n const out = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim()\n return { ok: false, feedback: out.length > 0 ? out : `exit ${result.status}` }\n }\n}\n\n/** A one-line summary for the commit message, derived from the findings. */\nfunction summarize(findings: AnalystFinding[]): string {\n if (findings.length === 0) return 'agentic improvement'\n if (findings.length === 1) return `agentic: ${truncate(findings[0]!.claim, 64)}`\n return `agentic: ${findings.length} findings addressed`\n}\n\nfunction truncate(s: string, n: number): string {\n return s.length <= n ? s : `${s.slice(0, n - 1)}…`\n}\n\n/** Non-empty `git status --porcelain` ⇒ the harness changed the worktree.\n * Fails loud: the worktree is a fresh checkout, so a git error here means\n * something is genuinely broken (git missing, corrupt index, killed mid-run).\n * Folding that into `false` would silently discard a candidate and mask the\n * real failure — forbidden by the no-silent-fallbacks doctrine. */\nfunction worktreeDirty(worktreePath: string): boolean {\n return worktreeChangedPaths(worktreePath).length > 0\n}\n\nfunction worktreeChangedPaths(worktreePath: string): string[] {\n const result = spawnSync('git', ['status', '--porcelain', '--untracked-files=all'], {\n cwd: worktreePath,\n encoding: 'utf-8',\n })\n if (result.error) {\n throw new Error(\n `agenticGenerator: git status failed to spawn in ${worktreePath}: ${result.error.message}`,\n )\n }\n if (result.status !== 0) {\n throw new Error(\n `agenticGenerator: git status exited ${result.status} in ${worktreePath}: ${result.stderr.trim()}`,\n )\n }\n return result.stdout\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0)\n .map((line) => line.slice(3).trim())\n}\n"],"mappings":";;;;;;AAkCA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,YAAY,cAAc,cAAc;AACjD,SAAS,MAAM,SAAS,WAAW;AASnC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAWP,IAAM,uBAAuB;AAC7B,IAAM,iBAAiB;AACvB,IAAM,2BAA2B;AAI1B,IAAM,gCAAgC;AAwFtC,SAAS,iBAAiB,OAAgC,CAAC,GAAuB;AACvF,QAAM,UAAU,KAAK,WAAW;AAChC,MAAI,KAAK,qBAAqB,YAAY,SAAS;AACjD,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AACA,MAAI,KAAK,qBAAqB,CAAC,KAAK,SAAS;AAC3C,UAAM,IAAI,MAAM,yEAAyE;AAAA,EAC3F;AACA,MAAI,KAAK,wBAAwB,CAAC,KAAK,mBAAmB;AACxD,UAAM,IAAI,MAAM,mEAAmE;AAAA,EACrF;AACA,MAAI,KAAK,iBAAiB,CAAC,KAAK,mBAAmB;AACjD,UAAM,IAAI,MAAM,4DAA4D;AAAA,EAC9E;AACA,QAAM,sBAAsB,KAAK,oBAC7B,0BAA0B,KAAK,OAAuB,IACtD;AACJ,QAAM,cAAc,KAAK,eAAe;AACxC,QAAM,MAAM,KAAK,cAAc;AAC/B,QAAM,QAAQ,KAAK,WAAW;AAC9B,QAAM,SAAS,KAAK;AAEpB,SAAO;AAAA,IACL,MAAM,WAAW,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMxB,yBAAyB;AAAA,IACzB,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,CAAC,EACzB,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,EAChC,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC;AACvC;","names":["result"]}
@@ -5,13 +5,13 @@ import {
5
5
  definePersona,
6
6
  runPersonified,
7
7
  worktreeFanout
8
- } from "./chunk-GKZ6DFDN.js";
8
+ } from "./chunk-7HH22XN4.js";
9
9
  import {
10
10
  runAnalystLoop
11
- } from "./chunk-ZQZX77MM.js";
11
+ } from "./chunk-QDSOD7RC.js";
12
12
  import {
13
13
  createExecutorRegistry
14
- } from "./chunk-LWNMCOEA.js";
14
+ } from "./chunk-FRXDOBFP.js";
15
15
  import {
16
16
  ConfigError
17
17
  } from "./chunk-YEJR7IXO.js";
@@ -196,4 +196,4 @@ export {
196
196
  runLoopRunnerCli,
197
197
  parseLoopRunnerArgv
198
198
  };
199
- //# sourceMappingURL=chunk-63TIZHMI.js.map
199
+ //# sourceMappingURL=chunk-KYPVUEJ4.js.map
@@ -168,4 +168,4 @@ export {
168
168
  mapSandboxToolEvent,
169
169
  mapSandboxEvent
170
170
  };
171
- //# sourceMappingURL=chunk-FVJ7M3DA.js.map
171
+ //# sourceMappingURL=chunk-M22PL4GH.js.map