@ai-sdk/openai 3.0.67 → 3.0.69

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.
@@ -2699,7 +2699,7 @@ async function convertToOpenAIResponsesInput({
2699
2699
  hasApplyPatchTool = false,
2700
2700
  customProviderToolNames
2701
2701
  }) {
2702
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2702
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2703
2703
  let input = [];
2704
2704
  const warnings = [];
2705
2705
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -2800,6 +2800,7 @@ async function convertToOpenAIResponsesInput({
2800
2800
  }
2801
2801
  case "tool-call": {
2802
2802
  const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
2803
+ const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
2803
2804
  if (hasConversation && id != null) {
2804
2805
  break;
2805
2806
  }
@@ -2823,7 +2824,7 @@ async function convertToOpenAIResponsesInput({
2823
2824
  type: "tool_search_call",
2824
2825
  id: id != null ? id : part.toolCallId,
2825
2826
  execution,
2826
- call_id: (_g = parsedInput.call_id) != null ? _g : null,
2827
+ call_id: (_l = parsedInput.call_id) != null ? _l : null,
2827
2828
  status: "completed",
2828
2829
  arguments: parsedInput.arguments
2829
2830
  });
@@ -2909,7 +2910,8 @@ async function convertToOpenAIResponsesInput({
2909
2910
  call_id: part.toolCallId,
2910
2911
  name: resolvedToolName,
2911
2912
  arguments: serializeToolCallArguments2(part.input),
2912
- id
2913
+ id,
2914
+ ...namespace != null && { namespace }
2913
2915
  });
2914
2916
  break;
2915
2917
  }
@@ -2925,7 +2927,7 @@ async function convertToOpenAIResponsesInput({
2925
2927
  part.toolName
2926
2928
  );
2927
2929
  if (resolvedResultToolName === "tool_search") {
2928
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2930
+ const itemId = (_o = (_n = (_m = part.providerOptions) == null ? void 0 : _m[providerOptionsName]) == null ? void 0 : _n.itemId) != null ? _o : part.toolCallId;
2929
2931
  if (store) {
2930
2932
  input.push({ type: "item_reference", id: itemId });
2931
2933
  } else if (part.output.type === "json") {
@@ -2966,7 +2968,7 @@ async function convertToOpenAIResponsesInput({
2966
2968
  break;
2967
2969
  }
2968
2970
  if (store) {
2969
- const itemId = (_m = (_l = (_k = part.providerOptions) == null ? void 0 : _k[providerOptionsName]) == null ? void 0 : _l.itemId) != null ? _m : part.toolCallId;
2971
+ const itemId = (_r = (_q = (_p = part.providerOptions) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _r : part.toolCallId;
2970
2972
  input.push({ type: "item_reference", id: itemId });
2971
2973
  } else {
2972
2974
  warnings.push({
@@ -3076,7 +3078,7 @@ async function convertToOpenAIResponsesInput({
3076
3078
  }
3077
3079
  const output = part.output;
3078
3080
  if (output.type === "execution-denied") {
3079
- const approvalId = (_o = (_n = output.providerOptions) == null ? void 0 : _n.openai) == null ? void 0 : _o.approvalId;
3081
+ const approvalId = (_t = (_s = output.providerOptions) == null ? void 0 : _s.openai) == null ? void 0 : _t.approvalId;
3080
3082
  if (approvalId) {
3081
3083
  continue;
3082
3084
  }
@@ -3150,7 +3152,7 @@ async function convertToOpenAIResponsesInput({
3150
3152
  outputValue = output.value;
3151
3153
  break;
3152
3154
  case "execution-denied":
3153
- outputValue = (_p = output.reason) != null ? _p : "Tool execution denied.";
3155
+ outputValue = (_u = output.reason) != null ? _u : "Tool execution denied.";
3154
3156
  break;
3155
3157
  case "json":
3156
3158
  case "error-json":
@@ -3211,7 +3213,7 @@ async function convertToOpenAIResponsesInput({
3211
3213
  contentValue = output.value;
3212
3214
  break;
3213
3215
  case "execution-denied":
3214
- contentValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
3216
+ contentValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
3215
3217
  break;
3216
3218
  case "json":
3217
3219
  case "error-json":
@@ -4746,20 +4748,37 @@ async function prepareResponsesTools({
4746
4748
  return { tools: void 0, toolChoice: void 0, toolWarnings };
4747
4749
  }
4748
4750
  const openaiTools = [];
4751
+ const namespaceTools = /* @__PURE__ */ new Map();
4749
4752
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4750
4753
  for (const tool of tools) {
4751
4754
  switch (tool.type) {
4752
4755
  case "function": {
4753
4756
  const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4754
- const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4755
- openaiTools.push({
4756
- type: "function",
4757
- name: tool.name,
4758
- description: tool.description,
4759
- parameters: tool.inputSchema,
4760
- ...tool.strict != null ? { strict: tool.strict } : {},
4761
- ...deferLoading != null ? { defer_loading: deferLoading } : {}
4757
+ const openaiFunctionTool = prepareFunctionTool({
4758
+ tool,
4759
+ options: openaiOptions
4762
4760
  });
4761
+ const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
4762
+ if (namespace == null) {
4763
+ openaiTools.push(openaiFunctionTool);
4764
+ } else {
4765
+ let namespaceTool = namespaceTools.get(namespace.name);
4766
+ if (namespaceTool == null) {
4767
+ namespaceTool = {
4768
+ type: "namespace",
4769
+ name: namespace.name,
4770
+ description: namespace.description,
4771
+ tools: []
4772
+ };
4773
+ namespaceTools.set(namespace.name, namespaceTool);
4774
+ openaiTools.push(namespaceTool);
4775
+ } else if (namespaceTool.description !== namespace.description) {
4776
+ throw new import_provider7.UnsupportedFunctionalityError({
4777
+ functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
4778
+ });
4779
+ }
4780
+ namespaceTool.tools.push(openaiFunctionTool);
4781
+ }
4763
4782
  break;
4764
4783
  }
4765
4784
  case "provider": {
@@ -4972,6 +4991,20 @@ async function prepareResponsesTools({
4972
4991
  }
4973
4992
  }
4974
4993
  }
4994
+ function prepareFunctionTool({
4995
+ tool,
4996
+ options
4997
+ }) {
4998
+ const deferLoading = options == null ? void 0 : options.deferLoading;
4999
+ return {
5000
+ type: "function",
5001
+ name: tool.name,
5002
+ description: tool.description,
5003
+ parameters: tool.inputSchema,
5004
+ ...tool.strict != null ? { strict: tool.strict } : {},
5005
+ ...deferLoading != null ? { defer_loading: deferLoading } : {}
5006
+ };
5007
+ }
4975
5008
  function mapShellEnvironment(environment) {
4976
5009
  if (environment.type === "containerReference") {
4977
5010
  const env2 = environment;