@tangle-network/agent-runtime 0.69.0 → 0.70.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.
- package/README.md +81 -13
- package/dist/agent.d.ts +4 -5
- package/dist/agent.js +3 -6
- package/dist/agent.js.map +1 -1
- package/dist/chunk-BYZCXQHF.js +474 -0
- package/dist/chunk-BYZCXQHF.js.map +1 -0
- package/dist/{chunk-G6U3GVK2.js → chunk-EDCVUZZC.js} +2 -2
- package/dist/{chunk-RTDI2DHD.js → chunk-L5ZFBVT6.js} +6 -6
- package/dist/chunk-L5ZFBVT6.js.map +1 -0
- package/dist/{chunk-NLRA6434.js → chunk-QXWGSDAQ.js} +716 -535
- package/dist/chunk-QXWGSDAQ.js.map +1 -0
- package/dist/{chunk-QZ6FA5LM.js → chunk-ZNQVMMR5.js} +3 -3
- package/dist/{coordination-Curpzeyc.d.ts → coordination-C7WxwHXq.d.ts} +8 -1
- package/dist/{delegates-CLFNAKyi.d.ts → delegates-DqAgo32T.d.ts} +105 -10
- package/dist/{improvement-adapter-BC4HhuAR.d.ts → improvement-adapter-BVuMragr.d.ts} +1 -1
- package/dist/index.d.ts +439 -100
- package/dist/index.js +583 -125
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -3
- package/dist/{loop-runner-bin-B6dzNZC8.d.ts → loop-runner-bin-B0NeLTRd.d.ts} +4 -4
- package/dist/loop-runner-bin.d.ts +7 -10
- package/dist/loop-runner-bin.js +4 -7
- package/dist/loops.d.ts +3149 -16
- package/dist/loops.js +34 -63
- package/dist/mcp/bin.js +14 -16
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +8 -12
- package/dist/mcp/index.js +16 -19
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-CA2N3-Ak.d.ts → openai-tools-DPx9Gzvn.d.ts} +1 -1
- package/dist/profiles.d.ts +94 -6
- package/dist/profiles.js +320 -9
- package/dist/profiles.js.map +1 -1
- package/dist/{router-client-30Y_pca8.d.ts → router-client-C7kp_ECN.d.ts} +37 -1
- package/dist/{substrate-CUgk7F7s.d.ts → substrate-BoRXgvka.d.ts} +52 -1
- package/dist/{types-Crxftafi.d.ts → types-BYa2ZOAx.d.ts} +83 -2
- package/dist/{types-p8dWBIXL.d.ts → types-DJu6TBGp.d.ts} +2 -16
- package/dist/{worktree-fanout-DUiKPApb.d.ts → worktree-fanout-gNfl0Byj.d.ts} +9 -37
- package/package.json +9 -39
- package/dist/analyst-loop.d.ts +0 -52
- package/dist/analyst-loop.js +0 -11
- package/dist/analyst-loop.js.map +0 -1
- package/dist/audit.d.ts +0 -93
- package/dist/audit.js +0 -312
- package/dist/audit.js.map +0 -1
- package/dist/chunk-4B6U4CVQ.js +0 -15
- package/dist/chunk-4B6U4CVQ.js.map +0 -1
- package/dist/chunk-K4FQSEXQ.js +0 -214
- package/dist/chunk-K4FQSEXQ.js.map +0 -1
- package/dist/chunk-NLRA6434.js.map +0 -1
- package/dist/chunk-O2UPHN7X.js +0 -114
- package/dist/chunk-O2UPHN7X.js.map +0 -1
- package/dist/chunk-P5OKDSLB.js +0 -580
- package/dist/chunk-P5OKDSLB.js.map +0 -1
- package/dist/chunk-RTDI2DHD.js.map +0 -1
- package/dist/chunk-VLF5RHEQ.js +0 -143
- package/dist/chunk-VLF5RHEQ.js.map +0 -1
- package/dist/coder-2leJPOvC.d.ts +0 -52
- package/dist/improvement.d.ts +0 -208
- package/dist/improvement.js +0 -343
- package/dist/improvement.js.map +0 -1
- package/dist/local-harness-BE_h8szs.d.ts +0 -93
- package/dist/platform.d.ts +0 -255
- package/dist/platform.js +0 -229
- package/dist/platform.js.map +0 -1
- package/dist/run-loop-D3PwlG7J.d.ts +0 -112
- package/dist/runtime-hooks-C7JwKb9E.d.ts +0 -70
- package/dist/runtime.d.ts +0 -3120
- package/dist/runtime.js +0 -263
- package/dist/runtime.js.map +0 -1
- package/dist/topology.d.ts +0 -126
- package/dist/topology.js +0 -333
- package/dist/topology.js.map +0 -1
- package/dist/workflow.d.ts +0 -551
- package/dist/workflow.js +0 -1781
- package/dist/workflow.js.map +0 -1
- /package/dist/{chunk-G6U3GVK2.js.map → chunk-EDCVUZZC.js.map} +0 -0
- /package/dist/{chunk-QZ6FA5LM.js.map → chunk-ZNQVMMR5.js.map} +0 -0
package/dist/audit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/audit/issue-writer.ts"],"sourcesContent":["/**\n * @experimental\n *\n * UI-audit issue writer — pure I/O. Takes a workspace dir + `UiFinding[]`\n * and emits:\n * - `<workspace>/issues/NNN--<lens>--<slug>.md` — one self-contained\n * GitHub-issue-ready Markdown per finding, with embedded screenshot\n * references.\n * - `<workspace>/registry.json` — finding index for dedup and audit\n * resume across iterations.\n * - `<workspace>/index.md` — human-readable rollup (severity / lens /\n * route counts plus a sorted finding list).\n *\n * The writer is deterministic, idempotent for `appendFindings()`, and\n * never invokes an LLM. It assigns the next monotonic id to a finding the\n * caller did not pre-id.\n */\n\nimport { promises as fs } from 'node:fs'\nimport path from 'node:path'\nimport { slugify } from '../profiles/ui-auditor/slugify'\nimport {\n UI_FINDING_SEVERITIES,\n UI_LENSES,\n type UiFinding,\n type UiLens,\n} from '../profiles/ui-auditor/substrate'\n\n/** @experimental */\nexport interface AuditRegistry {\n schemaVersion: 1\n findings: UiFinding[]\n /** Route → URL + captures sidecar; preserved across runs. */\n routes: Record<string, { url?: string; captures: AuditRegistryCapture[] }>\n}\n\n/** @experimental */\nexport interface AuditRegistryCapture {\n file: string\n viewport?: string\n fullPage?: boolean\n elementSelector?: string\n capturedAt: string\n}\n\nconst SEVERITY_ORDER: Record<UiFinding['severity'], number> = {\n critical: 0,\n high: 1,\n med: 2,\n low: 3,\n}\n\n// Validate workspaceDir at every public entry point. The MCP tool checks\n// the same shape at the wire boundary, but the writer is independently\n// exported via `@tangle-network/agent-runtime/audit`, so direct callers\n// would otherwise bypass that defense. Absolute + no `..` segments matches\n// the MCP tool's contract — any path that the writer joins for I/O must be\n// rooted at a deterministic location chosen by the caller.\nfunction assertValidWorkspaceDir(dir: string): void {\n if (typeof dir !== 'string' || dir.length === 0) {\n throw new Error(\n `audit-writer: workspaceDir must be a non-empty string (got ${JSON.stringify(dir)})`,\n )\n }\n if (!path.isAbsolute(dir)) {\n throw new Error(\n `audit-writer: workspaceDir must be an absolute path (got ${JSON.stringify(dir)})`,\n )\n }\n if (dir.split(path.sep).includes('..')) {\n throw new Error(\n `audit-writer: workspaceDir must not contain '..' segments (got ${JSON.stringify(dir)})`,\n )\n }\n}\n\n/** @experimental */\nexport async function initAuditWorkspace(workspaceDir: string): Promise<void> {\n assertValidWorkspaceDir(workspaceDir)\n await fs.mkdir(path.join(workspaceDir, 'issues'), { recursive: true })\n await fs.mkdir(path.join(workspaceDir, 'screenshots'), { recursive: true })\n const regPath = path.join(workspaceDir, 'registry.json')\n try {\n await fs.access(regPath)\n } catch {\n const fresh: AuditRegistry = { schemaVersion: 1, findings: [], routes: {} }\n await fs.writeFile(regPath, JSON.stringify(fresh, null, 2))\n }\n}\n\n/** @experimental */\nexport async function readAuditRegistry(workspaceDir: string): Promise<AuditRegistry> {\n assertValidWorkspaceDir(workspaceDir)\n const regPath = path.join(workspaceDir, 'registry.json')\n const text = await fs.readFile(regPath, 'utf8')\n const parsed = JSON.parse(text) as unknown\n if (!parsed || typeof parsed !== 'object') {\n throw new Error(`audit-writer: registry.json at ${regPath} is not a JSON object`)\n }\n const reg = parsed as Partial<AuditRegistry>\n if (reg.schemaVersion !== 1 || !Array.isArray(reg.findings) || typeof reg.routes !== 'object') {\n throw new Error(`audit-writer: registry.json at ${regPath} has an unrecognized shape`)\n }\n return reg as AuditRegistry\n}\n\nasync function writeAuditRegistry(workspaceDir: string, reg: AuditRegistry): Promise<void> {\n const regPath = path.join(workspaceDir, 'registry.json')\n // Write to a sibling temp file and rename. POSIX rename is atomic, so a\n // reader at any instant sees either the pre-write OR post-write registry,\n // never a half-written file. Prevents corruption on crash mid-write.\n const tmpPath = `${regPath}.tmp-${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`\n await fs.writeFile(tmpPath, JSON.stringify(reg, null, 2))\n await fs.rename(tmpPath, regPath)\n}\n\n// Per-workspace serialization. The writer reads registry.json, mutates it\n// in memory, then writes it back; concurrent calls would race on the\n// monotonic-id assignment and clobber each other's findings. Each\n// workspace key holds the Promise of the most-recently-enqueued operation;\n// new operations chain off it so they run strictly serially.\nconst workspaceLocks = new Map<string, Promise<unknown>>()\n\nasync function withWorkspaceLock<T>(workspaceDir: string, fn: () => Promise<T>): Promise<T> {\n const key = path.resolve(workspaceDir)\n const prev = workspaceLocks.get(key) ?? Promise.resolve()\n let signalDone!: () => void\n const done = new Promise<void>((resolve) => {\n signalDone = resolve\n })\n workspaceLocks.set(key, done)\n try {\n await prev\n return await fn()\n } finally {\n signalDone()\n // Only delete if no later caller has overwritten the slot — preserves\n // the chain for any concurrent callers still waiting.\n if (workspaceLocks.get(key) === done) workspaceLocks.delete(key)\n }\n}\n\nfunction assertFindingShape(f: UiFinding, index: number): void {\n const where = `audit-writer: findings[${index}]`\n if (!UI_LENSES.includes(f.lens)) {\n throw new Error(\n `${where}: invalid lens ${JSON.stringify(f.lens)}; one of ${UI_LENSES.join('|')}`,\n )\n }\n if (!UI_FINDING_SEVERITIES.includes(f.severity)) {\n throw new Error(\n `${where}: invalid severity ${JSON.stringify(f.severity)}; one of ${UI_FINDING_SEVERITIES.join('|')}`,\n )\n }\n for (const field of ['title', 'route', 'observation', 'impact', 'suggestedFix'] as const) {\n const v = f[field]\n if (typeof v !== 'string' || v.trim().length === 0) {\n throw new Error(`${where}: ${field} must be a non-empty string`)\n }\n }\n if (!Array.isArray(f.screenshots) || f.screenshots.length === 0) {\n throw new Error(`${where}: screenshots must be a non-empty array`)\n }\n for (let i = 0; i < f.screenshots.length; i += 1) {\n const s = f.screenshots[i]\n if (!s || typeof s.path !== 'string' || s.path.length === 0) {\n throw new Error(`${where}.screenshots[${i}].path must be a non-empty string`)\n }\n // Defense-in-depth: screenshot paths are written verbatim into Markdown\n // and the registry; a downstream consumer that joins workspaceDir with\n // them would otherwise be exposed to traversal-read. Reject `..`\n // segments at the validation boundary.\n if (s.path.split(/[/\\\\]/).includes('..')) {\n throw new Error(`${where}.screenshots[${i}].path must not contain '..' segments`)\n }\n }\n}\n\nfunction nextFindingId(reg: AuditRegistry): number {\n let max = 0\n for (const f of reg.findings) {\n if (typeof f.id === 'number' && f.id > max) max = f.id\n }\n return max + 1\n}\n\nfunction slugifyTitle(title: string): string {\n return slugify(title, 'title')\n}\n\nfunction renderFinding(finding: UiFinding): string {\n if (!finding.id) {\n throw new Error('audit-writer: cannot render a finding without an assigned id')\n }\n if (finding.screenshots.length === 0) {\n throw new Error(`audit-writer: finding #${finding.id} has no screenshots`)\n }\n const id = finding.id\n const numStr = String(id).padStart(3, '0')\n\n const metaLines: string[] = [\n `> **Issue #${numStr}** · **Severity:** ${finding.severity} · **Lens:** ${finding.lens}`,\n `> **Route:** \\`${finding.route}\\`${finding.url ? ` · **URL:** ${finding.url}` : ''}`,\n ]\n if (finding.viewport) metaLines.push(`> **Viewport:** ${finding.viewport}`)\n if (finding.selector) metaLines.push(`> **Selector:** \\`${finding.selector}\\``)\n if (finding.tags && finding.tags.length > 0) {\n metaLines.push(`> **Tags:** ${finding.tags.map((t) => `\\`${t}\\``).join(', ')}`)\n }\n if (finding.similarTo && finding.similarTo.length > 0) {\n metaLines.push(\n `> **Possible duplicates:** ${finding.similarTo.map((n) => `#${String(n).padStart(3, '0')}`).join(', ')}`,\n )\n }\n metaLines.push(`> _Generated: ${finding.createdAt ?? new Date().toISOString()}_`)\n\n const reproSteps =\n finding.reproSteps ??\n `1. Open \\`${finding.route}\\`${finding.url ? ` (${finding.url})` : ''}\\n2. Observe the area shown in the screenshot${finding.selector ? ` (selector: \\`${finding.selector}\\`)` : ''}.`\n\n // Screenshot paths are workspace-relative; the issue file sits in\n // `<workspace>/issues/`, so we render `../<path>`.\n const evidence = finding.screenshots\n .map((s) => ``)\n .join('\\n\\n')\n\n return [\n `# [UI] ${finding.title}`,\n '',\n metaLines.join('\\n'),\n '',\n '## Observation',\n finding.observation.trim(),\n '',\n '## Why it matters',\n finding.impact.trim(),\n '',\n '## Steps to reproduce',\n reproSteps,\n '',\n '## Suggested fix',\n finding.suggestedFix.trim(),\n '',\n '## Evidence',\n evidence,\n '',\n '---',\n `<sub>Generated by agent-runtime/ui-auditor · lens=\\`${finding.lens}\\` · severity=\\`${finding.severity}\\`</sub>`,\n '',\n ].join('\\n')\n}\n\n/** @experimental */\nexport interface AppendFindingsResult {\n /** Findings with id + createdAt assigned, in input order. */\n written: UiFinding[]\n /** Workspace-relative path to each issue Markdown file, in input order. */\n files: string[]\n}\n\n/**\n * Append findings to a workspace, writing one Markdown file per finding\n * and updating registry.json. Assigns monotonically increasing ids to\n * findings that arrived without one.\n *\n * Findings already carrying an id that collides with the registry are\n * rejected — callers must either freshly mint findings (id undefined) or\n * use a separate update path. This protects against accidental overwrite.\n *\n * @experimental\n */\nexport async function appendFindings(\n workspaceDir: string,\n findings: readonly UiFinding[],\n): Promise<AppendFindingsResult> {\n assertValidWorkspaceDir(workspaceDir)\n // Validate every finding BEFORE acquiring the lock so callers see a fast\n // input-shape error without blocking concurrent writers. Validation is\n // the only defense against path traversal via crafted `lens` values\n // (the filename interpolates lens directly) and against malformed\n // Markdown from missing required fields — TypeScript types are erased\n // at runtime, so this boundary cannot trust its callers.\n for (let i = 0; i < findings.length; i += 1) {\n const f = findings[i]\n if (!f) throw new Error(`audit-writer: findings[${i}] is undefined`)\n assertFindingShape(f, i)\n }\n\n return withWorkspaceLock(workspaceDir, async () => {\n await initAuditWorkspace(workspaceDir)\n const reg = await readAuditRegistry(workspaceDir)\n const usedIds = new Set<number>()\n for (const f of reg.findings) {\n if (typeof f.id === 'number') usedIds.add(f.id)\n }\n\n const written: UiFinding[] = []\n const files: string[] = []\n let nextId = nextFindingId(reg)\n\n for (const incoming of findings) {\n let id = incoming.id\n if (id !== undefined) {\n if (usedIds.has(id)) {\n throw new Error(\n `audit-writer: incoming finding id ${id} (title=${JSON.stringify(incoming.title)}) collides with an existing registry entry`,\n )\n }\n } else {\n id = nextId\n while (usedIds.has(id)) id += 1\n nextId = id + 1\n }\n usedIds.add(id)\n\n const createdAt = incoming.createdAt ?? new Date().toISOString()\n const persisted: UiFinding = { ...incoming, id, createdAt }\n\n const slug = slugifyTitle(persisted.title)\n const fileName = `${String(id).padStart(3, '0')}--${persisted.lens}--${slug}.md`\n const filePathAbs = path.join(workspaceDir, 'issues', fileName)\n const filePathRel = `issues/${fileName}`\n\n await fs.writeFile(filePathAbs, renderFinding(persisted))\n reg.findings.push(persisted)\n written.push(persisted)\n files.push(filePathRel)\n }\n\n await writeAuditRegistry(workspaceDir, reg)\n return { written, files }\n })\n}\n\n/** @experimental */\nexport interface RegisterCapturesOptions {\n route: string\n url?: string\n captures: readonly AuditRegistryCapture[]\n}\n\n/**\n * Record screenshots taken for a route in the registry, without filing a\n * finding. Useful when the auditor wants to remember which captures\n * exist for resume / dedup purposes.\n *\n * @experimental\n */\nexport async function registerCaptures(\n workspaceDir: string,\n options: RegisterCapturesOptions,\n): Promise<void> {\n assertValidWorkspaceDir(workspaceDir)\n if (typeof options.route !== 'string' || options.route.trim().length === 0) {\n throw new Error('audit-writer: registerCaptures: route must be a non-empty string')\n }\n return withWorkspaceLock(workspaceDir, async () => {\n await initAuditWorkspace(workspaceDir)\n const reg = await readAuditRegistry(workspaceDir)\n const slot = reg.routes[options.route] ?? { captures: [] }\n if (options.url) slot.url = options.url\n slot.captures = [...slot.captures, ...options.captures]\n reg.routes[options.route] = slot\n await writeAuditRegistry(workspaceDir, reg)\n })\n}\n\n/** @experimental */\nexport interface AuditIndex {\n /** Total findings in the workspace. */\n total: number\n bySeverity: Record<UiFinding['severity'], number>\n byLens: Partial<Record<UiLens, number>>\n byRoute: Record<string, number>\n}\n\n/** @experimental */\nexport function summarizeRegistry(reg: AuditRegistry): AuditIndex {\n const bySeverity: Record<UiFinding['severity'], number> = {\n critical: 0,\n high: 0,\n med: 0,\n low: 0,\n }\n const byLens: Partial<Record<UiLens, number>> = {}\n const byRoute: Record<string, number> = {}\n for (const f of reg.findings) {\n bySeverity[f.severity] += 1\n byLens[f.lens] = (byLens[f.lens] ?? 0) + 1\n byRoute[f.route] = (byRoute[f.route] ?? 0) + 1\n }\n return { total: reg.findings.length, bySeverity, byLens, byRoute }\n}\n\n/**\n * Regenerate `<workspace>/index.md` from registry.json.\n *\n * @experimental\n */\nexport async function writeAuditIndex(workspaceDir: string): Promise<string> {\n assertValidWorkspaceDir(workspaceDir)\n const reg = await readAuditRegistry(workspaceDir)\n const summary = summarizeRegistry(reg)\n\n const sorted = [...reg.findings].sort((a, b) => {\n const sa = SEVERITY_ORDER[a.severity]\n const sb = SEVERITY_ORDER[b.severity]\n if (sa !== sb) return sa - sb\n return (a.id ?? 0) - (b.id ?? 0)\n })\n\n const lines: string[] = []\n lines.push('# UI audit index', '')\n lines.push(`_Generated: ${new Date().toISOString()}_`, '')\n lines.push(`**Total findings:** ${summary.total}`, '')\n lines.push('## By severity')\n for (const s of ['critical', 'high', 'med', 'low'] as const) {\n const n = summary.bySeverity[s] ?? 0\n if (n > 0) lines.push(`- **${s}** — ${n}`)\n }\n lines.push('', '## By lens')\n const lensEntries: [string, number][] = Object.entries(summary.byLens).map(([k, v]) => [\n k,\n v ?? 0,\n ])\n for (const [lens, n] of lensEntries.sort((a, b) => b[1] - a[1])) {\n lines.push(`- **${lens}** — ${n}`)\n }\n lines.push('', '## By route')\n const routeEntries: [string, number][] = Object.entries(summary.byRoute).map(([k, v]) => [\n k,\n v ?? 0,\n ])\n for (const [route, n] of routeEntries.sort((a, b) => b[1] - a[1])) {\n lines.push(`- \\`${route}\\` — ${n}`)\n }\n lines.push('', '## Findings', '')\n for (const f of sorted) {\n if (typeof f.id !== 'number') continue\n const num = String(f.id).padStart(3, '0')\n const slug = slugifyTitle(f.title)\n const file = `issues/${num}--${f.lens}--${slug}.md`\n lines.push(`- [#${num} \\`${f.severity}\\` \\`${f.lens}\\` \\`${f.route}\\` — ${f.title}](${file})`)\n }\n lines.push('')\n\n const out = path.join(workspaceDir, 'index.md')\n const body = lines.join('\\n')\n await fs.writeFile(out, body)\n return out\n}\n"],"mappings":";;;;;;;;;;AAkBA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AA0BjB,IAAM,iBAAwD;AAAA,EAC5D,UAAU;AAAA,EACV,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AACP;AAQA,SAAS,wBAAwB,KAAmB;AAClD,MAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,GAAG;AAC/C,UAAM,IAAI;AAAA,MACR,8DAA8D,KAAK,UAAU,GAAG,CAAC;AAAA,IACnF;AAAA,EACF;AACA,MAAI,CAAC,KAAK,WAAW,GAAG,GAAG;AACzB,UAAM,IAAI;AAAA,MACR,4DAA4D,KAAK,UAAU,GAAG,CAAC;AAAA,IACjF;AAAA,EACF;AACA,MAAI,IAAI,MAAM,KAAK,GAAG,EAAE,SAAS,IAAI,GAAG;AACtC,UAAM,IAAI;AAAA,MACR,kEAAkE,KAAK,UAAU,GAAG,CAAC;AAAA,IACvF;AAAA,EACF;AACF;AAGA,eAAsB,mBAAmB,cAAqC;AAC5E,0BAAwB,YAAY;AACpC,QAAM,GAAG,MAAM,KAAK,KAAK,cAAc,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AACrE,QAAM,GAAG,MAAM,KAAK,KAAK,cAAc,aAAa,GAAG,EAAE,WAAW,KAAK,CAAC;AAC1E,QAAM,UAAU,KAAK,KAAK,cAAc,eAAe;AACvD,MAAI;AACF,UAAM,GAAG,OAAO,OAAO;AAAA,EACzB,QAAQ;AACN,UAAM,QAAuB,EAAE,eAAe,GAAG,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE;AAC1E,UAAM,GAAG,UAAU,SAAS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AAI;AAC9C,UAAM,KAAK,OAAO,GAAG,MAAM,EAAE,QAAQ,QAAQ,EAAE,IAAI,QAAQ,EAAE,KAAK,aAAQ,EAAE,KAAK,KAAK,IAAI,GAAG;AAAA,EAC/F;AACA,QAAM,KAAK,EAAE;AAEb,QAAM,MAAM,KAAK,KAAK,cAAc,UAAU;AAC9C,QAAM,OAAO,MAAM,KAAK,IAAI;AAC5B,QAAM,GAAG,UAAU,KAAK,IAAI;AAC5B,SAAO;AACT;","names":[]}
|
package/dist/chunk-4B6U4CVQ.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/profiles/ui-auditor/slugify.ts
|
|
2
|
-
function slugify(value, fieldName) {
|
|
3
|
-
const slug = value.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
4
|
-
if (slug.length === 0) {
|
|
5
|
-
throw new Error(
|
|
6
|
-
`ui-auditor: ${fieldName} slugified to empty string. Provide a non-empty value (got ${JSON.stringify(value)}).`
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
return slug;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
slugify
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=chunk-4B6U4CVQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/profiles/ui-auditor/slugify.ts"],"sourcesContent":["/**\n * @experimental\n *\n * Shared slug helper used by both the in-process auditor client (for\n * screenshot filenames) and the issue writer (for issue Markdown\n * filenames). Lowercases, normalizes, strips non-alphanumeric, trims\n * dashes, caps at 80 chars. Throws when the result is empty so callers\n * never silently write to a name-less filename.\n */\n\n/** @experimental */\nexport function slugify(value: string, fieldName: string): string {\n const slug = value\n .toLowerCase()\n .normalize('NFKD')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80)\n if (slug.length === 0) {\n throw new Error(\n `ui-auditor: ${fieldName} slugified to empty string. Provide a non-empty value (got ${JSON.stringify(value)}).`,\n )\n }\n return slug\n}\n"],"mappings":";AAWO,SAAS,QAAQ,OAAe,WAA2B;AAChE,QAAM,OAAO,MACV,YAAY,EACZ,UAAU,MAAM,EAChB,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE,EACtB,MAAM,GAAG,EAAE;AACd,MAAI,KAAK,WAAW,GAAG;AACrB,UAAM,IAAI;AAAA,MACR,eAAe,SAAS,8DAA8D,KAAK,UAAU,KAAK,CAAC;AAAA,IAC7G;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/chunk-K4FQSEXQ.js
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createKbGate
|
|
3
|
-
} from "./chunk-FNMGYYSS.js";
|
|
4
|
-
import {
|
|
5
|
-
detachedSessionDelegate
|
|
6
|
-
} from "./chunk-RTDI2DHD.js";
|
|
7
|
-
import {
|
|
8
|
-
runAnalystLoop
|
|
9
|
-
} from "./chunk-P5OKDSLB.js";
|
|
10
|
-
import {
|
|
11
|
-
createExecutorRegistry,
|
|
12
|
-
definePersona,
|
|
13
|
-
runPersonified,
|
|
14
|
-
worktreeFanout
|
|
15
|
-
} from "./chunk-NLRA6434.js";
|
|
16
|
-
import {
|
|
17
|
-
ConfigError
|
|
18
|
-
} from "./chunk-VLF5RHEQ.js";
|
|
19
|
-
|
|
20
|
-
// src/loop-runner.ts
|
|
21
|
-
import {
|
|
22
|
-
selfImprove
|
|
23
|
-
} from "@tangle-network/agent-eval/contract";
|
|
24
|
-
var DELEGATED_LOOP_MODES = ["code", "review", "research", "audit", "self-improve"];
|
|
25
|
-
function isDelegatedLoopMode(value) {
|
|
26
|
-
return typeof value === "string" && DELEGATED_LOOP_MODES.includes(value);
|
|
27
|
-
}
|
|
28
|
-
async function runDelegatedLoop(mode, registry, options = {}) {
|
|
29
|
-
const runner = registry[mode];
|
|
30
|
-
if (!runner) {
|
|
31
|
-
throw new ConfigError(
|
|
32
|
-
`runDelegatedLoop: no runner registered for mode '${mode}' (registered: ${Object.keys(registry).join(", ") || "none"})`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
const now = options.now ?? Date.now;
|
|
36
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
37
|
-
const start = now();
|
|
38
|
-
try {
|
|
39
|
-
const output = await runner(signal);
|
|
40
|
-
return { mode, ok: true, output, durationMs: now() - start };
|
|
41
|
-
} catch (err) {
|
|
42
|
-
return {
|
|
43
|
-
mode,
|
|
44
|
-
ok: false,
|
|
45
|
-
error: err instanceof Error ? err.message : String(err),
|
|
46
|
-
durationMs: now() - start
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function coderLoopRunner(options) {
|
|
51
|
-
const delegate = detachedSessionDelegate({
|
|
52
|
-
sandboxClient: options.sandboxClient,
|
|
53
|
-
...options.reviewer ? { reviewer: options.reviewer } : {},
|
|
54
|
-
...options.winnerSelection ? { winnerSelection: options.winnerSelection } : {},
|
|
55
|
-
...options.fanoutHarnesses ? { fanoutHarnesses: options.fanoutHarnesses } : {}
|
|
56
|
-
});
|
|
57
|
-
return async (signal) => {
|
|
58
|
-
const ctx = { signal, report: () => {
|
|
59
|
-
} };
|
|
60
|
-
return delegate(options.args, ctx);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function worktreeLoopRunner(options) {
|
|
64
|
-
const shape = worktreeFanout({
|
|
65
|
-
repoRoot: options.repoRoot,
|
|
66
|
-
taskPrompt: options.taskPrompt,
|
|
67
|
-
harnesses: options.harnesses,
|
|
68
|
-
...options.testCmd !== void 0 ? { testCmd: options.testCmd } : {},
|
|
69
|
-
...options.typecheckCmd !== void 0 ? { typecheckCmd: options.typecheckCmd } : {},
|
|
70
|
-
...options.require !== void 0 ? { require: options.require } : {},
|
|
71
|
-
...options.maxDiffLines !== void 0 ? { maxDiffLines: options.maxDiffLines } : {},
|
|
72
|
-
...options.forbiddenPaths !== void 0 ? { forbiddenPaths: options.forbiddenPaths } : {},
|
|
73
|
-
...options.winnerStrategy !== void 0 ? { winnerStrategy: options.winnerStrategy } : {},
|
|
74
|
-
...options.runGit ? { runGit: options.runGit } : {},
|
|
75
|
-
...options.runHarness ? { runHarness: options.runHarness } : {},
|
|
76
|
-
...options.runCommand ? { runCommand: options.runCommand } : {}
|
|
77
|
-
});
|
|
78
|
-
const persona = definePersona({
|
|
79
|
-
name: "worktree-coder",
|
|
80
|
-
root: { profile: { name: "worktree-coder" }, harness: null },
|
|
81
|
-
directive: "deliver a minimal validated patch on a fresh worktree",
|
|
82
|
-
context: { role: "coder" },
|
|
83
|
-
executors: { registry: createExecutorRegistry() }
|
|
84
|
-
});
|
|
85
|
-
return async (signal) => {
|
|
86
|
-
const result = await runPersonified({
|
|
87
|
-
persona,
|
|
88
|
-
shape,
|
|
89
|
-
task: options.taskPrompt,
|
|
90
|
-
budget: options.budget,
|
|
91
|
-
signal
|
|
92
|
-
});
|
|
93
|
-
if (result.kind !== "winner" || result.out.kind !== "done") {
|
|
94
|
-
const blockers = result.kind === "winner" && result.out.kind === "blocked" ? result.out.blockers.join("; ") : `supervisor settled ${result.kind}`;
|
|
95
|
-
throw new Error(`worktreeLoopRunner: no delivered patch (${blockers})`);
|
|
96
|
-
}
|
|
97
|
-
return result.out.deliverable;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function researchLoopRunner(o) {
|
|
101
|
-
const gate = createKbGate(o.gate);
|
|
102
|
-
const maxRounds = Math.max(1, Math.trunc(o.maxRounds ?? 1));
|
|
103
|
-
return async (signal) => {
|
|
104
|
-
const accepted = [];
|
|
105
|
-
let vetoed = [];
|
|
106
|
-
let rounds = 0;
|
|
107
|
-
for (let round = 0; round < maxRounds; round += 1) {
|
|
108
|
-
if (signal.aborted) break;
|
|
109
|
-
rounds += 1;
|
|
110
|
-
const candidates = await o.research(round, vetoed);
|
|
111
|
-
if (candidates.length === 0) break;
|
|
112
|
-
vetoed = [];
|
|
113
|
-
for (const c of candidates) {
|
|
114
|
-
const v = await gate(c);
|
|
115
|
-
if (v.accepted) accepted.push(c);
|
|
116
|
-
else vetoed.push({ candidate: c, vetoedBy: v.vetoedBy, reason: v.reason });
|
|
117
|
-
}
|
|
118
|
-
if (vetoed.length === 0) break;
|
|
119
|
-
}
|
|
120
|
-
return { accepted, vetoed, rounds };
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function selfImproveLoopRunner(options) {
|
|
124
|
-
return async () => selfImprove(options);
|
|
125
|
-
}
|
|
126
|
-
function auditLoopRunner(options) {
|
|
127
|
-
return async () => runAnalystLoop(options);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// src/loop-runner-bin.ts
|
|
131
|
-
async function runLoopRunnerCli(args) {
|
|
132
|
-
if (!isDelegatedLoopMode(args.mode)) {
|
|
133
|
-
return {
|
|
134
|
-
exitCode: 2,
|
|
135
|
-
error: `unknown mode '${args.mode}' (expected one of: ${DELEGATED_LOOP_MODES.join(", ")})`
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
let registry;
|
|
139
|
-
try {
|
|
140
|
-
registry = await args.loadRegistry();
|
|
141
|
-
} catch (err) {
|
|
142
|
-
return { exitCode: 2, error: `failed to load registry: ${errMsg(err)}` };
|
|
143
|
-
}
|
|
144
|
-
if (!registry[args.mode]) {
|
|
145
|
-
return {
|
|
146
|
-
exitCode: 2,
|
|
147
|
-
error: `config registers no runner for mode '${args.mode}' (registered: ${Object.keys(registry).join(", ") || "none"})`
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
const result = await runDelegatedLoop(args.mode, registry, {
|
|
151
|
-
...args.now ? { now: args.now } : {}
|
|
152
|
-
});
|
|
153
|
-
return { exitCode: result.ok ? 0 : 1, result };
|
|
154
|
-
}
|
|
155
|
-
function parseLoopRunnerArgv(argv) {
|
|
156
|
-
const out = {};
|
|
157
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
158
|
-
const a = argv[i];
|
|
159
|
-
if (a === "--mode") out.mode = argv[++i];
|
|
160
|
-
else if (a === "--config") out.config = argv[++i];
|
|
161
|
-
else if (a?.startsWith("--mode=")) out.mode = a.slice("--mode=".length);
|
|
162
|
-
else if (a?.startsWith("--config=")) out.config = a.slice("--config=".length);
|
|
163
|
-
}
|
|
164
|
-
return out;
|
|
165
|
-
}
|
|
166
|
-
function resolveRegistry(mod) {
|
|
167
|
-
const def = mod?.default ?? mod;
|
|
168
|
-
const value = typeof def === "function" ? def() : def;
|
|
169
|
-
return value;
|
|
170
|
-
}
|
|
171
|
-
function errMsg(err) {
|
|
172
|
-
return err instanceof Error ? err.message : String(err);
|
|
173
|
-
}
|
|
174
|
-
async function main() {
|
|
175
|
-
const { mode, config } = parseLoopRunnerArgv(process.argv.slice(2));
|
|
176
|
-
if (!mode || !config) {
|
|
177
|
-
process.stderr.write(
|
|
178
|
-
`usage: agent-runtime-loop --mode <mode> --config <module>
|
|
179
|
-
modes: ${DELEGATED_LOOP_MODES.join(" | ")}
|
|
180
|
-
config: a JS/TS module default-exporting a DelegatedLoopRegistry (or a factory)
|
|
181
|
-
`
|
|
182
|
-
);
|
|
183
|
-
process.exit(2);
|
|
184
|
-
}
|
|
185
|
-
const { pathToFileURL } = await import("url");
|
|
186
|
-
const { resolve } = await import("path");
|
|
187
|
-
const cli = await runLoopRunnerCli({
|
|
188
|
-
mode,
|
|
189
|
-
loadRegistry: async () => resolveRegistry(await import(pathToFileURL(resolve(config)).href))
|
|
190
|
-
});
|
|
191
|
-
process.stdout.write(`${JSON.stringify(cli.result ?? { error: cli.error }, null, 2)}
|
|
192
|
-
`);
|
|
193
|
-
if (cli.error) process.stderr.write(`${cli.error}
|
|
194
|
-
`);
|
|
195
|
-
process.exit(cli.exitCode);
|
|
196
|
-
}
|
|
197
|
-
var invokedScript = typeof process !== "undefined" ? process.argv?.[1] : void 0;
|
|
198
|
-
if (invokedScript && /loop-runner-bin\.(js|ts|mjs)$/.test(invokedScript)) {
|
|
199
|
-
void main();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export {
|
|
203
|
-
DELEGATED_LOOP_MODES,
|
|
204
|
-
isDelegatedLoopMode,
|
|
205
|
-
runDelegatedLoop,
|
|
206
|
-
coderLoopRunner,
|
|
207
|
-
worktreeLoopRunner,
|
|
208
|
-
researchLoopRunner,
|
|
209
|
-
selfImproveLoopRunner,
|
|
210
|
-
auditLoopRunner,
|
|
211
|
-
runLoopRunnerCli,
|
|
212
|
-
parseLoopRunnerArgv
|
|
213
|
-
};
|
|
214
|
-
//# sourceMappingURL=chunk-K4FQSEXQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/loop-runner.ts","../src/loop-runner-bin.ts"],"sourcesContent":["/**\n * @experimental\n *\n * `runDelegatedLoop` — the configured delegated loop-runner.\n *\n * One typed entrypoint a worker agent (or a scheduled routine) calls to run a\n * disciplined loop in a chosen MODE, over agent-runtime's hardened engines:\n *\n * code → build-in-a-loop via the coder delegate (no-op + secret floor,\n * optional reviewer gate, winner-selection)\n * review → code mode with a REQUIRED reviewer (the gate is the point)\n * research → research-in-a-loop with valid-only KB growth (createKbGate)\n * audit → analyze trace/run data → findings (runAnalystLoop, caller-wired)\n * self-improve → closed-loop text/config optimization (selfImprove, held-out gated)\n *\n * It is intentionally a thin façade: the value is that EVERY product reuses the\n * one hardened engine instead of forking delegation logic. The dispatcher owns\n * mode routing, timing, fail-loud on an unregistered mode, and a uniform result\n * shape; each mode's engine is a pre-configured runner in the registry (build it\n * with the factories below, or inject your own / a stub).\n */\n\nimport type { Scenario } from '@tangle-network/agent-eval/campaign'\nimport {\n type SelfImproveOptions,\n type SelfImproveResult,\n selfImprove,\n} from '@tangle-network/agent-eval/contract'\nimport { runAnalystLoop } from './analyst-loop'\nimport type { RunAnalystLoopOpts, RunAnalystLoopResult } from './analyst-loop/types'\nimport { ConfigError } from './errors'\nimport {\n type CoderReviewer,\n type DelegateRunCtx,\n type DetachedWinnerSelection,\n detachedSessionDelegate,\n} from './mcp/delegates'\nimport type { CoderOutput } from './mcp/detached-coder'\nimport { type CreateKbGateOptions, createKbGate, type FactCandidate } from './mcp/kb-gate'\nimport type { DelegateCodeArgs } from './mcp/types'\nimport {\n type AuthoredHarness,\n type Budget,\n createExecutorRegistry,\n definePersona,\n runPersonified,\n type SandboxClient,\n type WinnerStrategy,\n type WorktreeFanoutOptions,\n type WorktreePatchArtifact,\n worktreeFanout,\n} from './runtime'\n\n/** @experimental Every delegated-loop mode, for validation + CLI surfaces. */\nexport const DELEGATED_LOOP_MODES = ['code', 'review', 'research', 'audit', 'self-improve'] as const\n\n/** @experimental */\nexport type DelegatedLoopMode = (typeof DELEGATED_LOOP_MODES)[number]\n\n/** @experimental Type guard for an untrusted mode string (CLI / config input). */\nexport function isDelegatedLoopMode(value: unknown): value is DelegatedLoopMode {\n return typeof value === 'string' && (DELEGATED_LOOP_MODES as readonly string[]).includes(value)\n}\n\n/** @experimental A pre-configured loop for one mode. Returns the mode's raw\n * output; the dispatcher wraps it in a {@link DelegatedLoopResult}. */\nexport type DelegatedLoopRunner<T = unknown> = (signal: AbortSignal) => Promise<T>\n\n/** @experimental Mode → configured runner. Partial: only register the modes a\n * given product/routine actually uses. */\nexport type DelegatedLoopRegistry = Partial<Record<DelegatedLoopMode, DelegatedLoopRunner>>\n\n/** @experimental Uniform result — never throws from a registered runner; a\n * thrown engine becomes `{ ok: false, error }` so a routine can record + move on. */\nexport interface DelegatedLoopResult<T = unknown> {\n mode: DelegatedLoopMode\n ok: boolean\n output?: T\n error?: string\n durationMs: number\n}\n\n/** @experimental */\nexport interface RunDelegatedLoopOptions {\n signal?: AbortSignal\n /** Clock override for deterministic tests. */\n now?: () => number\n}\n\n/**\n * @experimental\n *\n * Dispatch a configured loop by mode. Fails loud (throws `ConfigError`) when no\n * runner is registered for the mode — a routine pointed at an unwired mode is a\n * config bug, not a silent no-op. A runner that throws is captured as\n * `{ ok: false }` so unattended runs record the failure rather than crash.\n */\nexport async function runDelegatedLoop<T = unknown>(\n mode: DelegatedLoopMode,\n registry: DelegatedLoopRegistry,\n options: RunDelegatedLoopOptions = {},\n): Promise<DelegatedLoopResult<T>> {\n const runner = registry[mode] as DelegatedLoopRunner<T> | undefined\n if (!runner) {\n throw new ConfigError(\n `runDelegatedLoop: no runner registered for mode '${mode}' (registered: ${\n Object.keys(registry).join(', ') || 'none'\n })`,\n )\n }\n const now = options.now ?? Date.now\n const signal = options.signal ?? new AbortController().signal\n const start = now()\n try {\n const output = await runner(signal)\n return { mode, ok: true, output, durationMs: now() - start }\n } catch (err) {\n return {\n mode,\n ok: false,\n error: err instanceof Error ? err.message : String(err),\n durationMs: now() - start,\n }\n }\n}\n\n/** @experimental Options for the default `code`/`review` runner. */\nexport interface CoderLoopRunnerOptions {\n sandboxClient: SandboxClient\n /** What to build — the delegate args (goal, repoRoot, variants, config, …). */\n args: DelegateCodeArgs\n /** Adversarial reviewer. Pass one to run `review` mode (an approval gate over the candidate). */\n reviewer?: CoderReviewer\n /** Winner-selection strategy. Default `highest-score`. */\n winnerSelection?: DetachedWinnerSelection\n /** Harnesses for `variants > 1` fanout. */\n fanoutHarnesses?: string[]\n}\n\n/**\n * @experimental Build a `code`/`review`-mode runner over the sandbox-session coder delegate. Pass a\n * `reviewer` to run `review` mode — an approval gate over the validated candidate.\n */\nexport function coderLoopRunner(options: CoderLoopRunnerOptions): DelegatedLoopRunner<CoderOutput> {\n const delegate = detachedSessionDelegate({\n sandboxClient: options.sandboxClient,\n ...(options.reviewer ? { reviewer: options.reviewer } : {}),\n ...(options.winnerSelection ? { winnerSelection: options.winnerSelection } : {}),\n ...(options.fanoutHarnesses ? { fanoutHarnesses: options.fanoutHarnesses } : {}),\n })\n return async (signal) => {\n const ctx: DelegateRunCtx = { signal, report: () => {} }\n return delegate(options.args, ctx)\n }\n}\n\n/** @experimental Options for the local-repo `code` runner over the GENERIC recursive path. */\nexport interface WorktreeLoopRunnerOptions {\n /** Absolute path to the local git checkout each worktree is cut from. */\n repoRoot: string\n /** The instruction handed to every authored harness (composed under each profile's systemPrompt). */\n taskPrompt: string\n /** The supervisor-authored harness profiles — one fanout item (one worktree-CLI leaf) each. */\n harnesses: ReadonlyArray<AuthoredHarness>\n /** Conserved budget pool bounding the fanout (equal-k holds by construction). */\n budget: Budget\n /** Shell command run in each worktree to derive the tests-PASS signal. */\n testCmd?: string\n /** Shell command run in each worktree to derive the typecheck-PASS signal. */\n typecheckCmd?: string\n /** Which verification signals the deliverable REQUIRES present-and-passing (default none). */\n require?: ReadonlyArray<'tests' | 'typecheck'>\n /** Diff-size cap (lines). */\n maxDiffLines?: number\n /** Literal path prefixes the patch must not touch (the secret-floor is always on regardless). */\n forbiddenPaths?: string[]\n /** Winner-selection strategy among gated candidates. Default `highest-score`. */\n winnerStrategy?: WinnerStrategy\n /** Test seams forwarded to the worktree-CLI leaves so the runner drives offline. */\n runGit?: WorktreeFanoutOptions['runGit']\n runHarness?: WorktreeFanoutOptions['runHarness']\n runCommand?: WorktreeFanoutOptions['runCommand']\n}\n\n/**\n * @experimental\n *\n * `code` mode on the GENERIC recursive path: author one `AgentProfile` per harness, run them as a\n * `worktreeFanout` (N `createWorktreeCliExecutor` leaves, each `gateOnDeliverable`) through\n * `runPersonified` on the keystone Supervisor. This is the local-repo counterpart to\n * {@link coderLoopRunner} (which drives the in-box harness over a `SandboxClient`): no `runLoop`\n * driver, no role-coupled delegate — the harness list is the fanout, the gate is `patchDelivered`,\n * the winner is the shared valid-only selector (NOT `defaultSelectWinner`, whose non-valid fallback\n * would surface an ungated patch). Equal-k holds by the conserved budget pool. Returns the winning\n * patch artifact, or throws when no candidate is delivered (fail loud, never a vacuous done).\n */\nexport function worktreeLoopRunner(\n options: WorktreeLoopRunnerOptions,\n): DelegatedLoopRunner<WorktreePatchArtifact> {\n const shape = worktreeFanout<string>({\n repoRoot: options.repoRoot,\n taskPrompt: options.taskPrompt,\n harnesses: options.harnesses,\n ...(options.testCmd !== undefined ? { testCmd: options.testCmd } : {}),\n ...(options.typecheckCmd !== undefined ? { typecheckCmd: options.typecheckCmd } : {}),\n ...(options.require !== undefined ? { require: options.require } : {}),\n ...(options.maxDiffLines !== undefined ? { maxDiffLines: options.maxDiffLines } : {}),\n ...(options.forbiddenPaths !== undefined ? { forbiddenPaths: options.forbiddenPaths } : {}),\n ...(options.winnerStrategy !== undefined ? { winnerStrategy: options.winnerStrategy } : {}),\n ...(options.runGit ? { runGit: options.runGit } : {}),\n ...(options.runHarness ? { runHarness: options.runHarness } : {}),\n ...(options.runCommand ? { runCommand: options.runCommand } : {}),\n })\n // The persona's only role here is to carry the fanout shape onto the Supervisor; each item's\n // executor is BYO (the gated worktree-CLI leaf), so the registry only needs to pass BYO through.\n const persona = definePersona<WorktreePatchArtifact>({\n name: 'worktree-coder',\n root: { profile: { name: 'worktree-coder' }, harness: null },\n directive: 'deliver a minimal validated patch on a fresh worktree',\n context: { role: 'coder' },\n executors: { registry: createExecutorRegistry() },\n })\n return async (signal) => {\n const result = await runPersonified<string, WorktreePatchArtifact>({\n persona,\n shape,\n task: options.taskPrompt,\n budget: options.budget,\n signal,\n })\n if (result.kind !== 'winner' || result.out.kind !== 'done') {\n const blockers =\n result.kind === 'winner' && result.out.kind === 'blocked'\n ? result.out.blockers.join('; ')\n : `supervisor settled ${result.kind}`\n throw new Error(`worktreeLoopRunner: no delivered patch (${blockers})`)\n }\n return result.out.deliverable\n }\n}\n\n/** @experimental A fact rejected at the KB gate — surfaced, never dropped. */\nexport interface VetoedFact {\n candidate: FactCandidate\n vetoedBy?: string\n reason?: string\n}\n\n/** @experimental */\nexport interface ResearchLoopResult {\n /** Facts that passed the fail-closed gate — safe to write to the KB. */\n accepted: FactCandidate[]\n /** Facts the gate vetoed in the final round — escalate, do not silently drop. */\n vetoed: VetoedFact[]\n /** Research rounds actually run. */\n rounds: number\n}\n\n/** @experimental Options for the default `research` runner. */\nexport interface ResearchLoopRunnerOptions {\n /**\n * The research engine (the consumer's web/doc searcher + extractor). Called\n * each round with the prior round's vetoes so it can re-research the gaps.\n * Returns fact candidates carrying their grounding (`verbatimPassage` +\n * `sourceText`).\n */\n research: (round: number, vetoed: VetoedFact[]) => Promise<FactCandidate[]>\n /** Gate config (extra judges, self-artifact kinds, …). The floor is always on. */\n gate?: CreateKbGateOptions\n /** Max research rounds (correct-on-veto remediation). Default 1. */\n maxRounds?: number\n}\n\n/**\n * @experimental `research` mode — research-in-a-loop with valid-only KB growth.\n *\n * Each round: research → gate every candidate (fail-closed; passage MUST be in\n * the source) → accept the clean ones → re-research the vetoed ones next round,\n * up to `maxRounds`. Vetoed facts in the final round are RETURNED (escalate,\n * never silently dropped) so the caller audits vs retries.\n */\nexport function researchLoopRunner(\n o: ResearchLoopRunnerOptions,\n): DelegatedLoopRunner<ResearchLoopResult> {\n const gate = createKbGate(o.gate)\n const maxRounds = Math.max(1, Math.trunc(o.maxRounds ?? 1))\n return async (signal) => {\n const accepted: FactCandidate[] = []\n let vetoed: VetoedFact[] = []\n let rounds = 0\n for (let round = 0; round < maxRounds; round += 1) {\n if (signal.aborted) break\n rounds += 1\n const candidates = await o.research(round, vetoed)\n if (candidates.length === 0) break\n vetoed = []\n for (const c of candidates) {\n const v = await gate(c)\n if (v.accepted) accepted.push(c)\n else vetoed.push({ candidate: c, vetoedBy: v.vetoedBy, reason: v.reason })\n }\n if (vetoed.length === 0) break\n }\n return { accepted, vetoed, rounds }\n }\n}\n\n/** @experimental `self-improve` mode — agent-eval's one-call closed loop (held-out gated). */\nexport function selfImproveLoopRunner<TScenario extends Scenario, TArtifact>(\n options: SelfImproveOptions<TScenario, TArtifact>,\n): DelegatedLoopRunner<SelfImproveResult<TScenario, TArtifact>> {\n return async () => selfImprove<TScenario, TArtifact>(options)\n}\n\n/** @experimental `audit` mode — analyst loop over captured trace/run data. */\nexport function auditLoopRunner<TProposal = unknown, TEdit = unknown>(\n options: RunAnalystLoopOpts,\n): DelegatedLoopRunner<RunAnalystLoopResult<TProposal, TEdit>> {\n return async () => runAnalystLoop<TProposal, TEdit>(options)\n}\n","#!/usr/bin/env node\n/**\n * @experimental\n *\n * `agent-runtime-loop` — the schedulable entrypoint for the configured\n * delegated loop-runner. A cron job / routine / Makefile target invokes:\n *\n * agent-runtime-loop --mode research --config ./loops.config.js\n *\n * The config module wires the registry (with full access to env / creds —\n * which is why the deps live there, not in this generic bin). It must default-\n * export a `DelegatedLoopRegistry`, or a `() => DelegatedLoopRegistry | Promise<…>`.\n * The bin runs the selected mode, prints the `DelegatedLoopResult` as JSON, and\n * exits 0 on `ok`, 1 on a recorded failure, 2 on a usage/config error.\n */\n\nimport {\n DELEGATED_LOOP_MODES,\n type DelegatedLoopMode,\n type DelegatedLoopRegistry,\n type DelegatedLoopResult,\n isDelegatedLoopMode,\n runDelegatedLoop,\n} from './loop-runner'\n\n/** @experimental Parsed CLI invocation. */\nexport interface LoopRunnerCliArgs {\n mode: string\n /** Loads the registry — the bin wires this from `--config`; tests inject a stub. */\n loadRegistry: () => Promise<DelegatedLoopRegistry> | DelegatedLoopRegistry\n now?: () => number\n}\n\n/** @experimental */\nexport interface LoopRunnerCliResult {\n exitCode: number\n result?: DelegatedLoopResult\n error?: string\n}\n\n/**\n * @experimental\n *\n * Pure CLI core (no process / argv / IO) so it's unit-testable: validate the\n * mode, load the registry, dispatch, map to an exit code (0 ok / 1 failed /\n * 2 usage). Exported for embedding in custom runners + tests.\n */\nexport async function runLoopRunnerCli(args: LoopRunnerCliArgs): Promise<LoopRunnerCliResult> {\n if (!isDelegatedLoopMode(args.mode)) {\n return {\n exitCode: 2,\n error: `unknown mode '${args.mode}' (expected one of: ${DELEGATED_LOOP_MODES.join(', ')})`,\n }\n }\n let registry: DelegatedLoopRegistry\n try {\n registry = await args.loadRegistry()\n } catch (err) {\n return { exitCode: 2, error: `failed to load registry: ${errMsg(err)}` }\n }\n if (!registry[args.mode]) {\n return {\n exitCode: 2,\n error: `config registers no runner for mode '${args.mode}' (registered: ${\n Object.keys(registry).join(', ') || 'none'\n })`,\n }\n }\n // runDelegatedLoop throws only on a missing runner (guarded above); a failing\n // engine is captured as { ok: false } → exit 1, not a crash.\n const result = await runDelegatedLoop(args.mode as DelegatedLoopMode, registry, {\n ...(args.now ? { now: args.now } : {}),\n })\n return { exitCode: result.ok ? 0 : 1, result }\n}\n\n/** Parse `--mode X --config Y` from an argv tail (`process.argv.slice(2)`). */\nexport function parseLoopRunnerArgv(argv: string[]): { mode?: string; config?: string } {\n const out: { mode?: string; config?: string } = {}\n for (let i = 0; i < argv.length; i += 1) {\n const a = argv[i]\n if (a === '--mode') out.mode = argv[++i]\n else if (a === '--config') out.config = argv[++i]\n else if (a?.startsWith('--mode=')) out.mode = a.slice('--mode='.length)\n else if (a?.startsWith('--config=')) out.config = a.slice('--config='.length)\n }\n return out\n}\n\n/** Normalize a config module's default export → a registry. */\nfunction resolveRegistry(mod: unknown): DelegatedLoopRegistry {\n const def = (mod as { default?: unknown })?.default ?? mod\n const value = typeof def === 'function' ? (def as () => unknown)() : def\n return value as DelegatedLoopRegistry\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err)\n}\n\n/** The argv → IO → exit shell. Kept thin; logic lives in `runLoopRunnerCli`. */\nasync function main(): Promise<void> {\n const { mode, config } = parseLoopRunnerArgv(process.argv.slice(2))\n if (!mode || !config) {\n process.stderr.write(\n 'usage: agent-runtime-loop --mode <mode> --config <module>\\n' +\n ` modes: ${DELEGATED_LOOP_MODES.join(' | ')}\\n` +\n ' config: a JS/TS module default-exporting a DelegatedLoopRegistry (or a factory)\\n',\n )\n process.exit(2)\n }\n const { pathToFileURL } = await import('node:url')\n const { resolve } = await import('node:path')\n const cli = await runLoopRunnerCli({\n mode,\n loadRegistry: async () => resolveRegistry(await import(pathToFileURL(resolve(config)).href)),\n })\n process.stdout.write(`${JSON.stringify(cli.result ?? { error: cli.error }, null, 2)}\\n`)\n if (cli.error) process.stderr.write(`${cli.error}\\n`)\n process.exit(cli.exitCode)\n}\n\n// Run only when executed as the bin — never when imported for the testable\n// core, and never when bundled into a runtime that has no `process.argv`\n// (e.g. Cloudflare Workers, where `process` is a shim without `argv`). Reading\n// `process.argv[1]` directly would throw at module load there; `process.argv?.`\n// keeps the guard a no-op instead of crashing the Worker on startup.\nconst invokedScript = typeof process !== 'undefined' ? process.argv?.[1] : undefined\nif (invokedScript && /loop-runner-bin\\.(js|ts|mjs)$/.test(invokedScript)) {\n void main()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA;AAAA,EAGE;AAAA,OACK;AA2BA,IAAM,uBAAuB,CAAC,QAAQ,UAAU,YAAY,SAAS,cAAc;AAMnF,SAAS,oBAAoB,OAA4C;AAC9E,SAAO,OAAO,UAAU,YAAa,qBAA2C,SAAS,KAAK;AAChG;AAmCA,eAAsB,iBACpB,MACA,UACA,UAAmC,CAAC,GACH;AACjC,QAAM,SAAS,SAAS,IAAI;AAC5B,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR,oDAAoD,IAAI,kBACtD,OAAO,KAAK,QAAQ,EAAE,KAAK,IAAI,KAAK,MACtC;AAAA,IACF;AAAA,EACF;AACA,QAAM,MAAM,QAAQ,OAAO,KAAK;AAChC,QAAM,SAAS,QAAQ,UAAU,IAAI,gBAAgB,EAAE;AACvD,QAAM,QAAQ,IAAI;AAClB,MAAI;AACF,UAAM,SAAS,MAAM,OAAO,MAAM;AAClC,WAAO,EAAE,MAAM,IAAI,MAAM,QAAQ,YAAY,IAAI,IAAI,MAAM;AAAA,EAC7D,SAAS,KAAK;AACZ,WAAO;AAAA,MACL;AAAA,MACA,IAAI;AAAA,MACJ,OAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,MACtD,YAAY,IAAI,IAAI;AAAA,IACtB;AAAA,EACF;AACF;AAmBO,SAAS,gBAAgB,SAAmE;AACjG,QAAM,WAAW,wBAAwB;AAAA,IACvC,eAAe,QAAQ;AAAA,IACvB,GAAI,QA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