diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..d470a4f --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,19 @@ +# Agents file for lambda-mcp-adaptor + +## Project structure +- `src/`: Source files for the MCP server SDK (ESM entrypoints and types). +- `tests/`: Mocha test suite (`*.test.mjs`). +- `example/`: Sample usage code. +- `dist/`: Build outputs (ESM, CJS, and type declarations). +- Root config: `package.json`, `eslint.config.mjs`, `.prettierrc`. + +## Build +- `npm run build` (runs ESM, CJS, and types outputs). +- Individual steps: `npm run build:esm`, `npm run build:cjs`, `npm run build:types`. + +## Test +- `npm test` (Mocha runs `tests/**/*.test.mjs`). + +## lint and format +Lint and format are currently in package.json but do not function properly. That will +be remedied in the future. diff --git a/dist/cors-config-C27FWWLN.mjs b/dist/cors-config-C27FWWLN.mjs new file mode 100644 index 0000000..c209a7b --- /dev/null +++ b/dist/cors-config-C27FWWLN.mjs @@ -0,0 +1,40 @@ +//#region src/cors-config.ts +/** +* CORS Configuration +* +* Centralized CORS headers configuration for consistent handling across all modules +*/ +/** +* Standard CORS headers for MCP server responses +* Includes all necessary headers for MCP protocol and authentication +*/ +const CORS_HEADERS = { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Content-Type, Accept, Authorization, Mcp-Protocol-Version, Mcp-Session-Id", + "Access-Control-Allow-Methods": "GET, POST, OPTIONS" +}; +/** +* Basic CORS headers for simple responses +*/ +const BASIC_CORS_HEADERS = { "Access-Control-Allow-Origin": "*" }; +/** +* Create response headers with CORS +*/ +function withCORS(additionalHeaders = {}) { + return { + ...CORS_HEADERS, + ...additionalHeaders + }; +} +/** +* Create basic response headers with CORS +*/ +function withBasicCORS(additionalHeaders = {}) { + return { + ...BASIC_CORS_HEADERS, + ...additionalHeaders + }; +} + +//#endregion +export { withBasicCORS as n, withCORS as r, CORS_HEADERS as t }; \ No newline at end of file diff --git a/dist/cors-config-HN36M-Ox.cjs b/dist/cors-config-HN36M-Ox.cjs new file mode 100644 index 0000000..aadf5f5 --- /dev/null +++ b/dist/cors-config-HN36M-Ox.cjs @@ -0,0 +1,58 @@ + +//#region src/cors-config.ts +/** +* CORS Configuration +* +* Centralized CORS headers configuration for consistent handling across all modules +*/ +/** +* Standard CORS headers for MCP server responses +* Includes all necessary headers for MCP protocol and authentication +*/ +const CORS_HEADERS = { + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": "Content-Type, Accept, Authorization, Mcp-Protocol-Version, Mcp-Session-Id", + "Access-Control-Allow-Methods": "GET, POST, OPTIONS" +}; +/** +* Basic CORS headers for simple responses +*/ +const BASIC_CORS_HEADERS = { "Access-Control-Allow-Origin": "*" }; +/** +* Create response headers with CORS +*/ +function withCORS(additionalHeaders = {}) { + return { + ...CORS_HEADERS, + ...additionalHeaders + }; +} +/** +* Create basic response headers with CORS +*/ +function withBasicCORS(additionalHeaders = {}) { + return { + ...BASIC_CORS_HEADERS, + ...additionalHeaders + }; +} + +//#endregion +Object.defineProperty(exports, 'CORS_HEADERS', { + enumerable: true, + get: function () { + return CORS_HEADERS; + } +}); +Object.defineProperty(exports, 'withBasicCORS', { + enumerable: true, + get: function () { + return withBasicCORS; + } +}); +Object.defineProperty(exports, 'withCORS', { + enumerable: true, + get: function () { + return withCORS; + } +}); \ No newline at end of file diff --git a/dist/index.cjs b/dist/index.cjs new file mode 100644 index 0000000..63868dc --- /dev/null +++ b/dist/index.cjs @@ -0,0 +1,499 @@ +const require_cors_config = require('./cors-config-HN36M-Ox.cjs'); +let zod = require("zod"); + +//#region src/schema-utils.ts +/** +* Schema Utilities +* +* Zod schema conversion and validation utilities +*/ +/** +* Convert Zod schema to JSON Schema +*/ +function zodToJsonSchema(zodSchema) { + const properties = {}; + const required = []; + for (const [key, schema] of Object.entries(zodSchema)) { + properties[key] = convertZodTypeToJsonSchema(schema); + if (!isZodOptional(schema)) required.push(key); + } + return { + type: "object", + properties, + required + }; +} +/** +* Convert individual Zod type to JSON Schema +*/ +function convertZodTypeToJsonSchema(zodType) { + if (zodType instanceof zod.z.ZodOptional) { + const def = zodType._def; + return convertZodTypeToJsonSchema(def.innerType); + } + if (zodType instanceof zod.z.ZodDefault) { + const def = zodType._def; + const schema = convertZodTypeToJsonSchema(def.innerType); + schema.default = def.defaultValue(); + return schema; + } + if (zodType instanceof zod.z.ZodString) { + const schema = { type: "string" }; + const def = zodType._def; + if (def.checks) for (const check of def.checks) switch (check.kind) { + case "min": + schema.minLength = check.value; + break; + case "max": + schema.maxLength = check.value; + break; + case "email": + schema.format = "email"; + break; + case "url": + schema.format = "uri"; + break; + case "uuid": + schema.format = "uuid"; + break; + } + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof zod.z.ZodNumber) { + const schema = { type: "number" }; + const def = zodType._def; + if (def.checks) for (const check of def.checks) switch (check.kind) { + case "min": + schema.minimum = check.value; + break; + case "max": + schema.maximum = check.value; + break; + case "int": + schema.type = "integer"; + break; + } + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof zod.z.ZodBoolean) { + const schema = { type: "boolean" }; + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof zod.z.ZodEnum) { + const schema = { + type: "string", + enum: zodType._def.values + }; + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof zod.z.ZodArray) { + const schema = { + type: "array", + items: convertZodTypeToJsonSchema(zodType._def.type) + }; + if (zodType._def.minLength) schema.minItems = zodType._def.minLength.value; + if (zodType._def.maxLength) schema.maxItems = zodType._def.maxLength.value; + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof zod.z.ZodObject) return zodToJsonSchema(zodType.shape); + return { + type: "string", + description: zodType.description || "Unknown type" + }; +} +/** +* Check if Zod type is optional +*/ +function isZodOptional(zodType) { + return zodType instanceof zod.z.ZodOptional || zodType instanceof zod.z.ZodDefault; +} +/** +* Check if Zod type has default value +*/ +function hasZodDefault(zodType) { + return zodType instanceof zod.z.ZodDefault; +} +/** +* Validate arguments with Zod schema +*/ +function validateWithZod(zodSchema, args) { + const validated = {}; + for (const [key, schema] of Object.entries(zodSchema)) try { + if (args[key] === void 0 && isZodOptional(schema)) { + if (hasZodDefault(schema)) validated[key] = schema.parse(void 0); + continue; + } + validated[key] = schema.parse(args[key]); + } catch (error) { + throw new zod.z.ZodError([{ + code: "custom", + path: [key], + message: error instanceof Error ? error.message : String(error) + }]); + } + return validated; +} + +//#endregion +//#region src/mcp-server.ts +/** +* MCP Server Core Implementation +* +* Handles MCP protocol logic and tool/resource/prompt management +*/ +/** +* Main MCP Server class with Zod-based type safety +*/ +var MCPServer = class { + config; + tools; + resources; + prompts; + constructor(config) { + const { name = "MCP Server", version = "1.0.0", description = "MCP Server powered by AWS Lambda", protocolVersion = "2025-03-26", ...rest } = config; + this.config = { + name, + version, + description, + protocolVersion, + ...rest + }; + this.tools = /* @__PURE__ */ new Map(); + this.resources = /* @__PURE__ */ new Map(); + this.prompts = /* @__PURE__ */ new Map(); + } + /** + * Register a tool with Zod schema validation + */ + tool(name, inputSchema, handler, options) { + const jsonSchema = zodToJsonSchema(inputSchema); + let outputSchema = void 0; + if (options?.outputZodSchema) outputSchema = zodToJsonSchema(options.outputZodSchema); + const handlerDescription = handler.description; + const validatedHandler = async (args) => { + try { + return await handler(validateWithZod(inputSchema, args)); + } catch (error) { + if (error instanceof zod.z.ZodError) throw new Error(`Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`); + throw error; + } + }; + this.tools.set(name, { + name, + description: handlerDescription || `Tool: ${name}`, + inputSchema: jsonSchema, + handler: validatedHandler, + options: { + outputSchema, + annotations: options?.annotations + } + }); + return this; + } + /** + * Register a resource + */ + resource(name, uri, handler) { + const handlerDescription = handler.description; + this.resources.set(name, { + name, + uri, + description: handlerDescription || `Resource: ${name}`, + handler: async (resourceUri) => handler(resourceUri) + }); + return this; + } + /** + * Register a prompt with Zod schema validation + */ + prompt(name, inputSchema, handler) { + zodToJsonSchema(inputSchema); + const handlerDescription = handler.description; + const validatedHandler = async (args) => { + try { + return await handler(validateWithZod(inputSchema, args)); + } catch (error) { + if (error instanceof zod.z.ZodError) throw new Error(`Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`); + throw error; + } + }; + this.prompts.set(name, { + name, + description: handlerDescription || `Prompt: ${name}`, + arguments: Object.entries(inputSchema).map(([key, schema]) => ({ + name: key, + description: schema.description || `${key} parameter`, + required: !isZodOptional(schema) + })), + handler: validatedHandler + }); + return this; + } + async handleRequest(request) { + switch (request.method) { + case "initialize": return this.handleInitialize(); + case "notifications/initialized": return null; + case "tools/list": return this.handleToolsList(); + case "tools/call": return this.handleToolsCall(request.params); + case "resources/list": return this.handleResourcesList(); + case "resources/read": return this.handleResourcesRead(request.params); + case "prompts/list": return this.handlePromptsList(); + case "prompts/get": return this.handlePromptsGet(request.params); + default: throw new Error(`Method not found: ${request.method}`); + } + } + /** + * Handle initialize request + */ + async handleInitialize() { + return { + protocolVersion: this.config.protocolVersion, + capabilities: { + tools: { listChanged: true }, + resources: { listChanged: true }, + prompts: { listChanged: true } + }, + serverInfo: { + name: this.config.name, + version: this.config.version + }, + instructions: this.config.description + }; + } + /** + * Handle tools/list request + */ + async handleToolsList() { + return { tools: Array.from(this.tools.values()).map((tool) => ({ + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + outputSchema: tool.options?.outputSchema, + annotations: tool.options?.annotations + })) }; + } + /** + * Handle tools/call request + */ + async handleToolsCall(params) { + if (!params?.name) throw new Error("Tool name is required"); + const tool = this.tools.get(params.name); + if (!tool) throw new Error(`Tool not found: ${params.name}`); + try { + return await tool.handler(params.arguments || {}); + } catch (error) { + return { + content: [{ + type: "text", + text: `Error: ${error instanceof Error ? error.message : String(error)}` + }], + isError: true + }; + } + } + /** + * Handle resources/list request + */ + async handleResourcesList() { + return { resources: Array.from(this.resources.values()).map((resource) => ({ + uri: resource.uri, + name: resource.name, + description: resource.description + })) }; + } + /** + * Handle resources/read request + */ + async handleResourcesRead(params) { + if (!params?.uri) throw new Error("Resource URI is required"); + const resource = Array.from(this.resources.values()).find((r) => r.uri === params.uri); + if (!resource) throw new Error(`Resource not found: ${params.uri}`); + try { + return await resource.handler(params.uri); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Resource read error: ${errorMessage}`); + } + } + /** + * Handle prompts/list request + */ + async handlePromptsList() { + return { prompts: Array.from(this.prompts.values()).map((prompt) => ({ + name: prompt.name, + description: prompt.description, + arguments: prompt.arguments + })) }; + } + /** + * Handle prompts/get request + */ + async handlePromptsGet(params) { + if (!params?.name) throw new Error("Prompt name is required"); + const prompt = this.prompts.get(params.name); + if (!prompt) throw new Error(`Prompt not found: ${params.name}`); + try { + return await prompt.handler(params.arguments || {}); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Prompt execution error: ${errorMessage}`); + } + } + /** + * Get server statistics + */ + getStats() { + return { + tools: this.tools.size, + resources: this.resources.size, + prompts: this.prompts.size, + config: this.config + }; + } +}; + +//#endregion +//#region src/lambda-adapter.ts +/** +* Create HTTP response +*/ +function createResponse(body, statusCode = 200, headers = {}) { + return { + statusCode, + headers: { + "Content-Type": "application/json", + ...headers + }, + body: typeof body === "string" ? body : JSON.stringify(body) + }; +} +/** +* Create error response +*/ +function createErrorResponse(statusCode, code, message, headers = {}, id = null) { + return createResponse({ + jsonrpc: "2.0", + error: { + code, + message + }, + id + }, statusCode, headers); +} +/** +* Handle MCP request processing +*/ +async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { + if (!(headers["content-type"] || headers["Content-Type"] || "").includes("application/json")) return createErrorResponse(400, -32700, "Parse error: Content-Type must be application/json", corsHeaders); + let jsonRpcMessage; + try { + jsonRpcMessage = JSON.parse(body || "{}"); + } catch { + return createErrorResponse(400, -32700, "Parse error: Invalid JSON", corsHeaders); + } + const responseId = "id" in jsonRpcMessage ? jsonRpcMessage.id : null; + if (!jsonRpcMessage.jsonrpc || jsonRpcMessage.jsonrpc !== "2.0") return createErrorResponse(400, -32600, "Invalid Request: missing jsonrpc field", corsHeaders, responseId); + if (!jsonRpcMessage.method) return createErrorResponse(400, -32600, "Invalid Request: missing method field", corsHeaders, responseId); + try { + const result = await mcpServer.handleRequest(jsonRpcMessage); + if (result === null) return createResponse("", 204, corsHeaders); + return createResponse({ + jsonrpc: "2.0", + result, + id: responseId + }, 200, corsHeaders); + } catch (error) { + console.error("MCP request error:", error); + let errorCode = -32603; + const errorMessage = error instanceof Error ? error.message : String(error); + if (errorMessage.includes("Method not found")) errorCode = -32601; + else if (errorMessage.includes("not found") || errorMessage.includes("required")) errorCode = -32602; + return createErrorResponse(500, errorCode, errorMessage, corsHeaders, responseId); + } +} +/** +* AWS Lambda Adapter for MCP Server +*/ +function createLambdaHandler(mcpServer, options = {}) { + const baseHandler = async (event) => { + try { + const method = "httpMethod" in event ? event.httpMethod : event.requestContext?.http?.method; + const headers = event.headers || {}; + if (method === "OPTIONS") return createResponse("", 200, require_cors_config.CORS_HEADERS); + if (method === "POST") return await handleMCPRequest(mcpServer, event.body, headers, require_cors_config.CORS_HEADERS); + if (method === "GET") return createErrorResponse(405, -32e3, "Method not allowed: Stateless mode", require_cors_config.CORS_HEADERS); + return createErrorResponse(405, -32e3, `Method not allowed: ${method}`, require_cors_config.CORS_HEADERS); + } catch (error) { + console.error("Lambda error:", error); + return createErrorResponse(500, -32603, "Internal server error", require_cors_config.withBasicCORS({ "Content-Type": "application/json" })); + } + }; + if (options.auth) { + const authConfig = options.auth; + return async (event, context) => { + try { + const { createAuthenticatedHandler } = await Promise.resolve().then(() => require("./middleware-BZkZMXHu.cjs")); + return await createAuthenticatedHandler(baseHandler, authConfig)(event, context); + } catch (error) { + console.error("Authentication module error:", error); + return { + statusCode: 500, + headers: require_cors_config.withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "server_error", + message: "Authentication module not available" + }) + }; + } + }; + } + return baseHandler; +} + +//#endregion +//#region src/common-schemas.ts +/** +* Common Zod Schemas +* +* Pre-defined schemas for common use cases +*/ +/** +* Common schema patterns for MCP tools +*/ +const CommonSchemas = { + string: zod.z.string(), + number: zod.z.number(), + boolean: zod.z.boolean(), + optionalString: zod.z.string().optional(), + optionalNumber: zod.z.number().optional(), + optionalBoolean: zod.z.boolean().optional(), + email: zod.z.string().email(), + url: zod.z.string().url(), + uuid: zod.z.string().uuid(), + enum: (values) => zod.z.enum(values), + array: (itemSchema) => zod.z.array(itemSchema), + object: (shape) => zod.z.object(shape) +}; + +//#endregion +//#region src/index.ts +/** +* @aws-lambda-mcp/adapter +* +* An MCP (Model Context Protocol) server SDK for AWS Lambda +* with Zod-based type safety, authentication support, and clean separation of concerns. +*/ +function createMCPServer(config) { + return new MCPServer(config); +} + +//#endregion +exports.CommonSchemas = CommonSchemas; +exports.MCPServer = MCPServer; +exports.createLambdaHandler = createLambdaHandler; +exports.createMCPServer = createMCPServer; \ No newline at end of file diff --git a/dist/index.d.cts b/dist/index.d.cts new file mode 100644 index 0000000..2ab797d --- /dev/null +++ b/dist/index.d.cts @@ -0,0 +1,1653 @@ +import { z } from "zod"; +import { Writable } from "node:stream"; + +//#region src/mcp-spec.d.ts +/** @internal */ +declare const JSONRPC_VERSION = '2.0'; +/** + * Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions. + * + * Certain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions. + * + * Valid keys have two segments: + * + * **Prefix:** + * - Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`). + * - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`). + * - Any prefix consisting of zero or more labels, followed by `modelcontextprotocol` or `mcp`, followed by any label, is **reserved** for MCP use. For example: `modelcontextprotocol.io/`, `mcp.dev/`, `api.modelcontextprotocol.org/`, and `tools.mcp.com/` are all reserved. + * + * **Name:** + * - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`). + * - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`). + * + * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details. + * @category Common Types + */ +type MetaObject = Record; +/** + * Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply. + * + * @see {@link MetaObject} for key naming rules and reserved prefixes. + * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details. + * @category Common Types + */ +interface RequestMetaObject extends MetaObject { + /** + * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by {@link ProgressNotification | notifications/progress}). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. + */ + progressToken?: ProgressToken; +} +/** + * A progress token, used to associate progress notifications with the original request. + * + * @category Common Types + */ +type ProgressToken = string | number; +/** + * An opaque token used to represent a cursor for pagination. + * + * @category Common Types + */ +type Cursor = string; +/** + * Common params for any task-augmented request. + * + * @internal + */ +interface TaskAugmentedRequestParams extends RequestParams { + /** + * If specified, the caller is requesting task-augmented execution for this request. + * The request will return a {@link CreateTaskResult} immediately, and the actual result can be + * retrieved later via {@link GetTaskPayloadRequest | tasks/result}. + * + * Task augmentation is subject to capability negotiation - receivers MUST declare support + * for task augmentation of specific request types in their capabilities. + */ + task?: TaskMetadata; +} +/** + * Common params for any request. + * + * @category Common Types + */ +interface RequestParams { + _meta?: RequestMetaObject; +} +/** @internal */ +interface Request { + method: string; // Allow unofficial extensions of `Request.params` without impacting `RequestParams`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: { + [key: string]: any; + }; +} +/** + * Common params for any notification. + * + * @category Common Types + */ +interface NotificationParams { + _meta?: MetaObject; +} +/** @internal */ +interface Notification { + method: string; // Allow unofficial extensions of `Notification.params` without impacting `NotificationParams`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: { + [key: string]: any; + }; +} +/** + * Common result fields. + * + * @category Common Types + */ +interface Result { + _meta?: MetaObject; + [key: string]: unknown; +} +/** + * A uniquely identifying ID for a request in JSON-RPC. + * + * @category Common Types + */ +type RequestId = string | number; +/** + * A request that expects a response. + * + * @category JSON-RPC + */ +interface JSONRPCRequest extends Request { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; +} +/** + * A notification which does not expect a response. + * + * @category JSON-RPC + */ +interface JSONRPCNotification extends Notification { + jsonrpc: typeof JSONRPC_VERSION; +} +/* Initialization */ +/** + * Parameters for an `initialize` request. + * + * @example Full client capabilities + * {@includeCode ./examples/InitializeRequestParams/full-client-capabilities.json} + * + * @category `initialize` + */ +interface InitializeRequestParams extends RequestParams { + /** + * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. + */ + protocolVersion: string; + capabilities: ClientCapabilities; + clientInfo: Implementation; +} +/** + * This request is sent from the client to the server when it first connects, asking it to begin initialization. + * + * @example Initialize request + * {@includeCode ./examples/InitializeRequest/initialize-request.json} + * + * @category `initialize` + */ +interface InitializeRequest extends JSONRPCRequest { + method: 'initialize'; + params: InitializeRequestParams; +} +/** + * The result returned by the server for an {@link InitializeRequest | initialize} request. + * + * @example Full server capabilities + * {@includeCode ./examples/InitializeResult/full-server-capabilities.json} + * + * @category `initialize` + */ +interface InitializeResult extends Result { + /** + * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. + */ + protocolVersion: string; + capabilities: ServerCapabilities; + serverInfo: Implementation; + /** + * Instructions describing how to use the server and its features. + * + * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. + */ + instructions?: string; +} +/** + * This notification is sent from the client to the server after initialization has finished. + * + * @example Initialized notification + * {@includeCode ./examples/InitializedNotification/initialized-notification.json} + * + * @category `notifications/initialized` + */ +interface InitializedNotification extends JSONRPCNotification { + method: 'notifications/initialized'; + params?: NotificationParams; +} +/** + * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities. + * + * @category `initialize` + */ +interface ClientCapabilities { + /** + * Experimental, non-standard capabilities that the client supports. + */ + experimental?: { + [key: string]: object; + }; + /** + * Present if the client supports listing roots. + * + * @example Roots — minimum baseline support + * {@includeCode ./examples/ClientCapabilities/roots-minimum-baseline-support.json} + * + * @example Roots — list changed notifications + * {@includeCode ./examples/ClientCapabilities/roots-list-changed-notifications.json} + */ + roots?: { + /** + * Whether the client supports notifications for changes to the roots list. + */ + listChanged?: boolean; + }; + /** + * Present if the client supports sampling from an LLM. + * + * @example Sampling — minimum baseline support + * {@includeCode ./examples/ClientCapabilities/sampling-minimum-baseline-support.json} + * + * @example Sampling — tool use support + * {@includeCode ./examples/ClientCapabilities/sampling-tool-use-support.json} + * + * @example Sampling — context inclusion support (soft-deprecated) + * {@includeCode ./examples/ClientCapabilities/sampling-context-inclusion-support-soft-deprecated.json} + */ + sampling?: { + /** + * Whether the client supports context inclusion via `includeContext` parameter. + * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it). + */ + context?: object; + /** + * Whether the client supports tool use via `tools` and `toolChoice` parameters. + */ + tools?: object; + }; + /** + * Present if the client supports elicitation from the server. + * + * @example Elicitation — form and URL mode support + * {@includeCode ./examples/ClientCapabilities/elicitation-form-and-url-mode-support.json} + * + * @example Elicitation — form mode only (implicit) + * {@includeCode ./examples/ClientCapabilities/elicitation-form-only-implicit.json} + */ + elicitation?: { + form?: object; + url?: object; + }; + /** + * Present if the client supports task-augmented requests. + */ + tasks?: { + /** + * Whether this client supports {@link ListTasksRequest | tasks/list}. + */ + list?: object; + /** + * Whether this client supports {@link CancelTaskRequest | tasks/cancel}. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for sampling-related requests. + */ + sampling?: { + /** + * Whether the client supports task-augmented `sampling/createMessage` requests. + */ + createMessage?: object; + }; + /** + * Task support for elicitation-related requests. + */ + elicitation?: { + /** + * Whether the client supports task-augmented {@link ElicitRequest | elicitation/create} requests. + */ + create?: object; + }; + }; + }; +} +/** + * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. + * + * @category `initialize` + */ +interface ServerCapabilities { + /** + * Experimental, non-standard capabilities that the server supports. + */ + experimental?: { + [key: string]: object; + }; + /** + * Present if the server supports sending log messages to the client. + * + * @example Logging — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/logging-minimum-baseline-support.json} + */ + logging?: object; + /** + * Present if the server supports argument autocompletion suggestions. + * + * @example Completions — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/completions-minimum-baseline-support.json} + */ + completions?: object; + /** + * Present if the server offers any prompt templates. + * + * @example Prompts — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/prompts-minimum-baseline-support.json} + * + * @example Prompts — list changed notifications + * {@includeCode ./examples/ServerCapabilities/prompts-list-changed-notifications.json} + */ + prompts?: { + /** + * Whether this server supports notifications for changes to the prompt list. + */ + listChanged?: boolean; + }; + /** + * Present if the server offers any resources to read. + * + * @example Resources — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/resources-minimum-baseline-support.json} + * + * @example Resources — subscription to individual resource updates (only) + * {@includeCode ./examples/ServerCapabilities/resources-subscription-to-individual-resource-updates-only.json} + * + * @example Resources — list changed notifications (only) + * {@includeCode ./examples/ServerCapabilities/resources-list-changed-notifications-only.json} + * + * @example Resources — all notifications + * {@includeCode ./examples/ServerCapabilities/resources-all-notifications.json} + */ + resources?: { + /** + * Whether this server supports subscribing to resource updates. + */ + subscribe?: boolean; + /** + * Whether this server supports notifications for changes to the resource list. + */ + listChanged?: boolean; + }; + /** + * Present if the server offers any tools to call. + * + * @example Tools — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/tools-minimum-baseline-support.json} + * + * @example Tools — list changed notifications + * {@includeCode ./examples/ServerCapabilities/tools-list-changed-notifications.json} + */ + tools?: { + /** + * Whether this server supports notifications for changes to the tool list. + */ + listChanged?: boolean; + }; + /** + * Present if the server supports task-augmented requests. + */ + tasks?: { + /** + * Whether this server supports {@link ListTasksRequest | tasks/list}. + */ + list?: object; + /** + * Whether this server supports {@link CancelTaskRequest | tasks/cancel}. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for tool-related requests. + */ + tools?: { + /** + * Whether the server supports task-augmented {@link CallToolRequest | tools/call} requests. + */ + call?: object; + }; + }; + }; +} +/** + * An optionally-sized icon that can be displayed in a user interface. + * + * @category Common Types + */ +interface Icon { + /** + * A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a + * `data:` URI with Base64-encoded image data. + * + * Consumers SHOULD take steps to ensure URLs serving icons are from the + * same domain as the client/server or a trusted domain. + * + * Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain + * executable JavaScript. + * + * @format uri + */ + src: string; + /** + * Optional MIME type override if the source MIME type is missing or generic. + * For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`. + */ + mimeType?: string; + /** + * Optional array of strings that specify sizes at which the icon can be used. + * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG. + * + * If not provided, the client should assume that the icon can be used at any size. + */ + sizes?: string[]; + /** + * Optional specifier for the theme this icon is designed for. `"light"` indicates + * the icon is designed to be used with a light background, and `"dark"` indicates + * the icon is designed to be used with a dark background. + * + * If not provided, the client should assume the icon can be used with any theme. + */ + theme?: 'light' | 'dark'; +} +/** + * Base interface to add `icons` property. + * + * @internal + */ +interface Icons { + /** + * Optional set of sized icons that the client can display in a user interface. + * + * Clients that support rendering icons MUST support at least the following MIME types: + * - `image/png` - PNG images (safe, universal compatibility) + * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility) + * + * Clients that support rendering icons SHOULD also support: + * - `image/svg+xml` - SVG images (scalable but requires security precautions) + * - `image/webp` - WebP images (modern, efficient format) + */ + icons?: Icon[]; +} +/** + * Base interface for metadata with name (identifier) and title (display name) properties. + * + * @internal + */ +interface BaseMetadata { + /** + * Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + */ + name: string; + /** + * Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + * even by those unfamiliar with domain-specific terminology. + * + * If not provided, the name should be used for display (except for {@link Tool}, + * where `annotations.title` should be given precedence over using `name`, + * if present). + */ + title?: string; +} +/** + * Describes the MCP implementation. + * + * @category `initialize` + */ +interface Implementation extends BaseMetadata, Icons { + version: string; + /** + * An optional human-readable description of what this implementation does. + * + * This can be used by clients or servers to provide context about their purpose + * and capabilities. For example, a server might describe the types of resources + * or tools it provides, while a client might describe its intended use case. + */ + description?: string; + /** + * An optional URL of the website for this implementation. + * + * @format uri + */ + websiteUrl?: string; +} +/* Pagination */ +/** + * Common params for paginated requests. + * + * @example List request with cursor + * {@includeCode ./examples/PaginatedRequestParams/list-with-cursor.json} + * + * @category Common Types + */ +interface PaginatedRequestParams extends RequestParams { + /** + * An opaque token representing the current pagination position. + * If provided, the server should return results starting after this cursor. + */ + cursor?: Cursor; +} +/** @internal */ +interface PaginatedRequest extends JSONRPCRequest { + params?: PaginatedRequestParams; +} +/** @internal */ +interface PaginatedResult extends Result { + /** + * An opaque token representing the pagination position after the last returned result. + * If present, there may be more results available. + */ + nextCursor?: Cursor; +} +/* Resources */ +/** + * Sent from the client to request a list of resources the server has. + * + * @example List resources request + * {@includeCode ./examples/ListResourcesRequest/list-resources-request.json} + * + * @category `resources/list` + */ +interface ListResourcesRequest extends PaginatedRequest { + method: 'resources/list'; +} +/** + * The result returned by the server for a {@link ListResourcesRequest | resources/list} request. + * + * @example Resources list with cursor + * {@includeCode ./examples/ListResourcesResult/resources-list-with-cursor.json} + * + * @category `resources/list` + */ +interface ListResourcesResult extends PaginatedResult { + resources: Resource[]; +} +/** + * Common params for resource-related requests. + * + * @internal + */ +interface ResourceRequestParams extends RequestParams { + /** + * The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri + */ + uri: string; +} +/** + * Parameters for a `resources/read` request. + * + * @category `resources/read` + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +interface ReadResourceRequestParams extends ResourceRequestParams {} +/** + * Sent from the client to the server, to read a specific resource URI. + * + * @example Read resource request + * {@includeCode ./examples/ReadResourceRequest/read-resource-request.json} + * + * @category `resources/read` + */ +interface ReadResourceRequest extends JSONRPCRequest { + method: 'resources/read'; + params: ReadResourceRequestParams; +} +/** + * The result returned by the server for a {@link ReadResourceRequest | resources/read} request. + * + * @example File resource contents + * {@includeCode ./examples/ReadResourceResult/file-resource-contents.json} + * + * @category `resources/read` + */ +interface ReadResourceResult extends Result { + contents: (TextResourceContents | BlobResourceContents)[]; +} +/** + * A known resource that the server is capable of reading. + * + * @example File resource with annotations + * {@includeCode ./examples/Resource/file-resource-with-annotations.json} + * + * @category `resources/list` + */ +interface Resource extends BaseMetadata, Icons { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + /** + * A description of what this resource represents. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + */ + description?: string; + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + /** + * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. + * + * This can be used by Hosts to display file sizes and estimate context window usage. + */ + size?: number; + _meta?: MetaObject; +} +/** + * The contents of a specific resource or sub-resource. + * + * @internal + */ +interface ResourceContents { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + _meta?: MetaObject; +} +/** + * @example Text file contents + * {@includeCode ./examples/TextResourceContents/text-file-contents.json} + * + * @category Content + */ +interface TextResourceContents extends ResourceContents { + /** + * The text of the item. This must only be set if the item can actually be represented as text (not binary data). + */ + text: string; +} +/** + * @example Image file contents + * {@includeCode ./examples/BlobResourceContents/image-file-contents.json} + * + * @category Content + */ +interface BlobResourceContents extends ResourceContents { + /** + * A base64-encoded string representing the binary data of the item. + * + * @format byte + */ + blob: string; +} +/* Prompts */ +/** + * Sent from the client to request a list of prompts and prompt templates the server has. + * + * @example List prompts request + * {@includeCode ./examples/ListPromptsRequest/list-prompts-request.json} + * + * @category `prompts/list` + */ +interface ListPromptsRequest extends PaginatedRequest { + method: 'prompts/list'; +} +/** + * The result returned by the server for a {@link ListPromptsRequest | prompts/list} request. + * + * @example Prompts list with cursor + * {@includeCode ./examples/ListPromptsResult/prompts-list-with-cursor.json} + * + * @category `prompts/list` + */ +interface ListPromptsResult extends PaginatedResult { + prompts: Prompt[]; +} +/** + * Parameters for a `prompts/get` request. + * + * @example Get code review prompt + * {@includeCode ./examples/GetPromptRequestParams/get-code-review-prompt.json} + * + * @category `prompts/get` + */ +interface GetPromptRequestParams extends RequestParams { + /** + * The name of the prompt or prompt template. + */ + name: string; + /** + * Arguments to use for templating the prompt. + */ + arguments?: { + [key: string]: string; + }; +} +/** + * Used by the client to get a prompt provided by the server. + * + * @example Get prompt request + * {@includeCode ./examples/GetPromptRequest/get-prompt-request.json} + * + * @category `prompts/get` + */ +interface GetPromptRequest extends JSONRPCRequest { + method: 'prompts/get'; + params: GetPromptRequestParams; +} +/** + * The result returned by the server for a {@link GetPromptRequest | prompts/get} request. + * + * @example Code review prompt + * {@includeCode ./examples/GetPromptResult/code-review-prompt.json} + * + * @category `prompts/get` + */ +interface GetPromptResult extends Result { + /** + * An optional description for the prompt. + */ + description?: string; + messages: PromptMessage[]; +} +/** + * A prompt or prompt template that the server offers. + * + * @category `prompts/list` + */ +interface Prompt extends BaseMetadata, Icons { + /** + * An optional description of what this prompt provides + */ + description?: string; + /** + * A list of arguments to use for templating the prompt. + */ + arguments?: PromptArgument[]; + _meta?: MetaObject; +} +/** + * Describes an argument that a prompt can accept. + * + * @category `prompts/list` + */ +interface PromptArgument extends BaseMetadata { + /** + * A human-readable description of the argument. + */ + description?: string; + /** + * Whether this argument must be provided. + */ + required?: boolean; +} +/** + * The sender or recipient of messages and data in a conversation. + * + * @category Common Types + */ +type Role = 'user' | 'assistant'; +/** + * Describes a message returned as part of a prompt. + * + * This is similar to {@link SamplingMessage}, but also supports the embedding of + * resources from the MCP server. + * + * @category `prompts/get` + */ +interface PromptMessage { + role: Role; + content: ContentBlock; +} +/** + * A resource that the server is capable of reading, included in a prompt or tool call result. + * + * Note: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequest | resources/list} requests. + * + * @example File resource link + * {@includeCode ./examples/ResourceLink/file-resource-link.json} + * + * @category Content + */ +interface ResourceLink extends Resource { + type: 'resource_link'; +} +/** + * The contents of a resource, embedded into a prompt or tool call result. + * + * It is up to the client how best to render embedded resources for the benefit + * of the LLM and/or the user. + * + * @example Embedded file resource with annotations + * {@includeCode ./examples/EmbeddedResource/embedded-file-resource-with-annotations.json} + * + * @category Content + */ +interface EmbeddedResource { + type: 'resource'; + resource: TextResourceContents | BlobResourceContents; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +/* Tools */ +/** + * Sent from the client to request a list of tools the server has. + * + * @example List tools request + * {@includeCode ./examples/ListToolsRequest/list-tools-request.json} + * + * @category `tools/list` + */ +interface ListToolsRequest extends PaginatedRequest { + method: 'tools/list'; +} +/** + * The result returned by the server for a {@link ListToolsRequest | tools/list} request. + * + * @example Tools list with cursor + * {@includeCode ./examples/ListToolsResult/tools-list-with-cursor.json} + * + * @category `tools/list` + */ +interface ListToolsResult extends PaginatedResult { + tools: Tool[]; +} +/** + * The result returned by the server for a {@link CallToolRequest | tools/call} request. + * + * @example Result with unstructured text + * {@includeCode ./examples/CallToolResult/result-with-unstructured-text.json} + * + * @example Result with structured content + * {@includeCode ./examples/CallToolResult/result-with-structured-content.json} + * + * @example Invalid tool input error + * {@includeCode ./examples/CallToolResult/invalid-tool-input-error.json} + * + * @category `tools/call` + */ +interface CallToolResult extends Result { + /** + * A list of content objects that represent the unstructured result of the tool call. + */ + content: ContentBlock[]; + /** + * An optional JSON object that represents the structured result of the tool call. + */ + structuredContent?: { + [key: string]: unknown; + }; + /** + * Whether the tool call ended in an error. + * + * If not set, this is assumed to be false (the call was successful). + * + * Any errors that originate from the tool SHOULD be reported inside the result + * object, with `isError` set to true, _not_ as an MCP protocol-level error + * response. Otherwise, the LLM would not be able to see that an error occurred + * and self-correct. + * + * However, any errors in _finding_ the tool, an error indicating that the + * server does not support tool calls, or any other exceptional conditions, + * should be reported as an MCP error response. + */ + isError?: boolean; +} +/** + * Parameters for a `tools/call` request. + * + * @example `get_weather` tool call params + * {@includeCode ./examples/CallToolRequestParams/get-weather-tool-call-params.json} + * + * @example Tool call params with progress token + * {@includeCode ./examples/CallToolRequestParams/tool-call-params-with-progress-token.json} + * + * @category `tools/call` + */ +interface CallToolRequestParams extends TaskAugmentedRequestParams { + /** + * The name of the tool. + */ + name: string; + /** + * Arguments to use for the tool call. + */ + arguments?: { + [key: string]: unknown; + }; +} +/** + * Used by the client to invoke a tool provided by the server. + * + * @example Call tool request + * {@includeCode ./examples/CallToolRequest/call-tool-request.json} + * + * @category `tools/call` + */ +interface CallToolRequest extends JSONRPCRequest { + method: 'tools/call'; + params: CallToolRequestParams; +} +/** + * Additional properties describing a {@link Tool} to clients. + * + * NOTE: all properties in `ToolAnnotations` are **hints**. + * They are not guaranteed to provide a faithful description of + * tool behavior (including descriptive properties like `title`). + * + * Clients should never make tool use decisions based on `ToolAnnotations` + * received from untrusted servers. + * + * @category `tools/list` + */ +interface ToolAnnotations { + /** + * A human-readable title for the tool. + */ + title?: string; + /** + * If true, the tool does not modify its environment. + * + * Default: false + */ + readOnlyHint?: boolean; + /** + * If true, the tool may perform destructive updates to its environment. + * If false, the tool performs only additive updates. + * + * (This property is meaningful only when `readOnlyHint == false`) + * + * Default: true + */ + destructiveHint?: boolean; + /** + * If true, calling the tool repeatedly with the same arguments + * will have no additional effect on its environment. + * + * (This property is meaningful only when `readOnlyHint == false`) + * + * Default: false + */ + idempotentHint?: boolean; + /** + * If true, this tool may interact with an "open world" of external + * entities. If false, the tool's domain of interaction is closed. + * For example, the world of a web search tool is open, whereas that + * of a memory tool is not. + * + * Default: true + */ + openWorldHint?: boolean; +} +/** + * Execution-related properties for a tool. + * + * @category `tools/list` + */ +interface ToolExecution { + /** + * Indicates whether this tool supports task-augmented execution. + * This allows clients to handle long-running operations through polling + * the task system. + * + * - `"forbidden"`: Tool does not support task-augmented execution (default when absent) + * - `"optional"`: Tool may support task-augmented execution + * - `"required"`: Tool requires task-augmented execution + * + * Default: `"forbidden"` + */ + taskSupport?: 'forbidden' | 'optional' | 'required'; +} +/** + * Definition for a tool the client can call. + * + * @example With default 2020-12 input schema + * {@includeCode ./examples/Tool/with-default-2020-12-input-schema.json} + * + * @example With explicit draft-07 input schema + * {@includeCode ./examples/Tool/with-explicit-draft-07-input-schema.json} + * + * @example With no parameters + * {@includeCode ./examples/Tool/with-no-parameters.json} + * + * @example With output schema for structured content + * {@includeCode ./examples/Tool/with-output-schema-for-structured-content.json} + * + * @category `tools/list` + */ +interface Tool extends BaseMetadata, Icons { + /** + * A human-readable description of the tool. + * + * This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model. + */ + description?: string; + /** + * A JSON Schema object defining the expected parameters for the tool. + */ + inputSchema: { + $schema?: string; + type: 'object'; + properties?: { + [key: string]: object; + }; + required?: string[]; + }; + /** + * Execution-related properties for this tool. + */ + execution?: ToolExecution; + /** + * An optional JSON Schema object defining the structure of the tool's output returned in + * the structuredContent field of a {@link CallToolResult}. + * + * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided. + * Currently restricted to `type: "object"` at the root level. + */ + outputSchema?: { + $schema?: string; + type: 'object'; + properties?: { + [key: string]: object; + }; + required?: string[]; + }; + /** + * Optional additional tool information. + * + * Display name precedence order is: `title`, `annotations.title`, then `name`. + */ + annotations?: ToolAnnotations; + _meta?: MetaObject; +} +// The request was cancelled before completion +/** + * Metadata for augmenting a request with task execution. + * Include this in the `task` field of the request parameters. + * + * @category `tasks` + */ +interface TaskMetadata { + /** + * Requested duration in milliseconds to retain task from creation. + */ + ttl?: number; +} +/** + * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed + * + * @category Common Types + */ +interface Annotations { + /** + * Describes who the intended audience of this object or data is. + * + * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). + */ + audience?: Role[]; + /** + * Describes how important this data is for operating the server. + * + * A value of 1 means "most important," and indicates that the data is + * effectively required, while 0 means "least important," and indicates that + * the data is entirely optional. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + priority?: number; + /** + * The moment the resource was last modified, as an ISO 8601 formatted string. + * + * Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z"). + * + * Examples: last activity timestamp in an open file, timestamp when the resource + * was attached, etc. + */ + lastModified?: string; +} +/** + * @category Content + */ +type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource; +/** + * Text provided to or from an LLM. + * + * @example Text content + * {@includeCode ./examples/TextContent/text-content.json} + * + * @category Content + */ +interface TextContent { + type: 'text'; + /** + * The text content of the message. + */ + text: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +/** + * An image provided to or from an LLM. + * + * @example `image/png` content with annotations + * {@includeCode ./examples/ImageContent/image-png-content-with-annotations.json} + * + * @category Content + */ +interface ImageContent { + type: 'image'; + /** + * The base64-encoded image data. + * + * @format byte + */ + data: string; + /** + * The MIME type of the image. Different providers may support different image types. + */ + mimeType: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +/** + * Audio provided to or from an LLM. + * + * @example `audio/wav` content + * {@includeCode ./examples/AudioContent/audio-wav-content.json} + * + * @category Content + */ +interface AudioContent { + type: 'audio'; + /** + * The base64-encoded audio data. + * + * @format byte + */ + data: string; + /** + * The MIME type of the audio. Different providers may support different audio types. + */ + mimeType: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +//#endregion +//#region src/mcp-server.d.ts +interface MCPServerConfig { + name: string; + version: string; + description?: string; + protocolVersion?: string; +} +type NormalizedMCPServerConfig = MCPServerConfig & { + description: string; + protocolVersion: string; +}; +type ZodSchema = z.ZodRawShape; +type ToolHandler = (args: z.infer>) => Promise | CallToolResult; +type ResourceHandler = (uri: string) => Promise | ReadResourceResult; +type PromptHandler = (args: z.infer>) => Promise | GetPromptResult; +type ToolOptions = { + outputSchema: Tool['outputSchema']; + annotations: Tool['annotations']; +}; +type ToolRegistration = { + name: string; + description: string; + inputSchema: Tool['inputSchema']; + handler: (args: Record) => Promise; + options?: ToolOptions; +}; +type ResourceRegistration = { + name: string; + uri: string; + description: string; + handler: (uri: string) => Promise; +}; +type PromptRegistration = { + name: string; + description: string; + arguments: PromptArgument[]; + handler: (args: Record) => Promise; +}; +/** + * Main MCP Server class with Zod-based type safety + */ +declare class MCPServer { + config: NormalizedMCPServerConfig; + tools: Map; + resources: Map; + prompts: Map; + constructor(config: MCPServerConfig); + /** + * Register a tool with Zod schema validation + */ + tool(name: string, inputSchema: T, handler: ToolHandler, options?: { + annotations?: Tool['annotations']; + outputZodSchema?: ZodSchema; + }): this; + /** + * Register a resource + */ + resource(name: string, uri: string, handler: ResourceHandler): this; + /** + * Register a prompt with Zod schema validation + */ + prompt(name: string, inputSchema: T, handler: PromptHandler): this; + /** + * Handle MCP protocol requests + */ + handleRequest(request: InitializeRequest): Promise; + handleRequest(request: InitializedNotification): Promise; + handleRequest(request: ListToolsRequest): Promise; + handleRequest(request: CallToolRequest): Promise; + handleRequest(request: ListResourcesRequest): Promise; + handleRequest(request: ReadResourceRequest): Promise; + handleRequest(request: ListPromptsRequest): Promise; + handleRequest(request: GetPromptRequest): Promise; + /** + * Handle initialize request + */ + handleInitialize(): Promise; + /** + * Handle tools/list request + */ + handleToolsList(): Promise; + /** + * Handle tools/call request + */ + handleToolsCall(params: CallToolRequestParams): Promise; + /** + * Handle resources/list request + */ + handleResourcesList(): Promise; + /** + * Handle resources/read request + */ + handleResourcesRead(params: ReadResourceRequestParams): Promise; + /** + * Handle prompts/list request + */ + handlePromptsList(): Promise; + /** + * Handle prompts/get request + */ + handlePromptsGet(params: GetPromptRequestParams): Promise; + /** + * Get server statistics + */ + getStats(): { + tools: number; + resources: number; + prompts: number; + config: MCPServerConfig; + }; +} +//#endregion +//#region node_modules/@types/aws-lambda/common/api-gateway.d.ts +// Default authorizer type, prefer using a specific type with the "...WithAuthorizer..." variant types. +// Note that this doesn't have to be a context from a custom lambda outhorizer, AWS also has a cognito +// authorizer type and could add more, so the property won't always be a string. +type APIGatewayEventDefaultAuthorizerContext = undefined | null | { + [name: string]: any; +}; +// The requestContext property of both request authorizer and proxy integration events. +interface APIGatewayEventRequestContextWithAuthorizer { + accountId: string; + apiId: string; // This one is a bit confusing: it is not actually present in authorizer calls + // and proxy calls without an authorizer. We model this by allowing undefined in the type, + // since it ends up the same and avoids breaking users that are testing the property. + // This lets us allow parameterizing the authorizer for proxy events that know what authorizer + // context values they have. + authorizer: TAuthorizerContext; + connectedAt?: number | undefined; + connectionId?: string | undefined; + domainName?: string | undefined; + domainPrefix?: string | undefined; + eventType?: string | undefined; + extendedRequestId?: string | undefined; + protocol: string; + httpMethod: string; + identity: APIGatewayEventIdentity; + messageDirection?: string | undefined; + messageId?: string | null | undefined; + path: string; + stage: string; + requestId: string; + requestTime?: string | undefined; + requestTimeEpoch: number; + resourceId: string; + resourcePath: string; + routeKey?: string | undefined; +} +interface APIGatewayEventClientCertificate { + clientCertPem: string; + serialNumber: string; + subjectDN: string; + issuerDN: string; + validity: { + notAfter: string; + notBefore: string; + }; +} +interface APIGatewayEventIdentity { + accessKey: string | null; + accountId: string | null; + apiKey: string | null; + apiKeyId: string | null; + caller: string | null; + clientCert: APIGatewayEventClientCertificate | null; + cognitoAuthenticationProvider: string | null; + cognitoAuthenticationType: string | null; + cognitoIdentityId: string | null; + cognitoIdentityPoolId: string | null; + principalOrgId: string | null; + sourceIp: string; + user: string | null; + userAgent: string | null; + userArn: string | null; + vpcId?: string | undefined; + vpceId?: string | undefined; +} +//#endregion +//#region node_modules/@types/aws-lambda/handler.d.ts +/** + * {@link Handler} context parameter. + * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}. + */ +interface Context { + callbackWaitsForEmptyEventLoop: boolean; + functionName: string; + functionVersion: string; + invokedFunctionArn: string; + memoryLimitInMB: string; + awsRequestId: string; + logGroupName: string; + logStreamName: string; + identity?: CognitoIdentity | undefined; + clientContext?: ClientContext | undefined; + tenantId?: string | undefined; + getRemainingTimeInMillis(): number; // Functions for compatibility with earlier Node.js Runtime v0.10.42 + // No longer documented, so they are deprecated, but they still work + // as of the 12.x runtime, so they are not removed from the types. + /** @deprecated Use handler callback or promise result */ + done(error?: Error, result?: any): void; + /** @deprecated Use handler callback with first argument or reject a promise result */ + fail(error: Error | string): void; + /** @deprecated Use handler callback with second argument or resolve a promise result */ + succeed(messageOrObject: any): void; // Unclear what behavior this is supposed to have, I couldn't find any still extant reference, + // and it behaves like the above, ignoring the object parameter. + /** @deprecated Use handler callback or promise result */ + succeed(message: string, object: any): void; +} +interface CognitoIdentity { + cognitoIdentityId: string; + cognitoIdentityPoolId: string; +} +interface ClientContext { + client: ClientContextClient; + Custom?: any; + env: ClientContextEnv; +} +interface ClientContextClient { + installationId: string; + appTitle: string; + appVersionName: string; + appVersionCode: string; + appPackageName: string; +} +interface ClientContextEnv { + platformVersion: string; + platform: string; + make: string; + model: string; + locale: string; +} +/** + * Interface for using response streaming from AWS Lambda. + * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator. + * + * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`. + * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream. + * + * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post} + * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation} + * + * @example Writing to the response stream + * import 'aws-lambda'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * responseStream.setContentType("text/plain"); + * responseStream.write("Hello, world!"); + * responseStream.end(); + * } + * ); + * + * @example Using pipeline + * import 'aws-lambda'; + * import { Readable } from 'stream'; + * import { pipeline } from 'stream/promises'; + * import zlib from 'zlib'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * // As an example, convert event to a readable stream. + * const requestStream = Readable.from(Buffer.from(JSON.stringify(event))); + * + * await pipeline(requestStream, zlib.createGzip(), responseStream); + * } + * ); + */ +type StreamifyHandler = (event: TEvent, responseStream: awslambda.HttpResponseStream, context: Context) => TResult | Promise; +declare global { + namespace awslambda { + class HttpResponseStream extends Writable { + static from(writable: Writable, metadata: Record): HttpResponseStream; + setContentType: (contentType: string) => void; + } + /** + * Decorator for using response streaming from AWS Lambda. + * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator. + * + * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`. + * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream. + * + * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post} + * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation} + * + * @example Writing to the response stream + * import 'aws-lambda'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * responseStream.setContentType("text/plain"); + * responseStream.write("Hello, world!"); + * responseStream.end(); + * } + * ); + * + * @example Using pipeline + * import 'aws-lambda'; + * import { Readable } from 'stream'; + * import { pipeline } from 'stream/promises'; + * import zlib from 'zlib'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * // As an example, convert event to a readable stream. + * const requestStream = Readable.from(Buffer.from(JSON.stringify(event))); + * + * await pipeline(requestStream, zlib.createGzip(), responseStream); + * } + * ); + */ + function streamifyResponse(handler: StreamifyHandler): StreamifyHandler; + } +} +//#endregion +//#region node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts +/** + * Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0 + * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html + */ +type APIGatewayProxyEvent = APIGatewayProxyEventBase; +interface APIGatewayProxyEventHeaders { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventMultiValueHeaders { + [name: string]: string[] | undefined; +} +interface APIGatewayProxyEventPathParameters { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventQueryStringParameters { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventMultiValueQueryStringParameters { + [name: string]: string[] | undefined; +} +interface APIGatewayProxyEventStageVariables { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventBase { + body: string | null; + headers: APIGatewayProxyEventHeaders; + multiValueHeaders: APIGatewayProxyEventMultiValueHeaders; + httpMethod: string; + isBase64Encoded: boolean; + path: string; + pathParameters: APIGatewayProxyEventPathParameters | null; + queryStringParameters: APIGatewayProxyEventQueryStringParameters | null; + multiValueQueryStringParameters: APIGatewayProxyEventMultiValueQueryStringParameters | null; + stageVariables: APIGatewayProxyEventStageVariables | null; + requestContext: APIGatewayEventRequestContextWithAuthorizer; + resource: string; +} +/** + * Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0 + * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html + */ +interface APIGatewayProxyResult { + statusCode: number; + headers?: { + [header: string]: boolean | number | string; + } | undefined; + multiValueHeaders?: { + [header: string]: Array; + } | undefined; + body: string; + isBase64Encoded?: boolean | undefined; +} +/** + * Works with HTTP API integration Payload Format version 2.0 + * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html + */ +interface APIGatewayEventRequestContextV2 { + accountId: string; + apiId: string; + authentication?: { + clientCert: APIGatewayEventClientCertificate; + }; + domainName: string; + domainPrefix: string; + http: { + method: string; + path: string; + protocol: string; + sourceIp: string; + userAgent: string; + }; + requestId: string; + routeKey: string; + stage: string; + time: string; + timeEpoch: number; +} +/** + * Proxy Event with adaptable requestContext for different authorizer scenarios + */ +interface APIGatewayProxyEventV2WithRequestContext { + version: string; + routeKey: string; + rawPath: string; + rawQueryString: string; + cookies?: string[]; + headers: APIGatewayProxyEventHeaders; + queryStringParameters?: APIGatewayProxyEventQueryStringParameters; + requestContext: TRequestContext; + body?: string; + pathParameters?: APIGatewayProxyEventPathParameters; + isBase64Encoded: boolean; + stageVariables?: APIGatewayProxyEventStageVariables; +} +/** + * Default Proxy event with no Authorizer + */ +type APIGatewayProxyEventV2 = APIGatewayProxyEventV2WithRequestContext; +//#endregion +//#region src/auth/index.d.ts +type LambdaEvent$1 = APIGatewayProxyEvent | APIGatewayProxyEventV2; +interface AuthUser { + token?: string; + [key: string]: unknown; +} +interface AuthValidationResult { + isValid: boolean; + user?: AuthUser; + token?: string; + error?: APIGatewayProxyResult; +} +interface BearerTokenAuthConfig { + type: 'bearer-token'; + tokens?: string[]; + validate?: (token: string, event: LambdaEvent$1) => AuthValidationResult | Promise; +} +type AuthConfig = BearerTokenAuthConfig; +//#endregion +//#region src/lambda-adapter.d.ts +type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2; +type LambdaHandler = (event: LambdaEvent, context: Context) => Promise; +interface LambdaHandlerOptions { + auth?: AuthConfig; +} +/** + * AWS Lambda Adapter for MCP Server + */ +declare function createLambdaHandler(mcpServer: MCPServer, options?: LambdaHandlerOptions): LambdaHandler; +//#endregion +//#region src/common-schemas.d.ts +/** + * Common schema patterns for MCP tools + */ +declare const CommonSchemas: { + string: z.ZodString; + number: z.ZodNumber; + boolean: z.ZodBoolean; + optionalString: z.ZodOptional; + optionalNumber: z.ZodOptional; + optionalBoolean: z.ZodOptional; + email: z.ZodString; + url: z.ZodString; + uuid: z.ZodString; + enum: (values: T) => z.ZodEnum>; + array: (itemSchema: T) => z.ZodArray; + object: (shape: T) => z.ZodObject, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks, any>[k] } : never, z.baseObjectInputType extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType[k_1] } : never>; +}; +//#endregion +//#region src/index.d.ts +declare function createMCPServer(config: ConstructorParameters[0]): MCPServer; +//#endregion +export { CommonSchemas, MCPServer, createLambdaHandler, createMCPServer }; \ No newline at end of file diff --git a/dist/index.d.mts b/dist/index.d.mts new file mode 100644 index 0000000..2ab797d --- /dev/null +++ b/dist/index.d.mts @@ -0,0 +1,1653 @@ +import { z } from "zod"; +import { Writable } from "node:stream"; + +//#region src/mcp-spec.d.ts +/** @internal */ +declare const JSONRPC_VERSION = '2.0'; +/** + * Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions. + * + * Certain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions. + * + * Valid keys have two segments: + * + * **Prefix:** + * - Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`). + * - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`). + * - Any prefix consisting of zero or more labels, followed by `modelcontextprotocol` or `mcp`, followed by any label, is **reserved** for MCP use. For example: `modelcontextprotocol.io/`, `mcp.dev/`, `api.modelcontextprotocol.org/`, and `tools.mcp.com/` are all reserved. + * + * **Name:** + * - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`). + * - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`). + * + * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details. + * @category Common Types + */ +type MetaObject = Record; +/** + * Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply. + * + * @see {@link MetaObject} for key naming rules and reserved prefixes. + * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details. + * @category Common Types + */ +interface RequestMetaObject extends MetaObject { + /** + * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by {@link ProgressNotification | notifications/progress}). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. + */ + progressToken?: ProgressToken; +} +/** + * A progress token, used to associate progress notifications with the original request. + * + * @category Common Types + */ +type ProgressToken = string | number; +/** + * An opaque token used to represent a cursor for pagination. + * + * @category Common Types + */ +type Cursor = string; +/** + * Common params for any task-augmented request. + * + * @internal + */ +interface TaskAugmentedRequestParams extends RequestParams { + /** + * If specified, the caller is requesting task-augmented execution for this request. + * The request will return a {@link CreateTaskResult} immediately, and the actual result can be + * retrieved later via {@link GetTaskPayloadRequest | tasks/result}. + * + * Task augmentation is subject to capability negotiation - receivers MUST declare support + * for task augmentation of specific request types in their capabilities. + */ + task?: TaskMetadata; +} +/** + * Common params for any request. + * + * @category Common Types + */ +interface RequestParams { + _meta?: RequestMetaObject; +} +/** @internal */ +interface Request { + method: string; // Allow unofficial extensions of `Request.params` without impacting `RequestParams`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: { + [key: string]: any; + }; +} +/** + * Common params for any notification. + * + * @category Common Types + */ +interface NotificationParams { + _meta?: MetaObject; +} +/** @internal */ +interface Notification { + method: string; // Allow unofficial extensions of `Notification.params` without impacting `NotificationParams`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: { + [key: string]: any; + }; +} +/** + * Common result fields. + * + * @category Common Types + */ +interface Result { + _meta?: MetaObject; + [key: string]: unknown; +} +/** + * A uniquely identifying ID for a request in JSON-RPC. + * + * @category Common Types + */ +type RequestId = string | number; +/** + * A request that expects a response. + * + * @category JSON-RPC + */ +interface JSONRPCRequest extends Request { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; +} +/** + * A notification which does not expect a response. + * + * @category JSON-RPC + */ +interface JSONRPCNotification extends Notification { + jsonrpc: typeof JSONRPC_VERSION; +} +/* Initialization */ +/** + * Parameters for an `initialize` request. + * + * @example Full client capabilities + * {@includeCode ./examples/InitializeRequestParams/full-client-capabilities.json} + * + * @category `initialize` + */ +interface InitializeRequestParams extends RequestParams { + /** + * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. + */ + protocolVersion: string; + capabilities: ClientCapabilities; + clientInfo: Implementation; +} +/** + * This request is sent from the client to the server when it first connects, asking it to begin initialization. + * + * @example Initialize request + * {@includeCode ./examples/InitializeRequest/initialize-request.json} + * + * @category `initialize` + */ +interface InitializeRequest extends JSONRPCRequest { + method: 'initialize'; + params: InitializeRequestParams; +} +/** + * The result returned by the server for an {@link InitializeRequest | initialize} request. + * + * @example Full server capabilities + * {@includeCode ./examples/InitializeResult/full-server-capabilities.json} + * + * @category `initialize` + */ +interface InitializeResult extends Result { + /** + * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. + */ + protocolVersion: string; + capabilities: ServerCapabilities; + serverInfo: Implementation; + /** + * Instructions describing how to use the server and its features. + * + * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. + */ + instructions?: string; +} +/** + * This notification is sent from the client to the server after initialization has finished. + * + * @example Initialized notification + * {@includeCode ./examples/InitializedNotification/initialized-notification.json} + * + * @category `notifications/initialized` + */ +interface InitializedNotification extends JSONRPCNotification { + method: 'notifications/initialized'; + params?: NotificationParams; +} +/** + * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities. + * + * @category `initialize` + */ +interface ClientCapabilities { + /** + * Experimental, non-standard capabilities that the client supports. + */ + experimental?: { + [key: string]: object; + }; + /** + * Present if the client supports listing roots. + * + * @example Roots — minimum baseline support + * {@includeCode ./examples/ClientCapabilities/roots-minimum-baseline-support.json} + * + * @example Roots — list changed notifications + * {@includeCode ./examples/ClientCapabilities/roots-list-changed-notifications.json} + */ + roots?: { + /** + * Whether the client supports notifications for changes to the roots list. + */ + listChanged?: boolean; + }; + /** + * Present if the client supports sampling from an LLM. + * + * @example Sampling — minimum baseline support + * {@includeCode ./examples/ClientCapabilities/sampling-minimum-baseline-support.json} + * + * @example Sampling — tool use support + * {@includeCode ./examples/ClientCapabilities/sampling-tool-use-support.json} + * + * @example Sampling — context inclusion support (soft-deprecated) + * {@includeCode ./examples/ClientCapabilities/sampling-context-inclusion-support-soft-deprecated.json} + */ + sampling?: { + /** + * Whether the client supports context inclusion via `includeContext` parameter. + * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it). + */ + context?: object; + /** + * Whether the client supports tool use via `tools` and `toolChoice` parameters. + */ + tools?: object; + }; + /** + * Present if the client supports elicitation from the server. + * + * @example Elicitation — form and URL mode support + * {@includeCode ./examples/ClientCapabilities/elicitation-form-and-url-mode-support.json} + * + * @example Elicitation — form mode only (implicit) + * {@includeCode ./examples/ClientCapabilities/elicitation-form-only-implicit.json} + */ + elicitation?: { + form?: object; + url?: object; + }; + /** + * Present if the client supports task-augmented requests. + */ + tasks?: { + /** + * Whether this client supports {@link ListTasksRequest | tasks/list}. + */ + list?: object; + /** + * Whether this client supports {@link CancelTaskRequest | tasks/cancel}. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for sampling-related requests. + */ + sampling?: { + /** + * Whether the client supports task-augmented `sampling/createMessage` requests. + */ + createMessage?: object; + }; + /** + * Task support for elicitation-related requests. + */ + elicitation?: { + /** + * Whether the client supports task-augmented {@link ElicitRequest | elicitation/create} requests. + */ + create?: object; + }; + }; + }; +} +/** + * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. + * + * @category `initialize` + */ +interface ServerCapabilities { + /** + * Experimental, non-standard capabilities that the server supports. + */ + experimental?: { + [key: string]: object; + }; + /** + * Present if the server supports sending log messages to the client. + * + * @example Logging — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/logging-minimum-baseline-support.json} + */ + logging?: object; + /** + * Present if the server supports argument autocompletion suggestions. + * + * @example Completions — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/completions-minimum-baseline-support.json} + */ + completions?: object; + /** + * Present if the server offers any prompt templates. + * + * @example Prompts — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/prompts-minimum-baseline-support.json} + * + * @example Prompts — list changed notifications + * {@includeCode ./examples/ServerCapabilities/prompts-list-changed-notifications.json} + */ + prompts?: { + /** + * Whether this server supports notifications for changes to the prompt list. + */ + listChanged?: boolean; + }; + /** + * Present if the server offers any resources to read. + * + * @example Resources — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/resources-minimum-baseline-support.json} + * + * @example Resources — subscription to individual resource updates (only) + * {@includeCode ./examples/ServerCapabilities/resources-subscription-to-individual-resource-updates-only.json} + * + * @example Resources — list changed notifications (only) + * {@includeCode ./examples/ServerCapabilities/resources-list-changed-notifications-only.json} + * + * @example Resources — all notifications + * {@includeCode ./examples/ServerCapabilities/resources-all-notifications.json} + */ + resources?: { + /** + * Whether this server supports subscribing to resource updates. + */ + subscribe?: boolean; + /** + * Whether this server supports notifications for changes to the resource list. + */ + listChanged?: boolean; + }; + /** + * Present if the server offers any tools to call. + * + * @example Tools — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/tools-minimum-baseline-support.json} + * + * @example Tools — list changed notifications + * {@includeCode ./examples/ServerCapabilities/tools-list-changed-notifications.json} + */ + tools?: { + /** + * Whether this server supports notifications for changes to the tool list. + */ + listChanged?: boolean; + }; + /** + * Present if the server supports task-augmented requests. + */ + tasks?: { + /** + * Whether this server supports {@link ListTasksRequest | tasks/list}. + */ + list?: object; + /** + * Whether this server supports {@link CancelTaskRequest | tasks/cancel}. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for tool-related requests. + */ + tools?: { + /** + * Whether the server supports task-augmented {@link CallToolRequest | tools/call} requests. + */ + call?: object; + }; + }; + }; +} +/** + * An optionally-sized icon that can be displayed in a user interface. + * + * @category Common Types + */ +interface Icon { + /** + * A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a + * `data:` URI with Base64-encoded image data. + * + * Consumers SHOULD take steps to ensure URLs serving icons are from the + * same domain as the client/server or a trusted domain. + * + * Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain + * executable JavaScript. + * + * @format uri + */ + src: string; + /** + * Optional MIME type override if the source MIME type is missing or generic. + * For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`. + */ + mimeType?: string; + /** + * Optional array of strings that specify sizes at which the icon can be used. + * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG. + * + * If not provided, the client should assume that the icon can be used at any size. + */ + sizes?: string[]; + /** + * Optional specifier for the theme this icon is designed for. `"light"` indicates + * the icon is designed to be used with a light background, and `"dark"` indicates + * the icon is designed to be used with a dark background. + * + * If not provided, the client should assume the icon can be used with any theme. + */ + theme?: 'light' | 'dark'; +} +/** + * Base interface to add `icons` property. + * + * @internal + */ +interface Icons { + /** + * Optional set of sized icons that the client can display in a user interface. + * + * Clients that support rendering icons MUST support at least the following MIME types: + * - `image/png` - PNG images (safe, universal compatibility) + * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility) + * + * Clients that support rendering icons SHOULD also support: + * - `image/svg+xml` - SVG images (scalable but requires security precautions) + * - `image/webp` - WebP images (modern, efficient format) + */ + icons?: Icon[]; +} +/** + * Base interface for metadata with name (identifier) and title (display name) properties. + * + * @internal + */ +interface BaseMetadata { + /** + * Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + */ + name: string; + /** + * Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + * even by those unfamiliar with domain-specific terminology. + * + * If not provided, the name should be used for display (except for {@link Tool}, + * where `annotations.title` should be given precedence over using `name`, + * if present). + */ + title?: string; +} +/** + * Describes the MCP implementation. + * + * @category `initialize` + */ +interface Implementation extends BaseMetadata, Icons { + version: string; + /** + * An optional human-readable description of what this implementation does. + * + * This can be used by clients or servers to provide context about their purpose + * and capabilities. For example, a server might describe the types of resources + * or tools it provides, while a client might describe its intended use case. + */ + description?: string; + /** + * An optional URL of the website for this implementation. + * + * @format uri + */ + websiteUrl?: string; +} +/* Pagination */ +/** + * Common params for paginated requests. + * + * @example List request with cursor + * {@includeCode ./examples/PaginatedRequestParams/list-with-cursor.json} + * + * @category Common Types + */ +interface PaginatedRequestParams extends RequestParams { + /** + * An opaque token representing the current pagination position. + * If provided, the server should return results starting after this cursor. + */ + cursor?: Cursor; +} +/** @internal */ +interface PaginatedRequest extends JSONRPCRequest { + params?: PaginatedRequestParams; +} +/** @internal */ +interface PaginatedResult extends Result { + /** + * An opaque token representing the pagination position after the last returned result. + * If present, there may be more results available. + */ + nextCursor?: Cursor; +} +/* Resources */ +/** + * Sent from the client to request a list of resources the server has. + * + * @example List resources request + * {@includeCode ./examples/ListResourcesRequest/list-resources-request.json} + * + * @category `resources/list` + */ +interface ListResourcesRequest extends PaginatedRequest { + method: 'resources/list'; +} +/** + * The result returned by the server for a {@link ListResourcesRequest | resources/list} request. + * + * @example Resources list with cursor + * {@includeCode ./examples/ListResourcesResult/resources-list-with-cursor.json} + * + * @category `resources/list` + */ +interface ListResourcesResult extends PaginatedResult { + resources: Resource[]; +} +/** + * Common params for resource-related requests. + * + * @internal + */ +interface ResourceRequestParams extends RequestParams { + /** + * The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri + */ + uri: string; +} +/** + * Parameters for a `resources/read` request. + * + * @category `resources/read` + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +interface ReadResourceRequestParams extends ResourceRequestParams {} +/** + * Sent from the client to the server, to read a specific resource URI. + * + * @example Read resource request + * {@includeCode ./examples/ReadResourceRequest/read-resource-request.json} + * + * @category `resources/read` + */ +interface ReadResourceRequest extends JSONRPCRequest { + method: 'resources/read'; + params: ReadResourceRequestParams; +} +/** + * The result returned by the server for a {@link ReadResourceRequest | resources/read} request. + * + * @example File resource contents + * {@includeCode ./examples/ReadResourceResult/file-resource-contents.json} + * + * @category `resources/read` + */ +interface ReadResourceResult extends Result { + contents: (TextResourceContents | BlobResourceContents)[]; +} +/** + * A known resource that the server is capable of reading. + * + * @example File resource with annotations + * {@includeCode ./examples/Resource/file-resource-with-annotations.json} + * + * @category `resources/list` + */ +interface Resource extends BaseMetadata, Icons { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + /** + * A description of what this resource represents. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + */ + description?: string; + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + /** + * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. + * + * This can be used by Hosts to display file sizes and estimate context window usage. + */ + size?: number; + _meta?: MetaObject; +} +/** + * The contents of a specific resource or sub-resource. + * + * @internal + */ +interface ResourceContents { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + _meta?: MetaObject; +} +/** + * @example Text file contents + * {@includeCode ./examples/TextResourceContents/text-file-contents.json} + * + * @category Content + */ +interface TextResourceContents extends ResourceContents { + /** + * The text of the item. This must only be set if the item can actually be represented as text (not binary data). + */ + text: string; +} +/** + * @example Image file contents + * {@includeCode ./examples/BlobResourceContents/image-file-contents.json} + * + * @category Content + */ +interface BlobResourceContents extends ResourceContents { + /** + * A base64-encoded string representing the binary data of the item. + * + * @format byte + */ + blob: string; +} +/* Prompts */ +/** + * Sent from the client to request a list of prompts and prompt templates the server has. + * + * @example List prompts request + * {@includeCode ./examples/ListPromptsRequest/list-prompts-request.json} + * + * @category `prompts/list` + */ +interface ListPromptsRequest extends PaginatedRequest { + method: 'prompts/list'; +} +/** + * The result returned by the server for a {@link ListPromptsRequest | prompts/list} request. + * + * @example Prompts list with cursor + * {@includeCode ./examples/ListPromptsResult/prompts-list-with-cursor.json} + * + * @category `prompts/list` + */ +interface ListPromptsResult extends PaginatedResult { + prompts: Prompt[]; +} +/** + * Parameters for a `prompts/get` request. + * + * @example Get code review prompt + * {@includeCode ./examples/GetPromptRequestParams/get-code-review-prompt.json} + * + * @category `prompts/get` + */ +interface GetPromptRequestParams extends RequestParams { + /** + * The name of the prompt or prompt template. + */ + name: string; + /** + * Arguments to use for templating the prompt. + */ + arguments?: { + [key: string]: string; + }; +} +/** + * Used by the client to get a prompt provided by the server. + * + * @example Get prompt request + * {@includeCode ./examples/GetPromptRequest/get-prompt-request.json} + * + * @category `prompts/get` + */ +interface GetPromptRequest extends JSONRPCRequest { + method: 'prompts/get'; + params: GetPromptRequestParams; +} +/** + * The result returned by the server for a {@link GetPromptRequest | prompts/get} request. + * + * @example Code review prompt + * {@includeCode ./examples/GetPromptResult/code-review-prompt.json} + * + * @category `prompts/get` + */ +interface GetPromptResult extends Result { + /** + * An optional description for the prompt. + */ + description?: string; + messages: PromptMessage[]; +} +/** + * A prompt or prompt template that the server offers. + * + * @category `prompts/list` + */ +interface Prompt extends BaseMetadata, Icons { + /** + * An optional description of what this prompt provides + */ + description?: string; + /** + * A list of arguments to use for templating the prompt. + */ + arguments?: PromptArgument[]; + _meta?: MetaObject; +} +/** + * Describes an argument that a prompt can accept. + * + * @category `prompts/list` + */ +interface PromptArgument extends BaseMetadata { + /** + * A human-readable description of the argument. + */ + description?: string; + /** + * Whether this argument must be provided. + */ + required?: boolean; +} +/** + * The sender or recipient of messages and data in a conversation. + * + * @category Common Types + */ +type Role = 'user' | 'assistant'; +/** + * Describes a message returned as part of a prompt. + * + * This is similar to {@link SamplingMessage}, but also supports the embedding of + * resources from the MCP server. + * + * @category `prompts/get` + */ +interface PromptMessage { + role: Role; + content: ContentBlock; +} +/** + * A resource that the server is capable of reading, included in a prompt or tool call result. + * + * Note: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequest | resources/list} requests. + * + * @example File resource link + * {@includeCode ./examples/ResourceLink/file-resource-link.json} + * + * @category Content + */ +interface ResourceLink extends Resource { + type: 'resource_link'; +} +/** + * The contents of a resource, embedded into a prompt or tool call result. + * + * It is up to the client how best to render embedded resources for the benefit + * of the LLM and/or the user. + * + * @example Embedded file resource with annotations + * {@includeCode ./examples/EmbeddedResource/embedded-file-resource-with-annotations.json} + * + * @category Content + */ +interface EmbeddedResource { + type: 'resource'; + resource: TextResourceContents | BlobResourceContents; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +/* Tools */ +/** + * Sent from the client to request a list of tools the server has. + * + * @example List tools request + * {@includeCode ./examples/ListToolsRequest/list-tools-request.json} + * + * @category `tools/list` + */ +interface ListToolsRequest extends PaginatedRequest { + method: 'tools/list'; +} +/** + * The result returned by the server for a {@link ListToolsRequest | tools/list} request. + * + * @example Tools list with cursor + * {@includeCode ./examples/ListToolsResult/tools-list-with-cursor.json} + * + * @category `tools/list` + */ +interface ListToolsResult extends PaginatedResult { + tools: Tool[]; +} +/** + * The result returned by the server for a {@link CallToolRequest | tools/call} request. + * + * @example Result with unstructured text + * {@includeCode ./examples/CallToolResult/result-with-unstructured-text.json} + * + * @example Result with structured content + * {@includeCode ./examples/CallToolResult/result-with-structured-content.json} + * + * @example Invalid tool input error + * {@includeCode ./examples/CallToolResult/invalid-tool-input-error.json} + * + * @category `tools/call` + */ +interface CallToolResult extends Result { + /** + * A list of content objects that represent the unstructured result of the tool call. + */ + content: ContentBlock[]; + /** + * An optional JSON object that represents the structured result of the tool call. + */ + structuredContent?: { + [key: string]: unknown; + }; + /** + * Whether the tool call ended in an error. + * + * If not set, this is assumed to be false (the call was successful). + * + * Any errors that originate from the tool SHOULD be reported inside the result + * object, with `isError` set to true, _not_ as an MCP protocol-level error + * response. Otherwise, the LLM would not be able to see that an error occurred + * and self-correct. + * + * However, any errors in _finding_ the tool, an error indicating that the + * server does not support tool calls, or any other exceptional conditions, + * should be reported as an MCP error response. + */ + isError?: boolean; +} +/** + * Parameters for a `tools/call` request. + * + * @example `get_weather` tool call params + * {@includeCode ./examples/CallToolRequestParams/get-weather-tool-call-params.json} + * + * @example Tool call params with progress token + * {@includeCode ./examples/CallToolRequestParams/tool-call-params-with-progress-token.json} + * + * @category `tools/call` + */ +interface CallToolRequestParams extends TaskAugmentedRequestParams { + /** + * The name of the tool. + */ + name: string; + /** + * Arguments to use for the tool call. + */ + arguments?: { + [key: string]: unknown; + }; +} +/** + * Used by the client to invoke a tool provided by the server. + * + * @example Call tool request + * {@includeCode ./examples/CallToolRequest/call-tool-request.json} + * + * @category `tools/call` + */ +interface CallToolRequest extends JSONRPCRequest { + method: 'tools/call'; + params: CallToolRequestParams; +} +/** + * Additional properties describing a {@link Tool} to clients. + * + * NOTE: all properties in `ToolAnnotations` are **hints**. + * They are not guaranteed to provide a faithful description of + * tool behavior (including descriptive properties like `title`). + * + * Clients should never make tool use decisions based on `ToolAnnotations` + * received from untrusted servers. + * + * @category `tools/list` + */ +interface ToolAnnotations { + /** + * A human-readable title for the tool. + */ + title?: string; + /** + * If true, the tool does not modify its environment. + * + * Default: false + */ + readOnlyHint?: boolean; + /** + * If true, the tool may perform destructive updates to its environment. + * If false, the tool performs only additive updates. + * + * (This property is meaningful only when `readOnlyHint == false`) + * + * Default: true + */ + destructiveHint?: boolean; + /** + * If true, calling the tool repeatedly with the same arguments + * will have no additional effect on its environment. + * + * (This property is meaningful only when `readOnlyHint == false`) + * + * Default: false + */ + idempotentHint?: boolean; + /** + * If true, this tool may interact with an "open world" of external + * entities. If false, the tool's domain of interaction is closed. + * For example, the world of a web search tool is open, whereas that + * of a memory tool is not. + * + * Default: true + */ + openWorldHint?: boolean; +} +/** + * Execution-related properties for a tool. + * + * @category `tools/list` + */ +interface ToolExecution { + /** + * Indicates whether this tool supports task-augmented execution. + * This allows clients to handle long-running operations through polling + * the task system. + * + * - `"forbidden"`: Tool does not support task-augmented execution (default when absent) + * - `"optional"`: Tool may support task-augmented execution + * - `"required"`: Tool requires task-augmented execution + * + * Default: `"forbidden"` + */ + taskSupport?: 'forbidden' | 'optional' | 'required'; +} +/** + * Definition for a tool the client can call. + * + * @example With default 2020-12 input schema + * {@includeCode ./examples/Tool/with-default-2020-12-input-schema.json} + * + * @example With explicit draft-07 input schema + * {@includeCode ./examples/Tool/with-explicit-draft-07-input-schema.json} + * + * @example With no parameters + * {@includeCode ./examples/Tool/with-no-parameters.json} + * + * @example With output schema for structured content + * {@includeCode ./examples/Tool/with-output-schema-for-structured-content.json} + * + * @category `tools/list` + */ +interface Tool extends BaseMetadata, Icons { + /** + * A human-readable description of the tool. + * + * This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model. + */ + description?: string; + /** + * A JSON Schema object defining the expected parameters for the tool. + */ + inputSchema: { + $schema?: string; + type: 'object'; + properties?: { + [key: string]: object; + }; + required?: string[]; + }; + /** + * Execution-related properties for this tool. + */ + execution?: ToolExecution; + /** + * An optional JSON Schema object defining the structure of the tool's output returned in + * the structuredContent field of a {@link CallToolResult}. + * + * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided. + * Currently restricted to `type: "object"` at the root level. + */ + outputSchema?: { + $schema?: string; + type: 'object'; + properties?: { + [key: string]: object; + }; + required?: string[]; + }; + /** + * Optional additional tool information. + * + * Display name precedence order is: `title`, `annotations.title`, then `name`. + */ + annotations?: ToolAnnotations; + _meta?: MetaObject; +} +// The request was cancelled before completion +/** + * Metadata for augmenting a request with task execution. + * Include this in the `task` field of the request parameters. + * + * @category `tasks` + */ +interface TaskMetadata { + /** + * Requested duration in milliseconds to retain task from creation. + */ + ttl?: number; +} +/** + * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed + * + * @category Common Types + */ +interface Annotations { + /** + * Describes who the intended audience of this object or data is. + * + * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). + */ + audience?: Role[]; + /** + * Describes how important this data is for operating the server. + * + * A value of 1 means "most important," and indicates that the data is + * effectively required, while 0 means "least important," and indicates that + * the data is entirely optional. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + priority?: number; + /** + * The moment the resource was last modified, as an ISO 8601 formatted string. + * + * Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z"). + * + * Examples: last activity timestamp in an open file, timestamp when the resource + * was attached, etc. + */ + lastModified?: string; +} +/** + * @category Content + */ +type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource; +/** + * Text provided to or from an LLM. + * + * @example Text content + * {@includeCode ./examples/TextContent/text-content.json} + * + * @category Content + */ +interface TextContent { + type: 'text'; + /** + * The text content of the message. + */ + text: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +/** + * An image provided to or from an LLM. + * + * @example `image/png` content with annotations + * {@includeCode ./examples/ImageContent/image-png-content-with-annotations.json} + * + * @category Content + */ +interface ImageContent { + type: 'image'; + /** + * The base64-encoded image data. + * + * @format byte + */ + data: string; + /** + * The MIME type of the image. Different providers may support different image types. + */ + mimeType: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +/** + * Audio provided to or from an LLM. + * + * @example `audio/wav` content + * {@includeCode ./examples/AudioContent/audio-wav-content.json} + * + * @category Content + */ +interface AudioContent { + type: 'audio'; + /** + * The base64-encoded audio data. + * + * @format byte + */ + data: string; + /** + * The MIME type of the audio. Different providers may support different audio types. + */ + mimeType: string; + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + _meta?: MetaObject; +} +//#endregion +//#region src/mcp-server.d.ts +interface MCPServerConfig { + name: string; + version: string; + description?: string; + protocolVersion?: string; +} +type NormalizedMCPServerConfig = MCPServerConfig & { + description: string; + protocolVersion: string; +}; +type ZodSchema = z.ZodRawShape; +type ToolHandler = (args: z.infer>) => Promise | CallToolResult; +type ResourceHandler = (uri: string) => Promise | ReadResourceResult; +type PromptHandler = (args: z.infer>) => Promise | GetPromptResult; +type ToolOptions = { + outputSchema: Tool['outputSchema']; + annotations: Tool['annotations']; +}; +type ToolRegistration = { + name: string; + description: string; + inputSchema: Tool['inputSchema']; + handler: (args: Record) => Promise; + options?: ToolOptions; +}; +type ResourceRegistration = { + name: string; + uri: string; + description: string; + handler: (uri: string) => Promise; +}; +type PromptRegistration = { + name: string; + description: string; + arguments: PromptArgument[]; + handler: (args: Record) => Promise; +}; +/** + * Main MCP Server class with Zod-based type safety + */ +declare class MCPServer { + config: NormalizedMCPServerConfig; + tools: Map; + resources: Map; + prompts: Map; + constructor(config: MCPServerConfig); + /** + * Register a tool with Zod schema validation + */ + tool(name: string, inputSchema: T, handler: ToolHandler, options?: { + annotations?: Tool['annotations']; + outputZodSchema?: ZodSchema; + }): this; + /** + * Register a resource + */ + resource(name: string, uri: string, handler: ResourceHandler): this; + /** + * Register a prompt with Zod schema validation + */ + prompt(name: string, inputSchema: T, handler: PromptHandler): this; + /** + * Handle MCP protocol requests + */ + handleRequest(request: InitializeRequest): Promise; + handleRequest(request: InitializedNotification): Promise; + handleRequest(request: ListToolsRequest): Promise; + handleRequest(request: CallToolRequest): Promise; + handleRequest(request: ListResourcesRequest): Promise; + handleRequest(request: ReadResourceRequest): Promise; + handleRequest(request: ListPromptsRequest): Promise; + handleRequest(request: GetPromptRequest): Promise; + /** + * Handle initialize request + */ + handleInitialize(): Promise; + /** + * Handle tools/list request + */ + handleToolsList(): Promise; + /** + * Handle tools/call request + */ + handleToolsCall(params: CallToolRequestParams): Promise; + /** + * Handle resources/list request + */ + handleResourcesList(): Promise; + /** + * Handle resources/read request + */ + handleResourcesRead(params: ReadResourceRequestParams): Promise; + /** + * Handle prompts/list request + */ + handlePromptsList(): Promise; + /** + * Handle prompts/get request + */ + handlePromptsGet(params: GetPromptRequestParams): Promise; + /** + * Get server statistics + */ + getStats(): { + tools: number; + resources: number; + prompts: number; + config: MCPServerConfig; + }; +} +//#endregion +//#region node_modules/@types/aws-lambda/common/api-gateway.d.ts +// Default authorizer type, prefer using a specific type with the "...WithAuthorizer..." variant types. +// Note that this doesn't have to be a context from a custom lambda outhorizer, AWS also has a cognito +// authorizer type and could add more, so the property won't always be a string. +type APIGatewayEventDefaultAuthorizerContext = undefined | null | { + [name: string]: any; +}; +// The requestContext property of both request authorizer and proxy integration events. +interface APIGatewayEventRequestContextWithAuthorizer { + accountId: string; + apiId: string; // This one is a bit confusing: it is not actually present in authorizer calls + // and proxy calls without an authorizer. We model this by allowing undefined in the type, + // since it ends up the same and avoids breaking users that are testing the property. + // This lets us allow parameterizing the authorizer for proxy events that know what authorizer + // context values they have. + authorizer: TAuthorizerContext; + connectedAt?: number | undefined; + connectionId?: string | undefined; + domainName?: string | undefined; + domainPrefix?: string | undefined; + eventType?: string | undefined; + extendedRequestId?: string | undefined; + protocol: string; + httpMethod: string; + identity: APIGatewayEventIdentity; + messageDirection?: string | undefined; + messageId?: string | null | undefined; + path: string; + stage: string; + requestId: string; + requestTime?: string | undefined; + requestTimeEpoch: number; + resourceId: string; + resourcePath: string; + routeKey?: string | undefined; +} +interface APIGatewayEventClientCertificate { + clientCertPem: string; + serialNumber: string; + subjectDN: string; + issuerDN: string; + validity: { + notAfter: string; + notBefore: string; + }; +} +interface APIGatewayEventIdentity { + accessKey: string | null; + accountId: string | null; + apiKey: string | null; + apiKeyId: string | null; + caller: string | null; + clientCert: APIGatewayEventClientCertificate | null; + cognitoAuthenticationProvider: string | null; + cognitoAuthenticationType: string | null; + cognitoIdentityId: string | null; + cognitoIdentityPoolId: string | null; + principalOrgId: string | null; + sourceIp: string; + user: string | null; + userAgent: string | null; + userArn: string | null; + vpcId?: string | undefined; + vpceId?: string | undefined; +} +//#endregion +//#region node_modules/@types/aws-lambda/handler.d.ts +/** + * {@link Handler} context parameter. + * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}. + */ +interface Context { + callbackWaitsForEmptyEventLoop: boolean; + functionName: string; + functionVersion: string; + invokedFunctionArn: string; + memoryLimitInMB: string; + awsRequestId: string; + logGroupName: string; + logStreamName: string; + identity?: CognitoIdentity | undefined; + clientContext?: ClientContext | undefined; + tenantId?: string | undefined; + getRemainingTimeInMillis(): number; // Functions for compatibility with earlier Node.js Runtime v0.10.42 + // No longer documented, so they are deprecated, but they still work + // as of the 12.x runtime, so they are not removed from the types. + /** @deprecated Use handler callback or promise result */ + done(error?: Error, result?: any): void; + /** @deprecated Use handler callback with first argument or reject a promise result */ + fail(error: Error | string): void; + /** @deprecated Use handler callback with second argument or resolve a promise result */ + succeed(messageOrObject: any): void; // Unclear what behavior this is supposed to have, I couldn't find any still extant reference, + // and it behaves like the above, ignoring the object parameter. + /** @deprecated Use handler callback or promise result */ + succeed(message: string, object: any): void; +} +interface CognitoIdentity { + cognitoIdentityId: string; + cognitoIdentityPoolId: string; +} +interface ClientContext { + client: ClientContextClient; + Custom?: any; + env: ClientContextEnv; +} +interface ClientContextClient { + installationId: string; + appTitle: string; + appVersionName: string; + appVersionCode: string; + appPackageName: string; +} +interface ClientContextEnv { + platformVersion: string; + platform: string; + make: string; + model: string; + locale: string; +} +/** + * Interface for using response streaming from AWS Lambda. + * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator. + * + * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`. + * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream. + * + * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post} + * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation} + * + * @example Writing to the response stream + * import 'aws-lambda'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * responseStream.setContentType("text/plain"); + * responseStream.write("Hello, world!"); + * responseStream.end(); + * } + * ); + * + * @example Using pipeline + * import 'aws-lambda'; + * import { Readable } from 'stream'; + * import { pipeline } from 'stream/promises'; + * import zlib from 'zlib'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * // As an example, convert event to a readable stream. + * const requestStream = Readable.from(Buffer.from(JSON.stringify(event))); + * + * await pipeline(requestStream, zlib.createGzip(), responseStream); + * } + * ); + */ +type StreamifyHandler = (event: TEvent, responseStream: awslambda.HttpResponseStream, context: Context) => TResult | Promise; +declare global { + namespace awslambda { + class HttpResponseStream extends Writable { + static from(writable: Writable, metadata: Record): HttpResponseStream; + setContentType: (contentType: string) => void; + } + /** + * Decorator for using response streaming from AWS Lambda. + * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator. + * + * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`. + * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream. + * + * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post} + * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation} + * + * @example Writing to the response stream + * import 'aws-lambda'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * responseStream.setContentType("text/plain"); + * responseStream.write("Hello, world!"); + * responseStream.end(); + * } + * ); + * + * @example Using pipeline + * import 'aws-lambda'; + * import { Readable } from 'stream'; + * import { pipeline } from 'stream/promises'; + * import zlib from 'zlib'; + * + * export const handler = awslambda.streamifyResponse( + * async (event, responseStream, context) => { + * // As an example, convert event to a readable stream. + * const requestStream = Readable.from(Buffer.from(JSON.stringify(event))); + * + * await pipeline(requestStream, zlib.createGzip(), responseStream); + * } + * ); + */ + function streamifyResponse(handler: StreamifyHandler): StreamifyHandler; + } +} +//#endregion +//#region node_modules/@types/aws-lambda/trigger/api-gateway-proxy.d.ts +/** + * Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0 + * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html + */ +type APIGatewayProxyEvent = APIGatewayProxyEventBase; +interface APIGatewayProxyEventHeaders { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventMultiValueHeaders { + [name: string]: string[] | undefined; +} +interface APIGatewayProxyEventPathParameters { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventQueryStringParameters { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventMultiValueQueryStringParameters { + [name: string]: string[] | undefined; +} +interface APIGatewayProxyEventStageVariables { + [name: string]: string | undefined; +} +interface APIGatewayProxyEventBase { + body: string | null; + headers: APIGatewayProxyEventHeaders; + multiValueHeaders: APIGatewayProxyEventMultiValueHeaders; + httpMethod: string; + isBase64Encoded: boolean; + path: string; + pathParameters: APIGatewayProxyEventPathParameters | null; + queryStringParameters: APIGatewayProxyEventQueryStringParameters | null; + multiValueQueryStringParameters: APIGatewayProxyEventMultiValueQueryStringParameters | null; + stageVariables: APIGatewayProxyEventStageVariables | null; + requestContext: APIGatewayEventRequestContextWithAuthorizer; + resource: string; +} +/** + * Works with Lambda Proxy Integration for Rest API or HTTP API integration Payload Format version 1.0 + * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html + */ +interface APIGatewayProxyResult { + statusCode: number; + headers?: { + [header: string]: boolean | number | string; + } | undefined; + multiValueHeaders?: { + [header: string]: Array; + } | undefined; + body: string; + isBase64Encoded?: boolean | undefined; +} +/** + * Works with HTTP API integration Payload Format version 2.0 + * @see - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html + */ +interface APIGatewayEventRequestContextV2 { + accountId: string; + apiId: string; + authentication?: { + clientCert: APIGatewayEventClientCertificate; + }; + domainName: string; + domainPrefix: string; + http: { + method: string; + path: string; + protocol: string; + sourceIp: string; + userAgent: string; + }; + requestId: string; + routeKey: string; + stage: string; + time: string; + timeEpoch: number; +} +/** + * Proxy Event with adaptable requestContext for different authorizer scenarios + */ +interface APIGatewayProxyEventV2WithRequestContext { + version: string; + routeKey: string; + rawPath: string; + rawQueryString: string; + cookies?: string[]; + headers: APIGatewayProxyEventHeaders; + queryStringParameters?: APIGatewayProxyEventQueryStringParameters; + requestContext: TRequestContext; + body?: string; + pathParameters?: APIGatewayProxyEventPathParameters; + isBase64Encoded: boolean; + stageVariables?: APIGatewayProxyEventStageVariables; +} +/** + * Default Proxy event with no Authorizer + */ +type APIGatewayProxyEventV2 = APIGatewayProxyEventV2WithRequestContext; +//#endregion +//#region src/auth/index.d.ts +type LambdaEvent$1 = APIGatewayProxyEvent | APIGatewayProxyEventV2; +interface AuthUser { + token?: string; + [key: string]: unknown; +} +interface AuthValidationResult { + isValid: boolean; + user?: AuthUser; + token?: string; + error?: APIGatewayProxyResult; +} +interface BearerTokenAuthConfig { + type: 'bearer-token'; + tokens?: string[]; + validate?: (token: string, event: LambdaEvent$1) => AuthValidationResult | Promise; +} +type AuthConfig = BearerTokenAuthConfig; +//#endregion +//#region src/lambda-adapter.d.ts +type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2; +type LambdaHandler = (event: LambdaEvent, context: Context) => Promise; +interface LambdaHandlerOptions { + auth?: AuthConfig; +} +/** + * AWS Lambda Adapter for MCP Server + */ +declare function createLambdaHandler(mcpServer: MCPServer, options?: LambdaHandlerOptions): LambdaHandler; +//#endregion +//#region src/common-schemas.d.ts +/** + * Common schema patterns for MCP tools + */ +declare const CommonSchemas: { + string: z.ZodString; + number: z.ZodNumber; + boolean: z.ZodBoolean; + optionalString: z.ZodOptional; + optionalNumber: z.ZodOptional; + optionalBoolean: z.ZodOptional; + email: z.ZodString; + url: z.ZodString; + uuid: z.ZodString; + enum: (values: T) => z.ZodEnum>; + array: (itemSchema: T) => z.ZodArray; + object: (shape: T) => z.ZodObject, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks, any>[k] } : never, z.baseObjectInputType extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType[k_1] } : never>; +}; +//#endregion +//#region src/index.d.ts +declare function createMCPServer(config: ConstructorParameters[0]): MCPServer; +//#endregion +export { CommonSchemas, MCPServer, createLambdaHandler, createMCPServer }; \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8626a91..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,156 +0,0 @@ -/** - * TypeScript definitions for @aws-lambda-mcp/adapter - */ - -import { z } from 'zod'; -import { - APIGatewayProxyEvent, - APIGatewayProxyResult, - Context, -} from 'aws-lambda'; - -// Core Types -export interface MCPServerConfig { - name: string; - version: string; - description?: string; - protocolVersion?: string; -} - -// JSON-RPC Types -export interface JsonRpcRequest { - jsonrpc: string; - method: string; - params?: Record; - id?: string | number | null; -} - -export interface JsonRpcResponse { - jsonrpc: string; - result?: unknown; - error?: { - code: number; - message: string; - data?: unknown; - }; - id?: string | number | null; -} - -export interface MCPToolResult { - content: Array<{ - type: 'text' | 'image' | 'resource'; - text?: string; - data?: string; - mimeType?: string; - }>; - isError?: boolean; -} - -export interface MCPResourceResult { - contents: Array<{ - uri: string; - text?: string; - blob?: string; - mimeType?: string; - }>; -} - -export interface MCPPromptResult { - messages: Array<{ - role: 'user' | 'assistant' | 'system'; - content: { - type: 'text' | 'image'; - text?: string; - data?: string; - mimeType?: string; - }; - }>; -} - -// Authentication Types -export interface AuthUser { - token?: string; - [key: string]: unknown; -} - -export interface AuthValidationResult { - isValid: boolean; - user?: AuthUser; - token?: string; - error?: APIGatewayProxyResult; -} - -export interface BearerTokenAuthConfig { - type: 'bearer-token'; - tokens?: string[]; - validate?: ( - token: string, - event: APIGatewayProxyEvent - ) => AuthValidationResult | Promise; -} - -export type AuthConfig = BearerTokenAuthConfig; - -export interface LambdaHandlerOptions { - auth?: AuthConfig; -} - -// Schema Types -export type ZodSchema = Record; -export type ToolHandler> = (args: T) => Promise; -export type ResourceHandler = (uri: string) => Promise; -export type PromptHandler> = (args: T) => Promise; - -// Core Classes -export declare class MCPServer { - constructor(config: MCPServerConfig); - - tool( - name: string, - inputSchema: T, - handler: ToolHandler>> - ): MCPServer; - - resource(name: string, uri: string, handler: ResourceHandler): MCPServer; - - prompt( - name: string, - inputSchema: T, - handler: PromptHandler>> - ): MCPServer; - - handleRequest(request: JsonRpcRequest): Promise; - getStats(): { - tools: number; - resources: number; - prompts: number; - config: MCPServerConfig; - }; -} - -// Main Functions -export declare function createMCPServer(config: MCPServerConfig): MCPServer; - -export declare function createLambdaHandler( - mcpServer: MCPServer, - options?: LambdaHandlerOptions -): ( - event: APIGatewayProxyEvent, - context: Context -) => Promise; - -// Common Schemas -export declare const CommonSchemas: { - string: z.ZodString; - number: z.ZodNumber; - boolean: z.ZodBoolean; - optionalString: z.ZodOptional; - optionalNumber: z.ZodOptional; - optionalBoolean: z.ZodOptional; - email: z.ZodString; - url: z.ZodString; - uuid: z.ZodString; - enum: (values: T) => z.ZodEnum; - array: (itemSchema: T) => z.ZodArray; - object: (shape: T) => z.ZodObject; -}; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 28771d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,815 +0,0 @@ -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __esm = (fn, res) => function __init() { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; -}; -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - -// src/cors-config.mjs -function withCORS(additionalHeaders = {}) { - return { - ...CORS_HEADERS, - ...additionalHeaders - }; -} -function withBasicCORS(additionalHeaders = {}) { - return { - ...BASIC_CORS_HEADERS, - ...additionalHeaders - }; -} -var CORS_HEADERS, BASIC_CORS_HEADERS; -var init_cors_config = __esm({ - "src/cors-config.mjs"() { - CORS_HEADERS = { - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Headers": "Content-Type, Accept, Authorization, Mcp-Protocol-Version, Mcp-Session-Id", - "Access-Control-Allow-Methods": "GET, POST, OPTIONS" - }; - BASIC_CORS_HEADERS = { - "Access-Control-Allow-Origin": "*" - }; - } -}); - -// src/auth/bearer-token.mjs -function createAuthErrorResponse(statusCode, error, message, additionalHeaders = {}) { - const headers = withCORS({ - "Content-Type": "application/json", - ...additionalHeaders - }); - return { - statusCode, - headers, - body: JSON.stringify({ - error, - message - }) - }; -} -function validateBearerToken(event, config = {}) { - const authHeader = event.headers?.authorization || event.headers?.Authorization; - if (!authHeader) { - return { - isValid: false, - error: createAuthErrorResponse( - 401, - "unauthorized", - "Authorization header is required", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - if (!authHeader.startsWith("Bearer ")) { - return { - isValid: false, - error: createAuthErrorResponse( - 401, - "unauthorized", - "Bearer token is required", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - const token = authHeader.substring(7); - if (config.validate && typeof config.validate === "function") { - try { - const result = config.validate(token, event); - if (result && result.isValid) { - return { - isValid: true, - user: result.user || { token }, - token - }; - } else { - return { - isValid: false, - error: result?.error || createAuthErrorResponse( - 401, - "invalid_token", - "Invalid or expired token", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - } catch (error) { - console.error("Error in custom token validation:", error); - return { - isValid: false, - error: createAuthErrorResponse( - 500, - "server_error", - "Authentication validation error" - ) - }; - } - } - const validTokens = config.tokens || []; - if (validTokens.length === 0) { - console.warn("No valid tokens configured for Bearer token authentication."); - return { - isValid: false, - error: createAuthErrorResponse( - 500, - "server_error", - "Authentication not configured" - ) - }; - } - if (!validTokens.includes(token)) { - return { - isValid: false, - error: createAuthErrorResponse( - 401, - "invalid_token", - "Invalid or expired token", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - return { - isValid: true, - user: { token }, - token - }; -} -var init_bearer_token = __esm({ - "src/auth/bearer-token.mjs"() { - init_cors_config(); - } -}); - -// src/auth/middleware.mjs -var middleware_exports = {}; -__export(middleware_exports, { - createAuthMiddleware: () => createAuthMiddleware, - createAuthenticatedHandler: () => createAuthenticatedHandler -}); -function handleCORSPreflight(event) { - const method = event.requestContext?.http?.method || event.httpMethod; - if (method === "OPTIONS") { - return { - statusCode: 200, - headers: CORS_HEADERS, - body: "" - }; - } - return null; -} -function createAuthMiddleware(authConfig) { - return async (event) => { - const corsResponse = handleCORSPreflight(event); - if (corsResponse) { - return corsResponse; - } - let authResult; - switch (authConfig.type) { - case "bearer-token": - authResult = validateBearerToken(event, authConfig); - break; - default: - console.error(`Unsupported authentication type: ${authConfig.type}`); - return { - statusCode: 500, - headers: withBasicCORS({ "Content-Type": "application/json" }), - body: JSON.stringify({ - error: "server_error", - message: "Unsupported authentication type" - }) - }; - } - if (!authResult.isValid) { - console.log("Authentication failed:", authResult.error.body); - return authResult.error; - } - event.user = authResult.user; - event.authToken = authResult.token; - console.log("Authentication successful"); - return null; - }; -} -function createAuthenticatedHandler(originalHandler, authConfig) { - const authMiddleware = createAuthMiddleware(authConfig); - return async (event) => { - console.log("=== MCP Server Request Start (with Authentication) ==="); - console.log("Event:", JSON.stringify(event, null, 2)); - try { - const authResponse = await authMiddleware(event); - if (authResponse) { - return authResponse; - } - const response = await originalHandler(event); - console.log("=== MCP Server Request End ==="); - return response; - } catch (error) { - console.error("Error in authenticated MCP server:", error); - return { - statusCode: 500, - headers: withBasicCORS({ "Content-Type": "application/json" }), - body: JSON.stringify({ - error: "internal_server_error", - message: "An internal server error occurred" - }) - }; - } - }; -} -var init_middleware = __esm({ - "src/auth/middleware.mjs"() { - init_bearer_token(); - init_cors_config(); - } -}); - -// src/index.mjs -var src_exports = {}; -__export(src_exports, { - CommonSchemas: () => CommonSchemas, - MCPServer: () => MCPServer, - createLambdaHandler: () => createLambdaHandler, - createMCPServer: () => createMCPServer -}); -module.exports = __toCommonJS(src_exports); - -// src/schema-utils.mjs -var import_zod = require("zod"); -function zodToJsonSchema(zodSchema) { - const properties = {}; - const required = []; - for (const [key, schema] of Object.entries(zodSchema)) { - properties[key] = convertZodTypeToJsonSchema(schema); - if (!isZodOptional(schema)) { - required.push(key); - } - } - return { - type: "object", - properties, - required - }; -} -function convertZodTypeToJsonSchema(zodType) { - if (zodType instanceof import_zod.z.ZodOptional) { - return convertZodTypeToJsonSchema(zodType._def.innerType); - } - if (zodType instanceof import_zod.z.ZodDefault) { - const schema = convertZodTypeToJsonSchema(zodType._def.innerType); - schema.default = zodType._def.defaultValue(); - return schema; - } - if (zodType instanceof import_zod.z.ZodString) { - const schema = { type: "string" }; - if (zodType._def.checks) { - for (const check of zodType._def.checks) { - switch (check.kind) { - case "min": - schema.minLength = check.value; - break; - case "max": - schema.maxLength = check.value; - break; - case "email": - schema.format = "email"; - break; - case "url": - schema.format = "uri"; - break; - case "uuid": - schema.format = "uuid"; - break; - } - } - } - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof import_zod.z.ZodNumber) { - const schema = { type: "number" }; - if (zodType._def.checks) { - for (const check of zodType._def.checks) { - switch (check.kind) { - case "min": - schema.minimum = check.value; - break; - case "max": - schema.maximum = check.value; - break; - case "int": - schema.type = "integer"; - break; - } - } - } - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof import_zod.z.ZodBoolean) { - const schema = { type: "boolean" }; - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof import_zod.z.ZodEnum) { - const schema = { - type: "string", - enum: zodType._def.values - }; - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof import_zod.z.ZodArray) { - const schema = { - type: "array", - items: convertZodTypeToJsonSchema(zodType._def.type) - }; - if (zodType._def.minLength) { - schema.minItems = zodType._def.minLength.value; - } - if (zodType._def.maxLength) { - schema.maxItems = zodType._def.maxLength.value; - } - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof import_zod.z.ZodObject) { - return zodToJsonSchema(zodType.shape); - } - return { - type: "string", - description: zodType.description || "Unknown type" - }; -} -function isZodOptional(zodType) { - return zodType instanceof import_zod.z.ZodOptional || zodType instanceof import_zod.z.ZodDefault; -} -function hasZodDefault(zodType) { - return zodType instanceof import_zod.z.ZodDefault; -} -function validateWithZod(zodSchema, args) { - const validated = {}; - for (const [key, schema] of Object.entries(zodSchema)) { - try { - if (args[key] === void 0 && isZodOptional(schema)) { - if (hasZodDefault(schema)) { - validated[key] = schema.parse(void 0); - } - continue; - } - validated[key] = schema.parse(args[key]); - } catch (error) { - throw new import_zod.z.ZodError([ - { - code: "custom", - path: [key], - message: `${error.message}` - } - ]); - } - } - return validated; -} - -// src/mcp-server.mjs -var MCPServer = class { - constructor(config) { - this.config = { - name: config.name || "MCP Server", - version: config.version || "1.0.0", - description: config.description || "MCP Server powered by AWS Lambda", - protocolVersion: config.protocolVersion || "2025-03-26", - ...config - }; - this.tools = /* @__PURE__ */ new Map(); - this.resources = /* @__PURE__ */ new Map(); - this.prompts = /* @__PURE__ */ new Map(); - } - /** - * Register a tool with Zod schema validation - */ - tool(name, inputSchema, handler) { - const jsonSchema = zodToJsonSchema(inputSchema); - const validatedHandler = async (args) => { - try { - const validatedArgs = validateWithZod(inputSchema, args); - return await handler(validatedArgs); - } catch (error) { - if (error.name === "ZodError") { - throw new Error( - `Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}` - ); - } - throw error; - } - }; - this.tools.set(name, { - name, - description: handler.description || `Tool: ${name}`, - inputSchema: jsonSchema, - handler: validatedHandler - }); - return this; - } - /** - * Register a resource - */ - resource(name, uri, handler) { - this.resources.set(name, { - name, - uri, - description: handler.description || `Resource: ${name}`, - handler - }); - return this; - } - /** - * Register a prompt with Zod schema validation - */ - prompt(name, inputSchema, handler) { - zodToJsonSchema(inputSchema); - const validatedHandler = async (args) => { - try { - const validatedArgs = validateWithZod(inputSchema, args); - return await handler(validatedArgs); - } catch (error) { - if (error.name === "ZodError") { - throw new Error( - `Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}` - ); - } - throw error; - } - }; - this.prompts.set(name, { - name, - description: handler.description || `Prompt: ${name}`, - arguments: Object.entries(inputSchema).map(([key, schema]) => ({ - name: key, - description: schema.description || `${key} parameter`, - required: !isZodOptional(schema) - })), - handler: validatedHandler - }); - return this; - } - /** - * Handle MCP protocol requests - */ - async handleRequest(request) { - switch (request.method) { - case "initialize": - return this.handleInitialize(request.params || {}); - case "notifications/initialized": - return null; - case "tools/list": - return this.handleToolsList(request.params || {}); - case "tools/call": - return this.handleToolsCall(request.params); - case "resources/list": - return this.handleResourcesList(request.params || {}); - case "resources/read": - return this.handleResourcesRead(request.params); - case "prompts/list": - return this.handlePromptsList(request.params || {}); - case "prompts/get": - return this.handlePromptsGet(request.params); - default: - throw new Error(`Method not found: ${request.method}`); - } - } - /** - * Handle initialize request - */ - async handleInitialize() { - return { - protocolVersion: this.config.protocolVersion, - capabilities: { - tools: { listChanged: true }, - resources: { listChanged: true }, - prompts: { listChanged: true } - }, - serverInfo: { - name: this.config.name, - version: this.config.version - }, - instructions: this.config.description - }; - } - /** - * Handle tools/list request - */ - async handleToolsList() { - const tools = Array.from(this.tools.values()).map((tool) => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema - })); - return { tools }; - } - /** - * Handle tools/call request - */ - async handleToolsCall(params) { - if (!params?.name) { - throw new Error("Tool name is required"); - } - const tool = this.tools.get(params.name); - if (!tool) { - throw new Error(`Tool not found: ${params.name}`); - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - return { - content: [{ type: "text", text: `Error: ${error.message}` }], - isError: true - }; - } - } - /** - * Handle resources/list request - */ - async handleResourcesList() { - const resources = Array.from(this.resources.values()).map((resource) => ({ - uri: resource.uri, - name: resource.name, - description: resource.description - })); - return { resources }; - } - /** - * Handle resources/read request - */ - async handleResourcesRead(params) { - if (!params?.uri) { - throw new Error("Resource URI is required"); - } - const resource = Array.from(this.resources.values()).find( - (r) => r.uri === params.uri - ); - if (!resource) { - throw new Error(`Resource not found: ${params.uri}`); - } - try { - const result = await resource.handler(params.uri); - return result; - } catch (error) { - throw new Error(`Resource read error: ${error.message}`); - } - } - /** - * Handle prompts/list request - */ - async handlePromptsList() { - const prompts = Array.from(this.prompts.values()).map((prompt) => ({ - name: prompt.name, - description: prompt.description, - arguments: prompt.arguments - })); - return { prompts }; - } - /** - * Handle prompts/get request - */ - async handlePromptsGet(params) { - if (!params?.name) { - throw new Error("Prompt name is required"); - } - const prompt = this.prompts.get(params.name); - if (!prompt) { - throw new Error(`Prompt not found: ${params.name}`); - } - try { - const result = await prompt.handler(params.arguments || {}); - return result; - } catch (error) { - throw new Error(`Prompt execution error: ${error.message}`); - } - } - /** - * Get server statistics - */ - getStats() { - return { - tools: this.tools.size, - resources: this.resources.size, - prompts: this.prompts.size, - config: this.config - }; - } -}; - -// src/lambda-adapter.mjs -init_cors_config(); -function createResponse(body, statusCode = 200, headers = {}) { - return { - statusCode, - headers: { - "Content-Type": "application/json", - ...headers - }, - body: typeof body === "string" ? body : JSON.stringify(body) - }; -} -function createErrorResponse(statusCode, code, message, headers = {}, id = null) { - return createResponse( - { - jsonrpc: "2.0", - error: { code, message }, - id - }, - statusCode, - headers - ); -} -async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { - const contentType = headers["content-type"] || headers["Content-Type"] || ""; - if (!contentType.includes("application/json")) { - return createErrorResponse( - 400, - -32700, - "Parse error: Content-Type must be application/json", - corsHeaders - ); - } - let jsonRpcMessage; - try { - jsonRpcMessage = JSON.parse(body || "{}"); - } catch { - return createErrorResponse( - 400, - -32700, - "Parse error: Invalid JSON", - corsHeaders - ); - } - if (!jsonRpcMessage.jsonrpc || jsonRpcMessage.jsonrpc !== "2.0") { - return createErrorResponse( - 400, - -32600, - "Invalid Request: missing jsonrpc field", - corsHeaders, - jsonRpcMessage.id - ); - } - if (!jsonRpcMessage.method) { - return createErrorResponse( - 400, - -32600, - "Invalid Request: missing method field", - corsHeaders, - jsonRpcMessage.id - ); - } - try { - const result = await mcpServer.handleRequest(jsonRpcMessage); - if (result === null) { - return createResponse("", 204, corsHeaders); - } - return createResponse( - { - jsonrpc: "2.0", - result, - id: jsonRpcMessage.id - }, - 200, - corsHeaders - ); - } catch (error) { - console.error("MCP request error:", error); - let errorCode = -32603; - let errorMessage = error.message; - if (error.message.includes("Method not found")) { - errorCode = -32601; - } else if (error.message.includes("not found") || error.message.includes("required")) { - errorCode = -32602; - } - return createErrorResponse( - 500, - errorCode, - errorMessage, - corsHeaders, - jsonRpcMessage.id - ); - } -} -function createLambdaHandler(mcpServer, options = {}) { - const baseHandler = async (event) => { - try { - const method = event.httpMethod || event.requestContext?.http?.method; - const headers = event.headers || {}; - if (method === "OPTIONS") { - return createResponse("", 200, CORS_HEADERS); - } - if (method === "POST") { - return await handleMCPRequest( - mcpServer, - event.body, - headers, - CORS_HEADERS - ); - } - if (method === "GET") { - return createErrorResponse( - 405, - -32e3, - "Method not allowed: Stateless mode", - CORS_HEADERS - ); - } - return createErrorResponse( - 405, - -32e3, - `Method not allowed: ${method}`, - CORS_HEADERS - ); - } catch (error) { - console.error("Lambda error:", error); - return createErrorResponse( - 500, - -32603, - "Internal server error", - withBasicCORS({ "Content-Type": "application/json" }) - ); - } - }; - if (options.auth) { - return async (event, context) => { - try { - const { createAuthenticatedHandler: createAuthenticatedHandler2 } = await Promise.resolve().then(() => (init_middleware(), middleware_exports)); - const authenticatedHandler = createAuthenticatedHandler2( - baseHandler, - options.auth - ); - return await authenticatedHandler(event, context); - } catch (error) { - console.error("Authentication module error:", error); - return { - statusCode: 500, - headers: withBasicCORS({ "Content-Type": "application/json" }), - body: JSON.stringify({ - error: "server_error", - message: "Authentication module not available" - }) - }; - } - }; - } - return baseHandler; -} - -// src/common-schemas.mjs -var import_zod2 = require("zod"); -var CommonSchemas = { - // Basic types - string: import_zod2.z.string(), - number: import_zod2.z.number(), - boolean: import_zod2.z.boolean(), - // Optional types - optionalString: import_zod2.z.string().optional(), - optionalNumber: import_zod2.z.number().optional(), - optionalBoolean: import_zod2.z.boolean().optional(), - // Common patterns - email: import_zod2.z.string().email(), - url: import_zod2.z.string().url(), - uuid: import_zod2.z.string().uuid(), - // Utility functions - enum: (values) => import_zod2.z.enum(values), - array: (itemSchema) => import_zod2.z.array(itemSchema), - object: (shape) => import_zod2.z.object(shape) -}; - -// src/index.mjs -function createMCPServer(config) { - return new MCPServer(config); -} -// Annotate the CommonJS export names for ESM import in node: -0 && (module.exports = { - CommonSchemas, - MCPServer, - createLambdaHandler, - createMCPServer -}); diff --git a/dist/index.mjs b/dist/index.mjs index 2ccbcdc..05a9f8f 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -1,793 +1,496 @@ -var __defProp = Object.defineProperty; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __esm = (fn, res) => function __init() { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; -}; -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; - -// src/cors-config.mjs -function withCORS(additionalHeaders = {}) { - return { - ...CORS_HEADERS, - ...additionalHeaders - }; -} -function withBasicCORS(additionalHeaders = {}) { - return { - ...BASIC_CORS_HEADERS, - ...additionalHeaders - }; -} -var CORS_HEADERS, BASIC_CORS_HEADERS; -var init_cors_config = __esm({ - "src/cors-config.mjs"() { - CORS_HEADERS = { - "Access-Control-Allow-Origin": "*", - "Access-Control-Allow-Headers": "Content-Type, Accept, Authorization, Mcp-Protocol-Version, Mcp-Session-Id", - "Access-Control-Allow-Methods": "GET, POST, OPTIONS" - }; - BASIC_CORS_HEADERS = { - "Access-Control-Allow-Origin": "*" - }; - } -}); - -// src/auth/bearer-token.mjs -function createAuthErrorResponse(statusCode, error, message, additionalHeaders = {}) { - const headers = withCORS({ - "Content-Type": "application/json", - ...additionalHeaders - }); - return { - statusCode, - headers, - body: JSON.stringify({ - error, - message - }) - }; -} -function validateBearerToken(event, config = {}) { - const authHeader = event.headers?.authorization || event.headers?.Authorization; - if (!authHeader) { - return { - isValid: false, - error: createAuthErrorResponse( - 401, - "unauthorized", - "Authorization header is required", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - if (!authHeader.startsWith("Bearer ")) { - return { - isValid: false, - error: createAuthErrorResponse( - 401, - "unauthorized", - "Bearer token is required", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - const token = authHeader.substring(7); - if (config.validate && typeof config.validate === "function") { - try { - const result = config.validate(token, event); - if (result && result.isValid) { - return { - isValid: true, - user: result.user || { token }, - token - }; - } else { - return { - isValid: false, - error: result?.error || createAuthErrorResponse( - 401, - "invalid_token", - "Invalid or expired token", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - } catch (error) { - console.error("Error in custom token validation:", error); - return { - isValid: false, - error: createAuthErrorResponse( - 500, - "server_error", - "Authentication validation error" - ) - }; - } - } - const validTokens = config.tokens || []; - if (validTokens.length === 0) { - console.warn("No valid tokens configured for Bearer token authentication."); - return { - isValid: false, - error: createAuthErrorResponse( - 500, - "server_error", - "Authentication not configured" - ) - }; - } - if (!validTokens.includes(token)) { - return { - isValid: false, - error: createAuthErrorResponse( - 401, - "invalid_token", - "Invalid or expired token", - { "WWW-Authenticate": 'Bearer realm="MCP Server"' } - ) - }; - } - return { - isValid: true, - user: { token }, - token - }; -} -var init_bearer_token = __esm({ - "src/auth/bearer-token.mjs"() { - init_cors_config(); - } -}); - -// src/auth/middleware.mjs -var middleware_exports = {}; -__export(middleware_exports, { - createAuthMiddleware: () => createAuthMiddleware, - createAuthenticatedHandler: () => createAuthenticatedHandler -}); -function handleCORSPreflight(event) { - const method = event.requestContext?.http?.method || event.httpMethod; - if (method === "OPTIONS") { - return { - statusCode: 200, - headers: CORS_HEADERS, - body: "" - }; - } - return null; -} -function createAuthMiddleware(authConfig) { - return async (event) => { - const corsResponse = handleCORSPreflight(event); - if (corsResponse) { - return corsResponse; - } - let authResult; - switch (authConfig.type) { - case "bearer-token": - authResult = validateBearerToken(event, authConfig); - break; - default: - console.error(`Unsupported authentication type: ${authConfig.type}`); - return { - statusCode: 500, - headers: withBasicCORS({ "Content-Type": "application/json" }), - body: JSON.stringify({ - error: "server_error", - message: "Unsupported authentication type" - }) - }; - } - if (!authResult.isValid) { - console.log("Authentication failed:", authResult.error.body); - return authResult.error; - } - event.user = authResult.user; - event.authToken = authResult.token; - console.log("Authentication successful"); - return null; - }; -} -function createAuthenticatedHandler(originalHandler, authConfig) { - const authMiddleware = createAuthMiddleware(authConfig); - return async (event) => { - console.log("=== MCP Server Request Start (with Authentication) ==="); - console.log("Event:", JSON.stringify(event, null, 2)); - try { - const authResponse = await authMiddleware(event); - if (authResponse) { - return authResponse; - } - const response = await originalHandler(event); - console.log("=== MCP Server Request End ==="); - return response; - } catch (error) { - console.error("Error in authenticated MCP server:", error); - return { - statusCode: 500, - headers: withBasicCORS({ "Content-Type": "application/json" }), - body: JSON.stringify({ - error: "internal_server_error", - message: "An internal server error occurred" - }) - }; - } - }; -} -var init_middleware = __esm({ - "src/auth/middleware.mjs"() { - init_bearer_token(); - init_cors_config(); - } -}); - -// src/schema-utils.mjs +import { n as withBasicCORS, t as CORS_HEADERS } from "./cors-config-C27FWWLN.mjs"; import { z } from "zod"; + +//#region src/schema-utils.ts +/** +* Schema Utilities +* +* Zod schema conversion and validation utilities +*/ +/** +* Convert Zod schema to JSON Schema +*/ function zodToJsonSchema(zodSchema) { - const properties = {}; - const required = []; - for (const [key, schema] of Object.entries(zodSchema)) { - properties[key] = convertZodTypeToJsonSchema(schema); - if (!isZodOptional(schema)) { - required.push(key); - } - } - return { - type: "object", - properties, - required - }; + const properties = {}; + const required = []; + for (const [key, schema] of Object.entries(zodSchema)) { + properties[key] = convertZodTypeToJsonSchema(schema); + if (!isZodOptional(schema)) required.push(key); + } + return { + type: "object", + properties, + required + }; } +/** +* Convert individual Zod type to JSON Schema +*/ function convertZodTypeToJsonSchema(zodType) { - if (zodType instanceof z.ZodOptional) { - return convertZodTypeToJsonSchema(zodType._def.innerType); - } - if (zodType instanceof z.ZodDefault) { - const schema = convertZodTypeToJsonSchema(zodType._def.innerType); - schema.default = zodType._def.defaultValue(); - return schema; - } - if (zodType instanceof z.ZodString) { - const schema = { type: "string" }; - if (zodType._def.checks) { - for (const check of zodType._def.checks) { - switch (check.kind) { - case "min": - schema.minLength = check.value; - break; - case "max": - schema.maxLength = check.value; - break; - case "email": - schema.format = "email"; - break; - case "url": - schema.format = "uri"; - break; - case "uuid": - schema.format = "uuid"; - break; - } - } - } - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof z.ZodNumber) { - const schema = { type: "number" }; - if (zodType._def.checks) { - for (const check of zodType._def.checks) { - switch (check.kind) { - case "min": - schema.minimum = check.value; - break; - case "max": - schema.maximum = check.value; - break; - case "int": - schema.type = "integer"; - break; - } - } - } - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof z.ZodBoolean) { - const schema = { type: "boolean" }; - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof z.ZodEnum) { - const schema = { - type: "string", - enum: zodType._def.values - }; - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof z.ZodArray) { - const schema = { - type: "array", - items: convertZodTypeToJsonSchema(zodType._def.type) - }; - if (zodType._def.minLength) { - schema.minItems = zodType._def.minLength.value; - } - if (zodType._def.maxLength) { - schema.maxItems = zodType._def.maxLength.value; - } - if (zodType.description) { - schema.description = zodType.description; - } - return schema; - } - if (zodType instanceof z.ZodObject) { - return zodToJsonSchema(zodType.shape); - } - return { - type: "string", - description: zodType.description || "Unknown type" - }; + if (zodType instanceof z.ZodOptional) { + const def = zodType._def; + return convertZodTypeToJsonSchema(def.innerType); + } + if (zodType instanceof z.ZodDefault) { + const def = zodType._def; + const schema = convertZodTypeToJsonSchema(def.innerType); + schema.default = def.defaultValue(); + return schema; + } + if (zodType instanceof z.ZodString) { + const schema = { type: "string" }; + const def = zodType._def; + if (def.checks) for (const check of def.checks) switch (check.kind) { + case "min": + schema.minLength = check.value; + break; + case "max": + schema.maxLength = check.value; + break; + case "email": + schema.format = "email"; + break; + case "url": + schema.format = "uri"; + break; + case "uuid": + schema.format = "uuid"; + break; + } + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof z.ZodNumber) { + const schema = { type: "number" }; + const def = zodType._def; + if (def.checks) for (const check of def.checks) switch (check.kind) { + case "min": + schema.minimum = check.value; + break; + case "max": + schema.maximum = check.value; + break; + case "int": + schema.type = "integer"; + break; + } + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof z.ZodBoolean) { + const schema = { type: "boolean" }; + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof z.ZodEnum) { + const schema = { + type: "string", + enum: zodType._def.values + }; + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof z.ZodArray) { + const schema = { + type: "array", + items: convertZodTypeToJsonSchema(zodType._def.type) + }; + if (zodType._def.minLength) schema.minItems = zodType._def.minLength.value; + if (zodType._def.maxLength) schema.maxItems = zodType._def.maxLength.value; + if (zodType.description) schema.description = zodType.description; + return schema; + } + if (zodType instanceof z.ZodObject) return zodToJsonSchema(zodType.shape); + return { + type: "string", + description: zodType.description || "Unknown type" + }; } +/** +* Check if Zod type is optional +*/ function isZodOptional(zodType) { - return zodType instanceof z.ZodOptional || zodType instanceof z.ZodDefault; + return zodType instanceof z.ZodOptional || zodType instanceof z.ZodDefault; } +/** +* Check if Zod type has default value +*/ function hasZodDefault(zodType) { - return zodType instanceof z.ZodDefault; + return zodType instanceof z.ZodDefault; } +/** +* Validate arguments with Zod schema +*/ function validateWithZod(zodSchema, args) { - const validated = {}; - for (const [key, schema] of Object.entries(zodSchema)) { - try { - if (args[key] === void 0 && isZodOptional(schema)) { - if (hasZodDefault(schema)) { - validated[key] = schema.parse(void 0); - } - continue; - } - validated[key] = schema.parse(args[key]); - } catch (error) { - throw new z.ZodError([ - { - code: "custom", - path: [key], - message: `${error.message}` - } - ]); - } - } - return validated; + const validated = {}; + for (const [key, schema] of Object.entries(zodSchema)) try { + if (args[key] === void 0 && isZodOptional(schema)) { + if (hasZodDefault(schema)) validated[key] = schema.parse(void 0); + continue; + } + validated[key] = schema.parse(args[key]); + } catch (error) { + throw new z.ZodError([{ + code: "custom", + path: [key], + message: error instanceof Error ? error.message : String(error) + }]); + } + return validated; } -// src/mcp-server.mjs +//#endregion +//#region src/mcp-server.ts +/** +* MCP Server Core Implementation +* +* Handles MCP protocol logic and tool/resource/prompt management +*/ +/** +* Main MCP Server class with Zod-based type safety +*/ var MCPServer = class { - constructor(config) { - this.config = { - name: config.name || "MCP Server", - version: config.version || "1.0.0", - description: config.description || "MCP Server powered by AWS Lambda", - protocolVersion: config.protocolVersion || "2025-03-26", - ...config - }; - this.tools = /* @__PURE__ */ new Map(); - this.resources = /* @__PURE__ */ new Map(); - this.prompts = /* @__PURE__ */ new Map(); - } - /** - * Register a tool with Zod schema validation - */ - tool(name, inputSchema, handler) { - const jsonSchema = zodToJsonSchema(inputSchema); - const validatedHandler = async (args) => { - try { - const validatedArgs = validateWithZod(inputSchema, args); - return await handler(validatedArgs); - } catch (error) { - if (error.name === "ZodError") { - throw new Error( - `Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}` - ); - } - throw error; - } - }; - this.tools.set(name, { - name, - description: handler.description || `Tool: ${name}`, - inputSchema: jsonSchema, - handler: validatedHandler - }); - return this; - } - /** - * Register a resource - */ - resource(name, uri, handler) { - this.resources.set(name, { - name, - uri, - description: handler.description || `Resource: ${name}`, - handler - }); - return this; - } - /** - * Register a prompt with Zod schema validation - */ - prompt(name, inputSchema, handler) { - zodToJsonSchema(inputSchema); - const validatedHandler = async (args) => { - try { - const validatedArgs = validateWithZod(inputSchema, args); - return await handler(validatedArgs); - } catch (error) { - if (error.name === "ZodError") { - throw new Error( - `Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}` - ); - } - throw error; - } - }; - this.prompts.set(name, { - name, - description: handler.description || `Prompt: ${name}`, - arguments: Object.entries(inputSchema).map(([key, schema]) => ({ - name: key, - description: schema.description || `${key} parameter`, - required: !isZodOptional(schema) - })), - handler: validatedHandler - }); - return this; - } - /** - * Handle MCP protocol requests - */ - async handleRequest(request) { - switch (request.method) { - case "initialize": - return this.handleInitialize(request.params || {}); - case "notifications/initialized": - return null; - case "tools/list": - return this.handleToolsList(request.params || {}); - case "tools/call": - return this.handleToolsCall(request.params); - case "resources/list": - return this.handleResourcesList(request.params || {}); - case "resources/read": - return this.handleResourcesRead(request.params); - case "prompts/list": - return this.handlePromptsList(request.params || {}); - case "prompts/get": - return this.handlePromptsGet(request.params); - default: - throw new Error(`Method not found: ${request.method}`); - } - } - /** - * Handle initialize request - */ - async handleInitialize() { - return { - protocolVersion: this.config.protocolVersion, - capabilities: { - tools: { listChanged: true }, - resources: { listChanged: true }, - prompts: { listChanged: true } - }, - serverInfo: { - name: this.config.name, - version: this.config.version - }, - instructions: this.config.description - }; - } - /** - * Handle tools/list request - */ - async handleToolsList() { - const tools = Array.from(this.tools.values()).map((tool) => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema - })); - return { tools }; - } - /** - * Handle tools/call request - */ - async handleToolsCall(params) { - if (!params?.name) { - throw new Error("Tool name is required"); - } - const tool = this.tools.get(params.name); - if (!tool) { - throw new Error(`Tool not found: ${params.name}`); - } - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - return { - content: [{ type: "text", text: `Error: ${error.message}` }], - isError: true - }; - } - } - /** - * Handle resources/list request - */ - async handleResourcesList() { - const resources = Array.from(this.resources.values()).map((resource) => ({ - uri: resource.uri, - name: resource.name, - description: resource.description - })); - return { resources }; - } - /** - * Handle resources/read request - */ - async handleResourcesRead(params) { - if (!params?.uri) { - throw new Error("Resource URI is required"); - } - const resource = Array.from(this.resources.values()).find( - (r) => r.uri === params.uri - ); - if (!resource) { - throw new Error(`Resource not found: ${params.uri}`); - } - try { - const result = await resource.handler(params.uri); - return result; - } catch (error) { - throw new Error(`Resource read error: ${error.message}`); - } - } - /** - * Handle prompts/list request - */ - async handlePromptsList() { - const prompts = Array.from(this.prompts.values()).map((prompt) => ({ - name: prompt.name, - description: prompt.description, - arguments: prompt.arguments - })); - return { prompts }; - } - /** - * Handle prompts/get request - */ - async handlePromptsGet(params) { - if (!params?.name) { - throw new Error("Prompt name is required"); - } - const prompt = this.prompts.get(params.name); - if (!prompt) { - throw new Error(`Prompt not found: ${params.name}`); - } - try { - const result = await prompt.handler(params.arguments || {}); - return result; - } catch (error) { - throw new Error(`Prompt execution error: ${error.message}`); - } - } - /** - * Get server statistics - */ - getStats() { - return { - tools: this.tools.size, - resources: this.resources.size, - prompts: this.prompts.size, - config: this.config - }; - } + config; + tools; + resources; + prompts; + constructor(config) { + const { name = "MCP Server", version = "1.0.0", description = "MCP Server powered by AWS Lambda", protocolVersion = "2025-03-26", ...rest } = config; + this.config = { + name, + version, + description, + protocolVersion, + ...rest + }; + this.tools = /* @__PURE__ */ new Map(); + this.resources = /* @__PURE__ */ new Map(); + this.prompts = /* @__PURE__ */ new Map(); + } + /** + * Register a tool with Zod schema validation + */ + tool(name, inputSchema, handler, options) { + const jsonSchema = zodToJsonSchema(inputSchema); + let outputSchema = void 0; + if (options?.outputZodSchema) outputSchema = zodToJsonSchema(options.outputZodSchema); + const handlerDescription = handler.description; + const validatedHandler = async (args) => { + try { + return await handler(validateWithZod(inputSchema, args)); + } catch (error) { + if (error instanceof z.ZodError) throw new Error(`Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`); + throw error; + } + }; + this.tools.set(name, { + name, + description: handlerDescription || `Tool: ${name}`, + inputSchema: jsonSchema, + handler: validatedHandler, + options: { + outputSchema, + annotations: options?.annotations + } + }); + return this; + } + /** + * Register a resource + */ + resource(name, uri, handler) { + const handlerDescription = handler.description; + this.resources.set(name, { + name, + uri, + description: handlerDescription || `Resource: ${name}`, + handler: async (resourceUri) => handler(resourceUri) + }); + return this; + } + /** + * Register a prompt with Zod schema validation + */ + prompt(name, inputSchema, handler) { + zodToJsonSchema(inputSchema); + const handlerDescription = handler.description; + const validatedHandler = async (args) => { + try { + return await handler(validateWithZod(inputSchema, args)); + } catch (error) { + if (error instanceof z.ZodError) throw new Error(`Validation error: ${error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join(", ")}`); + throw error; + } + }; + this.prompts.set(name, { + name, + description: handlerDescription || `Prompt: ${name}`, + arguments: Object.entries(inputSchema).map(([key, schema]) => ({ + name: key, + description: schema.description || `${key} parameter`, + required: !isZodOptional(schema) + })), + handler: validatedHandler + }); + return this; + } + async handleRequest(request) { + switch (request.method) { + case "initialize": return this.handleInitialize(); + case "notifications/initialized": return null; + case "tools/list": return this.handleToolsList(); + case "tools/call": return this.handleToolsCall(request.params); + case "resources/list": return this.handleResourcesList(); + case "resources/read": return this.handleResourcesRead(request.params); + case "prompts/list": return this.handlePromptsList(); + case "prompts/get": return this.handlePromptsGet(request.params); + default: throw new Error(`Method not found: ${request.method}`); + } + } + /** + * Handle initialize request + */ + async handleInitialize() { + return { + protocolVersion: this.config.protocolVersion, + capabilities: { + tools: { listChanged: true }, + resources: { listChanged: true }, + prompts: { listChanged: true } + }, + serverInfo: { + name: this.config.name, + version: this.config.version + }, + instructions: this.config.description + }; + } + /** + * Handle tools/list request + */ + async handleToolsList() { + return { tools: Array.from(this.tools.values()).map((tool) => ({ + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + outputSchema: tool.options?.outputSchema, + annotations: tool.options?.annotations + })) }; + } + /** + * Handle tools/call request + */ + async handleToolsCall(params) { + if (!params?.name) throw new Error("Tool name is required"); + const tool = this.tools.get(params.name); + if (!tool) throw new Error(`Tool not found: ${params.name}`); + try { + return await tool.handler(params.arguments || {}); + } catch (error) { + return { + content: [{ + type: "text", + text: `Error: ${error instanceof Error ? error.message : String(error)}` + }], + isError: true + }; + } + } + /** + * Handle resources/list request + */ + async handleResourcesList() { + return { resources: Array.from(this.resources.values()).map((resource) => ({ + uri: resource.uri, + name: resource.name, + description: resource.description + })) }; + } + /** + * Handle resources/read request + */ + async handleResourcesRead(params) { + if (!params?.uri) throw new Error("Resource URI is required"); + const resource = Array.from(this.resources.values()).find((r) => r.uri === params.uri); + if (!resource) throw new Error(`Resource not found: ${params.uri}`); + try { + return await resource.handler(params.uri); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Resource read error: ${errorMessage}`); + } + } + /** + * Handle prompts/list request + */ + async handlePromptsList() { + return { prompts: Array.from(this.prompts.values()).map((prompt) => ({ + name: prompt.name, + description: prompt.description, + arguments: prompt.arguments + })) }; + } + /** + * Handle prompts/get request + */ + async handlePromptsGet(params) { + if (!params?.name) throw new Error("Prompt name is required"); + const prompt = this.prompts.get(params.name); + if (!prompt) throw new Error(`Prompt not found: ${params.name}`); + try { + return await prompt.handler(params.arguments || {}); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Prompt execution error: ${errorMessage}`); + } + } + /** + * Get server statistics + */ + getStats() { + return { + tools: this.tools.size, + resources: this.resources.size, + prompts: this.prompts.size, + config: this.config + }; + } }; -// src/lambda-adapter.mjs -init_cors_config(); +//#endregion +//#region src/lambda-adapter.ts +/** +* Create HTTP response +*/ function createResponse(body, statusCode = 200, headers = {}) { - return { - statusCode, - headers: { - "Content-Type": "application/json", - ...headers - }, - body: typeof body === "string" ? body : JSON.stringify(body) - }; + return { + statusCode, + headers: { + "Content-Type": "application/json", + ...headers + }, + body: typeof body === "string" ? body : JSON.stringify(body) + }; } +/** +* Create error response +*/ function createErrorResponse(statusCode, code, message, headers = {}, id = null) { - return createResponse( - { - jsonrpc: "2.0", - error: { code, message }, - id - }, - statusCode, - headers - ); + return createResponse({ + jsonrpc: "2.0", + error: { + code, + message + }, + id + }, statusCode, headers); } +/** +* Handle MCP request processing +*/ async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { - const contentType = headers["content-type"] || headers["Content-Type"] || ""; - if (!contentType.includes("application/json")) { - return createErrorResponse( - 400, - -32700, - "Parse error: Content-Type must be application/json", - corsHeaders - ); - } - let jsonRpcMessage; - try { - jsonRpcMessage = JSON.parse(body || "{}"); - } catch { - return createErrorResponse( - 400, - -32700, - "Parse error: Invalid JSON", - corsHeaders - ); - } - if (!jsonRpcMessage.jsonrpc || jsonRpcMessage.jsonrpc !== "2.0") { - return createErrorResponse( - 400, - -32600, - "Invalid Request: missing jsonrpc field", - corsHeaders, - jsonRpcMessage.id - ); - } - if (!jsonRpcMessage.method) { - return createErrorResponse( - 400, - -32600, - "Invalid Request: missing method field", - corsHeaders, - jsonRpcMessage.id - ); - } - try { - const result = await mcpServer.handleRequest(jsonRpcMessage); - if (result === null) { - return createResponse("", 204, corsHeaders); - } - return createResponse( - { - jsonrpc: "2.0", - result, - id: jsonRpcMessage.id - }, - 200, - corsHeaders - ); - } catch (error) { - console.error("MCP request error:", error); - let errorCode = -32603; - let errorMessage = error.message; - if (error.message.includes("Method not found")) { - errorCode = -32601; - } else if (error.message.includes("not found") || error.message.includes("required")) { - errorCode = -32602; - } - return createErrorResponse( - 500, - errorCode, - errorMessage, - corsHeaders, - jsonRpcMessage.id - ); - } + if (!(headers["content-type"] || headers["Content-Type"] || "").includes("application/json")) return createErrorResponse(400, -32700, "Parse error: Content-Type must be application/json", corsHeaders); + let jsonRpcMessage; + try { + jsonRpcMessage = JSON.parse(body || "{}"); + } catch { + return createErrorResponse(400, -32700, "Parse error: Invalid JSON", corsHeaders); + } + const responseId = "id" in jsonRpcMessage ? jsonRpcMessage.id : null; + if (!jsonRpcMessage.jsonrpc || jsonRpcMessage.jsonrpc !== "2.0") return createErrorResponse(400, -32600, "Invalid Request: missing jsonrpc field", corsHeaders, responseId); + if (!jsonRpcMessage.method) return createErrorResponse(400, -32600, "Invalid Request: missing method field", corsHeaders, responseId); + try { + const result = await mcpServer.handleRequest(jsonRpcMessage); + if (result === null) return createResponse("", 204, corsHeaders); + return createResponse({ + jsonrpc: "2.0", + result, + id: responseId + }, 200, corsHeaders); + } catch (error) { + console.error("MCP request error:", error); + let errorCode = -32603; + const errorMessage = error instanceof Error ? error.message : String(error); + if (errorMessage.includes("Method not found")) errorCode = -32601; + else if (errorMessage.includes("not found") || errorMessage.includes("required")) errorCode = -32602; + return createErrorResponse(500, errorCode, errorMessage, corsHeaders, responseId); + } } +/** +* AWS Lambda Adapter for MCP Server +*/ function createLambdaHandler(mcpServer, options = {}) { - const baseHandler = async (event) => { - try { - const method = event.httpMethod || event.requestContext?.http?.method; - const headers = event.headers || {}; - if (method === "OPTIONS") { - return createResponse("", 200, CORS_HEADERS); - } - if (method === "POST") { - return await handleMCPRequest( - mcpServer, - event.body, - headers, - CORS_HEADERS - ); - } - if (method === "GET") { - return createErrorResponse( - 405, - -32e3, - "Method not allowed: Stateless mode", - CORS_HEADERS - ); - } - return createErrorResponse( - 405, - -32e3, - `Method not allowed: ${method}`, - CORS_HEADERS - ); - } catch (error) { - console.error("Lambda error:", error); - return createErrorResponse( - 500, - -32603, - "Internal server error", - withBasicCORS({ "Content-Type": "application/json" }) - ); - } - }; - if (options.auth) { - return async (event, context) => { - try { - const { createAuthenticatedHandler: createAuthenticatedHandler2 } = await Promise.resolve().then(() => (init_middleware(), middleware_exports)); - const authenticatedHandler = createAuthenticatedHandler2( - baseHandler, - options.auth - ); - return await authenticatedHandler(event, context); - } catch (error) { - console.error("Authentication module error:", error); - return { - statusCode: 500, - headers: withBasicCORS({ "Content-Type": "application/json" }), - body: JSON.stringify({ - error: "server_error", - message: "Authentication module not available" - }) - }; - } - }; - } - return baseHandler; + const baseHandler = async (event) => { + try { + const method = "httpMethod" in event ? event.httpMethod : event.requestContext?.http?.method; + const headers = event.headers || {}; + if (method === "OPTIONS") return createResponse("", 200, CORS_HEADERS); + if (method === "POST") return await handleMCPRequest(mcpServer, event.body, headers, CORS_HEADERS); + if (method === "GET") return createErrorResponse(405, -32e3, "Method not allowed: Stateless mode", CORS_HEADERS); + return createErrorResponse(405, -32e3, `Method not allowed: ${method}`, CORS_HEADERS); + } catch (error) { + console.error("Lambda error:", error); + return createErrorResponse(500, -32603, "Internal server error", withBasicCORS({ "Content-Type": "application/json" })); + } + }; + if (options.auth) { + const authConfig = options.auth; + return async (event, context) => { + try { + const { createAuthenticatedHandler } = await import("./middleware-DTiONAQk.mjs"); + return await createAuthenticatedHandler(baseHandler, authConfig)(event, context); + } catch (error) { + console.error("Authentication module error:", error); + return { + statusCode: 500, + headers: withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "server_error", + message: "Authentication module not available" + }) + }; + } + }; + } + return baseHandler; } -// src/common-schemas.mjs -import { z as z2 } from "zod"; -var CommonSchemas = { - // Basic types - string: z2.string(), - number: z2.number(), - boolean: z2.boolean(), - // Optional types - optionalString: z2.string().optional(), - optionalNumber: z2.number().optional(), - optionalBoolean: z2.boolean().optional(), - // Common patterns - email: z2.string().email(), - url: z2.string().url(), - uuid: z2.string().uuid(), - // Utility functions - enum: (values) => z2.enum(values), - array: (itemSchema) => z2.array(itemSchema), - object: (shape) => z2.object(shape) +//#endregion +//#region src/common-schemas.ts +/** +* Common Zod Schemas +* +* Pre-defined schemas for common use cases +*/ +/** +* Common schema patterns for MCP tools +*/ +const CommonSchemas = { + string: z.string(), + number: z.number(), + boolean: z.boolean(), + optionalString: z.string().optional(), + optionalNumber: z.number().optional(), + optionalBoolean: z.boolean().optional(), + email: z.string().email(), + url: z.string().url(), + uuid: z.string().uuid(), + enum: (values) => z.enum(values), + array: (itemSchema) => z.array(itemSchema), + object: (shape) => z.object(shape) }; -// src/index.mjs +//#endregion +//#region src/index.ts +/** +* @aws-lambda-mcp/adapter +* +* An MCP (Model Context Protocol) server SDK for AWS Lambda +* with Zod-based type safety, authentication support, and clean separation of concerns. +*/ function createMCPServer(config) { - return new MCPServer(config); + return new MCPServer(config); } -export { - CommonSchemas, - MCPServer, - createLambdaHandler, - createMCPServer -}; + +//#endregion +export { CommonSchemas, MCPServer, createLambdaHandler, createMCPServer }; \ No newline at end of file diff --git a/dist/middleware-BZkZMXHu.cjs b/dist/middleware-BZkZMXHu.cjs new file mode 100644 index 0000000..697874d --- /dev/null +++ b/dist/middleware-BZkZMXHu.cjs @@ -0,0 +1,179 @@ +const require_cors_config = require('./cors-config-HN36M-Ox.cjs'); + +//#region src/auth/bearer-token.ts +/** +* Bearer Token Authentication Module +* +* Provides Bearer token validation functionality for MCP servers +*/ +/** +* Creates an authentication error response +* @param {number} statusCode - HTTP status code +* @param {string} error - Error code +* @param {string} message - Error message +* @param {Object} additionalHeaders - Additional headers to include +* @returns {Object} Lambda response object +*/ +function createAuthErrorResponse(statusCode, error, message, additionalHeaders = {}) { + return { + statusCode, + headers: require_cors_config.withCORS({ + "Content-Type": "application/json", + ...additionalHeaders + }), + body: JSON.stringify({ + error, + message + }) + }; +} +/** +* Validates Bearer token from the Authorization header +* @param {Object} event - Lambda event object +* @param {Object} config - Authentication configuration +* @returns {Object} Validation result with isValid flag and error/user data +*/ +async function validateBearerToken(event, config = { type: "bearer-token" }) { + const authHeader = event.headers?.authorization || event.headers?.Authorization; + if (!authHeader) return { + isValid: false, + error: createAuthErrorResponse(401, "unauthorized", "Authorization header is required", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + if (!authHeader.startsWith("Bearer ")) return { + isValid: false, + error: createAuthErrorResponse(401, "unauthorized", "Bearer token is required", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + const token = authHeader.substring(7); + if (config.validate && typeof config.validate === "function") try { + const result = await config.validate(token, event); + if (result && result.isValid) return { + isValid: true, + user: result.user || { token }, + token + }; + else return { + isValid: false, + error: result?.error || createAuthErrorResponse(401, "invalid_token", "Invalid or expired token", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + } catch (error) { + console.error("Error in custom token validation:", error); + return { + isValid: false, + error: createAuthErrorResponse(500, "server_error", "Authentication validation error") + }; + } + const validTokens = config.tokens || []; + if (validTokens.length === 0) { + console.warn("No valid tokens configured for Bearer token authentication."); + return { + isValid: false, + error: createAuthErrorResponse(500, "server_error", "Authentication not configured") + }; + } + if (!validTokens.includes(token)) return { + isValid: false, + error: createAuthErrorResponse(401, "invalid_token", "Invalid or expired token", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + return { + isValid: true, + user: { token }, + token + }; +} + +//#endregion +//#region src/auth/middleware.ts +/** +* Authentication Middleware Module +* +* Provides authentication middleware for MCP Lambda handlers +*/ +/** +* Handles CORS preflight requests +* @param {Object} event - Lambda event object +* @returns {Object|null} CORS response or null if not a preflight request +*/ +function handleCORSPreflight(event) { + if (("httpMethod" in event ? event.httpMethod : event.requestContext?.http?.method) === "OPTIONS") return { + statusCode: 200, + headers: require_cors_config.CORS_HEADERS, + body: "" + }; + return null; +} +/** +* Creates an authentication middleware function +* @param {Object} authConfig - Authentication configuration +* @returns {Function} Middleware function +*/ +function createAuthMiddleware(authConfig) { + return async (event) => { + const corsResponse = handleCORSPreflight(event); + if (corsResponse) return corsResponse; + let authResult; + switch (authConfig.type) { + case "bearer-token": + authResult = await validateBearerToken(event, authConfig); + break; + default: + console.error(`Unsupported authentication type: ${authConfig.type}`); + return { + statusCode: 500, + headers: require_cors_config.withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "server_error", + message: "Unsupported authentication type" + }) + }; + } + if (!authResult.isValid) { + console.log("Authentication failed:", authResult.error?.body); + const fallbackError = { + statusCode: 401, + headers: require_cors_config.withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "unauthorized", + message: "Authentication failed" + }) + }; + return authResult.error ?? fallbackError; + } + event.user = authResult.user; + event.authToken = authResult.token; + console.log("Authentication successful"); + return null; + }; +} +/** +* Creates an authenticated Lambda handler wrapper +* @param {Function} originalHandler - Original Lambda handler function +* @param {Object} authConfig - Authentication configuration +* @returns {Function} Wrapped handler with authentication +*/ +function createAuthenticatedHandler(originalHandler, authConfig) { + const authMiddleware = createAuthMiddleware(authConfig); + return async (event, context) => { + console.log("=== MCP Server Request Start (with Authentication) ==="); + console.log("Event:", JSON.stringify(event, null, 2)); + try { + const authResponse = await authMiddleware(event); + if (authResponse) return authResponse; + const response = await originalHandler(event, context); + console.log("=== MCP Server Request End ==="); + return response; + } catch (error) { + console.error("Error in authenticated MCP server:", error); + return { + statusCode: 500, + headers: require_cors_config.withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "internal_server_error", + message: "An internal server error occurred" + }) + }; + } + }; +} + +//#endregion +exports.createAuthenticatedHandler = createAuthenticatedHandler; \ No newline at end of file diff --git a/dist/middleware-DTiONAQk.mjs b/dist/middleware-DTiONAQk.mjs new file mode 100644 index 0000000..a2b9798 --- /dev/null +++ b/dist/middleware-DTiONAQk.mjs @@ -0,0 +1,179 @@ +import { n as withBasicCORS, r as withCORS, t as CORS_HEADERS } from "./cors-config-C27FWWLN.mjs"; + +//#region src/auth/bearer-token.ts +/** +* Bearer Token Authentication Module +* +* Provides Bearer token validation functionality for MCP servers +*/ +/** +* Creates an authentication error response +* @param {number} statusCode - HTTP status code +* @param {string} error - Error code +* @param {string} message - Error message +* @param {Object} additionalHeaders - Additional headers to include +* @returns {Object} Lambda response object +*/ +function createAuthErrorResponse(statusCode, error, message, additionalHeaders = {}) { + return { + statusCode, + headers: withCORS({ + "Content-Type": "application/json", + ...additionalHeaders + }), + body: JSON.stringify({ + error, + message + }) + }; +} +/** +* Validates Bearer token from the Authorization header +* @param {Object} event - Lambda event object +* @param {Object} config - Authentication configuration +* @returns {Object} Validation result with isValid flag and error/user data +*/ +async function validateBearerToken(event, config = { type: "bearer-token" }) { + const authHeader = event.headers?.authorization || event.headers?.Authorization; + if (!authHeader) return { + isValid: false, + error: createAuthErrorResponse(401, "unauthorized", "Authorization header is required", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + if (!authHeader.startsWith("Bearer ")) return { + isValid: false, + error: createAuthErrorResponse(401, "unauthorized", "Bearer token is required", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + const token = authHeader.substring(7); + if (config.validate && typeof config.validate === "function") try { + const result = await config.validate(token, event); + if (result && result.isValid) return { + isValid: true, + user: result.user || { token }, + token + }; + else return { + isValid: false, + error: result?.error || createAuthErrorResponse(401, "invalid_token", "Invalid or expired token", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + } catch (error) { + console.error("Error in custom token validation:", error); + return { + isValid: false, + error: createAuthErrorResponse(500, "server_error", "Authentication validation error") + }; + } + const validTokens = config.tokens || []; + if (validTokens.length === 0) { + console.warn("No valid tokens configured for Bearer token authentication."); + return { + isValid: false, + error: createAuthErrorResponse(500, "server_error", "Authentication not configured") + }; + } + if (!validTokens.includes(token)) return { + isValid: false, + error: createAuthErrorResponse(401, "invalid_token", "Invalid or expired token", { "WWW-Authenticate": "Bearer realm=\"MCP Server\"" }) + }; + return { + isValid: true, + user: { token }, + token + }; +} + +//#endregion +//#region src/auth/middleware.ts +/** +* Authentication Middleware Module +* +* Provides authentication middleware for MCP Lambda handlers +*/ +/** +* Handles CORS preflight requests +* @param {Object} event - Lambda event object +* @returns {Object|null} CORS response or null if not a preflight request +*/ +function handleCORSPreflight(event) { + if (("httpMethod" in event ? event.httpMethod : event.requestContext?.http?.method) === "OPTIONS") return { + statusCode: 200, + headers: CORS_HEADERS, + body: "" + }; + return null; +} +/** +* Creates an authentication middleware function +* @param {Object} authConfig - Authentication configuration +* @returns {Function} Middleware function +*/ +function createAuthMiddleware(authConfig) { + return async (event) => { + const corsResponse = handleCORSPreflight(event); + if (corsResponse) return corsResponse; + let authResult; + switch (authConfig.type) { + case "bearer-token": + authResult = await validateBearerToken(event, authConfig); + break; + default: + console.error(`Unsupported authentication type: ${authConfig.type}`); + return { + statusCode: 500, + headers: withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "server_error", + message: "Unsupported authentication type" + }) + }; + } + if (!authResult.isValid) { + console.log("Authentication failed:", authResult.error?.body); + const fallbackError = { + statusCode: 401, + headers: withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "unauthorized", + message: "Authentication failed" + }) + }; + return authResult.error ?? fallbackError; + } + event.user = authResult.user; + event.authToken = authResult.token; + console.log("Authentication successful"); + return null; + }; +} +/** +* Creates an authenticated Lambda handler wrapper +* @param {Function} originalHandler - Original Lambda handler function +* @param {Object} authConfig - Authentication configuration +* @returns {Function} Wrapped handler with authentication +*/ +function createAuthenticatedHandler(originalHandler, authConfig) { + const authMiddleware = createAuthMiddleware(authConfig); + return async (event, context) => { + console.log("=== MCP Server Request Start (with Authentication) ==="); + console.log("Event:", JSON.stringify(event, null, 2)); + try { + const authResponse = await authMiddleware(event); + if (authResponse) return authResponse; + const response = await originalHandler(event, context); + console.log("=== MCP Server Request End ==="); + return response; + } catch (error) { + console.error("Error in authenticated MCP server:", error); + return { + statusCode: 500, + headers: withBasicCORS({ "Content-Type": "application/json" }), + body: JSON.stringify({ + error: "internal_server_error", + message: "An internal server error occurred" + }) + }; + } + }; +} + +//#endregion +export { createAuthenticatedHandler }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 61cdeb5..6129c7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,17 +10,20 @@ "license": "Apache-2.0", "devDependencies": { "@eslint/js": "^9.29.0", + "@types/aws-lambda": "^8.10.137", "@typescript-eslint/eslint-plugin": "^8.34.0", "@typescript-eslint/parser": "^8.34.0", - "chai": "^4.3.6", "esbuild": "^0.19.0", "eslint": "^9.29.0", "eslint-config-prettier": "^10.1.5", "eslint-plugin-prettier": "^5.4.1", "globals": "^16.2.0", - "mocha": "^10.2.0", + "json-schema": "^0.4.0", "prettier": "^3.5.3", + "tsdown": "^0.20.0-beta.3", + "typescript": "^5.6.3", "typescript-eslint": "^8.34.0", + "vitest": "^2.1.8", "zod": "^3.22.4" }, "engines": { @@ -30,6 +33,107 @@ "zod": "^3.22.0" } }, + "node_modules/@babel/generator": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.6.tgz", + "integrity": "sha512-lOoVRwADj8hjf7al89tvQ2a1lf53Z+7tiXMgpZJL3maQPDxh0DgLMN62B2MKUOFcoodBHLMbDM6WAbKgNy5Suw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.28.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", + "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.6.tgz", + "integrity": "sha512-TeR9zWR18BvbfPmGbLampPMW+uW1NZnJlRuuHso8i87QZNq2JRF9i6RgxRqtEq+wQGsS19NNTWr2duhnE49mfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.6" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.6.tgz", + "integrity": "sha512-0ZrskXVEHSWIqZM/sQZ4EV3jZJXRkio/WCxaqKZP1g//CEWEPSfeZFcms4XeKBCHU0ZKnIkdJeU/kF+eRp5lBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.28.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@emnapi/core": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.8.1.tgz", + "integrity": "sha512-AvT9QFpxK0Zd8J0jopedNm+w/2fIzvtPKPjqyw9jwvBaReTTqPBk9Hixaz7KbjimP+QNz605/XnjFcDAL2pqBg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.1.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.8.1.tgz", + "integrity": "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.1.0.tgz", + "integrity": "sha512-WI0DdZ8xFSbgMjR1sFsKABJ/C5OnRrjT06JXbZKexJGrDuPTzZdDYfFlsgcCXCyf+suG5QU2e/y1Wo2V/OapLQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.19.12", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz", @@ -699,6 +803,62 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.1.tgz", + "integrity": "sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1", + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -737,10 +897,20 @@ "node": ">= 8" } }, + "node_modules/@oxc-project/types": { + "version": "0.108.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.108.0.tgz", + "integrity": "sha512-7lf13b2IA/kZO6xgnIZA88sq3vwrxWk+2vxf6cc+omwYCRTiA5e63Beqf3fz/v8jEviChWWmFYBwzfSeyrsj7Q==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, "node_modules/@pkgr/core": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.7.tgz", - "integrity": "sha512-YLT9Zo3oNPJoBjBc4q8G2mjU4tqIbf5CEOORbUUr48dCD9q3umJ3IPlVqOqDakPfd2HuwccBaqlGhN4Gmr5OWg==", + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz", + "integrity": "sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==", "dev": true, "license": "MIT", "engines": { @@ -750,714 +920,1776 @@ "url": "https://opencollective.com/pkgr" } }, - "node_modules/@types/estree": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", - "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.34.0.tgz", - "integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==", + "node_modules/@quansync/fs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@quansync/fs/-/fs-1.0.0.tgz", + "integrity": "sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ==", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.34.0", - "@typescript-eslint/type-utils": "8.34.0", - "@typescript-eslint/utils": "8.34.0", - "@typescript-eslint/visitor-keys": "8.34.0", - "graphemer": "^1.4.0", - "ignore": "^7.0.0", - "natural-compare": "^1.4.0", - "ts-api-utils": "^2.1.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "quansync": "^1.0.0" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^8.34.0", - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" + "url": "https://github.com/sponsors/sxzz" } }, - "node_modules/@typescript-eslint/parser": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.34.0.tgz", - "integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==", + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-beta.60.tgz", + "integrity": "sha512-hOW6iQXtpG4uCW1zGK56+KhEXGttSkTp2ykncW/nkOIF/jOKTqbM944Q73HVeMXP1mPRvE2cZwNp3xeLIeyIGQ==", + "cpu": [ + "arm64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@typescript-eslint/scope-manager": "8.34.0", - "@typescript-eslint/types": "8.34.0", - "@typescript-eslint/typescript-estree": "8.34.0", - "@typescript-eslint/visitor-keys": "8.34.0", - "debug": "^4.3.4" - }, + "optional": true, + "os": [ + "android" + ], "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/@typescript-eslint/project-service": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.34.0.tgz", - "integrity": "sha512-iEgDALRf970/B2YExmtPMPF54NenZUf4xpL3wsCRx/lgjz6ul/l13R81ozP/ZNuXfnLCS+oPmG7JIxfdNYKELw==", + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-beta.60.tgz", + "integrity": "sha512-vyDA4HXY2mP8PPtl5UE17uGPxUNG4m1wkfa3kAkR8JWrFbarV97UmLq22IWrNhtBPa89xqerzLK8KoVmz5JqCQ==", + "cpu": [ + "arm64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.34.0", - "@typescript-eslint/types": "^8.34.0", - "debug": "^4.3.4" - }, + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <5.9.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.34.0.tgz", - "integrity": "sha512-9Ac0X8WiLykl0aj1oYQNcLZjHgBojT6cW68yAgZ19letYu+Hxd0rE0veI1XznSSst1X5lwnxhPbVdwjDRIomRw==", + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-beta.60.tgz", + "integrity": "sha512-WnxyqxAKP2BsxouwGY/RCF5UFw/LA4QOHhJ7VEl+UCelHokiwqNHRbryLAyRy3TE1FZ5eae+vAFcaetAu/kWLw==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "8.34.0", - "@typescript-eslint/visitor-keys": "8.34.0" - }, + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.34.0.tgz", - "integrity": "sha512-+W9VYHKFIzA5cBeooqQxqNriAP0QeQ7xTiDuIOr71hzgffm3EL2hxwWBIIj4GuofIbKxGNarpKqIq6Q6YrShOA==", + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-beta.60.tgz", + "integrity": "sha512-JtyWJ+zXOHof5gOUYwdTWI2kL6b8q9eNwqB/oD4mfUFaC/COEB2+47JMhcq78dey9Ahmec3DZKRDZPRh9hNAMQ==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <5.9.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/@typescript-eslint/type-utils": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.34.0.tgz", - "integrity": "sha512-n7zSmOcUVhcRYC75W2pnPpbO1iwhJY3NLoHEtbJwJSNlVAZuwqu05zY3f3s2SDWWDSo9FdN5szqc73DCtDObAg==", + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-beta.60.tgz", + "integrity": "sha512-LrMoKqpHx+kCaNSk84iSBd4yVOymLIbxJQtvFjDN2CjQraownR+IXcwYDblFcj9ivmS54T3vCboXBbm3s1zbPQ==", + "cpu": [ + "arm" + ], "dev": true, "license": "MIT", - "dependencies": { - "@typescript-eslint/typescript-estree": "8.34.0", - "@typescript-eslint/utils": "8.34.0", - "debug": "^4.3.4", - "ts-api-utils": "^2.1.0" - }, + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" + "node": "^20.19.0 || >=22.12.0" } }, - "node_modules/@typescript-eslint/types": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.34.0.tgz", - "integrity": "sha512-9V24k/paICYPniajHfJ4cuAWETnt7Ssy+R0Rbcqo5sSFr3QEZ/8TSoUi9XeXVBGXCaLtwTOKSLGcInCAvyZeMA==", + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-beta.60.tgz", + "integrity": "sha512-sqI+Vdx1gmXJMsXN3Fsewm3wlt7RHvRs1uysSp//NLsCoh9ZFEUr4ZzGhWKOg6Rvf+njNu/vCsz96x7wssLejQ==", + "cpu": [ + "arm64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-beta.60.tgz", + "integrity": "sha512-8xlqGLDtTP8sBfYwneTDu8+PRm5reNEHAuI/+6WPy9y350ls0KTFd3EJCOWEXWGW0F35ko9Fn9azmurBTjqOrQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-beta.60.tgz", + "integrity": "sha512-iR4nhVouVZK1CiGGGyz+prF5Lw9Lmz30Rl36Hajex+dFVFiegka604zBwzTp5Tl0BZnr50ztnVJ30tGrBhDr8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-beta.60.tgz", + "integrity": "sha512-HbfNcqNeqxFjSMf1Kpe8itr2e2lr0Bm6HltD2qXtfU91bSSikVs9EWsa1ThshQ1v2ZvxXckGjlVLtah6IoslPg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-beta.60.tgz", + "integrity": "sha512-BiiamFcgTJ+ZFOUIMO9AHXUo9WXvHVwGfSrJ+Sv0AsTd2w3VN7dJGiH3WRcxKFetljJHWvGbM4fdpY5lf6RIvw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-beta.60.tgz", + "integrity": "sha512-6roXGbHMdR2ucnxXuwbmQvk8tuYl3VGu0yv13KxspyKBxxBd4RS6iykzLD6mX2gMUHhfX8SVWz7n/62gfyKHow==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^1.1.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-beta.60.tgz", + "integrity": "sha512-JBOm8/DC/CKnHyMHoJFdvzVHxUixid4dGkiTqGflxOxO43uSJMpl77pSPXvzwZ/VXwqblU2V0/PanyCBcRLowQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-beta.60.tgz", + "integrity": "sha512-MKF0B823Efp+Ot8KsbwIuGhKH58pf+2rSM6VcqyNMlNBHheOM0Gf7JmEu+toc1jgN6fqjH7Et+8hAzsLVkIGfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.60.tgz", + "integrity": "sha512-Jz4aqXRPVtqkH1E3jRDzLO5cgN5JwW+WG0wXGE4NiJd25nougv/AHzxmKCzmVQUYnxLmTM0M4wrZp+LlC2FKLg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.55.1.tgz", + "integrity": "sha512-9R0DM/ykwfGIlNu6+2U09ga0WXeZ9MRC2Ter8jnz8415VbuIykVuc6bhdrbORFZANDmTDvq26mJrEVTl8TdnDg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.55.1.tgz", + "integrity": "sha512-eFZCb1YUqhTysgW3sj/55du5cG57S7UTNtdMjCW7LwVcj3dTTcowCsC8p7uBdzKsZYa8J7IDE8lhMI+HX1vQvg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.55.1.tgz", + "integrity": "sha512-p3grE2PHcQm2e8PSGZdzIhCKbMCw/xi9XvMPErPhwO17vxtvCN5FEA2mSLgmKlCjHGMQTP6phuQTYWUnKewwGg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.55.1.tgz", + "integrity": "sha512-rDUjG25C9qoTm+e02Esi+aqTKSBYwVTaoS1wxcN47/Luqef57Vgp96xNANwt5npq9GDxsH7kXxNkJVEsWEOEaQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.55.1.tgz", + "integrity": "sha512-+JiU7Jbp5cdxekIgdte0jfcu5oqw4GCKr6i3PJTlXTCU5H5Fvtkpbs4XJHRmWNXF+hKmn4v7ogI5OQPaupJgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.55.1.tgz", + "integrity": "sha512-V5xC1tOVWtLLmr3YUk2f6EJK4qksksOYiz/TCsFHu/R+woubcLWdC9nZQmwjOAbmExBIVKsm1/wKmEy4z4u4Bw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.55.1.tgz", + "integrity": "sha512-Rn3n+FUk2J5VWx+ywrG/HGPTD9jXNbicRtTM11e/uorplArnXZYsVifnPPqNNP5BsO3roI4n8332ukpY/zN7rQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.55.1.tgz", + "integrity": "sha512-grPNWydeKtc1aEdrJDWk4opD7nFtQbMmV7769hiAaYyUKCT1faPRm2av8CX1YJsZ4TLAZcg9gTR1KvEzoLjXkg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.55.1.tgz", + "integrity": "sha512-a59mwd1k6x8tXKcUxSyISiquLwB5pX+fJW9TkWU46lCqD/GRDe9uDN31jrMmVP3feI3mhAdvcCClhV8V5MhJFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.55.1.tgz", + "integrity": "sha512-puS1MEgWX5GsHSoiAsF0TYrpomdvkaXm0CofIMG5uVkP6IBV+ZO9xhC5YEN49nsgYo1DuuMquF9+7EDBVYu4uA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.55.1.tgz", + "integrity": "sha512-r3Wv40in+lTsULSb6nnoudVbARdOwb2u5fpeoOAZjFLznp6tDU8kd+GTHmJoqZ9lt6/Sys33KdIHUaQihFcu7g==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.55.1.tgz", + "integrity": "sha512-MR8c0+UxAlB22Fq4R+aQSPBayvYa3+9DrwG/i1TKQXFYEaoW3B5b/rkSRIypcZDdWjWnpcvxbNaAJDcSbJU3Lw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.55.1.tgz", + "integrity": "sha512-3KhoECe1BRlSYpMTeVrD4sh2Pw2xgt4jzNSZIIPLFEsnQn9gAnZagW9+VqDqAHgm1Xc77LzJOo2LdigS5qZ+gw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.55.1.tgz", + "integrity": "sha512-ziR1OuZx0vdYZZ30vueNZTg73alF59DicYrPViG0NEgDVN8/Jl87zkAPu4u6VjZST2llgEUjaiNl9JM6HH1Vdw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.55.1.tgz", + "integrity": "sha512-uW0Y12ih2XJRERZ4jAfKamTyIHVMPQnTZcQjme2HMVDAHY4amf5u414OqNYC+x+LzRdRcnIG1YodLrrtA8xsxw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.55.1.tgz", + "integrity": "sha512-u9yZ0jUkOED1BFrqu3BwMQoixvGHGZ+JhJNkNKY/hyoEgOwlqKb62qu+7UjbPSHYjiVy8kKJHvXKv5coH4wDeg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.55.1.tgz", + "integrity": "sha512-/0PenBCmqM4ZUd0190j7J0UsQ/1nsi735iPRakO8iPciE7BQ495Y6msPzaOmvx0/pn+eJVVlZrNrSh4WSYLxNg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.55.1.tgz", + "integrity": "sha512-a8G4wiQxQG2BAvo+gU6XrReRRqj+pLS2NGXKm8io19goR+K8lw269eTrPkSdDTALwMmJp4th2Uh0D8J9bEV1vg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.55.1.tgz", + "integrity": "sha512-bD+zjpFrMpP/hqkfEcnjXWHMw5BIghGisOKPj+2NaNDuVT+8Ds4mPf3XcPHuat1tz89WRL+1wbcxKY3WSbiT7w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.55.1.tgz", + "integrity": "sha512-eLXw0dOiqE4QmvikfQ6yjgkg/xDM+MdU9YJuP4ySTibXU0oAvnEWXt7UDJmD4UkYialMfOGFPJnIHSe/kdzPxg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.55.1.tgz", + "integrity": "sha512-xzm44KgEP11te3S2HCSyYf5zIzWmx3n8HDCc7EE59+lTcswEWNpvMLfd9uJvVX8LCg9QWG67Xt75AuHn4vgsXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.55.1.tgz", + "integrity": "sha512-yR6Bl3tMC/gBok5cz/Qi0xYnVbIxGx5Fcf/ca0eB6/6JwOY+SRUcJfI0OpeTpPls7f194as62thCt/2BjxYN8g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.55.1.tgz", + "integrity": "sha512-3fZBidchE0eY0oFZBnekYCfg+5wAB0mbpCBuofh5mZuzIU/4jIVkbESmd2dOsFNS78b53CYv3OAtwqkZZmU5nA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.55.1.tgz", + "integrity": "sha512-xGGY5pXj69IxKb4yv/POoocPy/qmEGhimy/FoTpTSVju3FYXUQQMFCaZZXJVidsmGxRioZAwpThl/4zX41gRKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz", + "integrity": "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", + "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/aws-lambda": { + "version": "8.10.159", + "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.159.tgz", + "integrity": "sha512-SAP22WSGNN12OQ8PlCzGzRCZ7QDCwI85dQZbmpz7+mAk+L7j+wI7qnvmdKh+o7A5LaOp6QnOZ2NJphAZQTTHQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.34.0.tgz", + "integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.34.0", + "@typescript-eslint/type-utils": "8.34.0", + "@typescript-eslint/utils": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0", + "graphemer": "^1.4.0", + "ignore": "^7.0.0", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.34.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.34.0.tgz", + "integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.34.0", + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/typescript-estree": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.34.0.tgz", + "integrity": "sha512-iEgDALRf970/B2YExmtPMPF54NenZUf4xpL3wsCRx/lgjz6ul/l13R81ozP/ZNuXfnLCS+oPmG7JIxfdNYKELw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.34.0", + "@typescript-eslint/types": "^8.34.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.34.0.tgz", + "integrity": "sha512-9Ac0X8WiLykl0aj1oYQNcLZjHgBojT6cW68yAgZ19letYu+Hxd0rE0veI1XznSSst1X5lwnxhPbVdwjDRIomRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.34.0.tgz", + "integrity": "sha512-+W9VYHKFIzA5cBeooqQxqNriAP0QeQ7xTiDuIOr71hzgffm3EL2hxwWBIIj4GuofIbKxGNarpKqIq6Q6YrShOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.34.0.tgz", + "integrity": "sha512-n7zSmOcUVhcRYC75W2pnPpbO1iwhJY3NLoHEtbJwJSNlVAZuwqu05zY3f3s2SDWWDSo9FdN5szqc73DCtDObAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.34.0", + "@typescript-eslint/utils": "8.34.0", + "debug": "^4.3.4", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.34.0.tgz", + "integrity": "sha512-9V24k/paICYPniajHfJ4cuAWETnt7Ssy+R0Rbcqo5sSFr3QEZ/8TSoUi9XeXVBGXCaLtwTOKSLGcInCAvyZeMA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.34.0.tgz", + "integrity": "sha512-rOi4KZxI7E0+BMqG7emPSK1bB4RICCpF7QD3KCLXn9ZvWoESsOMlHyZPAHyG04ujVplPaHbmEvs34m+wjgtVtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.34.0", + "@typescript-eslint/tsconfig-utils": "8.34.0", + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/visitor-keys": "8.34.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.1.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.34.0.tgz", + "integrity": "sha512-8L4tWatGchV9A1cKbjaavS6mwYwp39jql8xUmIIKJdm+qiaeHy5KMKlBrf30akXAWBzn2SqKsNOtSENWUwg7XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.7.0", + "@typescript-eslint/scope-manager": "8.34.0", + "@typescript-eslint/types": "8.34.0", + "@typescript-eslint/typescript-estree": "8.34.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" } }, - "node_modules/@typescript-eslint/typescript-estree": { + "node_modules/@typescript-eslint/visitor-keys": { "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.34.0.tgz", - "integrity": "sha512-rOi4KZxI7E0+BMqG7emPSK1bB4RICCpF7QD3KCLXn9ZvWoESsOMlHyZPAHyG04ujVplPaHbmEvs34m+wjgtVtg==", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.34.0.tgz", + "integrity": "sha512-qHV7pW7E85A0x6qyrFn+O+q1k1p3tQCsqIZ1KZ5ESLXY57aTvUd3/a4rdPTeXisvhXn2VQG0VSKUqs8KHF2zcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.34.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@vitest/expect": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", + "integrity": "sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.9", + "@vitest/utils": "2.1.9", + "chai": "^5.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-2.1.9.tgz", + "integrity": "sha512-tVL6uJgoUdi6icpxmdrn5YNo3g3Dxv+IHJBr0GXHaEdTcw3F+cPKnsXFhli6nO+f/6SDKPHEK1UN+k+TQv0Ehg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "2.1.9", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.12" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.9.tgz", + "integrity": "sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-2.1.9.tgz", + "integrity": "sha512-ZXSSqTFIrzduD63btIfEyOmNcBmQvgOVsPNPe0jYtESiXkhd8u2erDLnMxmGrDCwHCCHE7hxwRDCT3pt0esT4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "2.1.9", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-2.1.9.tgz", + "integrity": "sha512-oBO82rEjsxLNJincVhLhaxxZdEtV0EFHMK5Kmx5sJ6H9L183dHECjiefOAdnqpIgT5eZwT04PoggUnW88vOBNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.9", + "magic-string": "^0.30.12", + "pathe": "^1.1.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.9.tgz", + "integrity": "sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^3.0.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.9.tgz", + "integrity": "sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "2.1.9", + "loupe": "^3.1.2", + "tinyrainbow": "^1.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/acorn": { + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansis": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-4.2.0.tgz", + "integrity": "sha512-HqZ5rWlFjGiV0tDm3UxxgNRqsOTniqoKZu0pIAfh7TZQMGuZK+hH0drySty0si0QXj1ieop4+SkSfPZBPPkHig==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/ast-kit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ast-kit/-/ast-kit-2.2.0.tgz", + "integrity": "sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "pathe": "^2.0.3" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + } + }, + "node_modules/ast-kit/node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/birpc": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/birpc/-/birpc-4.0.0.tgz", + "integrity": "sha512-LShSxJP0KTmd101b6DRyGBj57LZxSDYWKitQNW/mi8GRMvZb078Uf9+pveax1DrVL89vm7mWe+TovdI/UDOuPw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/chai": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", + "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.34.0", - "@typescript-eslint/tsconfig-utils": "8.34.0", - "@typescript-eslint/types": "8.34.0", - "@typescript-eslint/visitor-keys": "8.34.0", - "debug": "^4.3.4", - "fast-glob": "^3.3.2", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^2.1.0" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": ">=10" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "typescript": ">=4.8.4 <5.9.0" + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "brace-expansion": "^2.0.1" + "has-flag": "^4.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "node": ">=8" } }, - "node_modules/@typescript-eslint/utils": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.34.0.tgz", - "integrity": "sha512-8L4tWatGchV9A1cKbjaavS6mwYwp39jql8xUmIIKJdm+qiaeHy5KMKlBrf30akXAWBzn2SqKsNOtSENWUwg7XQ==", + "node_modules/check-error": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz", + "integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/eslint-utils": "^4.7.0", - "@typescript-eslint/scope-manager": "8.34.0", - "@typescript-eslint/types": "8.34.0", - "@typescript-eslint/typescript-estree": "8.34.0" + "color-name": "~1.1.4" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" + "engines": { + "node": ">= 8" } }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.34.0.tgz", - "integrity": "sha512-qHV7pW7E85A0x6qyrFn+O+q1k1p3tQCsqIZ1KZ5ESLXY57aTvUd3/a4rdPTeXisvhXn2VQG0VSKUqs8KHF2zcA==", + "node_modules/debug": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.34.0", - "eslint-visitor-keys": "^4.2.0" + "ms": "^2.1.3" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": ">=6.0" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", - "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", "dev": true, - "license": "Apache-2.0", + "license": "MIT", "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": ">=6" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/defu": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", + "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", + "dev": true, + "license": "MIT" + }, + "node_modules/dts-resolver": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/dts-resolver/-/dts-resolver-2.1.3.tgz", + "integrity": "sha512-bihc7jPC90VrosXNzK0LTE2cuLP6jr0Ro8jk+kMugHReJVLIpHz/xadeq3MhuwyO4TD4OA3L1Q8pBBFRc08Tsw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.19.0" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "oxc-resolver": ">=11.0.0" + }, + "peerDependenciesMeta": { + "oxc-resolver": { + "optional": true + } } }, - "node_modules/acorn": { - "version": "8.15.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", - "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "node_modules/empathic": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/empathic/-/empathic-2.0.0.tgz", + "integrity": "sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.19.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz", + "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==", "dev": true, + "hasInstallScript": true, "license": "MIT", "bin": { - "acorn": "bin/acorn" + "esbuild": "bin/esbuild" }, "engines": { - "node": ">=0.4.0" + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.19.12", + "@esbuild/android-arm": "0.19.12", + "@esbuild/android-arm64": "0.19.12", + "@esbuild/android-x64": "0.19.12", + "@esbuild/darwin-arm64": "0.19.12", + "@esbuild/darwin-x64": "0.19.12", + "@esbuild/freebsd-arm64": "0.19.12", + "@esbuild/freebsd-x64": "0.19.12", + "@esbuild/linux-arm": "0.19.12", + "@esbuild/linux-arm64": "0.19.12", + "@esbuild/linux-ia32": "0.19.12", + "@esbuild/linux-loong64": "0.19.12", + "@esbuild/linux-mips64el": "0.19.12", + "@esbuild/linux-ppc64": "0.19.12", + "@esbuild/linux-riscv64": "0.19.12", + "@esbuild/linux-s390x": "0.19.12", + "@esbuild/linux-x64": "0.19.12", + "@esbuild/netbsd-x64": "0.19.12", + "@esbuild/openbsd-x64": "0.19.12", + "@esbuild/sunos-x64": "0.19.12", + "@esbuild/win32-arm64": "0.19.12", + "@esbuild/win32-ia32": "0.19.12", + "@esbuild/win32-x64": "0.19.12" } }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.29.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.29.0.tgz", + "integrity": "sha512-GsGizj2Y1rCWDu6XoEekL3RLilp0voSePurjZIkxL3wlm5o5EC9VpgaP7lrCvjnkuLvzFBQWB3vWB3K5KQTveQ==", "dev": true, "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.20.1", + "@eslint/config-helpers": "^0.2.1", + "@eslint/core": "^0.14.0", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "9.29.0", + "@eslint/plugin-kit": "^0.3.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } } }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "node_modules/eslint-config-prettier": { + "version": "10.1.5", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.5.tgz", + "integrity": "sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==", "dev": true, "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "bin": { + "eslint-config-prettier": "bin/cli.js" }, "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" } }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "node_modules/eslint-plugin-prettier": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz", + "integrity": "sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg==", "dev": true, "license": "MIT", "dependencies": { - "color-convert": "^2.0.1" + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.11.7" }, "engines": { - "node": ">=8" + "node": "^14.18.0 || >=16.0.0" }, "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", "dev": true, - "license": "ISC", + "license": "BSD-2-Clause", "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" }, "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0" - }, - "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, - "license": "MIT", + "license": "Apache-2.0", "engines": { - "node": ">=8" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/brace-expansion": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" + "url": "https://opencollective.com/eslint" } }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true, - "license": "ISC" - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" } }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, - "license": "MIT", + "license": "Apache-2.0", "engines": { - "node": ">=10" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://opencollective.com/eslint" } }, - "node_modules/chai": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", - "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, - "license": "MIT", + "license": "ISC", "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.3", - "deep-eql": "^4.1.3", - "get-func-name": "^2.0.2", - "loupe": "^2.3.6", - "pathval": "^1.1.1", - "type-detect": "^4.1.0" + "is-glob": "^4.0.3" }, "engines": { - "node": ">=4" + "node": ">=10.13.0" } }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "node_modules/eslint/node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" + "node": ">= 4" } }, - "node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "license": "MIT", + "license": "ISC", "dependencies": { - "has-flag": "^4.0.0" + "brace-expansion": "^1.1.7" }, "engines": { - "node": ">=8" + "node": "*" } }, - "node_modules/check-error": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", - "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", "dev": true, - "license": "MIT", + "license": "BSD-2-Clause", "dependencies": { - "get-func-name": "^2.0.2" + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" }, "engines": { - "node": "*" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, + "license": "Apache-2.0", "engines": { - "node": ">= 8.10.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" + "url": "https://opencollective.com/eslint" } }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", "dev": true, - "license": "ISC", + "license": "BSD-3-Clause", "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" } }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, - "license": "MIT", + "license": "BSD-2-Clause", "dependencies": { - "color-name": "~1.1.4" + "estraverse": "^5.2.0" }, "engines": { - "node": ">=7.0.0" + "node": ">=4.0" } }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "license": "MIT" - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, - "license": "MIT" + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", "dev": true, "license": "MIT", "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" + "@types/estree": "^1.0.0" } }, - "node_modules/debug": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", - "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, + "license": "BSD-2-Clause", "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">=0.10.0" } }, - "node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "node_modules/expect-type": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", + "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", "dev": true, - "license": "MIT", + "license": "Apache-2.0", "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=12.0.0" } }, - "node_modules/deep-eql": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.4.tgz", - "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", "dev": true, "license": "MIT", "dependencies": { - "type-detect": "^4.0.0" + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" }, "engines": { - "node": ">=6" + "node": ">=8.6.0" } }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true, "license": "MIT" }, - "node_modules/diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } + "license": "MIT" }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "node_modules/fastq": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", "dev": true, - "license": "MIT" + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } }, - "node_modules/esbuild": { - "version": "0.19.12", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz", - "integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==", + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "dev": true, - "hasInstallScript": true, "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" + "dependencies": { + "flat-cache": "^4.0.0" }, "engines": { - "node": ">=12" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.19.12", - "@esbuild/android-arm": "0.19.12", - "@esbuild/android-arm64": "0.19.12", - "@esbuild/android-x64": "0.19.12", - "@esbuild/darwin-arm64": "0.19.12", - "@esbuild/darwin-x64": "0.19.12", - "@esbuild/freebsd-arm64": "0.19.12", - "@esbuild/freebsd-x64": "0.19.12", - "@esbuild/linux-arm": "0.19.12", - "@esbuild/linux-arm64": "0.19.12", - "@esbuild/linux-ia32": "0.19.12", - "@esbuild/linux-loong64": "0.19.12", - "@esbuild/linux-mips64el": "0.19.12", - "@esbuild/linux-ppc64": "0.19.12", - "@esbuild/linux-riscv64": "0.19.12", - "@esbuild/linux-s390x": "0.19.12", - "@esbuild/linux-x64": "0.19.12", - "@esbuild/netbsd-x64": "0.19.12", - "@esbuild/openbsd-x64": "0.19.12", - "@esbuild/sunos-x64": "0.19.12", - "@esbuild/win32-arm64": "0.19.12", - "@esbuild/win32-ia32": "0.19.12", - "@esbuild/win32-x64": "0.19.12" + "node": ">=16.0.0" } }, - "node_modules/escalade": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", - "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, "engines": { - "node": ">=6" + "node": ">=8" } }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, "engines": { "node": ">=10" }, @@ -1465,371 +2697,423 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint": { - "version": "9.29.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.29.0.tgz", - "integrity": "sha512-GsGizj2Y1rCWDu6XoEekL3RLilp0voSePurjZIkxL3wlm5o5EC9VpgaP7lrCvjnkuLvzFBQWB3vWB3K5KQTveQ==", + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.20.1", - "@eslint/config-helpers": "^0.2.1", - "@eslint/core": "^0.14.0", - "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.29.0", - "@eslint/plugin-kit": "^0.3.1", - "@humanfs/node": "^0.16.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.2", - "@types/estree": "^1.0.6", - "@types/json-schema": "^7.0.15", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.6", - "debug": "^4.3.2", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.4.0", - "eslint-visitor-keys": "^4.2.1", - "espree": "^10.4.0", - "esquery": "^1.5.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3" - }, - "bin": { - "eslint": "bin/eslint.js" + "flatted": "^3.2.9", + "keyv": "^4.5.4" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://eslint.org/donate" - }, - "peerDependencies": { - "jiti": "*" - }, - "peerDependenciesMeta": { - "jiti": { - "optional": true - } + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/eslint-config-prettier": { - "version": "10.1.5", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.5.tgz", - "integrity": "sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==", + "node_modules/get-tsconfig": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz", + "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==", "dev": true, "license": "MIT", - "bin": { - "eslint-config-prettier": "bin/cli.js" + "dependencies": { + "resolve-pkg-maps": "^1.0.0" }, "funding": { - "url": "https://opencollective.com/eslint-config-prettier" - }, - "peerDependencies": { - "eslint": ">=7.0.0" + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, - "node_modules/eslint-plugin-prettier": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz", - "integrity": "sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg==", + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, - "license": "MIT", + "license": "ISC", "dependencies": { - "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.11.7" + "is-glob": "^4.0.1" }, "engines": { - "node": "^14.18.0 || >=16.0.0" + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz", + "integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" }, "funding": { - "url": "https://opencollective.com/eslint-plugin-prettier" - }, - "peerDependencies": { - "@types/eslint": ">=8.0.0", - "eslint": ">=8.0.0", - "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", - "prettier": ">=3.0.0" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "eslint-config-prettier": { - "optional": true - } + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-scope": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", - "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true, - "license": "BSD-2-Clause", + "license": "MIT" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/hookable": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/hookable/-/hookable-6.0.1.tgz", + "integrity": "sha512-uKGyY8BuzN/a5gvzvA+3FVWo0+wUjgtfSdnmjtrOVwQCZPHpHDH2WRO3VZSOeluYrHoDCiXFffZXs8Dj1ULWtw==", + "dev": true, + "license": "MIT" + }, + "node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": ">=6" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "node_modules/import-without-cache": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/import-without-cache/-/import-without-cache-0.2.5.tgz", + "integrity": "sha512-B6Lc2s6yApwnD2/pMzFh/d5AVjdsDXjgkeJ766FmFuJELIGHNycKRj+l3A39yZPM4CchqNCB4RITEAYB1KUM6A==", "dev": true, - "license": "Apache-2.0", + "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": ">=20.19.0" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://github.com/sponsors/sxzz" } }, - "node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "engines": { + "node": ">=0.8.19" } }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", - "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, - "license": "Apache-2.0", + "license": "MIT", "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" + "node": ">=0.10.0" } }, - "node_modules/eslint/node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "is-glob": "^4.0.3" + "is-extglob": "^2.1.1" }, "engines": { - "node": ">=10.13.0" + "node": ">=0.10.0" } }, - "node_modules/eslint/node_modules/ignore": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", - "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, "license": "MIT", "engines": { - "node": ">= 4" + "node": ">=0.12.0" } }, - "node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true, - "license": "ISC", + "license": "ISC" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", "dependencies": { - "brace-expansion": "^1.1.7" + "argparse": "^2.0.1" }, - "engines": { - "node": "*" + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "node_modules/espree": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", - "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "acorn": "^8.15.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.2.1" + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" + "node": ">=6" } }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", - "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" + "license": "MIT" + }, + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "dev": true, + "license": "(AFL-2.1 OR BSD-3-Clause)" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" } }, - "node_modules/esquery": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", - "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, - "license": "BSD-3-Clause", + "license": "MIT", "dependencies": { - "estraverse": "^5.1.0" + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" }, "engines": { - "node": ">=0.10" + "node": ">= 0.8.0" } }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, - "license": "BSD-2-Clause", + "license": "MIT", "dependencies": { - "estraverse": "^5.2.0" + "p-locate": "^5.0.0" }, "engines": { - "node": ">=4.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } + "license": "MIT" }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "node_modules/loupe": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.10.0" - } + "license": "MIT" }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", "dev": true, - "license": "MIT" + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } }, - "node_modules/fast-diff": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", - "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, - "license": "Apache-2.0" + "license": "MIT", + "engines": { + "node": ">= 8" + } }, - "node_modules/fast-glob": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", - "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "license": "MIT", "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.8" + "braces": "^3.0.3", + "picomatch": "^2.3.1" }, "engines": { - "node": ">=8.6.0" + "node": ">=8.6" } }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, "license": "MIT" }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true, "license": "MIT" }, - "node_modules/fastq": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", - "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "node_modules/obug": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", + "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT" }, - "node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "license": "MIT", "dependencies": { - "flat-cache": "^4.0.0" + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" }, "engines": { - "node": ">=16.0.0" + "node": ">= 0.8.0" } }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "license": "MIT", "dependencies": { - "to-regex-range": "^5.0.1" + "yocto-queue": "^0.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/find-up": { + "node_modules/p-locate": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "license": "MIT", "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" + "p-limit": "^3.0.2" }, "engines": { "node": ">=10" @@ -1838,999 +3122,1363 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, - "license": "BSD-3-Clause", - "bin": { - "flat": "cli.js" + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" } }, - "node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "license": "MIT", - "dependencies": { - "flatted": "^3.2.9", - "keyv": "^4.5.4" - }, "engines": { - "node": ">=16" + "node": ">=8" } }, - "node_modules/flatted": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", - "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, - "license": "ISC" + "license": "MIT", + "engines": { + "node": ">=8" + } }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true, "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, - "hasInstallScript": true, "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", "dev": true, - "license": "ISC", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, "engines": { - "node": "6.* || 8.* || >= 10.*" + "node": "^10 || ^12 || >=14" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "license": "MIT", "engines": { - "node": "*" + "node": ">= 0.8.0" } }, - "node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "deprecated": "Glob versions prior to v9 are no longer supported", + "node_modules/prettier": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=12" + "node": ">=14" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "is-glob": "^4.0.1" + "fast-diff": "^1.1.2" }, "engines": { - "node": ">= 6" + "node": ">=6.0.0" } }, - "node_modules/globals": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz", - "integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==", + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "license": "MIT", "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=6" } }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "node_modules/quansync": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/quansync/-/quansync-1.0.0.tgz", + "integrity": "sha512-5xZacEEufv3HSTPQuchrvV6soaiACMFnq1H8wkVioctoH3TRha9Sz66lOxRwPK/qZj7HPiSveih9yAyh98gvqA==", "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/antfu" + }, + { + "type": "individual", + "url": "https://github.com/sponsors/sxzz" + } + ], "license": "MIT" }, - "node_modules/has-flag": { + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/resolve-from": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=4" } }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", "dev": true, "license": "MIT", - "bin": { - "he": "bin/he" + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, - "node_modules/ignore": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", - "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", "dev": true, "license": "MIT", "engines": { - "node": ">= 4" + "iojs": ">=1.0.0", + "node": ">=0.10.0" } }, - "node_modules/import-fresh": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", - "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "node_modules/rolldown": { + "version": "1.0.0-beta.60", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-beta.60.tgz", + "integrity": "sha512-YYgpv7MiTp9LdLj1fzGzCtij8Yi2OKEc3HQtfbIxW4yuSgpQz9518I69U72T5ErPA/ATOXqlcisiLrWy+5V9YA==", "dev": true, "license": "MIT", "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" + "@oxc-project/types": "=0.108.0", + "@rolldown/pluginutils": "1.0.0-beta.60" + }, + "bin": { + "rolldown": "bin/cli.mjs" }, "engines": { - "node": ">=6" + "node": "^20.19.0 || >=22.12.0" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.0-beta.60", + "@rolldown/binding-darwin-arm64": "1.0.0-beta.60", + "@rolldown/binding-darwin-x64": "1.0.0-beta.60", + "@rolldown/binding-freebsd-x64": "1.0.0-beta.60", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.60", + "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.60", + "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.60", + "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.60", + "@rolldown/binding-linux-x64-musl": "1.0.0-beta.60", + "@rolldown/binding-openharmony-arm64": "1.0.0-beta.60", + "@rolldown/binding-wasm32-wasi": "1.0.0-beta.60", + "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.60", + "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.60" + } + }, + "node_modules/rolldown-plugin-dts": { + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/rolldown-plugin-dts/-/rolldown-plugin-dts-0.21.2.tgz", + "integrity": "sha512-yFOvVkkxmdGVBH4UwCu/ApQZQXI1kre+aQyOyrmDAwFfALRaX7JlEn+F3HDDj3hEFE/q3+kCSGYGxEZ8W5NsGg==", "dev": true, "license": "MIT", - "engines": { - "node": ">=0.8.19" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", - "dev": true, - "license": "ISC", "dependencies": { - "once": "^1.3.0", - "wrappy": "1" + "@babel/generator": "^7.28.6", + "@babel/parser": "^7.28.6", + "@babel/types": "^7.28.6", + "ast-kit": "^2.2.0", + "birpc": "^4.0.0", + "dts-resolver": "^2.1.3", + "get-tsconfig": "^4.13.0", + "obug": "^2.1.1" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "@ts-macro/tsc": "^0.3.6", + "@typescript/native-preview": ">=7.0.0-dev.20250601.1", + "rolldown": "^1.0.0-beta.57", + "typescript": "^5.0.0", + "vue-tsc": "~3.2.0" + }, + "peerDependenciesMeta": { + "@ts-macro/tsc": { + "optional": true + }, + "@typescript/native-preview": { + "optional": true + }, + "typescript": { + "optional": true + }, + "vue-tsc": { + "optional": true + } } }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "node_modules/rollup": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.55.1.tgz", + "integrity": "sha512-wDv/Ht1BNHB4upNbK74s9usvl7hObDnvVzknxqY/E/O3X6rW1U1rV1aENEfJ54eFZDTNo7zv1f5N4edCluH7+A==", "dev": true, "license": "MIT", "dependencies": { - "binary-extensions": "^2.0.0" + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" }, "engines": { - "node": ">=8" + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.55.1", + "@rollup/rollup-android-arm64": "4.55.1", + "@rollup/rollup-darwin-arm64": "4.55.1", + "@rollup/rollup-darwin-x64": "4.55.1", + "@rollup/rollup-freebsd-arm64": "4.55.1", + "@rollup/rollup-freebsd-x64": "4.55.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.55.1", + "@rollup/rollup-linux-arm-musleabihf": "4.55.1", + "@rollup/rollup-linux-arm64-gnu": "4.55.1", + "@rollup/rollup-linux-arm64-musl": "4.55.1", + "@rollup/rollup-linux-loong64-gnu": "4.55.1", + "@rollup/rollup-linux-loong64-musl": "4.55.1", + "@rollup/rollup-linux-ppc64-gnu": "4.55.1", + "@rollup/rollup-linux-ppc64-musl": "4.55.1", + "@rollup/rollup-linux-riscv64-gnu": "4.55.1", + "@rollup/rollup-linux-riscv64-musl": "4.55.1", + "@rollup/rollup-linux-s390x-gnu": "4.55.1", + "@rollup/rollup-linux-x64-gnu": "4.55.1", + "@rollup/rollup-linux-x64-musl": "4.55.1", + "@rollup/rollup-openbsd-x64": "4.55.1", + "@rollup/rollup-openharmony-arm64": "4.55.1", + "@rollup/rollup-win32-arm64-msvc": "4.55.1", + "@rollup/rollup-win32-ia32-msvc": "4.55.1", + "@rollup/rollup-win32-x64-gnu": "4.55.1", + "@rollup/rollup-win32-x64-msvc": "4.55.1", + "fsevents": "~2.3.2" } }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "license": "MIT", - "engines": { - "node": ">=0.10.0" + "dependencies": { + "queue-microtask": "^1.2.2" } }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", "dev": true, - "license": "MIT", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, "engines": { - "node": ">=8" + "node": ">=10" } }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "license": "MIT", "dependencies": { - "is-extglob": "^2.1.1" + "shebang-regex": "^3.0.0" }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "license": "MIT", "engines": { "node": ">=8" } }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, "license": "MIT", "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" } }, - "node_modules/isexe": { + "node_modules/siginfo": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", "dev": true, "license": "ISC" }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" } }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", "dev": true, "license": "MIT" }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", "dev": true, "license": "MIT" - }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "license": "MIT", - "dependencies": { - "json-buffer": "3.0.1" + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "node_modules/synckit": { + "version": "0.11.12", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.12.tgz", + "integrity": "sha512-Bh7QjT8/SuKUIfObSXNHNSK6WHo6J1tHCqJsuaFDP7gP0fkzSfTxI8y85JrppZ0h8l0maIgc2tfuZQ6/t3GtnQ==", "dev": true, "license": "MIT", "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" + "@pkgr/core": "^0.2.9" }, "engines": { - "node": ">= 0.8.0" + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/synckit" } }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", "dev": true, "license": "MIT", "dependencies": { - "p-locate": "^5.0.0" + "fdir": "^6.5.0", + "picomatch": "^4.0.3" }, "engines": { - "node": ">=10" + "node": ">=12.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/SuperchupuDev" } }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/loupe": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", - "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "node_modules/tinypool": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", "dev": true, "license": "MIT", - "dependencies": { - "get-func-name": "^2.0.1" + "engines": { + "node": "^18.0.0 || >=20.0.0" } }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "node_modules/tinyrainbow": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz", + "integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==", "dev": true, "license": "MIT", "engines": { - "node": ">= 8" + "node": ">=14.0.0" } }, - "node_modules/micromatch": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", - "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", "dev": true, "license": "MIT", - "dependencies": { - "braces": "^3.0.3", - "picomatch": "^2.3.1" - }, "engines": { - "node": ">=8.6" + "node": ">=14.0.0" } }, - "node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "brace-expansion": "^2.0.1" + "is-number": "^7.0.0" }, "engines": { - "node": ">=10" + "node": ">=8.0" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/ts-api-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", + "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" } }, - "node_modules/mocha": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", - "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "node_modules/tsdown": { + "version": "0.20.0-beta.3", + "resolved": "https://registry.npmjs.org/tsdown/-/tsdown-0.20.0-beta.3.tgz", + "integrity": "sha512-XcMb46jOmxrXCiUkw7qhI3f1BUTnU0kWmpBK6CzASDbjxCpB2k2hGpdwIGM4GanGhWuNaoCW4+GvyHoPgUNRaQ==", "dev": true, "license": "MIT", "dependencies": { - "ansi-colors": "^4.1.3", - "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", - "debug": "^4.3.5", - "diff": "^5.2.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^8.1.0", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", - "ms": "^2.1.3", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^6.5.1", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.9", - "yargs-unparser": "^2.0.0" + "ansis": "^4.2.0", + "cac": "^6.7.14", + "defu": "^6.1.4", + "empathic": "^2.0.0", + "hookable": "^6.0.1", + "import-without-cache": "^0.2.5", + "obug": "^2.1.1", + "picomatch": "^4.0.3", + "rolldown": "1.0.0-beta.60", + "rolldown-plugin-dts": "^0.21.1", + "semver": "^7.7.3", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tree-kill": "^1.2.2", + "unconfig-core": "^7.4.2", + "unrun": "^0.2.25" }, "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha.js" + "tsdown": "dist/run.mjs" }, "engines": { - "node": ">= 14.0.0" + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "@arethetypeswrong/core": "^0.18.1", + "@vitejs/devtools": "*", + "publint": "^0.3.0", + "typescript": "^5.0.0", + "unplugin-lightningcss": "^0.4.0", + "unplugin-unused": "^0.5.0" + }, + "peerDependenciesMeta": { + "@arethetypeswrong/core": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "publint": { + "optional": true + }, + "typescript": { + "optional": true + }, + "unplugin-lightningcss": { + "optional": true + }, + "unplugin-unused": { + "optional": true + } } }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "node_modules/tsdown/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "node_modules/tsdown/node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", "dev": true, "license": "MIT", "engines": { - "node": ">=0.10.0" + "node": ">=18" } }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "dev": true, - "license": "ISC", - "dependencies": { - "wrappy": "1" - } + "license": "0BSD", + "optional": true }, - "node_modules/optionator": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", - "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "license": "MIT", "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.5" + "prelude-ls": "^1.2.1" }, "engines": { "node": ">= 0.8.0" } }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, - "license": "MIT", - "dependencies": { - "yocto-queue": "^0.1.0" + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=14.17" } }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "node_modules/typescript-eslint": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.34.0.tgz", + "integrity": "sha512-MRpfN7uYjTrTGigFCt8sRyNqJFhjN0WwZecldaqhWm+wy0gaRt8Edb/3cuUy0zdq2opJWT6iXINKAtewnDOltQ==", "dev": true, "license": "MIT", "dependencies": { - "p-limit": "^3.0.2" + "@typescript-eslint/eslint-plugin": "8.34.0", + "@typescript-eslint/parser": "8.34.0", + "@typescript-eslint/utils": "8.34.0" }, "engines": { - "node": ">=10" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" } }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "node_modules/unconfig-core": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/unconfig-core/-/unconfig-core-7.4.2.tgz", + "integrity": "sha512-VgPCvLWugINbXvMQDf8Jh0mlbvNjNC6eSUziHsBCMpxR05OPrNrvDnyatdMjRgcHaaNsCqz+wjNXxNw1kRLHUg==", "dev": true, "license": "MIT", "dependencies": { - "callsites": "^3.0.0" + "@quansync/fs": "^1.0.0", + "quansync": "^1.0.0" }, - "engines": { - "node": ">=6" - } - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" + "funding": { + "url": "https://github.com/sponsors/antfu" } }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "node_modules/unrun": { + "version": "0.2.25", + "resolved": "https://registry.npmjs.org/unrun/-/unrun-0.2.25.tgz", + "integrity": "sha512-ZOr5uQL+JlcUT8hZsQbtuUgb1zzcFx3juhXyLSsciaWa3DW1ldMY9r4KSF3+k/LR1Evj2ggAZo1usK4/knBjMQ==", "dev": true, "license": "MIT", + "dependencies": { + "rolldown": "1.0.0-beta.60" + }, + "bin": { + "unrun": "dist/cli.mjs" + }, "engines": { - "node": ">=8" + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/Gugustinette" + }, + "peerDependencies": { + "synckit": "^0.11.11" + }, + "peerDependenciesMeta": { + "synckit": { + "optional": true + } } }, - "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, - "license": "MIT", - "engines": { - "node": "*" + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" } }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "node_modules/vite": { + "version": "5.4.21", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", + "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", "dev": true, "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, "engines": { - "node": ">=8.6" + "node": "^18.0.0 || >=20.0.0" }, "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.8.0" + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } } }, - "node_modules/prettier": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", - "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "node_modules/vite-node": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-2.1.9.tgz", + "integrity": "sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==", "dev": true, "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.7", + "es-module-lexer": "^1.5.4", + "pathe": "^1.1.2", + "vite": "^5.0.0" + }, "bin": { - "prettier": "bin/prettier.cjs" + "vite-node": "vite-node.mjs" }, "engines": { - "node": ">=14" + "node": "^18.0.0 || >=20.0.0" }, "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" + "url": "https://opencollective.com/vitest" } }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "node_modules/vite/node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], "dev": true, "license": "MIT", - "dependencies": { - "fast-diff": "^1.1.2" - }, + "optional": true, + "os": [ + "aix" + ], "engines": { - "node": ">=6.0.0" + "node": ">=12" } }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "node_modules/vite/node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "android" + ], "engines": { - "node": ">=6" + "node": ">=12" } }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "node_modules/vite/node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } + "license": "MIT", + "optional": true, + "os": [ + "android" ], - "license": "MIT" + "engines": { + "node": ">=12" + } }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "node_modules/vite/node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", - "dependencies": { - "safe-buffer": "^5.1.0" + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" } }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "node_modules/vite/node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], "dev": true, "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": ">=8.10.0" + "node": ">=12" } }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "node_modules/vite/node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], "engines": { - "node": ">=0.10.0" + "node": ">=12" } }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "node_modules/vite/node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], "engines": { - "node": ">=4" + "node": ">=12" } }, - "node_modules/reusify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", - "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "node_modules/vite/node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" + "node": ">=12" } }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } + "node_modules/vite/node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" ], + "dev": true, "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "node_modules/vite/node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } + "license": "MIT", + "optional": true, + "os": [ + "linux" ], - "license": "MIT" + "engines": { + "node": ">=12" + } }, - "node_modules/semver": { - "version": "7.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", - "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "node_modules/vite/node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=10" + "node": ">=12" } }, - "node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "node_modules/vite/node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "randombytes": "^2.1.0" + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" } }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "node_modules/vite/node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], "dev": true, "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=8" + "node": ">=12" } }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "node_modules/vite/node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=8" + "node": ">=12" } }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "node_modules/vite/node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], "dev": true, "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=8" + "node": ">=12" } }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "node_modules/vite/node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], "dev": true, "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=8" + "node": ">=12" } }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "node_modules/vite/node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "linux" + ], "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=12" } }, - "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "node_modules/vite/node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, + "optional": true, + "os": [ + "netbsd" + ], "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "node": ">=12" } }, - "node_modules/synckit": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.8.tgz", - "integrity": "sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A==", + "node_modules/vite/node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", - "dependencies": { - "@pkgr/core": "^0.2.4" - }, + "optional": true, + "os": [ + "openbsd" + ], "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/synckit" + "node": ">=12" } }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "node_modules/vite/node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, + "optional": true, + "os": [ + "sunos" + ], "engines": { - "node": ">=8.0" + "node": ">=12" } }, - "node_modules/ts-api-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz", - "integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==", + "node_modules/vite/node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">=18.12" - }, - "peerDependencies": { - "typescript": ">=4.8.4" + "node": ">=12" } }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "node_modules/vite/node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], "dev": true, "license": "MIT", - "dependencies": { - "prelude-ls": "^1.2.1" - }, + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">= 0.8.0" + "node": ">=12" } }, - "node_modules/type-detect": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", - "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", + "node_modules/vite/node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], "dev": true, "license": "MIT", + "optional": true, + "os": [ + "win32" + ], "engines": { - "node": ">=4" + "node": ">=12" } }, - "node_modules/typescript": { - "version": "5.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", - "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "node_modules/vite/node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", "dev": true, - "license": "Apache-2.0", - "peer": true, + "hasInstallScript": true, + "license": "MIT", "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" + "esbuild": "bin/esbuild" }, "engines": { - "node": ">=14.17" - } - }, - "node_modules/typescript-eslint": { - "version": "8.34.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.34.0.tgz", - "integrity": "sha512-MRpfN7uYjTrTGigFCt8sRyNqJFhjN0WwZecldaqhWm+wy0gaRt8Edb/3cuUy0zdq2opJWT6iXINKAtewnDOltQ==", + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/vitest": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-2.1.9.tgz", + "integrity": "sha512-MSmPM9REYqDGBI8439mA4mWhV5sKmDlBKWIYbA3lRb2PTHACE0mgKwA8yQ2xq9vxDTuk4iPrECBAEW2aoFXY0Q==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.34.0", - "@typescript-eslint/parser": "8.34.0", - "@typescript-eslint/utils": "8.34.0" + "@vitest/expect": "2.1.9", + "@vitest/mocker": "2.1.9", + "@vitest/pretty-format": "^2.1.9", + "@vitest/runner": "2.1.9", + "@vitest/snapshot": "2.1.9", + "@vitest/spy": "2.1.9", + "@vitest/utils": "2.1.9", + "chai": "^5.1.2", + "debug": "^4.3.7", + "expect-type": "^1.1.0", + "magic-string": "^0.30.12", + "pathe": "^1.1.2", + "std-env": "^3.8.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.1", + "tinypool": "^1.0.1", + "tinyrainbow": "^1.2.0", + "vite": "^5.0.0", + "vite-node": "2.1.9", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" }, "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + "node": "^18.0.0 || >=20.0.0" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0", - "typescript": ">=4.8.4 <5.9.0" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "punycode": "^2.1.0" + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "2.1.9", + "@vitest/ui": "2.1.9", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } } }, "node_modules/which": { @@ -2849,101 +4497,31 @@ "node": ">= 8" } }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", - "dev": true, - "license": "Apache-2.0" - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", "dev": true, "license": "MIT", "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" + "siginfo": "^2.0.0", + "stackback": "0.0.2" }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" + "bin": { + "why-is-node-running": "cli.js" }, "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" + "node": ">=8" } }, - "node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "license": "MIT", - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, "engines": { - "node": ">=10" + "node": ">=0.10.0" } }, "node_modules/yocto-queue": { diff --git a/package.json b/package.json index 126ef9f..6312b62 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,17 @@ "name": "lambda-mcp-adaptor", "version": "1.0.0", "description": "An MCP (Model Context Protocol) server SDK for AWS serverless architecture with official SDK-like API design", - "main": "dist/index.js", + "main": "dist/index.cjs", "module": "dist/index.mjs", - "types": "dist/index.d.ts", + "types": "dist/index.d.mts", "exports": { ".": { "import": "./dist/index.mjs", - "require": "./dist/index.js", - "types": "./dist/index.d.ts" + "require": "./dist/index.cjs", + "types": { + "import": "./dist/index.d.mts", + "require": "./dist/index.d.cts" + } } }, "files": [ @@ -18,11 +21,12 @@ "LICENSE" ], "scripts": { - "build": "npm run build:esm && npm run build:cjs && npm run build:types", - "build:esm": "esbuild src/index.mjs --bundle --platform=node --target=node18 --format=esm --outfile=dist/index.mjs --external:zod", - "build:cjs": "esbuild src/index.mjs --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.js --external:zod", - "build:types": "cp src/index.d.ts dist/index.d.ts", - "test": "mocha tests/**/*.test.mjs", + "build": "tsdown && npm run typecheck:tests", + "build:esm": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/index.mjs --external:zod", + "build:cjs": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.js --external:zod", + "build:types": "tsc -p tsconfig.json && cp src/mcp-spec.d.ts dist/mcp-spec.d.ts", + "typecheck:tests": "tsc -p tsconfig.tests.json --noEmit", + "test": "vitest run", "prepublishOnly": "npm run build", "dev": "node examples/basic-server.mjs", "lint": "eslint src/**/*.{js,ts,mjs} --fix", @@ -57,17 +61,20 @@ }, "devDependencies": { "@eslint/js": "^9.29.0", + "@types/aws-lambda": "^8.10.137", "@typescript-eslint/eslint-plugin": "^8.34.0", "@typescript-eslint/parser": "^8.34.0", - "chai": "^4.3.6", "esbuild": "^0.19.0", "eslint": "^9.29.0", "eslint-config-prettier": "^10.1.5", "eslint-plugin-prettier": "^5.4.1", "globals": "^16.2.0", - "mocha": "^10.2.0", + "json-schema": "^0.4.0", "prettier": "^3.5.3", + "tsdown": "^0.20.0-beta.3", + "typescript": "^5.6.3", "typescript-eslint": "^8.34.0", + "vitest": "^2.1.8", "zod": "^3.22.4" }, "engines": { diff --git a/src/auth/bearer-token.mjs b/src/auth/bearer-token.ts similarity index 83% rename from src/auth/bearer-token.mjs rename to src/auth/bearer-token.ts index ca5bc4b..4c9e7fa 100644 --- a/src/auth/bearer-token.mjs +++ b/src/auth/bearer-token.ts @@ -4,7 +4,13 @@ * Provides Bearer token validation functionality for MCP servers */ -import { withCORS } from '../cors-config.mjs'; +import { withCORS } from '../cors-config'; +import type { + AuthValidationResult, + BearerTokenAuthConfig, + LambdaEvent, +} from './index'; +import type { APIGatewayProxyResult } from 'aws-lambda'; /** * Creates an authentication error response @@ -15,11 +21,11 @@ import { withCORS } from '../cors-config.mjs'; * @returns {Object} Lambda response object */ function createAuthErrorResponse( - statusCode, - error, - message, - additionalHeaders = {} -) { + statusCode: number, + error: string, + message: string, + additionalHeaders: Record = {} +): APIGatewayProxyResult { const headers = withCORS({ 'Content-Type': 'application/json', ...additionalHeaders, @@ -41,7 +47,10 @@ function createAuthErrorResponse( * @param {Object} config - Authentication configuration * @returns {Object} Validation result with isValid flag and error/user data */ -export function validateBearerToken(event, config = {}) { +export async function validateBearerToken( + event: LambdaEvent, + config: BearerTokenAuthConfig = { type: 'bearer-token' } +): Promise { const authHeader = event.headers?.authorization || event.headers?.Authorization; @@ -76,7 +85,7 @@ export function validateBearerToken(event, config = {}) { // Handle custom validation function if (config.validate && typeof config.validate === 'function') { try { - const result = config.validate(token, event); + const result = await config.validate(token, event); if (result && result.isValid) { return { isValid: true, @@ -148,7 +157,9 @@ export function validateBearerToken(event, config = {}) { * @param {string} envVar - Environment variable name containing comma-separated tokens * @returns {Object} Authentication configuration */ -export function createBearerTokenConfigFromEnv(envVar = 'VALID_TOKENS') { +export function createBearerTokenConfigFromEnv( + envVar: string = 'VALID_TOKENS' +): BearerTokenAuthConfig { const tokens = (process.env[envVar] || '').split(',').filter((t) => t.trim()); return { @@ -162,7 +173,9 @@ export function createBearerTokenConfigFromEnv(envVar = 'VALID_TOKENS') { * @param {Function} validateFn - Custom validation function * @returns {Object} Authentication configuration */ -export function createBearerTokenConfigWithValidation(validateFn) { +export function createBearerTokenConfigWithValidation( + validateFn: BearerTokenAuthConfig['validate'] +): BearerTokenAuthConfig { return { type: 'bearer-token', validate: validateFn, diff --git a/src/auth/index.mjs b/src/auth/index.ts similarity index 56% rename from src/auth/index.mjs rename to src/auth/index.ts index 4679c90..a3cb79f 100644 --- a/src/auth/index.mjs +++ b/src/auth/index.ts @@ -4,16 +4,47 @@ * Provides authentication functionality for MCP servers */ +import type { + APIGatewayProxyEvent, + APIGatewayProxyEventV2, + APIGatewayProxyResult, +} from 'aws-lambda'; + +export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2; + +export interface AuthUser { + token?: string; + [key: string]: unknown; +} + +export interface AuthValidationResult { + isValid: boolean; + user?: AuthUser; + token?: string; + error?: APIGatewayProxyResult; +} + +export interface BearerTokenAuthConfig { + type: 'bearer-token'; + tokens?: string[]; + validate?: ( + token: string, + event: LambdaEvent + ) => AuthValidationResult | Promise; +} + +export type AuthConfig = BearerTokenAuthConfig; + export { validateBearerToken, createBearerTokenConfigFromEnv, createBearerTokenConfigWithValidation, -} from './bearer-token.mjs'; +} from './bearer-token'; export { createAuthMiddleware, createAuthenticatedHandler, -} from './middleware.mjs'; +} from './middleware'; /** * Authentication configuration presets @@ -24,7 +55,7 @@ export const AuthPresets = { * @param {string} envVar - Environment variable name (default: 'VALID_TOKENS') * @returns {Object} Authentication configuration */ - bearerTokenFromEnv: (envVar = 'VALID_TOKENS') => ({ + bearerTokenFromEnv: (envVar = 'VALID_TOKENS'): BearerTokenAuthConfig => ({ type: 'bearer-token', tokens: (process.env[envVar] || '').split(',').filter((t) => t.trim()), }), @@ -34,7 +65,7 @@ export const AuthPresets = { * @param {string[]} tokens - Array of valid tokens * @returns {Object} Authentication configuration */ - bearerTokenWithList: (tokens) => ({ + bearerTokenWithList: (tokens: string | string[]): BearerTokenAuthConfig => ({ type: 'bearer-token', tokens: Array.isArray(tokens) ? tokens : [tokens], }), @@ -44,7 +75,9 @@ export const AuthPresets = { * @param {Function} validateFn - Custom validation function * @returns {Object} Authentication configuration */ - bearerTokenWithValidation: (validateFn) => ({ + bearerTokenWithValidation: ( + validateFn: BearerTokenAuthConfig['validate'] + ): BearerTokenAuthConfig => ({ type: 'bearer-token', validate: validateFn, }), @@ -63,18 +96,21 @@ export const Auth = { * Bearer token authentication from environment variable * @param {string} envVar - Environment variable name */ - bearerToken: (envVar = 'VALID_TOKENS') => + bearerToken: (envVar = 'VALID_TOKENS'): BearerTokenAuthConfig => AuthPresets.bearerTokenFromEnv(envVar), /** * Bearer token authentication with token list * @param {string|string[]} tokens - Token or array of tokens */ - bearerTokens: (tokens) => AuthPresets.bearerTokenWithList(tokens), + bearerTokens: (tokens: string | string[]): BearerTokenAuthConfig => + AuthPresets.bearerTokenWithList(tokens), /** * Custom bearer token validation * @param {Function} validateFn - Validation function */ - custom: (validateFn) => AuthPresets.bearerTokenWithValidation(validateFn), + custom: ( + validateFn: BearerTokenAuthConfig['validate'] + ): BearerTokenAuthConfig => AuthPresets.bearerTokenWithValidation(validateFn), }; diff --git a/src/auth/middleware.mjs b/src/auth/middleware.ts similarity index 61% rename from src/auth/middleware.mjs rename to src/auth/middleware.ts index 083fa16..cf04ba3 100644 --- a/src/auth/middleware.mjs +++ b/src/auth/middleware.ts @@ -4,16 +4,25 @@ * Provides authentication middleware for MCP Lambda handlers */ -import { validateBearerToken } from './bearer-token.mjs'; -import { CORS_HEADERS, withBasicCORS } from '../cors-config.mjs'; +import { validateBearerToken } from './bearer-token'; +import { CORS_HEADERS, withBasicCORS } from '../cors-config'; +import type { + AuthConfig, + AuthValidationResult, + LambdaEvent, +} from './index'; +import type { APIGatewayProxyResult, Context } from 'aws-lambda'; /** * Handles CORS preflight requests * @param {Object} event - Lambda event object * @returns {Object|null} CORS response or null if not a preflight request */ -function handleCORSPreflight(event) { - const method = event.requestContext?.http?.method || event.httpMethod; +function handleCORSPreflight( + event: LambdaEvent +): APIGatewayProxyResult | null { + const method = + 'httpMethod' in event ? event.httpMethod : event.requestContext?.http?.method; if (method === 'OPTIONS') { return { @@ -31,8 +40,8 @@ function handleCORSPreflight(event) { * @param {Object} authConfig - Authentication configuration * @returns {Function} Middleware function */ -export function createAuthMiddleware(authConfig) { - return async (event) => { +export function createAuthMiddleware(authConfig: AuthConfig) { + return async (event: LambdaEvent): Promise => { // Handle CORS preflight requests const corsResponse = handleCORSPreflight(event); if (corsResponse) { @@ -40,11 +49,11 @@ export function createAuthMiddleware(authConfig) { } // Perform authentication based on type - let authResult; + let authResult: AuthValidationResult; switch (authConfig.type) { case 'bearer-token': - authResult = validateBearerToken(event, authConfig); + authResult = await validateBearerToken(event, authConfig); break; default: @@ -61,13 +70,22 @@ export function createAuthMiddleware(authConfig) { // Handle authentication failure if (!authResult.isValid) { - console.log('Authentication failed:', authResult.error.body); - return authResult.error; + console.log('Authentication failed:', authResult.error?.body); + const fallbackError: APIGatewayProxyResult = { + statusCode: 401, + headers: withBasicCORS({ 'Content-Type': 'application/json' }), + body: JSON.stringify({ + error: 'unauthorized', + message: 'Authentication failed', + }), + }; + return authResult.error ?? fallbackError; } // Authentication successful - add user context to event - event.user = authResult.user; - event.authToken = authResult.token; + (event as LambdaEvent & { user?: AuthValidationResult['user'] }).user = + authResult.user; + (event as LambdaEvent & { authToken?: string }).authToken = authResult.token; console.log('Authentication successful'); return null; // Continue to next middleware/handler @@ -80,10 +98,16 @@ export function createAuthMiddleware(authConfig) { * @param {Object} authConfig - Authentication configuration * @returns {Function} Wrapped handler with authentication */ -export function createAuthenticatedHandler(originalHandler, authConfig) { +export function createAuthenticatedHandler( + originalHandler: ( + event: LambdaEvent, + context: Context + ) => Promise, + authConfig: AuthConfig +): (event: LambdaEvent, context: Context) => Promise { const authMiddleware = createAuthMiddleware(authConfig); - return async (event) => { + return async (event: LambdaEvent, context: Context) => { console.log('=== MCP Server Request Start (with Authentication) ==='); console.log('Event:', JSON.stringify(event, null, 2)); @@ -97,7 +121,7 @@ export function createAuthenticatedHandler(originalHandler, authConfig) { } // Authentication successful, proceed with original handler - const response = await originalHandler(event); + const response = await originalHandler(event, context); console.log('=== MCP Server Request End ==='); return response; diff --git a/src/common-schemas.mjs b/src/common-schemas.ts similarity index 71% rename from src/common-schemas.mjs rename to src/common-schemas.ts index d95393a..ea5b31f 100644 --- a/src/common-schemas.mjs +++ b/src/common-schemas.ts @@ -26,7 +26,7 @@ export const CommonSchemas = { uuid: z.string().uuid(), // Utility functions - enum: (values) => z.enum(values), - array: (itemSchema) => z.array(itemSchema), - object: (shape) => z.object(shape), + enum: (values: T) => z.enum(values), + array: (itemSchema: T) => z.array(itemSchema), + object: (shape: T) => z.object(shape), }; diff --git a/src/cors-config.mjs b/src/cors-config.ts similarity index 71% rename from src/cors-config.mjs rename to src/cors-config.ts index c7caccf..70139cb 100644 --- a/src/cors-config.mjs +++ b/src/cors-config.ts @@ -8,7 +8,7 @@ * Standard CORS headers for MCP server responses * Includes all necessary headers for MCP protocol and authentication */ -export const CORS_HEADERS = { +export const CORS_HEADERS: Record = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization, Mcp-Protocol-Version, Mcp-Session-Id', @@ -18,14 +18,14 @@ export const CORS_HEADERS = { /** * Basic CORS headers for simple responses */ -export const BASIC_CORS_HEADERS = { +export const BASIC_CORS_HEADERS: Record = { 'Access-Control-Allow-Origin': '*', }; /** * Create response headers with CORS */ -export function withCORS(additionalHeaders = {}) { +export function withCORS(additionalHeaders: Record = {}): Record { return { ...CORS_HEADERS, ...additionalHeaders, @@ -35,7 +35,9 @@ export function withCORS(additionalHeaders = {}) { /** * Create basic response headers with CORS */ -export function withBasicCORS(additionalHeaders = {}) { +export function withBasicCORS( + additionalHeaders: Record = {} +): Record { return { ...BASIC_CORS_HEADERS, ...additionalHeaders, diff --git a/src/index.d.ts b/src/index.d.ts deleted file mode 100644 index 295980c..0000000 --- a/src/index.d.ts +++ /dev/null @@ -1,160 +0,0 @@ -/** - * TypeScript definitions for @aws-lambda-mcp/adapter - */ - -import { z } from 'zod'; -import { - APIGatewayProxyEvent, - APIGatewayProxyResult, - Context, -} from 'aws-lambda'; - -// Core Types -export interface MCPServerConfig { - name: string; - version: string; - description?: string; - protocolVersion?: string; -} - -// JSON-RPC Types -export interface JsonRpcRequest { - jsonrpc: string; - method: string; - params?: Record; - id?: string | number | null; -} - -export interface JsonRpcResponse { - jsonrpc: string; - result?: unknown; - error?: { - code: number; - message: string; - data?: unknown; - }; - id?: string | number | null; -} - -export interface MCPToolResult { - content: Array<{ - type: 'text' | 'image' | 'resource'; - text?: string; - data?: string; - mimeType?: string; - }>; - isError?: boolean; -} - -export interface MCPResourceResult { - contents: Array<{ - uri: string; - text?: string; - blob?: string; - mimeType?: string; - }>; -} - -export interface MCPPromptResult { - messages: Array<{ - role: 'user' | 'assistant' | 'system'; - content: { - type: 'text' | 'image'; - text?: string; - data?: string; - mimeType?: string; - }; - }>; -} - -// Authentication Types -export interface AuthUser { - token?: string; - [key: string]: unknown; -} - -export interface AuthValidationResult { - isValid: boolean; - user?: AuthUser; - token?: string; - error?: APIGatewayProxyResult; -} - -export interface BearerTokenAuthConfig { - type: 'bearer-token'; - tokens?: string[]; - validate?: ( - token: string, - event: APIGatewayProxyEvent - ) => AuthValidationResult | Promise; -} - -export type AuthConfig = BearerTokenAuthConfig; - -export interface LambdaHandlerOptions { - auth?: AuthConfig; -} - -// Schema Types -export type ZodSchema = Record; -export type ToolHandler> = ( - args: T -) => Promise; -export type ResourceHandler = (uri: string) => Promise; -export type PromptHandler> = ( - args: T -) => Promise; - -// Core Classes -export declare class MCPServer { - constructor(config: MCPServerConfig); - - tool( - name: string, - inputSchema: T, - handler: ToolHandler>> - ): MCPServer; - - resource(name: string, uri: string, handler: ResourceHandler): MCPServer; - - prompt( - name: string, - inputSchema: T, - handler: PromptHandler>> - ): MCPServer; - - handleRequest(request: JsonRpcRequest): Promise; - getStats(): { - tools: number; - resources: number; - prompts: number; - config: MCPServerConfig; - }; -} - -// Main Functions -export declare function createMCPServer(config: MCPServerConfig): MCPServer; - -export declare function createLambdaHandler( - mcpServer: MCPServer, - options?: LambdaHandlerOptions -): ( - event: APIGatewayProxyEvent, - context: Context -) => Promise; - -// Common Schemas -export declare const CommonSchemas: { - string: z.ZodString; - number: z.ZodNumber; - boolean: z.ZodBoolean; - optionalString: z.ZodOptional; - optionalNumber: z.ZodOptional; - optionalBoolean: z.ZodOptional; - email: z.ZodString; - url: z.ZodString; - uuid: z.ZodString; - enum: (values: T) => z.ZodEnum; - array: (itemSchema: T) => z.ZodArray; - object: (shape: T) => z.ZodObject; -}; diff --git a/src/index.mjs b/src/index.ts similarity index 50% rename from src/index.mjs rename to src/index.ts index 982512e..e01d7d8 100644 --- a/src/index.mjs +++ b/src/index.ts @@ -6,14 +6,14 @@ */ // Core imports -import { MCPServer } from './mcp-server.mjs'; +import { MCPServer } from './mcp-server'; // Core exports -export { MCPServer } from './mcp-server.mjs'; -export { createLambdaHandler } from './lambda-adapter.mjs'; -export { CommonSchemas } from './common-schemas.mjs'; +export { MCPServer } from './mcp-server'; +export { createLambdaHandler } from './lambda-adapter'; +export { CommonSchemas } from './common-schemas'; // Convenience function -export function createMCPServer(config) { +export function createMCPServer(config: ConstructorParameters[0]) { return new MCPServer(config); } diff --git a/src/lambda-adapter.mjs b/src/lambda-adapter.ts similarity index 61% rename from src/lambda-adapter.mjs rename to src/lambda-adapter.ts index b24b873..4a2a773 100644 --- a/src/lambda-adapter.mjs +++ b/src/lambda-adapter.ts @@ -4,12 +4,38 @@ * Handles Lambda integration and HTTP request/response processing */ -import { CORS_HEADERS, withBasicCORS } from './cors-config.mjs'; +import type { + JSONRPCNotification, + JSONRPCRequest, +} from './mcp-spec'; +import type { + APIGatewayProxyEvent, + APIGatewayProxyEventV2, + APIGatewayProxyResult, + Context, +} from 'aws-lambda'; +import type { AuthConfig } from './auth'; +import { CORS_HEADERS, withBasicCORS } from './cors-config'; +import type { MCPServer } from './mcp-server'; + +type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2; +type LambdaHandler = ( + event: LambdaEvent, + context: Context +) => Promise; + +export interface LambdaHandlerOptions { + auth?: AuthConfig; +} /** * Create HTTP response */ -export function createResponse(body, statusCode = 200, headers = {}) { +export function createResponse( + body: unknown, + statusCode: number = 200, + headers: Record = {} +): APIGatewayProxyResult { return { statusCode, headers: { @@ -24,12 +50,12 @@ export function createResponse(body, statusCode = 200, headers = {}) { * Create error response */ export function createErrorResponse( - statusCode, - code, - message, - headers = {}, - id = null -) { + statusCode: number, + code: number, + message: string, + headers: Record = {}, + id: string | number | null = null +): APIGatewayProxyResult { return createResponse( { jsonrpc: '2.0', @@ -44,7 +70,12 @@ export function createErrorResponse( /** * Handle MCP request processing */ -export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { +export async function handleMCPRequest( + mcpServer: MCPServer, + body: string | null | undefined, + headers: Record, + corsHeaders: Record +): Promise { const contentType = headers['content-type'] || headers['Content-Type'] || ''; if (!contentType.includes('application/json')) { return createErrorResponse( @@ -55,9 +86,9 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { ); } - let jsonRpcMessage; + let jsonRpcMessage: JSONRPCRequest | JSONRPCNotification; try { - jsonRpcMessage = JSON.parse(body || '{}'); + jsonRpcMessage = JSON.parse(body || '{}') as JSONRPCRequest | JSONRPCNotification; } catch { return createErrorResponse( 400, @@ -67,13 +98,15 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { ); } + const responseId = 'id' in jsonRpcMessage ? jsonRpcMessage.id : null; + if (!jsonRpcMessage.jsonrpc || jsonRpcMessage.jsonrpc !== '2.0') { return createErrorResponse( 400, -32600, 'Invalid Request: missing jsonrpc field', corsHeaders, - jsonRpcMessage.id + responseId ); } @@ -83,12 +116,16 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { -32600, 'Invalid Request: missing method field', corsHeaders, - jsonRpcMessage.id + responseId ); } try { - const result = await mcpServer.handleRequest(jsonRpcMessage); + const result = await ( + mcpServer.handleRequest as ( + request: JSONRPCRequest | JSONRPCNotification + ) => Promise + )(jsonRpcMessage); if (result === null) { return createResponse('', 204, corsHeaders); @@ -98,7 +135,7 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { { jsonrpc: '2.0', result, - id: jsonRpcMessage.id, + id: responseId, }, 200, corsHeaders @@ -107,14 +144,11 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { console.error('MCP request error:', error); let errorCode = -32603; // Internal error - let errorMessage = error.message; + const errorMessage = error instanceof Error ? error.message : String(error); - if (error.message.includes('Method not found')) { + if (errorMessage.includes('Method not found')) { errorCode = -32601; - } else if ( - error.message.includes('not found') || - error.message.includes('required') - ) { + } else if (errorMessage.includes('not found') || errorMessage.includes('required')) { errorCode = -32602; // Invalid params } @@ -123,7 +157,7 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { errorCode, errorMessage, corsHeaders, - jsonRpcMessage.id + responseId ); } } @@ -131,10 +165,14 @@ export async function handleMCPRequest(mcpServer, body, headers, corsHeaders) { /** * AWS Lambda Adapter for MCP Server */ -export function createLambdaHandler(mcpServer, options = {}) { - const baseHandler = async (event) => { +export function createLambdaHandler( + mcpServer: MCPServer, + options: LambdaHandlerOptions = {} +): LambdaHandler { + const baseHandler: LambdaHandler = async (event) => { try { - const method = event.httpMethod || event.requestContext?.http?.method; + const method = + 'httpMethod' in event ? event.httpMethod : event.requestContext?.http?.method; const headers = event.headers || {}; if (method === 'OPTIONS') { @@ -178,14 +216,15 @@ export function createLambdaHandler(mcpServer, options = {}) { // If authentication is configured, wrap with authentication middleware if (options.auth) { - return async (event, context) => { + const authConfig = options.auth; + return async (event: LambdaEvent, context: Context) => { try { const { createAuthenticatedHandler } = await import( - './auth/middleware.mjs' + './auth/middleware' ); const authenticatedHandler = createAuthenticatedHandler( baseHandler, - options.auth + authConfig ); return await authenticatedHandler(event, context); } catch (error) { diff --git a/src/mcp-server.mjs b/src/mcp-server.mjs deleted file mode 100644 index e68375c..0000000 --- a/src/mcp-server.mjs +++ /dev/null @@ -1,272 +0,0 @@ -/** - * MCP Server Core Implementation - * - * Handles MCP protocol logic and tool/resource/prompt management - */ - -import { - zodToJsonSchema, - validateWithZod, - isZodOptional, -} from './schema-utils.mjs'; - -/** - * Main MCP Server class with Zod-based type safety - */ -export class MCPServer { - constructor(config) { - this.config = { - name: config.name || 'MCP Server', - version: config.version || '1.0.0', - description: config.description || 'MCP Server powered by AWS Lambda', - protocolVersion: config.protocolVersion || '2025-03-26', - ...config, - }; - - this.tools = new Map(); - this.resources = new Map(); - this.prompts = new Map(); - } - - /** - * Register a tool with Zod schema validation - */ - tool(name, inputSchema, handler) { - const jsonSchema = zodToJsonSchema(inputSchema); - - const validatedHandler = async (args) => { - try { - const validatedArgs = validateWithZod(inputSchema, args); - return await handler(validatedArgs); - } catch (error) { - if (error.name === 'ZodError') { - throw new Error( - `Validation error: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}` - ); - } - throw error; - } - }; - - this.tools.set(name, { - name, - description: handler.description || `Tool: ${name}`, - inputSchema: jsonSchema, - handler: validatedHandler, - }); - - return this; - } - - /** - * Register a resource - */ - resource(name, uri, handler) { - this.resources.set(name, { - name, - uri, - description: handler.description || `Resource: ${name}`, - handler, - }); - - return this; - } - - /** - * Register a prompt with Zod schema validation - */ - prompt(name, inputSchema, handler) { - zodToJsonSchema(inputSchema); - - const validatedHandler = async (args) => { - try { - const validatedArgs = validateWithZod(inputSchema, args); - return await handler(validatedArgs); - } catch (error) { - if (error.name === 'ZodError') { - throw new Error( - `Validation error: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}` - ); - } - throw error; - } - }; - - this.prompts.set(name, { - name, - description: handler.description || `Prompt: ${name}`, - arguments: Object.entries(inputSchema).map(([key, schema]) => ({ - name: key, - description: schema.description || `${key} parameter`, - required: !isZodOptional(schema), - })), - handler: validatedHandler, - }); - - return this; - } - - /** - * Handle MCP protocol requests - */ - async handleRequest(request) { - switch (request.method) { - case 'initialize': - return this.handleInitialize(request.params || {}); - case 'notifications/initialized': - return null; - case 'tools/list': - return this.handleToolsList(request.params || {}); - case 'tools/call': - return this.handleToolsCall(request.params); - case 'resources/list': - return this.handleResourcesList(request.params || {}); - case 'resources/read': - return this.handleResourcesRead(request.params); - case 'prompts/list': - return this.handlePromptsList(request.params || {}); - case 'prompts/get': - return this.handlePromptsGet(request.params); - default: - throw new Error(`Method not found: ${request.method}`); - } - } - - /** - * Handle initialize request - */ - async handleInitialize() { - return { - protocolVersion: this.config.protocolVersion, - capabilities: { - tools: { listChanged: true }, - resources: { listChanged: true }, - prompts: { listChanged: true }, - }, - serverInfo: { - name: this.config.name, - version: this.config.version, - }, - instructions: this.config.description, - }; - } - - /** - * Handle tools/list request - */ - async handleToolsList() { - const tools = Array.from(this.tools.values()).map((tool) => ({ - name: tool.name, - description: tool.description, - inputSchema: tool.inputSchema, - })); - - return { tools }; - } - - /** - * Handle tools/call request - */ - async handleToolsCall(params) { - if (!params?.name) { - throw new Error('Tool name is required'); - } - - const tool = this.tools.get(params.name); - if (!tool) { - throw new Error(`Tool not found: ${params.name}`); - } - - try { - const result = await tool.handler(params.arguments || {}); - return result; - } catch (error) { - return { - content: [{ type: 'text', text: `Error: ${error.message}` }], - isError: true, - }; - } - } - - /** - * Handle resources/list request - */ - async handleResourcesList() { - const resources = Array.from(this.resources.values()).map((resource) => ({ - uri: resource.uri, - name: resource.name, - description: resource.description, - })); - - return { resources }; - } - - /** - * Handle resources/read request - */ - async handleResourcesRead(params) { - if (!params?.uri) { - throw new Error('Resource URI is required'); - } - - const resource = Array.from(this.resources.values()).find( - (r) => r.uri === params.uri - ); - if (!resource) { - throw new Error(`Resource not found: ${params.uri}`); - } - - try { - const result = await resource.handler(params.uri); - return result; - } catch (error) { - throw new Error(`Resource read error: ${error.message}`); - } - } - - /** - * Handle prompts/list request - */ - async handlePromptsList() { - const prompts = Array.from(this.prompts.values()).map((prompt) => ({ - name: prompt.name, - description: prompt.description, - arguments: prompt.arguments, - })); - - return { prompts }; - } - - /** - * Handle prompts/get request - */ - async handlePromptsGet(params) { - if (!params?.name) { - throw new Error('Prompt name is required'); - } - - const prompt = this.prompts.get(params.name); - if (!prompt) { - throw new Error(`Prompt not found: ${params.name}`); - } - - try { - const result = await prompt.handler(params.arguments || {}); - return result; - } catch (error) { - throw new Error(`Prompt execution error: ${error.message}`); - } - } - - /** - * Get server statistics - */ - getStats() { - return { - tools: this.tools.size, - resources: this.resources.size, - prompts: this.prompts.size, - config: this.config, - }; - } -} diff --git a/src/mcp-server.ts b/src/mcp-server.ts new file mode 100644 index 0000000..5e93204 --- /dev/null +++ b/src/mcp-server.ts @@ -0,0 +1,413 @@ +/** + * MCP Server Core Implementation + * + * Handles MCP protocol logic and tool/resource/prompt management + */ + +import { z } from 'zod'; +import type { + CallToolRequestParams, + CallToolResult, + GetPromptRequestParams, + GetPromptResult, + InitializeResult, + InitializeRequest, + InitializedNotification, + JSONRPCNotification, + JSONRPCRequest, + ListPromptsRequest, + ListPromptsResult, + ListResourcesRequest, + ListResourcesResult, + ListToolsRequest, + ListToolsResult, + PromptArgument, + ReadResourceRequest, + ReadResourceRequestParams, + ReadResourceResult, + Tool, + CallToolRequest, + GetPromptRequest, +} from './mcp-spec'; +import { + zodToJsonSchema, + validateWithZod, + isZodOptional, +} from './schema-utils'; +import { JSONSchema } from './types'; + +export interface MCPServerConfig { + name: string; + version: string; + description?: string; + protocolVersion?: string; +} + +type NormalizedMCPServerConfig = MCPServerConfig & { + description: string; + protocolVersion: string; +}; + +export type ZodSchema = z.ZodRawShape; +export type ToolHandler = ( + args: z.infer> +) => Promise | CallToolResult; +export type ResourceHandler = ( + uri: string +) => Promise | ReadResourceResult; +export type PromptHandler = ( + args: z.infer> +) => Promise | GetPromptResult; + +type ToolOptions = { + outputSchema: Tool['outputSchema']; + annotations: Tool['annotations']; +}; +type ToolRegistration = { + name: string; + description: string; + inputSchema: Tool['inputSchema']; + handler: (args: Record) => Promise; + options?: ToolOptions; +}; + +type ResourceRegistration = { + name: string; + uri: string; + description: string; + handler: (uri: string) => Promise; +}; + +type PromptRegistration = { + name: string; + description: string; + arguments: PromptArgument[]; + handler: (args: Record) => Promise; +}; + +type HandleRequestMethodMap = { + initialize: InitializeResult; + 'notifications/initialized': null; + 'tools/list': ListToolsResult; + 'tools/call': CallToolResult; + 'resources/list': ListResourcesResult; + 'resources/read': ReadResourceResult; + 'prompts/list': ListPromptsResult; + 'prompts/get': GetPromptResult; +}; + +type HandleRequestResultUnion = HandleRequestMethodMap[keyof HandleRequestMethodMap]; + +/** + * Main MCP Server class with Zod-based type safety + */ +export class MCPServer { + config: NormalizedMCPServerConfig; + tools: Map; + resources: Map; + prompts: Map; + + constructor(config: MCPServerConfig) { + const { + name = 'MCP Server', + version = '1.0.0', + description = 'MCP Server powered by AWS Lambda', + protocolVersion = '2025-03-26', + ...rest + } = config; + + this.config = { + name, + version, + description, + protocolVersion, + ...rest, + }; + + this.tools = new Map(); + this.resources = new Map(); + this.prompts = new Map(); + } + + /** + * Register a tool with Zod schema validation + */ + tool(name: string, inputSchema: T, handler: ToolHandler, options?: { + annotations?: Tool['annotations']; + outputZodSchema?: ZodSchema; + }) { + const jsonSchema = zodToJsonSchema(inputSchema); + let outputSchema: JSONSchema | undefined = undefined; + if (options?.outputZodSchema) { + outputSchema = zodToJsonSchema(options.outputZodSchema); + } + // I'm not sure this actually works? Seems like this should be passed as an argument? + const handlerDescription = (handler as { description?: string }).description; + + const validatedHandler = async (args: Record) => { + try { + const validatedArgs = validateWithZod(inputSchema, args); + return await handler(validatedArgs); + } catch (error) { + if (error instanceof z.ZodError) { + throw new Error( + `Validation error: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}` + ); + } + throw error; + } + }; + + this.tools.set(name, { + name, + description: handlerDescription || `Tool: ${name}`, + inputSchema: jsonSchema as Tool['inputSchema'], + handler: validatedHandler, + options: { + outputSchema, + annotations: options?.annotations, + }, + }); + + return this; + } + + /** + * Register a resource + */ + resource(name: string, uri: string, handler: ResourceHandler) { + const handlerDescription = (handler as { description?: string }).description; + this.resources.set(name, { + name, + uri, + description: handlerDescription || `Resource: ${name}`, + handler: async (resourceUri: string) => handler(resourceUri), + }); + + return this; + } + + /** + * Register a prompt with Zod schema validation + */ + prompt(name: string, inputSchema: T, handler: PromptHandler) { + zodToJsonSchema(inputSchema); + const handlerDescription = (handler as { description?: string }).description; + + const validatedHandler = async (args: Record) => { + try { + const validatedArgs = validateWithZod(inputSchema, args); + return await handler(validatedArgs); + } catch (error) { + if (error instanceof z.ZodError) { + throw new Error( + `Validation error: ${error.errors.map((e) => `${e.path.join('.')}: ${e.message}`).join(', ')}` + ); + } + throw error; + } + }; + + this.prompts.set(name, { + name, + description: handlerDescription || `Prompt: ${name}`, + arguments: Object.entries(inputSchema).map(([key, schema]) => ({ + name: key, + description: + (schema as z.ZodTypeAny).description || `${key} parameter`, + required: !isZodOptional(schema as z.ZodTypeAny), + })) as PromptArgument[], + handler: validatedHandler, + }); + + return this; + } + + /** + * Handle MCP protocol requests + */ + async handleRequest(request: InitializeRequest): Promise; + async handleRequest(request: InitializedNotification): Promise; + async handleRequest(request: ListToolsRequest): Promise; + async handleRequest(request: CallToolRequest): Promise; + async handleRequest(request: ListResourcesRequest): Promise; + async handleRequest(request: ReadResourceRequest): Promise; + async handleRequest(request: ListPromptsRequest): Promise; + async handleRequest(request: GetPromptRequest): Promise; + async handleRequest( + request: JSONRPCRequest | JSONRPCNotification + ): Promise { + switch (request.method) { + case 'initialize': + return this.handleInitialize(); + case 'notifications/initialized': + return null; + case 'tools/list': + return this.handleToolsList(); + case 'tools/call': + return this.handleToolsCall(request.params as CallToolRequestParams); + case 'resources/list': + return this.handleResourcesList(); + case 'resources/read': + return this.handleResourcesRead(request.params as ReadResourceRequestParams); + case 'prompts/list': + return this.handlePromptsList(); + case 'prompts/get': + return this.handlePromptsGet(request.params as GetPromptRequestParams); + default: + throw new Error(`Method not found: ${request.method}`); + } + } + + /** + * Handle initialize request + */ + async handleInitialize(): Promise { + return { + protocolVersion: this.config.protocolVersion, + capabilities: { + tools: { listChanged: true }, + resources: { listChanged: true }, + prompts: { listChanged: true }, + }, + serverInfo: { + name: this.config.name, + version: this.config.version, + }, + instructions: this.config.description, + }; + } + + /** + * Handle tools/list request + */ + async handleToolsList(): Promise { + const tools = Array.from(this.tools.values()).map((tool) => ({ + name: tool.name, + description: tool.description, + inputSchema: tool.inputSchema, + outputSchema: tool.options?.outputSchema, + annotations: tool.options?.annotations, + })); + + return { tools }; + } + + /** + * Handle tools/call request + */ + async handleToolsCall(params: CallToolRequestParams): Promise { + if (!params?.name) { + throw new Error('Tool name is required'); + } + + const tool = this.tools.get(params.name); + if (!tool) { + throw new Error(`Tool not found: ${params.name}`); + } + + try { + const result = await tool.handler(params.arguments || {}); + return result; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + return { + content: [{ type: 'text', text: `Error: ${errorMessage}` }], + isError: true, + }; + } + } + + /** + * Handle resources/list request + */ + async handleResourcesList(): Promise { + const resources = Array.from(this.resources.values()).map((resource) => ({ + uri: resource.uri, + name: resource.name, + description: resource.description, + })); + + return { resources }; + } + + /** + * Handle resources/read request + */ + async handleResourcesRead( + params: ReadResourceRequestParams + ): Promise { + if (!params?.uri) { + throw new Error('Resource URI is required'); + } + + const resource = Array.from(this.resources.values()).find( + (r) => r.uri === params.uri + ); + if (!resource) { + throw new Error(`Resource not found: ${params.uri}`); + } + + try { + const result = await resource.handler(params.uri); + return result; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Resource read error: ${errorMessage}`); + } + } + + /** + * Handle prompts/list request + */ + async handlePromptsList(): Promise { + const prompts = Array.from(this.prompts.values()).map((prompt) => ({ + name: prompt.name, + description: prompt.description, + arguments: prompt.arguments, + })); + + return { prompts }; + } + + /** + * Handle prompts/get request + */ + async handlePromptsGet( + params: GetPromptRequestParams + ): Promise { + if (!params?.name) { + throw new Error('Prompt name is required'); + } + + const prompt = this.prompts.get(params.name); + if (!prompt) { + throw new Error(`Prompt not found: ${params.name}`); + } + + try { + const result = await prompt.handler(params.arguments || {}); + return result; + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + throw new Error(`Prompt execution error: ${errorMessage}`); + } + } + + /** + * Get server statistics + */ + getStats(): { + tools: number; + resources: number; + prompts: number; + config: MCPServerConfig; + } { + return { + tools: this.tools.size, + resources: this.resources.size, + prompts: this.prompts.size, + config: this.config, + }; + } +} diff --git a/src/mcp-spec.d.ts b/src/mcp-spec.d.ts new file mode 100644 index 0000000..8a3cdb3 --- /dev/null +++ b/src/mcp-spec.d.ts @@ -0,0 +1,3226 @@ +/** + * These are the core spec types from + * https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/main/schema/draft/schema.ts + * + */ +/* JSON-RPC types */ + +/** + * Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent. + * + * @category JSON-RPC + */ +export type JSONRPCMessage = + | JSONRPCRequest + | JSONRPCNotification + | JSONRPCResponse; + +/** @internal */ +export const LATEST_PROTOCOL_VERSION = 'DRAFT-2026-v1'; +/** @internal */ +export const JSONRPC_VERSION = '2.0'; + +/** + * Represents the contents of a `_meta` field, which clients and servers use to attach additional metadata to their interactions. + * + * Certain key names are reserved by MCP for protocol-level metadata; implementations MUST NOT make assumptions about values at these keys. Additionally, specific schema definitions may reserve particular names for purpose-specific metadata, as declared in those definitions. + * + * Valid keys have two segments: + * + * **Prefix:** + * - Optional — if specified, MUST be a series of _labels_ separated by dots (`.`), followed by a slash (`/`). + * - Labels MUST start with a letter and end with a letter or digit. Interior characters may be letters, digits, or hyphens (`-`). + * - Any prefix consisting of zero or more labels, followed by `modelcontextprotocol` or `mcp`, followed by any label, is **reserved** for MCP use. For example: `modelcontextprotocol.io/`, `mcp.dev/`, `api.modelcontextprotocol.org/`, and `tools.mcp.com/` are all reserved. + * + * **Name:** + * - Unless empty, MUST start and end with an alphanumeric character (`[a-z0-9A-Z]`). + * - Interior characters may be alphanumeric, hyphens (`-`), underscores (`_`), or dots (`.`). + * + * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details. + * @category Common Types + */ +export type MetaObject = Record; + +/** + * Extends {@link MetaObject} with additional request-specific fields. All key naming rules from `MetaObject` apply. + * + * @see {@link MetaObject} for key naming rules and reserved prefixes. + * @see [General fields: `_meta`](/specification/draft/basic/index#meta) for more details. + * @category Common Types + */ +export interface RequestMetaObject extends MetaObject { + /** + * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by {@link ProgressNotification | notifications/progress}). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. + */ + progressToken?: ProgressToken; +} + +/** + * A progress token, used to associate progress notifications with the original request. + * + * @category Common Types + */ +export type ProgressToken = string | number; + +/** + * An opaque token used to represent a cursor for pagination. + * + * @category Common Types + */ +export type Cursor = string; + +/** + * Common params for any task-augmented request. + * + * @internal + */ +export interface TaskAugmentedRequestParams extends RequestParams { + /** + * If specified, the caller is requesting task-augmented execution for this request. + * The request will return a {@link CreateTaskResult} immediately, and the actual result can be + * retrieved later via {@link GetTaskPayloadRequest | tasks/result}. + * + * Task augmentation is subject to capability negotiation - receivers MUST declare support + * for task augmentation of specific request types in their capabilities. + */ + task?: TaskMetadata; +} + +/** + * Common params for any request. + * + * @category Common Types + */ +export interface RequestParams { + _meta?: RequestMetaObject; +} + +/** @internal */ +export interface Request { + method: string; + // Allow unofficial extensions of `Request.params` without impacting `RequestParams`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: { [key: string]: any }; +} + +/** + * Common params for any notification. + * + * @category Common Types + */ +export interface NotificationParams { + _meta?: MetaObject; +} + +/** @internal */ +export interface Notification { + method: string; + // Allow unofficial extensions of `Notification.params` without impacting `NotificationParams`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + params?: { [key: string]: any }; +} + +/** + * Common result fields. + * + * @category Common Types + */ +export interface Result { + _meta?: MetaObject; + [key: string]: unknown; +} + +/** + * @category Errors + */ +export interface Error { + /** + * The error type that occurred. + */ + code: number; + /** + * A short description of the error. The message SHOULD be limited to a concise single sentence. + */ + message: string; + /** + * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.). + */ + data?: unknown; +} + +/** + * A uniquely identifying ID for a request in JSON-RPC. + * + * @category Common Types + */ +export type RequestId = string | number; + +/** + * A request that expects a response. + * + * @category JSON-RPC + */ +export interface JSONRPCRequest extends Request { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; +} + +/** + * A notification which does not expect a response. + * + * @category JSON-RPC + */ +export interface JSONRPCNotification extends Notification { + jsonrpc: typeof JSONRPC_VERSION; +} + +/** + * A successful (non-error) response to a request. + * + * @category JSON-RPC + */ +export interface JSONRPCResultResponse { + jsonrpc: typeof JSONRPC_VERSION; + id: RequestId; + result: Result; +} + +/** + * A response to a request that indicates an error occurred. + * + * @category JSON-RPC + */ +export interface JSONRPCErrorResponse { + jsonrpc: typeof JSONRPC_VERSION; + id?: RequestId; + error: Error; +} + +/** + * A response to a request, containing either the result or error. + */ +export type JSONRPCResponse = JSONRPCResultResponse | JSONRPCErrorResponse; + +// Standard JSON-RPC error codes +export const PARSE_ERROR = -32700; +export const INVALID_REQUEST = -32600; +export const METHOD_NOT_FOUND = -32601; +export const INVALID_PARAMS = -32602; +export const INTERNAL_ERROR = -32603; + +/** + * A JSON-RPC error indicating that invalid JSON was received by the server. This error is returned when the server cannot parse the JSON text of a message. + * + * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object} + * + * @example Invalid JSON + * {@includeCode ./examples/ParseError/invalid-json.json} + * + * @category Errors + */ +export interface ParseError extends Error { + code: typeof PARSE_ERROR; +} + +/** + * A JSON-RPC error indicating that the request is not a valid request object. This error is returned when the message structure does not conform to the JSON-RPC 2.0 specification requirements for a request (e.g., missing required fields like `jsonrpc` or `method`, or using invalid types for these fields). + * + * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object} + * + * @category Errors + */ +export interface InvalidRequestError extends Error { + code: typeof INVALID_REQUEST; +} + +/** + * A JSON-RPC error indicating that the requested method does not exist or is not available. + * + * In MCP, this error is returned when a request is made for a method that requires a capability that has not been declared. This can occur in either direction: + * + * - A server returning this error when the client requests a capability it doesn't support (e.g., requesting completions when the `completions` capability was not advertised) + * - A client returning this error when the server requests a capability it doesn't support (e.g., requesting roots when the client did not declare the `roots` capability) + * + * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object} + * + * @example Roots not supported + * {@includeCode ./examples/MethodNotFoundError/roots-not-supported.json} + * + * @category Errors + */ +export interface MethodNotFoundError extends Error { + code: typeof METHOD_NOT_FOUND; +} + +/** + * A JSON-RPC error indicating that the method parameters are invalid or malformed. + * + * In MCP, this error is returned in various contexts when request parameters fail validation: + * + * - **Tools**: Unknown tool name or invalid tool arguments + * - **Prompts**: Unknown prompt name or missing required arguments + * - **Pagination**: Invalid or expired cursor values + * - **Logging**: Invalid log level + * - **Tasks**: Invalid or nonexistent task ID, invalid cursor, or attempting to cancel a task already in a terminal status + * - **Elicitation**: Server requests an elicitation mode not declared in client capabilities + * - **Sampling**: Missing tool result or tool results mixed with other content + * + * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object} + * + * @example Unknown tool + * {@includeCode ./examples/InvalidParamsError/unknown-tool.json} + * + * @example Invalid tool arguments + * {@includeCode ./examples/InvalidParamsError/invalid-tool-arguments.json} + * + * @example Unknown prompt + * {@includeCode ./examples/InvalidParamsError/unknown-prompt.json} + * + * @example Invalid cursor + * {@includeCode ./examples/InvalidParamsError/invalid-cursor.json} + * + * @category Errors + */ +export interface InvalidParamsError extends Error { + code: typeof INVALID_PARAMS; +} + +/** + * A JSON-RPC error indicating that an internal error occurred on the receiver. This error is returned when the receiver encounters an unexpected condition that prevents it from fulfilling the request. + * + * @see {@link https://www.jsonrpc.org/specification#error_object | JSON-RPC 2.0 Error Object} + * + * @example Unexpected error + * {@includeCode ./examples/InternalError/unexpected-error.json} + * + * @category Errors + */ +export interface InternalError extends Error { + code: typeof INTERNAL_ERROR; +} + +// Implementation-specific JSON-RPC error codes [-32000, -32099] +/** @internal */ +export const URL_ELICITATION_REQUIRED = -32042; + +/** + * An error response that indicates that the server requires the client to provide additional information via an elicitation request. + * + * @example Authorization required + * {@includeCode ./examples/URLElicitationRequiredError/authorization-required.json} + * + * @internal + */ +export interface URLElicitationRequiredError + extends Omit { + error: Error & { + code: typeof URL_ELICITATION_REQUIRED; + data: { + elicitations: ElicitRequestURLParams[]; + [key: string]: unknown; + }; + }; +} + +/* Empty result */ +/** + * A result that indicates success but carries no data. + * + * @category Common Types + */ +export type EmptyResult = Result; + +/* Cancellation */ +/** + * Parameters for a `notifications/cancelled` notification. + * + * @example User-requested cancellation + * {@includeCode ./examples/CancelledNotificationParams/user-requested-cancellation.json} + * + * @category `notifications/cancelled` + */ +export interface CancelledNotificationParams extends NotificationParams { + /** + * The ID of the request to cancel. + * + * This MUST correspond to the ID of a request previously issued in the same direction. + * This MUST be provided for cancelling non-task requests. + * This MUST NOT be used for cancelling tasks (use the {@link CancelTaskRequest | tasks/cancel} request instead). + */ + requestId?: RequestId; + + /** + * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user. + */ + reason?: string; +} + +/** + * This notification can be sent by either side to indicate that it is cancelling a previously-issued request. + * + * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished. + * + * This notification indicates that the result will be unused, so any associated processing SHOULD cease. + * + * A client MUST NOT attempt to cancel its `initialize` request. + * + * For task cancellation, use the {@link CancelTaskRequest | tasks/cancel} request instead of this notification. + * + * @example User-requested cancellation + * {@includeCode ./examples/CancelledNotification/user-requested-cancellation.json} + * + * @category `notifications/cancelled` + */ +export interface CancelledNotification extends JSONRPCNotification { + method: 'notifications/cancelled'; + params: CancelledNotificationParams; +} + +/* Initialization */ +/** + * Parameters for an `initialize` request. + * + * @example Full client capabilities + * {@includeCode ./examples/InitializeRequestParams/full-client-capabilities.json} + * + * @category `initialize` + */ +export interface InitializeRequestParams extends RequestParams { + /** + * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. + */ + protocolVersion: string; + capabilities: ClientCapabilities; + clientInfo: Implementation; +} + +/** + * This request is sent from the client to the server when it first connects, asking it to begin initialization. + * + * @example Initialize request + * {@includeCode ./examples/InitializeRequest/initialize-request.json} + * + * @category `initialize` + */ +export interface InitializeRequest extends JSONRPCRequest { + method: 'initialize'; + params: InitializeRequestParams; +} + +/** + * The result returned by the server for an {@link InitializeRequest | initialize} request. + * + * @example Full server capabilities + * {@includeCode ./examples/InitializeResult/full-server-capabilities.json} + * + * @category `initialize` + */ +export interface InitializeResult extends Result { + /** + * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. + */ + protocolVersion: string; + capabilities: ServerCapabilities; + serverInfo: Implementation; + + /** + * Instructions describing how to use the server and its features. + * + * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt. + */ + instructions?: string; +} + +/** + * A successful response from the server for a {@link InitializeRequest | initialize} request. + * + * @example Initialize result response + * {@includeCode ./examples/InitializeResultResponse/initialize-result-response.json} + * + * @category `initialize` + */ +export interface InitializeResultResponse extends JSONRPCResultResponse { + result: InitializeResult; +} + +/** + * This notification is sent from the client to the server after initialization has finished. + * + * @example Initialized notification + * {@includeCode ./examples/InitializedNotification/initialized-notification.json} + * + * @category `notifications/initialized` + */ +export interface InitializedNotification extends JSONRPCNotification { + method: 'notifications/initialized'; + params?: NotificationParams; +} + +/** + * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities. + * + * @category `initialize` + */ +export interface ClientCapabilities { + /** + * Experimental, non-standard capabilities that the client supports. + */ + experimental?: { [key: string]: object }; + /** + * Present if the client supports listing roots. + * + * @example Roots — minimum baseline support + * {@includeCode ./examples/ClientCapabilities/roots-minimum-baseline-support.json} + * + * @example Roots — list changed notifications + * {@includeCode ./examples/ClientCapabilities/roots-list-changed-notifications.json} + */ + roots?: { + /** + * Whether the client supports notifications for changes to the roots list. + */ + listChanged?: boolean; + }; + /** + * Present if the client supports sampling from an LLM. + * + * @example Sampling — minimum baseline support + * {@includeCode ./examples/ClientCapabilities/sampling-minimum-baseline-support.json} + * + * @example Sampling — tool use support + * {@includeCode ./examples/ClientCapabilities/sampling-tool-use-support.json} + * + * @example Sampling — context inclusion support (soft-deprecated) + * {@includeCode ./examples/ClientCapabilities/sampling-context-inclusion-support-soft-deprecated.json} + */ + sampling?: { + /** + * Whether the client supports context inclusion via `includeContext` parameter. + * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it). + */ + context?: object; + /** + * Whether the client supports tool use via `tools` and `toolChoice` parameters. + */ + tools?: object; + }; + /** + * Present if the client supports elicitation from the server. + * + * @example Elicitation — form and URL mode support + * {@includeCode ./examples/ClientCapabilities/elicitation-form-and-url-mode-support.json} + * + * @example Elicitation — form mode only (implicit) + * {@includeCode ./examples/ClientCapabilities/elicitation-form-only-implicit.json} + */ + elicitation?: { form?: object; url?: object }; + + /** + * Present if the client supports task-augmented requests. + */ + tasks?: { + /** + * Whether this client supports {@link ListTasksRequest | tasks/list}. + */ + list?: object; + /** + * Whether this client supports {@link CancelTaskRequest | tasks/cancel}. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for sampling-related requests. + */ + sampling?: { + /** + * Whether the client supports task-augmented `sampling/createMessage` requests. + */ + createMessage?: object; + }; + /** + * Task support for elicitation-related requests. + */ + elicitation?: { + /** + * Whether the client supports task-augmented {@link ElicitRequest | elicitation/create} requests. + */ + create?: object; + }; + }; + }; +} + +/** + * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities. + * + * @category `initialize` + */ +export interface ServerCapabilities { + /** + * Experimental, non-standard capabilities that the server supports. + */ + experimental?: { [key: string]: object }; + /** + * Present if the server supports sending log messages to the client. + * + * @example Logging — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/logging-minimum-baseline-support.json} + */ + logging?: object; + /** + * Present if the server supports argument autocompletion suggestions. + * + * @example Completions — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/completions-minimum-baseline-support.json} + */ + completions?: object; + /** + * Present if the server offers any prompt templates. + * + * @example Prompts — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/prompts-minimum-baseline-support.json} + * + * @example Prompts — list changed notifications + * {@includeCode ./examples/ServerCapabilities/prompts-list-changed-notifications.json} + */ + prompts?: { + /** + * Whether this server supports notifications for changes to the prompt list. + */ + listChanged?: boolean; + }; + /** + * Present if the server offers any resources to read. + * + * @example Resources — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/resources-minimum-baseline-support.json} + * + * @example Resources — subscription to individual resource updates (only) + * {@includeCode ./examples/ServerCapabilities/resources-subscription-to-individual-resource-updates-only.json} + * + * @example Resources — list changed notifications (only) + * {@includeCode ./examples/ServerCapabilities/resources-list-changed-notifications-only.json} + * + * @example Resources — all notifications + * {@includeCode ./examples/ServerCapabilities/resources-all-notifications.json} + */ + resources?: { + /** + * Whether this server supports subscribing to resource updates. + */ + subscribe?: boolean; + /** + * Whether this server supports notifications for changes to the resource list. + */ + listChanged?: boolean; + }; + /** + * Present if the server offers any tools to call. + * + * @example Tools — minimum baseline support + * {@includeCode ./examples/ServerCapabilities/tools-minimum-baseline-support.json} + * + * @example Tools — list changed notifications + * {@includeCode ./examples/ServerCapabilities/tools-list-changed-notifications.json} + */ + tools?: { + /** + * Whether this server supports notifications for changes to the tool list. + */ + listChanged?: boolean; + }; + /** + * Present if the server supports task-augmented requests. + */ + tasks?: { + /** + * Whether this server supports {@link ListTasksRequest | tasks/list}. + */ + list?: object; + /** + * Whether this server supports {@link CancelTaskRequest | tasks/cancel}. + */ + cancel?: object; + /** + * Specifies which request types can be augmented with tasks. + */ + requests?: { + /** + * Task support for tool-related requests. + */ + tools?: { + /** + * Whether the server supports task-augmented {@link CallToolRequest | tools/call} requests. + */ + call?: object; + }; + }; + }; +} + +/** + * An optionally-sized icon that can be displayed in a user interface. + * + * @category Common Types + */ +export interface Icon { + /** + * A standard URI pointing to an icon resource. May be an HTTP/HTTPS URL or a + * `data:` URI with Base64-encoded image data. + * + * Consumers SHOULD take steps to ensure URLs serving icons are from the + * same domain as the client/server or a trusted domain. + * + * Consumers SHOULD take appropriate precautions when consuming SVGs as they can contain + * executable JavaScript. + * + * @format uri + */ + src: string; + + /** + * Optional MIME type override if the source MIME type is missing or generic. + * For example: `"image/png"`, `"image/jpeg"`, or `"image/svg+xml"`. + */ + mimeType?: string; + + /** + * Optional array of strings that specify sizes at which the icon can be used. + * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG. + * + * If not provided, the client should assume that the icon can be used at any size. + */ + sizes?: string[]; + + /** + * Optional specifier for the theme this icon is designed for. `"light"` indicates + * the icon is designed to be used with a light background, and `"dark"` indicates + * the icon is designed to be used with a dark background. + * + * If not provided, the client should assume the icon can be used with any theme. + */ + theme?: 'light' | 'dark'; +} + +/** + * Base interface to add `icons` property. + * + * @internal + */ +export interface Icons { + /** + * Optional set of sized icons that the client can display in a user interface. + * + * Clients that support rendering icons MUST support at least the following MIME types: + * - `image/png` - PNG images (safe, universal compatibility) + * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility) + * + * Clients that support rendering icons SHOULD also support: + * - `image/svg+xml` - SVG images (scalable but requires security precautions) + * - `image/webp` - WebP images (modern, efficient format) + */ + icons?: Icon[]; +} + +/** + * Base interface for metadata with name (identifier) and title (display name) properties. + * + * @internal + */ +export interface BaseMetadata { + /** + * Intended for programmatic or logical use, but used as a display name in past specs or fallback (if title isn't present). + */ + name: string; + + /** + * Intended for UI and end-user contexts — optimized to be human-readable and easily understood, + * even by those unfamiliar with domain-specific terminology. + * + * If not provided, the name should be used for display (except for {@link Tool}, + * where `annotations.title` should be given precedence over using `name`, + * if present). + */ + title?: string; +} + +/** + * Describes the MCP implementation. + * + * @category `initialize` + */ +export interface Implementation extends BaseMetadata, Icons { + version: string; + + /** + * An optional human-readable description of what this implementation does. + * + * This can be used by clients or servers to provide context about their purpose + * and capabilities. For example, a server might describe the types of resources + * or tools it provides, while a client might describe its intended use case. + */ + description?: string; + + /** + * An optional URL of the website for this implementation. + * + * @format uri + */ + websiteUrl?: string; +} + +/* Ping */ +/** + * A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected. + * + * @example Ping request + * {@includeCode ./examples/PingRequest/ping-request.json} + * + * @category `ping` + */ +export interface PingRequest extends JSONRPCRequest { + method: 'ping'; + params?: RequestParams; +} + +/** + * A successful response for a {@link PingRequest | ping} request. + * + * @example Ping result response + * {@includeCode ./examples/PingResultResponse/ping-result-response.json} + * + * @category `ping` + */ +export interface PingResultResponse extends JSONRPCResultResponse { + result: EmptyResult; +} + +/* Progress notifications */ + +/** + * Parameters for a {@link ProgressNotification | notifications/progress} notification. + * + * @example Progress message + * {@includeCode ./examples/ProgressNotificationParams/progress-message.json} + * + * @category `notifications/progress` + */ +export interface ProgressNotificationParams extends NotificationParams { + /** + * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding. + */ + progressToken: ProgressToken; + /** + * The progress thus far. This should increase every time progress is made, even if the total is unknown. + * + * @TJS-type number + */ + progress: number; + /** + * Total number of items to process (or total progress required), if known. + * + * @TJS-type number + */ + total?: number; + /** + * An optional message describing the current progress. + */ + message?: string; +} + +/** + * An out-of-band notification used to inform the receiver of a progress update for a long-running request. + * + * @example Progress message + * {@includeCode ./examples/ProgressNotification/progress-message.json} + * + * @category `notifications/progress` + */ +export interface ProgressNotification extends JSONRPCNotification { + method: 'notifications/progress'; + params: ProgressNotificationParams; +} + +/* Pagination */ +/** + * Common params for paginated requests. + * + * @example List request with cursor + * {@includeCode ./examples/PaginatedRequestParams/list-with-cursor.json} + * + * @category Common Types + */ +export interface PaginatedRequestParams extends RequestParams { + /** + * An opaque token representing the current pagination position. + * If provided, the server should return results starting after this cursor. + */ + cursor?: Cursor; +} + +/** @internal */ +export interface PaginatedRequest extends JSONRPCRequest { + params?: PaginatedRequestParams; +} + +/** @internal */ +export interface PaginatedResult extends Result { + /** + * An opaque token representing the pagination position after the last returned result. + * If present, there may be more results available. + */ + nextCursor?: Cursor; +} + +/* Resources */ +/** + * Sent from the client to request a list of resources the server has. + * + * @example List resources request + * {@includeCode ./examples/ListResourcesRequest/list-resources-request.json} + * + * @category `resources/list` + */ +export interface ListResourcesRequest extends PaginatedRequest { + method: 'resources/list'; +} + +/** + * The result returned by the server for a {@link ListResourcesRequest | resources/list} request. + * + * @example Resources list with cursor + * {@includeCode ./examples/ListResourcesResult/resources-list-with-cursor.json} + * + * @category `resources/list` + */ +export interface ListResourcesResult extends PaginatedResult { + resources: Resource[]; +} + +/** + * A successful response from the server for a {@link ListResourcesRequest | resources/list} request. + * + * @example List resources result response + * {@includeCode ./examples/ListResourcesResultResponse/list-resources-result-response.json} + * + * @category `resources/list` + */ +export interface ListResourcesResultResponse extends JSONRPCResultResponse { + result: ListResourcesResult; +} + +/** + * Sent from the client to request a list of resource templates the server has. + * + * @example List resource templates request + * {@includeCode ./examples/ListResourceTemplatesRequest/list-resource-templates-request.json} + * + * @category `resources/templates/list` + */ +export interface ListResourceTemplatesRequest extends PaginatedRequest { + method: 'resources/templates/list'; +} + +/** + * The result returned by the server for a {@link ListResourceTemplatesRequest | resources/templates/list} request. + * + * @example Resource templates list + * {@includeCode ./examples/ListResourceTemplatesResult/resource-templates-list.json} + * + * @category `resources/templates/list` + */ +export interface ListResourceTemplatesResult extends PaginatedResult { + resourceTemplates: ResourceTemplate[]; +} + +/** + * A successful response from the server for a {@link ListResourceTemplatesRequest | resources/templates/list} request. + * + * @example List resource templates result response + * {@includeCode ./examples/ListResourceTemplatesResultResponse/list-resource-templates-result-response.json} + * + * @category `resources/templates/list` + */ +export interface ListResourceTemplatesResultResponse + extends JSONRPCResultResponse { + result: ListResourceTemplatesResult; +} + +/** + * Common params for resource-related requests. + * + * @internal + */ +export interface ResourceRequestParams extends RequestParams { + /** + * The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it. + * + * @format uri + */ + uri: string; +} + +/** + * Parameters for a `resources/read` request. + * + * @category `resources/read` + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ReadResourceRequestParams extends ResourceRequestParams {} + +/** + * Sent from the client to the server, to read a specific resource URI. + * + * @example Read resource request + * {@includeCode ./examples/ReadResourceRequest/read-resource-request.json} + * + * @category `resources/read` + */ +export interface ReadResourceRequest extends JSONRPCRequest { + method: 'resources/read'; + params: ReadResourceRequestParams; +} + +/** + * The result returned by the server for a {@link ReadResourceRequest | resources/read} request. + * + * @example File resource contents + * {@includeCode ./examples/ReadResourceResult/file-resource-contents.json} + * + * @category `resources/read` + */ +export interface ReadResourceResult extends Result { + contents: (TextResourceContents | BlobResourceContents)[]; +} + +/** + * A successful response from the server for a {@link ReadResourceRequest | resources/read} request. + * + * @example Read resource result response + * {@includeCode ./examples/ReadResourceResultResponse/read-resource-result-response.json} + * + * @category `resources/read` + */ +export interface ReadResourceResultResponse extends JSONRPCResultResponse { + result: ReadResourceResult; +} + +/** + * An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client. + * + * @example Resources list changed + * {@includeCode ./examples/ResourceListChangedNotification/resources-list-changed.json} + * + * @category `notifications/resources/list_changed` + */ +export interface ResourceListChangedNotification extends JSONRPCNotification { + method: 'notifications/resources/list_changed'; + params?: NotificationParams; +} + +/** + * Parameters for a `resources/subscribe` request. + * + * @example Subscribe to file resource + * {@includeCode ./examples/SubscribeRequestParams/subscribe-to-file-resource.json} + * + * @category `resources/subscribe` + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface SubscribeRequestParams extends ResourceRequestParams {} + +/** + * Sent from the client to request {@link ResourceUpdatedNotification | resources/updated} notifications from the server whenever a particular resource changes. + * + * @example Subscribe request + * {@includeCode ./examples/SubscribeRequest/subscribe-request.json} + * + * @category `resources/subscribe` + */ +export interface SubscribeRequest extends JSONRPCRequest { + method: 'resources/subscribe'; + params: SubscribeRequestParams; +} + +/** + * A successful response from the server for a {@link SubscribeRequest | resources/subscribe} request. + * + * @example Subscribe result response + * {@includeCode ./examples/SubscribeResultResponse/subscribe-result-response.json} + * + * @category `resources/subscribe` + */ +export interface SubscribeResultResponse extends JSONRPCResultResponse { + result: EmptyResult; +} + +/** + * Parameters for a `resources/unsubscribe` request. + * + * @category `resources/unsubscribe` + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface UnsubscribeRequestParams extends ResourceRequestParams {} + +/** + * Sent from the client to request cancellation of {@link ResourceUpdatedNotification | resources/updated} notifications from the server. This should follow a previous {@link SubscribeRequest | resources/subscribe} request. + * + * @example Unsubscribe request + * {@includeCode ./examples/UnsubscribeRequest/unsubscribe-request.json} + * + * @category `resources/unsubscribe` + */ +export interface UnsubscribeRequest extends JSONRPCRequest { + method: 'resources/unsubscribe'; + params: UnsubscribeRequestParams; +} + +/** + * A successful response from the server for a {@link UnsubscribeRequest | resources/unsubscribe} request. + * + * @example Unsubscribe result response + * {@includeCode ./examples/UnsubscribeResultResponse/unsubscribe-result-response.json} + * + * @category `resources/unsubscribe` + */ +export interface UnsubscribeResultResponse extends JSONRPCResultResponse { + result: EmptyResult; +} + +/** + * Parameters for a `notifications/resources/updated` notification. + * + * @example File resource updated + * {@includeCode ./examples/ResourceUpdatedNotificationParams/file-resource-updated.json} + * + * @category `notifications/resources/updated` + */ +export interface ResourceUpdatedNotificationParams extends NotificationParams { + /** + * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to. + * + * @format uri + */ + uri: string; +} + +/** + * A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a {@link SubscribeRequest | resources/subscribe} request. + * + * @example File resource updated notification + * {@includeCode ./examples/ResourceUpdatedNotification/file-resource-updated-notification.json} + * + * @category `notifications/resources/updated` + */ +export interface ResourceUpdatedNotification extends JSONRPCNotification { + method: 'notifications/resources/updated'; + params: ResourceUpdatedNotificationParams; +} + +/** + * A known resource that the server is capable of reading. + * + * @example File resource with annotations + * {@includeCode ./examples/Resource/file-resource-with-annotations.json} + * + * @category `resources/list` + */ +export interface Resource extends BaseMetadata, Icons { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + + /** + * A description of what this resource represents. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + */ + description?: string; + + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + + /** + * The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known. + * + * This can be used by Hosts to display file sizes and estimate context window usage. + */ + size?: number; + + _meta?: MetaObject; +} + +/** + * A template description for resources available on the server. + * + * @category `resources/templates/list` + */ +export interface ResourceTemplate extends BaseMetadata, Icons { + /** + * A URI template (according to RFC 6570) that can be used to construct resource URIs. + * + * @format uri-template + */ + uriTemplate: string; + + /** + * A description of what this template is for. + * + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model. + */ + description?: string; + + /** + * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type. + */ + mimeType?: string; + + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + + _meta?: MetaObject; +} + +/** + * The contents of a specific resource or sub-resource. + * + * @internal + */ +export interface ResourceContents { + /** + * The URI of this resource. + * + * @format uri + */ + uri: string; + /** + * The MIME type of this resource, if known. + */ + mimeType?: string; + + _meta?: MetaObject; +} + +/** + * @example Text file contents + * {@includeCode ./examples/TextResourceContents/text-file-contents.json} + * + * @category Content + */ +export interface TextResourceContents extends ResourceContents { + /** + * The text of the item. This must only be set if the item can actually be represented as text (not binary data). + */ + text: string; +} + +/** + * @example Image file contents + * {@includeCode ./examples/BlobResourceContents/image-file-contents.json} + * + * @category Content + */ +export interface BlobResourceContents extends ResourceContents { + /** + * A base64-encoded string representing the binary data of the item. + * + * @format byte + */ + blob: string; +} + +/* Prompts */ +/** + * Sent from the client to request a list of prompts and prompt templates the server has. + * + * @example List prompts request + * {@includeCode ./examples/ListPromptsRequest/list-prompts-request.json} + * + * @category `prompts/list` + */ +export interface ListPromptsRequest extends PaginatedRequest { + method: 'prompts/list'; +} + +/** + * The result returned by the server for a {@link ListPromptsRequest | prompts/list} request. + * + * @example Prompts list with cursor + * {@includeCode ./examples/ListPromptsResult/prompts-list-with-cursor.json} + * + * @category `prompts/list` + */ +export interface ListPromptsResult extends PaginatedResult { + prompts: Prompt[]; +} + +/** + * A successful response from the server for a {@link ListPromptsRequest | prompts/list} request. + * + * @example List prompts result response + * {@includeCode ./examples/ListPromptsResultResponse/list-prompts-result-response.json} + * + * @category `prompts/list` + */ +export interface ListPromptsResultResponse extends JSONRPCResultResponse { + result: ListPromptsResult; +} + +/** + * Parameters for a `prompts/get` request. + * + * @example Get code review prompt + * {@includeCode ./examples/GetPromptRequestParams/get-code-review-prompt.json} + * + * @category `prompts/get` + */ +export interface GetPromptRequestParams extends RequestParams { + /** + * The name of the prompt or prompt template. + */ + name: string; + /** + * Arguments to use for templating the prompt. + */ + arguments?: { [key: string]: string }; +} + +/** + * Used by the client to get a prompt provided by the server. + * + * @example Get prompt request + * {@includeCode ./examples/GetPromptRequest/get-prompt-request.json} + * + * @category `prompts/get` + */ +export interface GetPromptRequest extends JSONRPCRequest { + method: 'prompts/get'; + params: GetPromptRequestParams; +} + +/** + * The result returned by the server for a {@link GetPromptRequest | prompts/get} request. + * + * @example Code review prompt + * {@includeCode ./examples/GetPromptResult/code-review-prompt.json} + * + * @category `prompts/get` + */ +export interface GetPromptResult extends Result { + /** + * An optional description for the prompt. + */ + description?: string; + messages: PromptMessage[]; +} + +/** + * A successful response from the server for a {@link GetPromptRequest | prompts/get} request. + * + * @example Get prompt result response + * {@includeCode ./examples/GetPromptResultResponse/get-prompt-result-response.json} + * + * @category `prompts/get` + */ +export interface GetPromptResultResponse extends JSONRPCResultResponse { + result: GetPromptResult; +} + +/** + * A prompt or prompt template that the server offers. + * + * @category `prompts/list` + */ +export interface Prompt extends BaseMetadata, Icons { + /** + * An optional description of what this prompt provides + */ + description?: string; + + /** + * A list of arguments to use for templating the prompt. + */ + arguments?: PromptArgument[]; + + _meta?: MetaObject; +} + +/** + * Describes an argument that a prompt can accept. + * + * @category `prompts/list` + */ +export interface PromptArgument extends BaseMetadata { + /** + * A human-readable description of the argument. + */ + description?: string; + /** + * Whether this argument must be provided. + */ + required?: boolean; +} + +/** + * The sender or recipient of messages and data in a conversation. + * + * @category Common Types + */ +export type Role = 'user' | 'assistant'; + +/** + * Describes a message returned as part of a prompt. + * + * This is similar to {@link SamplingMessage}, but also supports the embedding of + * resources from the MCP server. + * + * @category `prompts/get` + */ +export interface PromptMessage { + role: Role; + content: ContentBlock; +} + +/** + * A resource that the server is capable of reading, included in a prompt or tool call result. + * + * Note: resource links returned by tools are not guaranteed to appear in the results of {@link ListResourcesRequest | resources/list} requests. + * + * @example File resource link + * {@includeCode ./examples/ResourceLink/file-resource-link.json} + * + * @category Content + */ +export interface ResourceLink extends Resource { + type: 'resource_link'; +} + +/** + * The contents of a resource, embedded into a prompt or tool call result. + * + * It is up to the client how best to render embedded resources for the benefit + * of the LLM and/or the user. + * + * @example Embedded file resource with annotations + * {@includeCode ./examples/EmbeddedResource/embedded-file-resource-with-annotations.json} + * + * @category Content + */ +export interface EmbeddedResource { + type: 'resource'; + resource: TextResourceContents | BlobResourceContents; + + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + + _meta?: MetaObject; +} +/** + * An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client. + * + * @example Prompts list changed + * {@includeCode ./examples/PromptListChangedNotification/prompts-list-changed.json} + * + * @category `notifications/prompts/list_changed` + */ +export interface PromptListChangedNotification extends JSONRPCNotification { + method: 'notifications/prompts/list_changed'; + params?: NotificationParams; +} + +/* Tools */ +/** + * Sent from the client to request a list of tools the server has. + * + * @example List tools request + * {@includeCode ./examples/ListToolsRequest/list-tools-request.json} + * + * @category `tools/list` + */ +export interface ListToolsRequest extends PaginatedRequest { + method: 'tools/list'; +} + +/** + * The result returned by the server for a {@link ListToolsRequest | tools/list} request. + * + * @example Tools list with cursor + * {@includeCode ./examples/ListToolsResult/tools-list-with-cursor.json} + * + * @category `tools/list` + */ +export interface ListToolsResult extends PaginatedResult { + tools: Tool[]; +} + +/** + * A successful response from the server for a {@link ListToolsRequest | tools/list} request. + * + * @example List tools result response + * {@includeCode ./examples/ListToolsResultResponse/list-tools-result-response.json} + * + * @category `tools/list` + */ +export interface ListToolsResultResponse extends JSONRPCResultResponse { + result: ListToolsResult; +} + +/** + * The result returned by the server for a {@link CallToolRequest | tools/call} request. + * + * @example Result with unstructured text + * {@includeCode ./examples/CallToolResult/result-with-unstructured-text.json} + * + * @example Result with structured content + * {@includeCode ./examples/CallToolResult/result-with-structured-content.json} + * + * @example Invalid tool input error + * {@includeCode ./examples/CallToolResult/invalid-tool-input-error.json} + * + * @category `tools/call` + */ +export interface CallToolResult extends Result { + /** + * A list of content objects that represent the unstructured result of the tool call. + */ + content: ContentBlock[]; + + /** + * An optional JSON object that represents the structured result of the tool call. + */ + structuredContent?: { [key: string]: unknown }; + + /** + * Whether the tool call ended in an error. + * + * If not set, this is assumed to be false (the call was successful). + * + * Any errors that originate from the tool SHOULD be reported inside the result + * object, with `isError` set to true, _not_ as an MCP protocol-level error + * response. Otherwise, the LLM would not be able to see that an error occurred + * and self-correct. + * + * However, any errors in _finding_ the tool, an error indicating that the + * server does not support tool calls, or any other exceptional conditions, + * should be reported as an MCP error response. + */ + isError?: boolean; +} + +/** + * A successful response from the server for a {@link CallToolRequest | tools/call} request. + * + * @example Call tool result response + * {@includeCode ./examples/CallToolResultResponse/call-tool-result-response.json} + * + * @category `tools/call` + */ +export interface CallToolResultResponse extends JSONRPCResultResponse { + result: CallToolResult; +} + +/** + * Parameters for a `tools/call` request. + * + * @example `get_weather` tool call params + * {@includeCode ./examples/CallToolRequestParams/get-weather-tool-call-params.json} + * + * @example Tool call params with progress token + * {@includeCode ./examples/CallToolRequestParams/tool-call-params-with-progress-token.json} + * + * @category `tools/call` + */ +export interface CallToolRequestParams extends TaskAugmentedRequestParams { + /** + * The name of the tool. + */ + name: string; + /** + * Arguments to use for the tool call. + */ + arguments?: { [key: string]: unknown }; +} + +/** + * Used by the client to invoke a tool provided by the server. + * + * @example Call tool request + * {@includeCode ./examples/CallToolRequest/call-tool-request.json} + * + * @category `tools/call` + */ +export interface CallToolRequest extends JSONRPCRequest { + method: 'tools/call'; + params: CallToolRequestParams; +} + +/** + * An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client. + * + * @example Tools list changed + * {@includeCode ./examples/ToolListChangedNotification/tools-list-changed.json} + * + * @category `notifications/tools/list_changed` + */ +export interface ToolListChangedNotification extends JSONRPCNotification { + method: 'notifications/tools/list_changed'; + params?: NotificationParams; +} + +/** + * Additional properties describing a {@link Tool} to clients. + * + * NOTE: all properties in `ToolAnnotations` are **hints**. + * They are not guaranteed to provide a faithful description of + * tool behavior (including descriptive properties like `title`). + * + * Clients should never make tool use decisions based on `ToolAnnotations` + * received from untrusted servers. + * + * @category `tools/list` + */ +export interface ToolAnnotations { + /** + * A human-readable title for the tool. + */ + title?: string; + + /** + * If true, the tool does not modify its environment. + * + * Default: false + */ + readOnlyHint?: boolean; + + /** + * If true, the tool may perform destructive updates to its environment. + * If false, the tool performs only additive updates. + * + * (This property is meaningful only when `readOnlyHint == false`) + * + * Default: true + */ + destructiveHint?: boolean; + + /** + * If true, calling the tool repeatedly with the same arguments + * will have no additional effect on its environment. + * + * (This property is meaningful only when `readOnlyHint == false`) + * + * Default: false + */ + idempotentHint?: boolean; + + /** + * If true, this tool may interact with an "open world" of external + * entities. If false, the tool's domain of interaction is closed. + * For example, the world of a web search tool is open, whereas that + * of a memory tool is not. + * + * Default: true + */ + openWorldHint?: boolean; +} + +/** + * Execution-related properties for a tool. + * + * @category `tools/list` + */ +export interface ToolExecution { + /** + * Indicates whether this tool supports task-augmented execution. + * This allows clients to handle long-running operations through polling + * the task system. + * + * - `"forbidden"`: Tool does not support task-augmented execution (default when absent) + * - `"optional"`: Tool may support task-augmented execution + * - `"required"`: Tool requires task-augmented execution + * + * Default: `"forbidden"` + */ + taskSupport?: 'forbidden' | 'optional' | 'required'; +} + +/** + * Definition for a tool the client can call. + * + * @example With default 2020-12 input schema + * {@includeCode ./examples/Tool/with-default-2020-12-input-schema.json} + * + * @example With explicit draft-07 input schema + * {@includeCode ./examples/Tool/with-explicit-draft-07-input-schema.json} + * + * @example With no parameters + * {@includeCode ./examples/Tool/with-no-parameters.json} + * + * @example With output schema for structured content + * {@includeCode ./examples/Tool/with-output-schema-for-structured-content.json} + * + * @category `tools/list` + */ +export interface Tool extends BaseMetadata, Icons { + /** + * A human-readable description of the tool. + * + * This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model. + */ + description?: string; + + /** + * A JSON Schema object defining the expected parameters for the tool. + */ + inputSchema: { + $schema?: string; + type: 'object'; + properties?: { [key: string]: object }; + required?: string[]; + }; + + /** + * Execution-related properties for this tool. + */ + execution?: ToolExecution; + + /** + * An optional JSON Schema object defining the structure of the tool's output returned in + * the structuredContent field of a {@link CallToolResult}. + * + * Defaults to JSON Schema 2020-12 when no explicit `$schema` is provided. + * Currently restricted to `type: "object"` at the root level. + */ + outputSchema?: { + $schema?: string; + type: 'object'; + properties?: { [key: string]: object }; + required?: string[]; + }; + + /** + * Optional additional tool information. + * + * Display name precedence order is: `title`, `annotations.title`, then `name`. + */ + annotations?: ToolAnnotations; + + _meta?: MetaObject; +} + +/* Tasks */ + +/** + * The status of a task. + * + * @category `tasks` + */ +export type TaskStatus = + | 'working' // The request is currently being processed + | 'input_required' // The task is waiting for input (e.g., elicitation or sampling) + | 'completed' // The request completed successfully and results are available + | 'failed' // The associated request did not complete successfully. For tool calls specifically, this includes cases where the tool call result has `isError` set to true. + | 'cancelled'; // The request was cancelled before completion + +/** + * Metadata for augmenting a request with task execution. + * Include this in the `task` field of the request parameters. + * + * @category `tasks` + */ +export interface TaskMetadata { + /** + * Requested duration in milliseconds to retain task from creation. + */ + ttl?: number; +} + +/** + * Metadata for associating messages with a task. + * Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`. + * + * @category `tasks` + */ +export interface RelatedTaskMetadata { + /** + * The task identifier this message is associated with. + */ + taskId: string; +} + +/** + * Data associated with a task. + * + * @category `tasks` + */ +export interface Task { + /** + * The task identifier. + */ + taskId: string; + + /** + * Current task state. + */ + status: TaskStatus; + + /** + * Optional human-readable message describing the current task state. + * This can provide context for any status, including: + * - Reasons for "cancelled" status + * - Summaries for "completed" status + * - Diagnostic information for "failed" status (e.g., error details, what went wrong) + */ + statusMessage?: string; + + /** + * ISO 8601 timestamp when the task was created. + */ + createdAt: string; + + /** + * ISO 8601 timestamp when the task was last updated. + */ + lastUpdatedAt: string; + + /** + * Actual retention duration from creation in milliseconds, null for unlimited. + */ + ttl: number | null; + + /** + * Suggested polling interval in milliseconds. + */ + pollInterval?: number; +} + +/** + * The result returned for a task-augmented request. + * + * @category `tasks` + */ +export interface CreateTaskResult extends Result { + task: Task; +} + +/** + * A successful response for a task-augmented request. + * + * @category `tasks` + */ +export interface CreateTaskResultResponse extends JSONRPCResultResponse { + result: CreateTaskResult; +} + +/** + * A request to retrieve the state of a task. + * + * @category `tasks/get` + */ +export interface GetTaskRequest extends JSONRPCRequest { + method: 'tasks/get'; + params: { + /** + * The task identifier to query. + */ + taskId: string; + }; +} + +/** + * The result returned for a {@link GetTaskRequest | tasks/get} request. + * + * @category `tasks/get` + */ +export type GetTaskResult = Result & Task; + +/** + * A successful response for a {@link GetTaskRequest | tasks/get} request. + * + * @category `tasks/get` + */ +export interface GetTaskResultResponse extends JSONRPCResultResponse { + result: GetTaskResult; +} + +/** + * A request to retrieve the result of a completed task. + * + * @category `tasks/result` + */ +export interface GetTaskPayloadRequest extends JSONRPCRequest { + method: 'tasks/result'; + params: { + /** + * The task identifier to retrieve results for. + */ + taskId: string; + }; +} + +/** + * The result returned for a {@link GetTaskPayloadRequest | tasks/result} request. + * The structure matches the result type of the original request. + * For example, a {@link CallToolRequest | tools/call} task would return the {@link CallToolResult} structure. + * + * @category `tasks/result` + */ +export interface GetTaskPayloadResult extends Result { + [key: string]: unknown; +} + +/** + * A successful response for a {@link GetTaskPayloadRequest | tasks/result} request. + * + * @category `tasks/result` + */ +export interface GetTaskPayloadResultResponse extends JSONRPCResultResponse { + result: GetTaskPayloadResult; +} + +/** + * A request to cancel a task. + * + * @category `tasks/cancel` + */ +export interface CancelTaskRequest extends JSONRPCRequest { + method: 'tasks/cancel'; + params: { + /** + * The task identifier to cancel. + */ + taskId: string; + }; +} + +/** + * The result returned for a {@link CancelTaskRequest | tasks/cancel} request. + * + * @category `tasks/cancel` + */ +export type CancelTaskResult = Result & Task; + +/** + * A successful response for a {@link CancelTaskRequest | tasks/cancel} request. + * + * @category `tasks/cancel` + */ +export interface CancelTaskResultResponse extends JSONRPCResultResponse { + result: CancelTaskResult; +} + +/** + * A request to retrieve a list of tasks. + * + * @category `tasks/list` + */ +export interface ListTasksRequest extends PaginatedRequest { + method: 'tasks/list'; +} + +/** + * The result returned for a {@link ListTasksRequest | tasks/list} request. + * + * @category `tasks/list` + */ +export interface ListTasksResult extends PaginatedResult { + tasks: Task[]; +} + +/** + * A successful response for a {@link ListTasksRequest | tasks/list} request. + * + * @category `tasks/list` + */ +export interface ListTasksResultResponse extends JSONRPCResultResponse { + result: ListTasksResult; +} + +/** + * Parameters for a `notifications/tasks/status` notification. + * + * @category `notifications/tasks/status` + */ +export type TaskStatusNotificationParams = NotificationParams & Task; + +/** + * An optional notification from the receiver to the requestor, informing them that a task's status has changed. Receivers are not required to send these notifications. + * + * @category `notifications/tasks/status` + */ +export interface TaskStatusNotification extends JSONRPCNotification { + method: 'notifications/tasks/status'; + params: TaskStatusNotificationParams; +} + +/* Logging */ + +/** + * Parameters for a `logging/setLevel` request. + * + * @example Set log level to "info" + * {@includeCode ./examples/SetLevelRequestParams/set-log-level-to-info.json} + * + * @category `logging/setLevel` + */ +export interface SetLevelRequestParams extends RequestParams { + /** + * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as {@link LoggingMessageNotification | notifications/message}. + */ + level: LoggingLevel; +} + +/** + * A request from the client to the server, to enable or adjust logging. + * + * @example Set logging level request + * {@includeCode ./examples/SetLevelRequest/set-logging-level-request.json} + * + * @category `logging/setLevel` + */ +export interface SetLevelRequest extends JSONRPCRequest { + method: 'logging/setLevel'; + params: SetLevelRequestParams; +} + +/** + * A successful response from the server for a {@link SetLevelRequest | logging/setLevel} request. + * + * @example Set logging level result response + * {@includeCode ./examples/SetLevelResultResponse/set-logging-level-result-response.json} + * + * @category `logging/setLevel` + */ +export interface SetLevelResultResponse extends JSONRPCResultResponse { + result: EmptyResult; +} + +/** + * Parameters for a `notifications/message` notification. + * + * @example Log database connection failed + * {@includeCode ./examples/LoggingMessageNotificationParams/log-database-connection-failed.json} + * + * @category `notifications/message` + */ +export interface LoggingMessageNotificationParams extends NotificationParams { + /** + * The severity of this log message. + */ + level: LoggingLevel; + /** + * An optional name of the logger issuing this message. + */ + logger?: string; + /** + * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here. + */ + data: unknown; +} + +/** + * JSONRPCNotification of a log message passed from server to client. If no `logging/setLevel` request has been sent from the client, the server MAY decide which messages to send automatically. + * + * @example Log database connection failed + * {@includeCode ./examples/LoggingMessageNotification/log-database-connection-failed.json} + * + * @category `notifications/message` + */ +export interface LoggingMessageNotification extends JSONRPCNotification { + method: 'notifications/message'; + params: LoggingMessageNotificationParams; +} + +/** + * The severity of a log message. + * + * These map to syslog message severities, as specified in RFC-5424: + * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1 + * + * @category Common Types + */ +export type LoggingLevel = + | 'debug' + | 'info' + | 'notice' + | 'warning' + | 'error' + | 'critical' + | 'alert' + | 'emergency'; + +/* Sampling */ +/** + * Parameters for a `sampling/createMessage` request. + * + * @example Basic request + * {@includeCode ./examples/CreateMessageRequestParams/basic-request.json} + * + * @example Request with tools + * {@includeCode ./examples/CreateMessageRequestParams/request-with-tools.json} + * + * @example Follow-up request with tool results + * {@includeCode ./examples/CreateMessageRequestParams/follow-up-with-tool-results.json} + * + * @category `sampling/createMessage` + */ +export interface CreateMessageRequestParams extends TaskAugmentedRequestParams { + messages: SamplingMessage[]; + /** + * The server's preferences for which model to select. The client MAY ignore these preferences. + */ + modelPreferences?: ModelPreferences; + /** + * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt. + */ + systemPrompt?: string; + /** + * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. + * The client MAY ignore this request. + * + * Default is `"none"`. Values `"thisServer"` and `"allServers"` are soft-deprecated. Servers SHOULD only use these values if the client + * declares {@link ClientCapabilities.sampling.context}. These values may be removed in future spec releases. + */ + includeContext?: 'none' | 'thisServer' | 'allServers'; + /** + * @TJS-type number + */ + temperature?: number; + /** + * The requested maximum number of tokens to sample (to prevent runaway completions). + * + * The client MAY choose to sample fewer tokens than the requested maximum. + */ + maxTokens: number; + stopSequences?: string[]; + /** + * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific. + */ + metadata?: object; + /** + * Tools that the model may use during generation. + * The client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared. + */ + tools?: Tool[]; + /** + * Controls how the model uses tools. + * The client MUST return an error if this field is provided but {@link ClientCapabilities.sampling.tools} is not declared. + * Default is `{ mode: "auto" }`. + */ + toolChoice?: ToolChoice; +} + +/** + * Controls tool selection behavior for sampling requests. + * + * @category `sampling/createMessage` + */ +export interface ToolChoice { + /** + * Controls the tool use ability of the model: + * - `"auto"`: Model decides whether to use tools (default) + * - `"required"`: Model MUST use at least one tool before completing + * - `"none"`: Model MUST NOT use any tools + */ + mode?: 'auto' | 'required' | 'none'; +} + +/** + * A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it. + * + * @example Sampling request + * {@includeCode ./examples/CreateMessageRequest/sampling-request.json} + * + * @category `sampling/createMessage` + */ +export interface CreateMessageRequest extends JSONRPCRequest { + method: 'sampling/createMessage'; + params: CreateMessageRequestParams; +} + +/** + * The result returned by the client for a {@link CreateMessageRequest | sampling/createMessage} request. + * The client should inform the user before returning the sampled message, to allow them + * to inspect the response (human in the loop) and decide whether to allow the server to see it. + * + * @example Text response + * {@includeCode ./examples/CreateMessageResult/text-response.json} + * + * @example Tool use response + * {@includeCode ./examples/CreateMessageResult/tool-use-response.json} + * + * @example Final response after tool use + * {@includeCode ./examples/CreateMessageResult/final-response.json} + * + * @category `sampling/createMessage` + */ +export interface CreateMessageResult extends Result, SamplingMessage { + /** + * The name of the model that generated the message. + */ + model: string; + + /** + * The reason why sampling stopped, if known. + * + * Standard values: + * - `"endTurn"`: Natural end of the assistant's turn + * - `"stopSequence"`: A stop sequence was encountered + * - `"maxTokens"`: Maximum token limit was reached + * - `"toolUse"`: The model wants to use one or more tools + * + * This field is an open string to allow for provider-specific stop reasons. + */ + stopReason?: 'endTurn' | 'stopSequence' | 'maxTokens' | 'toolUse' | string; +} + +/** + * A successful response from the client for a {@link CreateMessageRequest | sampling/createMessage} request. + * + * @example Sampling result response + * {@includeCode ./examples/CreateMessageResultResponse/sampling-result-response.json} + * + * @category `sampling/createMessage` + */ +export interface CreateMessageResultResponse extends JSONRPCResultResponse { + result: CreateMessageResult; +} + +/** + * Describes a message issued to or received from an LLM API. + * + * @example Single content block + * {@includeCode ./examples/SamplingMessage/single-content-block.json} + * + * @example Multiple content blocks + * {@includeCode ./examples/SamplingMessage/multiple-content-blocks.json} + * + * @category `sampling/createMessage` + */ +export interface SamplingMessage { + role: Role; + content: SamplingMessageContentBlock | SamplingMessageContentBlock[]; + _meta?: MetaObject; +} +export type SamplingMessageContentBlock = + | TextContent + | ImageContent + | AudioContent + | ToolUseContent + | ToolResultContent; + +/** + * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed + * + * @category Common Types + */ +export interface Annotations { + /** + * Describes who the intended audience of this object or data is. + * + * It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). + */ + audience?: Role[]; + + /** + * Describes how important this data is for operating the server. + * + * A value of 1 means "most important," and indicates that the data is + * effectively required, while 0 means "least important," and indicates that + * the data is entirely optional. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + priority?: number; + + /** + * The moment the resource was last modified, as an ISO 8601 formatted string. + * + * Should be an ISO 8601 formatted string (e.g., "2025-01-12T15:00:58Z"). + * + * Examples: last activity timestamp in an open file, timestamp when the resource + * was attached, etc. + */ + lastModified?: string; +} + +/** + * @category Content + */ +export type ContentBlock = + | TextContent + | ImageContent + | AudioContent + | ResourceLink + | EmbeddedResource; + +/** + * Text provided to or from an LLM. + * + * @example Text content + * {@includeCode ./examples/TextContent/text-content.json} + * + * @category Content + */ +export interface TextContent { + type: 'text'; + + /** + * The text content of the message. + */ + text: string; + + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + + _meta?: MetaObject; +} + +/** + * An image provided to or from an LLM. + * + * @example `image/png` content with annotations + * {@includeCode ./examples/ImageContent/image-png-content-with-annotations.json} + * + * @category Content + */ +export interface ImageContent { + type: 'image'; + + /** + * The base64-encoded image data. + * + * @format byte + */ + data: string; + + /** + * The MIME type of the image. Different providers may support different image types. + */ + mimeType: string; + + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + + _meta?: MetaObject; +} + +/** + * Audio provided to or from an LLM. + * + * @example `audio/wav` content + * {@includeCode ./examples/AudioContent/audio-wav-content.json} + * + * @category Content + */ +export interface AudioContent { + type: 'audio'; + + /** + * The base64-encoded audio data. + * + * @format byte + */ + data: string; + + /** + * The MIME type of the audio. Different providers may support different audio types. + */ + mimeType: string; + + /** + * Optional annotations for the client. + */ + annotations?: Annotations; + + _meta?: MetaObject; +} + +/** + * A request from the assistant to call a tool. + * + * @example `get_weather` tool use + * {@includeCode ./examples/ToolUseContent/get-weather-tool-use.json} + * + * @category `sampling/createMessage` + */ +export interface ToolUseContent { + type: 'tool_use'; + + /** + * A unique identifier for this tool use. + * + * This ID is used to match tool results to their corresponding tool uses. + */ + id: string; + + /** + * The name of the tool to call. + */ + name: string; + + /** + * The arguments to pass to the tool, conforming to the tool's input schema. + */ + input: { [key: string]: unknown }; + + /** + * Optional metadata about the tool use. Clients SHOULD preserve this field when + * including tool uses in subsequent sampling requests to enable caching optimizations. + */ + _meta?: MetaObject; +} + +/** + * The result of a tool use, provided by the user back to the assistant. + * + * @example `get_weather` tool result + * {@includeCode ./examples/ToolResultContent/get-weather-tool-result.json} + * + * @category `sampling/createMessage` + */ +export interface ToolResultContent { + type: 'tool_result'; + + /** + * The ID of the tool use this result corresponds to. + * + * This MUST match the ID from a previous {@link ToolUseContent}. + */ + toolUseId: string; + + /** + * The unstructured result content of the tool use. + * + * This has the same format as {@link CallToolResult.content} and can include text, images, + * audio, resource links, and embedded resources. + */ + content: ContentBlock[]; + + /** + * An optional structured result object. + * + * If the tool defined an {@link Tool.outputSchema}, this SHOULD conform to that schema. + */ + structuredContent?: { [key: string]: unknown }; + + /** + * Whether the tool use resulted in an error. + * + * If true, the content typically describes the error that occurred. + * Default: false + */ + isError?: boolean; + + /** + * Optional metadata about the tool result. Clients SHOULD preserve this field when + * including tool results in subsequent sampling requests to enable caching optimizations. + */ + _meta?: MetaObject; +} + +/** + * The server's preferences for model selection, requested of the client during sampling. + * + * Because LLMs can vary along multiple dimensions, choosing the "best" model is + * rarely straightforward. Different models excel in different areas—some are + * faster but less capable, others are more capable but more expensive, and so + * on. This interface allows servers to express their priorities across multiple + * dimensions to help clients make an appropriate selection for their use case. + * + * These preferences are always advisory. The client MAY ignore them. It is also + * up to the client to decide how to interpret these preferences and how to + * balance them against other considerations. + * + * @example With hints and priorities + * {@includeCode ./examples/ModelPreferences/with-hints-and-priorities.json} + * + * @category `sampling/createMessage` + */ +export interface ModelPreferences { + /** + * Optional hints to use for model selection. + * + * If multiple hints are specified, the client MUST evaluate them in order + * (such that the first match is taken). + * + * The client SHOULD prioritize these hints over the numeric priorities, but + * MAY still use the priorities to select from ambiguous matches. + */ + hints?: ModelHint[]; + + /** + * How much to prioritize cost when selecting a model. A value of 0 means cost + * is not important, while a value of 1 means cost is the most important + * factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + costPriority?: number; + + /** + * How much to prioritize sampling speed (latency) when selecting a model. A + * value of 0 means speed is not important, while a value of 1 means speed is + * the most important factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + speedPriority?: number; + + /** + * How much to prioritize intelligence and capabilities when selecting a + * model. A value of 0 means intelligence is not important, while a value of 1 + * means intelligence is the most important factor. + * + * @TJS-type number + * @minimum 0 + * @maximum 1 + */ + intelligencePriority?: number; +} + +/** + * Hints to use for model selection. + * + * Keys not declared here are currently left unspecified by the spec and are up + * to the client to interpret. + * + * @category `sampling/createMessage` + */ +export interface ModelHint { + /** + * A hint for a model name. + * + * The client SHOULD treat this as a substring of a model name; for example: + * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022` + * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc. + * - `claude` should match any Claude model + * + * The client MAY also map the string to a different provider's model name or a different model family, as long as it fills a similar niche; for example: + * - `gemini-1.5-flash` could match `claude-3-haiku-20240307` + */ + name?: string; +} + +/* Autocomplete */ +/** + * Parameters for a `completion/complete` request. + * + * @category `completion/complete` + * + * @example Prompt argument completion + * {@includeCode ./examples/CompleteRequestParams/prompt-argument-completion.json} + * + * @example Prompt argument completion with context + * {@includeCode ./examples/CompleteRequestParams/prompt-argument-completion-with-context.json} + */ +export interface CompleteRequestParams extends RequestParams { + ref: PromptReference | ResourceTemplateReference; + /** + * The argument's information + */ + argument: { + /** + * The name of the argument + */ + name: string; + /** + * The value of the argument to use for completion matching. + */ + value: string; + }; + + /** + * Additional, optional context for completions + */ + context?: { + /** + * Previously-resolved variables in a URI template or prompt. + */ + arguments?: { [key: string]: string }; + }; +} + +/** + * A request from the client to the server, to ask for completion options. + * + * @example Completion request + * {@includeCode ./examples/CompleteRequest/completion-request.json} + * + * @category `completion/complete` + */ +export interface CompleteRequest extends JSONRPCRequest { + method: 'completion/complete'; + params: CompleteRequestParams; +} + +/** + * The result returned by the server for a {@link CompleteRequest | completion/complete} request. + * + * @category `completion/complete` + * + * @example Single completion value + * {@includeCode ./examples/CompleteResult/single-completion-value.json} + * + * @example Multiple completion values with more available + * {@includeCode ./examples/CompleteResult/multiple-completion-values-with-more-available.json} + */ +export interface CompleteResult extends Result { + completion: { + /** + * An array of completion values. Must not exceed 100 items. + */ + values: string[]; + /** + * The total number of completion options available. This can exceed the number of values actually sent in the response. + */ + total?: number; + /** + * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown. + */ + hasMore?: boolean; + }; +} + +/** + * A successful response from the server for a {@link CompleteRequest | completion/complete} request. + * + * @example Completion result response + * {@includeCode ./examples/CompleteResultResponse/completion-result-response.json} + * + * @category `completion/complete` + */ +export interface CompleteResultResponse extends JSONRPCResultResponse { + result: CompleteResult; +} + +/** + * A reference to a resource or resource template definition. + * + * @category `completion/complete` + */ +export interface ResourceTemplateReference { + type: 'ref/resource'; + /** + * The URI or URI template of the resource. + * + * @format uri-template + */ + uri: string; +} + +/** + * Identifies a prompt. + * + * @category `completion/complete` + */ +export interface PromptReference extends BaseMetadata { + type: 'ref/prompt'; +} + +/* Roots */ +/** + * Sent from the server to request a list of root URIs from the client. Roots allow + * servers to ask for specific directories or files to operate on. A common example + * for roots is providing a set of repositories or directories a server should operate + * on. + * + * This request is typically used when the server needs to understand the file system + * structure or access specific locations that the client has permission to read from. + * + * @example List roots request + * {@includeCode ./examples/ListRootsRequest/list-roots-request.json} + * + * @category `roots/list` + */ +export interface ListRootsRequest extends JSONRPCRequest { + method: 'roots/list'; + params?: RequestParams; +} + +/** + * The result returned by the client for a {@link ListRootsRequest | roots/list} request. + * This result contains an array of {@link Root} objects, each representing a root directory + * or file that the server can operate on. + * + * @example Single root directory + * {@includeCode ./examples/ListRootsResult/single-root-directory.json} + * + * @example Multiple root directories + * {@includeCode ./examples/ListRootsResult/multiple-root-directories.json} + * + * @category `roots/list` + */ +export interface ListRootsResult extends Result { + roots: Root[]; +} + +/** + * A successful response from the client for a {@link ListRootsRequest | roots/list} request. + * + * @example List roots result response + * {@includeCode ./examples/ListRootsResultResponse/list-roots-result-response.json} + * + * @category `roots/list` + */ +export interface ListRootsResultResponse extends JSONRPCResultResponse { + result: ListRootsResult; +} + +/** + * Represents a root directory or file that the server can operate on. + * + * @example Project directory root + * {@includeCode ./examples/Root/project-directory.json} + * + * @category `roots/list` + */ +export interface Root { + /** + * The URI identifying the root. This *must* start with `file://` for now. + * This restriction may be relaxed in future versions of the protocol to allow + * other URI schemes. + * + * @format uri + */ + uri: string; + /** + * An optional name for the root. This can be used to provide a human-readable + * identifier for the root, which may be useful for display purposes or for + * referencing the root in other parts of the application. + */ + name?: string; + + _meta?: MetaObject; +} + +/** + * A notification from the client to the server, informing it that the list of roots has changed. + * This notification should be sent whenever the client adds, removes, or modifies any root. + * The server should then request an updated list of roots using the {@link ListRootsRequest}. + * + * @example Roots list changed + * {@includeCode ./examples/RootsListChangedNotification/roots-list-changed.json} + * + * @category `notifications/roots/list_changed` + */ +export interface RootsListChangedNotification extends JSONRPCNotification { + method: 'notifications/roots/list_changed'; + params?: NotificationParams; +} + +/** + * The parameters for a request to elicit non-sensitive information from the user via a form in the client. + * + * @example Elicit single field + * {@includeCode ./examples/ElicitRequestFormParams/elicit-single-field.json} + * + * @example Elicit multiple fields + * {@includeCode ./examples/ElicitRequestFormParams/elicit-multiple-fields.json} + * + * @category `elicitation/create` + */ +export interface ElicitRequestFormParams extends TaskAugmentedRequestParams { + /** + * The elicitation mode. + */ + mode?: 'form'; + + /** + * The message to present to the user describing what information is being requested. + */ + message: string; + + /** + * A restricted subset of JSON Schema. + * Only top-level properties are allowed, without nesting. + */ + requestedSchema: { + $schema?: string; + type: 'object'; + properties: { + [key: string]: PrimitiveSchemaDefinition; + }; + required?: string[]; + }; +} + +/** + * The parameters for a request to elicit information from the user via a URL in the client. + * + * @example Elicit sensitive data + * {@includeCode ./examples/ElicitRequestURLParams/elicit-sensitive-data.json} + * + * @category `elicitation/create` + */ +export interface ElicitRequestURLParams extends TaskAugmentedRequestParams { + /** + * The elicitation mode. + */ + mode: 'url'; + + /** + * The message to present to the user explaining why the interaction is needed. + */ + message: string; + + /** + * The ID of the elicitation, which must be unique within the context of the server. + * The client MUST treat this ID as an opaque value. + */ + elicitationId: string; + + /** + * The URL that the user should navigate to. + * + * @format uri + */ + url: string; +} + +/** + * The parameters for a request to elicit additional information from the user via the client. + * + * @category `elicitation/create` + */ +export type ElicitRequestParams = + | ElicitRequestFormParams + | ElicitRequestURLParams; + +/** + * A request from the server to elicit additional information from the user via the client. + * + * @example Elicitation request + * {@includeCode ./examples/ElicitRequest/elicitation-request.json} + * + * @category `elicitation/create` + */ +export interface ElicitRequest extends JSONRPCRequest { + method: 'elicitation/create'; + params: ElicitRequestParams; +} + +/** + * Restricted schema definitions that only allow primitive types + * without nested objects or arrays. + * + * @category `elicitation/create` + */ +export type PrimitiveSchemaDefinition = + | StringSchema + | NumberSchema + | BooleanSchema + | EnumSchema; + +/** + * @example Email input schema + * {@includeCode ./examples/StringSchema/email-input-schema.json} + * + * @category `elicitation/create` + */ +export interface StringSchema { + type: 'string'; + title?: string; + description?: string; + minLength?: number; + maxLength?: number; + format?: 'email' | 'uri' | 'date' | 'date-time'; + default?: string; +} + +/** + * @example Number input schema + * {@includeCode ./examples/NumberSchema/number-input-schema.json} + * + * @category `elicitation/create` + */ +export interface NumberSchema { + type: 'number' | 'integer'; + title?: string; + description?: string; + minimum?: number; + maximum?: number; + default?: number; +} + +/** + * @example Boolean input schema + * {@includeCode ./examples/BooleanSchema/boolean-input-schema.json} + * + * @category `elicitation/create` + */ +export interface BooleanSchema { + type: 'boolean'; + title?: string; + description?: string; + default?: boolean; +} + +/** + * Schema for single-selection enumeration without display titles for options. + * + * @example Color select schema + * {@includeCode ./examples/UntitledSingleSelectEnumSchema/color-select-schema.json} + * + * @category `elicitation/create` + */ +export interface UntitledSingleSelectEnumSchema { + type: 'string'; + /** + * Optional title for the enum field. + */ + title?: string; + /** + * Optional description for the enum field. + */ + description?: string; + /** + * Array of enum values to choose from. + */ + enum: string[]; + /** + * Optional default value. + */ + default?: string; +} + +/** + * Schema for single-selection enumeration with display titles for each option. + * + * @example Titled color select schema + * {@includeCode ./examples/TitledSingleSelectEnumSchema/titled-color-select-schema.json} + * + * @category `elicitation/create` + */ +export interface TitledSingleSelectEnumSchema { + type: 'string'; + /** + * Optional title for the enum field. + */ + title?: string; + /** + * Optional description for the enum field. + */ + description?: string; + /** + * Array of enum options with values and display labels. + */ + oneOf: Array<{ + /** + * The enum value. + */ + const: string; + /** + * Display label for this option. + */ + title: string; + }>; + /** + * Optional default value. + */ + default?: string; +} + +/** + * @category `elicitation/create` + */ +// Combined single selection enumeration +export type SingleSelectEnumSchema = + | UntitledSingleSelectEnumSchema + | TitledSingleSelectEnumSchema; + +/** + * Schema for multiple-selection enumeration without display titles for options. + * + * @example Color multi-select schema + * {@includeCode ./examples/UntitledMultiSelectEnumSchema/color-multi-select-schema.json} + * + * @category `elicitation/create` + */ +export interface UntitledMultiSelectEnumSchema { + type: 'array'; + /** + * Optional title for the enum field. + */ + title?: string; + /** + * Optional description for the enum field. + */ + description?: string; + /** + * Minimum number of items to select. + */ + minItems?: number; + /** + * Maximum number of items to select. + */ + maxItems?: number; + /** + * Schema for the array items. + */ + items: { + type: 'string'; + /** + * Array of enum values to choose from. + */ + enum: string[]; + }; + /** + * Optional default value. + */ + default?: string[]; +} + +/** + * Schema for multiple-selection enumeration with display titles for each option. + * + * @example Titled color multi-select schema + * {@includeCode ./examples/TitledMultiSelectEnumSchema/titled-color-multi-select-schema.json} + * + * @category `elicitation/create` + */ +export interface TitledMultiSelectEnumSchema { + type: 'array'; + /** + * Optional title for the enum field. + */ + title?: string; + /** + * Optional description for the enum field. + */ + description?: string; + /** + * Minimum number of items to select. + */ + minItems?: number; + /** + * Maximum number of items to select. + */ + maxItems?: number; + /** + * Schema for array items with enum options and display labels. + */ + items: { + /** + * Array of enum options with values and display labels. + */ + anyOf: Array<{ + /** + * The constant enum value. + */ + const: string; + /** + * Display title for this option. + */ + title: string; + }>; + }; + /** + * Optional default value. + */ + default?: string[]; +} + +/** + * @category `elicitation/create` + */ +// Combined multiple selection enumeration +export type MultiSelectEnumSchema = + | UntitledMultiSelectEnumSchema + | TitledMultiSelectEnumSchema; + +/** + * Use {@link TitledSingleSelectEnumSchema} instead. + * This interface will be removed in a future version. + * + * @category `elicitation/create` + */ +export interface LegacyTitledEnumSchema { + type: 'string'; + title?: string; + description?: string; + enum: string[]; + /** + * (Legacy) Display names for enum values. + * Non-standard according to JSON schema 2020-12. + */ + enumNames?: string[]; + default?: string; +} + +/** + * @category `elicitation/create` + */ +// Union type for all enum schemas +export type EnumSchema = + | SingleSelectEnumSchema + | MultiSelectEnumSchema + | LegacyTitledEnumSchema; + +/** + * The result returned by the client for an {@link ElicitRequest | elicitation/create} request. + * + * @example Input single field + * {@includeCode ./examples/ElicitResult/input-single-field.json} + * + * @example Input multiple fields + * {@includeCode ./examples/ElicitResult/input-multiple-fields.json} + * + * @example Accept URL mode (no content) + * {@includeCode ./examples/ElicitResult/accept-url-mode-no-content.json} + * + * @category `elicitation/create` + */ +export interface ElicitResult extends Result { + /** + * The user action in response to the elicitation. + * - `"accept"`: User submitted the form/confirmed the action + * - `"decline"`: User explicitly declined the action + * - `"cancel"`: User dismissed without making an explicit choice + */ + action: 'accept' | 'decline' | 'cancel'; + + /** + * The submitted form data, only present when action is `"accept"` and mode was `"form"`. + * Contains values matching the requested schema. + * Omitted for out-of-band mode responses. + */ + content?: { [key: string]: string | number | boolean | string[] }; +} + +/** + * A successful response from the client for a {@link ElicitRequest | elicitation/create} request. + * + * @example Elicitation result response + * {@includeCode ./examples/ElicitResultResponse/elicitation-result-response.json} + * + * @category `elicitation/create` + */ +export interface ElicitResultResponse extends JSONRPCResultResponse { + result: ElicitResult; +} + +/** + * An optional notification from the server to the client, informing it of a completion of a out-of-band elicitation request. + * + * @example Elicitation complete + * {@includeCode ./examples/ElicitationCompleteNotification/elicitation-complete.json} + * + * @category `notifications/elicitation/complete` + */ +export interface ElicitationCompleteNotification extends JSONRPCNotification { + method: 'notifications/elicitation/complete'; + params: { + /** + * The ID of the elicitation that completed. + */ + elicitationId: string; + }; +} + +/* Client messages */ +/** @internal */ +export type ClientRequest = + | PingRequest + | InitializeRequest + | CompleteRequest + | SetLevelRequest + | GetPromptRequest + | ListPromptsRequest + | ListResourcesRequest + | ListResourceTemplatesRequest + | ReadResourceRequest + | SubscribeRequest + | UnsubscribeRequest + | CallToolRequest + | ListToolsRequest + | GetTaskRequest + | GetTaskPayloadRequest + | ListTasksRequest + | CancelTaskRequest; + +/** @internal */ +export type ClientNotification = + | CancelledNotification + | ProgressNotification + | InitializedNotification + | RootsListChangedNotification + | TaskStatusNotification; + +/** @internal */ +export type ClientResult = + | EmptyResult + | CreateMessageResult + | ListRootsResult + | ElicitResult + | GetTaskResult + | GetTaskPayloadResult + | ListTasksResult + | CancelTaskResult; + +/* Server messages */ +/** @internal */ +export type ServerRequest = + | PingRequest + | CreateMessageRequest + | ListRootsRequest + | ElicitRequest + | GetTaskRequest + | GetTaskPayloadRequest + | ListTasksRequest + | CancelTaskRequest; + +/** @internal */ +export type ServerNotification = + | CancelledNotification + | ProgressNotification + | LoggingMessageNotification + | ResourceUpdatedNotification + | ResourceListChangedNotification + | ToolListChangedNotification + | PromptListChangedNotification + | ElicitationCompleteNotification + | TaskStatusNotification; + +/** @internal */ +export type ServerResult = + | EmptyResult + | InitializeResult + | CompleteResult + | GetPromptResult + | ListPromptsResult + | ListResourceTemplatesResult + | ListResourcesResult + | ReadResourceResult + | CallToolResult + | ListToolsResult + | GetTaskResult + | GetTaskPayloadResult + | ListTasksResult + | CancelTaskResult; diff --git a/src/schema-utils.mjs b/src/schema-utils.ts similarity index 61% rename from src/schema-utils.mjs rename to src/schema-utils.ts index 2a2c369..b7bd774 100644 --- a/src/schema-utils.mjs +++ b/src/schema-utils.ts @@ -5,13 +5,15 @@ */ import { z } from 'zod'; +import type { JSONSchema7, JSONSchema7Type } from 'json-schema'; +import { JSONSchema } from './types'; /** * Convert Zod schema to JSON Schema */ -export function zodToJsonSchema(zodSchema) { - const properties = {}; - const required = []; +export function zodToJsonSchema(zodSchema: z.ZodRawShape): JSONSchema { + const properties: Record = {}; + const required: string[] = []; for (const [key, schema] of Object.entries(zodSchema)) { properties[key] = convertZodTypeToJsonSchema(schema); @@ -31,26 +33,34 @@ export function zodToJsonSchema(zodSchema) { /** * Convert individual Zod type to JSON Schema */ -function convertZodTypeToJsonSchema(zodType) { +function convertZodTypeToJsonSchema(zodType: z.ZodTypeAny): JSONSchema7 { + type ZodCheck = { kind: string; value?: number }; + // Handle ZodOptional if (zodType instanceof z.ZodOptional) { - return convertZodTypeToJsonSchema(zodType._def.innerType); + const def = zodType._def as unknown as { innerType: z.ZodTypeAny }; + return convertZodTypeToJsonSchema(def.innerType); } // Handle ZodDefault if (zodType instanceof z.ZodDefault) { - const schema = convertZodTypeToJsonSchema(zodType._def.innerType); - schema.default = zodType._def.defaultValue(); + const def = zodType._def as unknown as { + innerType: z.ZodTypeAny; + defaultValue: () => unknown; + }; + const schema = convertZodTypeToJsonSchema(def.innerType); + schema.default = def.defaultValue() as JSONSchema7Type; return schema; } // Handle ZodString if (zodType instanceof z.ZodString) { - const schema = { type: 'string' }; + const schema: JSONSchema7 = { type: 'string' }; // Add constraints - if (zodType._def.checks) { - for (const check of zodType._def.checks) { + const def = zodType._def as unknown as { checks?: ZodCheck[] }; + if (def.checks) { + for (const check of def.checks) { switch (check.kind) { case 'min': schema.minLength = check.value; @@ -80,10 +90,11 @@ function convertZodTypeToJsonSchema(zodType) { // Handle ZodNumber if (zodType instanceof z.ZodNumber) { - const schema = { type: 'number' }; + const schema: JSONSchema7 = { type: 'number' }; - if (zodType._def.checks) { - for (const check of zodType._def.checks) { + const def = zodType._def as unknown as { checks?: ZodCheck[] }; + if (def.checks) { + for (const check of def.checks) { switch (check.kind) { case 'min': schema.minimum = check.value; @@ -107,7 +118,7 @@ function convertZodTypeToJsonSchema(zodType) { // Handle ZodBoolean if (zodType instanceof z.ZodBoolean) { - const schema = { type: 'boolean' }; + const schema: JSONSchema7 = { type: 'boolean' }; if (zodType.description) { schema.description = zodType.description; @@ -118,9 +129,10 @@ function convertZodTypeToJsonSchema(zodType) { // Handle ZodEnum if (zodType instanceof z.ZodEnum) { - const schema = { + const def = zodType._def as unknown as { values: string[] }; + const schema: JSONSchema7 = { type: 'string', - enum: zodType._def.values, + enum: def.values, }; if (zodType.description) { @@ -132,10 +144,10 @@ function convertZodTypeToJsonSchema(zodType) { // Handle ZodArray if (zodType instanceof z.ZodArray) { - const schema = { + const schema: JSONSchema7 = { type: 'array', items: convertZodTypeToJsonSchema(zodType._def.type), - }; + } ; if (zodType._def.minLength) { schema.minItems = zodType._def.minLength.value; @@ -167,43 +179,50 @@ function convertZodTypeToJsonSchema(zodType) { /** * Check if Zod type is optional */ -export function isZodOptional(zodType) { +export function isZodOptional(zodType: z.ZodTypeAny): boolean { return zodType instanceof z.ZodOptional || zodType instanceof z.ZodDefault; } /** * Check if Zod type has default value */ -export function hasZodDefault(zodType) { +export function hasZodDefault(zodType: z.ZodTypeAny): boolean { return zodType instanceof z.ZodDefault; } /** * Validate arguments with Zod schema */ -export function validateWithZod(zodSchema, args) { - const validated = {}; +export function validateWithZod( + zodSchema: T, + args: Record +): z.infer> { + const validated: Partial>> = {}; for (const [key, schema] of Object.entries(zodSchema)) { try { - if (args[key] === undefined && isZodOptional(schema)) { + if (args[key] === undefined && isZodOptional(schema as z.ZodTypeAny)) { if (hasZodDefault(schema)) { - validated[key] = schema.parse(undefined); + validated[key as keyof typeof validated] = ( + schema as z.ZodDefault + ).parse(undefined); } continue; } - validated[key] = schema.parse(args[key]); + validated[key as keyof typeof validated] = ( + schema as z.ZodTypeAny + ).parse(args[key]); } catch (error) { throw new z.ZodError([ { code: 'custom', path: [key], - message: `${error.message}`, + message: error instanceof Error ? error.message : String(error), }, ]); } } - return validated; + return validated as z.infer>; } diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 0000000..2365414 --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,8 @@ +// This is the generic json schema type used in the mcp spec + +export type JSONSchema = { + $schema?: string; + type: 'object'; + properties?: { [key: string]: object }; + required?: string[]; +}; diff --git a/tests/basic.test.mjs b/tests/basic.test.mjs deleted file mode 100644 index 8f74d85..0000000 --- a/tests/basic.test.mjs +++ /dev/null @@ -1,334 +0,0 @@ -/** - * Basic tests for lambda-mcp-adaptor - */ - -import { expect } from 'chai'; -import { createMCPServer, createLambdaHandler } from '../src/index.mjs'; -import { z } from 'zod'; - -describe('lambda-mcp-adaptor', function() { - let server; - - beforeEach(function() { - server = createMCPServer({ - name: 'Test Server', - version: '1.0.0', - description: 'Test MCP Server' - }); - }); - - describe('MCPServer', function() { - it('should create server with correct config', function() { - expect(server.config.name).to.equal('Test Server'); - expect(server.config.version).to.equal('1.0.0'); - expect(server.config.protocolVersion).to.equal('2025-03-26'); - }); - - it('should register tools with method chaining', function() { - const result = server - .tool('test1', { input: z.string() }, async ({ input }) => ({ content: [{ type: 'text', text: input }] })) - .tool('test2', { value: z.number() }, async ({ value }) => ({ content: [{ type: 'text', text: value.toString() }] })); - - expect(result).to.equal(server); - expect(server.tools.size).to.equal(2); - expect(server.tools.has('test1')).to.be.true; - expect(server.tools.has('test2')).to.be.true; - }); - - it('should handle initialize request', async function() { - server.tool('test', { input: z.string() }, async ({ input }) => ({ content: [{ type: 'text', text: input }] })); - - const result = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'initialize', - params: { - protocolVersion: '2025-03-26', - capabilities: {}, - clientInfo: { name: 'test', version: '1.0.0' } - } - }); - - expect(result.protocolVersion).to.equal('2025-03-26'); - expect(result.serverInfo.name).to.equal('Test Server'); - expect(result.capabilities.tools).to.deep.equal({ listChanged: true }); - }); - - it('should handle tools/list request', async function() { - server.tool('calculate', { - a: z.number(), - b: z.number() - }, async ({ a, b }) => ({ content: [{ type: 'text', text: (a + b).toString() }] })); - - const result = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'tools/list' - }); - - expect(result.tools).to.be.an('array'); - expect(result.tools).to.have.length(1); - expect(result.tools[0].name).to.equal('calculate'); - expect(result.tools[0].inputSchema.type).to.equal('object'); - expect(result.tools[0].inputSchema.properties).to.have.property('a'); - expect(result.tools[0].inputSchema.properties).to.have.property('b'); - }); - - it('should handle tools/call request with validation', async function() { - server.tool('add', { - a: z.number(), - b: z.number() - }, async ({ a, b }) => ({ content: [{ type: 'text', text: `${a} + ${b} = ${a + b}` }] })); - - const result = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'tools/call', - params: { - name: 'add', - arguments: { a: 5, b: 3 } - } - }); - - expect(result.content).to.be.an('array'); - expect(result.content[0].text).to.equal('5 + 3 = 8'); - }); - - it('should validate tool arguments with Zod', async function() { - server.tool('validate_test', { - email: z.string().email(), - age: z.number().int().positive() - }, async ({ email, age }) => ({ content: [{ type: 'text', text: `${email}: ${age}` }] })); - - // Valid arguments - const validResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'tools/call', - params: { - name: 'validate_test', - arguments: { email: 'test@example.com', age: 25 } - } - }); - - expect(validResult.content[0].text).to.equal('test@example.com: 25'); - - // Invalid arguments should return error response - const errorResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 2, - method: 'tools/call', - params: { - name: 'validate_test', - arguments: { email: 'invalid-email', age: -5 } - } - }); - - expect(errorResult.isError).to.be.true; - expect(errorResult.content[0].text).to.include('Validation error'); - }); - - it('should handle optional parameters with defaults', async function() { - server.tool('optional_test', { - required: z.string(), - optional: z.string().optional(), - withDefault: z.number().optional().default(42) - }, async ({ required, optional, withDefault }) => ({ - content: [{ type: 'text', text: `${required}, ${optional || 'none'}, ${withDefault}` }] - })); - - const result = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'tools/call', - params: { - name: 'optional_test', - arguments: { required: 'test' } - } - }); - - expect(result.content[0].text).to.equal('test, none, 42'); - }); - - it('should handle enum validation', async function() { - server.tool('enum_test', { - operation: z.enum(['add', 'subtract', 'multiply']) - }, async ({ operation }) => ({ content: [{ type: 'text', text: operation }] })); - - // Valid enum value - const validResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'tools/call', - params: { - name: 'enum_test', - arguments: { operation: 'add' } - } - }); - - expect(validResult.content[0].text).to.equal('add'); - - // Invalid enum value should return error response - const enumErrorResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 2, - method: 'tools/call', - params: { - name: 'enum_test', - arguments: { operation: 'invalid' } - } - }); - - expect(enumErrorResult.isError).to.be.true; - expect(enumErrorResult.content[0].text).to.include('Validation error'); - }); - - it('should register and handle resources', async function() { - server.resource('test-resource', 'test://resource', async (uri) => ({ - contents: [{ uri, text: 'Resource content', mimeType: 'text/plain' }] - })); - - const listResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'resources/list' - }); - - expect(listResult.resources).to.have.length(1); - expect(listResult.resources[0].name).to.equal('test-resource'); - - const readResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 2, - method: 'resources/read', - params: { uri: 'test://resource' } - }); - - expect(readResult.contents[0].text).to.equal('Resource content'); - }); - - it('should register and handle prompts', async function() { - server.prompt('test-prompt', { - input: z.string(), - context: z.string().optional() - }, ({ input, context }) => ({ - messages: [{ - role: 'user', - content: { type: 'text', text: `Process: ${input}${context ? ` (${context})` : ''}` } - }] - })); - - const listResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 1, - method: 'prompts/list' - }); - - expect(listResult.prompts).to.have.length(1); - expect(listResult.prompts[0].name).to.equal('test-prompt'); - - const getResult = await server.handleRequest({ - jsonrpc: '2.0', - id: 2, - method: 'prompts/get', - params: { - name: 'test-prompt', - arguments: { input: 'test input', context: 'test context' } - } - }); - - expect(getResult.messages[0].content.text).to.equal('Process: test input (test context)'); - }); - }); - - describe('Lambda Handler', function() { - it('should create Lambda handler', function() { - const handler = createLambdaHandler(server); - expect(handler).to.be.a('function'); - }); - - it('should handle OPTIONS request (CORS)', async function() { - const handler = createLambdaHandler(server); - - const result = await handler({ - httpMethod: 'OPTIONS', - headers: {} - }); - - expect(result.statusCode).to.equal(200); - expect(result.headers['Access-Control-Allow-Origin']).to.equal('*'); - expect(result.headers['Access-Control-Allow-Methods']).to.include('POST'); - }); - - it('should handle POST request with MCP message', async function() { - server.tool('test', { input: z.string() }, async ({ input }) => ({ content: [{ type: 'text', text: input }] })); - - const handler = createLambdaHandler(server); - - const result = await handler({ - httpMethod: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - jsonrpc: '2.0', - id: 1, - method: 'tools/list' - }) - }); - - expect(result.statusCode).to.equal(200); - expect(result.headers['Content-Type']).to.equal('application/json'); - - const response = JSON.parse(result.body); - expect(response.jsonrpc).to.equal('2.0'); - expect(response.id).to.equal(1); - expect(response.result.tools).to.be.an('array'); - }); - - it('should handle invalid JSON', async function() { - const handler = createLambdaHandler(server); - - const result = await handler({ - httpMethod: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: 'invalid json' - }); - - expect(result.statusCode).to.equal(400); - - const response = JSON.parse(result.body); - expect(response.error.code).to.equal(-32700); - expect(response.error.message).to.include('Parse error'); - }); - - it('should handle missing Content-Type', async function() { - const handler = createLambdaHandler(server); - - const result = await handler({ - httpMethod: 'POST', - headers: {}, - body: '{}' - }); - - expect(result.statusCode).to.equal(400); - - const response = JSON.parse(result.body); - expect(response.error.code).to.equal(-32700); - expect(response.error.message).to.include('Content-Type'); - }); - - it('should handle GET request (not allowed)', async function() { - const handler = createLambdaHandler(server); - - const result = await handler({ - httpMethod: 'GET', - headers: {} - }); - - expect(result.statusCode).to.equal(405); - - const response = JSON.parse(result.body); - expect(response.error.code).to.equal(-32000); - expect(response.error.message).to.include('Method not allowed'); - }); - }); -}); diff --git a/tests/basic.test.ts b/tests/basic.test.ts new file mode 100644 index 0000000..57b06cf --- /dev/null +++ b/tests/basic.test.ts @@ -0,0 +1,471 @@ +/** + * Basic tests for lambda-mcp-adaptor + */ + +import { beforeEach, describe, expect, it } from 'vitest'; +import { createMCPServer, createLambdaHandler } from '../src'; +import { z } from 'zod'; +import type { MCPServer } from '../src'; +import type { Context } from 'aws-lambda'; +import type { + BlobResourceContents, + ContentBlock, + TextContent, + TextResourceContents, +} from '../src/mcp-spec'; + +type LambdaEvent = Parameters>[0]; + +function asLambdaEvent(event: Partial): LambdaEvent { + return event as LambdaEvent; +} + +function assertTextContent(block: ContentBlock): asserts block is TextContent { + if (block.type !== 'text') { + throw new Error(`Expected text content, got ${block.type}`); + } +} + +function assertTextResourceContents( + content: TextResourceContents | BlobResourceContents +): asserts content is TextResourceContents { + if (!('text' in content)) { + throw new Error('Expected text resource contents'); + } +} + +describe('lambda-mcp-adaptor', () => { + let server: MCPServer; + + beforeEach(() => { + server = createMCPServer({ + name: 'Test Server', + version: '1.0.0', + description: 'Test MCP Server' + }); + }); + + describe('MCPServer', () => { + it('should create server with correct config', () => { + expect(server.config.name).toBe('Test Server'); + expect(server.config.version).toBe('1.0.0'); + expect(server.config.protocolVersion).toBe('2025-03-26'); + }); + + it('should register tools with method chaining', () => { + const result = server + .tool('test1', { input: z.string() }, async ({ input }) => ({ content: [{ type: 'text', text: input }] })) + .tool('test2', { value: z.number() }, async ({ value }) => ({ content: [{ type: 'text', text: value.toString() }] })); + + expect(result).toBe(server); + expect(server.tools.size).toBe(2); + expect(server.tools.has('test1')).toBe(true); + expect(server.tools.has('test2')).toBe(true); + }); + + it('should handle initialize request', async () => { + server.tool('test', { input: z.string() }, async ({ input }) => ({ content: [{ type: 'text', text: input }] })); + + const result = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'initialize', + params: { + protocolVersion: '2025-03-26', + capabilities: {}, + clientInfo: { name: 'test', version: '1.0.0' } + } + }); + + if (!result) { + throw new Error('Unexpected error'); + } + expect(result.protocolVersion).toBe('2025-03-26'); + expect(result.serverInfo.name).toBe('Test Server'); + expect(result.capabilities.tools).toEqual({ listChanged: true }); + }); + + it('should handle tools/list request', async () => { + server.tool('calculate', { + a: z.number(), + b: z.number() + }, async ({ a, b }) => ({ content: [{ type: 'text', text: (a + b).toString() }] })); + + const result = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/list' + }); + if (!result) { + throw new Error('Unexpected error'); + } + expect(Array.isArray(result.tools)).toBe(true); + expect(result.tools).toHaveLength(1); + expect(result.tools[0].name).toBe('calculate'); + expect(result.tools[0].inputSchema.type).toBe('object'); + expect(result.tools[0].inputSchema.properties).toHaveProperty('a'); + expect(result.tools[0].inputSchema.properties).toHaveProperty('b'); + }); + + it('should handle tools/call request with validation', async () => { + server.tool('add', { + a: z.number(), + b: z.number() + }, async ({ a, b }) => ({ content: [{ type: 'text', text: `${a} + ${b} = ${a + b}` }] })); + + const result = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { + name: 'add', + arguments: { a: 5, b: 3 } + } + }); + + if (!result) { + throw new Error('Unexpected error'); + } + expect(Array.isArray(result.content)).toBe(true); + assertTextContent(result.content[0]); + expect(result.content[0].text).toBe('5 + 3 = 8'); + }); + + it('should validate tool arguments with Zod', async () => { + server.tool('validate_test', { + email: z.string().email(), + age: z.number().int().positive() + }, async ({ email, age }) => ({ content: [{ type: 'text', text: `${email}: ${age}` }] })); + + // Valid arguments + const validResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { + name: 'validate_test', + arguments: { email: 'test@example.com', age: 25 } + } + }); + + if (!validResult) { + throw new Error('Unexpected error'); + } + assertTextContent(validResult.content[0]); + expect(validResult.content[0].text).toBe('test@example.com: 25'); + + // Invalid arguments should return error response + const errorResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 2, + method: 'tools/call', + params: { + name: 'validate_test', + arguments: { email: 'invalid-email', age: -5 } + } + }); + + if (!errorResult) { + throw new Error('Unexpected error'); + } + expect(errorResult.isError).toBe(true); + assertTextContent(errorResult.content[0]); + expect(errorResult.content[0].text).toContain('Validation error'); + }); + + it('should handle optional parameters with defaults', async () => { + server.tool('optional_test', { + required: z.string(), + optional: z.string().optional(), + withDefault: z.number().optional().default(42) + }, async ({ required, optional, withDefault }) => ({ + content: [{ type: 'text', text: `${required}, ${optional || 'none'}, ${withDefault}` }] + })); + + const result = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { + name: 'optional_test', + arguments: { required: 'test' } + } + }); + + if (!result) { + throw new Error('Unexpected error'); + } + + assertTextContent(result.content[0]); + expect(result.content[0].text).toBe('test, none, 42'); + }); + + it('should handle tool call with structured output', async () => { + server.tool('structured_test', { + input: z.string() + }, async ({ input }) => { + return { + content: [ + { type: 'text', text: input }, + ], + structuredContent: {result: input} + } + }, {outputZodSchema: z.object({result: z.string()}).shape, annotations: {title: 'human title'}}); + + const result = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { + name: 'structured_test', + arguments: { input: 'test' }, + }, + }); + expect(result.structuredContent?.result).toBe('test'); + + const listResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/list', + }); + expect(listResult).toEqual({ + tools: [ + { + name: 'structured_test', + description: 'Tool: structured_test', + annotations: { + title: 'human title', + }, + inputSchema: { + type: 'object', + properties: { + input: { + type: 'string', + }, + }, + required: ['input'], + }, + outputSchema: { + type: 'object', + properties: { + result: { + type: 'string', + }, + }, + required: ['result'], + }, + }, + ], + }); + }) + + it('should handle enum validation', async () => { + server.tool('enum_test', { + operation: z.enum(['add', 'subtract', 'multiply']) + }, async ({ operation }) => ({ content: [{ type: 'text', text: operation }] })); + + // Valid enum value + const validResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'tools/call', + params: { + name: 'enum_test', + arguments: { operation: 'add' } + } + }); + + if (!validResult) { + throw new Error('Unexpected error'); + } + + assertTextContent(validResult.content[0]); + expect(validResult.content[0].text).toBe('add'); + + // Invalid enum value should return error response + const enumErrorResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 2, + method: 'tools/call', + params: { + name: 'enum_test', + arguments: { operation: 'invalid' } + } + }); + + if(!enumErrorResult) { + throw new Error('Unexpected error'); + } + expect(enumErrorResult.isError).toBe(true); + assertTextContent(enumErrorResult.content[0]); + expect(enumErrorResult.content[0].text).toContain('Validation error'); + }); + + it('should register and handle resources', async () => { + server.resource('test-resource', 'test://resource', async (uri) => ({ + contents: [{ uri, text: 'Resource content', mimeType: 'text/plain' }] + })); + + const listResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'resources/list' + }); + + if(!listResult) throw new Error( + 'Unexpected error' + ) + expect(listResult.resources).toHaveLength(1); + expect(listResult.resources[0].name).toBe('test-resource'); + + const readResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 2, + method: 'resources/read', + params: { uri: 'test://resource' } + }); + + if(!readResult) { + throw new Error('Unexpected error'); + } + assertTextResourceContents(readResult.contents[0]); + expect(readResult.contents[0].text).toBe('Resource content'); + }); + + it('should register and handle prompts', async () => { + server.prompt('test-prompt', { + input: z.string(), + context: z.string().optional() + }, ({ input, context }) => ({ + messages: [{ + role: 'user', + content: { type: 'text', text: `Process: ${input}${context ? ` (${context})` : ''}` } + }] + })); + + const listResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 1, + method: 'prompts/list' + }); + + if (!listResult) { + throw new Error('Unexpected error'); + } + + expect(listResult.prompts).toHaveLength(1); + expect(listResult.prompts[0].name).toBe('test-prompt'); + + const getResult = await server.handleRequest({ + jsonrpc: '2.0', + id: 2, + method: 'prompts/get', + params: { + name: 'test-prompt', + arguments: { input: 'test input', context: 'test context' } + } + }); + + if (!getResult) { + throw new Error('Unexpected error'); + } + assertTextContent(getResult.messages[0].content); + expect(getResult.messages[0].content.text).toBe('Process: test input (test context)'); + }); + }); + + describe('Lambda Handler', () => { + const context = {} as Context; + + it('should create Lambda handler', () => { + const handler = createLambdaHandler(server); + expect(handler).toBeTypeOf('function'); + }); + + it('should handle OPTIONS request (CORS)', async () => { + const handler = createLambdaHandler(server); + + const result = await handler(asLambdaEvent({ + httpMethod: 'OPTIONS', + headers: {} + }), context); + + expect(result.statusCode).toBe(200); + const headers = result.headers ?? {}; + expect(headers['Access-Control-Allow-Origin']).toBe('*'); + expect(headers['Access-Control-Allow-Methods']).toContain('POST'); + }); + + it('should handle POST request with MCP message', async () => { + server.tool('test', { input: z.string() }, async ({ input }) => ({ content: [{ type: 'text', text: input }] })); + + const handler = createLambdaHandler(server); + + const result = await handler(asLambdaEvent({ + httpMethod: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + jsonrpc: '2.0', + id: 1, + method: 'tools/list' + }) + }), context); + + expect(result.statusCode).toBe(200); + const headers = result.headers ?? {}; + expect(headers['Content-Type']).toBe('application/json'); + + const response = JSON.parse(result.body); + expect(response.jsonrpc).toBe('2.0'); + expect(response.id).toBe(1); + expect(Array.isArray(response.result.tools)).toBe(true); + }); + + it('should handle invalid JSON', async () => { + const handler = createLambdaHandler(server); + + const result = await handler(asLambdaEvent({ + httpMethod: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: 'invalid json' + }), context); + + expect(result.statusCode).toBe(400); + + const response = JSON.parse(result.body); + expect(response.error.code).toBe(-32700); + expect(response.error.message).toContain('Parse error'); + }); + + it('should handle missing Content-Type', async () => { + const handler = createLambdaHandler(server); + + const result = await handler(asLambdaEvent({ + httpMethod: 'POST', + headers: {}, + body: '{}' + }), context); + + expect(result.statusCode).toBe(400); + + const response = JSON.parse(result.body); + expect(response.error.code).toBe(-32700); + expect(response.error.message).toContain('Content-Type'); + }); + + it('should handle GET request (not allowed)', async () => { + const handler = createLambdaHandler(server); + + const result = await handler(asLambdaEvent({ + httpMethod: 'GET', + headers: {} + }), context); + + expect(result.statusCode).toBe(405); + + const response = JSON.parse(result.body); + expect(response.error.code).toBe(-32000); + expect(response.error.message).toContain('Method not allowed'); + }); + }); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..cb1e015 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": ["ES2022"], + "strict": true, + "noImplicitAny": true, + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": false, + "outDir": "dist", + "rootDir": "src", + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts"], + "exclude": ["dist", "node_modules", "tests", "example"] +} diff --git a/tsconfig.tests.json b/tsconfig.tests.json new file mode 100644 index 0000000..bdec9a9 --- /dev/null +++ b/tsconfig.tests.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true, + "declaration": false, + "emitDeclarationOnly": false, + "rootDir": ".", + "types": ["vitest/globals"] + }, + "include": ["tests/**/*.ts", "tests/**/*.mts", "tests/**/*.cts", "src/**/*.ts", "src/**/*.d.ts"], + "exclude": ["dist", "node_modules"] +} diff --git a/tsdown.config.ts b/tsdown.config.ts new file mode 100644 index 0000000..dab5d1d --- /dev/null +++ b/tsdown.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'tsdown'; + +export default defineConfig([ + { + entry: ['./src/index.ts'], + format: ['cjs', 'esm'], + platform: 'node', + plugins: [], + }, +]);