@decocms/bindings 0.2.0 → 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 (73) 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/{well-known → browser}/collections.js +2 -1
  14. package/dist/browser/connection.js +8 -0
  15. package/dist/browser/connection.js.map +1 -0
  16. package/dist/browser/index.js +10 -0
  17. package/dist/browser/index.js.map +1 -0
  18. package/dist/browser/language-model.js +205 -0
  19. package/dist/browser/language-model.js.map +1 -0
  20. package/dist/client.d.ts +12 -0
  21. package/dist/client.js +54 -0
  22. package/dist/client.js.map +1 -0
  23. package/dist/{well-known/collections.d.ts → collections.d.ts} +120 -5
  24. package/dist/{chunk-JMM4EZYL.js → collections.js} +2 -2
  25. package/dist/collections.js.map +1 -0
  26. package/dist/connection.d.ts +30 -0
  27. package/dist/connection.js +3 -0
  28. package/dist/connection.js.map +1 -0
  29. package/dist/index.d.ts +6 -2
  30. package/dist/index.js +262 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/language-model.d.ts +3228 -0
  33. package/dist/language-model.js +628 -0
  34. package/dist/language-model.js.map +1 -0
  35. package/dist/models.d.ts +2071 -0
  36. package/dist/models.js +111 -0
  37. package/dist/models.js.map +1 -0
  38. package/dist/node/agents.d.ts +903 -0
  39. package/dist/node/agents.js +27 -0
  40. package/dist/node/agents.js.map +1 -0
  41. package/dist/node/chunk-BLCFITZG.js +56 -0
  42. package/dist/node/chunk-BLCFITZG.js.map +1 -0
  43. package/dist/node/chunk-QMQMPK7Q.js +50 -0
  44. package/dist/node/chunk-QMQMPK7Q.js.map +1 -0
  45. package/dist/node/chunk-QP7AQCEP.js +23478 -0
  46. package/dist/node/chunk-QP7AQCEP.js.map +1 -0
  47. package/dist/node/chunk-T2DG7334.js +125 -0
  48. package/dist/node/chunk-T2DG7334.js.map +1 -0
  49. package/dist/node/client.d.ts +12 -0
  50. package/dist/node/client.js +7 -0
  51. package/dist/node/client.js.map +1 -0
  52. package/dist/node/collections.d.ts +537 -0
  53. package/dist/node/collections.js +4 -0
  54. package/dist/node/collections.js.map +1 -0
  55. package/dist/node/connection.d.ts +30 -0
  56. package/dist/node/connection.js +6 -0
  57. package/dist/node/connection.js.map +1 -0
  58. package/dist/node/index.d.ts +94 -0
  59. package/dist/node/index.js +8 -0
  60. package/dist/node/index.js.map +1 -0
  61. package/dist/node/language-model.d.ts +2840 -0
  62. package/dist/node/language-model.js +203 -0
  63. package/dist/node/language-model.js.map +1 -0
  64. package/package.json +45 -16
  65. package/dist/chunk-JMM4EZYL.js.map +0 -1
  66. package/dist/well-known/models.d.ts +0 -127
  67. package/dist/well-known/models.js +0 -46
  68. package/dist/well-known/models.js.map +0 -1
  69. package/src/core/binder.ts +0 -226
  70. package/src/index.ts +0 -15
  71. package/src/well-known/collections.ts +0 -363
  72. package/src/well-known/models.ts +0 -87
  73. /package/dist/{well-known → browser}/collections.js.map +0 -0
@@ -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";
@@ -1,363 +0,0 @@
1
- import { z } from "zod";
2
- import type { ToolBinder } from "../core/binder";
3
-
4
- /**
5
- * Collection Bindings
6
- *
7
- * This module provides standardized tool bindings for Collections, representing
8
- * SQL table-like structures with CRUD + Search operations compatible with TanStack DB.
9
- *
10
- * Key Features:
11
- * - Generic collection bindings that work with any entity type
12
- * - Standardized tool naming: `COLLECTION_{COLLECTION}_*`
13
- * - Compatible with TanStack DB query-collection
14
- * - Full TypeScript support with proper type constraints
15
- * - Support for filtering, sorting, and pagination
16
- * - Simple id and title fields for human-readable identification
17
- */
18
-
19
- /**
20
- * Base schema for collection entities
21
- * All collection entities must have an id, title, and audit trail fields
22
- */
23
- export const BaseCollectionEntitySchema = z.object({
24
- id: z.string().describe("Unique identifier for the entity"),
25
- title: z.string().describe("Human-readable title for the entity"),
26
- created_at: z.string().datetime(),
27
- updated_at: z.string().datetime(),
28
- created_by: z.string().optional(),
29
- updated_by: z.string().optional(),
30
- });
31
-
32
- /**
33
- * Type helper for BaseCollectionEntitySchema
34
- */
35
- export type BaseCollectionEntitySchemaType = typeof BaseCollectionEntitySchema;
36
-
37
- /**
38
- * Comparison expression schema for filtering
39
- */
40
- const ComparisonExpressionSchema = z.object({
41
- field: z.array(z.string()),
42
- operator: z.enum(["eq", "gt", "gte", "lt", "lte", "in", "like", "contains"]),
43
- value: z.unknown(),
44
- });
45
-
46
- /**
47
- * Where expression schema for filtering
48
- * Supports TanStack DB predicate push-down patterns
49
- */
50
- export const WhereExpressionSchema = z.union([
51
- ComparisonExpressionSchema,
52
- z.object({
53
- operator: z.enum(["and", "or", "not"]),
54
- conditions: z.array(ComparisonExpressionSchema),
55
- }),
56
- ]);
57
-
58
- /**
59
- * Where expression type for filtering
60
- * Derived from WhereExpressionSchema
61
- */
62
- export type WhereExpression = z.infer<typeof WhereExpressionSchema>;
63
-
64
- /**
65
- * Order by expression for sorting
66
- */
67
- export const OrderByExpressionSchema = z.object({
68
- field: z.array(z.string()),
69
- direction: z.enum(["asc", "desc"]),
70
- nulls: z.enum(["first", "last"]).optional(),
71
- });
72
-
73
- /**
74
- * List/Query input schema for collections
75
- * Compatible with TanStack DB LoadSubsetOptions
76
- */
77
- export const CollectionListInputSchema = z.object({
78
- where: WhereExpressionSchema.optional().describe("Filter expression"),
79
- orderBy: z
80
- .array(OrderByExpressionSchema)
81
- .optional()
82
- .describe("Sort expressions"),
83
- limit: z
84
- .number()
85
- .int()
86
- .min(1)
87
- .max(1000)
88
- .optional()
89
- .describe("Maximum number of items to return"),
90
- offset: z
91
- .number()
92
- .int()
93
- .min(0)
94
- .optional()
95
- .describe("Number of items to skip"),
96
- });
97
-
98
- /**
99
- * Factory function to create list output schema for a specific collection type
100
- */
101
- export function createCollectionListOutputSchema<T extends z.ZodTypeAny>(
102
- entitySchema: T,
103
- ) {
104
- return z.object({
105
- items: z.array(entitySchema).describe("Array of collection items"),
106
- totalCount: z
107
- .number()
108
- .int()
109
- .min(0)
110
- .optional()
111
- .describe("Total number of matching items (if available)"),
112
- hasMore: z
113
- .boolean()
114
- .optional()
115
- .describe("Whether there are more items available"),
116
- });
117
- }
118
-
119
- /**
120
- * Get by ID input schema
121
- */
122
- export const CollectionGetInputSchema = z.object({
123
- id: z.string().describe("ID of the entity to retrieve"),
124
- });
125
-
126
- /**
127
- * Factory function to create get output schema
128
- */
129
- export function createCollectionGetOutputSchema<T extends z.ZodTypeAny>(
130
- entitySchema: T,
131
- ) {
132
- return z.object({
133
- item: entitySchema
134
- .nullable()
135
- .describe("The retrieved item, or null if not found"),
136
- });
137
- }
138
-
139
- /**
140
- * Factory function to create insert input schema
141
- */
142
- export function createCollectionInsertInputSchema<T extends z.ZodTypeAny>(
143
- entitySchema: T,
144
- ) {
145
- // Remove id field since it may be auto-generated by the server
146
- return z.object({
147
- data: entitySchema.describe(
148
- "Data for the new entity (id may be auto-generated)",
149
- ),
150
- });
151
- }
152
-
153
- /**
154
- * Factory function to create insert output schema
155
- */
156
- export function createCollectionInsertOutputSchema<T extends z.ZodTypeAny>(
157
- entitySchema: T,
158
- ) {
159
- return z.object({
160
- item: entitySchema.describe("The created entity with generated id"),
161
- });
162
- }
163
-
164
- /**
165
- * Factory function to create update input schema
166
- */
167
- export function createCollectionUpdateInputSchema<T extends z.ZodTypeAny>(
168
- entitySchema: T,
169
- ) {
170
- return z.object({
171
- id: z.string().describe("ID of the entity to update"),
172
- data: (entitySchema as unknown as z.AnyZodObject)
173
- .partial()
174
- .describe("Partial entity data to update"),
175
- });
176
- }
177
-
178
- /**
179
- * Factory function to create update output schema
180
- */
181
- export function createCollectionUpdateOutputSchema<T extends z.ZodTypeAny>(
182
- entitySchema: T,
183
- ) {
184
- return z.object({
185
- item: entitySchema.describe("The updated entity"),
186
- });
187
- }
188
-
189
- /**
190
- * Delete input schema
191
- */
192
- export const CollectionDeleteInputSchema = z.object({
193
- id: z.string().describe("ID of the entity to delete"),
194
- });
195
-
196
- /**
197
- * Factory function to create delete output schema
198
- */
199
- export function createCollectionDeleteOutputSchema<T extends z.ZodTypeAny>(
200
- entitySchema: T,
201
- ) {
202
- return z.object({
203
- item: entitySchema.describe("The deleted entity"),
204
- });
205
- }
206
-
207
- /**
208
- * Options for creating collection bindings
209
- */
210
- export interface CollectionBindingOptions {
211
- /**
212
- * If true, only LIST and GET operations will be included (read-only collection)
213
- * @default false
214
- */
215
- readOnly?: boolean;
216
- }
217
-
218
- /**
219
- * Creates generic collection bindings for a specific entity type
220
- *
221
- * This function generates standardized tool bindings that work with any collection/table
222
- * by accepting a custom entity schema and collection name. The bindings provide:
223
- * - COLLECTION_{NAME}_LIST - Query/search entities with filtering and sorting (required)
224
- * - COLLECTION_{NAME}_GET - Get a single entity by ID (required)
225
- * - COLLECTION_{NAME}_CREATE - Create a new entity (optional, excluded if readOnly=true)
226
- * - COLLECTION_{NAME}_UPDATE - Update an existing entity (optional, excluded if readOnly=true)
227
- * - COLLECTION_{NAME}_DELETE - Delete an entity (optional, excluded if readOnly=true)
228
- *
229
- * @param collectionName - The name of the collection/table (e.g., "users", "products", "orders")
230
- * @param entitySchema - The Zod schema for the entity type (must extend BaseCollectionEntitySchema)
231
- * @param options - Optional configuration for the collection bindings
232
- * @returns Array of tool bindings for Collection CRUD + Query operations
233
- *
234
- * @example
235
- * ```typescript
236
- * const UserSchema = z.object({
237
- * id: z.string(),
238
- * title: z.string(),
239
- * created_at: z.string().datetime(),
240
- * updated_at: z.string().datetime(),
241
- * created_by: z.string().optional(),
242
- * updated_by: z.string().optional(),
243
- * email: z.string().email(),
244
- * });
245
- *
246
- * // Full CRUD collection
247
- * const USER_COLLECTION_BINDING = createCollectionBindings("users", UserSchema);
248
- *
249
- * // Read-only collection (only LIST and GET)
250
- * const READONLY_COLLECTION_BINDING = createCollectionBindings("products", ProductSchema, { readOnly: true });
251
- * ```
252
- */
253
- export function createCollectionBindings<
254
- TEntitySchema extends BaseCollectionEntitySchemaType,
255
- >(
256
- collectionName: string,
257
- entitySchema: TEntitySchema,
258
- options?: CollectionBindingOptions,
259
- ) {
260
- const upperName = collectionName.toUpperCase();
261
- const readOnly = options?.readOnly ?? false;
262
-
263
- const bindings: ToolBinder[] = [
264
- {
265
- name: `COLLECTION_${upperName}_LIST` as const,
266
- inputSchema: CollectionListInputSchema,
267
- outputSchema: createCollectionListOutputSchema(entitySchema),
268
- },
269
- {
270
- name: `COLLECTION_${upperName}_GET` as const,
271
- inputSchema: CollectionGetInputSchema,
272
- outputSchema: createCollectionGetOutputSchema(entitySchema),
273
- },
274
- ];
275
-
276
- // Only include mutation operations if not read-only
277
- if (!readOnly) {
278
- bindings.push(
279
- {
280
- name: `COLLECTION_${upperName}_CREATE` as const,
281
- inputSchema: createCollectionInsertInputSchema(entitySchema),
282
- outputSchema: createCollectionInsertOutputSchema(entitySchema),
283
- opt: true,
284
- },
285
- {
286
- name: `COLLECTION_${upperName}_UPDATE` as const,
287
- inputSchema: createCollectionUpdateInputSchema(entitySchema),
288
- outputSchema: createCollectionUpdateOutputSchema(entitySchema),
289
- opt: true,
290
- },
291
- {
292
- name: `COLLECTION_${upperName}_DELETE` as const,
293
- inputSchema: CollectionDeleteInputSchema,
294
- outputSchema: createCollectionDeleteOutputSchema(entitySchema),
295
- opt: true,
296
- },
297
- );
298
- }
299
-
300
- return bindings satisfies readonly ToolBinder[];
301
- }
302
-
303
- /**
304
- * Type helper to extract the collection binding type
305
- */
306
- export type CollectionBinding<
307
- TEntitySchema extends BaseCollectionEntitySchemaType,
308
- > = ReturnType<typeof createCollectionBindings<TEntitySchema>>;
309
-
310
- /**
311
- * Type helper to extract tool names from a collection binding
312
- */
313
- export type CollectionTools<
314
- TEntitySchema extends BaseCollectionEntitySchemaType,
315
- > = CollectionBinding<TEntitySchema>[number]["name"];
316
-
317
- // Export types for TypeScript usage
318
- export type CollectionListInput = z.infer<typeof CollectionListInputSchema>;
319
- export type CollectionGetInput = z.infer<typeof CollectionGetInputSchema>;
320
- export type CollectionDeleteInput = z.infer<typeof CollectionDeleteInputSchema>;
321
- export type OrderByExpression = z.infer<typeof OrderByExpressionSchema>;
322
-
323
- /**
324
- * Type helper for list output with generic item type
325
- */
326
- export type CollectionListOutput<T> = {
327
- items: T[];
328
- totalCount?: number;
329
- hasMore?: boolean;
330
- };
331
-
332
- /**
333
- * Type helper for get output with generic item type
334
- */
335
- export type CollectionGetOutput<T> = {
336
- item: T | null;
337
- };
338
-
339
- /**
340
- * Type helper for insert output with generic item type
341
- */
342
- export type CollectionInsertOutput<T> = {
343
- item: T;
344
- };
345
-
346
- /**
347
- * Type helper for update output with generic item type
348
- */
349
- export type CollectionUpdateOutput<T> = {
350
- item: T;
351
- };
352
-
353
- /**
354
- * Type helper for delete output with generic item type
355
- */
356
- export type CollectionDeleteOutput<T> = {
357
- item: T;
358
- };
359
-
360
- /**
361
- * Base collection entity type - inferred from BaseCollectionEntitySchema
362
- */
363
- export type BaseCollectionEntity = z.infer<typeof BaseCollectionEntitySchema>;
@@ -1,87 +0,0 @@
1
- /**
2
- * Models Well-Known Binding
3
- *
4
- * Defines the interface for AI model providers.
5
- * Any MCP that implements this binding can provide AI models and streaming endpoints.
6
- *
7
- * This binding uses collection bindings for LIST and GET operations (read-only).
8
- * Streaming endpoint information is included directly in the model entity schema.
9
- */
10
-
11
- import { z } from "zod";
12
- import type { Binder } from "../core/binder";
13
- import {
14
- BaseCollectionEntitySchema,
15
- createCollectionBindings,
16
- } from "./collections";
17
-
18
- /**
19
- * Model entity schema for AI models
20
- * Extends BaseCollectionEntitySchema with model-specific fields
21
- * Base schema already includes: id, title, created_at, updated_at, created_by, updated_by
22
- */
23
- export const ModelSchema = BaseCollectionEntitySchema.extend({
24
- // Model-specific fields
25
- logo: z.string().nullable(),
26
- description: z.string().nullable(),
27
- capabilities: z.array(z.string()),
28
- limits: z
29
- .object({
30
- contextWindow: z.number(),
31
- maxOutputTokens: z.number(),
32
- })
33
- .nullable(),
34
- costs: z
35
- .object({
36
- input: z.number(),
37
- output: z.number(),
38
- })
39
- .nullable(),
40
- // Provider information
41
- provider: z
42
- .enum([
43
- "openai",
44
- "anthropic",
45
- "google",
46
- "xai",
47
- "deepseek",
48
- "openai-compatible",
49
- "openrouter",
50
- ])
51
- .nullable(),
52
- // Streaming endpoint information
53
- endpoint: z
54
- .object({
55
- url: z.string().url(),
56
- method: z.string().default("POST"),
57
- contentType: z.string().default("application/json"),
58
- stream: z.boolean().default(true),
59
- })
60
- .nullable(),
61
- });
62
-
63
- /**
64
- * MODELS Collection Binding
65
- *
66
- * Collection bindings for models (read-only).
67
- * Provides LIST and GET operations for AI models.
68
- */
69
- export const MODELS_COLLECTION_BINDING = createCollectionBindings(
70
- "models",
71
- ModelSchema,
72
- { readOnly: true },
73
- );
74
-
75
- /**
76
- * MODELS Binding
77
- *
78
- * Defines the interface for AI model providers.
79
- * Any MCP that implements this binding can provide AI models and streaming endpoints.
80
- *
81
- * Required tools:
82
- * - COLLECTION_MODELS_LIST: List available AI models with their capabilities
83
- * - COLLECTION_MODELS_GET: Get a single model by ID (includes streaming endpoint info)
84
- */
85
- export const MODELS_BINDING = [
86
- ...MODELS_COLLECTION_BINDING,
87
- ] as const satisfies Binder;
File without changes