@decocms/bindings 1.0.3 → 1.0.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/bindings",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@modelcontextprotocol/sdk": "1.25.1",
11
- "zod": "^3.25.76",
12
- "zod-from-json-schema": "^0.0.5"
11
+ "zod": "^4.0.0",
12
+ "zod-from-json-schema": "^0.5.2"
13
13
  },
14
14
  "exports": {
15
15
  ".": "./src/index.ts",
@@ -1,4 +1,5 @@
1
- import { z, type ZodType } from "zod";
1
+ import { z } from "zod";
2
+ import type { ZodType } from "zod";
2
3
  import type { ToolBinder } from "../core/binder";
3
4
 
4
5
  /**
@@ -178,7 +179,7 @@ export function createCollectionUpdateInputSchema<T extends z.ZodTypeAny>(
178
179
  ) {
179
180
  return z.object({
180
181
  id: z.string().describe("ID of the entity to update"),
181
- data: (entitySchema as unknown as z.AnyZodObject)
182
+ data: (entitySchema as unknown as z.ZodObject<z.ZodRawShape>)
182
183
  .partial()
183
184
  .describe("Partial entity data to update"),
184
185
  });
@@ -331,7 +332,7 @@ type ToolBinding<
331
332
  export type CollectionBinding<
332
333
  TEntitySchema,
333
334
  TUpperName extends Uppercase<string> = Uppercase<string>,
334
- TEntity = TEntitySchema extends z.AnyZodObject
335
+ TEntity = TEntitySchema extends z.ZodObject<z.ZodRawShape>
335
336
  ? z.infer<TEntitySchema>
336
337
  : TEntitySchema,
337
338
  > = [
@@ -369,7 +370,7 @@ export type CollectionBinding<
369
370
  * Type helper to extract tool names from a collection binding
370
371
  */
371
372
  export type CollectionTools<
372
- TEntitySchema extends z.AnyZodObject,
373
+ TEntitySchema extends z.ZodObject<z.ZodRawShape>,
373
374
  TUpperName extends Uppercase<string> = Uppercase<string>,
374
375
  > = CollectionBinding<TEntitySchema, TUpperName>[number]["name"];
375
376
 
@@ -55,11 +55,9 @@ const TextPartSchema = z.object({
55
55
 
56
56
  /**
57
57
  * Data Content Schema
58
- * File data can be Uint8Array (as base64 string), base64 encoded string, or URL string
58
+ * File data can be a URL string or a base64 encoded string
59
59
  */
60
- const DataContentSchema = z
61
- .union([z.string(), z.instanceof(Uint8Array)])
62
- .describe("File data as base64 encoded string, URL string, or Uint8Array");
60
+ const DataContentSchema = z.string().describe("File data as URL string");
63
61
 
64
62
  /**
65
63
  * File Part Schema
@@ -96,7 +94,7 @@ const ToolCallPartSchema = z.object({
96
94
  .describe("ID of the tool call, used to match with tool result"),
97
95
  toolName: z.string().describe("Name of the tool being called"),
98
96
  input: z
99
- .unknown()
97
+ .string()
100
98
  .describe(
101
99
  "Arguments of the tool call (JSON-serializable object matching tool input schema)",
102
100
  ),
@@ -157,6 +155,7 @@ const ToolResultPartSchema = z.object({
157
155
  .describe("ID of the tool call that this result is associated with"),
158
156
  toolName: z.string().describe("Name of the tool that generated this result"),
159
157
  output: ToolResultOutputSchema.describe("Result of the tool call"),
158
+ result: z.unknown().describe("Unknown result of the tool call"),
160
159
  providerOptions: ProviderOptionsSchema,
161
160
  });
162
161
 
@@ -335,10 +334,10 @@ export const LanguageModelCallOptionsSchema = z.object({
335
334
  .describe("Abort signal for cancelling the operation"),
336
335
 
337
336
  // Additional options
338
- headers: z
339
- .record(z.string(), z.union([z.string(), z.undefined()]))
340
- .optional()
341
- .describe("Additional HTTP headers to be sent with the request"),
337
+ // headers: z
338
+ // .record(z.string(), z.union([z.string(), z.undefined()]))
339
+ // .optional()
340
+ // .describe("Additional HTTP headers to be sent with the request"),
342
341
  providerOptions: z
343
342
  .any()
344
343
  .optional()
@@ -352,7 +351,15 @@ export const LanguageModelCallOptionsSchema = z.object({
352
351
  export const LanguageModelGenerateOutputSchema = z.object({
353
352
  // Ordered content that the model has generated
354
353
  content: z
355
- .array(z.any())
354
+ .array(
355
+ z.union([
356
+ TextPartSchema,
357
+ FilePartSchema,
358
+ ReasoningPartSchema,
359
+ ToolCallPartSchema,
360
+ ToolResultPartSchema,
361
+ ]),
362
+ )
356
363
  .describe(
357
364
  "Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)",
358
365
  ),
@@ -372,20 +379,12 @@ export const LanguageModelGenerateOutputSchema = z.object({
372
379
 
373
380
  // Usage information (required)
374
381
  usage: z
375
- .object({
382
+ .looseObject({
376
383
  inputTokens: z.number().optional(),
377
384
  outputTokens: z.number().optional(),
378
385
  totalTokens: z.number().optional(),
379
386
  reasoningTokens: z.number().optional(),
380
387
  })
381
- .passthrough()
382
- .transform((val) => ({
383
- inputTokens: val.inputTokens,
384
- outputTokens: val.outputTokens,
385
- totalTokens: val.totalTokens,
386
- reasoningTokens: val.reasoningTokens,
387
- ...val,
388
- }))
389
388
  .describe("Usage information for the language model call"),
390
389
 
391
390
  // Provider metadata
@@ -409,8 +408,8 @@ export const LanguageModelGenerateOutputSchema = z.object({
409
408
  response: z
410
409
  .object({
411
410
  id: z.string().optional().describe("ID for the generated response"),
412
- timestamp: z
413
- .date()
411
+ timestamp: z.iso
412
+ .datetime()
414
413
  .optional()
415
414
  .describe("Timestamp for the start of the generated response"),
416
415
  modelId: z
@@ -24,8 +24,8 @@ const RegistryToolSchema = z.object({
24
24
  id: z.string(),
25
25
  name: z.string(),
26
26
  description: z.string().optional(),
27
- inputSchema: z.record(z.unknown()),
28
- outputSchema: z.record(z.unknown()).optional(),
27
+ inputSchema: z.record(z.string(), z.unknown()),
28
+ outputSchema: z.record(z.string(), z.unknown()).optional(),
29
29
  });
30
30
 
31
31
  /**
@@ -44,7 +44,7 @@ export const MCPRegistryServerSchema = BaseCollectionEntitySchema.extend({
44
44
  scopeName: z.string(),
45
45
  appName: z.string(),
46
46
  friendlyName: z.string().nullable().optional(),
47
- metadata: z.record(z.unknown()).nullable().optional(),
47
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
48
48
  publishedAt: z.string().datetime().optional(),
49
49
  updatedAt: z.string().datetime().optional(),
50
50
  tools: z
@@ -58,7 +58,7 @@ export const MCPRegistryServerSchema = BaseCollectionEntitySchema.extend({
58
58
  .optional(),
59
59
  server: z.object({
60
60
  $schema: z.string().optional(),
61
- _meta: z.record(z.unknown()).optional(),
61
+ _meta: z.record(z.string(), z.unknown()).optional(),
62
62
  name: z.string().describe("The server name (scope/app)"),
63
63
  title: z.string().optional().describe("User-friendly title"),
64
64
  description: z.string().optional().describe("Server description"),
@@ -108,7 +108,7 @@ const JsonSchemaSchema: z.ZodType<JsonSchema> = z.lazy(() =>
108
108
  z
109
109
  .object({
110
110
  type: z.string().optional(),
111
- properties: z.record(z.unknown()).optional(),
111
+ properties: z.record(z.string(), z.unknown()).optional(),
112
112
  required: z.array(z.string()).optional(),
113
113
  description: z.string().optional(),
114
114
  additionalProperties: z.boolean().optional(),
@@ -128,7 +128,7 @@ export const StepSchema = z.object({
128
128
  description: z.string().optional().describe("What this step does"),
129
129
  action: StepActionSchema,
130
130
  input: z
131
- .record(z.unknown())
131
+ .record(z.string(), z.unknown())
132
132
  .optional()
133
133
  .describe(
134
134
  "Data passed to the action. Use @ref for dynamic values: @input.field (workflow input), @stepName.field (previous step output), @item/@index (loop context). Example: { 'userId': '@input.user_id', 'data': '@fetch.result' }",
@@ -175,7 +175,7 @@ export const WorkflowExecutionSchema = BaseCollectionEntitySchema.extend({
175
175
  "Current status of the workflow execution",
176
176
  ),
177
177
  input: z
178
- .record(z.unknown())
178
+ .record(z.string(), z.unknown())
179
179
  .optional()
180
180
  .describe("Input data for the workflow execution"),
181
181
  output: z