@tangle-network/agent-runtime 0.45.0 → 0.46.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 (63) hide show
  1. package/README.md +3 -3
  2. package/dist/agent.d.ts +5 -5
  3. package/dist/agent.js +2 -2
  4. package/dist/agent.js.map +1 -1
  5. package/dist/analyst-loop.d.ts +5 -40
  6. package/dist/analyst-loop.js +2 -4
  7. package/dist/{chunk-KEWO4KI6.js → chunk-65FQLI4V.js} +628 -138
  8. package/dist/chunk-65FQLI4V.js.map +1 -0
  9. package/dist/{chunk-NYN5RTLP.js → chunk-GN75RGM6.js} +7 -7
  10. package/dist/chunk-GN75RGM6.js.map +1 -0
  11. package/dist/{chunk-PRX45WE2.js → chunk-GSUO5QS6.js} +1 -119
  12. package/dist/chunk-GSUO5QS6.js.map +1 -0
  13. package/dist/{chunk-FK53TXOP.js → chunk-HNUXAZIJ.js} +4 -27
  14. package/dist/chunk-HNUXAZIJ.js.map +1 -0
  15. package/dist/{chunk-IJ6FGOPO.js → chunk-I42NHLKX.js} +3 -3
  16. package/dist/chunk-I42NHLKX.js.map +1 -0
  17. package/dist/{chunk-IJGS6J7X.js → chunk-JNPK46YH.js} +2 -2
  18. package/dist/{chunk-QR4UUC5P.js → chunk-KADIJAD4.js} +33 -19
  19. package/dist/chunk-KADIJAD4.js.map +1 -0
  20. package/dist/{chunk-Z2QXVBA6.js → chunk-KPN7OQ64.js} +4 -4
  21. package/dist/chunk-KPN7OQ64.js.map +1 -0
  22. package/dist/{chunk-KSMX62JF.js → chunk-VR4JIC5H.js} +2 -2
  23. package/dist/{coder-CczgMqFx.d.ts → coder-DCWFQpmJ.d.ts} +1 -1
  24. package/dist/{dynamic-BvllHV6M.d.ts → driver-C-mtBo7h.d.ts} +6 -6
  25. package/dist/{improvement-adapter-CWegd3vw.d.ts → improvement-adapter-BC4HhuAR.d.ts} +1 -1
  26. package/dist/improvement.d.ts +2 -2
  27. package/dist/index.d.ts +8 -8
  28. package/dist/index.js +8 -8
  29. package/dist/{kb-gate-D9GBocLN.d.ts → kb-gate-2Gwpz_27.d.ts} +7 -7
  30. package/dist/{loop-runner-bin-CPrCoKqC.d.ts → loop-runner-bin-D-K6bRp3.d.ts} +11 -11
  31. package/dist/loop-runner-bin.d.ts +6 -6
  32. package/dist/loop-runner-bin.js +6 -6
  33. package/dist/loops.d.ts +5 -5
  34. package/dist/loops.js +10 -10
  35. package/dist/mcp/bin.js +6 -6
  36. package/dist/mcp/bin.js.map +1 -1
  37. package/dist/mcp/index.d.ts +11 -11
  38. package/dist/mcp/index.js +7 -7
  39. package/dist/{otel-export-Dy2DyUCU.d.ts → otel-export-nurzFwuJ.d.ts} +1 -1
  40. package/dist/profiles.d.ts +8 -8
  41. package/dist/profiles.js +1 -1
  42. package/dist/profiles.js.map +1 -1
  43. package/dist/{run-loop--hSoIknW.d.ts → run-loop-CU2Y00Si.d.ts} +2 -2
  44. package/dist/runtime.d.ts +156 -52
  45. package/dist/runtime.js +10 -10
  46. package/dist/{types-1HbsFa7H.d.ts → types-BfoeiQRZ.d.ts} +20 -20
  47. package/dist/{types-DdzkffAm.d.ts → types-DnYoHvvZ.d.ts} +17 -5
  48. package/dist/{types-BtRLF2U3.d.ts → types-p8dWBIXL.d.ts} +1 -1
  49. package/dist/workflow.d.ts +3 -3
  50. package/dist/workflow.js +2 -2
  51. package/dist/workflow.js.map +1 -1
  52. package/package.json +13 -24
  53. package/skills/agent-runtime-adoption/SKILL.md +3 -3
  54. package/skills/generate-eval/SKILL.md +60 -0
  55. package/dist/chunk-FK53TXOP.js.map +0 -1
  56. package/dist/chunk-IJ6FGOPO.js.map +0 -1
  57. package/dist/chunk-KEWO4KI6.js.map +0 -1
  58. package/dist/chunk-NYN5RTLP.js.map +0 -1
  59. package/dist/chunk-PRX45WE2.js.map +0 -1
  60. package/dist/chunk-QR4UUC5P.js.map +0 -1
  61. package/dist/chunk-Z2QXVBA6.js.map +0 -1
  62. /package/dist/{chunk-IJGS6J7X.js.map → chunk-JNPK46YH.js.map} +0 -0
  63. /package/dist/{chunk-KSMX62JF.js.map → chunk-VR4JIC5H.js.map} +0 -0
package/dist/loops.js CHANGED
@@ -9,11 +9,11 @@ import {
9
9
  assertTraceDerivedFindings,
10
10
  buildSteerContext,
11
11
  builtinShapes,
12
- cliExecutor,
13
12
  completionAuthorizes,
14
13
  contentAddress,
15
14
  createBudgetPool,
16
- createDynamicDriver,
15
+ createDriver,
16
+ createExecutor,
17
17
  createExecutorRegistry,
18
18
  createRootHandle,
19
19
  createSandboxForSpec,
@@ -28,9 +28,11 @@ import {
28
28
  equalKOnCost,
29
29
  fanout,
30
30
  flatWidenGate,
31
+ inlineSandboxClient,
31
32
  loopDispatch,
32
33
  loopUntil,
33
34
  materializeTreeView,
35
+ openSandboxRun,
34
36
  panel,
35
37
  pipeline,
36
38
  probeSandboxCapabilities,
@@ -39,10 +41,8 @@ import {
39
41
  renderCorpusToInstructions,
40
42
  replaySpawnTree,
41
43
  reportLoopUsage,
42
- routerInlineExecutor,
43
44
  runLoop,
44
45
  runPersonified,
45
- sandboxExecutor,
46
46
  sentinelCompletion,
47
47
  settledToIteration,
48
48
  spendFromUsageEvents,
@@ -50,11 +50,11 @@ import {
50
50
  trajectoryReport,
51
51
  verify,
52
52
  widen
53
- } from "./chunk-KEWO4KI6.js";
53
+ } from "./chunk-65FQLI4V.js";
54
54
  import {
55
55
  extractLlmCallEvent,
56
56
  mapSandboxEvent
57
- } from "./chunk-PRX45WE2.js";
57
+ } from "./chunk-GSUO5QS6.js";
58
58
  import "./chunk-DGUM43GV.js";
59
59
  export {
60
60
  FileCorpus,
@@ -67,11 +67,11 @@ export {
67
67
  assertTraceDerivedFindings,
68
68
  buildSteerContext,
69
69
  builtinShapes,
70
- cliExecutor,
71
70
  completionAuthorizes,
72
71
  contentAddress,
73
72
  createBudgetPool,
74
- createDynamicDriver,
73
+ createDriver,
74
+ createExecutor,
75
75
  createExecutorRegistry,
76
76
  createRootHandle,
77
77
  createSandboxForSpec,
@@ -87,10 +87,12 @@ export {
87
87
  extractLlmCallEvent,
88
88
  fanout,
89
89
  flatWidenGate,
90
+ inlineSandboxClient,
90
91
  loopDispatch,
91
92
  loopUntil,
92
93
  mapSandboxEvent,
93
94
  materializeTreeView,
95
+ openSandboxRun,
94
96
  panel,
95
97
  pipeline,
96
98
  probeSandboxCapabilities,
@@ -99,10 +101,8 @@ export {
99
101
  renderCorpusToInstructions,
100
102
  replaySpawnTree,
101
103
  reportLoopUsage,
102
- routerInlineExecutor,
103
104
  runLoop,
104
105
  runPersonified,
105
- sandboxExecutor,
106
106
  sentinelCompletion,
107
107
  settledToIteration,
108
108
  spendFromUsageEvents,
package/dist/mcp/bin.js CHANGED
@@ -4,18 +4,18 @@ import {
4
4
  createPropagatingTraceEmitter,
5
5
  detectExecutor,
6
6
  readTraceContextFromEnv
7
- } from "../chunk-Z2QXVBA6.js";
7
+ } from "../chunk-KPN7OQ64.js";
8
8
  import "../chunk-WIR4HOOJ.js";
9
- import "../chunk-IJGS6J7X.js";
9
+ import "../chunk-JNPK46YH.js";
10
10
  import {
11
11
  createDefaultCoderDelegate
12
- } from "../chunk-IJ6FGOPO.js";
13
- import "../chunk-QR4UUC5P.js";
12
+ } from "../chunk-I42NHLKX.js";
13
+ import "../chunk-KADIJAD4.js";
14
14
  import "../chunk-GLR25NG7.js";
15
15
  import {
16
16
  runLoop
17
- } from "../chunk-KEWO4KI6.js";
18
- import "../chunk-PRX45WE2.js";
17
+ } from "../chunk-65FQLI4V.js";
18
+ import "../chunk-GSUO5QS6.js";
19
19
  import "../chunk-DGUM43GV.js";
20
20
 
21
21
  // src/mcp/bin.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mcp/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * @experimental\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Spins up a server with the default coder delegate (wired against the\n * real `@tangle-network/sandbox` client) and, when the optional\n * `@tangle-network/agent-knowledge` peer is installed, a researcher\n * delegate against `multiHarnessResearcherFanout`.\n *\n * Environment variables:\n * TANGLE_API_KEY required — passed to `new Sandbox({ apiKey })`\n * SANDBOX_BASE_URL optional — sandbox-SDK base URL override\n * TANGLE_FLEET_ID optional — when set, delegations dispatch\n * INTO this fleet's shared workspace instead\n * of creating sibling sandboxes. Set by the\n * parent sandbox when launching this MCP\n * server so worker diffs land on the caller's\n * filesystem with no cross-sandbox boundary.\n * TANGLE_FLEET_EXCLUDE_MACHINES optional — comma-separated machine ids to\n * skip during fleet-mode round-robin\n * (typically the coordinator machine this\n * MCP server is running on).\n * MCP_MAX_CONCURRENT_SANDBOXES default 4 — kernel maxConcurrency cap\n * MCP_CODER_FANOUT_HARNESSES comma-separated harness ids to use for variants > 1\n * MCP_DISABLE_CODER set to `1` to omit `delegate_code`\n * MCP_DISABLE_RESEARCHER set to `1` to omit `delegate_research` even when peer is present\n */\n\nimport type { LoopSandboxClient, LoopTraceEmitter } from '../runtime'\nimport { runLoop } from '../runtime'\nimport { detectExecutor } from './bin-helpers'\nimport { createDefaultCoderDelegate, type ResearcherDelegate } from './delegates'\nimport type { DelegationExecutor } from './executor'\nimport { createMcpServer } from './server'\nimport { createPropagatingTraceEmitter, readTraceContextFromEnv } from './trace-propagation'\nimport type { ResearchOutputShape } from './types'\n\nasync function main(): Promise<void> {\n const fanoutHarnesses = parseHarnesses(process.env.MCP_CODER_FANOUT_HARNESSES)\n const maxConcurrency = parseConcurrency(process.env.MCP_MAX_CONCURRENT_SANDBOXES)\n const wantCoder = !process.env.MCP_DISABLE_CODER\n const wantResearcher = !process.env.MCP_DISABLE_RESEARCHER\n const fleetId = parseFleetId(process.env.TANGLE_FLEET_ID)\n\n // Skip the sandbox client load entirely when no profile delegate needs it —\n // the feedback + status + history tools are queue-bound and require no\n // sandbox. Useful for tooling that mounts the MCP server purely for\n // self-introspection.\n const needsSandbox = wantCoder || wantResearcher\n let sandboxClient: LoopSandboxClient | undefined\n let executor: DelegationExecutor | undefined\n if (needsSandbox) {\n const apiKey = process.env.TANGLE_API_KEY\n if (!apiKey && !process.env.AGENT_RUNTIME_MCP_ALLOW_NO_KEY) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_API_KEY is required. Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n // Fleet mode against a diagnostic stub is meaningless — the stub can't\n // resolve a real fleet handle. Refuse rather than silently degrading,\n // otherwise a fleet-mounted MCP would behave differently than configured.\n if (fleetId && !apiKey) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_FLEET_ID was set but TANGLE_API_KEY is missing; cannot resolve fleet handle. Provide an api key or unset TANGLE_FLEET_ID.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n executor = await detectExecutor({ sandboxClient })\n if (fleetId) {\n process.stderr.write(`agent-runtime-mcp: fleet-aware delegation: fleetId=${fleetId}\\n`)\n }\n process.stderr.write(`agent-runtime-mcp: delegation placement → ${executor.describe()}\\n`)\n }\n\n // Export delegated-loop topology spans to the OTLP / Tangle Intelligence sink\n // when OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for\n // correlation with the caller's trace). A cheap no-op when the endpoint is\n // unset — the fleet forwards the env into this MCP's process to turn it on.\n const { emitter: traceEmitter, exporter: traceExporter } = createPropagatingTraceEmitter(\n readTraceContextFromEnv(),\n )\n if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {\n process.stderr.write(\n `agent-runtime-mcp: exporting loop topology → ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}\\n`,\n )\n }\n\n const coderDelegate =\n wantCoder && executor\n ? createDefaultCoderDelegate({\n executor,\n fanoutHarnesses,\n maxConcurrency,\n traceEmitter,\n })\n : undefined\n\n const researcherDelegate =\n wantResearcher && executor\n ? await loadResearcherDelegate(executor.client, maxConcurrency, traceEmitter)\n : undefined\n\n const server = createMcpServer({ coderDelegate, researcherDelegate })\n\n const shutdown = () => {\n server.stop()\n void traceExporter?.shutdown().finally(() => process.exit(0))\n if (!traceExporter) process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function loadSandboxClient(apiKey: string | undefined): Promise<LoopSandboxClient> {\n // Diagnostic mode: AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 enables tools/list + the\n // queue-bound tools (status / history / feedback) without sandbox creds.\n // Coder + researcher delegations require a real client; the stub fails loud\n // at create() so the agent observes the cause instead of silent success.\n if (!apiKey) {\n return {\n async create() {\n throw new Error(\n 'agent-runtime-mcp: TANGLE_API_KEY is unset; coder/researcher delegations are disabled in diagnostic mode. Set TANGLE_API_KEY or use MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to remove the unsupported tools from the tool list.',\n )\n },\n } satisfies LoopSandboxClient\n }\n // Dynamic import keeps the bin importable in environments that haven't\n // installed `@tangle-network/sandbox` yet (the runtime package lists it\n // as a peer dep, not a hard dep).\n const mod = await import('@tangle-network/sandbox').catch((err) => {\n process.stderr.write(\n `agent-runtime-mcp: failed to load @tangle-network/sandbox (${err.message}); install the peer dependency\\n`,\n )\n process.exit(2)\n })\n const SandboxCtor = (mod as { Sandbox?: new (config: unknown) => LoopSandboxClient }).Sandbox\n if (!SandboxCtor) {\n process.stderr.write(\n 'agent-runtime-mcp: @tangle-network/sandbox does not export Sandbox; cannot construct client\\n',\n )\n process.exit(2)\n }\n const baseUrl = process.env.SANDBOX_BASE_URL\n return new SandboxCtor({\n apiKey,\n ...(baseUrl ? { baseUrl } : {}),\n })\n}\n\ninterface ResearcherProfilePreset {\n agentRunSpec: Parameters<typeof runLoop>[0]['agentRun'] extends infer T ? NonNullable<T> : never\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n}\n\ninterface ResearcherFanoutPreset {\n agentRuns: NonNullable<Parameters<typeof runLoop>[0]['agentRuns']>\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n driver: Parameters<typeof runLoop>[0]['driver']\n}\n\nasync function loadResearcherDelegate(\n sandboxClient: LoopSandboxClient,\n maxConcurrency: number,\n traceEmitter?: LoopTraceEmitter,\n): Promise<ResearcherDelegate | undefined> {\n // Optional peer — when `@tangle-network/agent-knowledge` isn't installed,\n // we silently omit the researcher tool from the advertisement. The\n // dynamic-import path is resolved at runtime; TypeScript cannot see the\n // peer, so we type the module structurally rather than via its own\n // declaration file.\n const profilesSpecifier = '@tangle-network/agent-knowledge/profiles'\n const mod = await import(profilesSpecifier).catch(() => undefined)\n if (!mod) return undefined\n type SingleFactory = (opts: { task: unknown }) => ResearcherProfilePreset\n type FanoutFactory = (opts: { task: unknown }) => ResearcherFanoutPreset\n const fanoutFactory = (mod as { multiHarnessResearcherFanout?: FanoutFactory })\n .multiHarnessResearcherFanout\n const singleFactory = (mod as { researcherProfile?: SingleFactory }).researcherProfile\n if (!fanoutFactory || !singleFactory) return undefined\n\n return async (args, ctx) => {\n const task = {\n question: args.question,\n knowledgeNamespace: args.namespace,\n scope: args.scope,\n sources: args.sources,\n recencyWindow: args.config?.recencyWindow\n ? {\n since: args.config.recencyWindow.since\n ? new Date(args.config.recencyWindow.since)\n : undefined,\n until: args.config.recencyWindow.until\n ? new Date(args.config.recencyWindow.until)\n : undefined,\n }\n : undefined,\n maxItems: args.config?.maxItems,\n minConfidence: args.config?.minConfidence,\n }\n const variants = Math.max(1, Math.trunc(args.variants ?? 1))\n ctx.report({ iteration: 0, phase: 'starting' })\n if (variants <= 1) {\n const preset = singleFactory({ task })\n const result = await runLoop({\n driver: {\n name: 'mcp-researcher-single',\n async plan(t, history) {\n return history.length === 0 ? [t] : []\n },\n decide(history) {\n return history.length > 0 ? 'pick-winner' : 'fail'\n },\n },\n agentRun: preset.agentRunSpec,\n output: preset.output,\n validator: preset.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: 1,\n maxConcurrency,\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate produced no winner')\n ctx.report({ iteration: 1, phase: 'completed' })\n return output as ResearchOutputShape\n }\n const fanout = fanoutFactory({ task })\n const result = await runLoop({\n driver: fanout.driver,\n agentRuns: fanout.agentRuns.slice(0, variants),\n output: fanout.output,\n validator: fanout.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: variants,\n maxConcurrency: Math.min(maxConcurrency, variants),\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate fanout produced no winner')\n ctx.report({ iteration: result.iterations.length, phase: 'completed' })\n return output as ResearchOutputShape\n }\n}\n\nfunction parseHarnesses(raw: string | undefined): string[] | undefined {\n if (!raw) return undefined\n const list = raw\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n return list.length > 0 ? list : undefined\n}\n\nfunction parseFleetId(raw: string | undefined): string | undefined {\n if (typeof raw !== 'string') return undefined\n const trimmed = raw.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction parseConcurrency(raw: string | undefined): number {\n if (!raw) return 4\n const n = Number(raw)\n if (!Number.isFinite(n) || n < 1) return 4\n return Math.min(Math.trunc(n), 32)\n}\n\nmain().catch((err) => {\n process.stderr.write(`agent-runtime-mcp: ${err instanceof Error ? err.stack : String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwCA,eAAe,OAAsB;AACnC,QAAM,kBAAkB,eAAe,QAAQ,IAAI,0BAA0B;AAC7E,QAAM,iBAAiB,iBAAiB,QAAQ,IAAI,4BAA4B;AAChF,QAAM,YAAY,CAAC,QAAQ,IAAI;AAC/B,QAAM,iBAAiB,CAAC,QAAQ,IAAI;AACpC,QAAM,UAAU,aAAa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EAAE,aAAa,IAAI,CAAC,EAAG;AAAA,MACpF,eAAe;AAAA,MACf,gBAAgB,KAAK,IAAI,gBAAgB,QAAQ;AAAA,IACnD,CAAC;AACD,UAAM,SAAS,OAAO,QAAQ;AAC9B,QAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,QAAI,OAAO,EAAE,WAAW,OAAO,WAAW,QAAQ,OAAO,YAAY,CAAC;AACtE,WAAO;AAAA,EACT;AACF;AAEA,SAAS,eAAe,KAA+C;AACrE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,IACV,MAAM,GAAG,EACT,IAAI,CAAC,UAAU,MAAM,KAAK,CAAC,EAC3B,OAAO,OAAO;AACjB,SAAO,KAAK,SAAS,IAAI,OAAO;AAClC;AAEA,SAAS,aAAa,KAA6C;AACjE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,IAAI,KAAK;AACzB,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,iBAAiB,KAAiC;AACzD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,EAAG,QAAO;AACzC,SAAO,KAAK,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE;AACnC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,CAAC;AAAA,CAAI;AAC7F,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["result","output"]}
1
+ {"version":3,"sources":["../../src/mcp/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * @experimental\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Spins up a server with the default coder delegate (wired against the\n * real `@tangle-network/sandbox` client) and, when the optional\n * `@tangle-network/agent-knowledge` peer is installed, a researcher\n * delegate against `multiHarnessResearcherFanout`.\n *\n * Environment variables:\n * TANGLE_API_KEY required — passed to `new Sandbox({ apiKey })`\n * SANDBOX_BASE_URL optional — sandbox-SDK base URL override\n * TANGLE_FLEET_ID optional — when set, delegations dispatch\n * INTO this fleet's shared workspace instead\n * of creating sibling sandboxes. Set by the\n * parent sandbox when launching this MCP\n * server so worker diffs land on the caller's\n * filesystem with no cross-sandbox boundary.\n * TANGLE_FLEET_EXCLUDE_MACHINES optional — comma-separated machine ids to\n * skip during fleet-mode round-robin\n * (typically the coordinator machine this\n * MCP server is running on).\n * MCP_MAX_CONCURRENT_SANDBOXES default 4 — kernel maxConcurrency cap\n * MCP_CODER_FANOUT_HARNESSES comma-separated harness ids to use for variants > 1\n * MCP_DISABLE_CODER set to `1` to omit `delegate_code`\n * MCP_DISABLE_RESEARCHER set to `1` to omit `delegate_research` even when peer is present\n */\n\nimport type { LoopTraceEmitter, SandboxClient } from '../runtime'\nimport { runLoop } from '../runtime'\nimport { detectExecutor } from './bin-helpers'\nimport { createDefaultCoderDelegate, type ResearcherDelegate } from './delegates'\nimport type { DelegationExecutor } from './executor'\nimport { createMcpServer } from './server'\nimport { createPropagatingTraceEmitter, readTraceContextFromEnv } from './trace-propagation'\nimport type { ResearchOutputShape } from './types'\n\nasync function main(): Promise<void> {\n const fanoutHarnesses = parseHarnesses(process.env.MCP_CODER_FANOUT_HARNESSES)\n const maxConcurrency = parseConcurrency(process.env.MCP_MAX_CONCURRENT_SANDBOXES)\n const wantCoder = !process.env.MCP_DISABLE_CODER\n const wantResearcher = !process.env.MCP_DISABLE_RESEARCHER\n const fleetId = parseFleetId(process.env.TANGLE_FLEET_ID)\n\n // Skip the sandbox client load entirely when no profile delegate needs it —\n // the feedback + status + history tools are queue-bound and require no\n // sandbox. Useful for tooling that mounts the MCP server purely for\n // self-introspection.\n const needsSandbox = wantCoder || wantResearcher\n let sandboxClient: SandboxClient | undefined\n let executor: DelegationExecutor | undefined\n if (needsSandbox) {\n const apiKey = process.env.TANGLE_API_KEY\n if (!apiKey && !process.env.AGENT_RUNTIME_MCP_ALLOW_NO_KEY) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_API_KEY is required. Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n // Fleet mode against a diagnostic stub is meaningless — the stub can't\n // resolve a real fleet handle. Refuse rather than silently degrading,\n // otherwise a fleet-mounted MCP would behave differently than configured.\n if (fleetId && !apiKey) {\n process.stderr.write(\n 'agent-runtime-mcp: TANGLE_FLEET_ID was set but TANGLE_API_KEY is missing; cannot resolve fleet handle. Provide an api key or unset TANGLE_FLEET_ID.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n executor = await detectExecutor({ sandboxClient })\n if (fleetId) {\n process.stderr.write(`agent-runtime-mcp: fleet-aware delegation: fleetId=${fleetId}\\n`)\n }\n process.stderr.write(`agent-runtime-mcp: delegation placement → ${executor.describe()}\\n`)\n }\n\n // Export delegated-loop topology spans to the OTLP / Tangle Intelligence sink\n // when OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for\n // correlation with the caller's trace). A cheap no-op when the endpoint is\n // unset — the fleet forwards the env into this MCP's process to turn it on.\n const { emitter: traceEmitter, exporter: traceExporter } = createPropagatingTraceEmitter(\n readTraceContextFromEnv(),\n )\n if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) {\n process.stderr.write(\n `agent-runtime-mcp: exporting loop topology → ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT}\\n`,\n )\n }\n\n const coderDelegate =\n wantCoder && executor\n ? createDefaultCoderDelegate({\n executor,\n fanoutHarnesses,\n maxConcurrency,\n traceEmitter,\n })\n : undefined\n\n const researcherDelegate =\n wantResearcher && executor\n ? await loadResearcherDelegate(executor.client, maxConcurrency, traceEmitter)\n : undefined\n\n const server = createMcpServer({ coderDelegate, researcherDelegate })\n\n const shutdown = () => {\n server.stop()\n void traceExporter?.shutdown().finally(() => process.exit(0))\n if (!traceExporter) process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function loadSandboxClient(apiKey: string | undefined): Promise<SandboxClient> {\n // Diagnostic mode: AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 enables tools/list + the\n // queue-bound tools (status / history / feedback) without sandbox creds.\n // Coder + researcher delegations require a real client; the stub fails loud\n // at create() so the agent observes the cause instead of silent success.\n if (!apiKey) {\n return {\n async create() {\n throw new Error(\n 'agent-runtime-mcp: TANGLE_API_KEY is unset; coder/researcher delegations are disabled in diagnostic mode. Set TANGLE_API_KEY or use MCP_DISABLE_CODER=1 MCP_DISABLE_RESEARCHER=1 to remove the unsupported tools from the tool list.',\n )\n },\n } satisfies SandboxClient\n }\n // Dynamic import keeps the bin importable in environments that haven't\n // installed `@tangle-network/sandbox` yet (the runtime package lists it\n // as a peer dep, not a hard dep).\n const mod = await import('@tangle-network/sandbox').catch((err) => {\n process.stderr.write(\n `agent-runtime-mcp: failed to load @tangle-network/sandbox (${err.message}); install the peer dependency\\n`,\n )\n process.exit(2)\n })\n const SandboxCtor = (mod as { Sandbox?: new (config: unknown) => SandboxClient }).Sandbox\n if (!SandboxCtor) {\n process.stderr.write(\n 'agent-runtime-mcp: @tangle-network/sandbox does not export Sandbox; cannot construct client\\n',\n )\n process.exit(2)\n }\n const baseUrl = process.env.SANDBOX_BASE_URL\n return new SandboxCtor({\n apiKey,\n ...(baseUrl ? { baseUrl } : {}),\n })\n}\n\ninterface ResearcherProfilePreset {\n agentRunSpec: Parameters<typeof runLoop>[0]['agentRun'] extends infer T ? NonNullable<T> : never\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n}\n\ninterface ResearcherFanoutPreset {\n agentRuns: NonNullable<Parameters<typeof runLoop>[0]['agentRuns']>\n output: Parameters<typeof runLoop>[0]['output']\n validator: Parameters<typeof runLoop>[0]['validator']\n driver: Parameters<typeof runLoop>[0]['driver']\n}\n\nasync function loadResearcherDelegate(\n sandboxClient: SandboxClient,\n maxConcurrency: number,\n traceEmitter?: LoopTraceEmitter,\n): Promise<ResearcherDelegate | undefined> {\n // Optional peer — when `@tangle-network/agent-knowledge` isn't installed,\n // we silently omit the researcher tool from the advertisement. The\n // dynamic-import path is resolved at runtime; TypeScript cannot see the\n // peer, so we type the module structurally rather than via its own\n // declaration file.\n const profilesSpecifier = '@tangle-network/agent-knowledge/profiles'\n const mod = await import(profilesSpecifier).catch(() => undefined)\n if (!mod) return undefined\n type SingleFactory = (opts: { task: unknown }) => ResearcherProfilePreset\n type FanoutFactory = (opts: { task: unknown }) => ResearcherFanoutPreset\n const fanoutFactory = (mod as { multiHarnessResearcherFanout?: FanoutFactory })\n .multiHarnessResearcherFanout\n const singleFactory = (mod as { researcherProfile?: SingleFactory }).researcherProfile\n if (!fanoutFactory || !singleFactory) return undefined\n\n return async (args, ctx) => {\n const task = {\n question: args.question,\n knowledgeNamespace: args.namespace,\n scope: args.scope,\n sources: args.sources,\n recencyWindow: args.config?.recencyWindow\n ? {\n since: args.config.recencyWindow.since\n ? new Date(args.config.recencyWindow.since)\n : undefined,\n until: args.config.recencyWindow.until\n ? new Date(args.config.recencyWindow.until)\n : undefined,\n }\n : undefined,\n maxItems: args.config?.maxItems,\n minConfidence: args.config?.minConfidence,\n }\n const variants = Math.max(1, Math.trunc(args.variants ?? 1))\n ctx.report({ iteration: 0, phase: 'starting' })\n if (variants <= 1) {\n const preset = singleFactory({ task })\n const result = await runLoop({\n driver: {\n name: 'mcp-researcher-single',\n async plan(t, history) {\n return history.length === 0 ? [t] : []\n },\n decide(history) {\n return history.length > 0 ? 'pick-winner' : 'fail'\n },\n },\n agentRun: preset.agentRunSpec,\n output: preset.output,\n validator: preset.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: 1,\n maxConcurrency,\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate produced no winner')\n ctx.report({ iteration: 1, phase: 'completed' })\n return output as ResearchOutputShape\n }\n const fanout = fanoutFactory({ task })\n const result = await runLoop({\n driver: fanout.driver,\n agentRuns: fanout.agentRuns.slice(0, variants),\n output: fanout.output,\n validator: fanout.validator,\n task,\n ctx: { sandboxClient, signal: ctx.signal, ...(traceEmitter ? { traceEmitter } : {}) },\n maxIterations: variants,\n maxConcurrency: Math.min(maxConcurrency, variants),\n })\n const output = result.winner?.output\n if (!output) throw new Error('researcher delegate fanout produced no winner')\n ctx.report({ iteration: result.iterations.length, phase: 'completed' })\n return output as ResearchOutputShape\n }\n}\n\nfunction parseHarnesses(raw: string | undefined): string[] | undefined {\n if (!raw) return undefined\n const list = raw\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n return list.length > 0 ? list : undefined\n}\n\nfunction parseFleetId(raw: string | undefined): string | undefined {\n if (typeof raw !== 'string') return undefined\n const trimmed = raw.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction parseConcurrency(raw: string | undefined): number {\n if (!raw) return 4\n const n = Number(raw)\n if (!Number.isFinite(n) || n < 1) return 4\n return Math.min(Math.trunc(n), 32)\n}\n\nmain().catch((err) => {\n process.stderr.write(`agent-runtime-mcp: ${err instanceof Error ? err.stack : String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwCA,eAAe,OAAsB;AACnC,QAAM,kBAAkB,eAAe,QAAQ,IAAI,0BAA0B;AAC7E,QAAM,iBAAiB,iBAAiB,QAAQ,IAAI,4BAA4B;AAChF,QAAM,YAAY,CAAC,QAAQ,IAAI;AAC/B,QAAM,iBAAiB,CAAC,QAAQ,IAAI;AACpC,QAAM,UAAU,aAAa,QAAQ,IAAI,eAAe;AAMxD,QAAM,eAAe,aAAa;AAClC,MAAI;AACJ,MAAI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AAK,IAAI,gBAAgB,QAAQ;AAAA,IACnD,CAAC;AACD,UAAM,SAAS,OAAO,QAAQ;AAC9B,QAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,QAAI,OAAO,EAAE,WAAW,OAAO,WAAW,QAAQ,OAAO,YAAY,CAAC;AACtE,WAAO;AAAA,EACT;AACF;AAEA,SAAS,eAAe,KAA+C;AACrE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,OAAO,IACV,MAAM,GAAG,EACT,IAAI,CAAC,UAAU,MAAM,KAAK,CAAC,EAC3B,OAAO,OAAO;AACjB,SAAO,KAAK,SAAS,IAAI,OAAO;AAClC;AAEA,SAAS,aAAa,KAA6C;AACjE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,UAAU,IAAI,KAAK;AACzB,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,iBAAiB,KAAiC;AACzD,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,IAAI,EAAG,QAAO;AACzC,SAAO,KAAK,IAAI,KAAK,MAAM,CAAC,GAAG,EAAE;AACnC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,CAAC;AAAA,CAAI;AAC7F,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["result","output"]}
@@ -1,17 +1,17 @@
1
- import { b as LoopSandboxClient, g as LoopSandboxPlacement, f as LoopTraceEmitter } from '../types-DdzkffAm.js';
2
- import { c as FleetHandle, d as DelegationExecutor, e as DelegateFeedbackArgs, f as DelegationFeedbackSnapshot, g as DelegationProfile, D as DelegateCodeArgs, h as DelegateResearchArgs, i as DelegateUiAuditArgs, j as DelegationStatus, k as DelegationProgress, l as DelegationResultPayload, m as DelegationError, n as DelegationStatusResult, o as DelegationHistoryArgs, p as DelegationHistoryEntry, q as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, r as DelegateCodeResult, s as DelegateFeedbackResult, t as ResearchSource, u as DelegateResearchResult, v as DelegateUiAuditResult, w as DelegationHistoryResult, x as DelegationStatusArgs } from '../kb-gate-D9GBocLN.js';
3
- export { y as CoderReview, C as CoderReviewer, a as CoderWinnerSelection, z as CreateDefaultCoderDelegateOptions, b as CreateKbGateOptions, A as DelegateCodeConfig, B as DelegateResearchConfig, E as DelegateRunCtx, G as DelegateUiAuditConfig, H as DelegateUiAuditRoute, F as FactCandidate, I as FactJudge, J as FactJudgeVerdict, K as FeedbackRating, L as FeedbackRefersTo, M as FleetWorkspaceExecutorOptions, N as KbGateResult, O as ResearchOutputShape, S as SiblingSandboxExecutorOptions, P as UiAuditorDelegationOutput, Q as createDefaultCoderDelegate, T as createFleetWorkspaceExecutor, V as createKbGate, W as createSiblingSandboxExecutor } from '../kb-gate-D9GBocLN.js';
1
+ import { S as SandboxClient, f as LoopSandboxPlacement, e as LoopTraceEmitter } from '../types-DnYoHvvZ.js';
2
+ import { c as FleetHandle, d as DelegationExecutor, e as DelegateFeedbackArgs, f as DelegationFeedbackSnapshot, g as DelegationProfile, D as DelegateCodeArgs, h as DelegateResearchArgs, i as DelegateUiAuditArgs, j as DelegationStatus, k as DelegationProgress, l as DelegationResultPayload, m as DelegationError, n as DelegationStatusResult, o as DelegationHistoryArgs, p as DelegationHistoryEntry, q as CoderDelegate, R as ResearcherDelegate, U as UiAuditorDelegate, r as DelegateCodeResult, s as DelegateFeedbackResult, t as ResearchSource, u as DelegateResearchResult, v as DelegateUiAuditResult, w as DelegationHistoryResult, x as DelegationStatusArgs } from '../kb-gate-2Gwpz_27.js';
3
+ export { y as CoderReview, C as CoderReviewer, a as CoderWinnerSelection, z as CreateDefaultCoderDelegateOptions, b as CreateKbGateOptions, A as DelegateCodeConfig, B as DelegateResearchConfig, E as DelegateRunCtx, G as DelegateUiAuditConfig, H as DelegateUiAuditRoute, F as FactCandidate, I as FactJudge, J as FactJudgeVerdict, K as FeedbackRating, L as FeedbackRefersTo, M as FleetWorkspaceExecutorOptions, N as KbGateResult, O as ResearchOutputShape, S as SiblingSandboxExecutorOptions, P as UiAuditorDelegationOutput, Q as createDefaultCoderDelegate, T as createFleetWorkspaceExecutor, V as createKbGate, W as createSiblingSandboxExecutor } from '../kb-gate-2Gwpz_27.js';
4
4
  export { B as BuildDelegationMcpServerOptions, C as ComposeProductionAgentProfileOptions, D as DELEGATION_MCP_SERVER_KEY, b as buildDelegationMcpServer, c as composeProductionAgentProfile } from '../delegation-profile-1GbW5yA3.js';
5
5
  import { L as LocalHarness, r as runLocalHarness } from '../local-harness-KrdFTY5R.js';
6
6
  export { a as LocalHarnessResult, R as RunLocalHarnessOptions } from '../local-harness-KrdFTY5R.js';
7
- import { O as OtelExporter } from '../otel-export-Dy2DyUCU.js';
8
- export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../otel-export-Dy2DyUCU.js';
7
+ import { O as OtelExporter } from '../otel-export-nurzFwuJ.js';
8
+ export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../otel-export-nurzFwuJ.js';
9
9
  import { AnalystFinding } from '@tangle-network/agent-eval';
10
- import { S as Scope, R as ResultBlobStore, A as Agent, B as Budget } from '../types-1HbsFa7H.js';
10
+ import { S as Scope, R as ResultBlobStore, A as Agent, B as Budget } from '../types-BfoeiQRZ.js';
11
11
  import { a as UiLens } from '../substrate-CUgk7F7s.js';
12
12
  import '@tangle-network/sandbox';
13
13
  import '../runtime-hooks-C7JwKb9E.js';
14
- import '../coder-CczgMqFx.js';
14
+ import '../coder-DCWFQpmJ.js';
15
15
  import 'node:child_process';
16
16
 
17
17
  /**
@@ -24,7 +24,7 @@ import 'node:child_process';
24
24
 
25
25
  /** @experimental */
26
26
  interface DetectExecutorArgs {
27
- sandboxClient: LoopSandboxClient;
27
+ sandboxClient: SandboxClient;
28
28
  /** Raw env (defaults to `process.env`). Pass an explicit map for tests. */
29
29
  env?: Record<string, string | undefined>;
30
30
  /**
@@ -32,7 +32,7 @@ interface DetectExecutorArgs {
32
32
  * default reads `client.fleets.get(fleetId)` and validates the returned
33
33
  * shape against the structural `FleetHandle` contract.
34
34
  */
35
- resolveFleet?: (client: LoopSandboxClient, fleetId: string) => Promise<FleetHandle>;
35
+ resolveFleet?: (client: SandboxClient, fleetId: string) => Promise<FleetHandle>;
36
36
  }
37
37
  /**
38
38
  * Pick the right executor for an MCP server invocation based on env vars.
@@ -442,7 +442,7 @@ interface McpServerOptions {
442
442
  researcherDelegate?: ResearcherDelegate;
443
443
  /**
444
444
  * Required to enable delegate_ui_audit. Wire one that closes over your
445
- * `runLoop` + `uiAuditorProfile` + a `LoopSandboxClient` (the
445
+ * `runLoop` + `uiAuditorProfile` + a `SandboxClient` (the
446
446
  * canonical in-process choice is `createInProcessUiAuditClient` from
447
447
  * `@tangle-network/agent-runtime/profiles`) + your vision judge.
448
448
  */
@@ -916,7 +916,7 @@ declare function createDelegateResearchHandler(options: DelegateResearchHandlerO
916
916
  * The handler does not import the auditor profile directly — consumers
917
917
  * inject a `UiAuditorDelegate` via `createMcpServer({ uiAuditorDelegate })`.
918
918
  * The delegate is the seam where the consumer chooses the judge (vision
919
- * model) and the `LoopSandboxClient` (in-process Playwright vs fleet vs
919
+ * model) and the `SandboxClient` (in-process Playwright vs fleet vs
920
920
  * remote browser). agent-runtime ships the in-process client under
921
921
  * `./profiles` so consumers who want the canonical setup can wire it
922
922
  * with a few lines.
package/dist/mcp/index.js CHANGED
@@ -14,12 +14,12 @@ import {
14
14
  removeWorktree,
15
15
  traceContextToEnv,
16
16
  validateDelegateUiAuditArgs
17
- } from "../chunk-Z2QXVBA6.js";
17
+ } from "../chunk-KPN7OQ64.js";
18
18
  import "../chunk-WIR4HOOJ.js";
19
19
  import {
20
20
  mcpToolsForRuntimeMcp,
21
21
  mcpToolsForRuntimeMcpSubset
22
- } from "../chunk-KSMX62JF.js";
22
+ } from "../chunk-VR4JIC5H.js";
23
23
  import {
24
24
  DELEGATE_CODE_DESCRIPTION,
25
25
  DELEGATE_CODE_INPUT_SCHEMA,
@@ -50,7 +50,7 @@ import {
50
50
  validateDelegateResearchArgs,
51
51
  validateDelegationHistoryArgs,
52
52
  validateDelegationStatusArgs
53
- } from "../chunk-IJGS6J7X.js";
53
+ } from "../chunk-JNPK46YH.js";
54
54
  import {
55
55
  createKbGate
56
56
  } from "../chunk-FNMGYYSS.js";
@@ -58,8 +58,8 @@ import {
58
58
  createDefaultCoderDelegate,
59
59
  createFleetWorkspaceExecutor,
60
60
  createSiblingSandboxExecutor
61
- } from "../chunk-IJ6FGOPO.js";
62
- import "../chunk-QR4UUC5P.js";
61
+ } from "../chunk-I42NHLKX.js";
62
+ import "../chunk-KADIJAD4.js";
63
63
  import {
64
64
  runLocalHarness
65
65
  } from "../chunk-GLR25NG7.js";
@@ -70,8 +70,8 @@ import {
70
70
  } from "../chunk-7JITYN6T.js";
71
71
  import {
72
72
  assertTraceDerivedFindings
73
- } from "../chunk-KEWO4KI6.js";
74
- import "../chunk-PRX45WE2.js";
73
+ } from "../chunk-65FQLI4V.js";
74
+ import "../chunk-GSUO5QS6.js";
75
75
  import "../chunk-DGUM43GV.js";
76
76
 
77
77
  // src/mcp/tools/checks.ts
@@ -1,4 +1,4 @@
1
- import { e as OpenAIChatTool } from './types-DdzkffAm.js';
1
+ import { d as OpenAIChatTool } from './types-DnYoHvvZ.js';
2
2
 
3
3
  /**
4
4
  * @experimental
@@ -1,5 +1,5 @@
1
- export { C as CoderOutput, b as CoderProfileOptions, a as CoderTask, M as MultiHarnessCoderFanoutOptions, c as coderProfile, d as createCoderValidator, m as multiHarnessCoderFanout } from './coder-CczgMqFx.js';
2
- import { b as LoopSandboxClient, O as OutputAdapter, V as Validator, A as AgentRunSpec } from './types-DdzkffAm.js';
1
+ export { C as CoderOutput, b as CoderProfileOptions, a as CoderTask, M as MultiHarnessCoderFanoutOptions, c as coderProfile, d as createCoderValidator, m as multiHarnessCoderFanout } from './coder-DCWFQpmJ.js';
2
+ import { S as SandboxClient, O as OutputAdapter, V as Validator, A as AgentRunSpec } from './types-DnYoHvvZ.js';
3
3
  import { a as UiLens, U as UiFinding } from './substrate-CUgk7F7s.js';
4
4
  export { b as UI_FINDING_SEVERITIES, c as UI_LENSES, d as UiFindingScreenshot, e as UiFindingSeverity } from './substrate-CUgk7F7s.js';
5
5
  import { SandboxEvent, AgentProfile } from '@tangle-network/sandbox';
@@ -159,7 +159,7 @@ type UiJudge = (input: UiJudgeInput) => Promise<UiJudgeOutput>;
159
159
  /**
160
160
  * @experimental
161
161
  *
162
- * `createInProcessUiAuditClient` — a `LoopSandboxClient` that drives a
162
+ * `createInProcessUiAuditClient` — a `SandboxClient` that drives a
163
163
  * Playwright browser in-process and delegates finding identification to a
164
164
  * consumer-supplied {@link UiJudge}.
165
165
  *
@@ -172,7 +172,7 @@ type UiJudge = (input: UiJudgeInput) => Promise<UiJudgeOutput>;
172
172
  *
173
173
  * The client owns ONE browser for its lifetime and creates a fresh
174
174
  * context per iteration (isolated cookies/storage). Playwright is
175
- * dynamically imported so consumers who use a different `LoopSandboxClient`
175
+ * dynamically imported so consumers who use a different `SandboxClient`
176
176
  * — e.g. a fleet executor that drives Playwright remotely — do not pay
177
177
  * the peer dep cost.
178
178
  *
@@ -249,7 +249,7 @@ interface PageHandle {
249
249
  };
250
250
  }
251
251
  /** @experimental */
252
- declare function createInProcessUiAuditClient(options: InProcessUiAuditClientOptions): LoopSandboxClient & {
252
+ declare function createInProcessUiAuditClient(options: InProcessUiAuditClientOptions): SandboxClient & {
253
253
  /**
254
254
  * Close the underlying browser. Idempotent.
255
255
  *
@@ -293,7 +293,7 @@ declare function buildAuditorSystemPrompt(lens: UiLens): string;
293
293
  * @experimental
294
294
  *
295
295
  * Sandbox-event stream → UiAuditOutput decoder. The custom auditor
296
- * `LoopSandboxClient` emits events of the form:
296
+ * `SandboxClient` emits events of the form:
297
297
  *
298
298
  * { type: 'audit.capture', data: UiAuditCapture }
299
299
  * { type: 'audit.finding', data: UiFinding }
@@ -319,7 +319,7 @@ declare function parseAuditorEvents(events: SandboxEvent[]): UiAuditOutput;
319
319
  * — it's a vision-capable judge driving a browser. The loop kernel still
320
320
  * iterates `client.create() → box.streamPrompt() → box.delete()`; the
321
321
  * client/box pair are provided by `createInProcessUiAuditClient` (in
322
- * `./in-process-client.ts`) or by a consumer-supplied `LoopSandboxClient`.
322
+ * `./in-process-client.ts`) or by a consumer-supplied `SandboxClient`.
323
323
  */
324
324
 
325
325
  /** @experimental */
@@ -330,7 +330,7 @@ interface UiAuditorProfileOptions {
330
330
  name?: string;
331
331
  /**
332
332
  * Optional model identifier passed in `AgentProfile.model.default`.
333
- * The consumer's `LoopSandboxClient` chooses how to interpret it.
333
+ * The consumer's `SandboxClient` chooses how to interpret it.
334
334
  */
335
335
  model?: string;
336
336
  /**
package/dist/profiles.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  coderProfile,
10
10
  createCoderValidator,
11
11
  multiHarnessCoderFanout
12
- } from "./chunk-QR4UUC5P.js";
12
+ } from "./chunk-KADIJAD4.js";
13
13
  import "./chunk-DGUM43GV.js";
14
14
 
15
15
  // src/profiles/ui-auditor/prompt.ts