@tangle-network/agent-runtime 10.0.5 → 10.0.7

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 (86) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{activation-DvvM7gG5.js → activation-B3qLMoog.js} +2 -2
  3. package/dist/{activation-DvvM7gG5.js.map → activation-B3qLMoog.js.map} +1 -1
  4. package/dist/{activation-DyFt-GHq.d.ts → activation-CT-rr2-5.d.ts} +2 -2
  5. package/dist/agent.d.ts +1 -1
  6. package/dist/agent.js +3 -3
  7. package/dist/{delegate-YBqrrbq7.js → delegate-BFP1uCNY.js} +2 -2
  8. package/dist/{delegate-YBqrrbq7.js.map → delegate-BFP1uCNY.js.map} +1 -1
  9. package/dist/{driver-control-acknowledgers-CNNRjIo9.js → driver-control-acknowledgers-jdlf49OQ.js} +11 -10
  10. package/dist/driver-control-acknowledgers-jdlf49OQ.js.map +1 -0
  11. package/dist/durable-writer-thread.js +2 -2
  12. package/dist/durable.d.ts +1 -1
  13. package/dist/durable.js +11 -11
  14. package/dist/{failure-cause-DoCCGLDH.js → failure-cause-DvYGlOEV.js} +13 -5
  15. package/dist/{failure-cause-DoCCGLDH.js.map → failure-cause-DvYGlOEV.js.map} +1 -1
  16. package/dist/{graph-CUUtx7qT.js → graph-CiApRth2.js} +7 -7
  17. package/dist/graph-CiApRth2.js.map +1 -0
  18. package/dist/{improve-Cy8PZUdw.js → improve-LJaiGxdI.js} +5 -5
  19. package/dist/{improve-Cy8PZUdw.js.map → improve-LJaiGxdI.js.map} +1 -1
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +10 -10
  22. package/dist/intelligence.d.ts +2 -2
  23. package/dist/intelligence.js +4 -4
  24. package/dist/kernel.d.ts +2 -2
  25. package/dist/kernel.js +16 -16
  26. package/dist/{loop-runner-Icc1iBR-.d.ts → loop-runner-D6egvap-.d.ts} +2 -2
  27. package/dist/{loop-runner-BwkX4ViS.js → loop-runner-Dgow637w.js} +2 -2
  28. package/dist/{loop-runner-BwkX4ViS.js.map → loop-runner-Dgow637w.js.map} +1 -1
  29. package/dist/loop-runner-bin.d.ts +1 -1
  30. package/dist/loop-runner-bin.js +1 -1
  31. package/dist/mcp/bin.js +3 -3
  32. package/dist/mcp/index.d.ts +1 -1
  33. package/dist/mcp/index.js +6 -6
  34. package/dist/mcp/memory-bin.js +1 -1
  35. package/dist/profiles.d.ts +1 -1
  36. package/dist/{provision-supervisor-Dtn8RjHe.js → provision-supervisor-DLOeyFHV.js} +5 -5
  37. package/dist/{provision-supervisor-Dtn8RjHe.js.map → provision-supervisor-DLOeyFHV.js.map} +1 -1
  38. package/dist/{result-blob-store-UGXQYACQ.js → result-blob-store-BMMzqpHa.js} +2 -2
  39. package/dist/{result-blob-store-UGXQYACQ.js.map → result-blob-store-BMMzqpHa.js.map} +1 -1
  40. package/dist/{run-cancellation-BpUQZqBS.js → run-cancellation-Bv7ooTJa.js} +129 -54
  41. package/dist/run-cancellation-Bv7ooTJa.js.map +1 -0
  42. package/dist/{run-reopen-BvF3Gjj9.js → run-reopen-KAnkEJV4.js} +6 -6
  43. package/dist/{run-reopen-BvF3Gjj9.js.map → run-reopen-KAnkEJV4.js.map} +1 -1
  44. package/dist/{run-state-CZcFJjHn.js → run-state-Bcci4zIN.js} +5 -5
  45. package/dist/{run-state-CZcFJjHn.js.map → run-state-Bcci4zIN.js.map} +1 -1
  46. package/dist/{runtime-BvDaNyFf.js → runtime-DCo0OP4n.js} +16 -16
  47. package/dist/{runtime-BvDaNyFf.js.map → runtime-DCo0OP4n.js.map} +1 -1
  48. package/dist/{search-executor-DWQW-9WN.js → search-executor-Dn5YmHsg.js} +4 -4
  49. package/dist/{search-executor-DWQW-9WN.js.map → search-executor-Dn5YmHsg.js.map} +1 -1
  50. package/dist/{server-D5GpuQnT.js → server-DxpG9y6W.js} +4 -4
  51. package/dist/{server-D5GpuQnT.js.map → server-DxpG9y6W.js.map} +1 -1
  52. package/dist/{settle-record-BFhJigPW.js → settle-record-DMdeNy8A.js} +2 -2
  53. package/dist/{settle-record-BFhJigPW.js.map → settle-record-DMdeNy8A.js.map} +1 -1
  54. package/dist/{structural-rollout-D1pZn6Cu.js → structural-rollout-DOmjcEMD.js} +4 -4
  55. package/dist/{structural-rollout-D1pZn6Cu.js.map → structural-rollout-DOmjcEMD.js.map} +1 -1
  56. package/dist/{supervise-fmugf6Y2.js → supervise-D7jtypE-.js} +25 -21
  57. package/dist/supervise-D7jtypE-.js.map +1 -0
  58. package/dist/{supervise-identity-7_7DUghQ.js → supervise-identity-QavM_M4r.js} +2 -2
  59. package/dist/{supervise-identity-7_7DUghQ.js.map → supervise-identity-QavM_M4r.js.map} +1 -1
  60. package/dist/{supervision-discovery-DwRtZNdy.js → supervision-discovery-CFZnbNTB.js} +3 -3
  61. package/dist/{supervision-discovery-DwRtZNdy.js.map → supervision-discovery-CFZnbNTB.js.map} +1 -1
  62. package/dist/{supervisor-BlACe-uO.js → supervisor-BFs4u2Vo.js} +25 -16
  63. package/dist/supervisor-BFs4u2Vo.js.map +1 -0
  64. package/dist/{supervisor-accounting-DuFyM-_h.js → supervisor-accounting-CgipDzYg.js} +11 -3
  65. package/dist/{supervisor-accounting-DuFyM-_h.js.map → supervisor-accounting-CgipDzYg.js.map} +1 -1
  66. package/dist/{supervisor-root-contract-DCMw4u0V.js → supervisor-root-contract-Ca5xp0Vg.js} +3 -3
  67. package/dist/{supervisor-root-contract-DCMw4u0V.js.map → supervisor-root-contract-Ca5xp0Vg.js.map} +1 -1
  68. package/dist/testing.d.ts +1 -1
  69. package/dist/testing.js +11 -11
  70. package/dist/tool-loop.d.ts +1 -1
  71. package/dist/tool-loop.js +51 -52
  72. package/dist/tool-loop.js.map +1 -1
  73. package/dist/{tool-server-DQCdu3am.js → tool-server-Cb7LBW4e.js} +2 -2
  74. package/dist/{tool-server-DQCdu3am.js.map → tool-server-Cb7LBW4e.js.map} +1 -1
  75. package/dist/{top-web-C5vhiOFA.js → top-web-oDO4xhNE.js} +7 -7
  76. package/dist/{top-web-C5vhiOFA.js.map → top-web-oDO4xhNE.js.map} +1 -1
  77. package/dist/tui/bin.js +3 -3
  78. package/dist/tui/index.d.ts +1 -1
  79. package/dist/tui/index.js +2 -2
  80. package/dist/{types-CFmKHKiN.d.ts → types-CKsn_wgO.d.ts} +19 -3
  81. package/package.json +3 -3
  82. package/dist/driver-control-acknowledgers-CNNRjIo9.js.map +0 -1
  83. package/dist/graph-CUUtx7qT.js.map +0 -1
  84. package/dist/run-cancellation-BpUQZqBS.js.map +0 -1
  85. package/dist/supervise-fmugf6Y2.js.map +0 -1
  86. package/dist/supervisor-BlACe-uO.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tool-server-DQCdu3am.js","names":[],"sources":["../src/mcp/tool-server.ts"],"sourcesContent":["/**\n * `createStdioToolServer` — the generic newline-delimited JSON-RPC 2.0 MCP\n * server core: `initialize` / `notifications/initialized` / `tools/list` /\n * `ping` / `tools/call` over a stdio-shaped transport. It answers the\n * client's protocol version when listed in `SUPPORTED_PROTOCOL_VERSIONS`,\n * else 2024-11-05, and publishes tool annotations when a tool declares them.\n *\n * @experimental\n */\n\nimport { createInterface, type Interface as ReadlineInterface } from 'node:readline'\nimport { ValidationError } from '../errors'\nimport { runtimeFailureCause, runtimeFailureCauseSchema } from '../runtime/failure-cause'\nimport type { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } from './protocol'\n\nexport type { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } from './protocol'\n\nexport const PROTOCOL_VERSION = '2024-11-05'\n\n/**\n * Protocol versions this server speaks, newest first. `initialize` answers with\n * the client's requested version when it is listed here, and otherwise with\n * `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.\n */\nconst SUPPORTED_PROTOCOL_VERSIONS: readonly string[] = [\n '2025-11-25',\n '2025-06-18',\n '2025-03-26',\n PROTOCOL_VERSION,\n]\n\nconst toolFailureSchema = runtimeFailureCauseSchema.unwrap().pick({\n code: true,\n owner: true,\n providerCode: true,\n providerStatus: true,\n retryAfterMs: true,\n})\n\n/** @experimental */\nexport interface StdioToolServerOptions {\n /** Server display name surfaced via `initialize`. */\n serverName: string\n /** Server version surfaced via `initialize`. */\n serverVersion: string\n /** The tools to serve. Duplicate names throw — a silent shadow would hide a tool. */\n tools: readonly McpToolDescriptor[]\n}\n\n/** @experimental */\nexport interface StdioToolServer {\n /** Tools currently registered, keyed by name. */\n readonly tools: ReadonlyMap<string, McpToolDescriptor>\n /** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */\n handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>\n /** Drive the server on a stdio-shaped transport until `stop()` is called. */\n serve(transport?: McpTransport): Promise<void>\n /** Stop a `serve` call. Subsequent requests are rejected. */\n stop(): void\n}\n\n/** Build the generic stdio JSON-RPC tool server. */\nexport function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer {\n const tools = new Map<string, McpToolDescriptor>()\n for (const tool of options.tools) {\n if (tools.has(tool.name)) {\n throw new ValidationError(`createStdioToolServer: duplicate tool name \"${tool.name}\"`)\n }\n tools.set(tool.name, tool)\n }\n\n let stopped = false\n let activeReadline: ReadlineInterface | undefined\n\n async function handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null> {\n if (stopped) {\n return rpcError(message.id ?? null, -32099, 'server stopped')\n }\n if (message.method === 'initialize') {\n const requested = (message.params as { protocolVersion?: unknown } | undefined)\n ?.protocolVersion\n return rpcResult(message.id ?? null, {\n protocolVersion:\n typeof requested === 'string' && SUPPORTED_PROTOCOL_VERSIONS.includes(requested)\n ? requested\n : PROTOCOL_VERSION,\n capabilities: { tools: {} },\n serverInfo: { name: options.serverName, version: options.serverVersion },\n })\n }\n if (message.method === 'notifications/initialized') {\n // MCP clients send this after the handshake; it has no id and expects\n // no response.\n return null\n }\n if (message.method === 'ping') {\n return rpcResult(message.id ?? null, {})\n }\n if (message.method === 'tools/list') {\n return rpcResult(message.id ?? null, {\n tools: [...tools.values()].map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n ...(tool.annotations ? { annotations: tool.annotations } : {}),\n })),\n })\n }\n if (message.method === 'tools/call') {\n const params = (message.params ?? {}) as { name?: unknown; arguments?: unknown }\n const name = typeof params.name === 'string' ? params.name : ''\n const tool = tools.get(name)\n if (!tool) {\n return rpcError(message.id ?? null, -32601, `unknown tool: ${name}`)\n }\n try {\n const output = await tool.handler(params.arguments ?? {})\n return rpcResult(message.id ?? null, toolCallResult(output))\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err)\n const code = err instanceof TypeError || err instanceof RangeError ? -32602 : -32000\n const failure = toolFailureSchema.safeParse(runtimeFailureCause(err))\n return rpcError(\n message.id ?? null,\n code,\n reason,\n failure.success ? { failure: failure.data } : undefined,\n )\n }\n }\n if (message.id === undefined || message.id === null) return null\n return rpcError(message.id, -32601, `unknown method: ${message.method}`)\n }\n\n async function serve(transport?: McpTransport): Promise<void> {\n const input = transport?.input ?? process.stdin\n const output = transport?.output ?? process.stdout\n const rl = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY })\n activeReadline = rl\n return new Promise<void>((resolve, reject) => {\n rl.on('line', (line) => {\n const trimmed = line.trim()\n if (!trimmed) return\n let parsed: JsonRpcMessage | undefined\n try {\n parsed = JSON.parse(trimmed) as JsonRpcMessage\n } catch (err) {\n writeResponse(output, rpcError(null, -32700, `parse error: ${(err as Error).message}`))\n return\n }\n if (parsed?.jsonrpc !== '2.0' || typeof parsed.method !== 'string') {\n writeResponse(output, rpcError(parsed?.id ?? null, -32600, 'invalid request'))\n return\n }\n void handle(parsed).then((response) => {\n if (response) writeResponse(output, response)\n })\n })\n rl.on('close', () => resolve())\n rl.on('error', (err) => reject(err))\n if (stopped) {\n rl.close()\n resolve()\n }\n })\n }\n\n function stop(): void {\n stopped = true\n activeReadline?.close()\n activeReadline = undefined\n }\n\n return { tools, handle, serve, stop }\n}\n\nfunction toolCallResult(output: unknown): {\n content: [{ type: 'text'; text: string }]\n structuredContent?: Record<string, unknown>\n isError: false\n} {\n let json: string | undefined\n try {\n json = JSON.stringify(output)\n } catch (err) {\n const reason = err instanceof Error ? `: ${err.message}` : ''\n throw new TypeError(`MCP tool result must be JSON-serializable${reason}`, { cause: err })\n }\n if (json === undefined) {\n throw new TypeError('MCP tool result must be JSON-serializable')\n }\n\n const serialized = JSON.parse(json) as unknown\n // Preserve string content verbatim. MCP clients pass this text directly to the calling agent.\n const result: {\n content: [{ type: 'text'; text: string }]\n structuredContent?: Record<string, unknown>\n isError: false\n } = {\n content: [{ type: 'text', text: typeof serialized === 'string' ? serialized : json }],\n isError: false,\n }\n if (serialized !== null && typeof serialized === 'object' && !Array.isArray(serialized)) {\n result.structuredContent = serialized as Record<string, unknown>\n }\n return result\n}\n\nfunction rpcResult(id: number | string | null, result: unknown): JsonRpcResponse {\n return { jsonrpc: '2.0', id, result }\n}\n\nfunction rpcError(\n id: number | string | null,\n code: number,\n message: string,\n data?: unknown,\n): JsonRpcResponse {\n return {\n jsonrpc: '2.0',\n id,\n error: data === undefined ? { code, message } : { code, message, data },\n }\n}\n\nfunction writeResponse(output: NodeJS.WritableStream, response: JsonRpcResponse): void {\n output.write(`${JSON.stringify(response)}\\n`)\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAa,mBAAmB;;;;;;AAOhC,MAAM,8BAAiD;CACrD;CACA;CACA;CACA;AACF;AAEA,MAAM,oBAAoB,0BAA0B,OAAO,CAAC,CAAC,KAAK;CAChE,MAAM;CACN,OAAO;CACP,cAAc;CACd,gBAAgB;CAChB,cAAc;AAChB,CAAC;;AAyBD,SAAgB,sBAAsB,SAAkD;CACtF,MAAM,wBAAQ,IAAI,IAA+B;CACjD,KAAK,MAAM,QAAQ,QAAQ,OAAO;EAChC,IAAI,MAAM,IAAI,KAAK,IAAI,GACrB,MAAM,IAAI,gBAAgB,+CAA+C,KAAK,KAAK,EAAE;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pB,UAAU;EACV,gBAAgB,MAAM;EACtB,iBAAiB,KAAA;CACnB;CAEA,OAAO;EAAE;EAAO;EAAQ;EAAO;CAAK;AACtC;AAEA,SAAS,eAAe,QAItB;CACA,IAAI;CACJ,IAAI;EACF,OAAO,KAAK,UAAU,MAAM;CAC9B,SAAS,KAAK;EACZ,MAAM,SAAS,eAAe,QAAQ,KAAK,IAAI,YAAY;EAC3D,MAAM,IAAI,UAAU,4CAA4C,UAAU,EAAE,OAAO,IAAI,CAAC;CAC1F;CACA,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,UAAU,2CAA2C;CAGjE,MAAM,aAAa,KAAK,MAAM,IAAI;CAElC,MAAM,SAIF;EACF,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM,OAAO,eAAe,WAAW,aAAa;EAAK,CAAC;EACpF,SAAS;CACX;CACA,IAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,CAAC,MAAM,QAAQ,UAAU,GACpF,OAAO,oBAAoB;CAE7B,OAAO;AACT;AAEA,SAAS,UAAU,IAA4B,QAAkC;CAC/E,OAAO;EAAE,SAAS;EAAO;EAAI;CAAO;AACtC;AAEA,SAAS,SACP,IACA,MACA,SACA,MACiB;CACjB,OAAO;EACL,SAAS;EACT;EACA,OAAO,SAAS,KAAA,IAAY;GAAE;GAAM;EAAQ,IAAI;GAAE;GAAM;GAAS;EAAK;CACxE;AACF;AAEA,SAAS,cAAc,QAA+B,UAAiC;CACrF,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,EAAE,GAAG;AAC9C"}
1
+ {"version":3,"file":"tool-server-Cb7LBW4e.js","names":[],"sources":["../src/mcp/tool-server.ts"],"sourcesContent":["/**\n * `createStdioToolServer` — the generic newline-delimited JSON-RPC 2.0 MCP\n * server core: `initialize` / `notifications/initialized` / `tools/list` /\n * `ping` / `tools/call` over a stdio-shaped transport. It answers the\n * client's protocol version when listed in `SUPPORTED_PROTOCOL_VERSIONS`,\n * else 2024-11-05, and publishes tool annotations when a tool declares them.\n *\n * @experimental\n */\n\nimport { createInterface, type Interface as ReadlineInterface } from 'node:readline'\nimport { ValidationError } from '../errors'\nimport { runtimeFailureCause, runtimeFailureCauseSchema } from '../runtime/failure-cause'\nimport type { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } from './protocol'\n\nexport type { JsonRpcMessage, JsonRpcResponse, McpToolDescriptor, McpTransport } from './protocol'\n\nexport const PROTOCOL_VERSION = '2024-11-05'\n\n/**\n * Protocol versions this server speaks, newest first. `initialize` answers with\n * the client's requested version when it is listed here, and otherwise with\n * `PROTOCOL_VERSION` (2024-11-05), which every client that speaks 2024-11-05 accepts.\n */\nconst SUPPORTED_PROTOCOL_VERSIONS: readonly string[] = [\n '2025-11-25',\n '2025-06-18',\n '2025-03-26',\n PROTOCOL_VERSION,\n]\n\nconst toolFailureSchema = runtimeFailureCauseSchema.unwrap().pick({\n code: true,\n owner: true,\n providerCode: true,\n providerStatus: true,\n retryAfterMs: true,\n})\n\n/** @experimental */\nexport interface StdioToolServerOptions {\n /** Server display name surfaced via `initialize`. */\n serverName: string\n /** Server version surfaced via `initialize`. */\n serverVersion: string\n /** The tools to serve. Duplicate names throw — a silent shadow would hide a tool. */\n tools: readonly McpToolDescriptor[]\n}\n\n/** @experimental */\nexport interface StdioToolServer {\n /** Tools currently registered, keyed by name. */\n readonly tools: ReadonlyMap<string, McpToolDescriptor>\n /** Handle a single parsed JSON-RPC message. Returns the response object (or `null` for notifications). */\n handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null>\n /** Drive the server on a stdio-shaped transport until `stop()` is called. */\n serve(transport?: McpTransport): Promise<void>\n /** Stop a `serve` call. Subsequent requests are rejected. */\n stop(): void\n}\n\n/** Build the generic stdio JSON-RPC tool server. */\nexport function createStdioToolServer(options: StdioToolServerOptions): StdioToolServer {\n const tools = new Map<string, McpToolDescriptor>()\n for (const tool of options.tools) {\n if (tools.has(tool.name)) {\n throw new ValidationError(`createStdioToolServer: duplicate tool name \"${tool.name}\"`)\n }\n tools.set(tool.name, tool)\n }\n\n let stopped = false\n let activeReadline: ReadlineInterface | undefined\n\n async function handle(message: JsonRpcMessage): Promise<JsonRpcResponse | null> {\n if (stopped) {\n return rpcError(message.id ?? null, -32099, 'server stopped')\n }\n if (message.method === 'initialize') {\n const requested = (message.params as { protocolVersion?: unknown } | undefined)\n ?.protocolVersion\n return rpcResult(message.id ?? null, {\n protocolVersion:\n typeof requested === 'string' && SUPPORTED_PROTOCOL_VERSIONS.includes(requested)\n ? requested\n : PROTOCOL_VERSION,\n capabilities: { tools: {} },\n serverInfo: { name: options.serverName, version: options.serverVersion },\n })\n }\n if (message.method === 'notifications/initialized') {\n // MCP clients send this after the handshake; it has no id and expects\n // no response.\n return null\n }\n if (message.method === 'ping') {\n return rpcResult(message.id ?? null, {})\n }\n if (message.method === 'tools/list') {\n return rpcResult(message.id ?? null, {\n tools: [...tools.values()].map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n ...(tool.annotations ? { annotations: tool.annotations } : {}),\n })),\n })\n }\n if (message.method === 'tools/call') {\n const params = (message.params ?? {}) as { name?: unknown; arguments?: unknown }\n const name = typeof params.name === 'string' ? params.name : ''\n const tool = tools.get(name)\n if (!tool) {\n return rpcError(message.id ?? null, -32601, `unknown tool: ${name}`)\n }\n try {\n const output = await tool.handler(params.arguments ?? {})\n return rpcResult(message.id ?? null, toolCallResult(output))\n } catch (err) {\n const reason = err instanceof Error ? err.message : String(err)\n const code = err instanceof TypeError || err instanceof RangeError ? -32602 : -32000\n const failure = toolFailureSchema.safeParse(runtimeFailureCause(err))\n return rpcError(\n message.id ?? null,\n code,\n reason,\n failure.success ? { failure: failure.data } : undefined,\n )\n }\n }\n if (message.id === undefined || message.id === null) return null\n return rpcError(message.id, -32601, `unknown method: ${message.method}`)\n }\n\n async function serve(transport?: McpTransport): Promise<void> {\n const input = transport?.input ?? process.stdin\n const output = transport?.output ?? process.stdout\n const rl = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY })\n activeReadline = rl\n return new Promise<void>((resolve, reject) => {\n rl.on('line', (line) => {\n const trimmed = line.trim()\n if (!trimmed) return\n let parsed: JsonRpcMessage | undefined\n try {\n parsed = JSON.parse(trimmed) as JsonRpcMessage\n } catch (err) {\n writeResponse(output, rpcError(null, -32700, `parse error: ${(err as Error).message}`))\n return\n }\n if (parsed?.jsonrpc !== '2.0' || typeof parsed.method !== 'string') {\n writeResponse(output, rpcError(parsed?.id ?? null, -32600, 'invalid request'))\n return\n }\n void handle(parsed).then((response) => {\n if (response) writeResponse(output, response)\n })\n })\n rl.on('close', () => resolve())\n rl.on('error', (err) => reject(err))\n if (stopped) {\n rl.close()\n resolve()\n }\n })\n }\n\n function stop(): void {\n stopped = true\n activeReadline?.close()\n activeReadline = undefined\n }\n\n return { tools, handle, serve, stop }\n}\n\nfunction toolCallResult(output: unknown): {\n content: [{ type: 'text'; text: string }]\n structuredContent?: Record<string, unknown>\n isError: false\n} {\n let json: string | undefined\n try {\n json = JSON.stringify(output)\n } catch (err) {\n const reason = err instanceof Error ? `: ${err.message}` : ''\n throw new TypeError(`MCP tool result must be JSON-serializable${reason}`, { cause: err })\n }\n if (json === undefined) {\n throw new TypeError('MCP tool result must be JSON-serializable')\n }\n\n const serialized = JSON.parse(json) as unknown\n // Preserve string content verbatim. MCP clients pass this text directly to the calling agent.\n const result: {\n content: [{ type: 'text'; text: string }]\n structuredContent?: Record<string, unknown>\n isError: false\n } = {\n content: [{ type: 'text', text: typeof serialized === 'string' ? serialized : json }],\n isError: false,\n }\n if (serialized !== null && typeof serialized === 'object' && !Array.isArray(serialized)) {\n result.structuredContent = serialized as Record<string, unknown>\n }\n return result\n}\n\nfunction rpcResult(id: number | string | null, result: unknown): JsonRpcResponse {\n return { jsonrpc: '2.0', id, result }\n}\n\nfunction rpcError(\n id: number | string | null,\n code: number,\n message: string,\n data?: unknown,\n): JsonRpcResponse {\n return {\n jsonrpc: '2.0',\n id,\n error: data === undefined ? { code, message } : { code, message, data },\n }\n}\n\nfunction writeResponse(output: NodeJS.WritableStream, response: JsonRpcResponse): void {\n output.write(`${JSON.stringify(response)}\\n`)\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAa,mBAAmB;;;;;;AAOhC,MAAM,8BAAiD;CACrD;CACA;CACA;CACA;AACF;AAEA,MAAM,oBAAoB,0BAA0B,OAAO,CAAC,CAAC,KAAK;CAChE,MAAM;CACN,OAAO;CACP,cAAc;CACd,gBAAgB;CAChB,cAAc;AAChB,CAAC;;AAyBD,SAAgB,sBAAsB,SAAkD;CACtF,MAAM,wBAAQ,IAAI,IAA+B;CACjD,KAAK,MAAM,QAAQ,QAAQ,OAAO;EAChC,IAAI,MAAM,IAAI,KAAK,IAAI,GACrB,MAAM,IAAI,gBAAgB,+CAA+C,KAAK,KAAK,EAAE;EAEvF,MAAM,IAAI,KAAK,MAAM,IAAI;CAC3B;CAEA,IAAI,UAAU;CACd,IAAI;CAEJ,eAAe,OAAO,SAA0D;EAC9E,IAAI,SACF,OAAO,SAAS,QAAQ,MAAM,MAAM,QAAQ,gBAAgB;EAE9D,IAAI,QAAQ,WAAW,cAAc;GACnC,MAAM,YAAa,QAAQ,QACvB;GACJ,OAAO,UAAU,QAAQ,MAAM,MAAM;IACnC,iBACE,OAAO,cAAc,YAAY,4BAA4B,SAAS,SAAS,IAC3E,YACA;IACN,cAAc,EAAE,OAAO,CAAC,EAAE;IAC1B,YAAY;KAAE,MAAM,QAAQ;KAAY,SAAS,QAAQ;IAAc;GACzE,CAAC;EACH;EACA,IAAI,QAAQ,WAAW,6BAGrB,OAAO;EAET,IAAI,QAAQ,WAAW,QACrB,OAAO,UAAU,QAAQ,MAAM,MAAM,CAAC,CAAC;EAEzC,IAAI,QAAQ,WAAW,cACrB,OAAO,UAAU,QAAQ,MAAM,MAAM,EACnC,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU;GACxC,MAAM,KAAK;GACX,aAAa,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tC;AAEA,SAAS,SACP,IACA,MACA,SACA,MACiB;CACjB,OAAO;EACL,SAAS;EACT;EACA,OAAO,SAAS,KAAA,IAAY;GAAE;GAAM;EAAQ,IAAI;GAAE;GAAM;GAAS;EAAK;CACxE;AACF;AAEA,SAAS,cAAc,QAA+B,UAAiC;CACrF,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,EAAE,GAAG;AAC9C"}
@@ -1,9 +1,9 @@
1
- import { C as safeWorkerFile, Pn as FileObserverJournal, T as supervisorRunsRoot, Y as FileSpawnJournal, Z as spawnJournalRecordEvents, i as ROOT_STREAM_FILE, s as nodeStreamFile, sr as harnessTranscriptArtifact, v as legacySupervisorRunsRoot } from "./supervisor-accounting-DuFyM-_h.js";
2
- import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-DwRtZNdy.js";
3
- import { a as readFailureRecord, o as readSettleRecord } from "./settle-record-BFhJigPW.js";
4
- import { s as rootCoordinationOwner, u as FileCoordinationLog } from "./supervise-identity-7_7DUghQ.js";
5
- import { t as FileResultBlobStore } from "./result-blob-store-UGXQYACQ.js";
6
- import { Ot as recordValue } from "./failure-cause-DoCCGLDH.js";
1
+ import { E as supervisorRunsRoot, Fn as FileObserverJournal, Q as spawnJournalRecordEvents, X as FileSpawnJournal, cr as harnessTranscriptArtifact, i as ROOT_STREAM_FILE, s as nodeStreamFile, w as safeWorkerFile, y as legacySupervisorRunsRoot } from "./supervisor-accounting-CgipDzYg.js";
2
+ import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-CFZnbNTB.js";
3
+ import { a as readFailureRecord, o as readSettleRecord } from "./settle-record-DMdeNy8A.js";
4
+ import { s as rootCoordinationOwner, u as FileCoordinationLog } from "./supervise-identity-QavM_M4r.js";
5
+ import { t as FileResultBlobStore } from "./result-blob-store-BMMzqpHa.js";
6
+ import { At as recordValue } from "./failure-cause-DvYGlOEV.js";
7
7
  import { _ as runAbortable, g as linkAbort, n as parseCommittedJsonLines } from "./jsonl-file-vE9H9UXa.js";
8
8
  import { createRequire } from "node:module";
9
9
  import { isRecord } from "@tangle-network/agent-core";
@@ -1674,4 +1674,4 @@ async function loadRunsRoot(root) {
1674
1674
  }
1675
1675
  export { topAgentMetadata as _, buildSupervisorView as a, numberValue as c, topSnapshot as d, totalSpend as f, readTopAgentInspection as g, readTopAgentHistory as h, aggregateSnapshot as i, parseSpend as l, harnessSessionRows as m, runTopWeb as n, isSpawnEvent as o, createTopAgentStream as p, serveTopWeb as r, loadTopSnapshot as s, TOP_SNAPSHOT_RECONCILE_MS as t, parseTime as u, topAgentWorker as v };
1676
1676
 
1677
- //# sourceMappingURL=top-web-C5vhiOFA.js.map
1677
+ //# sourceMappingURL=top-web-oDO4xhNE.js.map