@tangle-network/agent-runtime 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -16
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +5 -3
- package/dist/agent.js.map +1 -1
- package/dist/analyst-loop.d.ts +1 -1
- package/dist/analyst-loop.js +2 -2
- package/dist/{chunk-K5M3SHEU.js → chunk-2BDXWZUC.js} +5 -34
- package/dist/chunk-2BDXWZUC.js.map +1 -0
- package/dist/chunk-A73RADPB.js +281 -0
- package/dist/chunk-A73RADPB.js.map +1 -0
- package/dist/chunk-FRBWCJLP.js +396 -0
- package/dist/chunk-FRBWCJLP.js.map +1 -0
- package/dist/chunk-GRAGM4MC.js +72 -0
- package/dist/chunk-GRAGM4MC.js.map +1 -0
- package/dist/{chunk-K6WP7PYW.js → chunk-JTH2FPCK.js} +3231 -424
- package/dist/chunk-JTH2FPCK.js.map +1 -0
- package/dist/{chunk-P4QNEXFC.js → chunk-KJH62YEK.js} +2 -2
- package/dist/{chunk-HNUXAZIJ.js → chunk-P5OKDSLB.js} +2 -2
- package/dist/{chunk-GSUO5QS6.js → chunk-VLF5RHEQ.js} +2 -5
- package/dist/{chunk-GSUO5QS6.js.map → chunk-VLF5RHEQ.js.map} +1 -1
- package/dist/{chunk-JFIYKDXF.js → chunk-XRYEZPR6.js} +2 -1
- package/dist/chunk-XRYEZPR6.js.map +1 -0
- package/dist/{coder-LKm3Mczw.d.ts → coder-CEkUFv8h.d.ts} +1 -1
- package/dist/{types-CNDJCL_0.d.ts → coordination-BMzskrUR.d.ts} +268 -2
- package/dist/{kb-gate-CKfykcYQ.d.ts → delegates-BPLIl8EC.d.ts} +491 -566
- package/dist/index.d.ts +7 -7
- package/dist/index.js +23 -80
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -2
- package/dist/kb-gate-CuzMYGYM.d.ts +76 -0
- package/dist/{loop-runner-bin-D4Ir7b00.d.ts → loop-runner-bin-BGpVVyXp.d.ts} +6 -27
- package/dist/loop-runner-bin.d.ts +5 -5
- package/dist/loop-runner-bin.js +6 -5
- package/dist/loops.d.ts +8 -6
- package/dist/loops.js +32 -8
- package/dist/mcp/bin.js +94 -30
- package/dist/mcp/bin.js.map +1 -1
- package/dist/mcp/index.d.ts +9 -272
- package/dist/mcp/index.js +45 -365
- package/dist/mcp/index.js.map +1 -1
- package/dist/{openai-tools-CKfR3EMh.d.ts → openai-tools-CoeLQ7Uo.d.ts} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/profiles.js +4 -4
- package/dist/{router-client-B0Qi1NiN.d.ts → router-client-30Y_pca8.d.ts} +1 -1
- package/dist/{run-loop-DgVhucoR.d.ts → run-loop-DluzfJ2h.d.ts} +1 -1
- package/dist/runtime.d.ts +424 -23
- package/dist/runtime.js +32 -8
- package/dist/topology.d.ts +54 -1
- package/dist/topology.js +222 -0
- package/dist/topology.js.map +1 -1
- package/dist/{types-CklkW4Eh.d.ts → types-C8rNlxfV.d.ts} +4 -4
- package/dist/workflow.d.ts +2 -2
- package/dist/workflow.js +4 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +5 -5
- package/skills/agent-runtime-adoption/SKILL.md +54 -46
- package/skills/build-with-agent-runtime/SKILL.md +12 -8
- package/skills/loop-writer/SKILL.md +9 -1
- package/skills/supervise/SKILL.md +24 -0
- package/dist/chunk-5M2WDWBI.js +0 -908
- package/dist/chunk-5M2WDWBI.js.map +0 -1
- package/dist/chunk-AYRQZRDV.js +0 -623
- package/dist/chunk-AYRQZRDV.js.map +0 -1
- package/dist/chunk-FO4DCM7R.js +0 -1356
- package/dist/chunk-FO4DCM7R.js.map +0 -1
- package/dist/chunk-JFIYKDXF.js.map +0 -1
- package/dist/chunk-K5M3SHEU.js.map +0 -1
- package/dist/chunk-K6WP7PYW.js.map +0 -1
- package/dist/driver-B2RKkVJW.d.ts +0 -221
- /package/dist/{chunk-P4QNEXFC.js.map → chunk-KJH62YEK.js.map} +0 -0
- /package/dist/{chunk-HNUXAZIJ.js.map → chunk-P5OKDSLB.js.map} +0 -0
package/dist/mcp/bin.js.map
CHANGED
|
@@ -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 * 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. Single-variant\n * coder/researcher delegations additionally\n * dispatch DETACHED (driveTurn ticks against a\n * deterministic session id) on session-backed\n * placements, so restored in-flight records\n * resume against their still-running sandbox\n * sessions; non-detached in-flight records\n * settle as failed with a truthful\n * driver-restart error.\n * AGENT_RUNTIME_DELEGATION_DETACHED\n * set to `0` to keep every delegation on the\n * streaming path even when the state file is\n * configured (disables detached dispatch +\n * resume).\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\nimport type { SandboxInstance } from '@tangle-network/sandbox'\nimport { coderProfile } from '../profiles/coder'\nimport type { AgentRunSpec, LoopTraceEmitter, SandboxClient } from '../runtime'\nimport { runLoop } from '../runtime'\nimport { detectExecutor } from './bin-helpers'\nimport {\n coderTaskFromArgs,\n createDefaultCoderDelegate,\n type ResearcherDelegate,\n settleDetachedCoderTurn,\n} from './delegates'\nimport { FileDelegationStore } from './delegation-store'\nimport { composeLoopTraceEmitters } from './delegation-trace'\nimport {\n createDriveTurnResumeDriver,\n type DetachedTurn,\n type DriveTurnCapableBox,\n detachedTurnEvents,\n formatDetachedSessionRef,\n parseDetachedSessionRef,\n runDetachedTurn,\n} from './detached-turn'\nimport type { DelegationExecutor } from './executor'\nimport { createMcpServer } from './server'\nimport { type DelegationResumeDriver, DelegationTaskQueue } from './task-queue'\nimport {\n createPropagatingTraceEmitter,\n readTraceContextFromEnv,\n type TraceContext,\n} from './trace-propagation'\nimport type { DelegateCodeArgs, DelegateResearchArgs, 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 // The same context is stamped onto every delegation record (traceId /\n // parentSpanId) so journal consumers join records into the caller's trace.\n const traceContext = readTraceContextFromEnv()\n const { emitter: traceEmitter, exporter: traceExporter } =\n createPropagatingTraceEmitter(traceContext)\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 researcherSupport =\n wantResearcher && executor\n ? await loadResearcherSupport(executor, maxConcurrency, traceEmitter)\n : undefined\n\n // Detached dispatch + resume turn on together with the durable store, and\n // only for session-backed placements with real credentials: in-process\n // placement has no sandbox session to detach, and the diagnostic no-key stub\n // cannot resolve boxes. AGENT_RUNTIME_DELEGATION_DETACHED=0 keeps everything\n // on the streaming path.\n const detachedDispatch =\n Boolean(process.env.AGENT_RUNTIME_DELEGATION_STATE_FILE?.trim()) &&\n process.env.AGENT_RUNTIME_DELEGATION_DETACHED !== '0' &&\n Boolean(process.env.TANGLE_API_KEY) &&\n (executor?.placement === 'sibling' || executor?.placement === 'fleet')\n if (detachedDispatch) {\n process.stderr.write(\n 'agent-runtime-mcp: detached dispatch enabled — single-variant delegations resume across restarts\\n',\n )\n }\n const resumeDriver =\n detachedDispatch && sandboxClient\n ? buildResumeDriver({ sandboxClient, researcherResume: researcherSupport?.resume })\n : undefined\n\n const durableQueue = await buildDurableQueueFromEnv(resumeDriver, traceContext)\n const server = createMcpServer({\n coderDelegate,\n researcherDelegate: researcherSupport?.delegate,\n detachedDispatch,\n traceContext,\n ...(durableQueue ? { queue: durableQueue } : {}),\n })\n\n const shutdown = () => {\n server.stop()\n const pending: Promise<unknown>[] = []\n if (traceExporter) pending.push(traceExporter.shutdown())\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) pending.push(durableQueue.flush().catch(() => {}))\n if (pending.length === 0) {\n process.exit(0)\n return\n }\n void Promise.allSettled(pending).finally(() => 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 resumeDriver: DelegationResumeDriver | undefined,\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 // With a resume driver, restored in-flight records that carry a\n // detachedSessionRef re-attach to their still-running sandbox sessions;\n // without one (detached dispatch disabled / no credentials) they settle as\n // failed with a truthful driver-restart error.\n const queue = await DelegationTaskQueue.restore({\n store,\n traceContext,\n ...(resumeDriver ? { resumeDelegate: resumeDriver } : {}),\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\ninterface ResearcherResumeSupport {\n message(args: DelegateResearchArgs): string\n settle(\n turn: DetachedTurn,\n args: DelegateResearchArgs,\n signal: AbortSignal,\n ): Promise<ResearchOutputShape>\n}\n\n/**\n * Compose the `driveTurn`-backed resume driver over the real sandbox client.\n * Profile dispatch: coder records settle through the same parse + validate\n * gate the delegate applies; researcher records settle through the\n * agent-knowledge preset when the peer is installed. Profiles without resume\n * support (ui-auditor, researcher-without-peer) fail loud — the record settles\n * as failed with the reason instead of fabricating an output.\n */\nfunction buildResumeDriver(args: {\n sandboxClient: SandboxClient\n researcherResume: ResearcherResumeSupport | undefined\n}): DelegationResumeDriver {\n const client = args.sandboxClient as SandboxClient & {\n get?: (id: string) => Promise<SandboxInstance | null>\n }\n return createDriveTurnResumeDriver({\n async resolveSandbox(sandboxId) {\n if (typeof client.get !== 'function') {\n throw new Error(\n 'agent-runtime-mcp: the sandbox client exposes no get(sandboxId); upgrade @tangle-network/sandbox to >= 0.6 to resume detached delegations',\n )\n }\n const box = await client.get(sandboxId)\n if (!box) {\n throw new Error(\n `agent-runtime-mcp: sandbox ${sandboxId} no longer exists — the detached run cannot be resumed`,\n )\n }\n return box as unknown as DriveTurnCapableBox\n },\n buildMessage(record) {\n if (record.profile === 'coder') {\n const task = coderTaskFromArgs(record.args as DelegateCodeArgs)\n return coderProfile({ task }).taskToPrompt(task)\n }\n if (record.profile === 'researcher' && args.researcherResume) {\n return args.researcherResume.message(record.args as DelegateResearchArgs)\n }\n throw new Error(\n `agent-runtime-mcp: no detached resume support for profile \"${record.profile}\"`,\n )\n },\n async settleOutput(turn, record, ctx) {\n if (record.profile === 'coder') {\n if (!record.detachedSessionRef) {\n throw new Error(\n `agent-runtime-mcp: record ${record.taskId} reached the resume settle without a detachedSessionRef`,\n )\n }\n return settleDetachedCoderTurn(turn, {\n task: coderTaskFromArgs(record.args as DelegateCodeArgs),\n sessionId: parseDetachedSessionRef(record.detachedSessionRef).sessionId,\n signal: ctx.signal,\n })\n }\n if (record.profile === 'researcher' && args.researcherResume) {\n return args.researcherResume.settle(turn, record.args as DelegateResearchArgs, ctx.signal)\n }\n throw new Error(\n `agent-runtime-mcp: no detached resume support for profile \"${record.profile}\"`,\n )\n },\n })\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\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\ninterface ResearcherSupport {\n delegate: ResearcherDelegate\n resume: ResearcherResumeSupport\n}\n\nasync function loadResearcherSupport(\n executor: DelegationExecutor,\n maxConcurrency: number,\n traceEmitter?: LoopTraceEmitter,\n): Promise<ResearcherSupport | undefined> {\n const sandboxClient = executor.client\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 const settleSingle = async (\n turn: DetachedTurn,\n args: DelegateResearchArgs,\n sessionId: string,\n signal: AbortSignal,\n ): Promise<ResearchOutputShape> => {\n const task = buildResearchTask(args)\n const preset = singleFactory({ task })\n if (!preset.validator) {\n throw new Error('agent-runtime-mcp: researcher preset exposes no validator; cannot settle')\n }\n const parsed = preset.output.parse(detachedTurnEvents(sessionId, turn))\n const verdict = await preset.validator.validate(parsed, { iteration: 0, signal })\n if ((verdict as { valid?: boolean }).valid !== true) {\n throw new Error('researcher delegate produced no winner')\n }\n return parsed as ResearchOutputShape\n }\n\n const delegate: ResearcherDelegate = async (args, ctx) => {\n const task = buildResearchTask(args)\n const variants = Math.max(1, Math.trunc(args.variants ?? 1))\n const loopEmitter = composeLoopTraceEmitters(traceEmitter, ctx.traceEmitter)\n ctx.report({ iteration: 0, phase: 'starting' })\n if (variants <= 1) {\n const preset = singleFactory({ task })\n // Detached dispatch — same contract as the coder delegate: one session\n // on one box, driveTurn ticks, resume key bound to the sandbox id.\n if (ctx.detachedSessionRef !== undefined && ctx.updateDetachedSessionRef) {\n const { sessionId } = parseDetachedSessionRef(ctx.detachedSessionRef)\n const rebind = ctx.updateDetachedSessionRef\n const spec = preset.agentRunSpec as AgentRunSpec<unknown>\n const turn = await runDetachedTurn({\n client: sandboxClient,\n spec,\n prompt: spec.taskToPrompt(task),\n sessionId,\n bindSandbox: (sandboxId) => rebind(formatDetachedSessionRef({ sandboxId, sessionId })),\n signal: ctx.signal,\n report: ctx.report,\n ...(loopEmitter ? { traceEmitter: loopEmitter } : {}),\n ...(executor.placement === 'fleet' ? { placement: 'fleet' as const } : {}),\n })\n const output = await settleSingle(turn, args, sessionId, ctx.signal)\n ctx.report({ iteration: 1, phase: 'completed' })\n return output\n }\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: {\n sandboxClient,\n signal: ctx.signal,\n ...(loopEmitter ? { traceEmitter: loopEmitter } : {}),\n },\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: {\n sandboxClient,\n signal: ctx.signal,\n ...(loopEmitter ? { traceEmitter: loopEmitter } : {}),\n },\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 return {\n delegate,\n resume: {\n message(args) {\n const task = buildResearchTask(args)\n const spec = singleFactory({ task }).agentRunSpec as AgentRunSpec<unknown>\n return spec.taskToPrompt(task)\n },\n async settle(turn, args, signal) {\n // The session id is only the synthesized event's id — the parser reads\n // data.result / data.text, never the id.\n return settleSingle(turn, args, 'resumed-detached-turn', signal)\n },\n },\n }\n}\n\nfunction buildResearchTask(args: DelegateResearchArgs): unknown {\n return {\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}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA,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;AACJ,MAAI,cAAc;AAChB,UAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,CAAC,UAAU,CAAC,QAAQ,IAAI,gCAAgC;AAC1D,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAIA,QAAI,WAAW,CAAC,QAAQ;AACtB,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,oBAAgB,MAA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AAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,sBAAsB,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,CAAC;AAAA,CAAI;AAC7F,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["output","result"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/researcher-provisioning.ts","../../src/mcp/bin.ts"],"sourcesContent":["/**\n * Researcher delegate provisioning — resolves the worker harness, model, and router\n * credentials for `delegate_research`, and injects the OpenAI-compatible router creds\n * into a sandbox agent-run spec.\n *\n * Why this exists: the agent-knowledge researcher profile defaults to a harness\n * (`opencode/zai-coding-plan/glm-5.1`) that isn't broadly provisionable, and the sandbox\n * SDK does not wire `backend.model.apiKey` into the in-box agent's OpenAI-compatible\n * provider. So the MCP server picks a provisionable harness + model and passes the router\n * creds as box env. Everything is env-overridable and reuses the repo's router resolution.\n */\nimport { type RouterEnv, resolveRouterBaseUrl } from '../model-resolution.js'\n\nexport interface ResearcherProvisioning {\n harness: string\n /** Worker model id (router-served). */\n model: string\n /** OpenAI-compatible router key for the in-box provider; undefined disables injection. */\n routerKey?: string\n /** OpenAI-compatible router base, always ending in a `/vN` segment. */\n routerBaseUrl: string\n /** Explicit fanout harness list (MCP_RESEARCHER_FANOUT_HARNESSES); undefined ⇒ caller defaults. */\n fanoutHarnesses?: string[]\n /** Per-harness fanout model overrides (MCP_RESEARCHER_FANOUT_MODELS), index-aligned. */\n fanoutModels?: string[]\n}\n\n/** A sandbox agent-run spec whose box env can be overridden. */\nexport interface ProvisionableSpec {\n sandboxOverrides?: { env?: Record<string, string> } & Record<string, unknown>\n}\n\nconst DEFAULT_HARNESS = 'opencode'\nconst DEFAULT_MODEL = 'moonshotai/kimi-k2.6'\n\nfunction trimmed(value: string | undefined): string | undefined {\n const t = value?.trim()\n return t ? t : undefined\n}\n\nfunction csv(value: string | undefined): string[] | undefined {\n const list = value\n ?.split(',')\n .map((v) => v.trim())\n .filter(Boolean)\n return list && list.length > 0 ? list : undefined\n}\n\n/**\n * Resolve harness/model/router from env. Model falls back through the repo's\n * `WORKER_MODEL` convention; router base reuses `resolveRouterBaseUrl` (TANGLE_ROUTER_URL\n * / TANGLE_ROUTER_BASE_URL) and is normalized to an OpenAI-compatible `/v1` endpoint.\n */\nexport function resolveResearcherProvisioning(\n env: NodeJS.ProcessEnv = process.env,\n): ResearcherProvisioning {\n const harness = trimmed(env.MCP_RESEARCHER_HARNESS) ?? DEFAULT_HARNESS\n const model =\n trimmed(env.MCP_RESEARCHER_MODEL) ??\n trimmed(env.MCP_WORKER_MODEL) ??\n trimmed(env.WORKER_MODEL) ??\n DEFAULT_MODEL\n const routerKey = trimmed(env.MCP_RESEARCHER_ROUTER_KEY) ?? trimmed(env.TANGLE_API_KEY)\n const base = trimmed(env.MCP_RESEARCHER_ROUTER_BASE_URL) ?? resolveRouterBaseUrl(env as RouterEnv)\n const routerBaseUrl = /\\/v\\d+\\/?$/.test(base)\n ? base.replace(/\\/$/, '')\n : `${base.replace(/\\/$/, '')}/v1`\n const fanoutHarnesses = csv(env.MCP_RESEARCHER_FANOUT_HARNESSES)\n const fanoutModels = csv(env.MCP_RESEARCHER_FANOUT_MODELS)\n return {\n harness,\n model,\n ...(routerKey ? { routerKey } : {}),\n routerBaseUrl,\n ...(fanoutHarnesses ? { fanoutHarnesses } : {}),\n ...(fanoutModels ? { fanoutModels } : {}),\n }\n}\n\n/**\n * Overlay the router creds onto a spec's box env (in place): preserve every env var the\n * preset already supplied and set OPENAI_API_KEY / OPENAI_BASE_URL on top (these two are\n * intentionally authoritative — they point the in-box provider at the router). No-op when\n * there is no router key.\n */\nexport function applyRouterEnv(\n spec: ProvisionableSpec,\n routerKey: string | undefined,\n routerBaseUrl: string,\n): void {\n if (!routerKey) return\n spec.sandboxOverrides = {\n ...(spec.sandboxOverrides ?? {}),\n env: {\n ...(spec.sandboxOverrides?.env ?? {}),\n OPENAI_API_KEY: routerKey,\n OPENAI_BASE_URL: routerBaseUrl,\n },\n }\n}\n","#!/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 * MCP_RESEARCHER_HARNESS researcher worker harness (default `opencode`)\n * MCP_RESEARCHER_MODEL researcher worker model id (falls back to\n * MCP_WORKER_MODEL, then WORKER_MODEL, then a default)\n * MCP_RESEARCHER_FANOUT_HARNESSES comma-separated harnesses for researcher variants > 1\n * MCP_RESEARCHER_FANOUT_MODELS comma-separated per-harness models, index-aligned\n * MCP_RESEARCHER_ROUTER_KEY OpenAI-compatible router key for the in-box agent\n * (defaults to TANGLE_API_KEY)\n * MCP_RESEARCHER_ROUTER_BASE_URL router base for the in-box agent (defaults to the\n * repo's resolveRouterBaseUrl, normalized to `/v1`)\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. Single-variant\n * coder/researcher delegations additionally\n * dispatch DETACHED (driveTurn ticks against a\n * deterministic session id) on session-backed\n * placements, so restored in-flight records\n * resume against their still-running sandbox\n * sessions; non-detached in-flight records\n * settle as failed with a truthful\n * driver-restart error.\n * AGENT_RUNTIME_DELEGATION_DETACHED\n * set to `0` to keep every delegation on the\n * streaming path even when the state file is\n * configured (disables detached dispatch +\n * resume).\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\nimport type { SandboxInstance } from '@tangle-network/sandbox'\nimport { coderProfile } from '../profiles/coder'\nimport type { AgentRunSpec, LoopTraceEmitter, SandboxClient } from '../runtime'\nimport { runLoop } from '../runtime'\nimport { detectExecutor } from './bin-helpers'\nimport {\n coderTaskFromArgs,\n createDefaultCoderDelegate,\n type ResearcherDelegate,\n settleDetachedCoderTurn,\n} from './delegates'\nimport { DEFAULT_SANDBOX_BASE_URL } from './delegation-profile'\nimport { FileDelegationStore } from './delegation-store'\nimport { composeLoopTraceEmitters } from './delegation-trace'\nimport {\n createDriveTurnResumeDriver,\n type DetachedTurn,\n type DriveTurnCapableBox,\n detachedTurnEvents,\n formatDetachedSessionRef,\n parseDetachedSessionRef,\n runDetachedTurn,\n} from './detached-turn'\nimport type { DelegationExecutor } from './executor'\nimport {\n applyRouterEnv,\n type ProvisionableSpec,\n resolveResearcherProvisioning,\n} from './researcher-provisioning'\nimport { createMcpServer } from './server'\nimport { type DelegationResumeDriver, DelegationTaskQueue } from './task-queue'\nimport {\n createPropagatingTraceEmitter,\n readTraceContextFromEnv,\n type TraceContext,\n} from './trace-propagation'\nimport type { DelegateCodeArgs, DelegateResearchArgs, 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 // The same context is stamped onto every delegation record (traceId /\n // parentSpanId) so journal consumers join records into the caller's trace.\n const traceContext = readTraceContextFromEnv()\n const { emitter: traceEmitter, exporter: traceExporter } =\n createPropagatingTraceEmitter(traceContext)\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 researcherSupport =\n wantResearcher && executor\n ? await loadResearcherSupport(executor, maxConcurrency, traceEmitter)\n : undefined\n\n // Detached dispatch + resume turn on together with the durable store, and\n // only for session-backed placements with real credentials: in-process\n // placement has no sandbox session to detach, and the diagnostic no-key stub\n // cannot resolve boxes. AGENT_RUNTIME_DELEGATION_DETACHED=0 keeps everything\n // on the streaming path.\n const detachedDispatch =\n Boolean(process.env.AGENT_RUNTIME_DELEGATION_STATE_FILE?.trim()) &&\n process.env.AGENT_RUNTIME_DELEGATION_DETACHED !== '0' &&\n Boolean(process.env.TANGLE_API_KEY) &&\n (executor?.placement === 'sibling' || executor?.placement === 'fleet')\n if (detachedDispatch) {\n process.stderr.write(\n 'agent-runtime-mcp: detached dispatch enabled — single-variant delegations resume across restarts\\n',\n )\n }\n const resumeDriver =\n detachedDispatch && sandboxClient\n ? buildResumeDriver({ sandboxClient, researcherResume: researcherSupport?.resume })\n : undefined\n\n const durableQueue = await buildDurableQueueFromEnv(resumeDriver, traceContext)\n const server = createMcpServer({\n coderDelegate,\n researcherDelegate: researcherSupport?.delegate,\n detachedDispatch,\n traceContext,\n ...(durableQueue ? { queue: durableQueue } : {}),\n })\n\n const shutdown = () => {\n server.stop()\n const pending: Promise<unknown>[] = []\n if (traceExporter) pending.push(traceExporter.shutdown())\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) pending.push(durableQueue.flush().catch(() => {}))\n if (pending.length === 0) {\n process.exit(0)\n return\n }\n void Promise.allSettled(pending).finally(() => 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 resumeDriver: DelegationResumeDriver | undefined,\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 // With a resume driver, restored in-flight records that carry a\n // detachedSessionRef re-attach to their still-running sandbox sessions;\n // without one (detached dispatch disabled / no credentials) they settle as\n // failed with a truthful driver-restart error.\n const queue = await DelegationTaskQueue.restore({\n store,\n traceContext,\n ...(resumeDriver ? { resumeDelegate: resumeDriver } : {}),\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\ninterface ResearcherResumeSupport {\n message(args: DelegateResearchArgs): string\n settle(\n turn: DetachedTurn,\n args: DelegateResearchArgs,\n signal: AbortSignal,\n ): Promise<ResearchOutputShape>\n}\n\n/**\n * Compose the `driveTurn`-backed resume driver over the real sandbox client.\n * Profile dispatch: coder records settle through the same parse + validate\n * gate the delegate applies; researcher records settle through the\n * agent-knowledge preset when the peer is installed. Profiles without resume\n * support (ui-auditor, researcher-without-peer) fail loud — the record settles\n * as failed with the reason instead of fabricating an output.\n */\nfunction buildResumeDriver(args: {\n sandboxClient: SandboxClient\n researcherResume: ResearcherResumeSupport | undefined\n}): DelegationResumeDriver {\n const client = args.sandboxClient as SandboxClient & {\n get?: (id: string) => Promise<SandboxInstance | null>\n }\n return createDriveTurnResumeDriver({\n async resolveSandbox(sandboxId) {\n if (typeof client.get !== 'function') {\n throw new Error(\n 'agent-runtime-mcp: the sandbox client exposes no get(sandboxId); upgrade @tangle-network/sandbox to >= 0.6 to resume detached delegations',\n )\n }\n const box = await client.get(sandboxId)\n if (!box) {\n throw new Error(\n `agent-runtime-mcp: sandbox ${sandboxId} no longer exists — the detached run cannot be resumed`,\n )\n }\n return box as unknown as DriveTurnCapableBox\n },\n buildMessage(record) {\n if (record.profile === 'coder') {\n const task = coderTaskFromArgs(record.args as DelegateCodeArgs)\n return coderProfile({ task }).taskToPrompt(task)\n }\n if (record.profile === 'researcher' && args.researcherResume) {\n return args.researcherResume.message(record.args as DelegateResearchArgs)\n }\n throw new Error(\n `agent-runtime-mcp: no detached resume support for profile \"${record.profile}\"`,\n )\n },\n async settleOutput(turn, record, ctx) {\n if (record.profile === 'coder') {\n if (!record.detachedSessionRef) {\n throw new Error(\n `agent-runtime-mcp: record ${record.taskId} reached the resume settle without a detachedSessionRef`,\n )\n }\n return settleDetachedCoderTurn(turn, {\n task: coderTaskFromArgs(record.args as DelegateCodeArgs),\n sessionId: parseDetachedSessionRef(record.detachedSessionRef).sessionId,\n signal: ctx.signal,\n })\n }\n if (record.profile === 'researcher' && args.researcherResume) {\n return args.researcherResume.settle(turn, record.args as DelegateResearchArgs, ctx.signal)\n }\n throw new Error(\n `agent-runtime-mcp: no detached resume support for profile \"${record.profile}\"`,\n )\n },\n })\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\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 // @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\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\ninterface ResearcherSupport {\n delegate: ResearcherDelegate\n resume: ResearcherResumeSupport\n}\n\nasync function loadResearcherSupport(\n executor: DelegationExecutor,\n maxConcurrency: number,\n traceEmitter?: LoopTraceEmitter,\n): Promise<ResearcherSupport | undefined> {\n const sandboxClient = executor.client\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: {\n task: unknown\n harness?: string\n model?: string\n }) => ResearcherProfilePreset\n type FanoutFactory = (opts: {\n task: unknown\n harnesses?: string[]\n models?: (string | undefined)[]\n }) => 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 // Worker harness + model + provider auth. Two reasons a researcher run otherwise makes\n // zero LLM calls and \"produces no winner\" on a successful box: (1) the profile's default\n // harness (opencode/zai-coding-plan/glm-5.1) is not broadly provisionable; (2) the\n // sandbox SDK does not wire backend.model.apiKey into the in-box agent's OpenAI-compatible\n // provider. resolveResearcherProvisioning picks a provisionable harness + model and the\n // router creds (all env-overridable); applyRouterEnv injects them as box env. Applied to\n // BOTH the single-variant path and every fanout agent-run so variants > 1 work too.\n const {\n harness,\n model,\n routerKey,\n routerBaseUrl,\n fanoutHarnesses: cfgFanoutHarnesses,\n fanoutModels,\n } = resolveResearcherProvisioning()\n const buildPreset = (task: unknown): ResearcherProfilePreset => {\n const preset = singleFactory({ task, harness, model })\n applyRouterEnv(preset.agentRunSpec as ProvisionableSpec, routerKey, routerBaseUrl)\n return preset\n }\n\n const settleSingle = async (\n turn: DetachedTurn,\n args: DelegateResearchArgs,\n sessionId: string,\n signal: AbortSignal,\n ): Promise<ResearchOutputShape> => {\n const task = buildResearchTask(args)\n const preset = buildPreset(task)\n if (!preset.validator) {\n throw new Error('agent-runtime-mcp: researcher preset exposes no validator; cannot settle')\n }\n const parsed = preset.output.parse(detachedTurnEvents(sessionId, turn))\n const verdict = await preset.validator.validate(parsed, { iteration: 0, signal })\n if ((verdict as { valid?: boolean }).valid !== true) {\n throw new Error('researcher delegate produced no winner')\n }\n return parsed as ResearchOutputShape\n }\n\n const delegate: ResearcherDelegate = async (args, ctx) => {\n const task = buildResearchTask(args)\n const variants = Math.max(1, Math.trunc(args.variants ?? 1))\n const loopEmitter = composeLoopTraceEmitters(traceEmitter, ctx.traceEmitter)\n ctx.report({ iteration: 0, phase: 'starting' })\n if (variants <= 1) {\n const preset = buildPreset(task)\n // Detached dispatch — same contract as the coder delegate: one session\n // on one box, driveTurn ticks, resume key bound to the sandbox id.\n if (ctx.detachedSessionRef !== undefined && ctx.updateDetachedSessionRef) {\n const { sessionId } = parseDetachedSessionRef(ctx.detachedSessionRef)\n const rebind = ctx.updateDetachedSessionRef\n const spec = preset.agentRunSpec as AgentRunSpec<unknown>\n const turn = await runDetachedTurn({\n client: sandboxClient,\n spec,\n prompt: spec.taskToPrompt(task),\n sessionId,\n bindSandbox: (sandboxId) => rebind(formatDetachedSessionRef({ sandboxId, sessionId })),\n signal: ctx.signal,\n report: ctx.report,\n ...(loopEmitter ? { traceEmitter: loopEmitter } : {}),\n ...(executor.placement === 'fleet' ? { placement: 'fleet' as const } : {}),\n })\n const output = await settleSingle(turn, args, sessionId, ctx.signal)\n ctx.report({ iteration: 1, phase: 'completed' })\n return output\n }\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: {\n sandboxClient,\n signal: ctx.signal,\n ...(loopEmitter ? { traceEmitter: loopEmitter } : {}),\n },\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 // Match the single-variant fix: use a provisionable harness/model and inject router\n // creds into every fanout agent-run, else variants > 1 makes zero LLM calls. Default to\n // `variants` copies of the working harness; MCP_RESEARCHER_FANOUT_HARNESSES overrides for\n // diversity (with optional per-harness MCP_RESEARCHER_FANOUT_MODELS).\n const fanoutHarnesses = cfgFanoutHarnesses ?? Array.from({ length: variants }, () => harness)\n const fanout = fanoutFactory({\n task,\n harnesses: fanoutHarnesses,\n models: fanoutHarnesses.map((_, i) => fanoutModels?.[i] ?? model),\n })\n for (const spec of fanout.agentRuns) {\n applyRouterEnv(spec as ProvisionableSpec, routerKey, routerBaseUrl)\n }\n // The harness list may be shorter than `variants` (misconfig) — never claim more\n // iterations than there are runs.\n const runs = fanout.agentRuns.slice(0, variants)\n const effectiveVariants = Math.max(1, runs.length)\n const result = await runLoop({\n driver: fanout.driver,\n agentRuns: runs,\n output: fanout.output,\n validator: fanout.validator,\n task,\n ctx: {\n sandboxClient,\n signal: ctx.signal,\n ...(loopEmitter ? { traceEmitter: loopEmitter } : {}),\n },\n maxIterations: effectiveVariants,\n maxConcurrency: Math.min(maxConcurrency, effectiveVariants),\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 return {\n delegate,\n resume: {\n message(args) {\n const task = buildResearchTask(args)\n // Use the same preset construction as dispatch so the displayed prompt can't drift.\n const spec = buildPreset(task).agentRunSpec as AgentRunSpec<unknown>\n return spec.taskToPrompt(task)\n },\n async settle(turn, args, signal) {\n // The session id is only the synthesized event's id — the parser reads\n // data.result / data.text, never the id.\n return settleSingle(turn, args, 'resumed-detached-turn', signal)\n },\n },\n }\n}\n\nfunction buildResearchTask(args: DelegateResearchArgs): unknown {\n return {\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}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAM,kBAAkB;AACxB,IAAM,gBAAgB;AAEtB,SAAS,QAAQ,OAA+C;AAC9D,QAAM,IAAI,OAAO,KAAK;AACtB,SAAO,IAAI,IAAI;AACjB;AAEA,SAAS,IAAI,OAAiD;AAC5D,QAAM,OAAO,OACT,MAAM,GAAG,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AACjB,SAAO,QAAQ,KAAK,SAAS,IAAI,OAAO;AAC1C;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ACd,eAAe,KAAK,QAAQ,gBACxB;AAAA,MACE,OAAO,KAAK,OAAO,cAAc,QAC7B,IAAI,KAAK,KAAK,OAAO,cAAc,KAAK,IACxC;AAAA,MACJ,OAAO,KAAK,OAAO,cAAc,QAC7B,IAAI,KAAK,KAAK,OAAO,cAAc,KAAK,IACxC;AAAA,IACN,IACA;AAAA,IACJ,UAAU,KAAK,QAAQ;AAAA,IACvB,eAAe,KAAK,QAAQ;AAAA,EAC9B;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,QAAME,WAAU,IAAI,KAAK;AACzB,SAAOA,SAAQ,SAAS,IAAIA,WAAU;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":["output","result","trimmed"]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { S as SandboxClient, f as LoopSandboxPlacement } from '../types-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { S as SandboxClient, f as LoopSandboxPlacement } from '../types-C8rNlxfV.js';
|
|
2
|
+
import { F as FleetHandle, f as DelegationExecutor, d as DelegationTaskQueue, e as CoderDelegate, D as DelegateCodeArgs, g as DelegateCodeResult, h as DelegateFeedbackResult, b as DelegateFeedbackArgs, i as ResearchSource, R as ResearcherDelegate, j as DelegateResearchArgs, k as DelegateResearchResult, U as UiAuditorDelegate, l as DelegateUiAuditArgs, m as DelegateUiAuditResult, n as DelegationHistoryResult, o as DelegationHistoryArgs, p as DelegationStatusResult, q as DelegationStatusArgs } from '../delegates-BPLIl8EC.js';
|
|
3
|
+
export { r as CappedDelegationTrace, s as CoderReview, C as CoderReviewer, a as CoderWinnerSelection, t as CreateDefaultCoderDelegateOptions, u as DELEGATION_TRACE_MAX_BYTES, v as DELEGATION_TRACE_MAX_SPANS, w as DelegateCodeConfig, x as DelegateResearchConfig, y as DelegateRunCtx, z as DelegateUiAuditConfig, A as DelegateUiAuditRoute, B as DelegationError, c as DelegationFeedbackSnapshot, E as DelegationHistoryEntry, G as DelegationPersistenceError, H as DelegationProfile, I as DelegationProgress, J as DelegationRecord, K as DelegationResultPayload, L as DelegationResumeContext, M as DelegationResumeDriver, N as DelegationResumeTick, O as DelegationRunContext, P as DelegationStateCorruptError, Q as DelegationStatus, S as DelegationStore, V as DelegationTaskQueueOptions, W as DelegationTraceCaps, X as DelegationTraceCollector, Y as DelegationTraceSpan, Z as DetachedSessionRefParts, _ as DetachedTurn, $ as DriveTurnCapableBox, a0 as DriveTurnResumeDriverOptions, a1 as DriveTurnTick, a2 as FeedbackRating, a3 as FeedbackRefersTo, a4 as FileDelegationStore, a5 as FileDelegationStoreOptions, a6 as FleetWorkspaceExecutorOptions, a7 as InMemoryDelegationStore, a8 as ResearchOutputShape, a9 as RunDetachedTurnOptions, aa as SettleDetachedCoderTurnOptions, ab as SiblingSandboxExecutorOptions, ac as SubmitInput, ad as SubmitOutput, T as TraceContext, ae as UiAuditorDelegationOutput, af as buildDelegationTraceSpans, ag as capDelegationTrace, ah as coderTaskFromArgs, ai as composeLoopTraceEmitters, aj as createDefaultCoderDelegate, ak as createDelegationTraceCollector, al as createDriveTurnResumeDriver, am as createFleetWorkspaceExecutor, an as createPropagatingTraceEmitter, ao as createSiblingSandboxExecutor, ap as detachedTurnEvents, aq as formatDetachedSessionRef, ar as hashIdempotencyInput, as as parseDetachedSessionRef, at as readTraceContextFromEnv, au as runDetachedTurn, av as settleDetachedCoderTurn, aw as traceContextToEnv } from '../delegates-BPLIl8EC.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-Bvfro2m1.js';
|
|
5
|
+
import { F as FeedbackStore } from '../coordination-BMzskrUR.js';
|
|
6
|
+
export { A as AnalystRegistry, C as CoordinationEvent, a as CoordinationTools, b as CoordinationToolsOptions, c as FeedbackEvent, I as InMemoryFeedbackStore, J as JsonRpcMessage, d as JsonRpcResponse, M as MakeWorkerAgent, e as McpServer, f as McpServerOptions, g as McpToolDescriptor, h as McpTransport, Q as Question, i as QuestionDecision, j as QuestionPolicy, k as QuestionRecord, S as SettledWorker, l as createCoordinationTools, m as createInProcessTransport, n as createMcpServer, o as eventToSnapshot } from '../coordination-BMzskrUR.js';
|
|
5
7
|
import { L as LocalHarness, r as runLocalHarness } from '../local-harness-KrdFTY5R.js';
|
|
6
8
|
export { a as LocalHarnessResult, R as RunLocalHarnessOptions } from '../local-harness-KrdFTY5R.js';
|
|
7
|
-
export {
|
|
9
|
+
export { C as CreateKbGateOptions, F as FactCandidate, a as FactJudge, b as FactJudgeVerdict, K as KbGateResult, c as createKbGate } from '../kb-gate-CuzMYGYM.js';
|
|
10
|
+
export { m as mcpToolsForRuntimeMcp, a as mcpToolsForRuntimeMcpSubset } from '../openai-tools-CoeLQ7Uo.js';
|
|
8
11
|
import { AnalystFinding } from '@tangle-network/agent-eval';
|
|
9
|
-
import { S as Scope, R as ResultBlobStore, A as Agent, B as Budget } from '../types-CNDJCL_0.js';
|
|
10
12
|
import { a as UiLens } from '../substrate-CUgk7F7s.js';
|
|
11
13
|
import '@tangle-network/sandbox';
|
|
12
14
|
import '../runtime-hooks-C7JwKb9E.js';
|
|
13
|
-
import '../coder-
|
|
15
|
+
import '../coder-CEkUFv8h.js';
|
|
14
16
|
import 'node:child_process';
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -49,61 +51,6 @@ interface DetectExecutorArgs {
|
|
|
49
51
|
*/
|
|
50
52
|
declare function detectExecutor(args: DetectExecutorArgs): Promise<DelegationExecutor>;
|
|
51
53
|
|
|
52
|
-
/**
|
|
53
|
-
* @experimental
|
|
54
|
-
*
|
|
55
|
-
* Feedback persistence surface for the MCP layer.
|
|
56
|
-
*
|
|
57
|
-
* The substrate cannot import `@tangle-network/agent-knowledge` (it would
|
|
58
|
-
* induce a dependency cycle), so the store is an abstract interface. The
|
|
59
|
-
* default implementation is in-memory; consumers wire their own adapter
|
|
60
|
-
* (a real KbStore-backed sink, an HTTP relay to gtm-agent's knowledge
|
|
61
|
-
* service, etc.) via `createMcpServer({ feedbackStore })`.
|
|
62
|
-
*
|
|
63
|
-
* Feedback events are append-only: every rating is a new event with a
|
|
64
|
-
* fresh id, even when the same delegation is rated multiple times. The
|
|
65
|
-
* caller decides how to roll up scores downstream.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/** @experimental */
|
|
69
|
-
interface FeedbackEvent {
|
|
70
|
-
id: string;
|
|
71
|
-
refersTo: DelegateFeedbackArgs['refersTo'];
|
|
72
|
-
rating: DelegateFeedbackArgs['rating'];
|
|
73
|
-
by: DelegateFeedbackArgs['by'];
|
|
74
|
-
capturedAt: string;
|
|
75
|
-
namespace?: string;
|
|
76
|
-
}
|
|
77
|
-
/** @experimental */
|
|
78
|
-
interface FeedbackStore {
|
|
79
|
-
/** Append a new event. Never dedupes — every rating is its own event. */
|
|
80
|
-
put(event: FeedbackEvent): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* List events filtered by `namespace`. When `namespace` is omitted, list
|
|
83
|
-
* across all namespaces. Returns events in insertion order.
|
|
84
|
-
*/
|
|
85
|
-
list(filter?: {
|
|
86
|
-
namespace?: string;
|
|
87
|
-
refersToRef?: string;
|
|
88
|
-
}): Promise<FeedbackEvent[]>;
|
|
89
|
-
}
|
|
90
|
-
/** @experimental */
|
|
91
|
-
declare class InMemoryFeedbackStore implements FeedbackStore {
|
|
92
|
-
private readonly events;
|
|
93
|
-
put(event: FeedbackEvent): Promise<void>;
|
|
94
|
-
list(filter?: {
|
|
95
|
-
namespace?: string;
|
|
96
|
-
refersToRef?: string;
|
|
97
|
-
}): Promise<FeedbackEvent[]>;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Project a `FeedbackEvent` down to the snapshot shape carried on
|
|
101
|
-
* `delegation_history` entries.
|
|
102
|
-
*
|
|
103
|
-
* @experimental
|
|
104
|
-
*/
|
|
105
|
-
declare function eventToSnapshot(event: FeedbackEvent): DelegationFeedbackSnapshot;
|
|
106
|
-
|
|
107
54
|
/**
|
|
108
55
|
* @experimental
|
|
109
56
|
*
|
|
@@ -289,133 +236,6 @@ interface InProcessExecutorDescribePlacement extends LoopSandboxPlacement {
|
|
|
289
236
|
*/
|
|
290
237
|
declare function createInProcessExecutor(options: InProcessExecutorOptions): DelegationExecutor;
|
|
291
238
|
|
|
292
|
-
/**
|
|
293
|
-
* @experimental
|
|
294
|
-
*
|
|
295
|
-
* Stdio JSON-RPC MCP server exposing the 5 delegation tools to sandbox
|
|
296
|
-
* coding-harness agents (claude-code, codex, opencode, ...).
|
|
297
|
-
*
|
|
298
|
-
* The server is transport-bound but topology-free: tool execution is
|
|
299
|
-
* delegated to handler functions composed from a queue, a feedback
|
|
300
|
-
* store, and per-profile run delegates. Consumers wire those at
|
|
301
|
-
* construction time. The `agent-runtime-mcp` bin spins up a default
|
|
302
|
-
* configuration for the common case (real sandbox client + coder).
|
|
303
|
-
*
|
|
304
|
-
* Wire protocol: line-delimited JSON-RPC 2.0 over stdio. Each line is
|
|
305
|
-
* one request; each response is one line. `tools/list` and `tools/call`
|
|
306
|
-
* mirror the MCP 2024-11-05 spec; we do not pull in
|
|
307
|
-
* `@modelcontextprotocol/sdk` to keep the dependency footprint zero.
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
/** @experimental */
|
|
311
|
-
interface McpServerOptions {
|
|
312
|
-
/** Required to enable delegate_code. */
|
|
313
|
-
coderDelegate?: CoderDelegate;
|
|
314
|
-
/**
|
|
315
|
-
* Required to enable delegate_research. The substrate cannot ship a
|
|
316
|
-
* default — wire one that closes over your `runLoop` + a
|
|
317
|
-
* researcher profile (typically `@tangle-network/agent-knowledge`'s
|
|
318
|
-
* `researcherProfile` / `multiHarnessResearcherFanout`).
|
|
319
|
-
*/
|
|
320
|
-
researcherDelegate?: ResearcherDelegate;
|
|
321
|
-
/**
|
|
322
|
-
* Required to enable delegate_ui_audit. Wire one that closes over your
|
|
323
|
-
* `runLoop` + `uiAuditorProfile` + a `SandboxClient` (the
|
|
324
|
-
* canonical in-process choice is `createInProcessUiAuditClient` from
|
|
325
|
-
* `@tangle-network/agent-runtime/profiles`) + your vision judge.
|
|
326
|
-
*/
|
|
327
|
-
uiAuditorDelegate?: UiAuditorDelegate;
|
|
328
|
-
/** Override the default in-memory feedback store. */
|
|
329
|
-
feedbackStore?: FeedbackStore;
|
|
330
|
-
/** Override the default in-memory task queue. */
|
|
331
|
-
queue?: DelegationTaskQueue;
|
|
332
|
-
/**
|
|
333
|
-
* Record deterministic detached-session resume keys on single-variant
|
|
334
|
-
* coder/researcher submissions so a durable queue can resume them after a
|
|
335
|
-
* restart. Enable only when the wired delegates dispatch via sandbox
|
|
336
|
-
* sessions (`driveTurn`) AND `queue` persists records — the keys are inert
|
|
337
|
-
* otherwise. The bin turns this on alongside the durable store for
|
|
338
|
-
* session-backed (sibling/fleet) placements.
|
|
339
|
-
*/
|
|
340
|
-
detachedDispatch?: boolean;
|
|
341
|
-
/**
|
|
342
|
-
* Extra tools to serve alongside the delegation tools, for example
|
|
343
|
-
* `createCoordinationTools(...).tools`. Registered after the built-ins; a
|
|
344
|
-
* duplicate name throws so delegation tools cannot be shadowed silently.
|
|
345
|
-
*/
|
|
346
|
-
extraTools?: McpToolDescriptor[];
|
|
347
|
-
/**
|
|
348
|
-
* Inherited trace identity (`readTraceContextFromEnv()`) stamped on every
|
|
349
|
-
* record the DEFAULT queue creates. Ignored when `queue` is supplied —
|
|
350
|
-
* pass `traceContext` to that queue's constructor instead.
|
|
351
|
-
*/
|
|
352
|
-
traceContext?: TraceContext;
|
|
353
|
-
/** Server display name surfaced via `initialize`. Default `'agent-runtime-mcp'`. */
|
|
354
|
-
serverName?: string;
|
|
355
|
-
/** Server version surfaced via `initialize`. Default = the package version baked at build time. */
|
|
356
|
-
serverVersion?: string;
|
|
357
|
-
}
|
|
358
|
-
/** @experimental */
|
|
359
|
-
interface McpToolDescriptor {
|
|
360
|
-
name: string;
|
|
361
|
-
description: string;
|
|
362
|
-
inputSchema: Record<string, unknown>;
|
|
363
|
-
handler: (raw: unknown) => Promise<unknown>;
|
|
364
|
-
}
|
|
365
|
-
/** @experimental */
|
|
366
|
-
interface McpServer {
|
|
367
|
-
/** Tools currently registered (depend on which delegates were wired). */
|
|
368
|
-
readonly tools: ReadonlyMap<string, McpToolDescriptor>;
|
|
369
|
-
/** The underlying queue — exposed so tests can introspect it. */
|
|
370
|
-
readonly queue: DelegationTaskQueue;
|
|
371
|
-
/** The feedback store — exposed for the same reason. */
|
|
372
|
-
readonly feedbackStore: FeedbackStore;
|
|
373
|
-
/** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */
|
|
374
|
-
handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>;
|
|
375
|
-
/** Drive the server on a stdio-shaped transport until `stop()` is called. */
|
|
376
|
-
serve(transport?: McpTransport): Promise<void>;
|
|
377
|
-
/** Stop a `serve` call. Subsequent requests are rejected. */
|
|
378
|
-
stop(): void;
|
|
379
|
-
}
|
|
380
|
-
/** @experimental */
|
|
381
|
-
interface McpTransport {
|
|
382
|
-
input: NodeJS.ReadableStream;
|
|
383
|
-
output: NodeJS.WritableStream;
|
|
384
|
-
}
|
|
385
|
-
/** @experimental */
|
|
386
|
-
interface JsonRpcMessage {
|
|
387
|
-
jsonrpc: '2.0';
|
|
388
|
-
id?: number | string | null;
|
|
389
|
-
method: string;
|
|
390
|
-
params?: unknown;
|
|
391
|
-
}
|
|
392
|
-
/** @experimental */
|
|
393
|
-
interface JsonRpcResponse {
|
|
394
|
-
jsonrpc: '2.0';
|
|
395
|
-
id: number | string | null;
|
|
396
|
-
result?: unknown;
|
|
397
|
-
error?: {
|
|
398
|
-
code: number;
|
|
399
|
-
message: string;
|
|
400
|
-
data?: unknown;
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
/** @experimental */
|
|
404
|
-
declare function createMcpServer(options?: McpServerOptions): McpServer;
|
|
405
|
-
/**
|
|
406
|
-
* In-process pair of `Readable` + `Writable` streams suitable for driving
|
|
407
|
-
* `server.serve(...)` from a test. Returns the agent-side stream (the
|
|
408
|
-
* client writes to it) and the server-side stream (the test reads from it).
|
|
409
|
-
*
|
|
410
|
-
* @experimental
|
|
411
|
-
*/
|
|
412
|
-
declare function createInProcessTransport(): {
|
|
413
|
-
transport: McpTransport;
|
|
414
|
-
clientWrite(line: string): void;
|
|
415
|
-
clientClose(): void;
|
|
416
|
-
readServer(): Promise<JsonRpcResponse[]>;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
239
|
/**
|
|
420
240
|
* @experimental
|
|
421
241
|
*
|
|
@@ -471,89 +291,6 @@ declare function makeCheckRunner(kinds: Record<string, Check>, opts: CheckRunner
|
|
|
471
291
|
error: string;
|
|
472
292
|
}>;
|
|
473
293
|
|
|
474
|
-
/**
|
|
475
|
-
* @experimental
|
|
476
|
-
*
|
|
477
|
-
* MCP binding for a live `Scope`. A sandbox driver gets the same small verbs
|
|
478
|
-
* the in-process driver has: spawn, observe, await, steer, ask/answer, analyze,
|
|
479
|
-
* and stop. Settled outputs remain Scope artifacts; product code can project
|
|
480
|
-
* them into any UI/report envelope it needs.
|
|
481
|
-
*/
|
|
482
|
-
|
|
483
|
-
/** A worker the driver has drained via `await_next`. */
|
|
484
|
-
interface SettledWorker {
|
|
485
|
-
readonly id: string;
|
|
486
|
-
readonly status: 'done' | 'down';
|
|
487
|
-
readonly score?: number;
|
|
488
|
-
readonly valid?: boolean;
|
|
489
|
-
readonly outRef?: string;
|
|
490
|
-
readonly reason?: string;
|
|
491
|
-
}
|
|
492
|
-
type QuestionLevel = 'worker' | 'driver' | 'loop';
|
|
493
|
-
type QuestionUrgency = 'continue-without' | 'blocks-step' | 'blocks-run';
|
|
494
|
-
interface QuestionOption {
|
|
495
|
-
readonly label: string;
|
|
496
|
-
readonly tradeoff: string;
|
|
497
|
-
}
|
|
498
|
-
interface Question {
|
|
499
|
-
readonly id: string;
|
|
500
|
-
readonly from: string;
|
|
501
|
-
readonly level: QuestionLevel;
|
|
502
|
-
readonly question: string;
|
|
503
|
-
readonly reason: string;
|
|
504
|
-
readonly urgency: QuestionUrgency;
|
|
505
|
-
readonly options?: ReadonlyArray<QuestionOption>;
|
|
506
|
-
}
|
|
507
|
-
type QuestionDecision = {
|
|
508
|
-
readonly kind: 'answer';
|
|
509
|
-
readonly answer: string;
|
|
510
|
-
readonly by: string;
|
|
511
|
-
} | {
|
|
512
|
-
readonly kind: 'defer';
|
|
513
|
-
readonly reason: string;
|
|
514
|
-
} | {
|
|
515
|
-
readonly kind: 'escalate';
|
|
516
|
-
readonly to: 'parent' | 'user' | string;
|
|
517
|
-
readonly reason: string;
|
|
518
|
-
};
|
|
519
|
-
interface QuestionRecord extends Question {
|
|
520
|
-
readonly status: 'open' | 'answered' | 'deferred' | 'escalated';
|
|
521
|
-
readonly decision?: QuestionDecision;
|
|
522
|
-
readonly openedAt: number;
|
|
523
|
-
}
|
|
524
|
-
type QuestionPolicy = 'auto' | 'mustDecide' | 'bubble' | 'failClosed';
|
|
525
|
-
interface AnalystRegistry {
|
|
526
|
-
readonly kinds: ReadonlyArray<{
|
|
527
|
-
id: string;
|
|
528
|
-
description: string;
|
|
529
|
-
area: string;
|
|
530
|
-
}>;
|
|
531
|
-
readonly run: (kindId: string, trace: unknown) => Promise<unknown>;
|
|
532
|
-
}
|
|
533
|
-
type CoordinationEvent = {
|
|
534
|
-
readonly type: 'question';
|
|
535
|
-
readonly question: QuestionRecord;
|
|
536
|
-
};
|
|
537
|
-
type MakeWorkerAgent = (profile: unknown) => Agent<unknown, unknown>;
|
|
538
|
-
interface CoordinationToolsOptions {
|
|
539
|
-
readonly scope: Scope<unknown>;
|
|
540
|
-
readonly blobs: ResultBlobStore;
|
|
541
|
-
readonly makeWorkerAgent: MakeWorkerAgent;
|
|
542
|
-
readonly perWorker: Budget;
|
|
543
|
-
readonly analysts?: AnalystRegistry;
|
|
544
|
-
readonly onEvent?: (event: CoordinationEvent) => void | Promise<void>;
|
|
545
|
-
readonly questionPolicy?: QuestionPolicy;
|
|
546
|
-
}
|
|
547
|
-
interface CoordinationTools {
|
|
548
|
-
readonly tools: McpToolDescriptor[];
|
|
549
|
-
isStopped(): boolean;
|
|
550
|
-
stopReason(): string | undefined;
|
|
551
|
-
settled(): ReadonlyArray<SettledWorker>;
|
|
552
|
-
questions(): ReadonlyArray<QuestionRecord>;
|
|
553
|
-
}
|
|
554
|
-
/** Build the driver's MCP tools over a live scope. */
|
|
555
|
-
declare function createCoordinationTools(opts: CoordinationToolsOptions): CoordinationTools;
|
|
556
|
-
|
|
557
294
|
/**
|
|
558
295
|
* @experimental
|
|
559
296
|
*
|
|
@@ -1012,4 +749,4 @@ interface DelegationStatusHandlerOptions {
|
|
|
1012
749
|
/** @experimental */
|
|
1013
750
|
declare function createDelegationStatusHandler(options: DelegationStatusHandlerOptions): (raw: unknown) => Promise<DelegationStatusResult>;
|
|
1014
751
|
|
|
1015
|
-
export { type
|
|
752
|
+
export { type Check, type CheckRunnerOptions, CoderDelegate, type CreateWorktreeOptions, DELEGATE_CODE_DESCRIPTION, DELEGATE_CODE_INPUT_SCHEMA, DELEGATE_CODE_TOOL_NAME, DELEGATE_FEEDBACK_DESCRIPTION, DELEGATE_FEEDBACK_INPUT_SCHEMA, DELEGATE_FEEDBACK_TOOL_NAME, DELEGATE_RESEARCH_DESCRIPTION, DELEGATE_RESEARCH_INPUT_SCHEMA, DELEGATE_RESEARCH_TOOL_NAME, DELEGATE_UI_AUDIT_DESCRIPTION, DELEGATE_UI_AUDIT_INPUT_SCHEMA, DELEGATE_UI_AUDIT_TOOL_NAME, DELEGATION_HISTORY_DESCRIPTION, DELEGATION_HISTORY_INPUT_SCHEMA, DELEGATION_HISTORY_TOOL_NAME, DELEGATION_STATUS_DESCRIPTION, DELEGATION_STATUS_INPUT_SCHEMA, DELEGATION_STATUS_TOOL_NAME, DelegateCodeArgs, DelegateCodeResult, DelegateFeedbackArgs, DelegateFeedbackResult, DelegateResearchArgs, DelegateResearchResult, DelegateUiAuditArgs, DelegateUiAuditResult, DelegationExecutor, DelegationHistoryArgs, DelegationHistoryResult, DelegationStatusArgs, DelegationStatusResult, DelegationTaskQueue, type DetectExecutorArgs, type DiffOptions, type DiffResult, FeedbackStore, FleetHandle, type GitRunner, type InProcessExecutorDescribePlacement, type InProcessExecutorOptions, LocalHarness, type RemoveWorktreeOptions, ResearchSource, ResearcherDelegate, UiAuditorDelegate, type WorktreeHandle, captureWorktreeDiff, createDelegateCodeHandler, createDelegateFeedbackHandler, createDelegateResearchHandler, createDelegateUiAuditHandler, createDelegationHistoryHandler, createDelegationStatusHandler, createInProcessExecutor, createWorktree, defaultChecks, detectExecutor, liftFindings, makeCheckRunner, removeWorktree, renderTrace, runCheck, runLocalHarness, validateDelegateCodeArgs, validateDelegateFeedbackArgs, validateDelegateResearchArgs, validateDelegateUiAuditArgs, validateDelegationHistoryArgs, validateDelegationStatusArgs };
|