@ai-sdk/openai 2.0.38 → 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.
@@ -2145,6 +2145,7 @@ async function convertToOpenAIResponsesInput({
2145
2145
  });
2146
2146
  break;
2147
2147
  }
2148
+ // assistant tool result parts are from provider-executed tools:
2148
2149
  case "tool-result": {
2149
2150
  if (store) {
2150
2151
  input.push({ type: "item_reference", id: part.toolCallId });
@@ -3267,6 +3268,24 @@ var OpenAIResponsesLanguageModel = class {
3267
3268
  id: value.item.id,
3268
3269
  toolName: "computer_use"
3269
3270
  });
3271
+ } else if (value.item.type === "code_interpreter_call") {
3272
+ ongoingToolCalls[value.output_index] = {
3273
+ toolName: "code_interpreter",
3274
+ toolCallId: value.item.id,
3275
+ codeInterpreter: {
3276
+ containerId: value.item.container_id
3277
+ }
3278
+ };
3279
+ controller.enqueue({
3280
+ type: "tool-input-start",
3281
+ id: value.item.id,
3282
+ toolName: "code_interpreter"
3283
+ });
3284
+ controller.enqueue({
3285
+ type: "tool-input-delta",
3286
+ id: value.item.id,
3287
+ delta: `{"containerId":"${value.item.container_id}","code":"`
3288
+ });
3270
3289
  } else if (value.item.type === "file_search_call") {
3271
3290
  controller.enqueue({
3272
3291
  type: "tool-call",
@@ -3390,16 +3409,7 @@ var OpenAIResponsesLanguageModel = class {
3390
3409
  providerExecuted: true
3391
3410
  });
3392
3411
  } else if (value.item.type === "code_interpreter_call") {
3393
- controller.enqueue({
3394
- type: "tool-call",
3395
- toolCallId: value.item.id,
3396
- toolName: "code_interpreter",
3397
- input: JSON.stringify({
3398
- code: value.item.code,
3399
- containerId: value.item.container_id
3400
- }),
3401
- providerExecuted: true
3402
- });
3412
+ ongoingToolCalls[value.output_index] = void 0;
3403
3413
  controller.enqueue({
3404
3414
  type: "tool-result",
3405
3415
  toolCallId: value.item.id,
@@ -3449,6 +3459,40 @@ var OpenAIResponsesLanguageModel = class {
3449
3459
  delta: value.delta
3450
3460
  });
3451
3461
  }
3462
+ } else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
3463
+ const toolCall = ongoingToolCalls[value.output_index];
3464
+ if (toolCall != null) {
3465
+ controller.enqueue({
3466
+ type: "tool-input-delta",
3467
+ id: toolCall.toolCallId,
3468
+ // The delta is code, which is embedding in a JSON string.
3469
+ // To escape it, we use JSON.stringify and slice to remove the outer quotes.
3470
+ delta: JSON.stringify(value.delta).slice(1, -1)
3471
+ });
3472
+ }
3473
+ } else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
3474
+ const toolCall = ongoingToolCalls[value.output_index];
3475
+ if (toolCall != null) {
3476
+ controller.enqueue({
3477
+ type: "tool-input-delta",
3478
+ id: toolCall.toolCallId,
3479
+ delta: '"}'
3480
+ });
3481
+ controller.enqueue({
3482
+ type: "tool-input-end",
3483
+ id: toolCall.toolCallId
3484
+ });
3485
+ controller.enqueue({
3486
+ type: "tool-call",
3487
+ toolCallId: toolCall.toolCallId,
3488
+ toolName: "code_interpreter",
3489
+ input: JSON.stringify({
3490
+ code: value.code,
3491
+ containerId: toolCall.codeInterpreter.containerId
3492
+ }),
3493
+ providerExecuted: true
3494
+ });
3495
+ }
3452
3496
  } else if (isResponseCreatedChunk(value)) {
3453
3497
  responseId = value.response.id;
3454
3498
  controller.enqueue({
@@ -3632,6 +3676,19 @@ var responseOutputItemAddedSchema = import_v418.z.object({
3632
3676
  import_v418.z.object({
3633
3677
  type: import_v418.z.literal("image_generation_call"),
3634
3678
  id: import_v418.z.string()
3679
+ }),
3680
+ import_v418.z.object({
3681
+ type: import_v418.z.literal("code_interpreter_call"),
3682
+ id: import_v418.z.string(),
3683
+ container_id: import_v418.z.string(),
3684
+ code: import_v418.z.string().nullable(),
3685
+ outputs: import_v418.z.array(
3686
+ import_v418.z.discriminatedUnion("type", [
3687
+ import_v418.z.object({ type: import_v418.z.literal("logs"), logs: import_v418.z.string() }),
3688
+ import_v418.z.object({ type: import_v418.z.literal("image"), url: import_v418.z.string() })
3689
+ ])
3690
+ ).nullable(),
3691
+ status: import_v418.z.string()
3635
3692
  })
3636
3693
  ])
3637
3694
  });
@@ -3673,6 +3730,18 @@ var responseFunctionCallArgumentsDeltaSchema = import_v418.z.object({
3673
3730
  output_index: import_v418.z.number(),
3674
3731
  delta: import_v418.z.string()
3675
3732
  });
3733
+ var responseCodeInterpreterCallCodeDeltaSchema = import_v418.z.object({
3734
+ type: import_v418.z.literal("response.code_interpreter_call_code.delta"),
3735
+ item_id: import_v418.z.string(),
3736
+ output_index: import_v418.z.number(),
3737
+ delta: import_v418.z.string()
3738
+ });
3739
+ var responseCodeInterpreterCallCodeDoneSchema = import_v418.z.object({
3740
+ type: import_v418.z.literal("response.code_interpreter_call_code.done"),
3741
+ item_id: import_v418.z.string(),
3742
+ output_index: import_v418.z.number(),
3743
+ code: import_v418.z.string()
3744
+ });
3676
3745
  var responseAnnotationAddedSchema = import_v418.z.object({
3677
3746
  type: import_v418.z.literal("response.output_text.annotation.added"),
3678
3747
  annotation: import_v418.z.discriminatedUnion("type", [
@@ -3710,6 +3779,8 @@ var openaiResponsesChunkSchema = import_v418.z.union([
3710
3779
  responseOutputItemAddedSchema,
3711
3780
  responseOutputItemDoneSchema,
3712
3781
  responseFunctionCallArgumentsDeltaSchema,
3782
+ responseCodeInterpreterCallCodeDeltaSchema,
3783
+ responseCodeInterpreterCallCodeDoneSchema,
3713
3784
  responseAnnotationAddedSchema,
3714
3785
  responseReasoningSummaryPartAddedSchema,
3715
3786
  responseReasoningSummaryTextDeltaSchema,
@@ -3735,6 +3806,12 @@ function isResponseCreatedChunk(chunk) {
3735
3806
  function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
3736
3807
  return chunk.type === "response.function_call_arguments.delta";
3737
3808
  }
3809
+ function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
3810
+ return chunk.type === "response.code_interpreter_call_code.delta";
3811
+ }
3812
+ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
3813
+ return chunk.type === "response.code_interpreter_call_code.done";
3814
+ }
3738
3815
  function isResponseOutputItemAddedChunk(chunk) {
3739
3816
  return chunk.type === "response.output_item.added";
3740
3817
  }