@tangle-network/agent-runtime 0.89.0 → 0.90.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 (56) hide show
  1. package/README.md +51 -18
  2. package/dist/agent.d.ts +53 -2
  3. package/dist/agent.js +166 -4
  4. package/dist/agent.js.map +1 -1
  5. package/dist/analyst-loop.d.ts +1 -1
  6. package/dist/{chunk-PIPPLSOF.js → chunk-4IBAMGBE.js} +33 -3
  7. package/dist/chunk-4IBAMGBE.js.map +1 -0
  8. package/dist/chunk-5QOB7H74.js +387 -0
  9. package/dist/chunk-5QOB7H74.js.map +1 -0
  10. package/dist/chunk-74SBMDTO.js +214 -0
  11. package/dist/chunk-74SBMDTO.js.map +1 -0
  12. package/dist/{chunk-BQPFZE2C.js → chunk-MHK62APK.js} +5 -5
  13. package/dist/{chunk-N7EJV7N3.js → chunk-QSNSMJSZ.js} +3417 -3393
  14. package/dist/chunk-QSNSMJSZ.js.map +1 -0
  15. package/dist/{chunk-VNOOH22O.js → chunk-XMOU4WEY.js} +74 -3
  16. package/dist/chunk-XMOU4WEY.js.map +1 -0
  17. package/dist/{chunk-5AVV7KAH.js → chunk-XQEISTK2.js} +2 -2
  18. package/dist/{worktree-harness-CX_McRLp.d.ts → completion-gate-BDaBP8dd.d.ts} +44 -44
  19. package/dist/{coordination-CuDLO8wj.d.ts → coordination-DxHduZg7.d.ts} +414 -226
  20. package/dist/environment-provider.d.ts +3 -3
  21. package/dist/index.d.ts +156 -13
  22. package/dist/index.js +316 -70
  23. package/dist/index.js.map +1 -1
  24. package/dist/intelligence.d.ts +2 -2
  25. package/dist/knowledge.d.ts +120 -0
  26. package/dist/knowledge.js +28 -0
  27. package/dist/knowledge.js.map +1 -0
  28. package/dist/lifecycle.js +1 -1
  29. package/dist/{loop-runner-bin-hQDUL8Ld.d.ts → loop-runner-bin-D3GmB2Ru.d.ts} +2 -2
  30. package/dist/loop-runner-bin.d.ts +5 -5
  31. package/dist/loop-runner-bin.js +5 -5
  32. package/dist/loops.d.ts +46 -141
  33. package/dist/loops.js +3 -3
  34. package/dist/mcp/bin.js +2 -2
  35. package/dist/mcp/index.d.ts +8 -9
  36. package/dist/mcp/index.js +7 -7
  37. package/dist/{openai-tools-BnrOmGjN.d.ts → openai-tools-D0xmzo0y.d.ts} +1 -1
  38. package/dist/profiles.d.ts +196 -5
  39. package/dist/profiles.js +8 -0
  40. package/dist/profiles.js.map +1 -1
  41. package/dist/{router-client-r8y_VFVM.d.ts → router-client-DJImUDlm.d.ts} +1 -1
  42. package/dist/supervise-BpCdssu0.d.ts +131 -0
  43. package/dist/{types-Driepl87.d.ts → types-DAJQRIUD.d.ts} +2 -2
  44. package/dist/{types-ESeMOj94.d.ts → types-Dnk189QA.d.ts} +1 -1
  45. package/dist/{worktree-fanout-D6xR2CIA.d.ts → worktree-fanout-CfRXYmgV.d.ts} +3 -3
  46. package/package.json +12 -4
  47. package/skills/agent-runtime-adoption/SKILL.md +74 -24
  48. package/skills/build-with-agent-runtime/SKILL.md +3 -3
  49. package/skills/loop-writer/SKILL.md +6 -5
  50. package/skills/supervise/SKILL.md +2 -2
  51. package/dist/chunk-N7EJV7N3.js.map +0 -1
  52. package/dist/chunk-PIPPLSOF.js.map +0 -1
  53. package/dist/chunk-VNOOH22O.js.map +0 -1
  54. package/dist/otel-export-BKmNwiCb.d.ts +0 -180
  55. /package/dist/{chunk-BQPFZE2C.js.map → chunk-MHK62APK.js.map} +0 -0
  56. /package/dist/{chunk-5AVV7KAH.js.map → chunk-XQEISTK2.js.map} +0 -0
@@ -4,6 +4,11 @@ import {
4
4
 
5
5
  // src/improvement/agentic-generator.ts
6
6
  import { spawnSync } from "child_process";
7
+ import { existsSync, readFileSync } from "fs";
8
+ import { join } from "path";
9
+ var RAW_TRACE_ANALYST_ID = "raw-trace-distiller";
10
+ var RAW_TRACE_AREA = "raw-trace-context";
11
+ var RAW_TRACE_DIAGNOSIS_PATH = ".improve/raw-trace-diagnosis.md";
7
12
  function agenticGenerator(opts = {}) {
8
13
  const harness = opts.harness ?? "claude";
9
14
  const buildPrompt = opts.buildPrompt ?? defaultBuildPrompt;
@@ -14,6 +19,7 @@ function agenticGenerator(opts = {}) {
14
19
  kind: `agentic:${harness}`,
15
20
  async generate({ worktreePath, report, findings, maxShots, signal }) {
16
21
  const basePrompt = buildPrompt({ report, findings });
22
+ const needsRawTraceEvidence = requiresRawTraceEvidence(findings);
17
23
  const shots = Math.max(1, maxShots);
18
24
  let attemptNote = "";
19
25
  for (let shot = 0; shot < shots; shot++) {
@@ -31,6 +37,13 @@ ${attemptNote}` : basePrompt,
31
37
  attemptNote = EMPTY_TREE_NOTE;
32
38
  continue;
33
39
  }
40
+ if (needsRawTraceEvidence) {
41
+ const problem = rawTraceEvidenceProblem(worktreePath, findings);
42
+ if (problem) {
43
+ attemptNote = problem;
44
+ continue;
45
+ }
46
+ }
34
47
  if (!verify) {
35
48
  return { applied: true, summary: summarize(findings) };
36
49
  }
@@ -57,6 +70,16 @@ function defaultBuildPrompt(args) {
57
70
  lines.push(`- (${f.severity})${where} ${f.claim}`);
58
71
  if (f.recommended_action) lines.push(` \u2192 ${f.recommended_action}`);
59
72
  }
73
+ if (requiresRawTraceEvidence(args.findings)) {
74
+ lines.push(
75
+ "",
76
+ "Raw trace evidence requirement:",
77
+ `- Inspect at least one raw trace path named above before editing.`,
78
+ `- Write ${RAW_TRACE_DIAGNOSIS_PATH} in this worktree.`,
79
+ "- Include the exact trace path(s) inspected, the failure mechanism, and the code change made.",
80
+ "- A candidate without this file, or with only this file changed, is discarded."
81
+ );
82
+ }
60
83
  return lines.join("\n");
61
84
  }
62
85
  var EMPTY_TREE_NOTE = "NOTE: your previous attempt left the working tree unchanged. Make the concrete file edits now.";
@@ -69,6 +92,51 @@ function failureNote(feedback) {
69
92
  ${truncate(detail, 4e3)}` : "No verifier detail was captured."
70
93
  ].join("\n");
71
94
  }
95
+ function rawTraceEvidenceProblem(worktreePath, findings) {
96
+ const changedPaths = worktreeChangedPaths(worktreePath);
97
+ const substantive = changedPaths.filter((path) => path !== RAW_TRACE_DIAGNOSIS_PATH);
98
+ if (substantive.length === 0) {
99
+ return [
100
+ `NOTE: raw-trace mode requires a real code/config edit in addition to ${RAW_TRACE_DIAGNOSIS_PATH}.`,
101
+ "Your previous attempt only changed the diagnosis artifact. Inspect the cited traces and make the causal code change."
102
+ ].join("\n");
103
+ }
104
+ const diagnosisPath = join(worktreePath, RAW_TRACE_DIAGNOSIS_PATH);
105
+ if (!existsSync(diagnosisPath)) {
106
+ return [
107
+ `NOTE: raw-trace mode requires ${RAW_TRACE_DIAGNOSIS_PATH}.`,
108
+ "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."
109
+ ].join("\n");
110
+ }
111
+ const body = readFileSync(diagnosisPath, "utf8");
112
+ const evidencePaths = traceEvidencePaths(findings);
113
+ if (evidencePaths.length > 0 && !evidencePaths.some((path) => body.includes(path))) {
114
+ return [
115
+ `${RAW_TRACE_DIAGNOSIS_PATH} exists, but it does not cite any exact raw trace path from the findings.`,
116
+ `Cite at least one of these inspected paths exactly: ${evidencePaths.slice(0, 5).join(", ")}`
117
+ ].join("\n");
118
+ }
119
+ return null;
120
+ }
121
+ function requiresRawTraceEvidence(findings) {
122
+ return findings.some((finding) => {
123
+ const f = finding;
124
+ return f.analyst_id === RAW_TRACE_ANALYST_ID || f.area === RAW_TRACE_AREA;
125
+ });
126
+ }
127
+ function traceEvidencePaths(findings) {
128
+ const out = [];
129
+ for (const finding of findings) {
130
+ const refs = finding.evidence_refs;
131
+ if (!Array.isArray(refs)) continue;
132
+ for (const ref of refs) {
133
+ if (!ref || typeof ref !== "object") continue;
134
+ const uri = ref.uri;
135
+ if (typeof uri === "string" && uri.length > 0) out.push(uri);
136
+ }
137
+ }
138
+ return [...new Set(out)];
139
+ }
72
140
  function commandVerifier(command, args = [], timeoutMs = 3e5) {
73
141
  return (worktreePath) => {
74
142
  const result = spawnSync(command, args, {
@@ -105,7 +173,10 @@ function truncate(s, n) {
105
173
  return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
106
174
  }
107
175
  function worktreeDirty(worktreePath) {
108
- const result = spawnSync("git", ["status", "--porcelain"], {
176
+ return worktreeChangedPaths(worktreePath).length > 0;
177
+ }
178
+ function worktreeChangedPaths(worktreePath) {
179
+ const result = spawnSync("git", ["status", "--porcelain", "--untracked-files=all"], {
109
180
  cwd: worktreePath,
110
181
  encoding: "utf-8"
111
182
  });
@@ -119,7 +190,7 @@ function worktreeDirty(worktreePath) {
119
190
  `agenticGenerator: git status exited ${result.status} in ${worktreePath}: ${result.stderr.trim()}`
120
191
  );
121
192
  }
122
- return result.stdout.trim().length > 0;
193
+ return result.stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => line.slice(3).trim());
123
194
  }
124
195
 
125
196
  // src/improvement/build-prompts.ts
@@ -263,4 +334,4 @@ export {
263
334
  mcpBuildPrompt,
264
335
  mcpServeVerifier
265
336
  };
266
- //# sourceMappingURL=chunk-VNOOH22O.js.map
337
+ //# sourceMappingURL=chunk-XMOU4WEY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/improvement/agentic-generator.ts","../src/improvement/build-prompts.ts","../src/improvement/mcp-serve-verifier.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 { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { AnalystFinding } from '@tangle-network/agent-eval'\nimport { type LocalHarness, runLocalHarness } 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/** 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 AgenticGeneratorOptions {\n /** Local coding harness to run in the worktree. Default `claude`. */\n harness?: LocalHarness\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 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 async generate({ worktreePath, report, findings, maxShots, signal }) {\n const basePrompt = buildPrompt({ report, findings })\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 await run({\n harness,\n cwd: worktreePath,\n taskPrompt: attemptNote ? `${basePrompt}\\n\\n${attemptNote}` : basePrompt,\n timeoutMs: opts.timeoutMs,\n signal,\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\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","/**\n * Build-prompt starting points for the two buildable artifact types. There is\n * NO `toolGenerator`/`mcpGenerator` wrapper — the factory is `agenticGenerator`\n * + a verifier (docs/artifact-lifecycle-frontier.md), so a tool or an MCP\n * server is built by composing the pieces directly:\n *\n * // a tool:\n * agenticGenerator({ buildPrompt: toolBuildPrompt, verify: commandVerifier('pnpm', ['test']) })\n * // an MCP server:\n * agenticGenerator({ buildPrompt: mcpBuildPrompt, verify: mcpServeVerifier({ command: 'node', args: ['server.mjs'] }) })\n *\n * These are the only type-specific bit (the phrasing that points the agent at a\n * tool vs. an MCP); the worktree, resume-on-failure loop, and improvement-loop\n * wrapper are shared. MCP is the load-bearing target — it is how a harness\n * acquires tools; raw tools matter where we control the loader.\n */\n\nimport type { AnalystFinding } from '@tangle-network/agent-eval'\n\ntype FindingsArg = { report: unknown; findings: AnalystFinding[] }\n\nfunction findingLines(findings: AnalystFinding[]): string[] {\n return findings.map((f) => {\n const where = f.subject ? ` [${f.subject}]` : ''\n const action = f.recommended_action ? ` → ${f.recommended_action}` : ''\n return `- (${f.severity})${where} ${f.claim}${action}`\n })\n}\n\n/** Build the starting instruction for a coder agent tasked with implementing a new tool. */\nexport function toolBuildPrompt(args: FindingsArg): string {\n return [\n 'You are building a new TOOL for this codebase to address the gaps below.',\n 'Write the tool as a small, self-contained module PLUS tests that exercise it.',\n 'The tool must compile and its tests must pass — they will be run automatically;',\n 'if verification fails you will get the error and another attempt. Do not commit;',\n 'leave the changes in the working tree.',\n '',\n 'Gaps the tool should close:',\n ...findingLines(args.findings),\n ].join('\\n')\n}\n\n/** Build the starting instruction for a coder agent tasked with implementing a new MCP server. */\nexport function mcpBuildPrompt(args: FindingsArg): string {\n return [\n 'You are building a new MCP SERVER (Model Context Protocol) that exposes',\n 'tool(s) addressing the gaps below, so any harness can mount it.',\n 'Requirements that WILL be checked by booting the server:',\n '- it starts over stdio and answers the MCP `initialize` handshake,',\n '- `tools/list` returns at least one tool with a valid input schema.',\n 'Newline-delimited JSON-RPC 2.0, protocol version 2024-11-05. Include a start',\n 'command (e.g. a package.json `start` script or a clear entrypoint). If the',\n 'boot-and-probe fails you will get the error and another attempt. Do not',\n 'commit; leave the changes in the working tree.',\n '',\n 'Capabilities the server should provide:',\n ...findingLines(args.findings),\n ].join('\\n')\n}\n","/**\n * `mcpServeVerifier` — the intrinsic verifier for a built MCP server: the\n * boot-and-probe checker named in docs/artifact-lifecycle-frontier.md. A\n * generated MCP server is only a candidate if it actually *serves* — so this\n * boots it over stdio (the default local MCP transport) and runs the real\n * handshake: `initialize` → `notifications/initialized` → `tools/list`, and\n * asserts the server answers with at least `minTools` tools.\n *\n * Outcomes follow the `Verifier` contract: a server that fails to start, exits\n * early, errors the handshake, times out, or exposes no tools is a FAILED\n * candidate (`{ok:false}`, fed back into the next generation shot); a missing\n * start binary or spawn fault THROWS (a setup bug, never a silent fallback).\n *\n * Protocol matches the runtime's own stdio MCP server (src/mcp/server.ts):\n * newline-delimited JSON-RPC 2.0, protocol version 2024-11-05.\n */\n\nimport { spawn } from 'node:child_process'\nimport { createInterface } from 'node:readline'\nimport type { Verifier, VerifyResult } from './agentic-generator'\n\nconst PROTOCOL_VERSION = '2024-11-05'\n\nexport interface McpServeSpec {\n /** Command that starts the built MCP server in the worktree (stdio transport). */\n command: string\n args?: string[]\n /** Extra env for the server process (merged over `process.env`). */\n env?: Record<string, string>\n /** Handshake timeout (ms). Default 30s. */\n timeoutMs?: number\n /** Minimum tools the server must expose to pass. Default 1. */\n minTools?: number\n}\n\ninterface JsonRpcResponse {\n jsonrpc?: string\n id?: number | string | null\n result?: unknown\n error?: { code: number; message: string }\n}\n\n/** Build a `Verifier` that boots a generated MCP server over stdio and checks it exposes tools. */\nexport function mcpServeVerifier(spec: McpServeSpec): Verifier {\n const timeoutMs = spec.timeoutMs ?? 30_000\n const minTools = spec.minTools ?? 1\n\n return (worktreePath: string): Promise<VerifyResult> =>\n new Promise<VerifyResult>((resolve, reject) => {\n const child = spawn(spec.command, spec.args ?? [], {\n cwd: worktreePath,\n stdio: ['pipe', 'pipe', 'pipe'],\n env: { ...process.env, ...spec.env },\n })\n\n const stderr: string[] = []\n let settled = false\n let nextId = 1\n const initId = nextId++\n let listId = -1\n\n const settle = (fn: () => void) => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n rl.close()\n child.kill('SIGKILL')\n fn()\n }\n const withStderr = (msg: string) =>\n stderr.length > 0 ? `${msg}\\nstderr:\\n${stderr.join('').slice(-2000)}` : msg\n const pass = () => settle(() => resolve({ ok: true }))\n const failCandidate = (msg: string) =>\n settle(() => resolve({ ok: false, feedback: withStderr(msg) }))\n const setupFault = (err: Error) => settle(() => reject(err))\n\n const send = (msg: Record<string, unknown>): boolean => {\n try {\n child.stdin.write(`${JSON.stringify(msg)}\\n`)\n return true\n } catch (err) {\n // EPIPE: the server died mid-handshake — a failed candidate, not a fault.\n failCandidate(`writing to MCP server stdin failed: ${(err as Error).message}`)\n return false\n }\n }\n\n child.on('error', (err) => {\n const code = (err as NodeJS.ErrnoException).code\n setupFault(\n code === 'ENOENT'\n ? new Error(\n `mcpServeVerifier: '${spec.command}' not found in PATH (setup bug, not a failed candidate)`,\n )\n : new Error(`mcpServeVerifier: '${spec.command}' failed to spawn: ${err.message}`),\n )\n })\n child.on('exit', (code, signal) => {\n // An exit before the handshake completes is a failed candidate (the\n // server crashed on boot); after we settle, our own SIGKILL fires here.\n failCandidate(`MCP server exited (code ${code}, signal ${signal}) before serving`)\n })\n child.stderr.on('data', (d) => stderr.push(String(d)))\n\n const rl = createInterface({ input: child.stdout })\n rl.on('line', (line) => {\n let msg: JsonRpcResponse | undefined\n try {\n msg = JSON.parse(line) as JsonRpcResponse\n } catch {\n return // servers log to stdout too; skip non-JSON lines\n }\n if (!msg || typeof msg !== 'object') return\n\n if (msg.id === initId) {\n if (msg.error) return failCandidate(`initialize errored: ${JSON.stringify(msg.error)}`)\n if (!send({ jsonrpc: '2.0', method: 'notifications/initialized' })) return\n listId = nextId++\n send({ jsonrpc: '2.0', id: listId, method: 'tools/list' })\n return\n }\n if (msg.id === listId) {\n if (msg.error) return failCandidate(`tools/list errored: ${JSON.stringify(msg.error)}`)\n const tools = (msg.result as { tools?: unknown[] } | undefined)?.tools\n if (!Array.isArray(tools)) return failCandidate('tools/list result has no tools array')\n if (tools.length < minTools) {\n return failCandidate(`tools/list returned ${tools.length} tool(s), need >= ${minTools}`)\n }\n return pass()\n }\n })\n\n const timer = setTimeout(\n () => failCandidate(`MCP server did not complete the handshake within ${timeoutMs}ms`),\n timeoutMs,\n )\n\n send({\n jsonrpc: '2.0',\n id: initId,\n method: 'initialize',\n params: {\n protocolVersion: PROTOCOL_VERSION,\n capabilities: {},\n clientInfo: { name: 'agent-runtime-mcp-verify', version: '0' },\n },\n })\n })\n}\n"],"mappings":";;;;;AAkCA,SAAS,iBAAiB;AAC1B,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAKrB,IAAM,uBAAuB;AAC7B,IAAM,iBAAiB;AACvB,IAAM,2BAA2B;AAmC1B,SAAS,iBAAiB,OAAgC,CAAC,GAAuB;AACvF,QAAM,UAAU,KAAK,WAAW;AAChC,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,IACxB,MAAM,SAAS,EAAE,cAAc,QAAQ,UAAU,UAAU,OAAO,GAAG;AACnE,YAAM,aAAa,YAAY,EAAE,QAAQ,SAAS,CAAC;AACnD,YAAM,wBAAwB,yBAAyB,QAAQ;AAC/D,YAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ;AAElC,UAAI,cAAc;AAElB,eAAS,OAAO,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rB,YAAI,IAAI,MAAO,QAAO,cAAc,uBAAuB,KAAK,UAAU,IAAI,KAAK,CAAC,EAAE;AACtF,cAAM,QAAS,IAAI,QAA8C;AACjE,YAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,cAAc,sCAAsC;AACtF,YAAI,MAAM,SAAS,UAAU;AAC3B,iBAAO,cAAc,uBAAuB,MAAM,MAAM,qBAAqB,QAAQ,EAAE;AAAA,QACzF;AACA,eAAO,KAAK;AAAA,MACd;AAAA,IACF,CAAC;AAED,UAAM,QAAQ;AAAA,MACZ,MAAM,cAAc,oDAAoD,SAAS,IAAI;AAAA,MACrF;AAAA,IACF;AAEA,SAAK;AAAA,MACH,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,QACN,iBAAiB;AAAA,QACjB,cAAc,CAAC;AAAA,QACf,YAAY,EAAE,MAAM,4BAA4B,SAAS,IAAI;AAAA,MAC/D;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACL;","names":[]}
@@ -8,7 +8,7 @@ import {
8
8
  DELEGATION_STATUS_DESCRIPTION,
9
9
  DELEGATION_STATUS_INPUT_SCHEMA,
10
10
  DELEGATION_STATUS_TOOL_NAME
11
- } from "./chunk-N7EJV7N3.js";
11
+ } from "./chunk-QSNSMJSZ.js";
12
12
 
13
13
  // src/mcp/openai-tools.ts
14
14
  function buildTool(name, description, parameters) {
@@ -45,4 +45,4 @@ export {
45
45
  mcpToolsForRuntimeMcp,
46
46
  mcpToolsForRuntimeMcpSubset
47
47
  };
48
- //# sourceMappingURL=chunk-5AVV7KAH.js.map
48
+ //# sourceMappingURL=chunk-XQEISTK2.js.map
@@ -1,48 +1,5 @@
1
- import { a as Executor } from './types-Driepl87.js';
2
1
  import { L as LocalHarness } from './local-harness-sI0S_XNA.js';
3
-
4
- /**
5
- *
6
- * The completion-oracle: **settled ⟺ DELIVERED.**
7
- *
8
- * Foreman's one hard lesson (0/18 self-improvement deliverables) — "done" must mean a check
9
- * PASSED, not the agent's say-so. `gateOnDeliverable` wraps an `Executor` so its settlement
10
- * is `valid` ONLY when the deliverable check passes. The child still RUNS and settles (its
11
- * spend is conserved into the pool either way), but a child that ran WITHOUT delivering
12
- * settles `valid:false` — so a keep-best driver never counts it as done, and a gate never
13
- * inflates with self-judged wins.
14
- *
15
- * Dual-purpose by construction:
16
- * - product: the agent fleet only advances on real, checked deliverables.
17
- * - proof: the gate's `valid` is the honest settle — equal-k comparisons can't be gamed by an
18
- * arm that "ran" without producing the artifact.
19
- *
20
- * The check is a DEPLOYABLE oracle — a test command, a state verifier, the commit0 judge —
21
- * read off the child's output, never the model judging itself. A throwing check is
22
- * fail-closed (not delivered), never a crash.
23
- *
24
- * @experimental
25
- */
26
-
27
- /**
28
- * The deployable completion oracle passed to {@link gateOnDeliverable}: a `check` that
29
- * decides DELIVERED (settles `valid` ⟺ it resolves true) plus an optional `describe` of
30
- * what the spawn was supposed to produce. The check reads the child's output — never the
31
- * model judging itself.
32
- */
33
- interface DeliverableSpec<Out = unknown> {
34
- /** The deployable check that decides DELIVERED. `settled.valid ⟺ this resolves true`. */
35
- check: (out: Out) => boolean | Promise<boolean>;
36
- /** What the spawn was supposed to produce — surfaced in traces/reports. */
37
- describe?: string;
38
- }
39
- /**
40
- * Wrap an `Executor` so its settlement `valid` reflects the deliverable check, not the
41
- * inner verdict. Handles both `execute` shapes (one-shot `Promise<ExecutorResult>` and
42
- * streaming `AsyncIterable<UsageEvent>` + `resultArtifact()`); the check runs once the inner
43
- * executor has produced its output. The inner `score` is preserved; only `valid` is gated.
44
- */
45
- declare function gateOnDeliverable<Out>(inner: Executor<Out>, deliverable: DeliverableSpec<Out>): Executor<Out>;
2
+ import { c as Executor } from './types-DAJQRIUD.js';
46
3
 
47
4
  /**
48
5
  *
@@ -197,4 +154,47 @@ type WorktreeCheckRunner = (opts: {
197
154
  output: string;
198
155
  }>;
199
156
 
157
+ /**
158
+ *
159
+ * The completion-oracle: **settled ⟺ DELIVERED.**
160
+ *
161
+ * Foreman's one hard lesson (0/18 self-improvement deliverables) — "done" must mean a check
162
+ * PASSED, not the agent's say-so. `gateOnDeliverable` wraps an `Executor` so its settlement
163
+ * is `valid` ONLY when the deliverable check passes. The child still RUNS and settles (its
164
+ * spend is conserved into the pool either way), but a child that ran WITHOUT delivering
165
+ * settles `valid:false` — so a keep-best driver never counts it as done, and a gate never
166
+ * inflates with self-judged wins.
167
+ *
168
+ * Dual-purpose by construction:
169
+ * - product: the agent fleet only advances on real, checked deliverables.
170
+ * - proof: the gate's `valid` is the honest settle — equal-k comparisons can't be gamed by an
171
+ * arm that "ran" without producing the artifact.
172
+ *
173
+ * The check is a DEPLOYABLE oracle — a test command, a state verifier, the commit0 judge —
174
+ * read off the child's output, never the model judging itself. A throwing check is
175
+ * fail-closed (not delivered), never a crash.
176
+ *
177
+ * @experimental
178
+ */
179
+
180
+ /**
181
+ * The deployable completion oracle passed to {@link gateOnDeliverable}: a `check` that
182
+ * decides DELIVERED (settles `valid` ⟺ it resolves true) plus an optional `describe` of
183
+ * what the spawn was supposed to produce. The check reads the child's output — never the
184
+ * model judging itself.
185
+ */
186
+ interface DeliverableSpec<Out = unknown> {
187
+ /** The deployable check that decides DELIVERED. `settled.valid ⟺ this resolves true`. */
188
+ check: (out: Out) => boolean | Promise<boolean>;
189
+ /** What the spawn was supposed to produce — surfaced in traces/reports. */
190
+ describe?: string;
191
+ }
192
+ /**
193
+ * Wrap an `Executor` so its settlement `valid` reflects the deliverable check, not the
194
+ * inner verdict. Handles both `execute` shapes (one-shot `Promise<ExecutorResult>` and
195
+ * streaming `AsyncIterable<UsageEvent>` + `resultArtifact()`); the check runs once the inner
196
+ * executor has produced its output. The inner `score` is preserved; only `valid` is gated.
197
+ */
198
+ declare function gateOnDeliverable<Out>(inner: Executor<Out>, deliverable: DeliverableSpec<Out>): Executor<Out>;
199
+
200
200
  export { type CreateWorktreeOptions as C, type DeliverableSpec as D, type GitRunner as G, type RemoveWorktreeOptions as R, type WorktreeHarnessResult as W, type WorktreeCheckRunner as a, type DiffOptions as b, type DiffResult as c, type WorktreeHandle as d, captureWorktreeDiff as e, createWorktree as f, type WorktreeCommandResult as g, gateOnDeliverable as h, removeWorktree as r };