@tangle-network/agent-runtime 0.82.0 → 0.84.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 (88) hide show
  1. package/README.md +4 -0
  2. package/dist/agent.d.ts +5 -3
  3. package/dist/agent.js +7 -7
  4. package/dist/agent.js.map +1 -1
  5. package/dist/analyst-loop.d.ts +3 -2
  6. package/dist/analyst-loop.js +2 -2
  7. package/dist/{chunk-A7LZR5DT.js → chunk-4WXGK6GV.js} +2 -2
  8. package/dist/chunk-4WXGK6GV.js.map +1 -0
  9. package/dist/{chunk-UZ5SODU7.js → chunk-5IBQAPVB.js} +1 -1
  10. package/dist/chunk-5IBQAPVB.js.map +1 -0
  11. package/dist/{chunk-5JAUQZQA.js → chunk-7LO5GMAO.js} +1 -1
  12. package/dist/chunk-7LO5GMAO.js.map +1 -0
  13. package/dist/{chunk-H7IBHAFT.js → chunk-BZF3KQ6G.js} +1 -1
  14. package/dist/chunk-BZF3KQ6G.js.map +1 -0
  15. package/dist/{chunk-WIR4HOOJ.js → chunk-DPEUKJRO.js} +1 -1
  16. package/dist/chunk-DPEUKJRO.js.map +1 -0
  17. package/dist/{chunk-DJQFJEOD.js → chunk-G7HQI6DB.js} +2 -2
  18. package/dist/chunk-G7HQI6DB.js.map +1 -0
  19. package/dist/{chunk-GRAGM4MC.js → chunk-NURIQBJQ.js} +1 -1
  20. package/dist/chunk-NURIQBJQ.js.map +1 -0
  21. package/dist/{chunk-FNMGYYSS.js → chunk-SGKPNBXE.js} +1 -1
  22. package/dist/chunk-SGKPNBXE.js.map +1 -0
  23. package/dist/{chunk-SRGV56W4.js → chunk-UD4BHQMI.js} +2 -2
  24. package/dist/{chunk-SRGV56W4.js.map → chunk-UD4BHQMI.js.map} +1 -1
  25. package/dist/{chunk-JYURIKPF.js → chunk-UJW6EVNY.js} +503 -218
  26. package/dist/chunk-UJW6EVNY.js.map +1 -0
  27. package/dist/{chunk-LWGVVP2C.js → chunk-VNOOH22O.js} +2 -2
  28. package/dist/chunk-VNOOH22O.js.map +1 -0
  29. package/dist/{chunk-KSGHI53L.js → chunk-XBSWWF6A.js} +6 -6
  30. package/dist/chunk-XBSWWF6A.js.map +1 -0
  31. package/dist/{chunk-CO2KBPRE.js → chunk-XN5TIJGP.js} +1011 -1011
  32. package/dist/chunk-XN5TIJGP.js.map +1 -0
  33. package/dist/{chunk-NBV35BR6.js → chunk-YEJR7IXO.js} +1 -1
  34. package/dist/chunk-YEJR7IXO.js.map +1 -0
  35. package/dist/{chunk-C2FZ6GR6.js → chunk-YPA5MLVE.js} +2 -2
  36. package/dist/chunk-YPA5MLVE.js.map +1 -0
  37. package/dist/{coordination-BI9tpcmF.d.ts → coordination-CuDLO8wj.d.ts} +53 -32
  38. package/dist/environment-provider.d.ts +2 -2
  39. package/dist/environment-provider.js +1 -1
  40. package/dist/{improvement-adapter-CioiEE2z.d.ts → improvement-adapter-CDR8QNVM.d.ts} +3 -0
  41. package/dist/index.d.ts +163 -49
  42. package/dist/index.js +43 -13
  43. package/dist/index.js.map +1 -1
  44. package/dist/intelligence.d.ts +14 -8
  45. package/dist/intelligence.js +1 -1
  46. package/dist/intelligence.js.map +1 -1
  47. package/dist/{kb-gate-CuzMYGYM.d.ts → kb-gate-CwHO0vz6.d.ts} +4 -2
  48. package/dist/lifecycle.d.ts +2 -2
  49. package/dist/lifecycle.js +3 -3
  50. package/dist/{local-harness-DU7yV6mG.d.ts → local-harness-sI0S_XNA.d.ts} +2 -1
  51. package/dist/{loop-runner-bin-CBkLsyFg.d.ts → loop-runner-bin-hQDUL8Ld.d.ts} +28 -13
  52. package/dist/loop-runner-bin.d.ts +7 -7
  53. package/dist/loop-runner-bin.js +10 -10
  54. package/dist/loops.d.ts +257 -48
  55. package/dist/loops.js +9 -7
  56. package/dist/mcp/bin.js +8 -8
  57. package/dist/mcp/bin.js.map +1 -1
  58. package/dist/mcp/index.d.ts +44 -38
  59. package/dist/mcp/index.js +11 -11
  60. package/dist/mcp/index.js.map +1 -1
  61. package/dist/{mcp-serve-verifier-BvMAV_8U.d.ts → mcp-serve-verifier-FL7-ZEb_.d.ts} +8 -3
  62. package/dist/{openai-tools-B-3v06BE.d.ts → openai-tools-BnrOmGjN.d.ts} +7 -4
  63. package/dist/platform.d.ts +4 -0
  64. package/dist/platform.js.map +1 -1
  65. package/dist/profiles.d.ts +36 -23
  66. package/dist/profiles.js +2 -2
  67. package/dist/profiles.js.map +1 -1
  68. package/dist/{router-client-D6Ocf4jG.d.ts → router-client-r8y_VFVM.d.ts} +1 -0
  69. package/dist/{substrate-rNj6TDc3.d.ts → substrate-DO2GHNg2.d.ts} +5 -3
  70. package/dist/{types-By9LXllv.d.ts → types-Driepl87.d.ts} +3 -2
  71. package/dist/{types-BF-MEsQB.d.ts → types-ESeMOj94.d.ts} +26 -11
  72. package/dist/{worktree-fanout-D9Z2dMS9.d.ts → worktree-fanout-D6xR2CIA.d.ts} +16 -10
  73. package/dist/{worktree-harness-Dx8XULW3.d.ts → worktree-harness-CX_McRLp.d.ts} +11 -8
  74. package/package.json +3 -3
  75. package/dist/chunk-5JAUQZQA.js.map +0 -1
  76. package/dist/chunk-A7LZR5DT.js.map +0 -1
  77. package/dist/chunk-C2FZ6GR6.js.map +0 -1
  78. package/dist/chunk-CO2KBPRE.js.map +0 -1
  79. package/dist/chunk-DJQFJEOD.js.map +0 -1
  80. package/dist/chunk-FNMGYYSS.js.map +0 -1
  81. package/dist/chunk-GRAGM4MC.js.map +0 -1
  82. package/dist/chunk-H7IBHAFT.js.map +0 -1
  83. package/dist/chunk-JYURIKPF.js.map +0 -1
  84. package/dist/chunk-KSGHI53L.js.map +0 -1
  85. package/dist/chunk-LWGVVP2C.js.map +0 -1
  86. package/dist/chunk-NBV35BR6.js.map +0 -1
  87. package/dist/chunk-UZ5SODU7.js.map +0 -1
  88. package/dist/chunk-WIR4HOOJ.js.map +0 -1
@@ -65,4 +65,4 @@ export {
65
65
  NotFoundError,
66
66
  ValidationError
67
67
  };
68
- //# sourceMappingURL=chunk-NBV35BR6.js.map
68
+ //# sourceMappingURL=chunk-YEJR7IXO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/**\n *\n * Error taxonomy for `@tangle-network/agent-runtime`.\n *\n * Public contract: every error this package throws as part of its consumer-\n * facing API either extends `AgentEvalError` (re-exported here for ergonomic\n * `instanceof` checks at the runtime boundary) or extends one of the\n * runtime-specific subclasses below.\n *\n * Internal invariant guards (`throw new Error('this should never happen')`)\n * remain plain `Error` — they are programmer-mistake assertions, not\n * consumer-catchable contract failures.\n *\n * Subclassing strategy: where a runtime-specific failure maps cleanly to an\n * agent-eval code (validation, config, not_found), we re-use the agent-eval\n * subclass. Runtime-only failure modes (session resume against the wrong\n * backend, backend transport errors) get fresh subclasses that still carry an\n * `AgentEvalErrorCode` so cross-package handlers can pattern-match without\n * importing the runtime.\n *\n * @stable\n */\n\nimport { AgentEvalError } from '@tangle-network/agent-eval'\n\nexport {\n AgentEvalError,\n type AgentEvalErrorCode,\n ConfigError,\n JudgeError,\n NotFoundError,\n ValidationError,\n} from '@tangle-network/agent-eval'\n\n/**\n *\n * Caller asked to resume a session against a backend whose `kind` does not\n * match the session's recorded backend. This is a routing bug — the same\n * session id was reused across two different backend implementations — and\n * is not retryable without picking the right backend.\n *\n * @stable\n */\nexport class SessionMismatchError extends AgentEvalError {\n readonly sessionBackend: string\n readonly requestedBackend: string\n\n constructor(sessionBackend: string, requestedBackend: string, options?: { cause?: unknown }) {\n super(\n 'validation',\n `Cannot resume ${sessionBackend} session with ${requestedBackend} backend`,\n options,\n )\n this.sessionBackend = sessionBackend\n this.requestedBackend = requestedBackend\n }\n}\n\n/**\n *\n * A backend transport call (HTTP, gRPC, sidecar IPC) failed with a non-success\n * status. Distinct from `JudgeError` (which is structural / unrecoverable)\n * because backend failures are sometimes retryable and consumers may want to\n * branch on the upstream status code.\n *\n * @stable\n */\nexport class BackendTransportError extends AgentEvalError {\n readonly backend: string\n readonly status?: number\n /**\n * Truncated upstream response body (≤2 KiB) when available. Diagnostic\n * only — surfaces in `backend_error.error.body` and `final.error.body`\n * so operators can see \"free_tier_limit\", \"invalid_api_key\", etc. without\n * cracking the log line open.\n */\n readonly body?: string\n\n constructor(\n backend: string,\n message: string,\n options?: { cause?: unknown; status?: number; body?: string },\n ) {\n super('config', message, options)\n this.backend = backend\n this.status = options?.status\n this.body = options?.body\n }\n}\n\n/**\n *\n * A runtime-run lifecycle method was called in an order the state machine does\n * not allow: `persist()` before `complete()`, `complete()` twice, etc.\n *\n * @stable\n */\nexport class RuntimeRunStateError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n *\n * The dynamic-loop planner returned an unusable topology move — the LLM emitted\n * no parseable envelope, an unknown `kind`, or a structurally-invalid move\n * (e.g. a fanout with zero tasks). This is a structural failure of the\n * agent-authored topology, not a config mistake: the planner ran but its output\n * cannot drive the kernel. Carries `validation` so cross-package handlers can\n * pattern-match without importing the runtime. Fail loud — never substitute a\n * default move, or the loop silently runs a topology nobody chose.\n *\n * @stable\n */\nexport class PlannerError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n * The analyst loop could not read or run over a round's trace — e.g. an empty round\n * (no iterations to analyze) or a malformed trace projection. Fail loud: a silent empty\n * store would mask a broken capture path and the driver would steer on nothing.\n */\nexport class AnalystError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n"],"mappings":";AAuBA,SAAS,sBAAsB;AAE/B;AAAA,EACE,kBAAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,IAAM,uBAAN,cAAmC,eAAe;AAAA,EAC9C;AAAA,EACA;AAAA,EAET,YAAY,gBAAwB,kBAA0B,SAA+B;AAC3F;AAAA,MACE;AAAA,MACA,iBAAiB,cAAc,iBAAiB,gBAAgB;AAAA,MAChE;AAAA,IACF;AACA,SAAK,iBAAiB;AACtB,SAAK,mBAAmB;AAAA,EAC1B;AACF;AAWO,IAAM,wBAAN,cAAoC,eAAe;AAAA,EAC/C;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA;AAAA,EAET,YACE,SACA,SACA,SACA;AACA,UAAM,UAAU,SAAS,OAAO;AAChC,SAAK,UAAU;AACf,SAAK,SAAS,SAAS;AACvB,SAAK,OAAO,SAAS;AAAA,EACvB;AACF;AASO,IAAM,uBAAN,cAAmC,eAAe;AAAA,EACvD,YAAY,SAAiB,SAA+B;AAC1D,UAAM,cAAc,SAAS,OAAO;AAAA,EACtC;AACF;AAcO,IAAM,eAAN,cAA2B,eAAe;AAAA,EAC/C,YAAY,SAAiB,SAA+B;AAC1D,UAAM,cAAc,SAAS,OAAO;AAAA,EACtC;AACF;AAOO,IAAM,eAAN,cAA2B,eAAe;AAAA,EAC/C,YAAY,SAAiB,SAA+B;AAC1D,UAAM,cAAc,SAAS,OAAO;AAAA,EACtC;AACF;","names":["AgentEvalError"]}
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-4J6RBI3K.js";
4
4
  import {
5
5
  AnalystError
6
- } from "./chunk-NBV35BR6.js";
6
+ } from "./chunk-YEJR7IXO.js";
7
7
 
8
8
  // src/analyst-loop/iterations-to-trace-store.ts
9
9
  import {
@@ -579,4 +579,4 @@ export {
579
579
  iterationsToTraceStore,
580
580
  runAnalystLoop
581
581
  };
582
- //# sourceMappingURL=chunk-C2FZ6GR6.js.map
582
+ //# sourceMappingURL=chunk-YPA5MLVE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/analyst-loop/iterations-to-trace-store.ts","../src/analyst-loop/run-analyst-loop.ts"],"sourcesContent":["/**\n *\n * The read seam that closes the autonomous loop: project a round's `Iteration[]`\n * (each carrying its raw `SandboxEvent[]`) into an in-memory `TraceAnalysisStore`, the\n * read interface the trace analysts query. `runAnalystLoop` has had zero consumers\n * because nothing turned a loop's iterations into a store — this is that bridge.\n *\n * One iteration → one trace. The iteration is the root AGENT span; each `SandboxEvent`\n * becomes a child span (LLM for llm_call events, TOOL for tool events, else SPAN), so an\n * analyst can walk a shot's trace, cluster its errors, and emit findings the driver\n * steers on. Projection is best-effort over the FLAT SandboxEvent shape (no per-event\n * lineage yet — that's the richer-trace gap); it never fabricates — an errored iteration\n * surfaces a real ERROR span carrying the real message.\n *\n * @experimental\n */\n\nimport {\n type DatasetOverview,\n DEFAULT_TRACE_ANALYST_BUDGETS,\n type QueryTracesPage,\n type SearchSpanResult,\n type SearchTraceResult,\n type SpanMatchRecord,\n TRACE_ANALYST_TRUNCATION_MARKER_PREFIX,\n type TraceAnalysisStore,\n type TraceAnalystByteBudgets,\n type TraceAnalystFilters,\n type TraceAnalystSpan,\n type TraceAnalystSpanKind,\n type TraceAnalystTraceSummary,\n type ViewSpansResult,\n type ViewTraceResult,\n} from '@tangle-network/agent-eval'\nimport type { SandboxEvent } from '@tangle-network/sandbox'\nimport { AnalystError } from '../errors'\nimport { extractLlmCallEvent } from '../runtime/sandbox-events'\nimport type { Iteration } from '../runtime/types'\n\n/** ErrorCluster isn't re-exported from the agent-eval root; derive it from the overview. */\ntype ErrorCluster = DatasetOverview['error_clusters'][number]\n\ninterface ProjectedTrace {\n summary: TraceAnalystTraceSummary\n spans: TraceAnalystSpan[]\n /** raw JSONL bytes of this trace's spans — the byte-budget accounting unit. */\n rawBytes: number\n}\n\nconst bytesOf = (v: unknown): number => Buffer.byteLength(JSON.stringify(v) ?? '', 'utf8')\nconst iso = (ms: number): string => new Date(ms).toISOString()\n\n/** Normalize volatile tokens out of a status message so semantically identical failures\n * collapse to one signature (digits, hex/uuids, paths, durations → placeholders). */\nfunction normalizeSignature(message: string): string {\n return message\n .replace(/0x[0-9a-fA-F]+/g, 'HEX')\n .replace(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g, 'UUID')\n .replace(/(\\/[\\w.-]+){2,}/g, 'PATH')\n .replace(/\\b\\d+(\\.\\d+)?(ms|s|m|h)\\b/g, 'DUR')\n .replace(/\\b\\d+\\b/g, '#')\n .replace(/\\s+/g, ' ')\n .trim()\n .slice(0, 200)\n}\n\nfunction spanKindFor(\n event: SandboxEvent,\n agentRunName: string,\n): {\n kind: TraceAnalystSpanKind\n model: string | null\n tool: string | null\n} {\n const llm = extractLlmCallEvent(event, agentRunName)\n if (llm) return { kind: 'LLM', model: llm.model ?? null, tool: null }\n const type = String(event?.type ?? '')\n if (/tool/i.test(type)) {\n const d = event?.data as { name?: unknown; tool?: unknown } | undefined\n const tool = typeof d?.name === 'string' ? d.name : typeof d?.tool === 'string' ? d.tool : type\n return { kind: 'TOOL', model: null, tool }\n }\n return { kind: 'SPAN', model: null, tool: null }\n}\n\nfunction errorMessageOf(event: SandboxEvent): string | undefined {\n const type = String(event?.type ?? '')\n const d = event?.data as { error?: unknown; message?: unknown } | undefined\n if (/error|fail/i.test(type) || d?.error) {\n const m = d?.error ?? d?.message\n return typeof m === 'string' ? m : `${type} error`\n }\n return undefined\n}\n\n/** Project one iteration → one trace: root AGENT span + a child span per event. */\nfunction projectIteration<Task, Output>(iter: Iteration<Task, Output>): ProjectedTrace {\n const traceId =\n (\n iter.events.find((e) => (e?.data as { sandboxId?: string } | undefined)?.sandboxId)?.data as\n | { sandboxId?: string }\n | undefined\n )?.sandboxId ?? `iter-${iter.index}`\n const start = iso(iter.startedAt)\n const end = iso(iter.endedAt || iter.startedAt)\n const durationMs = Math.max(0, (iter.endedAt || iter.startedAt) - iter.startedAt)\n const rootId = `${traceId}:root`\n const iterErrored = Boolean(iter.error) || iter.verdict?.valid === false\n const spans: TraceAnalystSpan[] = [\n {\n trace_id: traceId,\n span_id: rootId,\n parent_span_id: null,\n name: iter.agentRunName,\n kind: 'AGENT',\n start_time: start,\n end_time: end,\n duration_ms: durationMs,\n status: iter.error ? 'ERROR' : 'OK',\n status_message: iter.error?.message,\n service_name: 'agent-runtime',\n agent_name: iter.agentRunName,\n model_name: null,\n tool_name: null,\n attributes: {\n 'iteration.index': iter.index,\n 'verdict.valid': iter.verdict?.valid,\n 'verdict.score': iter.verdict?.score,\n 'output.preview':\n iter.output === undefined ? undefined : String(iter.output).slice(0, 2000),\n },\n },\n ]\n const models = new Set<string>()\n const tools = new Set<string>()\n iter.events.forEach((event, i) => {\n const { kind, model, tool } = spanKindFor(event, iter.agentRunName)\n if (model) models.add(model)\n if (tool) tools.add(tool)\n const errMsg = errorMessageOf(event)\n spans.push({\n trace_id: traceId,\n span_id: `${traceId}:e${i}`,\n parent_span_id: rootId,\n name: String(event?.type ?? 'event'),\n kind,\n start_time: start,\n end_time: end,\n duration_ms: 0,\n status: errMsg ? 'ERROR' : 'OK',\n status_message: errMsg,\n service_name: 'agent-runtime',\n agent_name: iter.agentRunName,\n model_name: model,\n tool_name: tool,\n attributes: (event?.data as Record<string, unknown> | undefined) ?? {},\n })\n })\n const hasErrors = spans.some((s) => s.status === 'ERROR') || iterErrored\n const summary: TraceAnalystTraceSummary = {\n trace_id: traceId,\n service_name: 'agent-runtime',\n agent_name: iter.agentRunName,\n span_count: spans.length,\n has_errors: hasErrors,\n start_time: start,\n end_time: end,\n duration_ms: durationMs,\n raw_jsonl_bytes: bytesOf(spans),\n models: [...models],\n tools: [...tools],\n }\n return { summary, spans, rawBytes: summary.raw_jsonl_bytes }\n}\n\nfunction matchesFilters(t: ProjectedTrace, f?: TraceAnalystFilters): boolean {\n if (!f) return true\n if (f.has_errors !== undefined && t.summary.has_errors !== f.has_errors) return false\n if (f.service_names?.length && !f.service_names.includes(t.summary.service_name ?? ''))\n return false\n if (f.agent_names?.length && !f.agent_names.includes(t.summary.agent_name ?? '')) return false\n if (f.model_names?.length && !f.model_names.some((m) => t.summary.models.includes(m)))\n return false\n if (f.tool_names?.length && !f.tool_names.some((tn) => t.summary.tools.includes(tn))) return false\n if (f.start_time_after && t.summary.start_time < f.start_time_after) return false\n if (f.start_time_before && t.summary.start_time > f.start_time_before) return false\n if (f.regex_pattern && !new RegExp(f.regex_pattern).test(JSON.stringify(t.spans))) return false\n return true\n}\n\nfunction capAttributes(\n attributes: Record<string, unknown>,\n perAttrCap: number,\n): { capped: Record<string, unknown>; truncated: number } {\n let truncated = 0\n const capped: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(attributes)) {\n const s = typeof v === 'string' ? v : JSON.stringify(v)\n if (typeof s === 'string' && s.length > perAttrCap) {\n truncated += 1\n capped[k] = `${TRACE_ANALYST_TRUNCATION_MARKER_PREFIX} ${s.length}b]${s.slice(0, perAttrCap)}`\n } else {\n capped[k] = v\n }\n }\n return { capped, truncated }\n}\n\n/**\n * Build an in-memory `TraceAnalysisStore` over a loop round's iterations. Fail-loud on an\n * empty round — there is nothing for an analyst to read, and a silent empty store would\n * mask a broken capture path.\n */\nexport function iterationsToTraceStore<Task, Output>(\n iterations: ReadonlyArray<Iteration<Task, Output>>,\n budgets: TraceAnalystByteBudgets = DEFAULT_TRACE_ANALYST_BUDGETS,\n): TraceAnalysisStore {\n if (iterations.length === 0) {\n throw new AnalystError('iterationsToTraceStore: no iterations to analyze (empty round)')\n }\n const traces = iterations.map((it) => projectIteration(it))\n const byId = new Map(traces.map((t) => [t.summary.trace_id, t]))\n\n const buildClusters = (set: ProjectedTrace[]): ErrorCluster[] => {\n const map = new Map<string, ErrorCluster>()\n for (const t of set) {\n for (const s of t.spans) {\n if (s.status !== 'ERROR' || !s.status_message) continue\n const sig = normalizeSignature(s.status_message)\n const c = map.get(sig) ?? {\n signature: sig,\n status_message_sample: s.status_message,\n span_name: s.name,\n tool_name: s.tool_name,\n trace_count: 0,\n span_count: 0,\n prevalence: 0,\n exemplar_trace_ids: [],\n exemplar_span_ids: [],\n }\n c.span_count += 1\n if (\n !c.exemplar_trace_ids.includes(t.summary.trace_id) &&\n c.exemplar_trace_ids.length < 10\n ) {\n c.exemplar_trace_ids.push(t.summary.trace_id)\n c.trace_count += 1\n }\n if (c.exemplar_span_ids.length < 10) c.exemplar_span_ids.push(s.span_id)\n map.set(sig, c)\n }\n }\n const errorTraces = set.filter((t) => t.summary.has_errors).length || 1\n const clusters = [...map.values()].map((c) => ({\n ...c,\n prevalence: c.trace_count / errorTraces,\n }))\n return clusters.sort((a, b) => b.trace_count - a.trace_count)\n }\n\n return {\n async getOverview(filters?: TraceAnalystFilters): Promise<DatasetOverview> {\n const set = traces.filter((t) => matchesFilters(t, filters))\n const services = new Set<string>()\n const agents = new Set<string>()\n const models = new Set<string>()\n const tools = new Set<string>()\n let errorSpans = 0\n for (const t of set) {\n if (t.summary.service_name) services.add(t.summary.service_name)\n if (t.summary.agent_name) agents.add(t.summary.agent_name)\n for (const m of t.summary.models) models.add(m)\n for (const tn of t.summary.tools) tools.add(tn)\n errorSpans += t.spans.filter((s) => s.status === 'ERROR').length\n }\n const times = set.map((t) => t.summary.start_time).sort()\n return {\n total_traces: set.length,\n raw_jsonl_bytes: set.reduce((n, t) => n + t.rawBytes, 0),\n services: [...services],\n agents: [...agents],\n models: [...models],\n tool_names: [...tools],\n sample_trace_ids: set.slice(0, 20).map((t) => t.summary.trace_id),\n errors: {\n trace_count: set.filter((t) => t.summary.has_errors).length,\n span_count: errorSpans,\n },\n error_clusters: buildClusters(set),\n time_range: times.length ? { earliest: times[0]!, latest: times[times.length - 1]! } : null,\n }\n },\n\n async queryTraces(opts): Promise<QueryTracesPage> {\n const set = traces.filter((t) => matchesFilters(t, opts.filters))\n const offset = opts.offset ?? 0\n const page = set.slice(offset, offset + opts.limit)\n return {\n traces: page.map((t) => t.summary),\n total: set.length,\n has_more: offset + opts.limit < set.length,\n }\n },\n\n async countTraces(filters?: TraceAnalystFilters): Promise<number> {\n return traces.filter((t) => matchesFilters(t, filters)).length\n },\n\n async viewTrace(opts): Promise<ViewTraceResult> {\n const t = byId.get(opts.trace_id)\n if (!t) return { trace_id: opts.trace_id, spans: [] }\n const cap = opts.per_attribute_byte_cap ?? budgets.perAttributeViewBudget\n const projected = t.spans.map((s) => ({\n ...s,\n attributes: capAttributes(s.attributes, cap).capped,\n }))\n if (bytesOf(projected) > budgets.perCallByteCeiling) {\n const names = new Map<string, number>()\n for (const s of t.spans) names.set(s.name, (names.get(s.name) ?? 0) + 1)\n return {\n trace_id: opts.trace_id,\n oversized: {\n span_count: t.spans.length,\n top_span_names: [...names.entries()].sort((a, b) => b[1] - a[1]).slice(0, 20),\n span_response_bytes_max: Math.max(...t.spans.map((s) => bytesOf(s))),\n error_span_count: t.spans.filter((s) => s.status === 'ERROR').length,\n },\n }\n }\n return { trace_id: opts.trace_id, spans: projected }\n },\n\n async viewSpans(opts): Promise<ViewSpansResult> {\n const t = byId.get(opts.trace_id)\n const cap = opts.per_attribute_byte_cap ?? budgets.perAttributeSpanBudget\n const want = new Set(opts.span_ids)\n const found = (t?.spans ?? []).filter((s) => want.has(s.span_id))\n let truncated = 0\n const spans = found.map((s) => {\n const { capped, truncated: n } = capAttributes(s.attributes, cap)\n truncated += n\n return { ...s, attributes: capped }\n })\n const foundIds = new Set(found.map((s) => s.span_id))\n return {\n trace_id: opts.trace_id,\n spans,\n missing_span_ids: opts.span_ids.filter((id) => !foundIds.has(id)),\n truncated_attribute_count: truncated,\n }\n },\n\n async searchTrace(opts): Promise<SearchTraceResult> {\n const t = byId.get(opts.trace_id)\n const max = opts.max_matches ?? 50\n const hits: SpanMatchRecord[] = []\n for (const s of t?.spans ?? []) {\n for (const hit of searchSpanAttrs(s, opts.regex_pattern, budgets.perMatchTextBudget)) {\n if (hits.length >= max) break\n hits.push(hit)\n }\n }\n return {\n trace_id: opts.trace_id,\n hits,\n total_matches: hits.length,\n has_more: hits.length >= max,\n }\n },\n\n async searchSpan(opts): Promise<SearchSpanResult> {\n const t = byId.get(opts.trace_id)\n const max = opts.max_matches ?? 50\n const span = (t?.spans ?? []).find((s) => s.span_id === opts.span_id)\n const hits = span\n ? searchSpanAttrs(span, opts.regex_pattern, budgets.perMatchTextBudget).slice(0, max)\n : []\n return {\n trace_id: opts.trace_id,\n span_id: opts.span_id,\n hits,\n total_matches: hits.length,\n has_more: false,\n }\n },\n }\n}\n\nfunction searchSpanAttrs(\n span: TraceAnalystSpan,\n pattern: string,\n textCap: number,\n): SpanMatchRecord[] {\n const re = new RegExp(pattern, 'g')\n const hits: SpanMatchRecord[] = []\n for (const [k, v] of Object.entries(span.attributes)) {\n const text = typeof v === 'string' ? v : JSON.stringify(v)\n if (typeof text !== 'string') continue\n re.lastIndex = 0\n const m = re.exec(text)\n if (!m) continue\n const at = m.index\n hits.push({\n trace_id: span.trace_id,\n span_id: span.span_id,\n span_name: span.name,\n span_kind: span.kind,\n attribute_path: `attributes.${k}`,\n matched_text: m[0].slice(0, textCap),\n context_before: text.slice(Math.max(0, at - textCap / 2), at),\n context_after: text.slice(at + m[0].length, at + m[0].length + textCap / 2),\n match_offset: at,\n })\n }\n return hits\n}\n","/**\n * `runAnalystLoop` — the one call agent apps reach for to close the\n * recursive-self-improvement loop.\n *\n * 1. Load baseline findings (last run, or the slice the caller specifies)\n * 2. Run the analyst registry with priorFindings injected\n * 3. Persist the new run's findings to the ledger\n * 4. Diff the new run against the baseline\n * 5. Hand the findings to the knowledge adapter → proposals (and\n * optionally apply them) → wiki edits\n * 6. Hand the findings to the improvement adapter → prompt / tool /\n * scaffolding edits (review-only by default)\n * 7. Return a single report the consumer renders / persists / acts on.\n *\n * Adapters are optional: the loop works as a \"run + diff + report\"\n * primitive when no adapters are wired; it closes end-to-end when\n * both adapters are wired.\n */\n\nimport type { AnalystFinding, AnalystRunResult, FindingsDiff } from '@tangle-network/agent-eval'\nimport { diffFindings } from '@tangle-network/agent-eval'\n\nimport type {\n AnalystLoopEvent,\n AnalystRegistryStreamingLike,\n ImprovementReport,\n KnowledgeReport,\n RunAnalystLoopOpts,\n RunAnalystLoopResult,\n} from './types'\n\nexport async function runAnalystLoop<TProposal = unknown, TEdit = unknown>(\n opts: RunAnalystLoopOpts,\n): Promise<RunAnalystLoopResult<TProposal, TEdit>> {\n const log = opts.log ?? defaultLog\n const strategy = opts.priorFindingsStrategy ?? 'per-kind'\n const emit = makeEmitter(opts.onEvent)\n const startedAt = Date.now()\n\n // 1. Resolve baseline + load prior findings.\n const baselineRunId = resolveBaselineRunId(opts)\n const priorAll: ReadonlyArray<AnalystFinding & { run_id: string }> = baselineRunId\n ? (opts.findingsStore?.loadRun(baselineRunId) ?? [])\n : []\n log('baseline resolved', { baselineRunId, prior_findings: priorAll.length })\n await emit({\n type: 'baseline-resolved',\n runId: opts.runId,\n baselineRunId,\n priorFindingCount: priorAll.length,\n })\n\n // 2. Run the registry. Strategy controls how analysts see priors.\n // When the registry exposes runStream, forward each event verbatim\n // so subscribers see per-analyst progress in real time.\n const priorFindings = buildPriorFindingsInput(priorAll, strategy, opts.registry.list())\n const analystResult = await runRegistry(opts, priorFindings, emit)\n log('analyst run complete', {\n findings: analystResult.findings.length,\n cost_usd: analystResult.total_cost_usd,\n per_analyst: analystResult.per_analyst.map((s) => ({\n id: s.analyst_id,\n status: s.status,\n n: s.findings_count,\n })),\n })\n\n // 3. Persist the new run before any side-effecting adapter runs so\n // the ledger is the source of truth even if an adapter throws.\n if (opts.findingsStore && analystResult.findings.length > 0) {\n await opts.findingsStore.append(opts.runId, analystResult.findings)\n await emit({\n type: 'findings-persisted',\n runId: opts.runId,\n count: analystResult.findings.length,\n })\n }\n\n // 4. Diff vs baseline.\n let diff: FindingsDiff | null = null\n if (baselineRunId && analystResult.findings.length > 0) {\n diff = diffFindings(\n priorAll.map((f) => ({ ...f })),\n analystResult.findings.map((f) => ({ ...f, run_id: opts.runId })),\n )\n log('diff vs baseline', {\n appeared: diff.appeared.length,\n disappeared: diff.disappeared.length,\n persisted: diff.persisted.length,\n changed: diff.changed.length,\n })\n await emit({\n type: 'diff-computed',\n runId: opts.runId,\n baselineRunId,\n appeared: diff.appeared.length,\n disappeared: diff.disappeared.length,\n persisted: diff.persisted.length,\n changed: diff.changed.length,\n })\n }\n\n // 5. Knowledge adapter — proposals + optional auto-apply.\n let knowledge: KnowledgeReport<TProposal> | null = null\n if (opts.knowledgeAdapter) {\n knowledge = await runKnowledgeAdapter(opts, analystResult.findings, log, emit)\n }\n\n // 6. Improvement adapter — prompt / tool / scaffolding edits.\n let improvement: ImprovementReport<TEdit> | null = null\n if (opts.improvementAdapter) {\n improvement = await runImprovementAdapter(opts, analystResult.findings, log, emit)\n }\n\n await emit({\n type: 'loop-completed',\n runId: opts.runId,\n durationMs: Date.now() - startedAt,\n })\n\n return {\n runId: opts.runId,\n baselineRunId,\n analystResult,\n diff,\n knowledge,\n improvement,\n }\n}\n\ntype Emitter = (event: AnalystLoopEvent) => Promise<void>\n\nfunction makeEmitter(onEvent: RunAnalystLoopOpts['onEvent']): Emitter {\n if (!onEvent) return async () => {}\n return async (event) => {\n await onEvent(event)\n }\n}\n\nasync function runRegistry(\n opts: RunAnalystLoopOpts,\n priorFindings: ReturnType<typeof buildPriorFindingsInput>,\n emit: Emitter,\n): Promise<AnalystRunResult> {\n const reg = opts.registry as AnalystRegistryStreamingLike\n if (typeof reg.runStream === 'function' && opts.onEvent) {\n let final: AnalystRunResult | null = null\n for await (const ev of reg.runStream(opts.runId, opts.inputs, { priorFindings })) {\n await emit({ type: 'analyst', runId: opts.runId, event: ev })\n if (ev.type === 'run-completed') final = ev.result\n }\n if (!final) {\n throw new Error('runAnalystLoop: registry.runStream ended without run-completed event')\n }\n return final\n }\n return opts.registry.run(opts.runId, opts.inputs, { priorFindings })\n}\n\nfunction resolveBaselineRunId(opts: RunAnalystLoopOpts): string | null {\n if (opts.baselineRunId === null) return null\n if (typeof opts.baselineRunId === 'string') return opts.baselineRunId\n if (!opts.findingsStore) return null\n const all = opts.findingsStore.loadAll()\n let last: string | null = null\n for (const row of all) {\n if (row.run_id === opts.runId) continue\n last = row.run_id\n }\n return last\n}\n\nfunction buildPriorFindingsInput(\n prior: ReadonlyArray<AnalystFinding & { run_id: string }>,\n strategy: 'per-kind' | 'wildcard' | 'none',\n registry: ReadonlyArray<{ id: string }>,\n): ReadonlyArray<AnalystFinding> | Record<string, ReadonlyArray<AnalystFinding>> | undefined {\n if (strategy === 'none' || prior.length === 0) return undefined\n const stripped = prior.map(({ run_id: _run_id, ...rest }) => rest as AnalystFinding)\n if (strategy === 'wildcard') {\n return { '*': stripped }\n }\n void registry\n return stripped\n}\n\nasync function runKnowledgeAdapter<TProposal>(\n opts: RunAnalystLoopOpts,\n findings: ReadonlyArray<AnalystFinding>,\n log: NonNullable<RunAnalystLoopOpts['log']>,\n emit: Emitter,\n): Promise<KnowledgeReport<TProposal>> {\n const adapter = opts.knowledgeAdapter!\n const batch = await adapter.proposeFromFindings(findings)\n log('knowledge.proposeFromFindings', {\n proposals: batch.proposals.length,\n skipped: batch.skipped,\n errors: batch.errors.length,\n })\n await emit({\n type: 'knowledge-proposed',\n runId: opts.runId,\n proposalCount: batch.proposals.length,\n skipped: batch.skipped,\n errors: batch.errors.length,\n })\n\n const auto = opts.autoApply?.knowledge ?? false\n const threshold = opts.autoApply?.knowledgeConfidenceThreshold ?? 0.85\n\n if (!auto || !adapter.apply) {\n await emit({\n type: 'knowledge-applied',\n runId: opts.runId,\n writtenCount: 0,\n withheldForReview: batch.proposals.length,\n })\n return {\n proposals: batch.proposals as TProposal[],\n applied: [],\n skipped: batch.skipped,\n errors: batch.errors,\n withheld_for_review: batch.proposals.length,\n }\n }\n\n const findingsById = new Map(findings.map((f) => [f.finding_id, f]))\n const safe: TProposal[] = []\n let withheld = 0\n for (const p of batch.proposals as Array<TProposal & { sourceFindingId?: string }>) {\n const src = p.sourceFindingId ? findingsById.get(p.sourceFindingId) : undefined\n if (!src) {\n withheld += 1\n continue\n }\n if (src.confidence < threshold) {\n withheld += 1\n continue\n }\n safe.push(p)\n }\n const result = await adapter.apply(safe)\n log('knowledge.apply', {\n applied: result.written.length,\n withheld_for_review: withheld,\n warnings: result.warnings.length,\n })\n await emit({\n type: 'knowledge-applied',\n runId: opts.runId,\n writtenCount: result.written.length,\n withheldForReview: withheld,\n })\n return {\n proposals: batch.proposals as TProposal[],\n applied: result.written,\n skipped: batch.skipped,\n errors: batch.errors,\n withheld_for_review: withheld,\n }\n}\n\nasync function runImprovementAdapter<TEdit>(\n opts: RunAnalystLoopOpts,\n findings: ReadonlyArray<AnalystFinding>,\n log: NonNullable<RunAnalystLoopOpts['log']>,\n emit: Emitter,\n): Promise<ImprovementReport<TEdit>> {\n const adapter = opts.improvementAdapter!\n const batch = await adapter.proposeFromFindings(findings)\n log('improvement.proposeFromFindings', {\n edits: batch.edits.length,\n skipped: batch.skipped,\n errors: batch.errors.length,\n })\n await emit({\n type: 'improvement-proposed',\n runId: opts.runId,\n editCount: batch.edits.length,\n skipped: batch.skipped,\n errors: batch.errors.length,\n })\n\n const auto = opts.autoApply?.improvement ?? false\n const threshold = opts.autoApply?.improvementConfidenceThreshold ?? 0.9\n\n if (!auto || !adapter.apply) {\n await emit({\n type: 'improvement-applied',\n runId: opts.runId,\n appliedCount: 0,\n withheldForReview: batch.edits.length,\n })\n return {\n edits: batch.edits as TEdit[],\n applied: [],\n skipped: batch.skipped,\n errors: batch.errors,\n withheld_for_review: batch.edits.length,\n }\n }\n\n const findingsById = new Map(findings.map((f) => [f.finding_id, f]))\n const safe: TEdit[] = []\n let withheld = 0\n for (const e of batch.edits as Array<TEdit & { sourceFindingId?: string }>) {\n const src = e.sourceFindingId ? findingsById.get(e.sourceFindingId) : undefined\n if (!src || src.confidence < threshold) {\n withheld += 1\n continue\n }\n safe.push(e)\n }\n const result = await adapter.apply(safe)\n log('improvement.apply', {\n applied: result.applied.length,\n withheld_for_review: withheld,\n warnings: result.warnings.length,\n })\n await emit({\n type: 'improvement-applied',\n runId: opts.runId,\n appliedCount: result.applied.length,\n withheldForReview: withheld,\n })\n return {\n edits: batch.edits as TEdit[],\n applied: result.applied,\n skipped: batch.skipped,\n errors: batch.errors,\n withheld_for_review: withheld,\n }\n}\n\nfunction defaultLog(ms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M;AAAA,IACN,OAAO,KAAK;AAAA,IACZ,cAAc,OAAO,QAAQ;AAAA,IAC7B,mBAAmB;AAAA,EACrB,CAAC;AACD,SAAO;AAAA,IACL,OAAO,MAAM;AAAA,IACb,SAAS,OAAO;AAAA,IAChB,SAAS,MAAM;AAAA,IACf,QAAQ,MAAM;AAAA,IACd,qBAAqB;AAAA,EACvB;AACF;AAEA,SAAS,WAAW,KAAa,QAAwC;AACvE,MAAI,OAAQ,SAAQ,IAAI,kBAAkB,GAAG,IAAI,MAAM;AAAA,MAClD,SAAQ,IAAI,kBAAkB,GAAG,EAAE;AAC1C;","names":[]}
@@ -1,18 +1,17 @@
1
- import { E as ExecutorFactory, b as ExecutorRegistry, h as Spend, c as Agent, i as Scope, d as ResultBlobStore, B as Budget } from './types-By9LXllv.js';
1
+ import { E as ExecutorFactory, b as ExecutorRegistry, h as Spend, c as Agent, i as Scope, d as ResultBlobStore, B as Budget } from './types-Driepl87.js';
2
2
  import { AgentProfile } from '@tangle-network/agent-interface';
3
- import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-rNj6TDc3.js';
4
- import { e as LoopTraceEmitter, c as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec, E as ExecCtx } from './types-BF-MEsQB.js';
3
+ import { U as UiLens, a as UiFinding, C as CoderTask } from './substrate-DO2GHNg2.js';
4
+ import { e as LoopTraceEmitter, c as LoopTraceEvent, S as SandboxClient, A as AgentRunSpec, E as ExecCtx } from './types-ESeMOj94.js';
5
5
  import { SandboxEvent, SandboxInstance, BackendType } from '@tangle-network/sandbox';
6
6
  import { AgentEvalError } from '@tangle-network/agent-eval';
7
7
  import { O as OtelExporter } from './otel-export-BKmNwiCb.js';
8
- import { T as ToolSpec, R as RouterConfig } from './router-client-D6Ocf4jG.js';
9
- import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './worktree-harness-Dx8XULW3.js';
10
- import { L as LocalHarness } from './local-harness-DU7yV6mG.js';
8
+ import { T as ToolSpec, R as RouterConfig } from './router-client-r8y_VFVM.js';
9
+ import { G as GitRunner, a as WorktreeCheckRunner, D as DeliverableSpec } from './worktree-harness-CX_McRLp.js';
10
+ import { L as LocalHarness } from './local-harness-sI0S_XNA.js';
11
11
  import { ProviderExecutorOptions, AgentEnvironmentProviderRegistry } from './environment-provider.js';
12
12
  import { AgentEnvironmentProvider } from '@tangle-network/agent-interface/environment-provider';
13
13
 
14
14
  /**
15
- * @experimental
16
15
  *
17
16
  * The child→parent message bus: the ONE pipe carrying every message a worker, sub-driver, or
18
17
  * analyst sends up to the driver — settled outputs, questions, and trace-analyst findings. It
@@ -33,6 +32,8 @@ import { AgentEnvironmentProvider } from '@tangle-network/agent-interface/enviro
33
32
  * the SAME publish/pull/subscribe surface backed by a durable mailbox on the parent's box (children
34
33
  * POST events with at-least-once retry; payloads are blob refs so the event stays small). Consumers
35
34
  * depend only on this interface, so distribution is a transport swap, never an architecture change.
35
+ *
36
+ * @experimental
36
37
  */
37
38
  /** Every bus event is a discriminated union member keyed by `type`. */
38
39
  interface BusEvent {
@@ -78,10 +79,10 @@ interface EventBus<E extends BusEvent> {
78
79
  /** Throughput counters for observability dashboards. */
79
80
  stats(): BusStats;
80
81
  }
82
+ /** Create the child→parent coordination bus: one typed pipe for settled outputs, questions, and analyst findings, with a priority-ordered pull queue and a pass-through subscribe lane. */
81
83
  declare function createEventBus<E extends BusEvent>(now?: () => number): EventBus<E>;
82
84
 
83
85
  /**
84
- * @experimental
85
86
  *
86
87
  * Sandbox-session coder decode layer. The sandbox-session delegate (`./delegates`) and the
87
88
  * cross-restart resume driver run the in-box harness over a `SandboxClient` and need to
@@ -96,6 +97,8 @@ declare function createEventBus<E extends BusEvent>(now?: () => number): EventBu
96
97
  * projected onto `CoderOutput`; and
97
98
  * 2. an LLM-emitted JSON block (`{ branch, patch, testResult, typecheckResult, diffStats }`),
98
99
  * lifted onto `data.result` or scanned out of the assistant transcript (any harness shape).
100
+ *
101
+ * @experimental
99
102
  */
100
103
 
101
104
  /** @experimental The structured coder result the sandbox-session path decodes + gates. */
@@ -122,7 +125,6 @@ interface CoderOutput {
122
125
  }
123
126
 
124
127
  /**
125
- * @experimental
126
128
  *
127
129
  * Persistence port for the MCP delegation queue.
128
130
  *
@@ -135,6 +137,8 @@ interface CoderOutput {
135
137
  * Records MUST be JSON-safe — `FileDelegationStore` round-trips them
136
138
  * through `JSON.stringify`/`JSON.parse`, so a `Date`, `Map`, or function
137
139
  * smuggled into `args`/`result` would corrupt the journal.
140
+ *
141
+ * @experimental
138
142
  */
139
143
 
140
144
  /** @experimental */
@@ -186,7 +190,7 @@ declare class DelegationPersistenceError extends AgentEvalError {
186
190
  cause?: unknown;
187
191
  });
188
192
  }
189
- /** @experimental */
193
+ /** In-memory `DelegationStore` — suitable for single-process use and tests. @experimental */
190
194
  declare class InMemoryDelegationStore implements DelegationStore {
191
195
  private readonly records;
192
196
  loadAll(): Promise<DelegationRecord[]>;
@@ -236,7 +240,6 @@ declare class FileDelegationStore implements DelegationStore {
236
240
  }
237
241
 
238
242
  /**
239
- * @experimental
240
243
  *
241
244
  * Compact loop-trace tee for the delegation journal.
242
245
  *
@@ -251,6 +254,8 @@ declare class FileDelegationStore implements DelegationStore {
251
254
  * Payload discipline: a record's trace is hard-capped (spans + serialized
252
255
  * bytes). Past the cap the OLDEST spans are dropped and the record carries a
253
256
  * `traceTruncated: true` marker — truncation is never silent.
257
+ *
258
+ * @experimental
254
259
  */
255
260
 
256
261
  /**
@@ -325,7 +330,7 @@ interface DelegationTraceCollector {
325
330
  /** Flush buffered events of runs that never reached `loop.ended`. */
326
331
  settle(): void;
327
332
  }
328
- /** @experimental */
333
+ /** Build a `DelegationTraceCollector` that buffers loop-trace events and converts them to spans on settle. @experimental */
329
334
  declare function createDelegationTraceCollector(onSpans: (spans: DelegationTraceSpan[]) => void): DelegationTraceCollector;
330
335
  /**
331
336
  * Fan one `LoopTraceEvent` stream into several emitters — e.g. the
@@ -338,7 +343,6 @@ declare function createDelegationTraceCollector(onSpans: (spans: DelegationTrace
338
343
  declare function composeLoopTraceEmitters(...emitters: ReadonlyArray<LoopTraceEmitter | undefined>): LoopTraceEmitter | undefined;
339
344
 
340
345
  /**
341
- * @experimental
342
346
  *
343
347
  * Trace context propagation for MCP subprocess.
344
348
  *
@@ -354,6 +358,8 @@ declare function composeLoopTraceEmitters(...emitters: ReadonlyArray<LoopTraceEm
354
358
  *
355
359
  * When these env vars are absent, the MCP generates a fresh trace root —
356
360
  * the server operates standalone without trace joining.
361
+ *
362
+ * @experimental
357
363
  */
358
364
 
359
365
  interface TraceContext {
@@ -386,7 +392,6 @@ declare function createPropagatingTraceEmitter(ctx: TraceContext): {
386
392
  declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
387
393
 
388
394
  /**
389
- * @experimental
390
395
  *
391
396
  * MCP delegation tool surface — the typed inputs/outputs the product agent
392
397
  * sees over the wire. These types are the contract; the JSON schemas under
@@ -397,6 +402,8 @@ declare function traceContextToEnv(ctx: TraceContext): Record<string, string>;
397
402
  * `completed` | `failed` | `cancelled`. `delegate_feedback` +
398
403
  * `delegation_history` are synchronous reads / writes against the local
399
404
  * task queue + feedback store.
405
+ *
406
+ * @experimental
400
407
  */
401
408
 
402
409
  /** @experimental */
@@ -674,7 +681,6 @@ interface DelegationHistoryResult {
674
681
  }
675
682
 
676
683
  /**
677
- * @experimental
678
684
  *
679
685
  * State machine for async MCP delegations:
680
686
  *
@@ -698,6 +704,8 @@ interface DelegationHistoryResult {
698
704
  * stay queryable, in-flight records either re-attach through the
699
705
  * `resumeDelegate` seam (when they carry a `detachedSessionRef`) or fail
700
706
  * loud with a driver-restart error so `delegation_status` tells the truth.
707
+ *
708
+ * @experimental
701
709
  */
702
710
 
703
711
  type AnyDelegateArgs = DelegateCodeArgs | DelegateResearchArgs | DelegateUiAuditArgs;
@@ -881,7 +889,7 @@ interface DelegationTaskQueueOptions {
881
889
  */
882
890
  traceContext?: TraceContext;
883
891
  }
884
- /** @experimental */
892
+ /** In-process queue for async delegation tasks — submit, cancel, poll status, and read history. @experimental */
885
893
  declare class DelegationTaskQueue {
886
894
  private readonly records;
887
895
  private readonly controllers;
@@ -982,7 +990,6 @@ declare class DelegationTaskQueue {
982
990
  declare function hashIdempotencyInput(value: unknown): string;
983
991
 
984
992
  /**
985
- * @experimental
986
993
  *
987
994
  * Detached delegation turns over the sandbox SDK's `driveTurn` primitive.
988
995
  *
@@ -1014,6 +1021,8 @@ declare function hashIdempotencyInput(value: unknown): string;
1014
1021
  * under the `'detached-turn'` driver tag. Multi-variant fanout stays on the
1015
1022
  * streaming `runLoop` path — N concurrent sessions cannot be expressed as one
1016
1023
  * resume key, and winner selection needs every candidate.
1024
+ *
1025
+ * @experimental
1017
1026
  */
1018
1027
 
1019
1028
  /**
@@ -1072,7 +1081,7 @@ interface DetachedSessionRefParts {
1072
1081
  * @experimental
1073
1082
  */
1074
1083
  declare function formatDetachedSessionRef(parts: DetachedSessionRefParts): string;
1075
- /** @experimental Inverse of {@link formatDetachedSessionRef}; throws `ValidationError` on malformed input. */
1084
+ /** Parse a `detachedSessionRef` string back to parts; throws `ValidationError` on malformed input. @experimental */
1076
1085
  declare function parseDetachedSessionRef(raw: string): DetachedSessionRefParts;
1077
1086
  /** @experimental The terminal payload of a finished detached turn. */
1078
1087
  interface DetachedTurn {
@@ -1187,7 +1196,6 @@ interface DetachedTurnResumeDriverOptions {
1187
1196
  declare function createDetachedTurnResumeDriver(options: DetachedTurnResumeDriverOptions): DelegationResumeDriver;
1188
1197
 
1189
1198
  /**
1190
- * @experimental
1191
1199
  *
1192
1200
  * Delegation executors — the layer between MCP delegates and the sandbox
1193
1201
  * substrate. Each executor exposes a {@link SandboxClient} the kernel
@@ -1204,6 +1212,8 @@ declare function createDetachedTurnResumeDriver(options: DetachedTurnResumeDrive
1204
1212
  * in the caller's existing fleet so worker diffs land directly on the
1205
1213
  * caller's filesystem (the fleet's shared workspace). Selected when the
1206
1214
  * parent sandbox passes `TANGLE_FLEET_ID` into the MCP server's env.
1215
+ *
1216
+ * @experimental
1207
1217
  */
1208
1218
 
1209
1219
  /** @experimental */
@@ -1280,7 +1290,6 @@ interface FleetWorkspaceExecutorOptions {
1280
1290
  declare function createFleetWorkspaceExecutor(options: FleetWorkspaceExecutorOptions): DelegationExecutor;
1281
1291
 
1282
1292
  /**
1283
- * @experimental
1284
1293
  *
1285
1294
  * `detachedSessionDelegate` — the sandbox-session coder delegate: a closure that drives `runLoop`
1286
1295
  * against a `SandboxClient` + a caller-supplied (or minimal model-only default) worker profile, to a
@@ -1297,6 +1306,8 @@ declare function createFleetWorkspaceExecutor(options: FleetWorkspaceExecutorOpt
1297
1306
  * none is passed, a minimal model-only default profile is materialized in `./detached-coder` — no
1298
1307
  * hardcoded skills or tools. For NEW local-repo coding use `worktreeFanout` / `worktreeLoopRunner`
1299
1308
  * (author one `AgentProfile` per harness → `createWorktreeCliExecutor` leaves → `gateOnDeliverable`).
1309
+ *
1310
+ * @experimental
1300
1311
  */
1301
1312
 
1302
1313
  /** @experimental */
@@ -1345,13 +1356,14 @@ interface CoderReview {
1345
1356
  notes?: string;
1346
1357
  }
1347
1358
  /**
1348
- * @experimental
1349
1359
  *
1350
1360
  * Optional adversarial reviewer over a coder candidate that already passed
1351
1361
  * mechanical validation (tests/typecheck/forbidden/diff/no-op/secrets). Folded
1352
1362
  * from the ai-trading-blueprint delegation MCP: a candidate is only eligible to
1353
1363
  * win if the reviewer approves it. The reviewer is the consumer's seam — an LLM
1354
1364
  * judge, a `pnpm review` command, anything returning a `CoderReview`.
1365
+ *
1366
+ * @experimental
1355
1367
  */
1356
1368
  type CoderReviewer = (output: CoderOutput, task: CoderTask, ctx: {
1357
1369
  signal: AbortSignal;
@@ -1484,7 +1496,6 @@ interface SettleDetachedCoderTurnOptions {
1484
1496
  declare function settleDetachedCoderTurn(turn: DetachedTurn, options: SettleDetachedCoderTurnOptions): Promise<CoderOutput>;
1485
1497
 
1486
1498
  /**
1487
- * @experimental
1488
1499
  *
1489
1500
  * Feedback persistence surface for the MCP layer.
1490
1501
  *
@@ -1497,6 +1508,8 @@ declare function settleDetachedCoderTurn(turn: DetachedTurn, options: SettleDeta
1497
1508
  * Feedback events are append-only: every rating is a new event with a
1498
1509
  * fresh id, even when the same delegation is rated multiple times. The
1499
1510
  * caller decides how to roll up scores downstream.
1511
+ *
1512
+ * @experimental
1500
1513
  */
1501
1514
 
1502
1515
  /** @experimental */
@@ -1521,7 +1534,7 @@ interface FeedbackStore {
1521
1534
  refersToRef?: string;
1522
1535
  }): Promise<FeedbackEvent[]>;
1523
1536
  }
1524
- /** @experimental */
1537
+ /** In-memory `FeedbackStore` — suitable for single-process use and tests. @experimental */
1525
1538
  declare class InMemoryFeedbackStore implements FeedbackStore {
1526
1539
  private readonly events;
1527
1540
  put(event: FeedbackEvent): Promise<void>;
@@ -1539,7 +1552,6 @@ declare class InMemoryFeedbackStore implements FeedbackStore {
1539
1552
  declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapshot;
1540
1553
 
1541
1554
  /**
1542
- * @experimental
1543
1555
  *
1544
1556
  * The leaf runtime — the built-in `Executor` IMPLEMENTATIONS behind the ONE
1545
1557
  * open interface frozen in `./types`, plus the open resolver/registry that maps
@@ -1561,6 +1573,8 @@ declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapsh
1561
1573
  * Layering: `estimateCost`/`isModelPriced` are substrate primitives from
1562
1574
  * `@tangle-network/agent-eval`; `runLoop`/`acquireSandbox` are runtime kernels
1563
1575
  * from this package. No per-vendor adapters live here.
1576
+ *
1577
+ * @experimental
1564
1578
  */
1565
1579
 
1566
1580
  /**
@@ -1757,7 +1771,6 @@ declare function createExecutor(config: ExecutorConfig): ExecutorFactory<unknown
1757
1771
  declare function createExecutorRegistry(): ExecutorRegistry;
1758
1772
 
1759
1773
  /**
1760
- * @experimental
1761
1774
  *
1762
1775
  * `delegate` MCP tool — the ONE generic delegation verb, the agent-facing front door to
1763
1776
  * `delegate()` / `supervise()`. The agent hands it an INTENT (what it wants done); a default
@@ -1771,13 +1784,15 @@ declare function createExecutorRegistry(): ExecutorRegistry;
1771
1784
  * The supervisor's substrate (its brain `router`, the worker `backend`, the completion `deliverable`)
1772
1785
  * is INJECTED at server construction — never an agent-supplied arg. The agent supplies only the
1773
1786
  * intent (+ an optional per-call `model` / `runId`).
1787
+ *
1788
+ * @experimental
1774
1789
  */
1775
1790
 
1776
- /** @experimental */
1791
+ /** MCP tool name for the `delegate` generic-delegation tool. @experimental */
1777
1792
  declare const DELEGATE_TOOL_NAME = "delegate";
1778
- /** @experimental */
1793
+ /** Human-readable description of the `delegate` MCP tool, injected into the tool manifest. @experimental */
1779
1794
  declare const DELEGATE_DESCRIPTION: string;
1780
- /** @experimental */
1795
+ /** JSON Schema for `delegate` tool arguments (`intent` + optional `model` and `runId`). @experimental */
1781
1796
  declare const DELEGATE_INPUT_SCHEMA: {
1782
1797
  readonly type: "object";
1783
1798
  readonly properties: {
@@ -1803,7 +1818,7 @@ interface DelegateArgs {
1803
1818
  model?: string;
1804
1819
  runId?: string;
1805
1820
  }
1806
- /** @experimental */
1821
+ /** Parse and validate raw MCP tool input into typed `DelegateArgs`; throws `TypeError` on bad input. @experimental */
1807
1822
  declare function validateDelegateArgs(raw: unknown): DelegateArgs;
1808
1823
  /** The synchronous result the `delegate` tool returns to the calling agent: the delivered output (or
1809
1824
  * the no-winner reason) PLUS the conserved spend of the whole delegation. */
@@ -1838,7 +1853,6 @@ interface DelegateHandlerOptions {
1838
1853
  declare function createDelegateHandler(options: DelegateHandlerOptions): (raw: unknown) => Promise<DelegateResult>;
1839
1854
 
1840
1855
  /**
1841
- * @experimental
1842
1856
  *
1843
1857
  * Stdio JSON-RPC MCP server exposing the delegation tools to sandbox
1844
1858
  * coding-harness agents (claude-code, codex, opencode, ...): the generic
@@ -1856,6 +1870,8 @@ declare function createDelegateHandler(options: DelegateHandlerOptions): (raw: u
1856
1870
  * one request; each response is one line. `tools/list` and `tools/call`
1857
1871
  * mirror the MCP 2024-11-05 spec; we do not pull in
1858
1872
  * `@modelcontextprotocol/sdk` to keep the dependency footprint zero.
1873
+ *
1874
+ * @experimental
1859
1875
  */
1860
1876
 
1861
1877
  /** @experimental */
@@ -1940,7 +1956,11 @@ interface JsonRpcResponse {
1940
1956
  data?: unknown;
1941
1957
  };
1942
1958
  }
1943
- /** @experimental */
1959
+ /**
1960
+ * Stdio JSON-RPC MCP server exposing the delegation tools (`delegate`, `delegate_feedback`, `delegation_status`, `delegation_history`, optional `delegate_ui_audit`) to sandbox coding-harness agents.
1961
+ *
1962
+ * @experimental
1963
+ */
1944
1964
  declare function createMcpServer(options?: McpServerOptions): McpServer;
1945
1965
  /**
1946
1966
  * In-process pair of `Readable` + `Writable` streams suitable for driving
@@ -1957,12 +1977,13 @@ declare function createInProcessTransport(): {
1957
1977
  };
1958
1978
 
1959
1979
  /**
1960
- * @experimental
1961
1980
  *
1962
1981
  * MCP binding for a live `Scope`. A sandbox driver gets the same small verbs
1963
1982
  * the in-process driver has: spawn, observe, await, steer, ask/answer, analyze,
1964
1983
  * and stop. Settled outputs remain Scope artifacts; product code can project
1965
1984
  * them into any UI/report envelope it needs.
1985
+ *
1986
+ * @experimental
1966
1987
  */
1967
1988
 
1968
1989
  /** A worker the driver has drained via `await_event`. */
@@ -2,8 +2,8 @@ import { AgentProfile, AgentProfileValidationResult } from '@tangle-network/agen
2
2
  import { AgentEnvironmentProvider, AgentEnvironmentCapabilities, CreateAgentEnvironmentInput, AgentTurnInput, AgentProfileRef } from '@tangle-network/agent-interface/environment-provider';
3
3
  export { AgentEnvironment, AgentEnvironmentCapabilities, AgentEnvironmentEvent, AgentEnvironmentProvider, AgentEnvironmentQuery, AgentEnvironmentStatus, AgentEnvironmentSummary, AgentProfileRef, AgentSession, AgentSessionRef, AgentSessionStatus, AgentTurnInput, AgentTurnResult, CheckpointRef, CheckpointRequest, CreateAgentEnvironmentInput, ExecRequest, ExecResult, ForkRequest, PlacementInfo, ResourceRequest, WorkspaceRequest } from '@tangle-network/agent-interface/environment-provider';
4
4
  import { CreateSandboxOptions, BackendType } from '@tangle-network/sandbox';
5
- import { R as Runtime, E as ExecutorFactory } from './types-By9LXllv.js';
6
- import { S as SandboxClient } from './types-BF-MEsQB.js';
5
+ import { R as Runtime, E as ExecutorFactory } from './types-Driepl87.js';
6
+ import { S as SandboxClient } from './types-ESeMOj94.js';
7
7
  import '@tangle-network/agent-eval';
8
8
 
9
9
  /** Provider object or registry name accepted by runtime provider adapters.
@@ -4,7 +4,7 @@ import {
4
4
  providerAsSandboxClient,
5
5
  resolveAgentEnvironmentProvider,
6
6
  sandboxClientAsProvider
7
- } from "./chunk-H7IBHAFT.js";
7
+ } from "./chunk-BZF3KQ6G.js";
8
8
  import "./chunk-DGUM43GV.js";
9
9
  export {
10
10
  createAgentEnvironmentProviderRegistry,
@@ -94,7 +94,9 @@ interface SurfaceValidationIssue {
94
94
  path: string;
95
95
  reason: 'missing' | 'not-directory' | 'not-file';
96
96
  }
97
+ /** Validate an `AgentSurfaces` map on disk — missing paths fail loud at `defineAgent` time instead of silently skipping self-improvement edits. */
97
98
  declare function validateSurfaces(surfaces: AgentSurfaces, repoRoot: string): ReadonlyArray<SurfaceValidationIssue>;
99
+ /** Format a list of surface validation issues into a human-readable error string. */
98
100
  declare function renderSurfaceIssues(issues: ReadonlyArray<SurfaceValidationIssue>, repoRoot: string): string;
99
101
 
100
102
  /**
@@ -202,6 +204,7 @@ interface DraftPatchOutput {
202
204
  /** Multi-line rationale for the PR body. */
203
205
  rationale: string;
204
206
  }
207
+ /** The substrate-default `ImprovementAdapter`: resolve each finding's subject to a real surface path, LLM-draft a unified-diff patch, then auto-apply or open a PR. */
205
208
  declare function createSurfaceImprovementAdapter(opts: CreateSurfaceImprovementAdapterOpts): ImprovementAdapter<SurfaceImprovementEdit>;
206
209
 
207
210
  export { type AgentSurfaces as A, type CreateSurfaceImprovementAdapterOpts as C, type DraftPatchInput as D, type ResolvedSurface as R, type SurfaceImprovementEdit as S, type DraftPatchOutput as a, type SurfaceValidationIssue as b, createSurfaceImprovementAdapter as c, resolveSubjectPath as d, renderSurfaceIssues as r, validateSurfaces as v };