@ai-sdk/openai 4.0.0-beta.10 → 4.0.0-beta.12

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
@@ -2733,7 +2733,7 @@ async function convertToOpenAIResponsesInput({
2733
2733
  hasApplyPatchTool = false,
2734
2734
  customProviderToolNames
2735
2735
  }) {
2736
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2736
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
2737
2737
  let input = [];
2738
2738
  const warnings = [];
2739
2739
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3080,6 +3080,28 @@ async function convertToOpenAIResponsesInput({
3080
3080
  }
3081
3081
  break;
3082
3082
  }
3083
+ case "custom": {
3084
+ if (part.kind === "openai-compaction") {
3085
+ const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
3086
+ const id = providerOpts == null ? void 0 : providerOpts.itemId;
3087
+ if (hasConversation && id != null) {
3088
+ break;
3089
+ }
3090
+ if (store && id != null) {
3091
+ input.push({ type: "item_reference", id });
3092
+ break;
3093
+ }
3094
+ const encryptedContent = providerOpts == null ? void 0 : providerOpts.encryptedContent;
3095
+ if (id != null) {
3096
+ input.push({
3097
+ type: "compaction",
3098
+ id,
3099
+ encrypted_content: encryptedContent
3100
+ });
3101
+ }
3102
+ }
3103
+ break;
3104
+ }
3083
3105
  }
3084
3106
  }
3085
3107
  break;
@@ -3107,7 +3129,7 @@ async function convertToOpenAIResponsesInput({
3107
3129
  }
3108
3130
  const output = part.output;
3109
3131
  if (output.type === "execution-denied") {
3110
- const approvalId = (_o = (_n = output.providerOptions) == null ? void 0 : _n.openai) == null ? void 0 : _o.approvalId;
3132
+ const approvalId = (_p = (_o = output.providerOptions) == null ? void 0 : _o.openai) == null ? void 0 : _p.approvalId;
3111
3133
  if (approvalId) {
3112
3134
  continue;
3113
3135
  }
@@ -3181,7 +3203,7 @@ async function convertToOpenAIResponsesInput({
3181
3203
  outputValue = output.value;
3182
3204
  break;
3183
3205
  case "execution-denied":
3184
- outputValue = (_p = output.reason) != null ? _p : "Tool execution denied.";
3206
+ outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
3185
3207
  break;
3186
3208
  case "json":
3187
3209
  case "error-json":
@@ -3235,7 +3257,7 @@ async function convertToOpenAIResponsesInput({
3235
3257
  contentValue = output.value;
3236
3258
  break;
3237
3259
  case "execution-denied":
3238
- contentValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
3260
+ contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
3239
3261
  break;
3240
3262
  case "json":
3241
3263
  case "error-json":
@@ -3487,6 +3509,11 @@ var openaiResponsesChunkSchema = lazySchema19(
3487
3509
  commands: z21.array(z21.string())
3488
3510
  })
3489
3511
  }),
3512
+ z21.object({
3513
+ type: z21.literal("compaction"),
3514
+ id: z21.string(),
3515
+ encrypted_content: z21.string().nullish()
3516
+ }),
3490
3517
  z21.object({
3491
3518
  type: z21.literal("shell_call_output"),
3492
3519
  id: z21.string(),
@@ -3710,6 +3737,11 @@ var openaiResponsesChunkSchema = lazySchema19(
3710
3737
  commands: z21.array(z21.string())
3711
3738
  })
3712
3739
  }),
3740
+ z21.object({
3741
+ type: z21.literal("compaction"),
3742
+ id: z21.string(),
3743
+ encrypted_content: z21.string()
3744
+ }),
3713
3745
  z21.object({
3714
3746
  type: z21.literal("shell_call_output"),
3715
3747
  id: z21.string(),
@@ -4107,6 +4139,11 @@ var openaiResponsesResponseSchema = lazySchema19(
4107
4139
  commands: z21.array(z21.string())
4108
4140
  })
4109
4141
  }),
4142
+ z21.object({
4143
+ type: z21.literal("compaction"),
4144
+ id: z21.string(),
4145
+ encrypted_content: z21.string()
4146
+ }),
4110
4147
  z21.object({
4111
4148
  type: z21.literal("shell_call_output"),
4112
4149
  id: z21.string(),
@@ -4369,7 +4406,16 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema20(
4369
4406
  * When enabled, the SDK applies reasoning-model parameter compatibility rules
4370
4407
  * and defaults `systemMessageMode` to `developer` unless overridden.
4371
4408
  */
4372
- forceReasoning: z22.boolean().optional()
4409
+ forceReasoning: z22.boolean().optional(),
4410
+ /**
4411
+ * Enable server-side context management (compaction).
4412
+ */
4413
+ contextManagement: z22.array(
4414
+ z22.object({
4415
+ type: z22.literal("compaction"),
4416
+ compactThreshold: z22.number()
4417
+ })
4418
+ ).nullish()
4373
4419
  })
4374
4420
  )
4375
4421
  );
@@ -4838,6 +4884,13 @@ var OpenAIResponsesLanguageModel = class {
4838
4884
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
4839
4885
  top_logprobs: topLogprobs,
4840
4886
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
4887
+ // context management (server-side compaction):
4888
+ ...(openaiOptions == null ? void 0 : openaiOptions.contextManagement) && {
4889
+ context_management: openaiOptions.contextManagement.map((cm) => ({
4890
+ type: cm.type,
4891
+ compact_threshold: cm.compactThreshold
4892
+ }))
4893
+ },
4841
4894
  // model-specific settings:
4842
4895
  ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4843
4896
  reasoning: {
@@ -5362,6 +5415,20 @@ var OpenAIResponsesLanguageModel = class {
5362
5415
  });
5363
5416
  break;
5364
5417
  }
5418
+ case "compaction": {
5419
+ content.push({
5420
+ type: "custom",
5421
+ kind: "openai-compaction",
5422
+ providerMetadata: {
5423
+ [providerOptionsName]: {
5424
+ type: "compaction",
5425
+ itemId: part.id,
5426
+ encryptedContent: part.encrypted_content
5427
+ }
5428
+ }
5429
+ });
5430
+ break;
5431
+ }
5365
5432
  }
5366
5433
  }
5367
5434
  const providerMetadata = {
@@ -5991,6 +6058,18 @@ var OpenAIResponsesLanguageModel = class {
5991
6058
  });
5992
6059
  }
5993
6060
  delete activeReasoning[value.item.id];
6061
+ } else if (value.item.type === "compaction") {
6062
+ controller.enqueue({
6063
+ type: "custom",
6064
+ kind: "openai-compaction",
6065
+ providerMetadata: {
6066
+ [providerOptionsName]: {
6067
+ type: "compaction",
6068
+ itemId: value.item.id,
6069
+ encryptedContent: value.item.encrypted_content
6070
+ }
6071
+ }
6072
+ });
5994
6073
  }
5995
6074
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
5996
6075
  const toolCall = ongoingToolCalls[value.output_index];
@@ -6690,7 +6769,7 @@ var OpenAITranscriptionModel = class {
6690
6769
  };
6691
6770
 
6692
6771
  // src/version.ts
6693
- var VERSION = true ? "4.0.0-beta.10" : "0.0.0-test";
6772
+ var VERSION = true ? "4.0.0-beta.12" : "0.0.0-test";
6694
6773
 
6695
6774
  // src/openai-provider.ts
6696
6775
  function createOpenAI(options = {}) {