@decocms/bindings 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -139,7 +139,7 @@ var ModelSchema = z.object({
139
139
  "openai",
140
140
  "anthropic",
141
141
  "google",
142
- "xai",
142
+ "x-ai",
143
143
  "deepseek",
144
144
  "openai-compatible",
145
145
  "openrouter"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/well-known/language-model.ts"],"names":[],"mappings":";;;;;;;AAAA,YAAA,EAAA;AAAA,WAAA,EAAA;AAAA,YAAA,EAAA;AAuBO,IAAM,8BAAA,GAAiC,EAAE,MAAA,CAAO;AAAA;AAAA,EAErD,MAAA,EAAQ,CAAA,CACL,GAAA,EAAI,CACJ,QAAA;AAAA,IACC;AAAA,GACF;AAAA;AAAA,EAGF,iBAAiB,CAAA,CACd,MAAA,GACA,QAAA,EAAS,CACT,SAAS,sCAAsC,CAAA;AAAA,EAClD,WAAA,EAAa,CAAA,CACV,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,MAAM,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,4BAA4B,CAAA;AAAA,EACjE,IAAA,EAAM,CAAA,CACH,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,eAAA,EAAiB,CAAA,CACd,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,gBAAA,EAAkB,CAAA,CACf,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,IAAA,EAAM,CAAA,CACH,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA;AAAA,EAGF,aAAA,EAAe,EACZ,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAChB,UAAS,CACT,QAAA;AAAA,IACC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b,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,GAAG;AACL;AAEO,IAAM,oBAAA,GAAuB,cAAc,sBAAsB","file":"language-model.js","sourcesContent":["/**\n * Language Model Well-Known Binding\n *\n * Defines the interface for AI model providers.\n * Any MCP that implements this binding can provide AI models and streaming endpoints.\n *\n * This binding includes:\n * - LLM operations (metadata, stream, generate)\n * - Collection bindings for LIST and GET operations (read-only)\n * - Streaming endpoint information is included directly in the model entity schema.\n */\n\nimport { z } from \"zod\";\nimport { bindingClient, type ToolBinder } from \"../core/binder\";\nimport {\n BaseCollectionEntitySchema,\n createCollectionBindings,\n} from \"./collections\";\n\n/**\n * Language Model Call Options Schema\n * Based on LanguageModelV2CallOptions from @ai-sdk/provider\n */\nexport const LanguageModelCallOptionsSchema = z.object({\n // Core parameters\n prompt: z\n .any()\n .describe(\n \"A language mode prompt is a standardized prompt type (messages, system, etc.)\",\n ),\n\n // Generation parameters\n maxOutputTokens: z\n .number()\n .optional()\n .describe(\"Maximum number of tokens to generate\"),\n temperature: z\n .number()\n .optional()\n .describe(\n \"Temperature setting. The range depends on the provider and model\",\n ),\n topP: z.number().optional().describe(\"Nucleus sampling parameter\"),\n topK: z\n .number()\n .optional()\n .describe(\n \"Only sample from the top K options for each subsequent token. Used to remove long tail low probability responses\",\n ),\n presencePenalty: z\n .number()\n .optional()\n .describe(\n \"Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt\",\n ),\n frequencyPenalty: z\n .number()\n .optional()\n .describe(\n \"Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases\",\n ),\n seed: z\n .number()\n .optional()\n .describe(\n \"The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results\",\n ),\n\n // Stop sequences\n stopSequences: z\n .array(z.string())\n .optional()\n .describe(\n \"Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated\",\n ),\n\n // Response format\n responseFormat: z\n .union([\n z.object({ type: z.literal(\"text\") }),\n z.object({\n type: z.literal(\"json\"),\n schema: z\n .any()\n .optional()\n .describe(\"JSON schema that the generated output should conform to\"),\n name: z\n .string()\n .optional()\n .describe(\"Name of output that should be generated\"),\n description: z\n .string()\n .optional()\n .describe(\"Description of the output that should be generated\"),\n }),\n ])\n .optional()\n .describe(\n \"Response format. The output can either be text or JSON. Default is text\",\n ),\n\n // Tools\n tools: z\n .array(z.any())\n .optional()\n .describe(\"The tools that are available for the model\"),\n toolChoice: z\n .any()\n .optional()\n .describe(\"Specifies how the tool should be selected. Defaults to 'auto'\"),\n\n // Stream options\n includeRawChunks: z\n .boolean()\n .optional()\n .describe(\n \"Include raw chunks in the stream. Only applicable for streaming calls\",\n ),\n\n // Abort signal\n abortSignal: z\n .any()\n .optional()\n .describe(\"Abort signal for cancelling the operation\"),\n\n // Additional options\n headers: z\n .record(z.string(), z.union([z.string(), z.undefined()]))\n .optional()\n .describe(\"Additional HTTP headers to be sent with the request\"),\n providerOptions: z\n .any()\n .optional()\n .describe(\"Additional provider-specific options\"),\n});\n\n/**\n * Language Model Generate Output Schema\n * Based on the return type of LanguageModelV2.doGenerate from @ai-sdk/provider\n */\nexport const LanguageModelGenerateOutputSchema = z.object({\n // Ordered content that the model has generated\n content: z\n .array(z.any())\n .describe(\n \"Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)\",\n ),\n\n // Finish reason (required)\n finishReason: z\n .enum([\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"error\",\n \"other\",\n \"unknown\",\n ])\n .describe(\"Reason why generation stopped\"),\n\n // Usage information (required)\n usage: z\n .object({\n inputTokens: z.number().optional(),\n outputTokens: z.number().optional(),\n totalTokens: z.number().optional(),\n reasoningTokens: z.number().optional(),\n })\n .passthrough()\n .transform((val) => ({\n inputTokens: val.inputTokens,\n outputTokens: val.outputTokens,\n totalTokens: val.totalTokens,\n reasoningTokens: val.reasoningTokens,\n ...val,\n }))\n .describe(\"Usage information for the language model call\"),\n\n // Provider metadata\n providerMetadata: z\n .any()\n .optional()\n .describe(\"Additional provider-specific metadata\"),\n\n // Request information for telemetry and debugging\n request: z\n .object({\n body: z\n .any()\n .optional()\n .describe(\"Request HTTP body sent to the provider API\"),\n })\n .optional()\n .describe(\"Optional request information for telemetry and debugging\"),\n\n // Response information for telemetry and debugging\n response: z\n .object({\n id: z.string().optional().describe(\"ID for the generated response\"),\n timestamp: z\n .date()\n .optional()\n .describe(\"Timestamp for the start of the generated response\"),\n modelId: z\n .string()\n .optional()\n .describe(\"The ID of the response model that was used\"),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\"Response headers\"),\n body: z.any().optional().describe(\"Response HTTP body\"),\n })\n .optional()\n .describe(\"Optional response information for telemetry and debugging\"),\n\n // Warnings for the call (required)\n warnings: z\n .array(z.any())\n .describe(\"Warnings for the call, e.g. unsupported settings\"),\n});\n\n/**\n * Language Model Stream Output Schema\n * Based on the return type of LanguageModelV2.doStream from @ai-sdk/provider\n */\nexport const LanguageModelStreamOutputSchema = z.object({\n // Stream of language model output parts\n stream: z.any().describe(\"ReadableStream of LanguageModelV2StreamPart\"),\n\n // Request information for telemetry and debugging\n request: z\n .object({\n body: z\n .any()\n .optional()\n .describe(\"Request HTTP body sent to the provider API\"),\n })\n .optional()\n .describe(\"Optional request information for telemetry and debugging\"),\n\n // Response information\n response: z\n .object({\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\"Response headers\"),\n })\n .optional()\n .describe(\"Optional response data\"),\n});\n\nexport const LanguageModelMetadataSchema = z.object({\n supportedUrls: z\n .record(z.string(), z.array(z.string()))\n .describe(\"Supported URL patterns by media type for the provider\"),\n});\n\n/**\n * Simple Model schema for LLM operations\n */\nexport const ModelSchema = z.object({\n modelId: z.string().describe(\"The ID of the model\"),\n // Model-specific fields\n logo: z.string().nullable(),\n description: z.string().nullable(),\n capabilities: z.array(z.string()),\n limits: z\n .object({\n contextWindow: z.number(),\n maxOutputTokens: z.number(),\n })\n .nullable(),\n costs: z\n .object({\n input: z.number(),\n output: z.number(),\n })\n .nullable(),\n // Provider information\n provider: z\n .enum([\n \"openai\",\n \"anthropic\",\n \"google\",\n \"xai\",\n \"deepseek\",\n \"openai-compatible\",\n \"openrouter\",\n ])\n .nullable(),\n});\n\nexport const LanguageModelInputSchema = z.object({\n modelId: z.string().describe(\"The ID of the model\"),\n callOptions: LanguageModelCallOptionsSchema,\n});\n\n/**\n * Model entity schema for AI models (Collection Entity)\n * Extends BaseCollectionEntitySchema with model-specific fields\n * Base schema already includes: id, title, created_at, updated_at, created_by, updated_by\n */\nexport const ModelCollectionEntitySchema = BaseCollectionEntitySchema.extend({\n // Model-specific fields\n logo: z.string().nullable(),\n description: z.string().nullable(),\n capabilities: z.array(z.string()),\n limits: z\n .object({\n contextWindow: z.number(),\n maxOutputTokens: z.number(),\n })\n .nullable(),\n costs: z\n .object({\n input: z.number(),\n output: z.number(),\n })\n .nullable(),\n // Provider information\n provider: z\n .enum([\n \"openai\",\n \"anthropic\",\n \"google\",\n \"xai\",\n \"deepseek\",\n \"openai-compatible\",\n \"openrouter\",\n ])\n .nullable(),\n});\n\n/**\n * LLM Collection Binding (internal)\n *\n * Collection bindings for language models (read-only).\n * Provides LIST and GET operations for AI models.\n */\nconst LLM_COLLECTION_BINDING = createCollectionBindings(\n \"llm\",\n ModelCollectionEntitySchema,\n { readOnly: true },\n);\n\n/**\n * Language Model Binding\n *\n * Defines the interface for AI model providers.\n * Any MCP that implements this binding can provide AI models.\n *\n * Required tools:\n * - LLM_METADATA: Get metadata for a specific model\n * - LLM_DO_STREAM: Stream a language model response\n * - LLM_DO_GENERATE: Generate a language model response\n * - COLLECTION_LLM_LIST: List available AI models with their capabilities\n * - COLLECTION_LLM_GET: Get a single model by ID\n */\nexport const LANGUAGE_MODEL_BINDING = [\n {\n name: \"LLM_METADATA\" as const,\n inputSchema: z.object({\n modelId: z.string().describe(\"The ID of the model\"),\n }),\n outputSchema: LanguageModelMetadataSchema,\n },\n {\n name: \"LLM_DO_STREAM\" as const,\n inputSchema: LanguageModelInputSchema,\n streamable: true,\n },\n {\n name: \"LLM_DO_GENERATE\" as const,\n inputSchema: LanguageModelInputSchema,\n outputSchema: LanguageModelGenerateOutputSchema,\n },\n ...LLM_COLLECTION_BINDING,\n] satisfies ToolBinder[];\n\nexport const LanguageModelBinding = bindingClient(LANGUAGE_MODEL_BINDING);\n"]}
1
+ {"version":3,"sources":["../../src/well-known/language-model.ts"],"names":[],"mappings":";;;;;;;AAAA,YAAA,EAAA;AAAA,WAAA,EAAA;AAAA,YAAA,EAAA;AAuBO,IAAM,8BAAA,GAAiC,EAAE,MAAA,CAAO;AAAA;AAAA,EAErD,MAAA,EAAQ,CAAA,CACL,GAAA,EAAI,CACJ,QAAA;AAAA,IACC;AAAA,GACF;AAAA;AAAA,EAGF,iBAAiB,CAAA,CACd,MAAA,GACA,QAAA,EAAS,CACT,SAAS,sCAAsC,CAAA;AAAA,EAClD,WAAA,EAAa,CAAA,CACV,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,MAAM,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,4BAA4B,CAAA;AAAA,EACjE,IAAA,EAAM,CAAA,CACH,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,eAAA,EAAiB,CAAA,CACd,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,gBAAA,EAAkB,CAAA,CACf,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA,EACF,IAAA,EAAM,CAAA,CACH,MAAA,EAAO,CACP,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA;AAAA,EAGF,aAAA,EAAe,EACZ,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAChB,UAAS,CACT,QAAA;AAAA,IACC;AAAA,GACF;AAAA;AAAA,EAGF,cAAA,EAAgB,EACb,KAAA,C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AAM,oBAAA,GAAuB,cAAc,sBAAsB","file":"language-model.js","sourcesContent":["/**\n * Language Model Well-Known Binding\n *\n * Defines the interface for AI model providers.\n * Any MCP that implements this binding can provide AI models and streaming endpoints.\n *\n * This binding includes:\n * - LLM operations (metadata, stream, generate)\n * - Collection bindings for LIST and GET operations (read-only)\n * - Streaming endpoint information is included directly in the model entity schema.\n */\n\nimport { z } from \"zod\";\nimport { bindingClient, type ToolBinder } from \"../core/binder\";\nimport {\n BaseCollectionEntitySchema,\n createCollectionBindings,\n} from \"./collections\";\n\n/**\n * Language Model Call Options Schema\n * Based on LanguageModelV2CallOptions from @ai-sdk/provider\n */\nexport const LanguageModelCallOptionsSchema = z.object({\n // Core parameters\n prompt: z\n .any()\n .describe(\n \"A language mode prompt is a standardized prompt type (messages, system, etc.)\",\n ),\n\n // Generation parameters\n maxOutputTokens: z\n .number()\n .optional()\n .describe(\"Maximum number of tokens to generate\"),\n temperature: z\n .number()\n .optional()\n .describe(\n \"Temperature setting. The range depends on the provider and model\",\n ),\n topP: z.number().optional().describe(\"Nucleus sampling parameter\"),\n topK: z\n .number()\n .optional()\n .describe(\n \"Only sample from the top K options for each subsequent token. Used to remove long tail low probability responses\",\n ),\n presencePenalty: z\n .number()\n .optional()\n .describe(\n \"Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt\",\n ),\n frequencyPenalty: z\n .number()\n .optional()\n .describe(\n \"Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases\",\n ),\n seed: z\n .number()\n .optional()\n .describe(\n \"The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results\",\n ),\n\n // Stop sequences\n stopSequences: z\n .array(z.string())\n .optional()\n .describe(\n \"Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated\",\n ),\n\n // Response format\n responseFormat: z\n .union([\n z.object({ type: z.literal(\"text\") }),\n z.object({\n type: z.literal(\"json\"),\n schema: z\n .any()\n .optional()\n .describe(\"JSON schema that the generated output should conform to\"),\n name: z\n .string()\n .optional()\n .describe(\"Name of output that should be generated\"),\n description: z\n .string()\n .optional()\n .describe(\"Description of the output that should be generated\"),\n }),\n ])\n .optional()\n .describe(\n \"Response format. The output can either be text or JSON. Default is text\",\n ),\n\n // Tools\n tools: z\n .array(z.any())\n .optional()\n .describe(\"The tools that are available for the model\"),\n toolChoice: z\n .any()\n .optional()\n .describe(\"Specifies how the tool should be selected. Defaults to 'auto'\"),\n\n // Stream options\n includeRawChunks: z\n .boolean()\n .optional()\n .describe(\n \"Include raw chunks in the stream. Only applicable for streaming calls\",\n ),\n\n // Abort signal\n abortSignal: z\n .any()\n .optional()\n .describe(\"Abort signal for cancelling the operation\"),\n\n // Additional options\n headers: z\n .record(z.string(), z.union([z.string(), z.undefined()]))\n .optional()\n .describe(\"Additional HTTP headers to be sent with the request\"),\n providerOptions: z\n .any()\n .optional()\n .describe(\"Additional provider-specific options\"),\n});\n\n/**\n * Language Model Generate Output Schema\n * Based on the return type of LanguageModelV2.doGenerate from @ai-sdk/provider\n */\nexport const LanguageModelGenerateOutputSchema = z.object({\n // Ordered content that the model has generated\n content: z\n .array(z.any())\n .describe(\n \"Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)\",\n ),\n\n // Finish reason (required)\n finishReason: z\n .enum([\n \"stop\",\n \"length\",\n \"content-filter\",\n \"tool-calls\",\n \"error\",\n \"other\",\n \"unknown\",\n ])\n .describe(\"Reason why generation stopped\"),\n\n // Usage information (required)\n usage: z\n .object({\n inputTokens: z.number().optional(),\n outputTokens: z.number().optional(),\n totalTokens: z.number().optional(),\n reasoningTokens: z.number().optional(),\n })\n .passthrough()\n .transform((val) => ({\n inputTokens: val.inputTokens,\n outputTokens: val.outputTokens,\n totalTokens: val.totalTokens,\n reasoningTokens: val.reasoningTokens,\n ...val,\n }))\n .describe(\"Usage information for the language model call\"),\n\n // Provider metadata\n providerMetadata: z\n .any()\n .optional()\n .describe(\"Additional provider-specific metadata\"),\n\n // Request information for telemetry and debugging\n request: z\n .object({\n body: z\n .any()\n .optional()\n .describe(\"Request HTTP body sent to the provider API\"),\n })\n .optional()\n .describe(\"Optional request information for telemetry and debugging\"),\n\n // Response information for telemetry and debugging\n response: z\n .object({\n id: z.string().optional().describe(\"ID for the generated response\"),\n timestamp: z\n .date()\n .optional()\n .describe(\"Timestamp for the start of the generated response\"),\n modelId: z\n .string()\n .optional()\n .describe(\"The ID of the response model that was used\"),\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\"Response headers\"),\n body: z.any().optional().describe(\"Response HTTP body\"),\n })\n .optional()\n .describe(\"Optional response information for telemetry and debugging\"),\n\n // Warnings for the call (required)\n warnings: z\n .array(z.any())\n .describe(\"Warnings for the call, e.g. unsupported settings\"),\n});\n\n/**\n * Language Model Stream Output Schema\n * Based on the return type of LanguageModelV2.doStream from @ai-sdk/provider\n */\nexport const LanguageModelStreamOutputSchema = z.object({\n // Stream of language model output parts\n stream: z.any().describe(\"ReadableStream of LanguageModelV2StreamPart\"),\n\n // Request information for telemetry and debugging\n request: z\n .object({\n body: z\n .any()\n .optional()\n .describe(\"Request HTTP body sent to the provider API\"),\n })\n .optional()\n .describe(\"Optional request information for telemetry and debugging\"),\n\n // Response information\n response: z\n .object({\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe(\"Response headers\"),\n })\n .optional()\n .describe(\"Optional response data\"),\n});\n\nexport const LanguageModelMetadataSchema = z.object({\n supportedUrls: z\n .record(z.string(), z.array(z.string()))\n .describe(\"Supported URL patterns by media type for the provider\"),\n});\n\n/**\n * Simple Model schema for LLM operations\n */\nexport const ModelSchema = z.object({\n modelId: z.string().describe(\"The ID of the model\"),\n // Model-specific fields\n logo: z.string().nullable(),\n description: z.string().nullable(),\n capabilities: z.array(z.string()),\n limits: z\n .object({\n contextWindow: z.number(),\n maxOutputTokens: z.number(),\n })\n .nullable(),\n costs: z\n .object({\n input: z.number(),\n output: z.number(),\n })\n .nullable(),\n // Provider information\n provider: z\n .enum([\n \"openai\",\n \"anthropic\",\n \"google\",\n \"x-ai\",\n \"deepseek\",\n \"openai-compatible\",\n \"openrouter\",\n ])\n .nullable(),\n});\n\nexport const LanguageModelInputSchema = z.object({\n modelId: z.string().describe(\"The ID of the model\"),\n callOptions: LanguageModelCallOptionsSchema,\n});\n\n/**\n * Model entity schema for AI models (Collection Entity)\n * Extends BaseCollectionEntitySchema with model-specific fields\n * Base schema already includes: id, title, created_at, updated_at, created_by, updated_by\n */\nexport const ModelCollectionEntitySchema = BaseCollectionEntitySchema.extend({\n // Model-specific fields\n logo: z.string().nullable(),\n description: z.string().nullable(),\n capabilities: z.array(z.string()),\n limits: z\n .object({\n contextWindow: z.number(),\n maxOutputTokens: z.number(),\n })\n .nullable(),\n costs: z\n .object({\n input: z.number(),\n output: z.number(),\n })\n .nullable(),\n // Provider information\n provider: z\n .enum([\n \"openai\",\n \"anthropic\",\n \"google\",\n \"xai\",\n \"deepseek\",\n \"openai-compatible\",\n \"openrouter\",\n ])\n .nullable(),\n});\n\n/**\n * LLM Collection Binding (internal)\n *\n * Collection bindings for language models (read-only).\n * Provides LIST and GET operations for AI models.\n */\nconst LLM_COLLECTION_BINDING = createCollectionBindings(\n \"llm\",\n ModelCollectionEntitySchema,\n { readOnly: true },\n);\n\n/**\n * Language Model Binding\n *\n * Defines the interface for AI model providers.\n * Any MCP that implements this binding can provide AI models.\n *\n * Required tools:\n * - LLM_METADATA: Get metadata for a specific model\n * - LLM_DO_STREAM: Stream a language model response\n * - LLM_DO_GENERATE: Generate a language model response\n * - COLLECTION_LLM_LIST: List available AI models with their capabilities\n * - COLLECTION_LLM_GET: Get a single model by ID\n */\nexport const LANGUAGE_MODEL_BINDING = [\n {\n name: \"LLM_METADATA\" as const,\n inputSchema: z.object({\n modelId: z.string().describe(\"The ID of the model\"),\n }),\n outputSchema: LanguageModelMetadataSchema,\n },\n {\n name: \"LLM_DO_STREAM\" as const,\n inputSchema: LanguageModelInputSchema,\n streamable: true,\n },\n {\n name: \"LLM_DO_GENERATE\" as const,\n inputSchema: LanguageModelInputSchema,\n outputSchema: LanguageModelGenerateOutputSchema,\n },\n ...LLM_COLLECTION_BINDING,\n] satisfies ToolBinder[];\n\nexport const LanguageModelBinding = bindingClient(LANGUAGE_MODEL_BINDING);\n"]}
@@ -0,0 +1,12 @@
1
+ import { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
2
+ import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
3
+
4
+ declare class HTTPClientTransport extends StreamableHTTPClientTransport {
5
+ constructor(url: URL, opts?: StreamableHTTPClientTransportOptions);
6
+ send(message: JSONRPCMessage, options?: {
7
+ resumptionToken?: string;
8
+ onresumptiontoken?: (token: string) => void;
9
+ }): Promise<void>;
10
+ }
11
+
12
+ export { HTTPClientTransport };
package/dist/client.js ADDED
@@ -0,0 +1,54 @@
1
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
2
+
3
+ // src/core/client/http-client-transport.ts
4
+ var HTTPClientTransport = class extends StreamableHTTPClientTransport {
5
+ constructor(url, opts) {
6
+ super(url, opts);
7
+ }
8
+ send(message, options) {
9
+ const mockAction = getMockActionFor(message);
10
+ if (mockAction?.type === "emit") {
11
+ this.onmessage?.(mockAction.message);
12
+ return Promise.resolve();
13
+ }
14
+ if (mockAction?.type === "suppress") {
15
+ return Promise.resolve();
16
+ }
17
+ return super.send(message, options);
18
+ }
19
+ };
20
+ function getMockActionFor(message) {
21
+ const m = message;
22
+ if (!m || typeof m !== "object" || !("method" in m)) return null;
23
+ switch (m.method) {
24
+ case "initialize": {
25
+ const protocolVersion = m?.params?.protocolVersion;
26
+ if (!protocolVersion) return null;
27
+ return {
28
+ type: "emit",
29
+ message: {
30
+ result: {
31
+ protocolVersion,
32
+ capabilities: { tools: {} },
33
+ serverInfo: { name: "deco-chat-server", version: "1.0.0" }
34
+ },
35
+ jsonrpc: m.jsonrpc ?? "2.0",
36
+ // @ts-expect-error - id is not typed
37
+ id: m.id
38
+ }
39
+ };
40
+ }
41
+ case "notifications/roots/list_changed":
42
+ case "notifications/initialized":
43
+ case "notifications/cancelled":
44
+ case "notifications/progress": {
45
+ return { type: "suppress" };
46
+ }
47
+ default:
48
+ return null;
49
+ }
50
+ }
51
+
52
+ export { HTTPClientTransport };
53
+ //# sourceMappingURL=client.js.map
54
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/client/http-client-transport.ts"],"names":[],"mappings":";;;AAMO,IAAM,mBAAA,GAAN,cAAkC,6BAAA,CAA8B;AAAA,EACrE,WAAA,CAAY,KAAU,IAAA,EAA6C;AACjE,IAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,EACjB;AAAA,EAES,IAAA,CACP,SACA,OAAA,EAIe;AACf,IAAA,MAAM,UAAA,GAAa,iBAAiB,OAAO,CAAA;AAC3C,IAAA,IAAI,UAAA,EAAY,SAAS,MAAA,EAAQ;AAC/B,MAAA,IAAA,CAAK,SAAA,GAAY,WAAW,OAAO,CAAA;AACnC,MAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,IACzB;AACA,IAAA,IAAI,UAAA,EAAY,SAAS,UAAA,EAAY;AACnC,MAAA,OAAO,QAAQ,OAAA,EAAQ;AAAA,IACzB;AACA,IAAA,OAAO,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,OAAO,CAAA;AAAA,EACpC;AACF;AAMA,SAAS,iBAAiB,OAAA,EAA4C;AACpE,EAAA,MAAM,CAAA,GAAI,OAAA;AACV,EAAA,IAAI,CAAC,KAAK,OAAO,CAAA,KAAM,YAAY,EAAE,QAAA,IAAY,IAAI,OAAO,IAAA;AAE5D,EAAA,QAAQ,EAAE,MAAA;AAAQ,IAChB,KAAK,YAAA,EAAc;AACjB,MAAA,MAAM,eAAA,GAAkB,GAAG,MAAA,EAAQ,eAAA;AACnC,MAAA,IAAI,CAAC,iBAAiB,OAAO,IAAA;AAC7B,MAAA,OAAO;AAAA,QACL,IAAA,EAAM,MAAA;AAAA,QACN,OAAA,EAAS;AAAA,UACP,MAAA,EAAQ;AAAA,YACN,eAAA;AAAA,YACA,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,YAC1B,UAAA,EAAY,EAAE,IAAA,EAAM,kBAAA,EAAoB,SAAS,OAAA;AAAQ,WAC3D;AAAA,UACA,OAAA,EAAS,EAAE,OAAA,IAAW,KAAA;AAAA;AAAA,UAEtB,IAAI,CAAA,CAAE;AAAA;AACR,OACF;AAAA,IACF;AAAA,IACA,KAAK,kCAAA;AAAA,IACL,KAAK,2BAAA;AAAA,IACL,KAAK,yBAAA;AAAA,IACL,KAAK,wBAAA,EAA0B;AAC7B,MAAA,OAAO,EAAE,MAAM,UAAA,EAAW;AAAA,IAC5B;AAAA,IACA;AACE,MAAA,OAAO,IAAA;AAAA;AAEb","file":"client.js","sourcesContent":["import type { JSONRPCMessage } from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n StreamableHTTPClientTransport,\n type StreamableHTTPClientTransportOptions,\n} from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\n\nexport class HTTPClientTransport extends StreamableHTTPClientTransport {\n constructor(url: URL, opts?: StreamableHTTPClientTransportOptions) {\n super(url, opts);\n }\n\n override send(\n message: JSONRPCMessage,\n options?: {\n resumptionToken?: string;\n onresumptiontoken?: (token: string) => void;\n },\n ): Promise<void> {\n const mockAction = getMockActionFor(message);\n if (mockAction?.type === \"emit\") {\n this.onmessage?.(mockAction.message);\n return Promise.resolve();\n }\n if (mockAction?.type === \"suppress\") {\n return Promise.resolve();\n }\n return super.send(message, options);\n }\n}\n\ntype MockAction =\n | { type: \"emit\"; message: JSONRPCMessage }\n | { type: \"suppress\" };\n\nfunction getMockActionFor(message: JSONRPCMessage): MockAction | null {\n const m = message;\n if (!m || typeof m !== \"object\" || !(\"method\" in m)) return null;\n\n switch (m.method) {\n case \"initialize\": {\n const protocolVersion = m?.params?.protocolVersion;\n if (!protocolVersion) return null;\n return {\n type: \"emit\",\n message: {\n result: {\n protocolVersion,\n capabilities: { tools: {} },\n serverInfo: { name: \"deco-chat-server\", version: \"1.0.0\" },\n },\n jsonrpc: m.jsonrpc ?? \"2.0\",\n // @ts-expect-error - id is not typed\n id: m.id,\n } as JSONRPCMessage,\n };\n }\n case \"notifications/roots/list_changed\":\n case \"notifications/initialized\":\n case \"notifications/cancelled\":\n case \"notifications/progress\": {\n return { type: \"suppress\" };\n }\n default:\n return null;\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  import { z } from 'zod';
2
- import { ToolBinder } from '../index.js';
3
2
 
4
3
  /**
5
4
  * Collection Bindings
@@ -369,15 +368,131 @@ interface CollectionBindingOptions {
369
368
  * const READONLY_COLLECTION_BINDING = createCollectionBindings("products", ProductSchema, { readOnly: true });
370
369
  * ```
371
370
  */
372
- declare function createCollectionBindings<TEntitySchema extends BaseCollectionEntitySchemaType>(collectionName: string, entitySchema: TEntitySchema, options?: CollectionBindingOptions): ToolBinder<string, any, object>[];
371
+ declare function createCollectionBindings<TEntitySchema extends BaseCollectionEntitySchemaType, TName extends string>(collectionName: TName, entitySchema: TEntitySchema, options?: CollectionBindingOptions): ({
372
+ name: `COLLECTION_${Uppercase<TName>}_LIST`;
373
+ inputSchema: typeof CollectionListInputSchema;
374
+ outputSchema: z.ZodObject<{
375
+ items: z.ZodArray<TEntitySchema, "many">;
376
+ totalCount: z.ZodOptional<z.ZodNumber>;
377
+ hasMore: z.ZodOptional<z.ZodBoolean>;
378
+ }, "strip", z.ZodTypeAny, {
379
+ items: TEntitySchema["_output"][];
380
+ totalCount?: number | undefined;
381
+ hasMore?: boolean | undefined;
382
+ }, {
383
+ items: TEntitySchema["_input"][];
384
+ totalCount?: number | undefined;
385
+ hasMore?: boolean | undefined;
386
+ }>;
387
+ } | {
388
+ name: `COLLECTION_${Uppercase<TName>}_GET`;
389
+ inputSchema: typeof CollectionGetInputSchema;
390
+ outputSchema: z.ZodObject<{
391
+ item: z.ZodNullable<TEntitySchema>;
392
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
393
+ item: z.ZodNullable<TEntitySchema>;
394
+ }>, any> extends infer T ? { [k in keyof T]: T[k]; } : never, z.baseObjectInputType<{
395
+ item: z.ZodNullable<TEntitySchema>;
396
+ }> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1]; } : never>;
397
+ } | {
398
+ name: `COLLECTION_${Uppercase<TName>}_CREATE`;
399
+ inputSchema: z.ZodObject<{
400
+ data: TEntitySchema;
401
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
402
+ data: TEntitySchema;
403
+ }>, any> extends infer T_2 ? { [k_2 in keyof T_2]: T_2[k_2]; } : never, z.baseObjectInputType<{
404
+ data: TEntitySchema;
405
+ }> extends infer T_3 ? { [k_3 in keyof T_3]: T_3[k_3]; } : never>;
406
+ outputSchema: z.ZodObject<{
407
+ item: TEntitySchema;
408
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
409
+ item: TEntitySchema;
410
+ }>, any> extends infer T_4 ? { [k_4 in keyof T_4]: T_4[k_4]; } : never, z.baseObjectInputType<{
411
+ item: TEntitySchema;
412
+ }> extends infer T_5 ? { [k_5 in keyof T_5]: T_5[k_5]; } : never>;
413
+ opt: true;
414
+ } | {
415
+ name: `COLLECTION_${Uppercase<TName>}_UPDATE`;
416
+ inputSchema: z.ZodObject<{
417
+ id: z.ZodString;
418
+ data: z.ZodObject<{
419
+ [x: string]: z.ZodOptional<any>;
420
+ }, any, any, {
421
+ [x: string]: any;
422
+ }, {
423
+ [x: string]: any;
424
+ }>;
425
+ }, "strip", z.ZodTypeAny, {
426
+ id: string;
427
+ data: {
428
+ [x: string]: any;
429
+ };
430
+ }, {
431
+ id: string;
432
+ data: {
433
+ [x: string]: any;
434
+ };
435
+ }>;
436
+ outputSchema: z.ZodObject<{
437
+ item: TEntitySchema;
438
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
439
+ item: TEntitySchema;
440
+ }>, any> extends infer T_6 ? { [k_6 in keyof T_6]: T_6[k_6]; } : never, z.baseObjectInputType<{
441
+ item: TEntitySchema;
442
+ }> extends infer T_7 ? { [k_7 in keyof T_7]: T_7[k_7]; } : never>;
443
+ opt: true;
444
+ } | {
445
+ name: `COLLECTION_${Uppercase<TName>}_DELETE`;
446
+ inputSchema: typeof CollectionDeleteInputSchema;
447
+ outputSchema: z.ZodObject<{
448
+ item: TEntitySchema;
449
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
450
+ item: TEntitySchema;
451
+ }>, any> extends infer T_8 ? { [k_8 in keyof T_8]: T_8[k_8]; } : never, z.baseObjectInputType<{
452
+ item: TEntitySchema;
453
+ }> extends infer T_9 ? { [k_9 in keyof T_9]: T_9[k_9]; } : never>;
454
+ opt: true;
455
+ })[];
456
+ type ReadOnlyCollectionBinding<TEntitySchema extends BaseCollectionEntitySchemaType, TUpperName extends Uppercase<string> = Uppercase<string>> = [
457
+ {
458
+ name: `COLLECTION_${TUpperName}_LIST`;
459
+ inputSchema: typeof CollectionListInputSchema;
460
+ outputSchema: ReturnType<typeof createCollectionListOutputSchema<TEntitySchema>>;
461
+ },
462
+ {
463
+ name: `COLLECTION_${TUpperName}_GET`;
464
+ inputSchema: typeof CollectionGetInputSchema;
465
+ outputSchema: ReturnType<typeof createCollectionGetOutputSchema<TEntitySchema>>;
466
+ }
467
+ ];
373
468
  /**
374
469
  * Type helper to extract the collection binding type
375
470
  */
376
- type CollectionBinding<TEntitySchema extends BaseCollectionEntitySchemaType> = ReturnType<typeof createCollectionBindings<TEntitySchema>>;
471
+ type CollectionBinding<TEntitySchema extends BaseCollectionEntitySchemaType, TUpperName extends Uppercase<string> = Uppercase<string>> = [
472
+ ...ReadOnlyCollectionBinding<TEntitySchema, TUpperName>,
473
+ {
474
+ name: `COLLECTION_${TUpperName}_CREATE`;
475
+ inputSchema: ReturnType<typeof createCollectionInsertInputSchema<TEntitySchema>>;
476
+ outputSchema: ReturnType<typeof createCollectionInsertOutputSchema<TEntitySchema>>;
477
+ opt: true;
478
+ },
479
+ {
480
+ name: `COLLECTION_${TUpperName}_UPDATE`;
481
+ inputSchema: ReturnType<typeof createCollectionUpdateInputSchema<TEntitySchema>>;
482
+ outputSchema: ReturnType<typeof createCollectionUpdateOutputSchema<TEntitySchema>>;
483
+ opt: true;
484
+ },
485
+ {
486
+ name: `COLLECTION_${TUpperName}_DELETE`;
487
+ inputSchema: typeof CollectionDeleteInputSchema;
488
+ outputSchema: ReturnType<typeof createCollectionDeleteOutputSchema<TEntitySchema>>;
489
+ opt: true;
490
+ }
491
+ ];
377
492
  /**
378
493
  * Type helper to extract tool names from a collection binding
379
494
  */
380
- type CollectionTools<TEntitySchema extends BaseCollectionEntitySchemaType> = CollectionBinding<TEntitySchema>[number]["name"];
495
+ type CollectionTools<TEntitySchema extends BaseCollectionEntitySchemaType, TUpperName extends Uppercase<string> = Uppercase<string>> = CollectionBinding<TEntitySchema, TUpperName>[number]["name"];
381
496
  type CollectionListInput = z.infer<typeof CollectionListInputSchema>;
382
497
  type CollectionGetInput = z.infer<typeof CollectionGetInputSchema>;
383
498
  type CollectionDeleteInput = z.infer<typeof CollectionDeleteInputSchema>;
@@ -419,4 +534,4 @@ type CollectionDeleteOutput<T> = {
419
534
  */
420
535
  type BaseCollectionEntity = z.infer<typeof BaseCollectionEntitySchema>;
421
536
 
422
- export { type BaseCollectionEntity, BaseCollectionEntitySchema, type BaseCollectionEntitySchemaType, type CollectionBinding, type CollectionBindingOptions, type CollectionDeleteInput, CollectionDeleteInputSchema, type CollectionDeleteOutput, type CollectionGetInput, CollectionGetInputSchema, type CollectionGetOutput, type CollectionInsertOutput, type CollectionListInput, CollectionListInputSchema, type CollectionListOutput, type CollectionTools, type CollectionUpdateOutput, type OrderByExpression, OrderByExpressionSchema, type WhereExpression, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema };
537
+ export { type BaseCollectionEntity, BaseCollectionEntitySchema, type BaseCollectionEntitySchemaType, type CollectionBinding, type CollectionBindingOptions, type CollectionDeleteInput, CollectionDeleteInputSchema, type CollectionDeleteOutput, type CollectionGetInput, CollectionGetInputSchema, type CollectionGetOutput, type CollectionInsertOutput, type CollectionListInput, CollectionListInputSchema, type CollectionListOutput, type CollectionTools, type CollectionUpdateOutput, type OrderByExpression, OrderByExpressionSchema, type ReadOnlyCollectionBinding, type WhereExpression, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema };
@@ -119,5 +119,5 @@ function createCollectionBindings(collectionName, entitySchema, options) {
119
119
  }
120
120
 
121
121
  export { BaseCollectionEntitySchema, CollectionDeleteInputSchema, CollectionGetInputSchema, CollectionListInputSchema, OrderByExpressionSchema, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema };
122
- //# sourceMappingURL=chunk-JMM4EZYL.js.map
123
- //# sourceMappingURL=chunk-JMM4EZYL.js.map
122
+ //# sourceMappingURL=collections.js.map
123
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/well-known/collections.ts"],"names":[],"mappings":";;;AAsBO,IAAM,0BAAA,GAA6B,EAAE,MAAA,CAAO;AAAA,EACjD,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kCAAkC,CAAA;AAAA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Ac,SAAS,CAAA,IAAA,CAAA;AAAA,MAC7B,WAAA,EAAa,wBAAA;AAAA,MACb,YAAA,EAAc,gCAAgC,YAAY;AAAA;AAC5D,GACF;AAGF,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,QAAA,CAAS,IAAA;AAAA,MACP;AAAA,QACE,IAAA,EAAM,cAAc,SAAS,CAAA,OAAA,CAAA;AAAA,QAC7B,WAAA,EAAa,kCAAkC,YAAY,CAAA;AAAA,QAC3D,YAAA,EAAc,mCAAmC,YAAY,CAAA;AAAA,QAC7D,GAAA,EAAK;AAAA,OACP;AAAA,MACA;AAAA,QACE,IAAA,EAAM,cAAc,SAAS,CAAA,OAAA,CAAA;AAAA,QAC7B,WAAA,EAAa,kCAAkC,YAAY,CAAA;AAAA,QAC3D,YAAA,EAAc,mCAAmC,YAAY,CAAA;AAAA,QAC7D,GAAA,EAAK;AAAA,OACP;AAAA,MACA;AAAA,QACE,IAAA,EAAM,cAAc,SAAS,CAAA,OAAA,CAAA;AAAA,QAC7B,WAAA,EAAa,2BAAA;AAAA,QACb,YAAA,EAAc,mCAAmC,YAAY,CAAA;AAAA,QAC7D,GAAA,EAAK;AAAA;AACP,KACF;AAAA,EACF;AAEA,EAAA,OAAO,QAAA;AACT","file":"collections.js","sourcesContent":["import { z } from \"zod\";\nimport type { ToolBinder } from \"../core/binder\";\n\n/**\n * Collection Bindings\n *\n * This module provides standardized tool bindings for Collections, representing\n * SQL table-like structures with CRUD + Search operations compatible with TanStack DB.\n *\n * Key Features:\n * - Generic collection bindings that work with any entity type\n * - Standardized tool naming: `COLLECTION_{COLLECTION}_*`\n * - Compatible with TanStack DB query-collection\n * - Full TypeScript support with proper type constraints\n * - Support for filtering, sorting, and pagination\n * - Simple id and title fields for human-readable identification\n */\n\n/**\n * Base schema for collection entities\n * All collection entities must have an id, title, and audit trail fields\n */\nexport const BaseCollectionEntitySchema = z.object({\n id: z.string().describe(\"Unique identifier for the entity\"),\n title: z.string().describe(\"Human-readable title for the entity\"),\n created_at: z.string().datetime(),\n updated_at: z.string().datetime(),\n created_by: z.string().optional(),\n updated_by: z.string().optional(),\n});\n\n/**\n * Type helper for BaseCollectionEntitySchema\n */\nexport type BaseCollectionEntitySchemaType = typeof BaseCollectionEntitySchema;\n\n/**\n * Comparison expression schema for filtering\n */\nconst ComparisonExpressionSchema = z.object({\n field: z.array(z.string()),\n operator: z.enum([\"eq\", \"gt\", \"gte\", \"lt\", \"lte\", \"in\", \"like\", \"contains\"]),\n value: z.unknown(),\n});\n\n/**\n * Where expression schema for filtering\n * Supports TanStack DB predicate push-down patterns\n */\nexport const WhereExpressionSchema = z.union([\n ComparisonExpressionSchema,\n z.object({\n operator: z.enum([\"and\", \"or\", \"not\"]),\n conditions: z.array(ComparisonExpressionSchema),\n }),\n]);\n\n/**\n * Where expression type for filtering\n * Derived from WhereExpressionSchema\n */\nexport type WhereExpression = z.infer<typeof WhereExpressionSchema>;\n\n/**\n * Order by expression for sorting\n */\nexport const OrderByExpressionSchema = z.object({\n field: z.array(z.string()),\n direction: z.enum([\"asc\", \"desc\"]),\n nulls: z.enum([\"first\", \"last\"]).optional(),\n});\n\n/**\n * List/Query input schema for collections\n * Compatible with TanStack DB LoadSubsetOptions\n */\nexport const CollectionListInputSchema = z.object({\n where: WhereExpressionSchema.optional().describe(\"Filter expression\"),\n orderBy: z\n .array(OrderByExpressionSchema)\n .optional()\n .describe(\"Sort expressions\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .optional()\n .describe(\"Maximum number of items to return\"),\n offset: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe(\"Number of items to skip\"),\n});\n\n/**\n * Factory function to create list output schema for a specific collection type\n */\nexport function createCollectionListOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n items: z.array(entitySchema).describe(\"Array of collection items\"),\n totalCount: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe(\"Total number of matching items (if available)\"),\n hasMore: z\n .boolean()\n .optional()\n .describe(\"Whether there are more items available\"),\n });\n}\n\n/**\n * Get by ID input schema\n */\nexport const CollectionGetInputSchema = z.object({\n id: z.string().describe(\"ID of the entity to retrieve\"),\n});\n\n/**\n * Factory function to create get output schema\n */\nexport function createCollectionGetOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema\n .nullable()\n .describe(\"The retrieved item, or null if not found\"),\n });\n}\n\n/**\n * Factory function to create insert input schema\n */\nexport function createCollectionInsertInputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n // Remove id field since it may be auto-generated by the server\n return z.object({\n data: entitySchema.describe(\n \"Data for the new entity (id may be auto-generated)\",\n ),\n });\n}\n\n/**\n * Factory function to create insert output schema\n */\nexport function createCollectionInsertOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema.describe(\"The created entity with generated id\"),\n });\n}\n\n/**\n * Factory function to create update input schema\n */\nexport function createCollectionUpdateInputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n id: z.string().describe(\"ID of the entity to update\"),\n data: (entitySchema as unknown as z.AnyZodObject)\n .partial()\n .describe(\"Partial entity data to update\"),\n });\n}\n\n/**\n * Factory function to create update output schema\n */\nexport function createCollectionUpdateOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema.describe(\"The updated entity\"),\n });\n}\n\n/**\n * Delete input schema\n */\nexport const CollectionDeleteInputSchema = z.object({\n id: z.string().describe(\"ID of the entity to delete\"),\n});\n\n/**\n * Factory function to create delete output schema\n */\nexport function createCollectionDeleteOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema.describe(\"The deleted entity\"),\n });\n}\n\n/**\n * Options for creating collection bindings\n */\nexport interface CollectionBindingOptions {\n /**\n * If true, only LIST and GET operations will be included (read-only collection)\n * @default false\n */\n readOnly?: boolean;\n}\n\n/**\n * Creates generic collection bindings for a specific entity type\n *\n * This function generates standardized tool bindings that work with any collection/table\n * by accepting a custom entity schema and collection name. The bindings provide:\n * - COLLECTION_{NAME}_LIST - Query/search entities with filtering and sorting (required)\n * - COLLECTION_{NAME}_GET - Get a single entity by ID (required)\n * - COLLECTION_{NAME}_CREATE - Create a new entity (optional, excluded if readOnly=true)\n * - COLLECTION_{NAME}_UPDATE - Update an existing entity (optional, excluded if readOnly=true)\n * - COLLECTION_{NAME}_DELETE - Delete an entity (optional, excluded if readOnly=true)\n *\n * @param collectionName - The name of the collection/table (e.g., \"users\", \"products\", \"orders\")\n * @param entitySchema - The Zod schema for the entity type (must extend BaseCollectionEntitySchema)\n * @param options - Optional configuration for the collection bindings\n * @returns Array of tool bindings for Collection CRUD + Query operations\n *\n * @example\n * ```typescript\n * const UserSchema = z.object({\n * id: z.string(),\n * title: z.string(),\n * created_at: z.string().datetime(),\n * updated_at: z.string().datetime(),\n * created_by: z.string().optional(),\n * updated_by: z.string().optional(),\n * email: z.string().email(),\n * });\n *\n * // Full CRUD collection\n * const USER_COLLECTION_BINDING = createCollectionBindings(\"users\", UserSchema);\n *\n * // Read-only collection (only LIST and GET)\n * const READONLY_COLLECTION_BINDING = createCollectionBindings(\"products\", ProductSchema, { readOnly: true });\n * ```\n */\nexport function createCollectionBindings<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TName extends string,\n>(\n collectionName: TName,\n entitySchema: TEntitySchema,\n options?: CollectionBindingOptions,\n) {\n const upperName = collectionName.toUpperCase() as Uppercase<TName>;\n const readOnly = options?.readOnly ?? false;\n\n const bindings: CollectionBinding<TEntitySchema, Uppercase<TName>>[number][] =\n [\n {\n name: `COLLECTION_${upperName}_LIST` as const,\n inputSchema: CollectionListInputSchema,\n outputSchema: createCollectionListOutputSchema(entitySchema),\n },\n {\n name: `COLLECTION_${upperName}_GET` as const,\n inputSchema: CollectionGetInputSchema,\n outputSchema: createCollectionGetOutputSchema(entitySchema),\n },\n ];\n\n // Only include mutation operations if not read-only\n if (!readOnly) {\n bindings.push(\n {\n name: `COLLECTION_${upperName}_CREATE` as const,\n inputSchema: createCollectionInsertInputSchema(entitySchema),\n outputSchema: createCollectionInsertOutputSchema(entitySchema),\n opt: true,\n },\n {\n name: `COLLECTION_${upperName}_UPDATE` as const,\n inputSchema: createCollectionUpdateInputSchema(entitySchema),\n outputSchema: createCollectionUpdateOutputSchema(entitySchema),\n opt: true,\n },\n {\n name: `COLLECTION_${upperName}_DELETE` as const,\n inputSchema: CollectionDeleteInputSchema,\n outputSchema: createCollectionDeleteOutputSchema(entitySchema),\n opt: true,\n },\n );\n }\n\n return bindings satisfies readonly ToolBinder[];\n}\n\nexport type ReadOnlyCollectionBinding<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TUpperName extends Uppercase<string> = Uppercase<string>,\n> = [\n {\n name: `COLLECTION_${TUpperName}_LIST`;\n inputSchema: typeof CollectionListInputSchema;\n outputSchema: ReturnType<\n typeof createCollectionListOutputSchema<TEntitySchema>\n >;\n },\n {\n name: `COLLECTION_${TUpperName}_GET`;\n inputSchema: typeof CollectionGetInputSchema;\n outputSchema: ReturnType<\n typeof createCollectionGetOutputSchema<TEntitySchema>\n >;\n },\n];\n/**\n * Type helper to extract the collection binding type\n */\nexport type CollectionBinding<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TUpperName extends Uppercase<string> = Uppercase<string>,\n> = [\n ...ReadOnlyCollectionBinding<TEntitySchema, TUpperName>,\n {\n name: `COLLECTION_${TUpperName}_CREATE`;\n inputSchema: ReturnType<\n typeof createCollectionInsertInputSchema<TEntitySchema>\n >;\n outputSchema: ReturnType<\n typeof createCollectionInsertOutputSchema<TEntitySchema>\n >;\n opt: true;\n },\n {\n name: `COLLECTION_${TUpperName}_UPDATE`;\n inputSchema: ReturnType<\n typeof createCollectionUpdateInputSchema<TEntitySchema>\n >;\n outputSchema: ReturnType<\n typeof createCollectionUpdateOutputSchema<TEntitySchema>\n >;\n opt: true;\n },\n {\n name: `COLLECTION_${TUpperName}_DELETE`;\n inputSchema: typeof CollectionDeleteInputSchema;\n outputSchema: ReturnType<\n typeof createCollectionDeleteOutputSchema<TEntitySchema>\n >;\n opt: true;\n },\n];\n\n/**\n * Type helper to extract tool names from a collection binding\n */\nexport type CollectionTools<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TUpperName extends Uppercase<string> = Uppercase<string>,\n> = CollectionBinding<TEntitySchema, TUpperName>[number][\"name\"];\n\n// Export types for TypeScript usage\nexport type CollectionListInput = z.infer<typeof CollectionListInputSchema>;\nexport type CollectionGetInput = z.infer<typeof CollectionGetInputSchema>;\nexport type CollectionDeleteInput = z.infer<typeof CollectionDeleteInputSchema>;\nexport type OrderByExpression = z.infer<typeof OrderByExpressionSchema>;\n\n/**\n * Type helper for list output with generic item type\n */\nexport type CollectionListOutput<T> = {\n items: T[];\n totalCount?: number;\n hasMore?: boolean;\n};\n\n/**\n * Type helper for get output with generic item type\n */\nexport type CollectionGetOutput<T> = {\n item: T | null;\n};\n\n/**\n * Type helper for insert output with generic item type\n */\nexport type CollectionInsertOutput<T> = {\n item: T;\n};\n\n/**\n * Type helper for update output with generic item type\n */\nexport type CollectionUpdateOutput<T> = {\n item: T;\n};\n\n/**\n * Type helper for delete output with generic item type\n */\nexport type CollectionDeleteOutput<T> = {\n item: T;\n};\n\n/**\n * Base collection entity type - inferred from BaseCollectionEntitySchema\n */\nexport type BaseCollectionEntity = z.infer<typeof BaseCollectionEntitySchema>;\n"]}
@@ -0,0 +1,30 @@
1
+ type SSEConnection = {
2
+ type: "SSE";
3
+ url: string;
4
+ token?: string;
5
+ headers?: Record<string, string>;
6
+ };
7
+ type WebsocketConnection = {
8
+ type: "Websocket";
9
+ url: string;
10
+ token?: string;
11
+ };
12
+ type DecoConnection = {
13
+ type: "Deco";
14
+ tenant: string;
15
+ token?: string;
16
+ };
17
+ type InnateConnection = {
18
+ type: "INNATE";
19
+ name: string;
20
+ workspace?: string;
21
+ };
22
+ type HTTPConnection = {
23
+ type: "HTTP";
24
+ url: string;
25
+ headers?: Record<string, string>;
26
+ token?: string;
27
+ };
28
+ type MCPConnection = SSEConnection | WebsocketConnection | InnateConnection | DecoConnection | HTTPConnection;
29
+
30
+ export type { DecoConnection, HTTPConnection, InnateConnection, MCPConnection, SSEConnection, WebsocketConnection };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=connection.js.map
3
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"connection.js"}
package/dist/index.d.ts CHANGED
@@ -15,13 +15,17 @@ import { ZodType } from 'zod';
15
15
  * @template TInput - The input type (inferred from inputSchema)
16
16
  * @template TReturn - The return type (inferred from outputSchema)
17
17
  */
18
- interface ToolBinder<TName extends string | RegExp = string, TInput = any, TReturn extends object | null | boolean = object> {
18
+ interface ToolBinder<TName extends string | RegExp = string, TInput = any, TReturn extends object | null | boolean = object, TStreamable extends boolean = boolean> {
19
19
  /** The name of the tool (e.g., "DECO_CHAT_CHANNELS_JOIN") */
20
20
  name: TName;
21
21
  /** Zod schema for validating tool input */
22
22
  inputSchema: ZodType<TInput>;
23
23
  /** Optional Zod schema for validating tool output */
24
- outputSchema?: ZodType<TReturn>;
24
+ outputSchema?: TStreamable extends true ? never : ZodType<TReturn>;
25
+ /**
26
+ * Whether this tool is streamable.
27
+ */
28
+ streamable?: TStreamable;
25
29
  /**
26
30
  * Whether this tool is optional in the binding.
27
31
  * If true, an implementation doesn't need to provide this tool.