@tangle-network/agent-runtime 0.348.1 → 0.350.2

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 (130) hide show
  1. package/dist/{activation-BEGalhOL.js → activation-CfJMyzEs.js} +12 -14
  2. package/dist/{activation-BEGalhOL.js.map → activation-CfJMyzEs.js.map} +1 -1
  3. package/dist/{activation-NQZP_mdI.d.ts → activation-DyiHrTlS.d.ts} +2 -24
  4. package/dist/agent.d.ts +8 -12
  5. package/dist/agent.js +9 -12
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DZw5QWT9.js → analyst-loop-BZvXCDKy.js} +2 -3
  8. package/dist/{analyst-loop-DZw5QWT9.js.map → analyst-loop-BZvXCDKy.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +3 -5
  10. package/dist/analyst-loop.js +1 -2
  11. package/dist/{bundle-DKQtOO9d.js → bundle-Ze8pd07a.js} +3 -4
  12. package/dist/{bundle-DKQtOO9d.js.map → bundle-Ze8pd07a.js.map} +1 -1
  13. package/dist/candidate-execution/index.d.ts +13 -33
  14. package/dist/candidate-execution/index.js +16 -18
  15. package/dist/candidate-execution/index.js.map +1 -1
  16. package/dist/{coordination-manager-Bm6leXc6.js → coordination-manager-BkVfWlMz.js} +101 -132
  17. package/dist/coordination-manager-BkVfWlMz.js.map +1 -0
  18. package/dist/{delegate-Cp5-PsaX.js → delegate-DgEie4ad.js} +19 -21
  19. package/dist/delegate-DgEie4ad.js.map +1 -0
  20. package/dist/durable.d.ts +13 -23
  21. package/dist/durable.js +48 -43
  22. package/dist/durable.js.map +1 -1
  23. package/dist/{errors-DodWX-cb.js → errors-wuhGvpE3.js} +2 -3
  24. package/dist/{errors-DodWX-cb.js.map → errors-wuhGvpE3.js.map} +1 -1
  25. package/dist/{graph-CE_pzU31.js → graph-Cx0FhKSE.js} +192 -15
  26. package/dist/graph-Cx0FhKSE.js.map +1 -0
  27. package/dist/{improve-wT11zteg.js → improve-i0HU1-aa.js} +35 -53
  28. package/dist/{improve-wT11zteg.js.map → improve-i0HU1-aa.js.map} +1 -1
  29. package/dist/{improvement-adapter-sIthWkcN.d.ts → improvement-adapter-D5GRU1eY.d.ts} +2 -6
  30. package/dist/index.d.ts +41 -89
  31. package/dist/index.js +43 -61
  32. package/dist/index.js.map +1 -1
  33. package/dist/intelligence.d.ts +39 -59
  34. package/dist/intelligence.js +23 -33
  35. package/dist/intelligence.js.map +1 -1
  36. package/dist/kernel.d.ts +5 -5
  37. package/dist/kernel.js +11 -11
  38. package/dist/{loop-runner-CZzeeJTG.js → loop-runner-BwN9MhdP.js} +5 -6
  39. package/dist/{loop-runner-CZzeeJTG.js.map → loop-runner-BwN9MhdP.js.map} +1 -1
  40. package/dist/{loop-runner-CY5HHhtR.d.ts → loop-runner-DvfOXVx9.d.ts} +3 -5
  41. package/dist/loop-runner-bin.d.ts +5 -8
  42. package/dist/loop-runner-bin.js +2 -3
  43. package/dist/mcp/bin.js +6 -8
  44. package/dist/mcp/bin.js.map +1 -1
  45. package/dist/mcp/index.d.ts +8 -18
  46. package/dist/mcp/index.js +17 -25
  47. package/dist/mcp/index.js.map +1 -1
  48. package/dist/mcp/memory-bin.js +4 -6
  49. package/dist/mcp/memory-bin.js.map +1 -1
  50. package/dist/{model-policy-CyCUwHed.js → model-policy-GSxWwP-b.js} +11 -13
  51. package/dist/model-policy-GSxWwP-b.js.map +1 -0
  52. package/dist/placement.d.ts +12 -14
  53. package/dist/placement.js +1 -2
  54. package/dist/platform.d.ts +7 -13
  55. package/dist/platform.js +3 -6
  56. package/dist/platform.js.map +1 -1
  57. package/dist/{prepare-TEEHSJwq.js → prepare-DE8TQnLu.js} +49 -69
  58. package/dist/{prepare-TEEHSJwq.js.map → prepare-DE8TQnLu.js.map} +1 -1
  59. package/dist/{profile-6OLpbjvV.js → profile-CAhZDW2T.js} +58 -92
  60. package/dist/profile-CAhZDW2T.js.map +1 -0
  61. package/dist/{profile-materialization-bPm0gGLO.d.ts → profile-materialization-BRY22Oh8.d.ts} +1 -3
  62. package/dist/profiles.d.ts +25 -12
  63. package/dist/profiles.js +52 -11
  64. package/dist/profiles.js.map +1 -1
  65. package/dist/{protected-model-port-DVVh-hEk.d.ts → protected-model-port-IKqhTypD.d.ts} +2 -14
  66. package/dist/{protected-redaction-DFCeo4vg.js → protected-redaction-DilFZch5.js} +2 -3
  67. package/dist/{protected-redaction-DFCeo4vg.js.map → protected-redaction-DilFZch5.js.map} +1 -1
  68. package/dist/{provision-supervisor-CC0HdOHo.js → provision-supervisor-Bde_FF0R.js} +11 -15
  69. package/dist/{provision-supervisor-CC0HdOHo.js.map → provision-supervisor-Bde_FF0R.js.map} +1 -1
  70. package/dist/{record-events-D93DkpAx.js → record-events-B2GUgYdz.js} +12 -14
  71. package/dist/{record-events-D93DkpAx.js.map → record-events-B2GUgYdz.js.map} +1 -1
  72. package/dist/{run-cancellation-CzFhQGMa.js → run-cancellation-BLy_Zz-w.js} +6 -7
  73. package/dist/{run-cancellation-CzFhQGMa.js.map → run-cancellation-BLy_Zz-w.js.map} +1 -1
  74. package/dist/{runtime-B_40dXlF.js → runtime-6Ec9sHRe.js} +833 -215
  75. package/dist/runtime-6Ec9sHRe.js.map +1 -0
  76. package/dist/{runtime-hooks-tXpAarhW.js → runtime-hooks-CsW2pfFk.js} +2 -3
  77. package/dist/{runtime-hooks-tXpAarhW.js.map → runtime-hooks-CsW2pfFk.js.map} +1 -1
  78. package/dist/{runtime-hooks-nsqxSUFL.d.ts → runtime-hooks-ZQqPw-0g.d.ts} +1 -3
  79. package/dist/{sandbox-profile-compat-_fEtHPCj.js → sandbox-profile-compat-BxMQ1VXv.js} +62 -44
  80. package/dist/sandbox-profile-compat-BxMQ1VXv.js.map +1 -0
  81. package/dist/{search-executor-COd2F2wp.js → search-executor-B7g_5Wjl.js} +12 -17
  82. package/dist/search-executor-B7g_5Wjl.js.map +1 -0
  83. package/dist/{server-BGB4R4wQ.js → server-fvEMwGMQ.js} +19 -30
  84. package/dist/{server-BGB4R4wQ.js.map → server-fvEMwGMQ.js.map} +1 -1
  85. package/dist/{structural-rollout-Wl_rCuzM.js → structural-rollout-B86bSixU.js} +69 -70
  86. package/dist/structural-rollout-B86bSixU.js.map +1 -0
  87. package/dist/{substrate-CGDFTSRh.js → substrate-Db2pp6y3.js} +2 -3
  88. package/dist/{substrate-CGDFTSRh.js.map → substrate-Db2pp6y3.js.map} +1 -1
  89. package/dist/{supervise-BUOeThuB.js → supervise-CaeZcgAW.js} +615 -203
  90. package/dist/supervise-CaeZcgAW.js.map +1 -0
  91. package/dist/{supervisor-DDy0aEtR.js → supervisor-C1OePYE-.js} +526 -642
  92. package/dist/supervisor-C1OePYE-.js.map +1 -0
  93. package/dist/{task-queue-0fKkoweu.d.ts → task-queue-kefGy79U.d.ts} +1 -3
  94. package/dist/task-queue.d.ts +1 -1
  95. package/dist/task-queue.js +1 -2
  96. package/dist/testing.d.ts +8 -16
  97. package/dist/testing.js +241 -244
  98. package/dist/testing.js.map +1 -1
  99. package/dist/tool-loop.d.ts +16 -19
  100. package/dist/tool-loop.js +2 -3
  101. package/dist/{tool-server-XV4aJwoQ.js → tool-server-CwuYeW_Z.js} +3 -4
  102. package/dist/{tool-server-XV4aJwoQ.js.map → tool-server-CwuYeW_Z.js.map} +1 -1
  103. package/dist/{top-snapshot-CflmaDgk.js → top-snapshot-ChwpTr7A.js} +4 -5
  104. package/dist/{top-snapshot-CflmaDgk.js.map → top-snapshot-ChwpTr7A.js.map} +1 -1
  105. package/dist/tui/bin.js +7 -9
  106. package/dist/tui/bin.js.map +1 -1
  107. package/dist/tui/index.d.ts +3 -5
  108. package/dist/tui/index.js +2 -2
  109. package/dist/{types-hc4cmSc7.d.ts → types-Fowuwdz2.d.ts} +555 -503
  110. package/dist/{types-Cwrea-bU.d.ts → types-qsqfyQoY.d.ts} +1 -3
  111. package/dist/workspace-store/index.d.ts +12 -22
  112. package/dist/workspace-store/index.js +4 -7
  113. package/dist/workspace-store/index.js.map +1 -1
  114. package/dist/{workspace-streams-BiS4ABah.d.ts → workspace-streams-Dq2Fzk3c.d.ts} +1 -11
  115. package/package.json +25 -25
  116. package/skills/agent-graphs/SKILL.md +19 -4
  117. package/skills/be-ambitious/SKILL.md +46 -0
  118. package/skills/graph-designer/SKILL.md +15 -2
  119. package/skills/profile-authoring/SKILL.md +1 -1
  120. package/dist/coordination-manager-Bm6leXc6.js.map +0 -1
  121. package/dist/delegate-Cp5-PsaX.js.map +0 -1
  122. package/dist/graph-CE_pzU31.js.map +0 -1
  123. package/dist/model-policy-CyCUwHed.js.map +0 -1
  124. package/dist/profile-6OLpbjvV.js.map +0 -1
  125. package/dist/runtime-B_40dXlF.js.map +0 -1
  126. package/dist/sandbox-profile-compat-_fEtHPCj.js.map +0 -1
  127. package/dist/search-executor-COd2F2wp.js.map +0 -1
  128. package/dist/structural-rollout-Wl_rCuzM.js.map +0 -1
  129. package/dist/supervise-BUOeThuB.js.map +0 -1
  130. package/dist/supervisor-DDy0aEtR.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","names":[],"sources":["../../src/mcp/delegate-supervisor-provisioning.ts","../../src/mcp/bin.ts"],"sourcesContent":["/**\n *\n * Resolve the `delegate` supervisor substrate (router brain + worker backend) from env, so the\n * `agent-runtime-mcp` bin can serve the ONE generic `delegate` verb by env, over the SAME stdio\n * invocation a consumer already mounts.\n *\n * `delegate` is wired into `createMcpServer` via `McpServerOptions.delegateSupervisor`, which needs a\n * router (the supervisor brain's transport) and a backend (WHERE the authored workers run). Inside a\n * sandbox child the natural backend is `sandbox`: authored workers run as sub-sandboxes through the\n * SAME `SandboxClient` the bin already loads from its sandbox key. Dedicated MCP variables name\n * the supervisor's router connection and exact model; inherited worker/model aliases are rejected.\n *\n * @experimental\n */\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { ConfigError } from '../errors'\nimport type { SandboxClient } from '../runtime'\nimport type { RouterTransportConfig } from '../runtime/router-http-transport'\nimport { supervisorInstructions } from '../runtime/supervise/authoring'\nimport { coordinationProfileToolPrefix } from '../runtime/supervise/provider-visible-profile'\nimport type { ExecutorConfig } from '../runtime/supervise/runtime'\nimport type { DelegateHandlerOptions } from './tools/delegate'\n\nfunction trimmed(value: string | undefined): string | undefined {\n const v = value?.trim()\n return v ? v : undefined\n}\n\nfunction requiredEnv(env: NodeJS.ProcessEnv, name: string): string {\n const value = trimmed(env[name])\n if (value) return value\n throw new ConfigError(`agent-runtime-mcp: ${name} is required when MCP_ENABLE_DELEGATE=1`)\n}\n\n/** True when the operator opted the generic `delegate` verb in (`MCP_ENABLE_DELEGATE=1`). Default off:\n * the wiring is additive, so consumers that do not enable it are unaffected. */\nexport function delegateEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n return env.MCP_ENABLE_DELEGATE === '1'\n}\n\n/**\n * The Runtime verbs the authoring supervisor is granted. A profile gets no coordination tool it does\n * not declare, so without `spawn_worker` the brain is offered no tools and every delegation settles\n * `no-children-spawned`. The rest let it inspect, steer, stop, and re-read what it already spawned,\n * which its authoring instruction tells it to do.\n */\nconst delegateSupervisorVerbs = [\n 'spawn_worker',\n 'observe_agent',\n 'steer_agent',\n 'cancel_worker',\n 'read_journal',\n] as const\n\n/**\n * The `delegate` caller asked for a worker to do the task, and only a worker's settled result is\n * delivered. A capable brain otherwise answers a small intent itself (gemini-3.7-flash and kimi-k3\n * both replied to \"Reply with exactly DELEGATED-391\" directly), which settles `no-children-spawned`\n * and discards the answer.\n */\nconst delegateContract = [\n '',\n 'This task came through `delegate`: the caller wants a worker to do it. However small the task,',\n 'call spawn_worker at least once before you end your turn. Your own reply is never delivered;',\n \"only a worker's settled result is.\",\n].join('\\n')\n\n/**\n * Resolve the supervisor brain from dedicated MCP configuration. The model is part of the exact\n * profile; the URL and key are transport-only. No generic worker/model/key variable may silently\n * select this paid execution path.\n */\nfunction resolveRouterSupervisor(env: NodeJS.ProcessEnv): {\n router: RouterTransportConfig\n profile: AgentProfile\n} {\n const routerKey = requiredEnv(env, 'MCP_SUPERVISOR_ROUTER_KEY')\n const base = requiredEnv(env, 'MCP_SUPERVISOR_ROUTER_BASE_URL')\n const routerBaseUrl = /\\/v\\d+\\/?$/.test(base)\n ? base.replace(/\\/$/, '')\n : `${base.replace(/\\/$/, '')}/v1`\n const model = requiredEnv(env, 'MCP_SUPERVISOR_MODEL')\n // The consumer's own policy for the workers this supervisor authors, such as the only harness and\n // model its worker boxes can run. Without it the brain picks instruments from memory, and on\n // 2026-10-19 every one it picked (claude-code on Anthropic, nanoclaw, cli-base) died in the box.\n const consumerInstructions = trimmed(env.MCP_SUPERVISOR_INSTRUCTIONS)\n return {\n router: { routerBaseUrl, routerKey },\n profile: {\n name: 'delegate-supervisor',\n harness: 'cli-base',\n model: { provider: 'tangle-router', default: model },\n prompt: {\n systemPrompt: [\n supervisorInstructions(),\n delegateContract,\n ...(consumerInstructions ? ['', consumerInstructions] : []),\n ].join('\\n'),\n },\n tools: Object.fromEntries(\n delegateSupervisorVerbs.map((verb) => [`${coordinationProfileToolPrefix}${verb}`, true]),\n ),\n },\n }\n}\n\n/**\n * Build the `delegateSupervisor` substrate for `createMcpServer` from env + the bin's loaded\n * `SandboxClient`. Returns `undefined` when `delegate` is not opted in, so the caller mounts it only\n * when asked. The worker backend is `sandbox`; every authored worker's exact profile selects its\n * own harness/provider/model.\n */\nexport function resolveDelegateSupervisor(\n sandboxClient: SandboxClient,\n env: NodeJS.ProcessEnv = process.env,\n): DelegateHandlerOptions | undefined {\n if (!delegateEnabled(env)) return undefined\n const supervisor = resolveRouterSupervisor(env)\n const backend: ExecutorConfig = {\n backend: 'sandbox',\n sandboxClient,\n }\n return {\n router: supervisor.router,\n supervisorProfile: supervisor.profile,\n backend,\n }\n}\n","#!/usr/bin/env node\n\n/**\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Serves the ONE generic `delegate` verb (opt-in via `MCP_ENABLE_DELEGATE=1`): one intent → a\n * supervisor that authors + drives its own worker over `supervise()`, returning the delivered output\n * with its cost. The supervisor brain runs on the router; authored workers run as sub-sandboxes\n * through the `SandboxClient` the bin loads from the sandbox key. The queue-bound tools\n * (`delegate_feedback`, `delegation_status`, `delegation_history`) are always served.\n *\n * A platform key serves one product, so the Sandbox API key and the router key are separate\n * variables: the sandbox key only constructs the Sandbox client, and the router key only reaches\n * the supervisor brain. Neither is forwarded into a worker box; each worker's model access comes\n * from the box its profile provisions.\n *\n * Environment variables:\n * TANGLE_SANDBOX_API_KEY Sandbox API key passed to `new Sandbox({ apiKey })`. Falls back\n * to TANGLE_API_KEY when unset, so one key that serves the Sandbox\n * API keeps working.\n * TANGLE_API_KEY Sandbox API key when TANGLE_SANDBOX_API_KEY is unset\n * SANDBOX_BASE_URL optional — sandbox-SDK base URL override\n * MCP_ENABLE_DELEGATE set to `1` to serve the generic `delegate` verb. Its authoring\n * supervisor runs the brain on the router and spawns authored\n * workers as sub-sandboxes via the same client; needs a sandbox key.\n * MCP_SUPERVISOR_MODEL required exact supervisor brain model id\n * MCP_SUPERVISOR_ROUTER_KEY required router key for the supervisor brain\n * MCP_SUPERVISOR_ROUTER_BASE_URL required router base, normalized to `/v1`\n * MCP_SUPERVISOR_INSTRUCTIONS optional text appended to the supervisor's system prompt: the\n * caller's policy for the workers it authors, such as the harness\n * and model its worker boxes can run\n * AGENT_RUNTIME_DELEGATION_STATE_FILE\n * optional — absolute path of a JSON state\n * file. When set, delegation records persist\n * across MCP restarts (FileDelegationStore):\n * status/history survive and idempotency keys\n * dedupe across processes.\n * AGENT_RUNTIME_DELEGATION_STATE_RECOVER\n * set to `1` to archive a corrupt state file\n * (`<file>.corrupt-<ts>`) and start empty\n * instead of refusing to boot.\n * AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL\n * optional — positive integer cap on retained\n * terminal records. Unset = keep forever.\n *\n * @experimental\n */\n\nimport type { SandboxClient } from '../runtime'\nimport { delegateEnabled, resolveDelegateSupervisor } from './delegate-supervisor-provisioning'\nimport { FileDelegationStore } from './delegation-store'\nimport { createMcpServer } from './server'\nimport { DelegationTaskQueue } from './task-queue'\nimport type { DelegateHandlerOptions } from './tools/delegate'\nimport { readTraceContextFromEnv, type TraceContext } from './trace-propagation'\n\nconst DEFAULT_SANDBOX_BASE_URL = 'https://sandbox.tangle.tools'\n\nasync function main(): Promise<void> {\n const wantDelegate = delegateEnabled(process.env)\n\n // The generic `delegate` verb needs the sandbox client: its authored workers run as sub-sandboxes\n // (the `sandbox` backend). When `delegate` is not opted in, the server runs the queue-only subset\n // (feedback + status + history) with no sandbox.\n let sandboxClient: SandboxClient | undefined\n if (wantDelegate) {\n const apiKey = sandboxApiKey(process.env)\n if (!apiKey && !process.env.AGENT_RUNTIME_MCP_ALLOW_NO_KEY) {\n process.stderr.write(\n 'agent-runtime-mcp: a Sandbox API key is required to serve `delegate`: set TANGLE_SANDBOX_API_KEY (or TANGLE_API_KEY when that key serves the Sandbox API). Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or unset MCP_ENABLE_DELEGATE to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n }\n\n // The supervisor's loop topology spans export to the OTLP / Tangle Intelligence sink when\n // OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for correlation). The same\n // context is stamped onto every delegation record so journal consumers join records into the\n // caller's trace.\n const traceContext = readTraceContextFromEnv()\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 // The ONE generic `delegate` verb — opt-in via MCP_ENABLE_DELEGATE=1. Its authoring supervisor\n // runs the brain on the router and spawns authored workers as sub-sandboxes through the SAME\n // client, so it needs the loaded `sandboxClient`. Gated on the client resolving (no key → no\n // delegate, fail-closed).\n let delegateSupervisor: DelegateHandlerOptions | undefined\n if (wantDelegate && sandboxClient) {\n try {\n delegateSupervisor = resolveDelegateSupervisor(sandboxClient)\n } catch (error) {\n // Refuse to serve a verb that cannot work. Advertising `delegate` on an\n // unresolvable substrate spends an agent's turn on a tool whose first\n // inference is guaranteed to reject.\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`)\n process.exit(2)\n }\n }\n if (delegateSupervisor) {\n process.stderr.write(\n `agent-runtime-mcp: delegate enabled — generic authoring supervisor on ${delegateSupervisor.supervisorProfile.model?.default}\\n`,\n )\n }\n\n const durableQueue = await buildDurableQueueFromEnv(traceContext)\n const server = createMcpServer({\n ...(delegateSupervisor ? { delegateSupervisor } : {}),\n traceContext,\n ...(durableQueue ? { queue: durableQueue } : {}),\n })\n\n const shutdown = () => {\n server.stop()\n // Drain journal writes so the state file reflects the final record\n // states before the process exits. A persist failure already routed\n // through onPersistError; swallow the duplicate rejection here.\n if (durableQueue) {\n void durableQueue\n .flush()\n .catch(() => {})\n .finally(() => process.exit(0))\n return\n }\n process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function buildDurableQueueFromEnv(\n traceContext: TraceContext,\n): Promise<DelegationTaskQueue | undefined> {\n const stateFile = process.env.AGENT_RUNTIME_DELEGATION_STATE_FILE?.trim()\n if (!stateFile) return undefined\n const store = new FileDelegationStore({\n filePath: stateFile,\n recoverCorrupt: process.env.AGENT_RUNTIME_DELEGATION_STATE_RECOVER === '1',\n })\n const maxTerminalRecords = parseRetention(process.env.AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL)\n const queue = await DelegationTaskQueue.restore({\n store,\n traceContext,\n ...(maxTerminalRecords !== undefined ? { maxTerminalRecords } : {}),\n onPersistError: (error) => {\n // Durable mode that can no longer write is a broken contract: crash\n // loud instead of degrading to memory-only behind the caller's back.\n process.stderr.write(`agent-runtime-mcp: ${error.message}\\n`)\n process.exit(1)\n },\n })\n process.stderr.write(`agent-runtime-mcp: durable delegation state → ${stateFile}\\n`)\n return queue\n}\n\nfunction parseRetention(raw: string | undefined): number | undefined {\n if (raw === undefined || raw.trim() === '') return undefined\n const n = Number(raw)\n if (!Number.isInteger(n) || n < 1) {\n process.stderr.write(\n `agent-runtime-mcp: AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL must be a positive integer, got \"${raw}\"\\n`,\n )\n process.exit(2)\n }\n return n\n}\n\n/** The Sandbox API key: the dedicated variable when set, else the legacy single key. The router key\n * (`MCP_SUPERVISOR_ROUTER_KEY`) is read only by the supervisor provisioning. */\nfunction sandboxApiKey(env: NodeJS.ProcessEnv): string | undefined {\n return env.TANGLE_SANDBOX_API_KEY?.trim() || env.TANGLE_API_KEY?.trim() || undefined\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 // `delegate` requires a real client; the stub fails loud at create() so the\n // agent observes the cause instead of silent success.\n if (!apiKey) {\n return {\n async create() {\n throw new Error(\n 'agent-runtime-mcp: no Sandbox API key is set; `delegate` is disabled in diagnostic mode. Set TANGLE_SANDBOX_API_KEY (or TANGLE_API_KEY) or unset MCP_ENABLE_DELEGATE to remove the unsupported tool from the tool list.',\n )\n },\n } satisfies SandboxClient\n }\n // Diagnostic mode does not need a client, so defer SDK initialization until\n // delegation is requested. Runtime declares the SDK as a required peer.\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 // @tangle-network/sandbox ≥0.6 makes baseUrl required; default it so the MCP server\n // starts without forcing every caller to set SANDBOX_BASE_URL. Treat empty/whitespace as\n // unset (|| not ??) so `SANDBOX_BASE_URL=` still resolves to the default.\n const baseUrl = process.env.SANDBOX_BASE_URL?.trim() || DEFAULT_SANDBOX_BASE_URL\n return new SandboxCtor({ apiKey, baseUrl })\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":";;;;;;AAwBA,SAAS,QAAQ,OAA+C;CAC9D,MAAM,IAAI,OAAO,KAAK;CACtB,OAAO,IAAI,IAAI,KAAA;AACjB;AAEA,SAAS,YAAY,KAAwB,MAAsB;CACjE,MAAM,QAAQ,QAAQ,IAAI,KAAK;CAC/B,IAAI,OAAO,OAAO;CAClB,MAAM,IAAI,YAAY,sBAAsB,KAAK,wCAAwC;AAC3F;;;AAIA,SAAgB,gBAAgB,MAAyB,QAAQ,KAAc;CAC7E,OAAO,IAAI,wBAAwB;AACrC;;;;;;;AAQA,MAAM,0BAA0B;CAC9B;CACA;CACA;CACA;CACA;AACF;;;;;;;AAQA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;AAOX,SAAS,wBAAwB,KAG/B;CACA,MAAM,YAAY,YAAY,KAAK,2BAA2B;CAC9D,MAAM,OAAO,YAAY,KAAK,gCAAgC;CAC9D,MAAM,gBAAgB,aAAa,KAAK,IAAI,IACxC,KAAK,QAAQ,OAAO,EAAE,IACtB,GAAG,KAAK,QAAQ,OAAO,EAAE,EAAE;CAC/B,MAAM,QAAQ,YAAY,KAAK,sBAAsB;CAIrD,MAAM,uBAAuB,QAAQ,IAAI,2BAA2B;CACpE,OAAO;EACL,QAAQ;GAAE;GAAe;EAAU;EACnC,SAAS;GACP,MAAM;GACN,SAAS;GACT,OAAO;IAAE,UAAU;IAAiB,SAAS;GAAM;GACnD,QAAQ,EACN,cAAc;IACZ,uBAAuB;IACvB;IACA,GAAI,uBAAuB,CAA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KAAK,KAAK,KAAA;AAC7E;AAEA,eAAe,kBAAkB,QAAoD;CAKnF,IAAI,CAAC,QACH,OAAO,EACL,MAAM,SAAS;EACb,MAAM,IAAI,MACR,yNACF;CACF,EACF;CAUF,MAAM,eAAe,MANH,OAAO,0BAA0B,CAAC,OAAO,QAAQ;EACjE,QAAQ,OAAO,MACb,8DAA8D,IAAI,QAAQ,iCAC5E;EACA,QAAQ,KAAK,CAAC;CAChB,CAAC,EAAA,CACiF;CAClF,IAAI,CAAC,aAAa;EAChB,QAAQ,OAAO,MACb,+FACF;EACA,QAAQ,KAAK,CAAC;CAChB;CAKA,OAAO,IAAI,YAAY;EAAE;EAAQ,SADjB,QAAQ,IAAI,kBAAkB,KAAK,KAAK;CACf,CAAC;AAC5C;AAEA,KAAK,CAAC,CAAC,OAAO,QAAQ;CACpB,QAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,EAAE,GAAG;CAC7F,QAAQ,KAAK,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"bin.js","names":[],"sources":["../../src/mcp/delegate-supervisor-provisioning.ts","../../src/mcp/bin.ts"],"sourcesContent":["/**\n *\n * Resolve the `delegate` supervisor substrate (router brain + worker backend) from env, so the\n * `agent-runtime-mcp` bin can serve the ONE generic `delegate` verb by env, over the SAME stdio\n * invocation a consumer already mounts.\n *\n * `delegate` is wired into `createMcpServer` via `McpServerOptions.delegateSupervisor`, which needs a\n * router (the supervisor brain's transport) and a backend (WHERE the authored workers run). Inside a\n * sandbox child the natural backend is `sandbox`: authored workers run as sub-sandboxes through the\n * SAME `SandboxClient` the bin already loads from its sandbox key. Dedicated MCP variables name\n * the supervisor's router connection and exact model; inherited worker/model aliases are rejected.\n *\n * @experimental\n */\n\nimport type { AgentProfile } from '@tangle-network/agent-interface'\nimport { ConfigError } from '../errors'\nimport type { SandboxClient } from '../runtime'\nimport type { RouterTransportConfig } from '../runtime/router-http-transport'\nimport { supervisorInstructions } from '../runtime/supervise/authoring'\nimport { coordinationProfileToolPrefix } from '../runtime/supervise/provider-visible-profile'\nimport type { ExecutorConfig } from '../runtime/supervise/runtime'\nimport type { DelegateHandlerOptions } from './tools/delegate'\n\nfunction trimmed(value: string | undefined): string | undefined {\n const v = value?.trim()\n return v ? v : undefined\n}\n\nfunction requiredEnv(env: NodeJS.ProcessEnv, name: string): string {\n const value = trimmed(env[name])\n if (value) return value\n throw new ConfigError(`agent-runtime-mcp: ${name} is required when MCP_ENABLE_DELEGATE=1`)\n}\n\n/** True when the operator opted the generic `delegate` verb in (`MCP_ENABLE_DELEGATE=1`). Default off:\n * the wiring is additive, so consumers that do not enable it are unaffected. */\nexport function delegateEnabled(env: NodeJS.ProcessEnv = process.env): boolean {\n return env.MCP_ENABLE_DELEGATE === '1'\n}\n\n/**\n * The Runtime verbs the authoring supervisor is granted. A profile gets no coordination tool it does\n * not declare, so without `spawn_worker` the brain is offered no tools and every delegation settles\n * `no-children-spawned`. The rest let it inspect, steer, stop, and re-read what it already spawned,\n * which its authoring instruction tells it to do.\n */\nconst delegateSupervisorVerbs = [\n 'spawn_worker',\n 'observe_agent',\n 'steer_agent',\n 'cancel_worker',\n 'read_journal',\n] as const\n\n/**\n * The `delegate` caller asked for a worker to do the task, and only a worker's settled result is\n * delivered. A capable brain otherwise answers a small intent itself (gemini-3.7-flash and kimi-k3\n * both replied to \"Reply with exactly DELEGATED-391\" directly), which settles `no-children-spawned`\n * and discards the answer.\n */\nconst delegateContract = [\n '',\n 'This task came through `delegate`: the caller wants a worker to do it. However small the task,',\n 'call spawn_worker at least once before you end your turn. Your own reply is never delivered;',\n \"only a worker's settled result is.\",\n].join('\\n')\n\n/**\n * Resolve the supervisor brain from dedicated MCP configuration. The model is part of the exact\n * profile; the URL and key are transport-only. No generic worker/model/key variable may silently\n * select this paid execution path.\n */\nfunction resolveRouterSupervisor(env: NodeJS.ProcessEnv): {\n router: RouterTransportConfig\n profile: AgentProfile\n} {\n const routerKey = requiredEnv(env, 'MCP_SUPERVISOR_ROUTER_KEY')\n const base = requiredEnv(env, 'MCP_SUPERVISOR_ROUTER_BASE_URL')\n const routerBaseUrl = /\\/v\\d+\\/?$/.test(base)\n ? base.replace(/\\/$/, '')\n : `${base.replace(/\\/$/, '')}/v1`\n const model = requiredEnv(env, 'MCP_SUPERVISOR_MODEL')\n // The consumer's own policy for the workers this supervisor authors, such as the only harness and\n // model its worker boxes can run. Without it the brain picks instruments from memory, and on\n // 2026-10-19 every one it picked (claude-code on Anthropic, nanoclaw, cli-base) died in the box.\n const consumerInstructions = trimmed(env.MCP_SUPERVISOR_INSTRUCTIONS)\n return {\n router: { routerBaseUrl, routerKey },\n profile: {\n name: 'delegate-supervisor',\n harness: 'cli-base',\n model: { provider: 'tangle-router', default: model },\n prompt: {\n systemPrompt: [\n supervisorInstructions(),\n delegateContract,\n ...(consumerInstructions ? ['', consumerInstructions] : []),\n ].join('\\n'),\n },\n tools: Object.fromEntries(\n delegateSupervisorVerbs.map((verb) => [`${coordinationProfileToolPrefix}${verb}`, true]),\n ),\n },\n }\n}\n\n/**\n * Build the `delegateSupervisor` substrate for `createMcpServer` from env + the bin's loaded\n * `SandboxClient`. Returns `undefined` when `delegate` is not opted in, so the caller mounts it only\n * when asked. The worker backend is `sandbox`; every authored worker's exact profile selects its\n * own harness/provider/model.\n */\nexport function resolveDelegateSupervisor(\n sandboxClient: SandboxClient,\n env: NodeJS.ProcessEnv = process.env,\n): DelegateHandlerOptions | undefined {\n if (!delegateEnabled(env)) return undefined\n const supervisor = resolveRouterSupervisor(env)\n const backend: ExecutorConfig = {\n backend: 'sandbox',\n sandboxClient,\n }\n return {\n router: supervisor.router,\n supervisorProfile: supervisor.profile,\n backend,\n }\n}\n","#!/usr/bin/env node\n\n/**\n *\n * `agent-runtime-mcp` — stdio MCP server entry point.\n *\n * Serves the ONE generic `delegate` verb (opt-in via `MCP_ENABLE_DELEGATE=1`): one intent → a\n * supervisor that authors + drives its own worker over `supervise()`, returning the delivered output\n * with its cost. The supervisor brain runs on the router; authored workers run as sub-sandboxes\n * through the `SandboxClient` the bin loads from the sandbox key. The queue-bound tools\n * (`delegate_feedback`, `delegation_status`, `delegation_history`) are always served.\n *\n * A platform key serves one product, so the Sandbox API key and the router key are separate\n * variables: the sandbox key only constructs the Sandbox client, and the router key only reaches\n * the supervisor brain. Neither is forwarded into a worker box; each worker's model access comes\n * from the box its profile provisions.\n *\n * Environment variables:\n * TANGLE_SANDBOX_API_KEY Sandbox API key passed to `new Sandbox({ apiKey })`. Falls back\n * to TANGLE_API_KEY when unset, so one key that serves the Sandbox\n * API keeps working.\n * TANGLE_API_KEY Sandbox API key when TANGLE_SANDBOX_API_KEY is unset\n * SANDBOX_BASE_URL optional — sandbox-SDK base URL override\n * MCP_ENABLE_DELEGATE set to `1` to serve the generic `delegate` verb. Its authoring\n * supervisor runs the brain on the router and spawns authored\n * workers as sub-sandboxes via the same client; needs a sandbox key.\n * MCP_SUPERVISOR_MODEL required exact supervisor brain model id\n * MCP_SUPERVISOR_ROUTER_KEY required router key for the supervisor brain\n * MCP_SUPERVISOR_ROUTER_BASE_URL required router base, normalized to `/v1`\n * MCP_SUPERVISOR_INSTRUCTIONS optional text appended to the supervisor's system prompt: the\n * caller's policy for the workers it authors, such as the harness\n * and model its worker boxes can run\n * AGENT_RUNTIME_DELEGATION_STATE_FILE\n * optional — absolute path of a JSON state\n * file. When set, delegation records persist\n * across MCP restarts (FileDelegationStore):\n * status/history survive and idempotency keys\n * dedupe across processes.\n * AGENT_RUNTIME_DELEGATION_STATE_RECOVER\n * set to `1` to archive a corrupt state file\n * (`<file>.corrupt-<ts>`) and start empty\n * instead of refusing to boot.\n * AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL\n * optional — positive integer cap on retained\n * terminal records. Unset = keep forever.\n *\n * @experimental\n */\n\nimport type { SandboxClient } from '../runtime'\nimport { delegateEnabled, resolveDelegateSupervisor } from './delegate-supervisor-provisioning'\nimport { FileDelegationStore } from './delegation-store'\nimport { createMcpServer } from './server'\nimport { DelegationTaskQueue } from './task-queue'\nimport type { DelegateHandlerOptions } from './tools/delegate'\nimport { readTraceContextFromEnv, type TraceContext } from './trace-propagation'\n\nconst DEFAULT_SANDBOX_BASE_URL = 'https://sandbox.tangle.tools'\n\nasync function main(): Promise<void> {\n const wantDelegate = delegateEnabled(process.env)\n\n // The generic `delegate` verb needs the sandbox client: its authored workers run as sub-sandboxes\n // (the `sandbox` backend). When `delegate` is not opted in, the server runs the queue-only subset\n // (feedback + status + history) with no sandbox.\n let sandboxClient: SandboxClient | undefined\n if (wantDelegate) {\n const apiKey = sandboxApiKey(process.env)\n if (!apiKey && !process.env.AGENT_RUNTIME_MCP_ALLOW_NO_KEY) {\n process.stderr.write(\n 'agent-runtime-mcp: a Sandbox API key is required to serve `delegate`: set TANGLE_SANDBOX_API_KEY (or TANGLE_API_KEY when that key serves the Sandbox API). Set AGENT_RUNTIME_MCP_ALLOW_NO_KEY=1 to run without it for diagnostics, or unset MCP_ENABLE_DELEGATE to run the queue-only subset.\\n',\n )\n process.exit(2)\n }\n sandboxClient = await loadSandboxClient(apiKey)\n }\n\n // The supervisor's loop topology spans export to the OTLP / Tangle Intelligence sink when\n // OTEL_EXPORTER_OTLP_ENDPOINT is set (+ TRACE_ID / PARENT_SPAN_ID for correlation). The same\n // context is stamped onto every delegation record so journal consumers join records into the\n // caller's trace.\n const traceContext = readTraceContextFromEnv()\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 // The ONE generic `delegate` verb — opt-in via MCP_ENABLE_DELEGATE=1. Its authoring supervisor\n // runs the brain on the router and spawns authored workers as sub-sandboxes through the SAME\n // client, so it needs the loaded `sandboxClient`. Gated on the client resolving (no key → no\n // delegate, fail-closed).\n let delegateSupervisor: DelegateHandlerOptions | undefined\n if (wantDelegate && sandboxClient) {\n try {\n delegateSupervisor = resolveDelegateSupervisor(sandboxClient)\n } catch (error) {\n // Refuse to serve a verb that cannot work. Advertising `delegate` on an\n // unresolvable substrate spends an agent's turn on a tool whose first\n // inference is guaranteed to reject.\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`)\n process.exit(2)\n }\n }\n if (delegateSupervisor) {\n process.stderr.write(\n `agent-runtime-mcp: delegate enabled — generic authoring supervisor on ${delegateSupervisor.supervisorProfile.model?.default}\\n`,\n )\n }\n\n const durableQueue = await buildDurableQueueFromEnv(traceContext)\n const server = createMcpServer({\n ...(delegateSupervisor ? { delegateSupervisor } : {}),\n traceContext,\n ...(durableQueue ? { queue: durableQueue } : {}),\n })\n\n const shutdown = () => {\n server.stop()\n // Drain journal writes so the state file reflects the final record\n // states before the process exits. A persist failure already routed\n // through onPersistError; swallow the duplicate rejection here.\n if (durableQueue) {\n void durableQueue\n .flush()\n .catch(() => {})\n .finally(() => process.exit(0))\n return\n }\n process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n await server.serve()\n}\n\nasync function buildDurableQueueFromEnv(\n traceContext: TraceContext,\n): Promise<DelegationTaskQueue | undefined> {\n const stateFile = process.env.AGENT_RUNTIME_DELEGATION_STATE_FILE?.trim()\n if (!stateFile) return undefined\n const store = new FileDelegationStore({\n filePath: stateFile,\n recoverCorrupt: process.env.AGENT_RUNTIME_DELEGATION_STATE_RECOVER === '1',\n })\n const maxTerminalRecords = parseRetention(process.env.AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL)\n const queue = await DelegationTaskQueue.restore({\n store,\n traceContext,\n ...(maxTerminalRecords !== undefined ? { maxTerminalRecords } : {}),\n onPersistError: (error) => {\n // Durable mode that can no longer write is a broken contract: crash\n // loud instead of degrading to memory-only behind the caller's back.\n process.stderr.write(`agent-runtime-mcp: ${error.message}\\n`)\n process.exit(1)\n },\n })\n process.stderr.write(`agent-runtime-mcp: durable delegation state → ${stateFile}\\n`)\n return queue\n}\n\nfunction parseRetention(raw: string | undefined): number | undefined {\n if (raw === undefined || raw.trim() === '') return undefined\n const n = Number(raw)\n if (!Number.isInteger(n) || n < 1) {\n process.stderr.write(\n `agent-runtime-mcp: AGENT_RUNTIME_DELEGATION_RETAIN_TERMINAL must be a positive integer, got \"${raw}\"\\n`,\n )\n process.exit(2)\n }\n return n\n}\n\n/** The Sandbox API key: the dedicated variable when set, else the legacy single key. The router key\n * (`MCP_SUPERVISOR_ROUTER_KEY`) is read only by the supervisor provisioning. */\nfunction sandboxApiKey(env: NodeJS.ProcessEnv): string | undefined {\n return env.TANGLE_SANDBOX_API_KEY?.trim() || env.TANGLE_API_KEY?.trim() || undefined\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 // `delegate` requires a real client; the stub fails loud at create() so the\n // agent observes the cause instead of silent success.\n if (!apiKey) {\n return {\n async create() {\n throw new Error(\n 'agent-runtime-mcp: no Sandbox API key is set; `delegate` is disabled in diagnostic mode. Set TANGLE_SANDBOX_API_KEY (or TANGLE_API_KEY) or unset MCP_ENABLE_DELEGATE to remove the unsupported tool from the tool list.',\n )\n },\n } satisfies SandboxClient\n }\n // Diagnostic mode does not need a client, so defer SDK initialization until\n // delegation is requested. Runtime declares the SDK as a required peer.\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 // @tangle-network/sandbox ≥0.6 makes baseUrl required; default it so the MCP server\n // starts without forcing every caller to set SANDBOX_BASE_URL. Treat empty/whitespace as\n // unset (|| not ??) so `SANDBOX_BASE_URL=` still resolves to the default.\n const baseUrl = process.env.SANDBOX_BASE_URL?.trim() || DEFAULT_SANDBOX_BASE_URL\n return new SandboxCtor({ apiKey, baseUrl })\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":";;;;;;AAwBA,SAAS,QAAQ,OAA+C;CAC9D,MAAM,IAAI,OAAO,KAAK;CACtB,OAAO,IAAI,IAAI,KAAA;AACjB;AAEA,SAAS,YAAY,KAAwB,MAAsB;CACjE,MAAM,QAAQ,QAAQ,IAAI,KAAK;CAC/B,IAAI,OAAO,OAAO;CAClB,MAAM,IAAI,YAAY,sBAAsB,KAAK,wCAAwC;AAC3F;;;AAIA,SAAgB,gBAAgB,MAAyB,QAAQ,KAAc;CAC7E,OAAO,IAAI,wBAAwB;AACrC;;;;;;;AAQA,MAAM,0BAA0B;CAC9B;CACA;CACA;CACA;CACA;AACF;;;;;;;AAQA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;AAOX,SAAS,wBAAwB,KAG/B;CACA,MAAM,YAAY,YAAY,KAAK,2BAA2B;CAC9D,MAAM,OAAO,YAAY,KAAK,gCAAgC;CAC9D,MAAM,gBAAgB,aAAa,KAAK,IAAI,IACxC,KAAK,QAAQ,OAAO,EAAE,IACtB,GAAG,KAAK,QAAQ,OAAO,EAAE,EAAE;CAC/B,MAAM,QAAQ,YAAY,KAAK,sBAAsB;CAIrD,MAAM,uBAAuB,QAAQ,IAAI,2BAA2B;CACpE,OAAO;EACL,QAAQ;GAAE;GAAe;EAAU;EACnC,SAAS;GACP,MAAM;GACN,SAAS;GACT,OAAO;IAAE,UAAU;IAAiB,SAAS;GAAM;GACnD,QAAQ,EACN,cAAc;IACZ,uBAAuB;IACvB;IACA,GAAI,uBAAuB,CAAC,IAAI,oBAAoB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;AAC7E;AAEA,eAAe,kBAAkB,QAAoD;CAKnF,IAAI,CAAC,QACH,OAAO,EACL,MAAM,SAAS;EACb,MAAM,IAAI,MACR,yNACF;CACF,EACF;CAUF,MAAM,eAAe,MANH,OAAO,0BAA0B,CAAC,OAAO,QAAQ;EACjE,QAAQ,OAAO,MACb,8DAA8D,IAAI,QAAQ,iCAC5E;EACA,QAAQ,KAAK,CAAC;CAChB,CAAC,EAAA,CACiF;CAClF,IAAI,CAAC,aAAa;EAChB,QAAQ,OAAO,MACb,+FACF;EACA,QAAQ,KAAK,CAAC;CAChB;CAKA,OAAO,IAAI,YAAY;EAAE;EAAQ,SADjB,QAAQ,IAAI,kBAAkB,KAAK,KAAK;CACf,CAAC;AAC5C;AAEA,KAAK,CAAC,CAAC,OAAO,QAAQ;CACpB,QAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,EAAE,GAAG;CAC7F,QAAQ,KAAK,CAAC;AAChB,CAAC"}
@@ -1,6 +1,5 @@
1
- import { Ah as SubmitInput, Ap as environmentReader, Av as QuestionLevel, Ay as AnalystRegistry, Bh as DelegationFeedbackSnapshot, By as LOCAL_HARNESSES, Ch as DelegationRecord, Dh as DelegationRunContext, Dp as SpawnResourceBytes, Eh as DelegationResumeTick, Ep as ResolvedSpawnResourcePath, Fh as DelegateResearchConfig, Fp as DelegateError, Gh as DelegationStatus, Hh as DelegationHistoryEntry, Ih as DelegateUiAuditArgs, Ip as DelegateHandlerOptions, Jh as FeedbackRefersTo, Kh as DelegationStatusResult, Lh as DelegateUiAuditConfig, Lp as DelegateResult, Mh as DelegateCodeArgs, Mp as McpServer, Nh as DelegateCodeConfig, Np as McpServerOptions, Oh as DelegationTaskQueue, Op as SpawnResourceRead, Ph as DelegateResearchArgs, Pp as createMcpServer, Pv as QuestionUrgency, Rh as DelegateUiAuditRoute, Rp as createDelegateHandler, Ry as RunLocalHarnessOptions, Sh as DelegationArgs, St as SpawnRefusalCause, Th as DelegationResumeDriver, Tp as ResolveSpawnResourcePathsResult, Tv as Question, Uh as DelegationProgress, Vh as DelegationHistoryArgs, Vy as LocalHarness, Wh as DelegationResultPayload, Xh as UiAuditLensFilter, Yh as ResearchOutputShape, Zh as UiAuditorDelegationOutput, _g as FileDelegationStoreOptions, _h as createFleetWorkspaceExecutor, ah as CoderDelegate, bh as RunDetachedTurnOptions, ch as DelegateRunCtx, cv as CoordinationEvent, dg as readTraceContextFromEnv, dh as UiAuditorDelegate, dp as CheckRead, dt as CoordinationStats, fg as DelegationTraceSpan, fh as detachedSessionDelegate, ft as CoordinationTools, fv as ManagerWake, fy as JsonRpcMessage, gg as FileDelegationStore, gh as SiblingSandboxExecutorOptions, gt as MakeWorkerAgent, gy as McpTransport, hg as DelegationStore, hh as FleetWorkspaceExecutorOptions, hy as McpToolDescriptor, ih as FeedbackStore, jh as SubmitOutput, jp as resolveSpawnResourcePaths, jv as QuestionOption, kh as DelegationTaskQueueOptions, kp as SpawnResourceReader, lg as TraceContext, lh as DetachedSessionDelegateOptions, mg as DelegationPersistenceError, mh as FleetHandle, my as McpToolAnnotations, oh as CoderReview, ov as GitRunner, pg as composeLoopTraceEmitters, ph as DelegationExecutor, pt as CoordinationToolsOptions, py as JsonRpcResponse, qh as FeedbackRating, rh as FeedbackEvent, sh as CoderReviewer, sv as AwaitWakeInput, ug as createPropagatingTraceEmitter, uh as DetachedWinnerSelection, vg as CoderOutput, vh as createSiblingSandboxExecutor, wh as DelegationResumeContext, wt as WorkerSpawnContext, xh as runDetachedTurn, yg as CoderTask, yh as DetachedTurn, zh as DelegationError, zy as runLocalHarness } from "../types-hc4cmSc7.js";
1
+ import { $h as DelegationRunContext, $p as SpawnResourceBytes, Ah as FeedbackStore, Bg as DelegationPersistenceError, Bh as FleetHandle, By as JsonRpcResponse, Cg as UiAuditorDelegationOutput, Fg as TraceContext, Fh as DetachedSessionDelegateOptions, Fv as CoordinationEvent, Gg as CoderTask, Gh as DetachedTurn, Hg as FileDelegationStore, Hh as SiblingSandboxExecutorOptions, Hy as McpToolDescriptor, Ig as createPropagatingTraceEmitter, Ih as DetachedWinnerSelection, Jh as DelegationArgs, Kh as RunDetachedTurnOptions, Lg as readTraceContextFromEnv, Lh as UiAuditorDelegate, Lp as CheckRead, Mh as CoderReview, Nh as CoderReviewer, Nv as GitRunner, Ph as DelegateRunCtx, Pv as AwaitWakeInput, Qh as DelegationResumeTick, Qp as ResolvedSpawnResourcePath, Qv as Question, Rg as DelegationTraceSpan, Rh as detachedSessionDelegate, Sg as UiAuditLensFilter, St as SpawnRefusalCause, Ug as FileDelegationStoreOptions, Uh as createFleetWorkspaceExecutor, Uy as McpTransport, Vg as DelegationStore, Vh as FleetWorkspaceExecutorOptions, Vy as McpToolAnnotations, Wg as CoderOutput, Wh as createSiblingSandboxExecutor, Xh as DelegationResumeContext, Yh as DelegationRecord, Zh as DelegationResumeDriver, Zp as ResolveSpawnResourcePathsResult, _g as DelegationStatus, ag as DelegateCodeConfig, am as McpServerOptions, bg as FeedbackRefersTo, cg as DelegateUiAuditArgs, cm as DelegateHandlerOptions, db as RunLocalHarnessOptions, dg as DelegationError, dt as CoordinationStats, eg as DelegationTaskQueue, em as SpawnResourceRead, fb as runLocalHarness, fg as DelegationFeedbackSnapshot, ft as CoordinationTools, gg as DelegationResultPayload, gt as MakeWorkerAgent, hg as DelegationProgress, ig as DelegateCodeArgs, im as McpServer, iy as QuestionOption, jh as CoderDelegate, kh as FeedbackEvent, lg as DelegateUiAuditConfig, lm as DelegateResult, mb as LocalHarness, mg as DelegationHistoryEntry, ng as SubmitInput, nm as environmentReader, og as DelegateResearchArgs, om as createMcpServer, pb as LOCAL_HARNESSES, pg as DelegationHistoryArgs, pt as CoordinationToolsOptions, qh as runDetachedTurn, rb as AnalystRegistry, rg as SubmitOutput, rm as resolveSpawnResourcePaths, ry as QuestionLevel, sg as DelegateResearchConfig, sm as DelegateError, sy as QuestionUrgency, tg as DelegationTaskQueueOptions, tm as SpawnResourceReader, ug as DelegateUiAuditRoute, um as createDelegateHandler, vg as DelegationStatusResult, wt as WorkerSpawnContext, xg as ResearchOutputShape, yg as FeedbackRating, zg as composeLoopTraceEmitters, zh as DelegationExecutor, zv as ManagerWake, zy as JsonRpcMessage } from "../types-Fowuwdz2.js";
2
2
  import { HarnessType } from "@tangle-network/agent-interface";
3
- //#region src/mcp/kb-gate.d.ts
4
3
  /**
5
4
  *
6
5
  * `createKbGate` — the valid-only knowledge-base growth gate, distilled from
@@ -76,9 +75,7 @@ interface CreateKbGateOptions {
76
75
  *
77
76
  * @experimental
78
77
  */
79
- declare function createKbGate(options?: CreateKbGateOptions): (candidate: FactCandidate) => Promise<KbGateResult>;
80
- //#endregion
81
- //#region src/mcp/harness-native-tools.d.ts
78
+ export declare function createKbGate(options?: CreateKbGateOptions): (candidate: FactCandidate) => Promise<KbGateResult>;
82
79
  /**
83
80
  * Sourced native sub-agent tool names, keyed by the same `HarnessType` vocabulary the rest of the
84
81
  * runtime draws harness names from, so a harness the interface renames is a compile error here.
@@ -94,16 +91,14 @@ type SourcedHarness = keyof typeof harnessNativeTools;
94
91
  * The tool names `harness` publishes natively, or `undefined` when no list has been sourced for it.
95
92
  * The two are different facts and a caller must not read one as the other.
96
93
  */
97
- declare function harnessNativeToolNames(harness: HarnessType): ReadonlyArray<string> | undefined;
94
+ export declare function harnessNativeToolNames(harness: HarnessType): ReadonlyArray<string> | undefined;
98
95
  /**
99
96
  * The sourced harnesses that publish `name` natively — empty when the name is clear of all of them.
100
97
  *
101
98
  * The comparison folds case. A model resolving a bare word out of a prompt does not hold the
102
99
  * harness's exact casing, so `task` and `Task` are one collision, not two distinct names.
103
100
  */
104
- declare function collidesWithHarnessNativeTool(name: string): ReadonlyArray<SourcedHarness>;
105
- //#endregion
106
- //#region src/mcp/in-process-executor.d.ts
101
+ export declare function collidesWithHarnessNativeTool(name: string): ReadonlyArray<SourcedHarness>;
107
102
  /** @experimental */
108
103
  interface InProcessExecutorOptions {
109
104
  /** Absolute path to the git repo (the workspace). Worktrees go under `<repoRoot>/.agent-worktrees/`. */
@@ -140,9 +135,7 @@ interface InProcessExecutorOptions {
140
135
  *
141
136
  * @experimental
142
137
  */
143
- declare function createInProcessExecutor(options: InProcessExecutorOptions): DelegationExecutor;
144
- //#endregion
145
- //#region src/mcp/tool-server.d.ts
138
+ export declare function createInProcessExecutor(options: InProcessExecutorOptions): DelegationExecutor;
146
139
  /** @experimental */
147
140
  interface StdioToolServerOptions {
148
141
  /** Server display name surfaced via `initialize`. */
@@ -164,11 +157,8 @@ interface StdioToolServer {
164
157
  stop(): void;
165
158
  }
166
159
  /** Build the generic stdio JSON-RPC tool server. */
167
- declare function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer;
168
- //#endregion
169
- //#region src/mcp/tools/coordination-manager.d.ts
160
+ export declare function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer;
170
161
  /** Build the driver's MCP tools over a live scope. */
171
- declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
172
- //#endregion
173
- export { type AnalystRegistry, type AwaitWakeInput, type CheckRead, type CoderDelegate, type CoderOutput, type CoderReview, type CoderReviewer, type CoderTask, type CoordinationEvent, type CoordinationStats, type CoordinationTools, type CoordinationToolsOptions, type CreateKbGateOptions, type DelegateCodeArgs, type DelegateCodeConfig, type DelegateError, type DelegateHandlerOptions, type DelegateResearchArgs, type DelegateResearchConfig, type DelegateResult, type DelegateRunCtx, type DelegateUiAuditArgs, type DelegateUiAuditConfig, type DelegateUiAuditRoute, type DelegationArgs, type DelegationError, type DelegationExecutor, type DelegationFeedbackSnapshot, type DelegationHistoryArgs, type DelegationHistoryEntry, type DelegationPersistenceError, type DelegationProgress, type DelegationRecord, type DelegationResultPayload, type DelegationResumeContext, type DelegationResumeDriver, type DelegationResumeTick, type DelegationRunContext, type DelegationStatus, type DelegationStatusResult, type DelegationStore, DelegationTaskQueue, type DelegationTaskQueueOptions, type DelegationTraceSpan, type DetachedSessionDelegateOptions, type DetachedTurn, type DetachedWinnerSelection, type FactCandidate, type FactJudge, type FactJudgeVerdict, type FeedbackEvent, type FeedbackRating, type FeedbackRefersTo, type FeedbackStore, FileDelegationStore, type FileDelegationStoreOptions, type FleetHandle, type FleetWorkspaceExecutorOptions, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, type KbGateResult, LOCAL_HARNESSES, type LocalHarness, type MakeWorkerAgent, type ManagerWake, type McpServer, type McpServerOptions, type McpToolAnnotations, type McpToolDescriptor, type McpTransport, type Question, type QuestionLevel, type QuestionOption, type QuestionUrgency, type ResearchOutputShape, type ResolveSpawnResourcePathsResult, type ResolvedSpawnResourcePath, type RunDetachedTurnOptions, type RunLocalHarnessOptions, type SiblingSandboxExecutorOptions, type SpawnRefusalCause, type SpawnResourceBytes, type SpawnResourceRead, type SpawnResourceReader, type StdioToolServer, type StdioToolServerOptions, type SubmitInput, type SubmitOutput, type TraceContext, type UiAuditLensFilter, type UiAuditorDelegate, type UiAuditorDelegationOutput, type WorkerSpawnContext, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateHandler, createFleetWorkspaceExecutor, createInProcessExecutor, createKbGate, createMcpServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, detachedSessionDelegate, environmentReader, harnessNativeToolNames, readTraceContextFromEnv, resolveSpawnResourcePaths, runDetachedTurn };
162
+ export declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
163
+ export { type AnalystRegistry, type AwaitWakeInput, type CheckRead, type CoderDelegate, type CoderOutput, type CoderReview, type CoderReviewer, type CoderTask, type CoordinationEvent, type CoordinationStats, type CoordinationTools, type CoordinationToolsOptions, type CreateKbGateOptions, type DelegateCodeArgs, type DelegateCodeConfig, type DelegateError, type DelegateHandlerOptions, type DelegateResearchArgs, type DelegateResearchConfig, type DelegateResult, type DelegateRunCtx, type DelegateUiAuditArgs, type DelegateUiAuditConfig, type DelegateUiAuditRoute, type DelegationArgs, type DelegationError, type DelegationExecutor, type DelegationFeedbackSnapshot, type DelegationHistoryArgs, type DelegationHistoryEntry, type DelegationPersistenceError, type DelegationProgress, type DelegationRecord, type DelegationResultPayload, type DelegationResumeContext, type DelegationResumeDriver, type DelegationResumeTick, type DelegationRunContext, type DelegationStatus, type DelegationStatusResult, type DelegationStore, DelegationTaskQueue, type DelegationTaskQueueOptions, type DelegationTraceSpan, type DetachedSessionDelegateOptions, type DetachedTurn, type DetachedWinnerSelection, type FactCandidate, type FactJudge, type FactJudgeVerdict, type FeedbackEvent, type FeedbackRating, type FeedbackRefersTo, type FeedbackStore, FileDelegationStore, type FileDelegationStoreOptions, type FleetHandle, type FleetWorkspaceExecutorOptions, type InProcessExecutorOptions, type JsonRpcMessage, type JsonRpcResponse, type KbGateResult, LOCAL_HARNESSES, type LocalHarness, type MakeWorkerAgent, type ManagerWake, type McpServer, type McpServerOptions, type McpToolAnnotations, type McpToolDescriptor, type McpTransport, type Question, type QuestionLevel, type QuestionOption, type QuestionUrgency, type ResearchOutputShape, type ResolveSpawnResourcePathsResult, type ResolvedSpawnResourcePath, type RunDetachedTurnOptions, type RunLocalHarnessOptions, type SiblingSandboxExecutorOptions, type SpawnRefusalCause, type SpawnResourceBytes, type SpawnResourceRead, type SpawnResourceReader, type StdioToolServer, type StdioToolServerOptions, type SubmitInput, type SubmitOutput, type TraceContext, type UiAuditLensFilter, type UiAuditorDelegate, type UiAuditorDelegationOutput, type WorkerSpawnContext, composeLoopTraceEmitters, createDelegateHandler, createFleetWorkspaceExecutor, createMcpServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, detachedSessionDelegate, environmentReader, readTraceContextFromEnv, resolveSpawnResourcePaths, runDetachedTurn };
174
164
  //# sourceMappingURL=index.d.ts.map
package/dist/mcp/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { $ as resolveSpawnResourcePaths, Br as LOCAL_HARNESSES, Ft as assertBoxlessPromptOptions, Lt as createSandboxForSpec, Pt as runAgentRounds, Q as environmentReader, vn as createPropagatingTraceEmitter, yn as readTraceContextFromEnv, zr as runWorktreeHarness } from "../supervisor-DDy0aEtR.js";
2
- import { i as ConfigError, m as ValidationError } from "../errors-DodWX-cb.js";
3
- import { Y as deleteBoxSafe, lt as throwIfAborted, ot as sleep } from "../sandbox-profile-compat-_fEtHPCj.js";
4
- import { t as assertExecutableAgentProfile } from "../model-policy-CyCUwHed.js";
5
- import { t as createCoordinationTools } from "../coordination-manager-Bm6leXc6.js";
6
- import { n as createStdioToolServer } from "../tool-server-XV4aJwoQ.js";
7
- import { ct as selectValidWinner, h as runCoderChecks } from "../runtime-B_40dXlF.js";
8
- import { a as composeLoopTraceEmitters, i as FileDelegationStore, n as createDelegateHandler, r as DelegationTaskQueue, t as createMcpServer } from "../server-BGB4R4wQ.js";
1
+ import { $ as resolveSpawnResourcePaths, Br as runWorktreeHarness, Ft as assertBoxlessPromptOptions, Lt as createSandboxForSpec, Pt as runAgentRounds, Q as environmentReader, Vr as LOCAL_HARNESSES, vn as createPropagatingTraceEmitter, yn as readTraceContextFromEnv } from "../supervisor-C1OePYE-.js";
2
+ import { i as ConfigError, m as ValidationError } from "../errors-wuhGvpE3.js";
3
+ import { X as deleteBoxSafe, st as sleep, ut as throwIfAborted } from "../sandbox-profile-compat-BxMQ1VXv.js";
4
+ import { t as assertExecutableAgentProfile } from "../model-policy-GSxWwP-b.js";
5
+ import { t as createCoordinationTools } from "../coordination-manager-BkVfWlMz.js";
6
+ import { n as createStdioToolServer } from "../tool-server-CwuYeW_Z.js";
7
+ import { h as runCoderChecks, pt as selectValidWinner } from "../runtime-6Ec9sHRe.js";
8
+ import { a as composeLoopTraceEmitters, i as FileDelegationStore, n as createDelegateHandler, r as DelegationTaskQueue, t as createMcpServer } from "../server-fvEMwGMQ.js";
9
9
  import { agentProfileSchema } from "@tangle-network/agent-interface";
10
10
  import { isRecord } from "@tangle-network/agent-core";
11
11
  import { randomUUID } from "node:crypto";
12
- //#region src/mcp/kb-gate.ts
12
+ // src/mcp/kb-gate.ts
13
13
  const norm = (s) => s.toLowerCase().replace(/\s+/g, " ").trim();
14
14
  /** Does `value` appear in the (normalized) passage — literally, comma-grouped,
15
15
  * or in billion/million shorthand (the forms a source actually writes). */
@@ -85,8 +85,7 @@ function createKbGate(options = {}) {
85
85
  return { accepted: true };
86
86
  };
87
87
  }
88
- //#endregion
89
- //#region src/profiles/coder.ts
88
+ // src/profiles/coder.ts
90
89
  /**
91
90
  *
92
91
  * `CoderTask` + `coderTaskToPrompt` — the per-task DATA + pure formatter for code-modification tasks
@@ -122,8 +121,7 @@ function coderTaskToPrompt(task) {
122
121
  "returning. Emit the final JSON result block exactly as instructed."
123
122
  ].join("\n");
124
123
  }
125
- //#endregion
126
- //#region src/mcp/detached-coder.ts
124
+ // src/mcp/detached-coder.ts
127
125
  /**
128
126
  *
129
127
  * Sandbox-session coder decode layer. The sandbox-session delegate (`./delegates`) and the
@@ -371,8 +369,7 @@ function toFiniteInt(value) {
371
369
  if (!Number.isFinite(value)) return 0;
372
370
  return Math.max(0, Math.trunc(value));
373
371
  }
374
- //#endregion
375
- //#region src/mcp/detached-turn.ts
372
+ // src/mcp/detached-turn.ts
376
373
  const DEFAULT_TICK_INTERVAL_MS = 5e3;
377
374
  /**
378
375
  * Encode ref parts into the JSON-safe string stored on the record:
@@ -586,8 +583,7 @@ function createDetachedTurnTrace(options) {
586
583
  function detachedRunningPhase(elapsedMs) {
587
584
  return elapsedMs === void 0 ? "detached-running" : `detached-running ${Math.round(elapsedMs / 1e3)}s`;
588
585
  }
589
- //#endregion
590
- //#region src/mcp/executor.ts
586
+ // src/mcp/executor.ts
591
587
  /**
592
588
  * Wrap a raw sandbox SDK client so the kernel emits
593
589
  * `loop.iteration.dispatch` events with `{ placement: 'sibling', sandboxId }`.
@@ -669,8 +665,7 @@ function readId(box) {
669
665
  const raw = box.id;
670
666
  return typeof raw === "string" && raw.length > 0 ? raw : void 0;
671
667
  }
672
- //#endregion
673
- //#region src/mcp/delegates.ts
668
+ // src/mcp/delegates.ts
674
669
  /**
675
670
  * Build the sandbox-session coder delegate. It drives `runAgentRounds` against the project's
676
671
  * sandbox client + coder profile; when `args.variants > 1` it switches to the multi-harness fanout
@@ -927,8 +922,7 @@ const singleShotDriver = {
927
922
  return history.length > 0 ? "pick-winner" : "fail";
928
923
  }
929
924
  };
930
- //#endregion
931
- //#region src/mcp/harness-native-tools.ts
925
+ // src/mcp/harness-native-tools.ts
932
926
  /**
933
927
  * Sourced native sub-agent tool names, keyed by the same `HarnessType` vocabulary the rest of the
934
928
  * runtime draws harness names from, so a harness the interface renames is a compile error here.
@@ -973,8 +967,7 @@ function collidesWithHarnessNativeTool(name) {
973
967
  const wanted = name.toLowerCase();
974
968
  return sourcedHarnesses.filter((harness) => harnessNativeTools[harness].some((native) => native.toLowerCase() === wanted));
975
969
  }
976
- //#endregion
977
- //#region src/mcp/in-process-executor.ts
970
+ // src/mcp/in-process-executor.ts
978
971
  /**
979
972
  *
980
973
  * In-process delegation executor — when `agent-runtime-mcp` runs inside a sandbox whose image
@@ -993,7 +986,7 @@ function collidesWithHarnessNativeTool(name) {
993
986
  *
994
987
  * @experimental
995
988
  */
996
- const DEFAULT_POSTCHECK_TIMEOUT_MS = 120 * 1e3;
989
+ const DEFAULT_POSTCHECK_TIMEOUT_MS = 12e4;
997
990
  /**
998
991
  * Build an in-process executor. Returns a {@link DelegationExecutor} whose `client.create()`
999
992
  * returns a minimal virtual `SandboxInstance`; the kernel calls `streamPrompt(msg)` on it, which
@@ -1154,7 +1147,6 @@ async function defaultRunPostCheck(cmd, cwd, signal) {
1154
1147
  });
1155
1148
  });
1156
1149
  }
1157
- //#endregion
1158
1150
  export { DelegationTaskQueue, FileDelegationStore, LOCAL_HARNESSES, collidesWithHarnessNativeTool, composeLoopTraceEmitters, createCoordinationTools, createDelegateHandler, createFleetWorkspaceExecutor, createInProcessExecutor, createKbGate, createMcpServer, createPropagatingTraceEmitter, createSiblingSandboxExecutor, createStdioToolServer, detachedSessionDelegate, environmentReader, harnessNativeToolNames, readTraceContextFromEnv, resolveSpawnResourcePaths, runDetachedTurn };
1159
1151
 
1160
1152
  //# sourceMappingURL=index.js.map