@decocms/bindings 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",
@@ -53,13 +53,24 @@ const TextPartSchema = z.object({
53
53
  providerOptions: ProviderOptionsSchema,
54
54
  });
55
55
 
56
+ /**
57
+ * Text Output Part Schema
58
+ * Text content generated by the model (uses providerMetadata instead of providerOptions)
59
+ */
60
+ const TextOutputPartSchema = z.object({
61
+ type: z.literal("text"),
62
+ text: z.string().describe("The text content"),
63
+ providerMetadata: z
64
+ .any()
65
+ .optional()
66
+ .describe("Additional provider-specific metadata"),
67
+ });
68
+
56
69
  /**
57
70
  * Data Content Schema
58
- * File data can be Uint8Array (as base64 string), base64 encoded string, or URL string
71
+ * File data can be a URL string or a base64 encoded string
59
72
  */
60
- const DataContentSchema = z
61
- .union([z.string(), z.instanceof(Uint8Array)])
62
- .describe("File data as base64 encoded string, URL string, or Uint8Array");
73
+ const DataContentSchema = z.string().describe("File data as URL string");
63
74
 
64
75
  /**
65
76
  * File Part Schema
@@ -75,6 +86,18 @@ const FilePartSchema = z.object({
75
86
  providerOptions: ProviderOptionsSchema,
76
87
  });
77
88
 
89
+ /**
90
+ * File Output Part Schema
91
+ * File content generated by the model
92
+ */
93
+ const FileOutputPartSchema = z.object({
94
+ type: z.literal("file"),
95
+ mediaType: z
96
+ .string()
97
+ .describe("IANA media type of the file (e.g., image/png, audio/mp3)"),
98
+ data: z.string().describe("Generated file data as base64 encoded string"),
99
+ });
100
+
78
101
  /**
79
102
  * Reasoning Part Schema
80
103
  * Reasoning content part of a prompt
@@ -85,6 +108,19 @@ const ReasoningPartSchema = z.object({
85
108
  providerOptions: ProviderOptionsSchema,
86
109
  });
87
110
 
111
+ /**
112
+ * Reasoning Output Part Schema
113
+ * Reasoning content generated by the model
114
+ */
115
+ const ReasoningOutputPartSchema = z.object({
116
+ type: z.literal("reasoning"),
117
+ text: z.string().describe("The reasoning text"),
118
+ providerMetadata: z
119
+ .any()
120
+ .optional()
121
+ .describe("Additional provider-specific metadata"),
122
+ });
123
+
88
124
  /**
89
125
  * Tool Call Part Schema
90
126
  * Tool call content part of a prompt (usually generated by the AI model)
@@ -96,7 +132,7 @@ const ToolCallPartSchema = z.object({
96
132
  .describe("ID of the tool call, used to match with tool result"),
97
133
  toolName: z.string().describe("Name of the tool being called"),
98
134
  input: z
99
- .unknown()
135
+ .string()
100
136
  .describe(
101
137
  "Arguments of the tool call (JSON-serializable object matching tool input schema)",
102
138
  ),
@@ -107,6 +143,27 @@ const ToolCallPartSchema = z.object({
107
143
  providerOptions: ProviderOptionsSchema,
108
144
  });
109
145
 
146
+ /**
147
+ * Tool Call Output Part Schema
148
+ * Tool call content generated by the model
149
+ */
150
+ const ToolCallOutputPartSchema = z.object({
151
+ type: z.literal("tool-call"),
152
+ toolCallId: z.string().describe("ID of the tool call"),
153
+ toolName: z.string().describe("Name of the tool being called"),
154
+ input: z
155
+ .string()
156
+ .describe("Stringified JSON object with the tool call arguments"),
157
+ providerExecuted: z
158
+ .boolean()
159
+ .optional()
160
+ .describe("Whether the tool call will be executed by the provider"),
161
+ providerMetadata: z
162
+ .any()
163
+ .optional()
164
+ .describe("Additional provider-specific metadata"),
165
+ });
166
+
110
167
  /**
111
168
  * Tool Result Output Schema
112
169
  * The output of a tool result
@@ -157,9 +214,70 @@ const ToolResultPartSchema = z.object({
157
214
  .describe("ID of the tool call that this result is associated with"),
158
215
  toolName: z.string().describe("Name of the tool that generated this result"),
159
216
  output: ToolResultOutputSchema.describe("Result of the tool call"),
217
+ result: z.unknown().describe("Unknown result of the tool call"),
160
218
  providerOptions: ProviderOptionsSchema,
161
219
  });
162
220
 
221
+ /**
222
+ * Tool Result Output Part Schema
223
+ * Tool result content generated by the model (provider-executed tools)
224
+ */
225
+ const ToolResultOutputPartSchema = z.object({
226
+ type: z.literal("tool-result"),
227
+ toolCallId: z
228
+ .string()
229
+ .describe("ID of the tool call that this result is associated with"),
230
+ toolName: z.string().describe("Name of the tool that generated this result"),
231
+ result: z.any().describe("Result of the tool call (JSON-serializable)"),
232
+ isError: z
233
+ .boolean()
234
+ .optional()
235
+ .describe("Whether the result is an error or error message"),
236
+ providerExecuted: z
237
+ .boolean()
238
+ .optional()
239
+ .describe("Whether the tool result was generated by the provider"),
240
+ providerMetadata: z
241
+ .any()
242
+ .optional()
243
+ .describe("Additional provider-specific metadata"),
244
+ });
245
+
246
+ /**
247
+ * Source Part Schema
248
+ * Source content generated by the model (references to web or document sources)
249
+ */
250
+ const SourcePartSchema = z.union([
251
+ z.object({
252
+ type: z.literal("source"),
253
+ sourceType: z.literal("url"),
254
+ id: z.string().describe("The ID of the source"),
255
+ url: z.string().describe("The URL of the source"),
256
+ title: z.string().optional().describe("The title of the source"),
257
+ providerMetadata: z
258
+ .any()
259
+ .optional()
260
+ .describe("Additional provider-specific metadata"),
261
+ }),
262
+ z.object({
263
+ type: z.literal("source"),
264
+ sourceType: z.literal("document"),
265
+ id: z.string().describe("The ID of the source"),
266
+ mediaType: z
267
+ .string()
268
+ .describe("IANA media type of the document (e.g., application/pdf)"),
269
+ title: z.string().describe("The title of the document"),
270
+ filename: z
271
+ .string()
272
+ .optional()
273
+ .describe("Optional filename of the document"),
274
+ providerMetadata: z
275
+ .any()
276
+ .optional()
277
+ .describe("Additional provider-specific metadata"),
278
+ }),
279
+ ]);
280
+
163
281
  /**
164
282
  * System Message Schema
165
283
  */
@@ -335,10 +453,10 @@ export const LanguageModelCallOptionsSchema = z.object({
335
453
  .describe("Abort signal for cancelling the operation"),
336
454
 
337
455
  // 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"),
456
+ // headers: z
457
+ // .record(z.string(), z.union([z.string(), z.undefined()]))
458
+ // .optional()
459
+ // .describe("Additional HTTP headers to be sent with the request"),
342
460
  providerOptions: z
343
461
  .any()
344
462
  .optional()
@@ -352,7 +470,16 @@ export const LanguageModelCallOptionsSchema = z.object({
352
470
  export const LanguageModelGenerateOutputSchema = z.object({
353
471
  // Ordered content that the model has generated
354
472
  content: z
355
- .array(z.any())
473
+ .array(
474
+ z.union([
475
+ TextOutputPartSchema,
476
+ FileOutputPartSchema,
477
+ ReasoningOutputPartSchema,
478
+ ToolCallOutputPartSchema,
479
+ ToolResultOutputPartSchema,
480
+ SourcePartSchema,
481
+ ]),
482
+ )
356
483
  .describe(
357
484
  "Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)",
358
485
  ),
@@ -372,20 +499,12 @@ export const LanguageModelGenerateOutputSchema = z.object({
372
499
 
373
500
  // Usage information (required)
374
501
  usage: z
375
- .object({
502
+ .looseObject({
376
503
  inputTokens: z.number().optional(),
377
504
  outputTokens: z.number().optional(),
378
505
  totalTokens: z.number().optional(),
379
506
  reasoningTokens: z.number().optional(),
380
507
  })
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
508
  .describe("Usage information for the language model call"),
390
509
 
391
510
  // Provider metadata
@@ -409,8 +528,8 @@ export const LanguageModelGenerateOutputSchema = z.object({
409
528
  response: z
410
529
  .object({
411
530
  id: z.string().optional().describe("ID for the generated response"),
412
- timestamp: z
413
- .date()
531
+ timestamp: z.iso
532
+ .datetime()
414
533
  .optional()
415
534
  .describe("Timestamp for the start of the generated response"),
416
535
  modelId: z