@ai-sdk/openai 3.0.101 → 3.0.102

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/dist/index.mjs CHANGED
@@ -4042,6 +4042,22 @@ var jsonValueSchema2 = z22.lazy(
4042
4042
  z22.record(z22.string(), jsonValueSchema2.optional())
4043
4043
  ])
4044
4044
  );
4045
+ function isRecord(value) {
4046
+ return value != null && typeof value === "object" && !Array.isArray(value);
4047
+ }
4048
+ var openaiResponsesLocalShellCallSchema = z22.object({
4049
+ type: z22.literal("local_shell_call"),
4050
+ id: z22.string(),
4051
+ call_id: z22.string(),
4052
+ action: z22.object({
4053
+ type: z22.literal("exec"),
4054
+ command: z22.array(z22.string()),
4055
+ timeout_ms: z22.number().optional(),
4056
+ user: z22.string().optional(),
4057
+ working_directory: z22.string().optional(),
4058
+ env: z22.record(z22.string(), z22.string()).optional()
4059
+ })
4060
+ });
4045
4061
  var openaiResponsesNestedErrorChunkSchema = z22.object({
4046
4062
  type: z22.literal("error"),
4047
4063
  sequence_number: z22.number(),
@@ -4059,6 +4075,60 @@ var openaiResponsesErrorChunkSchema = z22.object({
4059
4075
  message: z22.string(),
4060
4076
  param: z22.string().nullish()
4061
4077
  });
4078
+ var openaiResponsesModeledChunkTypes = /* @__PURE__ */ new Set([
4079
+ "error",
4080
+ "response.apply_patch_call_operation_diff.delta",
4081
+ "response.apply_patch_call_operation_diff.done",
4082
+ "response.code_interpreter_call_code.delta",
4083
+ "response.code_interpreter_call_code.done",
4084
+ "response.completed",
4085
+ "response.created",
4086
+ "response.custom_tool_call_input.delta",
4087
+ "response.failed",
4088
+ "response.function_call_arguments.delta",
4089
+ "response.function_call_arguments.done",
4090
+ "response.image_generation_call.partial_image",
4091
+ "response.incomplete",
4092
+ "response.output_item.added",
4093
+ "response.output_item.done",
4094
+ "response.output_text.annotation.added",
4095
+ "response.output_text.delta",
4096
+ "response.reasoning_summary_part.added",
4097
+ "response.reasoning_summary_part.done",
4098
+ "response.reasoning_summary_text.delta"
4099
+ ]);
4100
+ var openaiResponsesModeledOutputItemTypes = /* @__PURE__ */ new Set([
4101
+ "apply_patch_call",
4102
+ "code_interpreter_call",
4103
+ "computer_call",
4104
+ "custom_tool_call",
4105
+ "file_search_call",
4106
+ "function_call",
4107
+ "image_generation_call",
4108
+ "local_shell_call",
4109
+ "mcp_approval_request",
4110
+ "mcp_call",
4111
+ "mcp_list_tools",
4112
+ "message",
4113
+ "reasoning",
4114
+ "shell_call",
4115
+ "shell_call_output",
4116
+ "tool_search_call",
4117
+ "tool_search_output",
4118
+ "web_search_call"
4119
+ ]);
4120
+ function isModeledOpenAIResponsesChunk(value) {
4121
+ if (typeof value.type !== "string" || !openaiResponsesModeledChunkTypes.has(value.type)) {
4122
+ return false;
4123
+ }
4124
+ if (value.type !== "response.output_item.added" && value.type !== "response.output_item.done") {
4125
+ return true;
4126
+ }
4127
+ if (!isRecord(value.item) || typeof value.item.type !== "string") {
4128
+ return true;
4129
+ }
4130
+ return openaiResponsesModeledOutputItemTypes.has(value.item.type);
4131
+ }
4062
4132
  var openaiResponsesChunkSchema = lazySchema20(
4063
4133
  () => zodSchema20(
4064
4134
  z22.union([
@@ -4177,6 +4247,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4177
4247
  type: z22.literal("file_search_call"),
4178
4248
  id: z22.string()
4179
4249
  }),
4250
+ openaiResponsesLocalShellCallSchema,
4180
4251
  z22.object({
4181
4252
  type: z22.literal("image_generation_call"),
4182
4253
  id: z22.string()
@@ -4375,19 +4446,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4375
4446
  })
4376
4447
  ).nullish()
4377
4448
  }),
4378
- z22.object({
4379
- type: z22.literal("local_shell_call"),
4380
- id: z22.string(),
4381
- call_id: z22.string(),
4382
- action: z22.object({
4383
- type: z22.literal("exec"),
4384
- command: z22.array(z22.string()),
4385
- timeout_ms: z22.number().optional(),
4386
- user: z22.string().optional(),
4387
- working_directory: z22.string().optional(),
4388
- env: z22.record(z22.string(), z22.string()).optional()
4389
- })
4390
- }),
4449
+ openaiResponsesLocalShellCallSchema,
4391
4450
  z22.object({
4392
4451
  type: z22.literal("computer_call"),
4393
4452
  id: z22.string(),
@@ -4514,6 +4573,14 @@ var openaiResponsesChunkSchema = lazySchema20(
4514
4573
  output_index: z22.number(),
4515
4574
  delta: z22.string()
4516
4575
  }),
4576
+ z22.object({
4577
+ // `name` is documented as required but omitted from live API events:
4578
+ // https://github.com/openai/openai-openapi/issues/545
4579
+ type: z22.literal("response.function_call_arguments.done"),
4580
+ item_id: z22.string(),
4581
+ output_index: z22.number(),
4582
+ arguments: z22.string()
4583
+ }),
4517
4584
  z22.object({
4518
4585
  type: z22.literal("response.custom_tool_call_input.delta"),
4519
4586
  item_id: z22.string(),
@@ -4600,7 +4667,9 @@ var openaiResponsesChunkSchema = lazySchema20(
4600
4667
  }),
4601
4668
  openaiResponsesNestedErrorChunkSchema,
4602
4669
  openaiResponsesErrorChunkSchema,
4603
- z22.object({ type: z22.string() }).loose().transform((value) => ({
4670
+ z22.object({ type: z22.string() }).loose().refine((value) => !isModeledOpenAIResponsesChunk(value), {
4671
+ message: "Known response chunk failed schema validation"
4672
+ }).transform((value) => ({
4604
4673
  type: "unknown_chunk",
4605
4674
  message: value.type
4606
4675
  }))
@@ -4740,19 +4809,7 @@ var openaiResponsesResponseSchema = lazySchema20(
4740
4809
  id: z22.string(),
4741
4810
  result: z22.string()
4742
4811
  }),
4743
- z22.object({
4744
- type: z22.literal("local_shell_call"),
4745
- id: z22.string(),
4746
- call_id: z22.string(),
4747
- action: z22.object({
4748
- type: z22.literal("exec"),
4749
- command: z22.array(z22.string()),
4750
- timeout_ms: z22.number().optional(),
4751
- user: z22.string().optional(),
4752
- working_directory: z22.string().optional(),
4753
- env: z22.record(z22.string(), z22.string()).optional()
4754
- })
4755
- }),
4812
+ openaiResponsesLocalShellCallSchema,
4756
4813
  z22.object({
4757
4814
  type: z22.literal("function_call"),
4758
4815
  call_id: z22.string(),
@@ -6516,6 +6573,7 @@ var OpenAIResponsesLanguageModel = class {
6516
6573
  requestBodyValues: body,
6517
6574
  responseHeaders
6518
6575
  }) : chunk.error;
6576
+ encounteredStreamError = true;
6519
6577
  finishReason = { unified: "error", raw: void 0 };
6520
6578
  controller.enqueue({ type: "error", error });
6521
6579
  return;
@@ -7315,13 +7373,15 @@ var OpenAIResponsesLanguageModel = class {
7315
7373
  activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
7316
7374
  }
7317
7375
  } else if (isResponseFinishedChunk(value)) {
7318
- finishReason = {
7319
- unified: mapOpenAIResponseFinishReason({
7320
- finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
7321
- hasFunctionCall
7322
- }),
7323
- raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7324
- };
7376
+ if (!encounteredStreamError) {
7377
+ finishReason = {
7378
+ unified: mapOpenAIResponseFinishReason({
7379
+ finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
7380
+ hasFunctionCall
7381
+ }),
7382
+ raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7383
+ };
7384
+ }
7325
7385
  usage = value.response.usage;
7326
7386
  if (typeof value.response.service_tier === "string") {
7327
7387
  serviceTier = value.response.service_tier;
@@ -7940,7 +8000,7 @@ var OpenAITranscriptionModel = class {
7940
8000
  };
7941
8001
 
7942
8002
  // src/version.ts
7943
- var VERSION = true ? "3.0.101" : "0.0.0-test";
8003
+ var VERSION = true ? "3.0.102" : "0.0.0-test";
7944
8004
 
7945
8005
  // src/openai-provider.ts
7946
8006
  function createOpenAI(options = {}) {