@ai-sdk/open-responses 2.0.0-beta.21 → 2.0.0-beta.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @ai-sdk/open-responses
2
2
 
3
+ ## 2.0.0-beta.23
4
+
5
+ ### Patch Changes
6
+
7
+ - b3976a2: Add workflow serialization support to all provider models.
8
+
9
+ **`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
10
+
11
+ **All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
12
+
13
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
14
+
15
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
16
+ - Updated dependencies [b3976a2]
17
+ - Updated dependencies [ff5eba1]
18
+ - @ai-sdk/provider-utils@5.0.0-beta.20
19
+ - @ai-sdk/provider@4.0.0-beta.12
20
+
21
+ ## 2.0.0-beta.22
22
+
23
+ ### Major Changes
24
+
25
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [ef992f8]
30
+ - @ai-sdk/provider@4.0.0-beta.11
31
+ - @ai-sdk/provider-utils@5.0.0-beta.19
32
+
3
33
  ## 2.0.0-beta.21
4
34
 
5
35
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,44 +1,37 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- createOpenResponses: () => createOpenResponses
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
1
  // src/version.ts
29
- var VERSION = true ? "2.0.0-beta.21" : "0.0.0-test";
2
+ var VERSION = true ? "2.0.0-beta.23" : "0.0.0-test";
30
3
 
31
4
  // src/open-responses-provider.ts
32
- var import_provider2 = require("@ai-sdk/provider");
33
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
5
+ import {
6
+ NoSuchModelError
7
+ } from "@ai-sdk/provider";
8
+ import {
9
+ generateId,
10
+ withUserAgentSuffix
11
+ } from "@ai-sdk/provider-utils";
34
12
 
35
13
  // src/responses/open-responses-language-model.ts
36
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
37
- var import_v43 = require("zod/v4");
14
+ import {
15
+ combineHeaders,
16
+ createEventSourceResponseHandler,
17
+ createJsonErrorResponseHandler,
18
+ createJsonResponseHandler,
19
+ isCustomReasoning,
20
+ jsonSchema,
21
+ mapReasoningToProviderEffort,
22
+ parseProviderOptions,
23
+ postJsonToApi,
24
+ serializeModelOptions,
25
+ WORKFLOW_SERIALIZE,
26
+ WORKFLOW_DESERIALIZE
27
+ } from "@ai-sdk/provider-utils";
28
+ import { z as z3 } from "zod/v4";
38
29
 
39
30
  // src/responses/convert-to-open-responses-input.ts
40
- var import_provider = require("@ai-sdk/provider");
41
- var import_provider_utils = require("@ai-sdk/provider-utils");
31
+ import {
32
+ UnsupportedFunctionalityError
33
+ } from "@ai-sdk/provider";
34
+ import { convertToBase64, isProviderReference } from "@ai-sdk/provider-utils";
42
35
  async function convertToOpenResponsesInput({
43
36
  prompt
44
37
  }) {
@@ -61,8 +54,8 @@ async function convertToOpenResponsesInput({
61
54
  break;
62
55
  }
63
56
  case "file": {
64
- if ((0, import_provider_utils.isProviderReference)(part.data)) {
65
- throw new import_provider.UnsupportedFunctionalityError({
57
+ if (isProviderReference(part.data)) {
58
+ throw new UnsupportedFunctionalityError({
66
59
  functionality: "file parts with provider references"
67
60
  });
68
61
  }
@@ -77,7 +70,7 @@ async function convertToOpenResponsesInput({
77
70
  userContent.push({
78
71
  type: "input_image",
79
72
  ...part.data instanceof URL ? { image_url: part.data.toString() } : {
80
- image_url: `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`
73
+ image_url: `data:${mediaType};base64,${convertToBase64(part.data)}`
81
74
  }
82
75
  });
83
76
  break;
@@ -148,26 +141,33 @@ async function convertToOpenResponsesInput({
148
141
  });
149
142
  break;
150
143
  }
151
- case "image-data": {
152
- contentParts.push({
153
- type: "input_image",
154
- image_url: `data:${item.mediaType};base64,${item.data}`
155
- });
156
- break;
157
- }
158
- case "image-url": {
159
- contentParts.push({
160
- type: "input_image",
161
- image_url: item.url
162
- });
144
+ case "file-data": {
145
+ if (item.mediaType.startsWith("image/")) {
146
+ contentParts.push({
147
+ type: "input_image",
148
+ image_url: `data:${item.mediaType};base64,${item.data}`
149
+ });
150
+ } else {
151
+ contentParts.push({
152
+ type: "input_file",
153
+ filename: (_b = item.filename) != null ? _b : "data",
154
+ file_data: `data:${item.mediaType};base64,${item.data}`
155
+ });
156
+ }
163
157
  break;
164
158
  }
165
- case "file-data": {
166
- contentParts.push({
167
- type: "input_file",
168
- filename: (_b = item.filename) != null ? _b : "data",
169
- file_data: `data:${item.mediaType};base64,${item.data}`
170
- });
159
+ case "file-url": {
160
+ if (item.mediaType.startsWith("image/")) {
161
+ contentParts.push({
162
+ type: "input_image",
163
+ image_url: item.url
164
+ });
165
+ } else {
166
+ contentParts.push({
167
+ type: "input_file",
168
+ file_url: item.url
169
+ });
170
+ }
171
171
  break;
172
172
  }
173
173
  default: {
@@ -202,17 +202,17 @@ async function convertToOpenResponsesInput({
202
202
  }
203
203
 
204
204
  // src/responses/open-responses-api.ts
205
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
206
- var import_v4 = require("zod/v4");
207
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
208
- var openResponsesErrorSchema = (0, import_provider_utils2.lazySchema)(
209
- () => (0, import_provider_utils3.zodSchema)(
210
- import_v4.z.object({
211
- error: import_v4.z.object({
212
- message: import_v4.z.string(),
213
- type: import_v4.z.string(),
214
- param: import_v4.z.string(),
215
- code: import_v4.z.string()
205
+ import { lazySchema } from "@ai-sdk/provider-utils";
206
+ import { z } from "zod/v4";
207
+ import { zodSchema } from "@ai-sdk/provider-utils";
208
+ var openResponsesErrorSchema = lazySchema(
209
+ () => zodSchema(
210
+ z.object({
211
+ error: z.object({
212
+ message: z.string(),
213
+ type: z.string(),
214
+ param: z.string(),
215
+ code: z.string()
216
216
  })
217
217
  })
218
218
  )
@@ -237,22 +237,22 @@ function mapOpenResponsesFinishReason({
237
237
  }
238
238
 
239
239
  // src/responses/open-responses-options.ts
240
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
241
- var import_v42 = require("zod/v4");
242
- var openResponsesOptionsSchema = (0, import_provider_utils4.lazySchema)(
243
- () => (0, import_provider_utils4.zodSchema)(
244
- import_v42.z.object({
240
+ import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
241
+ import { z as z2 } from "zod/v4";
242
+ var openResponsesOptionsSchema = lazySchema2(
243
+ () => zodSchema2(
244
+ z2.object({
245
245
  /**
246
246
  * Controls reasoning summary output from the model.
247
247
  * Valid values: 'concise', 'detailed', 'auto'.
248
248
  */
249
- reasoningSummary: import_v42.z.enum(["concise", "detailed", "auto"]).nullish()
249
+ reasoningSummary: z2.enum(["concise", "detailed", "auto"]).nullish()
250
250
  })
251
251
  )
252
252
  );
253
253
 
254
254
  // src/responses/open-responses-language-model.ts
255
- var OpenResponsesLanguageModel = class {
255
+ var OpenResponsesLanguageModel = class _OpenResponsesLanguageModel {
256
256
  constructor(modelId, config) {
257
257
  this.specificationVersion = "v4";
258
258
  this.supportedUrls = {
@@ -261,6 +261,15 @@ var OpenResponsesLanguageModel = class {
261
261
  this.modelId = modelId;
262
262
  this.config = config;
263
263
  }
264
+ static [WORKFLOW_SERIALIZE](model) {
265
+ return serializeModelOptions({
266
+ modelId: model.modelId,
267
+ config: model.config
268
+ });
269
+ }
270
+ static [WORKFLOW_DESERIALIZE](options) {
271
+ return new _OpenResponsesLanguageModel(options.modelId, options.config);
272
+ }
264
273
  get provider() {
265
274
  return this.config.provider;
266
275
  }
@@ -316,12 +325,12 @@ var OpenResponsesLanguageModel = class {
316
325
  strict: true
317
326
  } : {}
318
327
  } : void 0;
319
- const openResponsesOptions = await (0, import_provider_utils5.parseProviderOptions)({
328
+ const openResponsesOptions = await parseProviderOptions({
320
329
  provider: this.config.providerOptionsName,
321
330
  providerOptions,
322
331
  schema: openResponsesOptionsSchema
323
332
  });
324
- const resolvedReasoningEffort = (0, import_provider_utils5.isCustomReasoning)(reasoning) ? reasoning === "none" ? "none" : (0, import_provider_utils5.mapReasoningToProviderEffort)({
333
+ const resolvedReasoningEffort = isCustomReasoning(reasoning) ? reasoning === "none" ? "none" : mapReasoningToProviderEffort({
325
334
  reasoning,
326
335
  effortMap: {
327
336
  minimal: "low",
@@ -358,23 +367,23 @@ var OpenResponsesLanguageModel = class {
358
367
  };
359
368
  }
360
369
  async doGenerate(options) {
361
- var _a, _b, _c, _d, _e, _f;
370
+ var _a, _b, _c, _d, _e, _f, _g, _h;
362
371
  const { body, warnings } = await this.getArgs(options);
363
372
  const {
364
373
  responseHeaders,
365
374
  value: response,
366
375
  rawValue: rawResponse
367
- } = await (0, import_provider_utils5.postJsonToApi)({
376
+ } = await postJsonToApi({
368
377
  url: this.config.url,
369
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
378
+ headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
370
379
  body,
371
- failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
380
+ failedResponseHandler: createJsonErrorResponseHandler({
372
381
  errorSchema: openResponsesErrorSchema,
373
382
  errorToMessage: (error) => error.error.message
374
383
  }),
375
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
384
+ successfulResponseHandler: createJsonResponseHandler(
376
385
  // do not validate the response body, only apply types to the response body
377
- (0, import_provider_utils5.jsonSchema)(() => {
386
+ jsonSchema(() => {
378
387
  throw new Error("json schema not implemented");
379
388
  })
380
389
  ),
@@ -387,7 +396,7 @@ var OpenResponsesLanguageModel = class {
387
396
  switch (part.type) {
388
397
  // TODO AI SDK 7 adjust reasoning in the specification to better support the reasoning structure from open responses.
389
398
  case "reasoning": {
390
- for (const contentPart of (_a = part.content) != null ? _a : []) {
399
+ for (const contentPart of (_c = part.content) != null ? _c : []) {
391
400
  content.push({
392
401
  type: "reasoning",
393
402
  text: contentPart.text
@@ -418,17 +427,17 @@ var OpenResponsesLanguageModel = class {
418
427
  }
419
428
  const usage = response.usage;
420
429
  const inputTokens = usage == null ? void 0 : usage.input_tokens;
421
- const cachedInputTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.cached_tokens;
430
+ const cachedInputTokens = (_d = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _d.cached_tokens;
422
431
  const outputTokens = usage == null ? void 0 : usage.output_tokens;
423
- const reasoningTokens = (_c = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens;
432
+ const reasoningTokens = (_e = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens;
424
433
  return {
425
434
  content,
426
435
  finishReason: {
427
436
  unified: mapOpenResponsesFinishReason({
428
- finishReason: (_d = response.incomplete_details) == null ? void 0 : _d.reason,
437
+ finishReason: (_f = response.incomplete_details) == null ? void 0 : _f.reason,
429
438
  hasToolCalls
430
439
  }),
431
- raw: (_f = (_e = response.incomplete_details) == null ? void 0 : _e.reason) != null ? _f : void 0
440
+ raw: (_h = (_g = response.incomplete_details) == null ? void 0 : _g.reason) != null ? _h : void 0
432
441
  },
433
442
  usage: {
434
443
  inputTokens: {
@@ -457,20 +466,21 @@ var OpenResponsesLanguageModel = class {
457
466
  };
458
467
  }
459
468
  async doStream(options) {
469
+ var _a, _b;
460
470
  const { body, warnings } = await this.getArgs(options);
461
- const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
471
+ const { responseHeaders, value: response } = await postJsonToApi({
462
472
  url: this.config.url,
463
- headers: (0, import_provider_utils5.combineHeaders)(this.config.headers(), options.headers),
473
+ headers: combineHeaders((_b = (_a = this.config).headers) == null ? void 0 : _b.call(_a), options.headers),
464
474
  body: {
465
475
  ...body,
466
476
  stream: true
467
477
  },
468
- failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
478
+ failedResponseHandler: createJsonErrorResponseHandler({
469
479
  errorSchema: openResponsesErrorSchema,
470
480
  errorToMessage: (error) => error.error.message
471
481
  }),
472
482
  // TODO consider validation
473
- successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(import_v43.z.any()),
483
+ successfulResponseHandler: createEventSourceResponseHandler(z3.any()),
474
484
  abortSignal: options.abortSignal,
475
485
  fetch: this.config.fetch
476
486
  });
@@ -488,14 +498,14 @@ var OpenResponsesLanguageModel = class {
488
498
  }
489
499
  };
490
500
  const updateUsage = (responseUsage) => {
491
- var _a, _b;
501
+ var _a2, _b2;
492
502
  if (!responseUsage) {
493
503
  return;
494
504
  }
495
505
  const inputTokens = responseUsage.input_tokens;
496
- const cachedInputTokens = (_a = responseUsage.input_tokens_details) == null ? void 0 : _a.cached_tokens;
506
+ const cachedInputTokens = (_a2 = responseUsage.input_tokens_details) == null ? void 0 : _a2.cached_tokens;
497
507
  const outputTokens = responseUsage.output_tokens;
498
- const reasoningTokens = (_b = responseUsage.output_tokens_details) == null ? void 0 : _b.reasoning_tokens;
508
+ const reasoningTokens = (_b2 = responseUsage.output_tokens_details) == null ? void 0 : _b2.reasoning_tokens;
499
509
  usage.inputTokens = {
500
510
  total: inputTokens,
501
511
  noCache: (inputTokens != null ? inputTokens : 0) - (cachedInputTokens != null ? cachedInputTokens : 0),
@@ -523,7 +533,7 @@ var OpenResponsesLanguageModel = class {
523
533
  controller.enqueue({ type: "stream-start", warnings });
524
534
  },
525
535
  transform(parseResult, controller) {
526
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
536
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
527
537
  if (options.includeRawChunks) {
528
538
  controller.enqueue({
529
539
  type: "raw",
@@ -543,8 +553,8 @@ var OpenResponsesLanguageModel = class {
543
553
  };
544
554
  } else if (chunk.type === "response.function_call_arguments.delta") {
545
555
  const functionCallChunk = chunk;
546
- const toolCall = (_a = toolCallsByItemId[functionCallChunk.item_id]) != null ? _a : toolCallsByItemId[functionCallChunk.item_id] = {};
547
- toolCall.arguments = ((_b = toolCall.arguments) != null ? _b : "") + functionCallChunk.delta;
556
+ const toolCall = (_a2 = toolCallsByItemId[functionCallChunk.item_id]) != null ? _a2 : toolCallsByItemId[functionCallChunk.item_id] = {};
557
+ toolCall.arguments = ((_b2 = toolCall.arguments) != null ? _b2 : "") + functionCallChunk.delta;
548
558
  } else if (chunk.type === "response.function_call_arguments.done") {
549
559
  const functionCallChunk = chunk;
550
560
  const toolCall = (_c = toolCallsByItemId[functionCallChunk.item_id]) != null ? _c : toolCallsByItemId[functionCallChunk.item_id] = {};
@@ -628,7 +638,7 @@ var OpenResponsesLanguageModel = class {
628
638
  // src/open-responses-provider.ts
629
639
  function createOpenResponses(options) {
630
640
  const providerName = options.name;
631
- const getHeaders = () => (0, import_provider_utils6.withUserAgentSuffix)(
641
+ const getHeaders = () => withUserAgentSuffix(
632
642
  {
633
643
  ...options.apiKey ? {
634
644
  Authorization: `Bearer ${options.apiKey}`
@@ -644,7 +654,7 @@ function createOpenResponses(options) {
644
654
  headers: getHeaders,
645
655
  url: options.url,
646
656
  fetch: options.fetch,
647
- generateId: () => (0, import_provider_utils6.generateId)()
657
+ generateId: () => generateId()
648
658
  });
649
659
  };
650
660
  const createLanguageModel = (modelId) => {
@@ -661,16 +671,15 @@ function createOpenResponses(options) {
661
671
  provider.specificationVersion = "v4";
662
672
  provider.languageModel = createLanguageModel;
663
673
  provider.embeddingModel = (modelId) => {
664
- throw new import_provider2.NoSuchModelError({ modelId, modelType: "embeddingModel" });
674
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
665
675
  };
666
676
  provider.imageModel = (modelId) => {
667
- throw new import_provider2.NoSuchModelError({ modelId, modelType: "imageModel" });
677
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
668
678
  };
669
679
  return provider;
670
680
  }
671
- // Annotate the CommonJS export names for ESM import in node:
672
- 0 && (module.exports = {
681
+ export {
673
682
  VERSION,
674
683
  createOpenResponses
675
- });
684
+ };
676
685
  //# sourceMappingURL=index.js.map