@ai-sdk/openai 3.0.138 → 3.0.140

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.
@@ -3638,7 +3638,7 @@ function getParallelToolCallMetadata({
3638
3638
  }) {
3639
3639
  var _a2;
3640
3640
  const metadata = (_a2 = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a2.parallelToolCall;
3641
- if (!isJSONObject(metadata) || typeof metadata.itemId !== "string" || typeof metadata.toolCallId !== "string" || typeof metadata.toolName !== "string" || typeof metadata.input !== "string" || typeof metadata.index !== "number" || !Number.isInteger(metadata.index) || typeof metadata.count !== "number" || !Number.isInteger(metadata.count) || metadata.index < 0 || metadata.count <= metadata.index) {
3641
+ if (!isJSONObject(metadata) || typeof metadata.itemId !== "string" || typeof metadata.toolCallId !== "string" || typeof metadata.toolName !== "string" || metadata.input !== void 0 && typeof metadata.input !== "string" || typeof metadata.index !== "number" || !Number.isInteger(metadata.index) || typeof metadata.count !== "number" || !Number.isInteger(metadata.count) || metadata.index < 0 || metadata.count <= metadata.index) {
3642
3642
  return void 0;
3643
3643
  }
3644
3644
  return metadata;
@@ -3692,7 +3692,7 @@ async function expandParallelToolCall({
3692
3692
  itemId,
3693
3693
  toolCallId: toolCall.toolCallId,
3694
3694
  toolName: toolCall.toolName,
3695
- input: toolCall.input,
3695
+ ...index === 0 && { input: toolCall.input },
3696
3696
  index,
3697
3697
  count: toolUses.length
3698
3698
  }
@@ -3879,7 +3879,7 @@ async function convertFunctionToolResultOutput({
3879
3879
  }
3880
3880
  }
3881
3881
  function hasSameParallelToolCall(first, second) {
3882
- return first.itemId === second.itemId && first.toolCallId === second.toolCallId && first.toolName === second.toolName && first.input === second.input && first.count === second.count;
3882
+ return first.itemId === second.itemId && first.toolCallId === second.toolCallId && first.toolName === second.toolName && (first.input === void 0 || second.input === void 0 || first.input === second.input) && first.count === second.count;
3883
3883
  }
3884
3884
  function collectCompleteParallelToolResultGroups({
3885
3885
  prompt,
@@ -3914,12 +3914,15 @@ function collectCompleteParallelToolResultGroups({
3914
3914
  existing.invalid = true;
3915
3915
  continue;
3916
3916
  }
3917
+ if (existing.metadata.input === void 0 && metadata.input !== void 0) {
3918
+ existing.metadata = metadata;
3919
+ }
3917
3920
  existing.results.set(metadata.index, part);
3918
3921
  }
3919
3922
  }
3920
3923
  const completeGroups = /* @__PURE__ */ new Map();
3921
3924
  for (const [toolCallId, group] of pendingGroups) {
3922
- if (group.invalid || group.results.size !== group.metadata.count) {
3925
+ if (group.invalid || group.results.size !== group.metadata.count || group.metadata.input === void 0) {
3923
3926
  continue;
3924
3927
  }
3925
3928
  const results = Array.from(
@@ -3928,7 +3931,7 @@ function collectCompleteParallelToolResultGroups({
3928
3931
  );
3929
3932
  if (results.every(isNonNullable)) {
3930
3933
  completeGroups.set(toolCallId, {
3931
- metadata: group.metadata,
3934
+ metadata: { ...group.metadata, input: group.metadata.input },
3932
3935
  results
3933
3936
  });
3934
3937
  }