@ai-sdk/openai 2.0.37 → 2.0.39

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
@@ -2089,6 +2089,7 @@ async function convertToOpenAIResponsesInput({
2089
2089
  });
2090
2090
  break;
2091
2091
  }
2092
+ // assistant tool result parts are from provider-executed tools:
2092
2093
  case "tool-result": {
2093
2094
  if (store) {
2094
2095
  input.push({ type: "item_reference", id: part.toolCallId });
@@ -3012,6 +3013,24 @@ var OpenAIResponsesLanguageModel = class {
3012
3013
  id: value.item.id,
3013
3014
  toolName: "computer_use"
3014
3015
  });
3016
+ } else if (value.item.type === "code_interpreter_call") {
3017
+ ongoingToolCalls[value.output_index] = {
3018
+ toolName: "code_interpreter",
3019
+ toolCallId: value.item.id,
3020
+ codeInterpreter: {
3021
+ containerId: value.item.container_id
3022
+ }
3023
+ };
3024
+ controller.enqueue({
3025
+ type: "tool-input-start",
3026
+ id: value.item.id,
3027
+ toolName: "code_interpreter"
3028
+ });
3029
+ controller.enqueue({
3030
+ type: "tool-input-delta",
3031
+ id: value.item.id,
3032
+ delta: `{"containerId":"${value.item.container_id}","code":"`
3033
+ });
3015
3034
  } else if (value.item.type === "file_search_call") {
3016
3035
  controller.enqueue({
3017
3036
  type: "tool-call",
@@ -3135,16 +3154,7 @@ var OpenAIResponsesLanguageModel = class {
3135
3154
  providerExecuted: true
3136
3155
  });
3137
3156
  } else if (value.item.type === "code_interpreter_call") {
3138
- controller.enqueue({
3139
- type: "tool-call",
3140
- toolCallId: value.item.id,
3141
- toolName: "code_interpreter",
3142
- input: JSON.stringify({
3143
- code: value.item.code,
3144
- containerId: value.item.container_id
3145
- }),
3146
- providerExecuted: true
3147
- });
3157
+ ongoingToolCalls[value.output_index] = void 0;
3148
3158
  controller.enqueue({
3149
3159
  type: "tool-result",
3150
3160
  toolCallId: value.item.id,
@@ -3194,6 +3204,40 @@ var OpenAIResponsesLanguageModel = class {
3194
3204
  delta: value.delta
3195
3205
  });
3196
3206
  }
3207
+ } else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
3208
+ const toolCall = ongoingToolCalls[value.output_index];
3209
+ if (toolCall != null) {
3210
+ controller.enqueue({
3211
+ type: "tool-input-delta",
3212
+ id: toolCall.toolCallId,
3213
+ // The delta is code, which is embedding in a JSON string.
3214
+ // To escape it, we use JSON.stringify and slice to remove the outer quotes.
3215
+ delta: JSON.stringify(value.delta).slice(1, -1)
3216
+ });
3217
+ }
3218
+ } else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
3219
+ const toolCall = ongoingToolCalls[value.output_index];
3220
+ if (toolCall != null) {
3221
+ controller.enqueue({
3222
+ type: "tool-input-delta",
3223
+ id: toolCall.toolCallId,
3224
+ delta: '"}'
3225
+ });
3226
+ controller.enqueue({
3227
+ type: "tool-input-end",
3228
+ id: toolCall.toolCallId
3229
+ });
3230
+ controller.enqueue({
3231
+ type: "tool-call",
3232
+ toolCallId: toolCall.toolCallId,
3233
+ toolName: "code_interpreter",
3234
+ input: JSON.stringify({
3235
+ code: value.code,
3236
+ containerId: toolCall.codeInterpreter.containerId
3237
+ }),
3238
+ providerExecuted: true
3239
+ });
3240
+ }
3197
3241
  } else if (isResponseCreatedChunk(value)) {
3198
3242
  responseId = value.response.id;
3199
3243
  controller.enqueue({
@@ -3377,6 +3421,19 @@ var responseOutputItemAddedSchema = z15.object({
3377
3421
  z15.object({
3378
3422
  type: z15.literal("image_generation_call"),
3379
3423
  id: z15.string()
3424
+ }),
3425
+ z15.object({
3426
+ type: z15.literal("code_interpreter_call"),
3427
+ id: z15.string(),
3428
+ container_id: z15.string(),
3429
+ code: z15.string().nullable(),
3430
+ outputs: z15.array(
3431
+ z15.discriminatedUnion("type", [
3432
+ z15.object({ type: z15.literal("logs"), logs: z15.string() }),
3433
+ z15.object({ type: z15.literal("image"), url: z15.string() })
3434
+ ])
3435
+ ).nullable(),
3436
+ status: z15.string()
3380
3437
  })
3381
3438
  ])
3382
3439
  });
@@ -3418,6 +3475,18 @@ var responseFunctionCallArgumentsDeltaSchema = z15.object({
3418
3475
  output_index: z15.number(),
3419
3476
  delta: z15.string()
3420
3477
  });
3478
+ var responseCodeInterpreterCallCodeDeltaSchema = z15.object({
3479
+ type: z15.literal("response.code_interpreter_call_code.delta"),
3480
+ item_id: z15.string(),
3481
+ output_index: z15.number(),
3482
+ delta: z15.string()
3483
+ });
3484
+ var responseCodeInterpreterCallCodeDoneSchema = z15.object({
3485
+ type: z15.literal("response.code_interpreter_call_code.done"),
3486
+ item_id: z15.string(),
3487
+ output_index: z15.number(),
3488
+ code: z15.string()
3489
+ });
3421
3490
  var responseAnnotationAddedSchema = z15.object({
3422
3491
  type: z15.literal("response.output_text.annotation.added"),
3423
3492
  annotation: z15.discriminatedUnion("type", [
@@ -3455,6 +3524,8 @@ var openaiResponsesChunkSchema = z15.union([
3455
3524
  responseOutputItemAddedSchema,
3456
3525
  responseOutputItemDoneSchema,
3457
3526
  responseFunctionCallArgumentsDeltaSchema,
3527
+ responseCodeInterpreterCallCodeDeltaSchema,
3528
+ responseCodeInterpreterCallCodeDoneSchema,
3458
3529
  responseAnnotationAddedSchema,
3459
3530
  responseReasoningSummaryPartAddedSchema,
3460
3531
  responseReasoningSummaryTextDeltaSchema,
@@ -3480,6 +3551,12 @@ function isResponseCreatedChunk(chunk) {
3480
3551
  function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
3481
3552
  return chunk.type === "response.function_call_arguments.delta";
3482
3553
  }
3554
+ function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
3555
+ return chunk.type === "response.code_interpreter_call_code.delta";
3556
+ }
3557
+ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
3558
+ return chunk.type === "response.code_interpreter_call_code.done";
3559
+ }
3483
3560
  function isResponseOutputItemAddedChunk(chunk) {
3484
3561
  return chunk.type === "response.output_item.added";
3485
3562
  }
@@ -3918,7 +3995,7 @@ var openaiTranscriptionResponseSchema = z18.object({
3918
3995
  });
3919
3996
 
3920
3997
  // src/version.ts
3921
- var VERSION = true ? "2.0.37" : "0.0.0-test";
3998
+ var VERSION = true ? "2.0.39" : "0.0.0-test";
3922
3999
 
3923
4000
  // src/openai-provider.ts
3924
4001
  function createOpenAI(options = {}) {