@decocms/bindings 0.1.6 → 0.2.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +16 -16
  2. package/dist/browser/agents.js +29 -0
  3. package/dist/browser/agents.js.map +1 -0
  4. package/dist/browser/chunk-6QEXJ7XW.js +48564 -0
  5. package/dist/browser/chunk-6QEXJ7XW.js.map +1 -0
  6. package/dist/browser/chunk-WKNVAFKE.js +2176 -0
  7. package/dist/browser/chunk-WKNVAFKE.js.map +1 -0
  8. package/dist/browser/chunk-XWLBKKHZ.js +127 -0
  9. package/dist/browser/chunk-XWLBKKHZ.js.map +1 -0
  10. package/dist/browser/chunk-ZX4ZDU2T.js +58 -0
  11. package/dist/browser/chunk-ZX4ZDU2T.js.map +1 -0
  12. package/dist/browser/client.js +9 -0
  13. package/dist/browser/client.js.map +1 -0
  14. package/dist/browser/collections.js +4 -0
  15. package/dist/browser/connection.js +8 -0
  16. package/dist/browser/connection.js.map +1 -0
  17. package/dist/browser/index.js +10 -0
  18. package/dist/browser/index.js.map +1 -0
  19. package/dist/browser/language-model.js +205 -0
  20. package/dist/browser/language-model.js.map +1 -0
  21. package/dist/client.d.ts +12 -0
  22. package/dist/client.js +54 -0
  23. package/dist/client.js.map +1 -0
  24. package/dist/{well-known/collections.d.ts → collections.d.ts} +170 -23
  25. package/dist/{chunk-L7E6ONLJ.js → collections.js} +18 -24
  26. package/dist/collections.js.map +1 -0
  27. package/dist/connection.d.ts +30 -0
  28. package/dist/connection.js +3 -0
  29. package/dist/connection.js.map +1 -0
  30. package/dist/index.d.ts +6 -2
  31. package/dist/index.js +262 -1
  32. package/dist/index.js.map +1 -1
  33. package/dist/language-model.d.ts +3228 -0
  34. package/dist/language-model.js +628 -0
  35. package/dist/language-model.js.map +1 -0
  36. package/dist/models.d.ts +2071 -0
  37. package/dist/models.js +111 -0
  38. package/dist/models.js.map +1 -0
  39. package/dist/node/agents.d.ts +903 -0
  40. package/dist/node/agents.js +27 -0
  41. package/dist/node/agents.js.map +1 -0
  42. package/dist/node/chunk-BLCFITZG.js +56 -0
  43. package/dist/node/chunk-BLCFITZG.js.map +1 -0
  44. package/dist/node/chunk-QMQMPK7Q.js +50 -0
  45. package/dist/node/chunk-QMQMPK7Q.js.map +1 -0
  46. package/dist/node/chunk-QP7AQCEP.js +23478 -0
  47. package/dist/node/chunk-QP7AQCEP.js.map +1 -0
  48. package/dist/node/chunk-T2DG7334.js +125 -0
  49. package/dist/node/chunk-T2DG7334.js.map +1 -0
  50. package/dist/node/client.d.ts +12 -0
  51. package/dist/node/client.js +7 -0
  52. package/dist/node/client.js.map +1 -0
  53. package/dist/node/collections.d.ts +537 -0
  54. package/dist/node/collections.js +4 -0
  55. package/dist/node/collections.js.map +1 -0
  56. package/dist/node/connection.d.ts +30 -0
  57. package/dist/node/connection.js +6 -0
  58. package/dist/node/connection.js.map +1 -0
  59. package/dist/node/index.d.ts +94 -0
  60. package/dist/node/index.js +8 -0
  61. package/dist/node/index.js.map +1 -0
  62. package/dist/node/language-model.d.ts +2840 -0
  63. package/dist/node/language-model.js +203 -0
  64. package/dist/node/language-model.js.map +1 -0
  65. package/package.json +45 -17
  66. package/dist/chunk-L7E6ONLJ.js.map +0 -1
  67. package/dist/well-known/collections.js +0 -3
  68. package/dist/well-known/models.d.ts +0 -127
  69. package/dist/well-known/models.js +0 -46
  70. package/dist/well-known/models.js.map +0 -1
  71. package/src/core/binder.ts +0 -221
  72. package/src/index.ts +0 -16
  73. package/src/well-known/collections.ts +0 -328
  74. package/src/well-known/models.ts +0 -79
  75. /package/dist/{well-known → browser}/collections.js.map +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/client/http-client-transport.ts"],"names":[],"mappings":";;;;AAAA,YAAA,EAAA;AAAA,WAAA,EAAA;AAAA,YAAA,EAAA;AAMO,IAAM,mBAAA,GAAN,cAAkC,6BAAA,CAA8B;AAAA,EACrE,WAAA,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A;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":"chunk-ZX4ZDU2T.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"]}
@@ -0,0 +1,9 @@
1
+ export { HTTPClientTransport } from './chunk-ZX4ZDU2T.js';
2
+ import { init_dirname, init_buffer, init_process } from './chunk-WKNVAFKE.js';
3
+
4
+ // src/core/client/index.ts
5
+ init_dirname();
6
+ init_buffer();
7
+ init_process();
8
+ //# sourceMappingURL=client.js.map
9
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/client/index.ts"],"names":[],"mappings":";;;;AAAA,YAAA,EAAA;AAAA,WAAA,EAAA;AAAA,YAAA,EAAA","file":"client.js","sourcesContent":["export { HTTPClientTransport } from \"./http-client-transport\";\n"]}
@@ -0,0 +1,4 @@
1
+ export { BaseCollectionEntitySchema, CollectionDeleteInputSchema, CollectionGetInputSchema, CollectionListInputSchema, OrderByExpressionSchema, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema } from './chunk-XWLBKKHZ.js';
2
+ import './chunk-WKNVAFKE.js';
3
+ //# sourceMappingURL=collections.js.map
4
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1,8 @@
1
+ import { init_dirname, init_buffer, init_process } from './chunk-WKNVAFKE.js';
2
+
3
+ // src/core/connection.ts
4
+ init_dirname();
5
+ init_buffer();
6
+ init_process();
7
+ //# sourceMappingURL=connection.js.map
8
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/connection.ts"],"names":[],"mappings":";;;AAAA,YAAA,EAAA;AAAA,WAAA,EAAA;AAAA,YAAA,EAAA","file":"connection.js","sourcesContent":["export type SSEConnection = {\n type: \"SSE\";\n url: string;\n token?: string;\n headers?: Record<string, string>;\n};\n\nexport type WebsocketConnection = {\n type: \"Websocket\";\n url: string;\n token?: string;\n};\n\nexport type DecoConnection = {\n type: \"Deco\";\n tenant: string;\n token?: string;\n};\n\nexport type InnateConnection = {\n type: \"INNATE\";\n name: string;\n workspace?: string;\n};\n\nexport type HTTPConnection = {\n type: \"HTTP\";\n url: string;\n headers?: Record<string, string>;\n token?: string;\n};\n\nexport type MCPConnection =\n | SSEConnection\n | WebsocketConnection\n | InnateConnection\n | DecoConnection\n | HTTPConnection;\n"]}
@@ -0,0 +1,10 @@
1
+ export { createBindingChecker } from './chunk-6QEXJ7XW.js';
2
+ import './chunk-ZX4ZDU2T.js';
3
+ import { init_dirname, init_buffer, init_process } from './chunk-WKNVAFKE.js';
4
+
5
+ // src/index.ts
6
+ init_dirname();
7
+ init_buffer();
8
+ init_process();
9
+ //# sourceMappingURL=index.js.map
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,YAAA,EAAA;AAAA,WAAA,EAAA;AAAA,YAAA,EAAA","file":"index.js","sourcesContent":["/**\n * @decocms/bindings\n *\n * Core type definitions for the bindings system.\n * Bindings define standardized interfaces that integrations (MCPs) can implement.\n */\n\n// Re-export core binder types and utilities\nexport {\n createBindingChecker,\n type Binder,\n type BindingChecker,\n type ToolBinder,\n type ToolWithSchemas,\n} from \"./core/binder\";\n"]}
@@ -0,0 +1,205 @@
1
+ import { bindingClient } from './chunk-6QEXJ7XW.js';
2
+ import { BaseCollectionEntitySchema, createCollectionBindings } from './chunk-XWLBKKHZ.js';
3
+ import './chunk-ZX4ZDU2T.js';
4
+ import { init_dirname, init_buffer, init_process } from './chunk-WKNVAFKE.js';
5
+ import { z } from 'zod';
6
+
7
+ // src/well-known/language-model.ts
8
+ init_dirname();
9
+ init_buffer();
10
+ init_process();
11
+ var LanguageModelCallOptionsSchema = z.object({
12
+ // Core parameters
13
+ prompt: z.any().describe(
14
+ "A language mode prompt is a standardized prompt type (messages, system, etc.)"
15
+ ),
16
+ // Generation parameters
17
+ maxOutputTokens: z.number().optional().describe("Maximum number of tokens to generate"),
18
+ temperature: z.number().optional().describe(
19
+ "Temperature setting. The range depends on the provider and model"
20
+ ),
21
+ topP: z.number().optional().describe("Nucleus sampling parameter"),
22
+ topK: z.number().optional().describe(
23
+ "Only sample from the top K options for each subsequent token. Used to remove long tail low probability responses"
24
+ ),
25
+ presencePenalty: z.number().optional().describe(
26
+ "Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt"
27
+ ),
28
+ frequencyPenalty: z.number().optional().describe(
29
+ "Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases"
30
+ ),
31
+ seed: z.number().optional().describe(
32
+ "The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results"
33
+ ),
34
+ // Stop sequences
35
+ stopSequences: z.array(z.string()).optional().describe(
36
+ "Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated"
37
+ ),
38
+ // Response format
39
+ responseFormat: z.union([
40
+ z.object({ type: z.literal("text") }),
41
+ z.object({
42
+ type: z.literal("json"),
43
+ schema: z.any().optional().describe("JSON schema that the generated output should conform to"),
44
+ name: z.string().optional().describe("Name of output that should be generated"),
45
+ description: z.string().optional().describe("Description of the output that should be generated")
46
+ })
47
+ ]).optional().describe(
48
+ "Response format. The output can either be text or JSON. Default is text"
49
+ ),
50
+ // Tools
51
+ tools: z.array(z.any()).optional().describe("The tools that are available for the model"),
52
+ toolChoice: z.any().optional().describe("Specifies how the tool should be selected. Defaults to 'auto'"),
53
+ // Stream options
54
+ includeRawChunks: z.boolean().optional().describe(
55
+ "Include raw chunks in the stream. Only applicable for streaming calls"
56
+ ),
57
+ // Abort signal
58
+ abortSignal: z.any().optional().describe("Abort signal for cancelling the operation"),
59
+ // Additional options
60
+ headers: z.record(z.string(), z.union([z.string(), z.undefined()])).optional().describe("Additional HTTP headers to be sent with the request"),
61
+ providerOptions: z.any().optional().describe("Additional provider-specific options")
62
+ });
63
+ var LanguageModelGenerateOutputSchema = z.object({
64
+ // Ordered content that the model has generated
65
+ content: z.array(z.any()).describe(
66
+ "Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)"
67
+ ),
68
+ // Finish reason (required)
69
+ finishReason: z.enum([
70
+ "stop",
71
+ "length",
72
+ "content-filter",
73
+ "tool-calls",
74
+ "error",
75
+ "other",
76
+ "unknown"
77
+ ]).describe("Reason why generation stopped"),
78
+ // Usage information (required)
79
+ usage: z.object({
80
+ inputTokens: z.number().optional(),
81
+ outputTokens: z.number().optional(),
82
+ totalTokens: z.number().optional(),
83
+ reasoningTokens: z.number().optional()
84
+ }).passthrough().transform((val) => ({
85
+ inputTokens: val.inputTokens,
86
+ outputTokens: val.outputTokens,
87
+ totalTokens: val.totalTokens,
88
+ reasoningTokens: val.reasoningTokens,
89
+ ...val
90
+ })).describe("Usage information for the language model call"),
91
+ // Provider metadata
92
+ providerMetadata: z.any().optional().describe("Additional provider-specific metadata"),
93
+ // Request information for telemetry and debugging
94
+ request: z.object({
95
+ body: z.any().optional().describe("Request HTTP body sent to the provider API")
96
+ }).optional().describe("Optional request information for telemetry and debugging"),
97
+ // Response information for telemetry and debugging
98
+ response: z.object({
99
+ id: z.string().optional().describe("ID for the generated response"),
100
+ timestamp: z.date().optional().describe("Timestamp for the start of the generated response"),
101
+ modelId: z.string().optional().describe("The ID of the response model that was used"),
102
+ headers: z.record(z.string(), z.string()).optional().describe("Response headers"),
103
+ body: z.any().optional().describe("Response HTTP body")
104
+ }).optional().describe("Optional response information for telemetry and debugging"),
105
+ // Warnings for the call (required)
106
+ warnings: z.array(z.any()).describe("Warnings for the call, e.g. unsupported settings")
107
+ });
108
+ var LanguageModelStreamOutputSchema = z.object({
109
+ // Stream of language model output parts
110
+ stream: z.any().describe("ReadableStream of LanguageModelV2StreamPart"),
111
+ // Request information for telemetry and debugging
112
+ request: z.object({
113
+ body: z.any().optional().describe("Request HTTP body sent to the provider API")
114
+ }).optional().describe("Optional request information for telemetry and debugging"),
115
+ // Response information
116
+ response: z.object({
117
+ headers: z.record(z.string(), z.string()).optional().describe("Response headers")
118
+ }).optional().describe("Optional response data")
119
+ });
120
+ var LanguageModelMetadataSchema = z.object({
121
+ supportedUrls: z.record(z.string(), z.array(z.string())).describe("Supported URL patterns by media type for the provider")
122
+ });
123
+ var ModelSchema = z.object({
124
+ modelId: z.string().describe("The ID of the model"),
125
+ // Model-specific fields
126
+ logo: z.string().nullable(),
127
+ description: z.string().nullable(),
128
+ capabilities: z.array(z.string()),
129
+ limits: z.object({
130
+ contextWindow: z.number(),
131
+ maxOutputTokens: z.number()
132
+ }).nullable(),
133
+ costs: z.object({
134
+ input: z.number(),
135
+ output: z.number()
136
+ }).nullable(),
137
+ // Provider information
138
+ provider: z.enum([
139
+ "openai",
140
+ "anthropic",
141
+ "google",
142
+ "x-ai",
143
+ "deepseek",
144
+ "openai-compatible",
145
+ "openrouter"
146
+ ]).nullable()
147
+ });
148
+ var LanguageModelInputSchema = z.object({
149
+ modelId: z.string().describe("The ID of the model"),
150
+ callOptions: LanguageModelCallOptionsSchema
151
+ });
152
+ var ModelCollectionEntitySchema = BaseCollectionEntitySchema.extend({
153
+ // Model-specific fields
154
+ logo: z.string().nullable(),
155
+ description: z.string().nullable(),
156
+ capabilities: z.array(z.string()),
157
+ limits: z.object({
158
+ contextWindow: z.number(),
159
+ maxOutputTokens: z.number()
160
+ }).nullable(),
161
+ costs: z.object({
162
+ input: z.number(),
163
+ output: z.number()
164
+ }).nullable(),
165
+ // Provider information
166
+ provider: z.enum([
167
+ "openai",
168
+ "anthropic",
169
+ "google",
170
+ "xai",
171
+ "deepseek",
172
+ "openai-compatible",
173
+ "openrouter"
174
+ ]).nullable()
175
+ });
176
+ var LLM_COLLECTION_BINDING = createCollectionBindings(
177
+ "llm",
178
+ ModelCollectionEntitySchema,
179
+ { readOnly: true }
180
+ );
181
+ var LANGUAGE_MODEL_BINDING = [
182
+ {
183
+ name: "LLM_METADATA",
184
+ inputSchema: z.object({
185
+ modelId: z.string().describe("The ID of the model")
186
+ }),
187
+ outputSchema: LanguageModelMetadataSchema
188
+ },
189
+ {
190
+ name: "LLM_DO_STREAM",
191
+ inputSchema: LanguageModelInputSchema,
192
+ streamable: true
193
+ },
194
+ {
195
+ name: "LLM_DO_GENERATE",
196
+ inputSchema: LanguageModelInputSchema,
197
+ outputSchema: LanguageModelGenerateOutputSchema
198
+ },
199
+ ...LLM_COLLECTION_BINDING
200
+ ];
201
+ var LanguageModelBinding = bindingClient(LANGUAGE_MODEL_BINDING);
202
+
203
+ export { LANGUAGE_MODEL_BINDING, LanguageModelBinding, LanguageModelCallOptionsSchema, LanguageModelGenerateOutputSchema, LanguageModelInputSchema, LanguageModelMetadataSchema, LanguageModelStreamOutputSchema, ModelCollectionEntitySchema, ModelSchema };
204
+ //# sourceMappingURL=language-model.js.map
205
+ //# sourceMappingURL=language-model.js.map
@@ -0,0 +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,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AAAA,IACE,IAAA,EAAM,eAAA;AAAA,IACN,WAAA,EAAa,wBAAA;AAAA,IACb,UAAA,EAAY;AAAA,GACd;AAAA,EACA;AAAA,IACE,IAAA,EAAM,iBAAA;AAAA,IACN,WAAA,EAAa,wBAAA;AAAA,IACb,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 \"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
@@ -9,7 +8,7 @@ import { ToolBinder } from '../index.js';
9
8
  *
10
9
  * Key Features:
11
10
  * - Generic collection bindings that work with any entity type
12
- * - Standardized tool naming: `DECO_COLLECTION_{COLLECTION}_*`
11
+ * - Standardized tool naming: `COLLECTION_{COLLECTION}_*`
13
12
  * - Compatible with TanStack DB query-collection
14
13
  * - Full TypeScript support with proper type constraints
15
14
  * - Support for filtering, sorting, and pagination
@@ -315,18 +314,15 @@ declare const CollectionDeleteInputSchema: z.ZodObject<{
315
314
  id: string;
316
315
  }>;
317
316
  /**
318
- * Delete output schema
317
+ * Factory function to create delete output schema
319
318
  */
320
- declare const CollectionDeleteOutputSchema: z.ZodObject<{
321
- success: z.ZodBoolean;
322
- id: z.ZodString;
323
- }, "strip", z.ZodTypeAny, {
324
- id: string;
325
- success: boolean;
326
- }, {
327
- id: string;
328
- success: boolean;
329
- }>;
319
+ declare function createCollectionDeleteOutputSchema<T extends z.ZodTypeAny>(entitySchema: T): z.ZodObject<{
320
+ item: T;
321
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
322
+ item: T;
323
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
324
+ item: T;
325
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
330
326
  /**
331
327
  * Options for creating collection bindings
332
328
  */
@@ -342,11 +338,11 @@ interface CollectionBindingOptions {
342
338
  *
343
339
  * This function generates standardized tool bindings that work with any collection/table
344
340
  * by accepting a custom entity schema and collection name. The bindings provide:
345
- * - DECO_COLLECTION_{NAME}_LIST - Query/search entities with filtering and sorting (required)
346
- * - DECO_COLLECTION_{NAME}_GET - Get a single entity by ID (required)
347
- * - DECO_COLLECTION_{NAME}_INSERT - Create a new entity (optional, excluded if readOnly=true)
348
- * - DECO_COLLECTION_{NAME}_UPDATE - Update an existing entity (optional, excluded if readOnly=true)
349
- * - DECO_COLLECTION_{NAME}_DELETE - Delete an entity (optional, excluded if readOnly=true)
341
+ * - COLLECTION_{NAME}_LIST - Query/search entities with filtering and sorting (required)
342
+ * - COLLECTION_{NAME}_GET - Get a single entity by ID (required)
343
+ * - COLLECTION_{NAME}_CREATE - Create a new entity (optional, excluded if readOnly=true)
344
+ * - COLLECTION_{NAME}_UPDATE - Update an existing entity (optional, excluded if readOnly=true)
345
+ * - COLLECTION_{NAME}_DELETE - Delete an entity (optional, excluded if readOnly=true)
350
346
  *
351
347
  * @param collectionName - The name of the collection/table (e.g., "users", "products", "orders")
352
348
  * @param entitySchema - The Zod schema for the entity type (must extend BaseCollectionEntitySchema)
@@ -372,19 +368,170 @@ interface CollectionBindingOptions {
372
368
  * const READONLY_COLLECTION_BINDING = createCollectionBindings("products", ProductSchema, { readOnly: true });
373
369
  * ```
374
370
  */
375
- 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
+ ];
376
468
  /**
377
469
  * Type helper to extract the collection binding type
378
470
  */
379
- 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
+ ];
380
492
  /**
381
493
  * Type helper to extract tool names from a collection binding
382
494
  */
383
- 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"];
384
496
  type CollectionListInput = z.infer<typeof CollectionListInputSchema>;
385
497
  type CollectionGetInput = z.infer<typeof CollectionGetInputSchema>;
386
498
  type CollectionDeleteInput = z.infer<typeof CollectionDeleteInputSchema>;
387
- type CollectionDeleteOutput = z.infer<typeof CollectionDeleteOutputSchema>;
388
499
  type OrderByExpression = z.infer<typeof OrderByExpressionSchema>;
500
+ /**
501
+ * Type helper for list output with generic item type
502
+ */
503
+ type CollectionListOutput<T> = {
504
+ items: T[];
505
+ totalCount?: number;
506
+ hasMore?: boolean;
507
+ };
508
+ /**
509
+ * Type helper for get output with generic item type
510
+ */
511
+ type CollectionGetOutput<T> = {
512
+ item: T | null;
513
+ };
514
+ /**
515
+ * Type helper for insert output with generic item type
516
+ */
517
+ type CollectionInsertOutput<T> = {
518
+ item: T;
519
+ };
520
+ /**
521
+ * Type helper for update output with generic item type
522
+ */
523
+ type CollectionUpdateOutput<T> = {
524
+ item: T;
525
+ };
526
+ /**
527
+ * Type helper for delete output with generic item type
528
+ */
529
+ type CollectionDeleteOutput<T> = {
530
+ item: T;
531
+ };
532
+ /**
533
+ * Base collection entity type - inferred from BaseCollectionEntitySchema
534
+ */
535
+ type BaseCollectionEntity = z.infer<typeof BaseCollectionEntitySchema>;
389
536
 
390
- export { BaseCollectionEntitySchema, type BaseCollectionEntitySchemaType, type CollectionBinding, type CollectionBindingOptions, type CollectionDeleteInput, CollectionDeleteInputSchema, type CollectionDeleteOutput, CollectionDeleteOutputSchema, type CollectionGetInput, CollectionGetInputSchema, type CollectionListInput, CollectionListInputSchema, type CollectionTools, type OrderByExpression, OrderByExpressionSchema, type WhereExpression, WhereExpressionSchema, createCollectionBindings, 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 };