@pixerate/editor 0.53.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/agent/index.cjs +20 -12
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts +4 -3
  4. package/dist/agent/index.d.ts +4 -3
  5. package/dist/agent/index.js +18 -10
  6. package/dist/agent/index.js.map +1 -1
  7. package/dist/animation/index.cjs +16 -2
  8. package/dist/animation/index.cjs.map +1 -1
  9. package/dist/animation/index.d.cts +4 -226
  10. package/dist/animation/index.d.ts +4 -226
  11. package/dist/animation/index.js +15 -1
  12. package/dist/animation-editor/index.cjs +2221 -0
  13. package/dist/animation-editor/index.cjs.map +1 -0
  14. package/dist/animation-editor/index.d.cts +1117 -0
  15. package/dist/animation-editor/index.d.ts +1117 -0
  16. package/dist/animation-editor/index.js +2221 -0
  17. package/dist/animation-editor/index.js.map +1 -0
  18. package/dist/bezier-BfwIbVTl.d.cts +548 -0
  19. package/dist/bezier-DYBvLgUH.d.ts +548 -0
  20. package/dist/bridge/cli.cjs +36 -0
  21. package/dist/bridge/cli.cjs.map +1 -0
  22. package/dist/bridge/cli.d.cts +1 -0
  23. package/dist/bridge/cli.d.ts +1 -0
  24. package/dist/bridge/cli.js +36 -0
  25. package/dist/bridge/cli.js.map +1 -0
  26. package/dist/bridge/index.cjs +16 -0
  27. package/dist/bridge/index.cjs.map +1 -0
  28. package/dist/bridge/index.d.cts +65 -0
  29. package/dist/bridge/index.d.ts +65 -0
  30. package/dist/bridge/index.js +16 -0
  31. package/dist/bridge/index.js.map +1 -0
  32. package/dist/bridge-client-C5OziCRK.d.cts +148 -0
  33. package/dist/bridge-client-C5dRjrz5.d.ts +148 -0
  34. package/dist/canvas/index.cjs +1564 -557
  35. package/dist/canvas/index.cjs.map +1 -1
  36. package/dist/canvas/index.d.cts +411 -7
  37. package/dist/canvas/index.d.ts +411 -7
  38. package/dist/canvas/index.js +1559 -552
  39. package/dist/canvas/index.js.map +1 -1
  40. package/dist/chart/index.cjs +34 -76
  41. package/dist/chart/index.cjs.map +1 -1
  42. package/dist/chart/index.d.cts +9 -38
  43. package/dist/chart/index.d.ts +9 -38
  44. package/dist/chart/index.js +23 -65
  45. package/dist/chart/index.js.map +1 -1
  46. package/dist/chunk-AWKPSOSX.js +401 -0
  47. package/dist/chunk-AWKPSOSX.js.map +1 -0
  48. package/dist/chunk-B6DSIEXA.js +96 -0
  49. package/dist/chunk-B6DSIEXA.js.map +1 -0
  50. package/dist/chunk-EGFUVXKK.cjs +96 -0
  51. package/dist/chunk-EGFUVXKK.cjs.map +1 -0
  52. package/dist/{chunk-AMWXSYCI.js → chunk-GPWNYQ7R.js} +2 -370
  53. package/dist/chunk-GPWNYQ7R.js.map +1 -0
  54. package/dist/{chunk-TO22LX34.js → chunk-GTMJ4Y3S.js} +2208 -2920
  55. package/dist/chunk-GTMJ4Y3S.js.map +1 -0
  56. package/dist/chunk-H5K77C7Y.cjs +3848 -0
  57. package/dist/chunk-H5K77C7Y.cjs.map +1 -0
  58. package/dist/chunk-K73CKYUM.cjs +458 -0
  59. package/dist/chunk-K73CKYUM.cjs.map +1 -0
  60. package/dist/chunk-MLREO6J3.cjs +737 -0
  61. package/dist/chunk-MLREO6J3.cjs.map +1 -0
  62. package/dist/chunk-NONDTTH7.js +5979 -0
  63. package/dist/chunk-NONDTTH7.js.map +1 -0
  64. package/dist/chunk-NV22EMOZ.cjs +401 -0
  65. package/dist/chunk-NV22EMOZ.cjs.map +1 -0
  66. package/dist/{chunk-YNSK4MGT.cjs → chunk-O2UH7LZE.cjs} +1549 -2261
  67. package/dist/chunk-O2UH7LZE.cjs.map +1 -0
  68. package/dist/chunk-PTMIGXZ2.js +467 -0
  69. package/dist/chunk-PTMIGXZ2.js.map +1 -0
  70. package/dist/chunk-QIWFEEWG.cjs +467 -0
  71. package/dist/chunk-QIWFEEWG.cjs.map +1 -0
  72. package/dist/chunk-VWZB6BCY.js +737 -0
  73. package/dist/chunk-VWZB6BCY.js.map +1 -0
  74. package/dist/chunk-WWJNC7SX.js +3848 -0
  75. package/dist/chunk-WWJNC7SX.js.map +1 -0
  76. package/dist/chunk-XCXQDPID.cjs +5979 -0
  77. package/dist/chunk-XCXQDPID.cjs.map +1 -0
  78. package/dist/color-E9pwm--w.d.cts +33 -0
  79. package/dist/color-E9pwm--w.d.ts +33 -0
  80. package/dist/commands/index.cjs +2 -2
  81. package/dist/commands/index.cjs.map +1 -1
  82. package/dist/commands/index.d.cts +1 -1
  83. package/dist/commands/index.d.ts +1 -1
  84. package/dist/commands/index.js +3 -3
  85. package/dist/diagram/index.cjs +1167 -0
  86. package/dist/diagram/index.cjs.map +1 -0
  87. package/dist/diagram/index.d.cts +810 -0
  88. package/dist/diagram/index.d.ts +810 -0
  89. package/dist/diagram/index.js +1167 -0
  90. package/dist/diagram/index.js.map +1 -0
  91. package/dist/{easing-DTmX99QG.d.cts → easing-CNGk-W6d.d.cts} +1 -1
  92. package/dist/{easing-DTmX99QG.d.ts → easing-CNGk-W6d.d.ts} +1 -1
  93. package/dist/generation/index.d.cts +2 -2
  94. package/dist/generation/index.d.ts +2 -2
  95. package/dist/image-editor/index.d.cts +1 -1
  96. package/dist/image-editor/index.d.ts +1 -1
  97. package/dist/parameters/index.d.cts +1 -1
  98. package/dist/parameters/index.d.ts +1 -1
  99. package/dist/pathfinder-BZL8aSu0.d.cts +469 -0
  100. package/dist/pathfinder-CNtsbCRK.d.ts +469 -0
  101. package/dist/player-Dg0FT0UI.d.cts +193 -0
  102. package/dist/player-W-5DX3Go.d.ts +193 -0
  103. package/dist/presence-Cb6WhcrQ.d.cts +77 -0
  104. package/dist/presence-Cb6WhcrQ.d.ts +77 -0
  105. package/dist/{registry-CSlH4iUn.d.ts → registry-7AZFuand.d.ts} +1 -1
  106. package/dist/{registry-B4l-lYts.d.cts → registry-DIpIaCkH.d.cts} +1 -1
  107. package/dist/svg-CLg2zqZA.d.cts +847 -0
  108. package/dist/svg-CPK82TtU.d.ts +847 -0
  109. package/dist/tools/index.cjs +10 -2
  110. package/dist/tools/index.cjs.map +1 -1
  111. package/dist/tools/index.d.cts +3 -74
  112. package/dist/tools/index.d.ts +3 -74
  113. package/dist/tools/index.js +12 -4
  114. package/dist/types-BULrFyuQ.d.cts +316 -0
  115. package/dist/types-BULrFyuQ.d.ts +316 -0
  116. package/dist/vector/index.cjs +1328 -6752
  117. package/dist/vector/index.cjs.map +1 -1
  118. package/dist/vector/index.d.cts +7 -847
  119. package/dist/vector/index.d.ts +7 -847
  120. package/dist/vector/index.js +645 -6069
  121. package/dist/vector/index.js.map +1 -1
  122. package/package.json +19 -1
  123. package/dist/chunk-AMWXSYCI.js.map +0 -1
  124. package/dist/chunk-TO22LX34.js.map +0 -1
  125. package/dist/chunk-XFYUFVAX.cjs +0 -826
  126. package/dist/chunk-XFYUFVAX.cjs.map +0 -1
  127. package/dist/chunk-YNSK4MGT.cjs.map +0 -1
  128. package/dist/pathfinder-B9xh_pCZ.d.ts +0 -1013
  129. package/dist/pathfinder-QdG70sr9.d.cts +0 -1013
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-XFYUFVAX.cjs","../src/tools/registry.ts","../src/tools/definitions.ts","../src/tools/mcp-server.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;AC8EO,IAAM,kBAAA,EAAN,MAAA,QAAgC,MAAM;AAAA,EACnC;AAAA,EAET,WAAA,CAAY,IAAA,EAAiC,OAAA,EAAiB;AAC7D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,KAAA,EAAO,mBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,EAAO,IAAA;AAAA,EACb;AACD,CAAA;AAgBO,IAAM,yBAAA,EAA2B,IAAA;AAExC,IAAM,gBAAA,EAAkB,yBAAA;AACxB,IAAM,kBAAA,EAAoB,CAAC,EAAA,EAAA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;AACD,EAAA;AAEO,EAAA;AACY,IAAA;AACV,MAAA;AACR,IAAA;AACsB,IAAA;AACjB,MAAA;AAC6B,MAAA;AAC5B,QAAA;AACyB,UAAA;AACrB,QAAA;AAC8D,UAAA;AACtE,QAAA;AACM,MAAA;AACI,QAAA;AACX,MAAA;AAKqB,MAAA;AAGuF,QAAA;AACnB,QAAA;AACzF,MAAA;AACI,MAAA;AAC0B,QAAA;AACd,MAAA;AAC6C,QAAA;AACrD,QAAA;AACE,UAAA;AACQ,UAAA;AACqC,UAAA;AACtD,QAAA;AACD,MAAA;AACD,IAAA;AACQ,IAAA;AACO,sBAAA;AACA,MAAA;AAC8D,MAAA;AAC9D,MAAA;AACf,IAAA;AACD,EAAA;AACD;AHmlBoG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-XFYUFVAX.cjs","sourcesContent":[null,"import { validateJsonSchema, type JsonSchema, type SchemaValidationError } from './schema.js';\n\n/**\n * MCP-shaped tool definition, as returned by `tools/list`.\n */\nexport interface McpToolDefinition {\n\tname: string;\n\ttitle?: string;\n\tdescription?: string;\n\tinputSchema: JsonSchema & { type: 'object' };\n\toutputSchema?: JsonSchema;\n\tannotations?: {\n\t\ttitle?: string;\n\t\treadOnlyHint?: boolean;\n\t\tdestructiveHint?: boolean;\n\t\tidempotentHint?: boolean;\n\t\topenWorldHint?: boolean;\n\t\t[key: string]: unknown;\n\t};\n}\n\nexport type McpToolContent =\n\t| { type: 'text'; text: string }\n\t| { type: 'image'; data: string; mimeType: string }\n\t| { type: string; [key: string]: unknown };\n\n/** MCP `tools/call` result. */\nexport interface McpToolResult {\n\tcontent: McpToolContent[];\n\tstructuredContent?: Record<string, unknown>;\n\tisError?: boolean;\n}\n\n/** MCP `tools/list` result. */\nexport interface McpListToolsResult {\n\ttools: McpToolDefinition[];\n}\n\nexport interface ToolCallContext {\n\t/** Name the tool was called by (possibly namespaced). */\n\tname: string;\n\t/** Id of the provider that owns the tool. */\n\tproviderId: string;\n\tsignal?: AbortSignal;\n}\n\n/**\n * Handler return values are normalized into an {@link McpToolResult}: a full\n * result (`{ content: [...] }`) is passed through, a string becomes a text\n * block, `undefined` becomes an empty result, and anything else is returned\n * as `structuredContent` (plain objects) plus a JSON text block.\n */\nexport type AgentToolHandler = (args: Record<string, any>, context: ToolCallContext) => unknown | Promise<unknown>;\n\nexport interface AgentTool extends McpToolDefinition {\n\thandler: AgentToolHandler;\n}\n\n/**\n * A source of tools, typically one per mounted editor, spreadsheet or canvas.\n */\nexport interface AgentToolProvider {\n\t/** Unique id within a registry, e.g. `doc-1`. Used as the namespace on collisions. */\n\tid: string;\n\t/** Always prefix this provider's tools with `<namespace>__`. */\n\tnamespace?: string;\n\t/** Tools, or a function returning the current tools (re-read on every `listTools`). */\n\ttools: readonly AgentTool[] | (() => readonly AgentTool[]);\n\t/** Lets the provider signal that its tool list changed; returns an unsubscribe function. */\n\tsubscribe?: (notify: () => void) => () => void;\n}\n\nexport type ToolErrorCode = 'unknown_tool' | 'invalid_arguments' | 'tool_failed';\n\n/** Structured error carried in `structuredContent.error` of a failed call. */\nexport interface ToolCallError {\n\tcode: ToolErrorCode;\n\tmessage: string;\n\ttool: string;\n\tdetails?: SchemaValidationError[];\n}\n\nexport class ToolRegistryError extends Error {\n\treadonly code: 'duplicate_provider' | 'name_collision' | 'invalid_tool';\n\n\tconstructor(code: ToolRegistryError['code'], message: string) {\n\t\tsuper(message);\n\t\tthis.name = 'ToolRegistryError';\n\t\tthis.code = code;\n\t}\n}\n\nexport interface ToolRegistryOptions {\n\t/**\n\t * What to do when two providers contribute the same tool name:\n\t * `namespace` (default) exposes every colliding tool as `<providerId>__<name>`;\n\t * `error` makes `register` throw.\n\t */\n\tonCollision?: 'namespace' | 'error';\n\t/** Coalescing window for `listChanged` notifications in ms (default 0: same tick). */\n\tlistChangedDelayMs?: number;\n\t/** Validate arguments against `inputSchema` before calling handlers (default `true`). */\n\tvalidateArguments?: boolean;\n}\n\n/** Separator between namespace and tool name; valid in MCP and LLM tool-name charsets. */\nexport const TOOL_NAMESPACE_SEPARATOR = '__';\n\nconst TOOL_NAME_REGEX = /^[A-Za-z0-9_.-]{1,128}$/;\nconst sanitizeNamespace = (id: string) => id.replace(/[^A-Za-z0-9_-]/g, '_');\n\ninterface ResolvedTool {\n\tname: string;\n\ttool: AgentTool;\n\tprovider: AgentToolProvider;\n}\n\ninterface ProviderEntry {\n\tprovider: AgentToolProvider;\n\tunsubscribe?: () => void;\n}\n\nfunction readTools(provider: AgentToolProvider): readonly AgentTool[] {\n\treturn typeof provider.tools === 'function' ? provider.tools() : provider.tools;\n}\n\nfunction toDefinition(name: string, tool: AgentTool): McpToolDefinition {\n\tconst { handler: _handler, name: _name, ...rest } = tool;\n\treturn { name, ...rest };\n}\n\nfunction errorResult(error: ToolCallError): McpToolResult {\n\tconst details = error.details?.length\n\t\t? '\\n' + error.details.map((d) => `- ${d.path}: ${d.message}`).join('\\n')\n\t\t: '';\n\treturn {\n\t\tisError: true,\n\t\tcontent: [{ type: 'text', text: `${error.message}${details}` }],\n\t\tstructuredContent: { error: error as unknown as Record<string, unknown> }\n\t};\n}\n\n/** Normalizes a handler's return value into an MCP `tools/call` result. */\nexport function toToolResult(value: unknown): McpToolResult {\n\tif (\n\t\tvalue &&\n\t\ttypeof value === 'object' &&\n\t\tArray.isArray((value as McpToolResult).content)\n\t) {\n\t\treturn value as McpToolResult;\n\t}\n\tif (value === undefined) return { content: [] };\n\tif (typeof value === 'string') return { content: [{ type: 'text', text: value }] };\n\tconst text = JSON.stringify(value);\n\tconst isPlainObject = typeof value === 'object' && value !== null && !Array.isArray(value);\n\treturn {\n\t\tcontent: [{ type: 'text', text: text ?? String(value) }],\n\t\t...(isPlainObject ? { structuredContent: value as Record<string, unknown> } : {})\n\t};\n}\n\n/**\n * Transport-agnostic registry of agent tools contributed by live providers.\n *\n * `listTools()` and `callTool()` return MCP `tools/list` / `tools/call`\n * result shapes, and `onListChanged` fires (coalesced) whenever the exposed\n * tool list changes, mirroring MCP's `notifications/tools/list_changed`, so an\n * MCP server can be a thin wrapper around it.\n */\nexport class ToolRegistry {\n\t/** MCP server capabilities this registry supports. */\n\treadonly capabilities = { tools: { listChanged: true } } as const;\n\n\tprivate readonly entries: ProviderEntry[] = [];\n\tprivate readonly listeners = new Set<(tools: McpToolDefinition[]) => void>();\n\tprivate readonly options: Required<ToolRegistryOptions>;\n\tprivate timer: ReturnType<typeof setTimeout> | null = null;\n\tprivate lastSignature: string;\n\n\tconstructor(options: ToolRegistryOptions = {}) {\n\t\tthis.options = {\n\t\t\tonCollision: options.onCollision ?? 'namespace',\n\t\t\tlistChangedDelayMs: options.listChangedDelayMs ?? 0,\n\t\t\tvalidateArguments: options.validateArguments ?? true\n\t\t};\n\t\tthis.lastSignature = this.signature();\n\t}\n\n\t/**\n\t * Registers a provider and returns a function that unregisters it.\n\t * Throws a {@link ToolRegistryError} for a duplicate provider id, an invalid\n\t * tool name, or (with `onCollision: 'error'`) a tool name collision.\n\t */\n\tregister(provider: AgentToolProvider): () => void {\n\t\tif (this.entries.some((e) => e.provider.id === provider.id)) {\n\t\t\tthrow new ToolRegistryError('duplicate_provider', `Tool provider \"${provider.id}\" is already registered.`);\n\t\t}\n\t\tfor (const tool of readTools(provider)) {\n\t\t\tif (!TOOL_NAME_REGEX.test(tool.name)) {\n\t\t\t\tthrow new ToolRegistryError('invalid_tool', `Invalid tool name \"${tool.name}\" from provider \"${provider.id}\".`);\n\t\t\t}\n\t\t}\n\t\tconst entry: ProviderEntry = { provider };\n\t\tthis.entries.push(entry);\n\t\ttry {\n\t\t\tconst names = this.resolve(this.options.onCollision === 'error').map((t) => t.name);\n\t\t\tconst duplicate = names.find((name, i) => names.indexOf(name) !== i);\n\t\t\tif (duplicate) {\n\t\t\t\t// Only possible with explicit namespaces (or duplicate names within one provider).\n\t\t\t\tthrow new ToolRegistryError('name_collision', `Tool name \"${duplicate}\" is exposed more than once.`);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.entries.pop();\n\t\t\tthrow error;\n\t\t}\n\t\tif (provider.subscribe) {\n\t\t\tentry.unsubscribe = provider.subscribe(() => this.notifyListChanged());\n\t\t}\n\t\tthis.notifyListChanged();\n\t\tlet registered = true;\n\t\treturn () => {\n\t\t\tif (!registered) return;\n\t\t\tregistered = false;\n\t\t\tthis.unregister(provider);\n\t\t};\n\t}\n\n\t/** Removes a provider by id or instance. Returns whether it was registered. */\n\tunregister(providerOrId: string | AgentToolProvider): boolean {\n\t\tconst index = this.entries.findIndex((e) =>\n\t\t\ttypeof providerOrId === 'string' ? e.provider.id === providerOrId : e.provider === providerOrId\n\t\t);\n\t\tif (index === -1) return false;\n\t\tconst [entry] = this.entries.splice(index, 1);\n\t\tentry.unsubscribe?.();\n\t\tthis.notifyListChanged();\n\t\treturn true;\n\t}\n\n\t/** Registered provider ids in registration order. */\n\tproviderIds(): string[] {\n\t\treturn this.entries.map((e) => e.provider.id);\n\t}\n\n\t/**\n\t * Resolves exposed names. Tools are ordered by provider registration, then\n\t * by their order within the provider.\n\t */\n\tprivate resolve(throwOnCollision = false): ResolvedTool[] {\n\t\tconst all: ResolvedTool[] = [];\n\t\tconst counts = new Map<string, number>();\n\t\tfor (const { provider } of this.entries) {\n\t\t\tfor (const tool of readTools(provider)) {\n\t\t\t\tall.push({ name: tool.name, tool, provider });\n\t\t\t\tif (!provider.namespace) counts.set(tool.name, (counts.get(tool.name) ?? 0) + 1);\n\t\t\t}\n\t\t}\n\t\tfor (const item of all) {\n\t\t\tconst prefix = item.provider.namespace ?? ((counts.get(item.name) ?? 0) > 1 ? item.provider.id : undefined);\n\t\t\tif (prefix !== undefined) {\n\t\t\t\tif (throwOnCollision && !item.provider.namespace) {\n\t\t\t\t\tthrow new ToolRegistryError(\n\t\t\t\t\t\t'name_collision',\n\t\t\t\t\t\t`Tool \"${item.name}\" from provider \"${item.provider.id}\" collides with another provider's tool.`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\titem.name = `${sanitizeNamespace(prefix)}${TOOL_NAMESPACE_SEPARATOR}${item.name}`;\n\t\t\t}\n\t\t}\n\t\treturn all;\n\t}\n\n\t/** MCP `tools/list` result for the current providers. */\n\tlistTools(): McpListToolsResult {\n\t\treturn { tools: this.resolve().map(({ name, tool }) => toDefinition(name, tool)) };\n\t}\n\n\t/** Whether a tool with this exposed name exists. */\n\thasTool(name: string): boolean {\n\t\treturn this.resolve().some((t) => t.name === name);\n\t}\n\n\t/** Looks up a tool definition by exposed name. */\n\tgetTool(name: string): McpToolDefinition | undefined {\n\t\tconst found = this.resolve().find((t) => t.name === name);\n\t\treturn found ? toDefinition(found.name, found.tool) : undefined;\n\t}\n\n\t/**\n\t * Calls a tool by exposed name and returns an MCP `tools/call` result.\n\t * Never rejects: unknown tools, invalid arguments and handler errors come\n\t * back as `isError: true` results with a {@link ToolCallError} in\n\t * `structuredContent.error` (MCP transports may map `unknown_tool` to a\n\t * JSON-RPC `-32602` error instead).\n\t */\n\tasync callTool(name: string, args: Record<string, unknown> = {}, options: { signal?: AbortSignal } = {}): Promise<McpToolResult> {\n\t\tconst found = this.resolve().find((t) => t.name === name);\n\t\tif (!found) {\n\t\t\treturn errorResult({ code: 'unknown_tool', message: `Unknown tool \"${name}\".`, tool: name });\n\t\t}\n\t\tconst input = args ?? {};\n\t\tif (this.options.validateArguments) {\n\t\t\tconst details = validateJsonSchema(input, found.tool.inputSchema);\n\t\t\tif (details.length > 0) {\n\t\t\t\treturn errorResult({\n\t\t\t\t\tcode: 'invalid_arguments',\n\t\t\t\t\tmessage: `Invalid arguments for tool \"${name}\".`,\n\t\t\t\t\ttool: name,\n\t\t\t\t\tdetails\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tconst value = await found.tool.handler(input as Record<string, any>, {\n\t\t\t\tname,\n\t\t\t\tproviderId: found.provider.id,\n\t\t\t\tsignal: options.signal\n\t\t\t});\n\t\t\treturn toToolResult(value);\n\t\t} catch (error) {\n\t\t\treturn errorResult({\n\t\t\t\tcode: 'tool_failed',\n\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\ttool: name\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Subscribes to tool-list changes. Notifications are coalesced: many\n\t * registrations or provider signals within the delay window produce one\n\t * call, and none if the exposed list ends up unchanged (e.g. a provider\n\t * unmounted and remounted). Returns an unsubscribe function.\n\t */\n\tonListChanged(listener: (tools: McpToolDefinition[]) => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Schedules a coalesced `listChanged` check; providers may call it directly. */\n\tnotifyListChanged(): void {\n\t\tif (this.timer !== null) return;\n\t\tthis.timer = setTimeout(() => this.flush(), this.options.listChangedDelayMs);\n\t}\n\n\t/** Runs a pending `listChanged` check immediately. */\n\tflush(): void {\n\t\tif (this.timer !== null) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = null;\n\t\t}\n\t\tconst signature = this.signature();\n\t\tif (signature === this.lastSignature) return;\n\t\tthis.lastSignature = signature;\n\t\tconst { tools } = this.listTools();\n\t\tfor (const listener of Array.from(this.listeners)) listener(tools);\n\t}\n\n\tprivate signature(): string {\n\t\ttry {\n\t\t\treturn JSON.stringify(this.listTools().tools);\n\t\t} catch {\n\t\t\treturn String(Math.random());\n\t\t}\n\t}\n\n\t/** Unregisters every provider and listener and cancels pending notifications. */\n\tdispose(): void {\n\t\tif (this.timer !== null) clearTimeout(this.timer);\n\t\tthis.timer = null;\n\t\tfor (const entry of this.entries.splice(0)) entry.unsubscribe?.();\n\t\tthis.listeners.clear();\n\t}\n}\n\nexport function createToolRegistry(options?: ToolRegistryOptions): ToolRegistry {\n\treturn new ToolRegistry(options);\n}\n","/**\n * Standard MCP Tool Definitions for @pixerate/editor.\n * Compatible with the Model Context Protocol (MCP) tool specification schema.\n */\n\nexport const MCP_TOOL_GET_EDITOR_STATE = {\n\tname: 'get_editor_state',\n\ttitle: 'Get editor state',\n\tannotations: {\n\t\ttitle: 'Get editor state',\n\t\treadOnlyHint: true,\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Retrieves the current state of the document, variables, selection, and canvas graph (nodes and edges).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tincludeDocument: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Whether to include the prompt document text and variables (default: true).'\n\t\t\t},\n\t\t\tincludeCanvas: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Whether to include the canvas nodes and edges (default: true).'\n\t\t\t}\n\t\t}\n\t}\n} as const;\n\nexport const MCP_TOOL_EDIT_CANVAS = {\n\tname: 'edit_canvas',\n\ttitle: 'Edit the canvas',\n\tannotations: {\n\t\ttitle: 'Edit the canvas',\n\t\treadOnlyHint: false,\n\t\tdestructiveHint: true,\n\t\tidempotentHint: false,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Applies high-level structural operations to the visual canvas (adding nodes, connecting edges, organizing layout, or moving elements). ' +\n\t\t'Prefer the per-operation canvas_* tools when the host exposes them. Returns the ids of created nodes and edges.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\toperation: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: [\n\t\t\t\t\t'add_node',\n\t\t\t\t\t'remove_nodes',\n\t\t\t\t\t'connect',\n\t\t\t\t\t'update_node',\n\t\t\t\t\t'layout',\n\t\t\t\t\t'select',\n\t\t\t\t\t'highlight'\n\t\t\t\t],\n\t\t\t\tdescription: 'The canvas operation to execute.'\n\t\t\t},\n\t\t\tnode: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdescription: 'Node definition when operation is add_node. Can omit position to auto-place.'\n\t\t\t},\n\t\t\tnearNodeId: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Anchor node ID to position beside using collision-aware placement.'\n\t\t\t},\n\t\t\tside: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['top', 'right', 'bottom', 'left'],\n\t\t\t\tdescription: 'Side of the anchor node to place the new node beside.'\n\t\t\t},\n\t\t\tnodeIds: {\n\t\t\t\ttype: 'array',\n\t\t\t\titems: { type: 'string' },\n\t\t\t\tdescription: 'Array of node IDs for remove_nodes, select, or highlight.'\n\t\t\t},\n\t\t\tid: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Node ID for update_node (or pass `node: { id, data }`).'\n\t\t\t},\n\t\t\tdata: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdescription: 'Data fields to merge into the node for update_node.'\n\t\t\t},\n\t\t\tcolor: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'CSS color for highlight (default #3b82f6).'\n\t\t\t},\n\t\t\tdurationMs: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'How long the highlight lasts in ms (default 2000).'\n\t\t\t},\n\t\t\tsource: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Source node ID for connect operation.'\n\t\t\t},\n\t\t\ttarget: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Target node ID for connect operation.'\n\t\t\t},\n\t\t\tlabel: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Optional edge label for connect operation.'\n\t\t\t},\n\t\t\tdirection: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['LR', 'TB', 'RL', 'BT'],\n\t\t\t\tdescription: 'Layout direction (default LR).'\n\t\t\t},\n\t\t\tincremental: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Preserve existing node coordinates and blend layout (default true).'\n\t\t\t}\n\t\t},\n\t\trequired: ['operation']\n\t}\n} as const;\n\nexport const MCP_TOOL_EDIT_PROMPT = {\n\tname: 'edit_prompt',\n\ttitle: 'Edit the prompt',\n\tannotations: {\n\t\ttitle: 'Edit the prompt',\n\t\treadOnlyHint: false,\n\t\tdestructiveHint: true,\n\t\tidempotentHint: false,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Applies edits to the prompt template document, including inserting text, replacing ranges, and setting variables.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\toperation: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['insert_text', 'replace_range', 'set_variable', 'select'],\n\t\t\t\tdescription: 'The prompt operation to execute.'\n\t\t\t},\n\t\t\ttext: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Text to insert or replace.'\n\t\t\t},\n\t\t\tat: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'Position to insert text at.'\n\t\t\t},\n\t\t\tfrom: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'Start offset for replace_range or select.'\n\t\t\t},\n\t\t\tto: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tminimum: 0,\n\t\t\t\tdescription: 'End offset for replace_range or select.'\n\t\t\t},\n\t\t\tname: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'Variable name for set_variable.'\n\t\t\t},\n\t\t\tvalue: {\n\t\t\t\tdescription: 'Variable value for set_variable.'\n\t\t\t}\n\t\t},\n\t\trequired: ['operation']\n\t}\n} as const;\n\nexport const MCP_TOOL_VIEW_EDITOR = {\n\tname: 'view_editor',\n\ttitle: 'View the editor',\n\tannotations: {\n\t\ttitle: 'View the editor',\n\t\treadOnlyHint: true,\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false\n\t},\n\tdescription:\n\t\t'Captures a visual image snapshot (JPEG or PNG) of the editor canvas or viewport for multimodal evaluation. Active agent cursor indicators are automatically excluded from the snapshot.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tscope: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['viewport', 'canvas'],\n\t\t\t\tdescription: 'Whether to capture only the visible viewport or the full canvas bounding box (default: viewport).'\n\t\t\t},\n\t\t\tformat: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['jpeg', 'png'],\n\t\t\t\tdescription: 'Image format of the base64 snapshot (default: jpeg).'\n\t\t\t},\n\t\t\tmaxEdge: {\n\t\t\t\ttype: 'integer',\n\t\t\t\tdescription: 'Maximum width or height dimension in pixels (default: 1024).'\n\t\t\t}\n\t\t}\n\t}\n} as const;\n\n// ---------------------------------------------------------------------------\n// Per-operation tools: one strict schema per canvas / prompt operation.\n// ---------------------------------------------------------------------------\n\nconst WRITE_ANNOTATIONS = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } as const;\nconst DESTRUCTIVE_ANNOTATIONS = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false } as const;\nconst IDEMPOTENT_ANNOTATIONS = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false } as const;\n\nconst NODE_IDS = {\n\ttype: 'array',\n\titems: { type: 'string', minLength: 1 },\n\tminItems: 1,\n\tuniqueItems: true,\n\tdescription: 'Node ids (from get_editor_state).'\n} as const;\n\nconst POSITION = {\n\ttype: 'object',\n\tproperties: { x: { type: 'number' }, y: { type: 'number' } },\n\trequired: ['x', 'y'],\n\tadditionalProperties: false\n} as const;\n\nconst DOC_POSITION = { type: 'integer', minimum: 0 } as const;\n\nexport const MCP_TOOL_CANVAS_ADD_NODE = {\n\tname: 'canvas_add_node',\n\ttitle: 'Add a canvas node',\n\tannotations: { title: 'Add a canvas node', ...WRITE_ANNOTATIONS },\n\tdescription:\n\t\t'Adds a node to the canvas. Without `position` it is placed without overlaps beside `nearNodeId` (and connected from it) ' +\n\t\t'or beside the last node. Returns the new node id (generated unless you pass `node.id`) and the id of the connecting edge.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tnode: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdescription: 'The node. Extra host-specific fields are kept.',\n\t\t\t\tproperties: {\n\t\t\t\t\tid: { type: 'string', minLength: 1, description: 'Node id (default: generated). Must be unused.' },\n\t\t\t\t\ttype: { type: 'string', description: 'Node type registered by the host.' },\n\t\t\t\t\tdata: { type: 'object', description: 'Node data (e.g. { \"label\": \"...\" }).' },\n\t\t\t\t\tposition: { ...POSITION, description: 'Canvas coordinates (default: auto-placed).' },\n\t\t\t\t\twidth: { type: 'number', exclusiveMinimum: 0 },\n\t\t\t\t\theight: { type: 'number', exclusiveMinimum: 0 },\n\t\t\t\t\tparentId: { type: 'string', description: 'Parent (group/frame) node id.' }\n\t\t\t\t}\n\t\t\t},\n\t\t\tnearNodeId: { type: 'string', description: 'Existing node to place the new node beside and connect from.' },\n\t\t\tside: {\n\t\t\t\ttype: 'string',\n\t\t\t\tenum: ['top', 'right', 'bottom', 'left'],\n\t\t\t\tdescription: 'Side of `nearNodeId` to place the node on (default right).'\n\t\t\t}\n\t\t},\n\t\trequired: ['node'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_REMOVE_NODES = {\n\tname: 'canvas_remove_nodes',\n\ttitle: 'Remove canvas nodes',\n\tannotations: { title: 'Remove canvas nodes', ...DESTRUCTIVE_ANNOTATIONS },\n\tdescription: 'Removes nodes (and their edges) from the canvas. Every id must exist.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: { nodeIds: NODE_IDS },\n\t\trequired: ['nodeIds'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_CONNECT = {\n\tname: 'canvas_connect',\n\ttitle: 'Connect canvas nodes',\n\tannotations: { title: 'Connect canvas nodes', ...WRITE_ANNOTATIONS },\n\tdescription: 'Adds an edge from one existing node to another. Returns the new edge id.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tsource: { type: 'string', minLength: 1, description: 'Source node id.' },\n\t\t\ttarget: { type: 'string', minLength: 1, description: 'Target node id.' },\n\t\t\tlabel: { type: 'string', description: 'Edge label.' }\n\t\t},\n\t\trequired: ['source', 'target'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_UPDATE_NODE = {\n\tname: 'canvas_update_node',\n\ttitle: 'Update a canvas node',\n\tannotations: { title: 'Update a canvas node', ...DESTRUCTIVE_ANNOTATIONS, idempotentHint: true },\n\tdescription: \"Merges fields into an existing node's data.\",\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tid: { type: 'string', minLength: 1, description: 'Node id.' },\n\t\t\tdata: { type: 'object', description: 'Data fields to merge (e.g. { \"label\": \"New\" }).' }\n\t\t},\n\t\trequired: ['id', 'data'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_LAYOUT = {\n\tname: 'canvas_layout',\n\ttitle: 'Lay out the canvas',\n\tannotations: { title: 'Lay out the canvas', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Arranges the canvas graph automatically.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tdirection: { type: 'string', enum: ['LR', 'TB', 'RL', 'BT'], description: 'Layout direction (default LR).' },\n\t\t\tincremental: {\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Keep nodes that already have a position where they are (default true).'\n\t\t\t}\n\t\t},\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_SELECT = {\n\tname: 'canvas_select',\n\ttitle: 'Select canvas nodes',\n\tannotations: { title: 'Select canvas nodes', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Replaces the canvas selection with these nodes (an empty list clears it).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: { nodeIds: { ...NODE_IDS, minItems: 0 } },\n\t\trequired: ['nodeIds'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_CANVAS_HIGHLIGHT = {\n\tname: 'canvas_highlight',\n\ttitle: 'Highlight canvas nodes',\n\tannotations: { title: 'Highlight canvas nodes', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Briefly highlights nodes to draw the user\\'s attention to them.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tnodeIds: NODE_IDS,\n\t\t\tcolor: { type: 'string', description: 'CSS color (default #3b82f6).' },\n\t\t\tdurationMs: { type: 'integer', minimum: 0, maximum: 60000, description: 'Duration in ms (default 2000).' }\n\t\t},\n\t\trequired: ['nodeIds'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_INSERT_TEXT = {\n\tname: 'prompt_insert_text',\n\ttitle: 'Insert prompt text',\n\tannotations: { title: 'Insert prompt text', ...WRITE_ANNOTATIONS },\n\tdescription: 'Inserts text into the prompt at a position, or at the cursor when `at` is omitted.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\ttext: { type: 'string', description: 'Text to insert.' },\n\t\t\tat: { ...DOC_POSITION, description: 'Position (as in get_editor_state `document.selection`).' }\n\t\t},\n\t\trequired: ['text'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_REPLACE_RANGE = {\n\tname: 'prompt_replace_range',\n\ttitle: 'Replace prompt text',\n\tannotations: { title: 'Replace prompt text', ...DESTRUCTIVE_ANNOTATIONS },\n\tdescription: 'Replaces the prompt text between two positions (an empty text deletes it).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tfrom: { ...DOC_POSITION, description: 'Start position.' },\n\t\t\tto: { ...DOC_POSITION, description: 'End position (>= from).' },\n\t\t\ttext: { type: 'string', description: 'Replacement text.' }\n\t\t},\n\t\trequired: ['from', 'to', 'text'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_SET_VARIABLE = {\n\tname: 'prompt_set_variable',\n\ttitle: 'Set a prompt variable',\n\tannotations: { title: 'Set a prompt variable', ...DESTRUCTIVE_ANNOTATIONS, idempotentHint: true },\n\tdescription: 'Sets the value of a template variable used by the prompt.',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tname: { type: 'string', minLength: 1, description: 'Variable name.' },\n\t\t\tvalue: { description: 'Variable value (any JSON value).' }\n\t\t},\n\t\trequired: ['name', 'value'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\nexport const MCP_TOOL_PROMPT_SELECT = {\n\tname: 'prompt_select',\n\ttitle: 'Select prompt text',\n\tannotations: { title: 'Select prompt text', ...IDEMPOTENT_ANNOTATIONS },\n\tdescription: 'Selects the prompt text between two positions (from === to places the cursor).',\n\tinputSchema: {\n\t\ttype: 'object',\n\t\tproperties: {\n\t\t\tfrom: { ...DOC_POSITION, description: 'Start position.' },\n\t\t\tto: { ...DOC_POSITION, description: 'End position (>= from).' }\n\t\t},\n\t\trequired: ['from', 'to'],\n\t\tadditionalProperties: false\n\t}\n} as const;\n\n/** Per-operation canvas tools, the strict alternative to `edit_canvas`. */\nexport const EDITOR_CANVAS_TOOLS = [\n\tMCP_TOOL_CANVAS_ADD_NODE,\n\tMCP_TOOL_CANVAS_REMOVE_NODES,\n\tMCP_TOOL_CANVAS_CONNECT,\n\tMCP_TOOL_CANVAS_UPDATE_NODE,\n\tMCP_TOOL_CANVAS_LAYOUT,\n\tMCP_TOOL_CANVAS_SELECT,\n\tMCP_TOOL_CANVAS_HIGHLIGHT\n] as const;\n\n/** Per-operation prompt tools, the strict alternative to `edit_prompt`. */\nexport const EDITOR_PROMPT_TOOLS = [\n\tMCP_TOOL_PROMPT_INSERT_TEXT,\n\tMCP_TOOL_PROMPT_REPLACE_RANGE,\n\tMCP_TOOL_PROMPT_SET_VARIABLE,\n\tMCP_TOOL_PROMPT_SELECT\n] as const;\n\n/**\n * Arguments each `edit_canvas` / `edit_prompt` operation needs, used to tell\n * an agent exactly what is missing (the combined schemas cannot express it).\n */\nexport const EDIT_OPERATION_REQUIRED_ARGUMENTS: Readonly<Record<'edit_canvas' | 'edit_prompt', Readonly<Record<string, readonly string[]>>>> = {\n\tedit_canvas: {\n\t\tadd_node: ['node'],\n\t\tremove_nodes: ['nodeIds'],\n\t\tconnect: ['source', 'target'],\n\t\tupdate_node: ['id'],\n\t\tlayout: [],\n\t\tselect: ['nodeIds'],\n\t\thighlight: ['nodeIds']\n\t},\n\tedit_prompt: {\n\t\tinsert_text: ['text'],\n\t\treplace_range: ['from', 'to', 'text'],\n\t\tset_variable: ['name'],\n\t\tselect: ['from', 'to']\n\t}\n};\n\n/**\n * CSS selectors for ephemeral UI overlays (such as agent cursors, presence tags, and transient bubbles)\n * that should be excluded during canvas image export and visual snapshot generation.\n */\nexport const EXPORT_EXCLUDED_SELECTORS = [\n\t'.pixerate-presence',\n\t'.agent-presence',\n\t'.ursula-presence'\n] as const;\n\nexport const EDITOR_MCP_TOOLS = [\n\tMCP_TOOL_GET_EDITOR_STATE,\n\tMCP_TOOL_EDIT_CANVAS,\n\tMCP_TOOL_EDIT_PROMPT,\n\tMCP_TOOL_VIEW_EDITOR\n] as const;\n\n","import type { ToolRegistry } from './registry.js';\n\n/** MCP protocol revisions this server speaks, newest first. */\nexport const MCP_PROTOCOL_VERSIONS = ['2025-06-18', '2025-03-26', '2024-11-05'] as const;\n\nexport type JsonRpcId = string | number;\n\nexport interface JsonRpcRequest {\n\tjsonrpc: '2.0';\n\tid?: JsonRpcId | null;\n\tmethod: string;\n\tparams?: Record<string, any>;\n}\n\nexport interface JsonRpcResponse {\n\tjsonrpc: '2.0';\n\tid: JsonRpcId | null;\n\tresult?: unknown;\n\terror?: { code: number; message: string; data?: unknown };\n}\n\nexport interface JsonRpcNotification {\n\tjsonrpc: '2.0';\n\tmethod: string;\n\tparams?: Record<string, unknown>;\n}\n\n/** Standard JSON-RPC error codes used by the server. */\nexport const JSON_RPC_ERRORS = {\n\tparseError: -32700,\n\tinvalidRequest: -32600,\n\tmethodNotFound: -32601,\n\tinvalidParams: -32602,\n\tinternalError: -32603\n} as const;\n\nexport interface McpServerOptions {\n\t/** `serverInfo` sent in the `initialize` result. */\n\tname: string;\n\tversion: string;\n\ttitle?: string;\n\t/** Usage hints for the client's model, sent in the `initialize` result. */\n\tinstructions?: string;\n\t/**\n\t * Sends server → client messages (`notifications/tools/list_changed`).\n\t * Without it the server still answers requests but announces nothing.\n\t */\n\tsend?: (message: JsonRpcNotification) => void;\n}\n\nexport interface McpServer {\n\t/**\n\t * Handles one client message (a JSON string or a parsed object) and\n\t * resolves to the response to send back, or `null` for notifications.\n\t * Never rejects.\n\t */\n\thandle(message: string | JsonRpcRequest): Promise<JsonRpcResponse | null>;\n\t/** Whether the client has completed the `initialize` handshake. */\n\treadonly initialized: boolean;\n\t/** Stops list-changed notifications and aborts running tool calls. */\n\tclose(): void;\n}\n\nconst errorResponse = (id: JsonRpcId | null, code: number, message: string, data?: unknown): JsonRpcResponse => ({\n\tjsonrpc: '2.0',\n\tid,\n\terror: { code, message, ...(data !== undefined ? { data } : {}) }\n});\n\n/**\n * A transport-agnostic MCP server for a {@link ToolRegistry}: wire `handle`\n * to any transport (stdio lines, a WebSocket, `postMessage`, an HTTP POST\n * handler) and pass `send` for server → client notifications.\n *\n * Supports `initialize` (with protocol version negotiation), `ping`,\n * `tools/list`, `tools/call` and `notifications/cancelled` (aborts the\n * call's `signal`), and announces `notifications/tools/list_changed` after\n * the client sends `notifications/initialized`. An unknown tool is a\n * JSON-RPC `-32602` error, as the MCP spec asks; invalid arguments and\n * handler failures are `isError` tool results the model can read and fix.\n */\nexport function createMcpServer(registry: ToolRegistry, options: McpServerOptions): McpServer {\n\tlet initialized = false;\n\tlet unsubscribe: (() => void) | null = null;\n\tconst running = new Map<JsonRpcId, AbortController>();\n\n\tconst startNotifications = () => {\n\t\tif (unsubscribe || !options.send) return;\n\t\tconst send = options.send;\n\t\tunsubscribe = registry.onListChanged(() => send({ jsonrpc: '2.0', method: 'notifications/tools/list_changed' }));\n\t};\n\n\tasync function dispatch(request: JsonRpcRequest): Promise<JsonRpcResponse | null> {\n\t\tconst id = request.id ?? null;\n\t\tconst isNotification = request.id === undefined || request.id === null;\n\t\tconst params = request.params ?? {};\n\n\t\tswitch (request.method) {\n\t\t\tcase 'initialize': {\n\t\t\t\tconst requested = String(params.protocolVersion ?? '');\n\t\t\t\tconst protocolVersion = (MCP_PROTOCOL_VERSIONS as readonly string[]).includes(requested)\n\t\t\t\t\t? requested\n\t\t\t\t\t: MCP_PROTOCOL_VERSIONS[0];\n\t\t\t\treturn {\n\t\t\t\t\tjsonrpc: '2.0',\n\t\t\t\t\tid,\n\t\t\t\t\tresult: {\n\t\t\t\t\t\tprotocolVersion,\n\t\t\t\t\t\tcapabilities: registry.capabilities,\n\t\t\t\t\t\tserverInfo: { name: options.name, version: options.version, ...(options.title ? { title: options.title } : {}) },\n\t\t\t\t\t\t...(options.instructions ? { instructions: options.instructions } : {})\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\tcase 'notifications/initialized':\n\t\t\t\tinitialized = true;\n\t\t\t\tstartNotifications();\n\t\t\t\treturn null;\n\t\t\tcase 'notifications/cancelled': {\n\t\t\t\tconst requestId = params.requestId as JsonRpcId | undefined;\n\t\t\t\tif (requestId !== undefined) running.get(requestId)?.abort(params.reason);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tcase 'ping':\n\t\t\t\treturn { jsonrpc: '2.0', id, result: {} };\n\t\t\tcase 'tools/list':\n\t\t\t\treturn { jsonrpc: '2.0', id, result: registry.listTools() };\n\t\t\tcase 'tools/call': {\n\t\t\t\tconst name = params.name;\n\t\t\t\tif (typeof name !== 'string') {\n\t\t\t\t\treturn errorResponse(id, JSON_RPC_ERRORS.invalidParams, 'tools/call needs a string \"name\".');\n\t\t\t\t}\n\t\t\t\tif (!registry.hasTool(name)) {\n\t\t\t\t\treturn errorResponse(id, JSON_RPC_ERRORS.invalidParams, `Unknown tool: ${name}`);\n\t\t\t\t}\n\t\t\t\tconst args = params.arguments;\n\t\t\t\tif (args !== undefined && (typeof args !== 'object' || args === null || Array.isArray(args))) {\n\t\t\t\t\treturn errorResponse(id, JSON_RPC_ERRORS.invalidParams, '\"arguments\" must be an object.');\n\t\t\t\t}\n\t\t\t\tconst controller = new AbortController();\n\t\t\t\tif (!isNotification) running.set(id as JsonRpcId, controller);\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await registry.callTool(name, args ?? {}, { signal: controller.signal });\n\t\t\t\t\t// A cancelled request gets no response (MCP cancellation semantics).\n\t\t\t\t\tif (controller.signal.aborted) return null;\n\t\t\t\t\treturn { jsonrpc: '2.0', id, result };\n\t\t\t\t} finally {\n\t\t\t\t\tif (!isNotification) running.delete(id as JsonRpcId);\n\t\t\t\t}\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif (isNotification) return null;\n\t\t\t\treturn errorResponse(id, JSON_RPC_ERRORS.methodNotFound, `Method not found: ${request.method}`);\n\t\t}\n\t}\n\n\treturn {\n\t\tget initialized() {\n\t\t\treturn initialized;\n\t\t},\n\t\tasync handle(message) {\n\t\t\tlet request: JsonRpcRequest;\n\t\t\tif (typeof message === 'string') {\n\t\t\t\ttry {\n\t\t\t\t\trequest = JSON.parse(message);\n\t\t\t\t} catch {\n\t\t\t\t\treturn errorResponse(null, JSON_RPC_ERRORS.parseError, 'Parse error.');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trequest = message;\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!request ||\n\t\t\t\ttypeof request !== 'object' ||\n\t\t\t\tArray.isArray(request) ||\n\t\t\t\trequest.jsonrpc !== '2.0' ||\n\t\t\t\ttypeof request.method !== 'string'\n\t\t\t) {\n\t\t\t\tconst id = request && typeof request === 'object' && !Array.isArray(request) ? (request as JsonRpcRequest).id ?? null : null;\n\t\t\t\treturn errorResponse(id, JSON_RPC_ERRORS.invalidRequest, 'Invalid JSON-RPC 2.0 request.');\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn await dispatch(request);\n\t\t\t} catch (error) {\n\t\t\t\tif (request.id === undefined || request.id === null) return null;\n\t\t\t\treturn errorResponse(\n\t\t\t\t\trequest.id,\n\t\t\t\t\tJSON_RPC_ERRORS.internalError,\n\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\tclose() {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = null;\n\t\t\tfor (const controller of running.values()) controller.abort('Server closed.');\n\t\t\trunning.clear();\n\t\t}\n\t};\n}\n"]}