@decocms/bindings 0.2.4-beta.1 → 0.2.4-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +5 -5
  2. package/dist/core/binder.d.ts +3 -0
  3. package/dist/core/binder.js +81 -0
  4. package/dist/core/binder.js.map +1 -0
  5. package/dist/{client.js → core/client/http-client-transport.js} +9 -9
  6. package/dist/core/client/http-client-transport.js.map +1 -0
  7. package/dist/core/client/index.d.ts +3 -0
  8. package/dist/core/client/index.js +5 -0
  9. package/dist/core/client/index.js.map +1 -0
  10. package/dist/core/client/mcp-client.d.ts +233 -0
  11. package/dist/core/client/mcp-client.js +99 -0
  12. package/dist/core/client/mcp-client.js.map +1 -0
  13. package/dist/core/client/mcp.d.ts +3 -0
  14. package/dist/core/client/mcp.js +29 -0
  15. package/dist/core/client/mcp.js.map +1 -0
  16. package/dist/core/client/proxy.d.ts +10 -0
  17. package/dist/core/client/proxy.js +104 -0
  18. package/dist/core/client/proxy.js.map +1 -0
  19. package/dist/core/connection.js +1 -0
  20. package/dist/core/connection.js.map +1 -0
  21. package/dist/core/subset.d.ts +17 -0
  22. package/dist/core/subset.js +321 -0
  23. package/dist/core/subset.js.map +1 -0
  24. package/dist/index-D0aUdNls.d.ts +153 -0
  25. package/dist/index.d.ts +3 -94
  26. package/dist/index.js +5 -340
  27. package/dist/index.js.map +1 -1
  28. package/dist/{node → well-known}/agents.d.ts +64 -64
  29. package/dist/well-known/agents.js +28 -0
  30. package/dist/well-known/agents.js.map +1 -0
  31. package/dist/{node → well-known}/collections.d.ts +1 -1
  32. package/dist/{collections.js → well-known/collections.js} +24 -13
  33. package/dist/well-known/collections.js.map +1 -0
  34. package/dist/{node → well-known}/language-model.d.ts +387 -391
  35. package/dist/{node → well-known}/language-model.js +27 -21
  36. package/dist/well-known/language-model.js.map +1 -0
  37. package/package.json +17 -37
  38. package/dist/browser/agents.js +0 -29
  39. package/dist/browser/agents.js.map +0 -1
  40. package/dist/browser/chunk-6QEXJ7XW.js +0 -48564
  41. package/dist/browser/chunk-6QEXJ7XW.js.map +0 -1
  42. package/dist/browser/chunk-WKNVAFKE.js +0 -2176
  43. package/dist/browser/chunk-WKNVAFKE.js.map +0 -1
  44. package/dist/browser/chunk-XWLBKKHZ.js +0 -127
  45. package/dist/browser/chunk-XWLBKKHZ.js.map +0 -1
  46. package/dist/browser/chunk-ZX4ZDU2T.js +0 -58
  47. package/dist/browser/chunk-ZX4ZDU2T.js.map +0 -1
  48. package/dist/browser/client.js +0 -9
  49. package/dist/browser/client.js.map +0 -1
  50. package/dist/browser/collections.js +0 -4
  51. package/dist/browser/collections.js.map +0 -1
  52. package/dist/browser/connection.js +0 -8
  53. package/dist/browser/connection.js.map +0 -1
  54. package/dist/browser/index.js +0 -10
  55. package/dist/browser/index.js.map +0 -1
  56. package/dist/browser/language-model.js +0 -205
  57. package/dist/browser/language-model.js.map +0 -1
  58. package/dist/client.js.map +0 -1
  59. package/dist/collections.d.ts +0 -537
  60. package/dist/collections.js.map +0 -1
  61. package/dist/connection.js +0 -3
  62. package/dist/connection.js.map +0 -1
  63. package/dist/language-model.d.ts +0 -3228
  64. package/dist/language-model.js +0 -628
  65. package/dist/language-model.js.map +0 -1
  66. package/dist/models.d.ts +0 -2071
  67. package/dist/models.js +0 -111
  68. package/dist/models.js.map +0 -1
  69. package/dist/node/agents.js +0 -27
  70. package/dist/node/agents.js.map +0 -1
  71. package/dist/node/chunk-BLCFITZG.js +0 -56
  72. package/dist/node/chunk-BLCFITZG.js.map +0 -1
  73. package/dist/node/chunk-QMQMPK7Q.js +0 -50
  74. package/dist/node/chunk-QMQMPK7Q.js.map +0 -1
  75. package/dist/node/chunk-QP7AQCEP.js +0 -23478
  76. package/dist/node/chunk-QP7AQCEP.js.map +0 -1
  77. package/dist/node/chunk-T2DG7334.js +0 -125
  78. package/dist/node/chunk-T2DG7334.js.map +0 -1
  79. package/dist/node/client.d.ts +0 -12
  80. package/dist/node/client.js +0 -7
  81. package/dist/node/client.js.map +0 -1
  82. package/dist/node/collections.js +0 -4
  83. package/dist/node/collections.js.map +0 -1
  84. package/dist/node/connection.d.ts +0 -30
  85. package/dist/node/connection.js +0 -6
  86. package/dist/node/connection.js.map +0 -1
  87. package/dist/node/index.d.ts +0 -94
  88. package/dist/node/index.js +0 -8
  89. package/dist/node/index.js.map +0 -1
  90. package/dist/node/language-model.js.map +0 -1
  91. /package/dist/{client.d.ts → core/client/http-client-transport.d.ts} +0 -0
  92. /package/dist/{connection.d.ts → core/connection.d.ts} +0 -0
@@ -1,125 +0,0 @@
1
- import { init_esm_shims } from './chunk-QMQMPK7Q.js';
2
- import { z } from 'zod';
3
-
4
- // src/well-known/collections.ts
5
- init_esm_shims();
6
- var BaseCollectionEntitySchema = z.object({
7
- id: z.string().describe("Unique identifier for the entity"),
8
- title: z.string().describe("Human-readable title for the entity"),
9
- created_at: z.string().datetime(),
10
- updated_at: z.string().datetime(),
11
- created_by: z.string().optional(),
12
- updated_by: z.string().optional()
13
- });
14
- var ComparisonExpressionSchema = z.object({
15
- field: z.array(z.string()),
16
- operator: z.enum(["eq", "gt", "gte", "lt", "lte", "in", "like", "contains"]),
17
- value: z.unknown()
18
- });
19
- var WhereExpressionSchema = z.union([
20
- ComparisonExpressionSchema,
21
- z.object({
22
- operator: z.enum(["and", "or", "not"]),
23
- conditions: z.array(ComparisonExpressionSchema)
24
- })
25
- ]);
26
- var OrderByExpressionSchema = z.object({
27
- field: z.array(z.string()),
28
- direction: z.enum(["asc", "desc"]),
29
- nulls: z.enum(["first", "last"]).optional()
30
- });
31
- var CollectionListInputSchema = z.object({
32
- where: WhereExpressionSchema.optional().describe("Filter expression"),
33
- orderBy: z.array(OrderByExpressionSchema).optional().describe("Sort expressions"),
34
- limit: z.number().int().min(1).max(1e3).optional().describe("Maximum number of items to return"),
35
- offset: z.number().int().min(0).optional().describe("Number of items to skip")
36
- });
37
- function createCollectionListOutputSchema(entitySchema) {
38
- return z.object({
39
- items: z.array(entitySchema).describe("Array of collection items"),
40
- totalCount: z.number().int().min(0).optional().describe("Total number of matching items (if available)"),
41
- hasMore: z.boolean().optional().describe("Whether there are more items available")
42
- });
43
- }
44
- var CollectionGetInputSchema = z.object({
45
- id: z.string().describe("ID of the entity to retrieve")
46
- });
47
- function createCollectionGetOutputSchema(entitySchema) {
48
- return z.object({
49
- item: entitySchema.nullable().describe("The retrieved item, or null if not found")
50
- });
51
- }
52
- function createCollectionInsertInputSchema(entitySchema) {
53
- return z.object({
54
- data: entitySchema.describe(
55
- "Data for the new entity (id may be auto-generated)"
56
- )
57
- });
58
- }
59
- function createCollectionInsertOutputSchema(entitySchema) {
60
- return z.object({
61
- item: entitySchema.describe("The created entity with generated id")
62
- });
63
- }
64
- function createCollectionUpdateInputSchema(entitySchema) {
65
- return z.object({
66
- id: z.string().describe("ID of the entity to update"),
67
- data: entitySchema.partial().describe("Partial entity data to update")
68
- });
69
- }
70
- function createCollectionUpdateOutputSchema(entitySchema) {
71
- return z.object({
72
- item: entitySchema.describe("The updated entity")
73
- });
74
- }
75
- var CollectionDeleteInputSchema = z.object({
76
- id: z.string().describe("ID of the entity to delete")
77
- });
78
- function createCollectionDeleteOutputSchema(entitySchema) {
79
- return z.object({
80
- item: entitySchema.describe("The deleted entity")
81
- });
82
- }
83
- function createCollectionBindings(collectionName, entitySchema, options) {
84
- const upperName = collectionName.toUpperCase();
85
- const readOnly = options?.readOnly ?? false;
86
- const bindings = [
87
- {
88
- name: `COLLECTION_${upperName}_LIST`,
89
- inputSchema: CollectionListInputSchema,
90
- outputSchema: createCollectionListOutputSchema(entitySchema)
91
- },
92
- {
93
- name: `COLLECTION_${upperName}_GET`,
94
- inputSchema: CollectionGetInputSchema,
95
- outputSchema: createCollectionGetOutputSchema(entitySchema)
96
- }
97
- ];
98
- if (!readOnly) {
99
- bindings.push(
100
- {
101
- name: `COLLECTION_${upperName}_CREATE`,
102
- inputSchema: createCollectionInsertInputSchema(entitySchema),
103
- outputSchema: createCollectionInsertOutputSchema(entitySchema),
104
- opt: true
105
- },
106
- {
107
- name: `COLLECTION_${upperName}_UPDATE`,
108
- inputSchema: createCollectionUpdateInputSchema(entitySchema),
109
- outputSchema: createCollectionUpdateOutputSchema(entitySchema),
110
- opt: true
111
- },
112
- {
113
- name: `COLLECTION_${upperName}_DELETE`,
114
- inputSchema: CollectionDeleteInputSchema,
115
- outputSchema: createCollectionDeleteOutputSchema(entitySchema),
116
- opt: true
117
- }
118
- );
119
- }
120
- return bindings;
121
- }
122
-
123
- export { BaseCollectionEntitySchema, CollectionDeleteInputSchema, CollectionGetInputSchema, CollectionListInputSchema, OrderByExpressionSchema, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema };
124
- //# sourceMappingURL=chunk-T2DG7334.js.map
125
- //# sourceMappingURL=chunk-T2DG7334.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/well-known/collections.ts"],"names":[],"mappings":";;;;AAAA,cAAA,EAAA;AAsBO,IAAM,0BAAA,GAA6B,EAAE,MAAA,CAAO;AAAA,EACjD,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kCAAkC,CAAA;AAAA,EAC1D,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,qCAAqC,CAAA;AAAA,EAChE,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAChC,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAChC,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,EAChC,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACzB,CAAC;AAUD,IAAM,0BAAA,GAA6B,EAAE,MAAA,C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;AAAA,QACE,IAAA,EAAM,cAAc,SAAS,CAAA,OAAA,CAAA;AAAA,QAC7B,WAAA,EAAa,kCAAkC,YAAY,CAAA;AAAA,QAC3D,YAAA,EAAc,mCAAmC,YAAY,CAAA;AAAA,QAC7D,GAAA,EAAK;AAAA,OACP;AAAA,MACA;AAAA,QACE,IAAA,EAAM,cAAc,SAAS,CAAA,OAAA,CAAA;AAAA,QAC7B,WAAA,EAAa,2BAAA;AAAA,QACb,YAAA,EAAc,mCAAmC,YAAY,CAAA;AAAA,QAC7D,GAAA,EAAK;AAAA;AACP,KACF;AAAA,EACF;AAEA,EAAA,OAAO,QAAA;AACT","file":"chunk-T2DG7334.js","sourcesContent":["import { z } from \"zod\";\nimport type { ToolBinder } from \"../core/binder\";\n\n/**\n * Collection Bindings\n *\n * This module provides standardized tool bindings for Collections, representing\n * SQL table-like structures with CRUD + Search operations compatible with TanStack DB.\n *\n * Key Features:\n * - Generic collection bindings that work with any entity type\n * - Standardized tool naming: `COLLECTION_{COLLECTION}_*`\n * - Compatible with TanStack DB query-collection\n * - Full TypeScript support with proper type constraints\n * - Support for filtering, sorting, and pagination\n * - Simple id and title fields for human-readable identification\n */\n\n/**\n * Base schema for collection entities\n * All collection entities must have an id, title, and audit trail fields\n */\nexport const BaseCollectionEntitySchema = z.object({\n id: z.string().describe(\"Unique identifier for the entity\"),\n title: z.string().describe(\"Human-readable title for the entity\"),\n created_at: z.string().datetime(),\n updated_at: z.string().datetime(),\n created_by: z.string().optional(),\n updated_by: z.string().optional(),\n});\n\n/**\n * Type helper for BaseCollectionEntitySchema\n */\nexport type BaseCollectionEntitySchemaType = typeof BaseCollectionEntitySchema;\n\n/**\n * Comparison expression schema for filtering\n */\nconst ComparisonExpressionSchema = z.object({\n field: z.array(z.string()),\n operator: z.enum([\"eq\", \"gt\", \"gte\", \"lt\", \"lte\", \"in\", \"like\", \"contains\"]),\n value: z.unknown(),\n});\n\n/**\n * Where expression schema for filtering\n * Supports TanStack DB predicate push-down patterns\n */\nexport const WhereExpressionSchema = z.union([\n ComparisonExpressionSchema,\n z.object({\n operator: z.enum([\"and\", \"or\", \"not\"]),\n conditions: z.array(ComparisonExpressionSchema),\n }),\n]);\n\n/**\n * Where expression type for filtering\n * Derived from WhereExpressionSchema\n */\nexport type WhereExpression = z.infer<typeof WhereExpressionSchema>;\n\n/**\n * Order by expression for sorting\n */\nexport const OrderByExpressionSchema = z.object({\n field: z.array(z.string()),\n direction: z.enum([\"asc\", \"desc\"]),\n nulls: z.enum([\"first\", \"last\"]).optional(),\n});\n\n/**\n * List/Query input schema for collections\n * Compatible with TanStack DB LoadSubsetOptions\n */\nexport const CollectionListInputSchema = z.object({\n where: WhereExpressionSchema.optional().describe(\"Filter expression\"),\n orderBy: z\n .array(OrderByExpressionSchema)\n .optional()\n .describe(\"Sort expressions\"),\n limit: z\n .number()\n .int()\n .min(1)\n .max(1000)\n .optional()\n .describe(\"Maximum number of items to return\"),\n offset: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe(\"Number of items to skip\"),\n});\n\n/**\n * Factory function to create list output schema for a specific collection type\n */\nexport function createCollectionListOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n items: z.array(entitySchema).describe(\"Array of collection items\"),\n totalCount: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe(\"Total number of matching items (if available)\"),\n hasMore: z\n .boolean()\n .optional()\n .describe(\"Whether there are more items available\"),\n });\n}\n\n/**\n * Get by ID input schema\n */\nexport const CollectionGetInputSchema = z.object({\n id: z.string().describe(\"ID of the entity to retrieve\"),\n});\n\n/**\n * Factory function to create get output schema\n */\nexport function createCollectionGetOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema\n .nullable()\n .describe(\"The retrieved item, or null if not found\"),\n });\n}\n\n/**\n * Factory function to create insert input schema\n */\nexport function createCollectionInsertInputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n // Remove id field since it may be auto-generated by the server\n return z.object({\n data: entitySchema.describe(\n \"Data for the new entity (id may be auto-generated)\",\n ),\n });\n}\n\n/**\n * Factory function to create insert output schema\n */\nexport function createCollectionInsertOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema.describe(\"The created entity with generated id\"),\n });\n}\n\n/**\n * Factory function to create update input schema\n */\nexport function createCollectionUpdateInputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n id: z.string().describe(\"ID of the entity to update\"),\n data: (entitySchema as unknown as z.AnyZodObject)\n .partial()\n .describe(\"Partial entity data to update\"),\n });\n}\n\n/**\n * Factory function to create update output schema\n */\nexport function createCollectionUpdateOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema.describe(\"The updated entity\"),\n });\n}\n\n/**\n * Delete input schema\n */\nexport const CollectionDeleteInputSchema = z.object({\n id: z.string().describe(\"ID of the entity to delete\"),\n});\n\n/**\n * Factory function to create delete output schema\n */\nexport function createCollectionDeleteOutputSchema<T extends z.ZodTypeAny>(\n entitySchema: T,\n) {\n return z.object({\n item: entitySchema.describe(\"The deleted entity\"),\n });\n}\n\n/**\n * Options for creating collection bindings\n */\nexport interface CollectionBindingOptions {\n /**\n * If true, only LIST and GET operations will be included (read-only collection)\n * @default false\n */\n readOnly?: boolean;\n}\n\n/**\n * Creates generic collection bindings for a specific entity type\n *\n * This function generates standardized tool bindings that work with any collection/table\n * by accepting a custom entity schema and collection name. The bindings provide:\n * - COLLECTION_{NAME}_LIST - Query/search entities with filtering and sorting (required)\n * - COLLECTION_{NAME}_GET - Get a single entity by ID (required)\n * - COLLECTION_{NAME}_CREATE - Create a new entity (optional, excluded if readOnly=true)\n * - COLLECTION_{NAME}_UPDATE - Update an existing entity (optional, excluded if readOnly=true)\n * - COLLECTION_{NAME}_DELETE - Delete an entity (optional, excluded if readOnly=true)\n *\n * @param collectionName - The name of the collection/table (e.g., \"users\", \"products\", \"orders\")\n * @param entitySchema - The Zod schema for the entity type (must extend BaseCollectionEntitySchema)\n * @param options - Optional configuration for the collection bindings\n * @returns Array of tool bindings for Collection CRUD + Query operations\n *\n * @example\n * ```typescript\n * const UserSchema = z.object({\n * id: z.string(),\n * title: z.string(),\n * created_at: z.string().datetime(),\n * updated_at: z.string().datetime(),\n * created_by: z.string().optional(),\n * updated_by: z.string().optional(),\n * email: z.string().email(),\n * });\n *\n * // Full CRUD collection\n * const USER_COLLECTION_BINDING = createCollectionBindings(\"users\", UserSchema);\n *\n * // Read-only collection (only LIST and GET)\n * const READONLY_COLLECTION_BINDING = createCollectionBindings(\"products\", ProductSchema, { readOnly: true });\n * ```\n */\nexport function createCollectionBindings<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TName extends string,\n>(\n collectionName: TName,\n entitySchema: TEntitySchema,\n options?: CollectionBindingOptions,\n) {\n const upperName = collectionName.toUpperCase() as Uppercase<TName>;\n const readOnly = options?.readOnly ?? false;\n\n const bindings: CollectionBinding<TEntitySchema, Uppercase<TName>>[number][] =\n [\n {\n name: `COLLECTION_${upperName}_LIST` as const,\n inputSchema: CollectionListInputSchema,\n outputSchema: createCollectionListOutputSchema(entitySchema),\n },\n {\n name: `COLLECTION_${upperName}_GET` as const,\n inputSchema: CollectionGetInputSchema,\n outputSchema: createCollectionGetOutputSchema(entitySchema),\n },\n ];\n\n // Only include mutation operations if not read-only\n if (!readOnly) {\n bindings.push(\n {\n name: `COLLECTION_${upperName}_CREATE` as const,\n inputSchema: createCollectionInsertInputSchema(entitySchema),\n outputSchema: createCollectionInsertOutputSchema(entitySchema),\n opt: true,\n },\n {\n name: `COLLECTION_${upperName}_UPDATE` as const,\n inputSchema: createCollectionUpdateInputSchema(entitySchema),\n outputSchema: createCollectionUpdateOutputSchema(entitySchema),\n opt: true,\n },\n {\n name: `COLLECTION_${upperName}_DELETE` as const,\n inputSchema: CollectionDeleteInputSchema,\n outputSchema: createCollectionDeleteOutputSchema(entitySchema),\n opt: true,\n },\n );\n }\n\n return bindings satisfies readonly ToolBinder[];\n}\n\nexport type ReadOnlyCollectionBinding<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TUpperName extends Uppercase<string> = Uppercase<string>,\n> = [\n {\n name: `COLLECTION_${TUpperName}_LIST`;\n inputSchema: typeof CollectionListInputSchema;\n outputSchema: ReturnType<\n typeof createCollectionListOutputSchema<TEntitySchema>\n >;\n },\n {\n name: `COLLECTION_${TUpperName}_GET`;\n inputSchema: typeof CollectionGetInputSchema;\n outputSchema: ReturnType<\n typeof createCollectionGetOutputSchema<TEntitySchema>\n >;\n },\n];\n/**\n * Type helper to extract the collection binding type\n */\nexport type CollectionBinding<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TUpperName extends Uppercase<string> = Uppercase<string>,\n> = [\n ...ReadOnlyCollectionBinding<TEntitySchema, TUpperName>,\n {\n name: `COLLECTION_${TUpperName}_CREATE`;\n inputSchema: ReturnType<\n typeof createCollectionInsertInputSchema<TEntitySchema>\n >;\n outputSchema: ReturnType<\n typeof createCollectionInsertOutputSchema<TEntitySchema>\n >;\n opt: true;\n },\n {\n name: `COLLECTION_${TUpperName}_UPDATE`;\n inputSchema: ReturnType<\n typeof createCollectionUpdateInputSchema<TEntitySchema>\n >;\n outputSchema: ReturnType<\n typeof createCollectionUpdateOutputSchema<TEntitySchema>\n >;\n opt: true;\n },\n {\n name: `COLLECTION_${TUpperName}_DELETE`;\n inputSchema: typeof CollectionDeleteInputSchema;\n outputSchema: ReturnType<\n typeof createCollectionDeleteOutputSchema<TEntitySchema>\n >;\n opt: true;\n },\n];\n\n/**\n * Type helper to extract tool names from a collection binding\n */\nexport type CollectionTools<\n TEntitySchema extends BaseCollectionEntitySchemaType,\n TUpperName extends Uppercase<string> = Uppercase<string>,\n> = CollectionBinding<TEntitySchema, TUpperName>[number][\"name\"];\n\n// Export types for TypeScript usage\nexport type CollectionListInput = z.infer<typeof CollectionListInputSchema>;\nexport type CollectionGetInput = z.infer<typeof CollectionGetInputSchema>;\nexport type CollectionDeleteInput = z.infer<typeof CollectionDeleteInputSchema>;\nexport type OrderByExpression = z.infer<typeof OrderByExpressionSchema>;\n\n/**\n * Type helper for list output with generic item type\n */\nexport type CollectionListOutput<T> = {\n items: T[];\n totalCount?: number;\n hasMore?: boolean;\n};\n\n/**\n * Type helper for get output with generic item type\n */\nexport type CollectionGetOutput<T> = {\n item: T | null;\n};\n\n/**\n * Type helper for insert output with generic item type\n */\nexport type CollectionInsertOutput<T> = {\n item: T;\n};\n\n/**\n * Type helper for update output with generic item type\n */\nexport type CollectionUpdateOutput<T> = {\n item: T;\n};\n\n/**\n * Type helper for delete output with generic item type\n */\nexport type CollectionDeleteOutput<T> = {\n item: T;\n};\n\n/**\n * Base collection entity type - inferred from BaseCollectionEntitySchema\n */\nexport type BaseCollectionEntity = z.infer<typeof BaseCollectionEntitySchema>;\n"]}
@@ -1,12 +0,0 @@
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 };
@@ -1,7 +0,0 @@
1
- export { HTTPClientTransport } from './chunk-BLCFITZG.js';
2
- import { init_esm_shims } from './chunk-QMQMPK7Q.js';
3
-
4
- // src/core/client/index.ts
5
- init_esm_shims();
6
- //# sourceMappingURL=client.js.map
7
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/client/index.ts"],"names":[],"mappings":";;;;AAAA,cAAA,EAAA","file":"client.js","sourcesContent":["export { HTTPClientTransport } from \"./http-client-transport\";\n"]}
@@ -1,4 +0,0 @@
1
- export { BaseCollectionEntitySchema, CollectionDeleteInputSchema, CollectionGetInputSchema, CollectionListInputSchema, OrderByExpressionSchema, WhereExpressionSchema, createCollectionBindings, createCollectionDeleteOutputSchema, createCollectionGetOutputSchema, createCollectionInsertInputSchema, createCollectionInsertOutputSchema, createCollectionListOutputSchema, createCollectionUpdateInputSchema, createCollectionUpdateOutputSchema } from './chunk-T2DG7334.js';
2
- import './chunk-QMQMPK7Q.js';
3
- //# sourceMappingURL=collections.js.map
4
- //# sourceMappingURL=collections.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"collections.js"}
@@ -1,30 +0,0 @@
1
- type SSEConnection = {
2
- type: "SSE";
3
- url: string;
4
- token?: string;
5
- headers?: Record<string, string>;
6
- };
7
- type WebsocketConnection = {
8
- type: "Websocket";
9
- url: string;
10
- token?: string;
11
- };
12
- type DecoConnection = {
13
- type: "Deco";
14
- tenant: string;
15
- token?: string;
16
- };
17
- type InnateConnection = {
18
- type: "INNATE";
19
- name: string;
20
- workspace?: string;
21
- };
22
- type HTTPConnection = {
23
- type: "HTTP";
24
- url: string;
25
- headers?: Record<string, string>;
26
- token?: string;
27
- };
28
- type MCPConnection = SSEConnection | WebsocketConnection | InnateConnection | DecoConnection | HTTPConnection;
29
-
30
- export type { DecoConnection, HTTPConnection, InnateConnection, MCPConnection, SSEConnection, WebsocketConnection };
@@ -1,6 +0,0 @@
1
- import { init_esm_shims } from './chunk-QMQMPK7Q.js';
2
-
3
- // src/core/connection.ts
4
- init_esm_shims();
5
- //# sourceMappingURL=connection.js.map
6
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/connection.ts"],"names":[],"mappings":";;;AAAA,cAAA,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"]}
@@ -1,94 +0,0 @@
1
- import { ZodType } from 'zod';
2
-
3
- /**
4
- * Core Binder Types and Utilities
5
- *
6
- * This module provides the core types and utilities for the bindings system.
7
- * Bindings define standardized interfaces that integrations (MCPs) can implement.
8
- */
9
-
10
- /**
11
- * ToolBinder defines a single tool within a binding.
12
- * It specifies the tool name, input/output schemas, and whether it's optional.
13
- *
14
- * @template TName - The tool name (can be a string or RegExp for pattern matching)
15
- * @template TInput - The input type (inferred from inputSchema)
16
- * @template TReturn - The return type (inferred from outputSchema)
17
- */
18
- interface ToolBinder<TName extends string | RegExp = string, TInput = any, TReturn extends object | null | boolean = object, TStreamable extends boolean = boolean> {
19
- /** The name of the tool (e.g., "DECO_CHAT_CHANNELS_JOIN") */
20
- name: TName;
21
- /** Zod schema for validating tool input */
22
- inputSchema: ZodType<TInput>;
23
- /** Optional Zod schema for validating tool output */
24
- outputSchema?: TStreamable extends true ? never : ZodType<TReturn>;
25
- /**
26
- * Whether this tool is streamable.
27
- */
28
- streamable?: TStreamable;
29
- /**
30
- * Whether this tool is optional in the binding.
31
- * If true, an implementation doesn't need to provide this tool.
32
- */
33
- opt?: true;
34
- }
35
- /**
36
- * Binder represents a collection of tool definitions that form a binding.
37
- * A binding is like a TypeScript interface - it defines what tools must be implemented.
38
- *
39
- * @template TDefinition - Array of ToolBinder definitions
40
- *
41
- * @example
42
- * ```ts
43
- * const MY_BINDING = [{
44
- * name: "MY_TOOL" as const,
45
- * inputSchema: z.object({ id: z.string() }),
46
- * outputSchema: z.object({ success: z.boolean() }),
47
- * }] as const satisfies Binder;
48
- * ```
49
- */
50
- type Binder<TDefinition extends readonly ToolBinder[] = readonly ToolBinder[]> = TDefinition;
51
- /**
52
- * Tool with schemas for validation
53
- */
54
- interface ToolWithSchemas {
55
- name: string;
56
- inputSchema?: ZodType<any> | Record<string, unknown>;
57
- outputSchema?: ZodType<any> | Record<string, unknown>;
58
- }
59
- /**
60
- * Binding checker interface
61
- */
62
- interface BindingChecker {
63
- /**
64
- * Check if a set of tools implements the binding with full schema validation.
65
- *
66
- * Validates:
67
- * - Tool name matches (exact or regex)
68
- * - Input schema: Tool accepts what binder requires (no removals from binder to tool)
69
- * - Output schema: Tool provides what binder expects (no removals from tool to binder)
70
- *
71
- * @param tools - Array of tools with names and schemas
72
- * @returns Promise<boolean> - true if all tools implement the binding correctly
73
- */
74
- isImplementedBy: (tools: ToolWithSchemas[]) => Promise<boolean>;
75
- }
76
- /**
77
- * Creates a binding checker with full schema validation using json-schema-diff.
78
- *
79
- * This performs strict compatibility checking:
80
- * - For input schemas: Validates that the tool can accept what the binder requires
81
- * - For output schemas: Validates that the tool provides what the binder expects
82
- *
83
- * @param binderTools - The binding definition to check against
84
- * @returns A binding checker with an async isImplementedBy method
85
- *
86
- * @example
87
- * ```ts
88
- * const checker = createBindingChecker(MY_BINDING);
89
- * const isCompatible = await checker.isImplementedBy(availableTools);
90
- * ```
91
- */
92
- declare function createBindingChecker<TDefinition extends readonly ToolBinder[]>(binderTools: TDefinition): BindingChecker;
93
-
94
- export { type Binder, type BindingChecker, type ToolBinder, type ToolWithSchemas, createBindingChecker };
@@ -1,8 +0,0 @@
1
- export { createBindingChecker } from './chunk-QP7AQCEP.js';
2
- import './chunk-BLCFITZG.js';
3
- import { init_esm_shims } from './chunk-QMQMPK7Q.js';
4
-
5
- // src/index.ts
6
- init_esm_shims();
7
- //# sourceMappingURL=index.js.map
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,cAAA,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"]}
@@ -1 +0,0 @@
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,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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"]}
File without changes