@decocms/bindings 0.2.1 → 0.2.2

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 (51) hide show
  1. package/dist/browser/agents.js +29 -0
  2. package/dist/browser/agents.js.map +1 -0
  3. package/dist/browser/chunk-6QEXJ7XW.js +48564 -0
  4. package/dist/browser/chunk-6QEXJ7XW.js.map +1 -0
  5. package/dist/browser/chunk-WKNVAFKE.js +2176 -0
  6. package/dist/browser/chunk-WKNVAFKE.js.map +1 -0
  7. package/dist/browser/chunk-XWLBKKHZ.js +127 -0
  8. package/dist/browser/chunk-XWLBKKHZ.js.map +1 -0
  9. package/dist/browser/chunk-ZX4ZDU2T.js +58 -0
  10. package/dist/browser/chunk-ZX4ZDU2T.js.map +1 -0
  11. package/dist/browser/client.js +9 -0
  12. package/dist/browser/client.js.map +1 -0
  13. package/dist/browser/collections.js +4 -0
  14. package/dist/browser/collections.js.map +1 -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/node/agents.d.ts +903 -0
  22. package/dist/node/agents.js +27 -0
  23. package/dist/node/agents.js.map +1 -0
  24. package/dist/node/chunk-BLCFITZG.js +56 -0
  25. package/dist/node/chunk-BLCFITZG.js.map +1 -0
  26. package/dist/node/chunk-QMQMPK7Q.js +50 -0
  27. package/dist/node/chunk-QMQMPK7Q.js.map +1 -0
  28. package/dist/node/chunk-QP7AQCEP.js +23478 -0
  29. package/dist/node/chunk-QP7AQCEP.js.map +1 -0
  30. package/dist/node/chunk-T2DG7334.js +125 -0
  31. package/dist/node/chunk-T2DG7334.js.map +1 -0
  32. package/dist/node/client.d.ts +12 -0
  33. package/dist/node/client.js +7 -0
  34. package/dist/node/client.js.map +1 -0
  35. package/dist/node/collections.d.ts +537 -0
  36. package/dist/node/collections.js +4 -0
  37. package/dist/node/collections.js.map +1 -0
  38. package/dist/node/connection.d.ts +30 -0
  39. package/dist/node/connection.js +6 -0
  40. package/dist/node/connection.js.map +1 -0
  41. package/dist/node/index.d.ts +94 -0
  42. package/dist/node/index.js +8 -0
  43. package/dist/node/index.js.map +1 -0
  44. package/dist/node/language-model.d.ts +2840 -0
  45. package/dist/node/language-model.js +203 -0
  46. package/dist/node/language-model.js.map +1 -0
  47. package/package.json +45 -16
  48. package/src/core/binder.ts +0 -226
  49. package/src/index.ts +0 -15
  50. package/src/well-known/collections.ts +0 -363
  51. package/src/well-known/models.ts +0 -87
@@ -0,0 +1,203 @@
1
+ import { bindingClient } from './chunk-QP7AQCEP.js';
2
+ import { BaseCollectionEntitySchema, createCollectionBindings } from './chunk-T2DG7334.js';
3
+ import './chunk-BLCFITZG.js';
4
+ import { init_esm_shims } from './chunk-QMQMPK7Q.js';
5
+ import { z } from 'zod';
6
+
7
+ // src/well-known/language-model.ts
8
+ init_esm_shims();
9
+ var LanguageModelCallOptionsSchema = z.object({
10
+ // Core parameters
11
+ prompt: z.any().describe(
12
+ "A language mode prompt is a standardized prompt type (messages, system, etc.)"
13
+ ),
14
+ // Generation parameters
15
+ maxOutputTokens: z.number().optional().describe("Maximum number of tokens to generate"),
16
+ temperature: z.number().optional().describe(
17
+ "Temperature setting. The range depends on the provider and model"
18
+ ),
19
+ topP: z.number().optional().describe("Nucleus sampling parameter"),
20
+ topK: z.number().optional().describe(
21
+ "Only sample from the top K options for each subsequent token. Used to remove long tail low probability responses"
22
+ ),
23
+ presencePenalty: z.number().optional().describe(
24
+ "Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt"
25
+ ),
26
+ frequencyPenalty: z.number().optional().describe(
27
+ "Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases"
28
+ ),
29
+ seed: z.number().optional().describe(
30
+ "The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results"
31
+ ),
32
+ // Stop sequences
33
+ stopSequences: z.array(z.string()).optional().describe(
34
+ "Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated"
35
+ ),
36
+ // Response format
37
+ responseFormat: z.union([
38
+ z.object({ type: z.literal("text") }),
39
+ z.object({
40
+ type: z.literal("json"),
41
+ schema: z.any().optional().describe("JSON schema that the generated output should conform to"),
42
+ name: z.string().optional().describe("Name of output that should be generated"),
43
+ description: z.string().optional().describe("Description of the output that should be generated")
44
+ })
45
+ ]).optional().describe(
46
+ "Response format. The output can either be text or JSON. Default is text"
47
+ ),
48
+ // Tools
49
+ tools: z.array(z.any()).optional().describe("The tools that are available for the model"),
50
+ toolChoice: z.any().optional().describe("Specifies how the tool should be selected. Defaults to 'auto'"),
51
+ // Stream options
52
+ includeRawChunks: z.boolean().optional().describe(
53
+ "Include raw chunks in the stream. Only applicable for streaming calls"
54
+ ),
55
+ // Abort signal
56
+ abortSignal: z.any().optional().describe("Abort signal for cancelling the operation"),
57
+ // Additional options
58
+ headers: z.record(z.string(), z.union([z.string(), z.undefined()])).optional().describe("Additional HTTP headers to be sent with the request"),
59
+ providerOptions: z.any().optional().describe("Additional provider-specific options")
60
+ });
61
+ var LanguageModelGenerateOutputSchema = z.object({
62
+ // Ordered content that the model has generated
63
+ content: z.array(z.any()).describe(
64
+ "Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)"
65
+ ),
66
+ // Finish reason (required)
67
+ finishReason: z.enum([
68
+ "stop",
69
+ "length",
70
+ "content-filter",
71
+ "tool-calls",
72
+ "error",
73
+ "other",
74
+ "unknown"
75
+ ]).describe("Reason why generation stopped"),
76
+ // Usage information (required)
77
+ usage: z.object({
78
+ inputTokens: z.number().optional(),
79
+ outputTokens: z.number().optional(),
80
+ totalTokens: z.number().optional(),
81
+ reasoningTokens: z.number().optional()
82
+ }).passthrough().transform((val) => ({
83
+ inputTokens: val.inputTokens,
84
+ outputTokens: val.outputTokens,
85
+ totalTokens: val.totalTokens,
86
+ reasoningTokens: val.reasoningTokens,
87
+ ...val
88
+ })).describe("Usage information for the language model call"),
89
+ // Provider metadata
90
+ providerMetadata: z.any().optional().describe("Additional provider-specific metadata"),
91
+ // Request information for telemetry and debugging
92
+ request: z.object({
93
+ body: z.any().optional().describe("Request HTTP body sent to the provider API")
94
+ }).optional().describe("Optional request information for telemetry and debugging"),
95
+ // Response information for telemetry and debugging
96
+ response: z.object({
97
+ id: z.string().optional().describe("ID for the generated response"),
98
+ timestamp: z.date().optional().describe("Timestamp for the start of the generated response"),
99
+ modelId: z.string().optional().describe("The ID of the response model that was used"),
100
+ headers: z.record(z.string(), z.string()).optional().describe("Response headers"),
101
+ body: z.any().optional().describe("Response HTTP body")
102
+ }).optional().describe("Optional response information for telemetry and debugging"),
103
+ // Warnings for the call (required)
104
+ warnings: z.array(z.any()).describe("Warnings for the call, e.g. unsupported settings")
105
+ });
106
+ var LanguageModelStreamOutputSchema = z.object({
107
+ // Stream of language model output parts
108
+ stream: z.any().describe("ReadableStream of LanguageModelV2StreamPart"),
109
+ // Request information for telemetry and debugging
110
+ request: z.object({
111
+ body: z.any().optional().describe("Request HTTP body sent to the provider API")
112
+ }).optional().describe("Optional request information for telemetry and debugging"),
113
+ // Response information
114
+ response: z.object({
115
+ headers: z.record(z.string(), z.string()).optional().describe("Response headers")
116
+ }).optional().describe("Optional response data")
117
+ });
118
+ var LanguageModelMetadataSchema = z.object({
119
+ supportedUrls: z.record(z.string(), z.array(z.string())).describe("Supported URL patterns by media type for the provider")
120
+ });
121
+ var ModelSchema = z.object({
122
+ modelId: z.string().describe("The ID of the model"),
123
+ // Model-specific fields
124
+ logo: z.string().nullable(),
125
+ description: z.string().nullable(),
126
+ capabilities: z.array(z.string()),
127
+ limits: z.object({
128
+ contextWindow: z.number(),
129
+ maxOutputTokens: z.number()
130
+ }).nullable(),
131
+ costs: z.object({
132
+ input: z.number(),
133
+ output: z.number()
134
+ }).nullable(),
135
+ // Provider information
136
+ provider: z.enum([
137
+ "openai",
138
+ "anthropic",
139
+ "google",
140
+ "xai",
141
+ "deepseek",
142
+ "openai-compatible",
143
+ "openrouter"
144
+ ]).nullable()
145
+ });
146
+ var LanguageModelInputSchema = z.object({
147
+ modelId: z.string().describe("The ID of the model"),
148
+ callOptions: LanguageModelCallOptionsSchema
149
+ });
150
+ var ModelCollectionEntitySchema = BaseCollectionEntitySchema.extend({
151
+ // Model-specific fields
152
+ logo: z.string().nullable(),
153
+ description: z.string().nullable(),
154
+ capabilities: z.array(z.string()),
155
+ limits: z.object({
156
+ contextWindow: z.number(),
157
+ maxOutputTokens: z.number()
158
+ }).nullable(),
159
+ costs: z.object({
160
+ input: z.number(),
161
+ output: z.number()
162
+ }).nullable(),
163
+ // Provider information
164
+ provider: z.enum([
165
+ "openai",
166
+ "anthropic",
167
+ "google",
168
+ "xai",
169
+ "deepseek",
170
+ "openai-compatible",
171
+ "openrouter"
172
+ ]).nullable()
173
+ });
174
+ var LLM_COLLECTION_BINDING = createCollectionBindings(
175
+ "llm",
176
+ ModelCollectionEntitySchema,
177
+ { readOnly: true }
178
+ );
179
+ var LANGUAGE_MODEL_BINDING = [
180
+ {
181
+ name: "LLM_METADATA",
182
+ inputSchema: z.object({
183
+ modelId: z.string().describe("The ID of the model")
184
+ }),
185
+ outputSchema: LanguageModelMetadataSchema
186
+ },
187
+ {
188
+ name: "LLM_DO_STREAM",
189
+ inputSchema: LanguageModelInputSchema,
190
+ streamable: true
191
+ },
192
+ {
193
+ name: "LLM_DO_GENERATE",
194
+ inputSchema: LanguageModelInputSchema,
195
+ outputSchema: LanguageModelGenerateOutputSchema
196
+ },
197
+ ...LLM_COLLECTION_BINDING
198
+ ];
199
+ var LanguageModelBinding = bindingClient(LANGUAGE_MODEL_BINDING);
200
+
201
+ export { LANGUAGE_MODEL_BINDING, LanguageModelBinding, LanguageModelCallOptionsSchema, LanguageModelGenerateOutputSchema, LanguageModelInputSchema, LanguageModelMetadataSchema, LanguageModelStreamOutputSchema, ModelCollectionEntitySchema, ModelSchema };
202
+ //# sourceMappingURL=language-model.js.map
203
+ //# sourceMappingURL=language-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/well-known/language-model.ts"],"names":[],"mappings":";;;;;;;AAAA,cAAA,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,CAAM;AAAA,IACL,CAAA,CAAE,OAAO,EAAE,IAAA,EAAM,EAAE,OAAA,CAAQ,MAAM,GAAG,CAAA;AAAA,IACpC,EAAE,MAAA,CAAO;AAAA,MACP,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,MAAM,CAAA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AAQ,EACL,MAAA,CAAO;AAAA,IACN,aAAA,EAAe,EAAE,MAAA,EAAO;AAAA,IACxB,eAAA,EAAiB,EAAE,MAAA;AAAO,GAC3B,EACA,QAAA,EAAS;AAAA,EACZ,KAAA,EAAO,EACJ,MAAA,CAAO;AAAA,IACN,KAAA,EAAO,EAAE,MAAA,EAAO;AAAA,IAChB,MAAA,EAAQ,EAAE,MAAA;AAAO,GAClB,EACA,QAAA,EAAS;AAAA;AAAA,EAEZ,QAAA,EAAU,EACP,IAAA,CAAK;AAAA,IACJ,QAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACD,EACA,QAAA;AACL,CAAC;AAQD,IAAM,sBAAA,GAAyB,wBAAA;AAAA,EAC7B,KAAA;AAAA,EACA,2BAAA;AAAA,EACA,EAAE,UAAU,IAAA;AACd,CAAA;AAeO,IAAM,sBAAA,GAAyB;AAAA,EACpC;AAAA,IACE,IAAA,EAAM,cAAA;AAAA,IACN,WAAA,EAAa,EAAE,MAAA,CAAO;AAAA,MACpB,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,qBAAqB;AAAA,KACnD,CAAA;AAAA,IACD,YAAA,EAAc;AAAA,GAChB;AAAA,EACA;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 \"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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/bindings",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -11,32 +11,61 @@
11
11
  "dependencies": {
12
12
  "json-schema-diff": "^1.0.0",
13
13
  "zod": "^3.25.76",
14
- "zod-to-json-schema": "^3.24.4"
14
+ "zod-to-json-schema": "^3.24.4",
15
+ "zod-from-json-schema": "^0.0.5",
16
+ "@modelcontextprotocol/sdk": "^1.20.2"
15
17
  },
16
- "main": "./dist/index.js",
17
- "types": "./src/index.ts",
18
+ "main": "./dist/node/index.js",
19
+ "types": "./dist/node/index.d.ts",
18
20
  "files": [
19
- "dist/**/*",
20
- "src/**/*"
21
+ "dist/**/*"
21
22
  ],
22
23
  "exports": {
23
24
  ".": {
24
- "source": "./src/index.ts",
25
- "types": "./src/index.ts",
26
- "default": "./dist/index.js"
25
+ "types": "./dist/node/index.d.ts",
26
+ "browser": "./dist/browser/index.js",
27
+ "bun": "./dist/node/index.js",
28
+ "node": "./dist/node/index.js",
29
+ "default": "./dist/node/index.js"
27
30
  },
28
- "./models": {
29
- "source": "./src/well-known/models.ts",
30
- "types": "./src/well-known/models.ts",
31
- "default": "./dist/well-known/models.js"
31
+ "./client": {
32
+ "types": "./dist/node/index.d.ts",
33
+ "browser": "./dist/browser/index.js",
34
+ "bun": "./dist/node/index.js",
35
+ "node": "./dist/node/index.js",
36
+ "default": "./dist/node/index.js"
37
+ },
38
+ "./llm": {
39
+ "types": "./dist/node/language-model.d.ts",
40
+ "browser": "./dist/browser/language-model.js",
41
+ "bun": "./dist/node/language-model.js",
42
+ "node": "./dist/node/language-model.js",
43
+ "default": "./dist/node/language-model.js"
44
+ },
45
+ "./connection": {
46
+ "types": "./dist/node/connection.d.ts",
47
+ "browser": "./dist/browser/connection.js",
48
+ "bun": "./dist/node/connection.js",
49
+ "node": "./dist/node/connection.js",
50
+ "default": "./dist/node/connection.js"
32
51
  },
33
52
  "./collections": {
34
- "source": "./src/well-known/collections.ts",
35
- "types": "./src/well-known/collections.ts",
36
- "default": "./dist/well-known/collections.js"
53
+ "types": "./dist/node/collections.d.ts",
54
+ "browser": "./dist/browser/collections.js",
55
+ "bun": "./dist/node/collections.js",
56
+ "node": "./dist/node/collections.js",
57
+ "default": "./dist/node/collections.js"
58
+ },
59
+ "./agents": {
60
+ "types": "./dist/node/agents.d.ts",
61
+ "browser": "./dist/browser/agents.js",
62
+ "bun": "./dist/node/agents.js",
63
+ "node": "./dist/node/agents.js",
64
+ "default": "./dist/node/agents.js"
37
65
  }
38
66
  },
39
67
  "devDependencies": {
68
+ "esbuild-plugin-polyfill-node": "^0.3.0",
40
69
  "tsup": "^8.5.0",
41
70
  "typescript": "^5.9.3",
42
71
  "vitest": "3.2.4"
@@ -1,226 +0,0 @@
1
- /**
2
- * Core Binder Types and Utilities
3
- *
4
- * This module provides the core types and utilities for the bindings system.
5
- * Bindings define standardized interfaces that integrations (MCPs) can implement.
6
- */
7
-
8
- import type { ZodType } from "zod";
9
- import { zodToJsonSchema } from "zod-to-json-schema";
10
- import { diffSchemas } from "json-schema-diff";
11
-
12
- /**
13
- * ToolBinder defines a single tool within a binding.
14
- * It specifies the tool name, input/output schemas, and whether it's optional.
15
- *
16
- * @template TName - The tool name (can be a string or RegExp for pattern matching)
17
- * @template TInput - The input type (inferred from inputSchema)
18
- * @template TReturn - The return type (inferred from outputSchema)
19
- */
20
- export interface ToolBinder<
21
- TName extends string | RegExp = string,
22
- // biome-ignore lint/suspicious/noExplicitAny: Generic type parameter
23
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
- TInput = any,
25
- TReturn extends object | null | boolean = object,
26
- > {
27
- /** The name of the tool (e.g., "DECO_CHAT_CHANNELS_JOIN") */
28
- name: TName;
29
-
30
- /** Zod schema for validating tool input */
31
- inputSchema: ZodType<TInput>;
32
-
33
- /** Optional Zod schema for validating tool output */
34
- outputSchema?: ZodType<TReturn>;
35
-
36
- /**
37
- * Whether this tool is optional in the binding.
38
- * If true, an implementation doesn't need to provide this tool.
39
- */
40
- opt?: true;
41
- }
42
-
43
- /**
44
- * Binder represents a collection of tool definitions that form a binding.
45
- * A binding is like a TypeScript interface - it defines what tools must be implemented.
46
- *
47
- * @template TDefinition - Array of ToolBinder definitions
48
- *
49
- * @example
50
- * ```ts
51
- * const MY_BINDING = [{
52
- * name: "MY_TOOL" as const,
53
- * inputSchema: z.object({ id: z.string() }),
54
- * outputSchema: z.object({ success: z.boolean() }),
55
- * }] as const satisfies Binder;
56
- * ```
57
- */
58
- export type Binder<
59
- TDefinition extends readonly ToolBinder[] = readonly ToolBinder[],
60
- > = TDefinition;
61
-
62
- /**
63
- * Tool with schemas for validation
64
- */
65
- export interface ToolWithSchemas {
66
- name: string;
67
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
- inputSchema?: ZodType<any> | Record<string, unknown>;
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- outputSchema?: ZodType<any> | Record<string, unknown>;
71
- }
72
-
73
- /**
74
- * Converts a schema to JSON Schema format if it's a Zod schema
75
- */
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- function normalizeSchema(schema: any): Record<string, unknown> | undefined {
78
- if (!schema) return undefined;
79
-
80
- // If it's a Zod schema (has _def property), convert it
81
- if (schema._def) {
82
- const jsonSchema = zodToJsonSchema(schema, {
83
- // Don't add additionalProperties: false to allow structural compatibility
84
- $refStrategy: "none",
85
- }) as Record<string, unknown>;
86
-
87
- // Remove additionalProperties constraint to allow subtyping
88
- if (jsonSchema.type === "object") {
89
- delete jsonSchema.additionalProperties;
90
- }
91
-
92
- return jsonSchema;
93
- }
94
-
95
- // Otherwise assume it's already a JSON Schema
96
- const jsonSchema = schema as Record<string, unknown>;
97
-
98
- // Remove additionalProperties constraint if present
99
- if (jsonSchema.type === "object" && "additionalProperties" in jsonSchema) {
100
- const copy = { ...jsonSchema };
101
- delete copy.additionalProperties;
102
- return copy;
103
- }
104
-
105
- return jsonSchema;
106
- }
107
-
108
- /**
109
- * Binding checker interface
110
- */
111
- export interface BindingChecker {
112
- /**
113
- * Check if a set of tools implements the binding with full schema validation.
114
- *
115
- * Validates:
116
- * - Tool name matches (exact or regex)
117
- * - Input schema: Tool accepts what binder requires (no removals from binder to tool)
118
- * - Output schema: Tool provides what binder expects (no removals from tool to binder)
119
- *
120
- * @param tools - Array of tools with names and schemas
121
- * @returns Promise<boolean> - true if all tools implement the binding correctly
122
- */
123
- isImplementedBy: (tools: ToolWithSchemas[]) => Promise<boolean>;
124
- }
125
-
126
- /**
127
- * Creates a binding checker with full schema validation using json-schema-diff.
128
- *
129
- * This performs strict compatibility checking:
130
- * - For input schemas: Validates that the tool can accept what the binder requires
131
- * - For output schemas: Validates that the tool provides what the binder expects
132
- *
133
- * @param binderTools - The binding definition to check against
134
- * @returns A binding checker with an async isImplementedBy method
135
- *
136
- * @example
137
- * ```ts
138
- * const checker = createBindingChecker(MY_BINDING);
139
- * const isCompatible = await checker.isImplementedBy(availableTools);
140
- * ```
141
- */
142
- export function createBindingChecker<TDefinition extends readonly ToolBinder[]>(
143
- binderTools: TDefinition,
144
- ): BindingChecker {
145
- return {
146
- isImplementedBy: async (tools: ToolWithSchemas[]) => {
147
- for (const binderTool of binderTools) {
148
- // Find matching tool by name (exact or regex)
149
- const pattern =
150
- typeof binderTool.name === "string"
151
- ? new RegExp(`^${binderTool.name}$`)
152
- : binderTool.name;
153
-
154
- const matchedTool = tools.find((t) => pattern.test(t.name));
155
-
156
- // Skip optional tools that aren't present
157
- if (!matchedTool && binderTool.opt) {
158
- continue;
159
- }
160
-
161
- // Required tool not found
162
- if (!matchedTool) {
163
- return false;
164
- }
165
-
166
- // === INPUT SCHEMA VALIDATION ===
167
- // Tool must accept what binder requires
168
- // Check: binder (source) -> tool (destination)
169
- // If removals found, tool doesn't accept something binder requires
170
- const binderInputSchema = normalizeSchema(binderTool.inputSchema);
171
- const toolInputSchema = normalizeSchema(matchedTool.inputSchema);
172
-
173
- if (binderInputSchema && toolInputSchema) {
174
- try {
175
- const inputDiff = await diffSchemas({
176
- sourceSchema: binderInputSchema,
177
- destinationSchema: toolInputSchema,
178
- });
179
-
180
- // If something was removed from binder to tool, tool can't accept it
181
- if (inputDiff.removalsFound) {
182
- return false;
183
- }
184
- } catch (error) {
185
- console.error("Schema diff failed", error);
186
- // Schema diff failed - consider incompatible
187
- return false;
188
- }
189
- } else if (binderInputSchema && !toolInputSchema) {
190
- // Binder requires input schema but tool doesn't have one
191
- return false;
192
- }
193
-
194
- // === OUTPUT SCHEMA VALIDATION ===
195
- // Tool must provide what binder expects (but can provide more)
196
- // Check: binder (source) -> tool (destination)
197
- // If removals found, tool doesn't provide something binder expects
198
- const binderOutputSchema = normalizeSchema(binderTool.outputSchema);
199
- const toolOutputSchema = normalizeSchema(matchedTool.outputSchema);
200
-
201
- if (binderOutputSchema && toolOutputSchema) {
202
- try {
203
- const outputDiff = await diffSchemas({
204
- sourceSchema: binderOutputSchema,
205
- destinationSchema: toolOutputSchema,
206
- });
207
-
208
- // If something was removed from binder to tool, tool doesn't provide it
209
- if (outputDiff.removalsFound) {
210
- return false;
211
- }
212
- } catch (error) {
213
- console.error("Schema diff failed", error);
214
- // Schema diff failed - consider incompatible
215
- return false;
216
- }
217
- } else if (binderOutputSchema && !toolOutputSchema) {
218
- // Binder expects output schema but tool doesn't have one
219
- return false;
220
- }
221
- }
222
-
223
- return true;
224
- },
225
- };
226
- }
package/src/index.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * @decocms/bindings
3
- *
4
- * Core type definitions for the bindings system.
5
- * Bindings define standardized interfaces that integrations (MCPs) can implement.
6
- */
7
-
8
- // Re-export core binder types and utilities
9
- export {
10
- type ToolBinder,
11
- type Binder,
12
- type ToolWithSchemas,
13
- type BindingChecker,
14
- createBindingChecker,
15
- } from "./core/binder";