@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.
package/dist/index.mjs CHANGED
@@ -2847,7 +2847,7 @@ async function convertToOpenAIResponsesInput({
2847
2847
  hasApplyPatchTool = false,
2848
2848
  customProviderToolNames
2849
2849
  }) {
2850
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2850
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2851
2851
  let input = [];
2852
2852
  const warnings = [];
2853
2853
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -2948,6 +2948,7 @@ async function convertToOpenAIResponsesInput({
2948
2948
  }
2949
2949
  case "tool-call": {
2950
2950
  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;
2951
+ 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;
2951
2952
  if (hasConversation && id != null) {
2952
2953
  break;
2953
2954
  }
@@ -2971,7 +2972,7 @@ async function convertToOpenAIResponsesInput({
2971
2972
  type: "tool_search_call",
2972
2973
  id: id != null ? id : part.toolCallId,
2973
2974
  execution,
2974
- call_id: (_g = parsedInput.call_id) != null ? _g : null,
2975
+ call_id: (_l = parsedInput.call_id) != null ? _l : null,
2975
2976
  status: "completed",
2976
2977
  arguments: parsedInput.arguments
2977
2978
  });
@@ -3057,7 +3058,8 @@ async function convertToOpenAIResponsesInput({
3057
3058
  call_id: part.toolCallId,
3058
3059
  name: resolvedToolName,
3059
3060
  arguments: serializeToolCallArguments2(part.input),
3060
- id
3061
+ id,
3062
+ ...namespace != null && { namespace }
3061
3063
  });
3062
3064
  break;
3063
3065
  }
@@ -3073,7 +3075,7 @@ async function convertToOpenAIResponsesInput({
3073
3075
  part.toolName
3074
3076
  );
3075
3077
  if (resolvedResultToolName === "tool_search") {
3076
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
3078
+ const itemId = (_o = (_n = (_m = part.providerOptions) == null ? void 0 : _m[providerOptionsName]) == null ? void 0 : _n.itemId) != null ? _o : part.toolCallId;
3077
3079
  if (store) {
3078
3080
  input.push({ type: "item_reference", id: itemId });
3079
3081
  } else if (part.output.type === "json") {
@@ -3114,7 +3116,7 @@ async function convertToOpenAIResponsesInput({
3114
3116
  break;
3115
3117
  }
3116
3118
  if (store) {
3117
- const itemId = (_m = (_l = (_k = part.providerOptions) == null ? void 0 : _k[providerOptionsName]) == null ? void 0 : _l.itemId) != null ? _m : part.toolCallId;
3119
+ const itemId = (_r = (_q = (_p = part.providerOptions) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _r : part.toolCallId;
3118
3120
  input.push({ type: "item_reference", id: itemId });
3119
3121
  } else {
3120
3122
  warnings.push({
@@ -3224,7 +3226,7 @@ async function convertToOpenAIResponsesInput({
3224
3226
  }
3225
3227
  const output = part.output;
3226
3228
  if (output.type === "execution-denied") {
3227
- const approvalId = (_o = (_n = output.providerOptions) == null ? void 0 : _n.openai) == null ? void 0 : _o.approvalId;
3229
+ const approvalId = (_t = (_s = output.providerOptions) == null ? void 0 : _s.openai) == null ? void 0 : _t.approvalId;
3228
3230
  if (approvalId) {
3229
3231
  continue;
3230
3232
  }
@@ -3298,7 +3300,7 @@ async function convertToOpenAIResponsesInput({
3298
3300
  outputValue = output.value;
3299
3301
  break;
3300
3302
  case "execution-denied":
3301
- outputValue = (_p = output.reason) != null ? _p : "Tool execution denied.";
3303
+ outputValue = (_u = output.reason) != null ? _u : "Tool execution denied.";
3302
3304
  break;
3303
3305
  case "json":
3304
3306
  case "error-json":
@@ -3359,7 +3361,7 @@ async function convertToOpenAIResponsesInput({
3359
3361
  contentValue = output.value;
3360
3362
  break;
3361
3363
  case "execution-denied":
3362
- contentValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
3364
+ contentValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
3363
3365
  break;
3364
3366
  case "json":
3365
3367
  case "error-json":
@@ -4581,20 +4583,37 @@ async function prepareResponsesTools({
4581
4583
  return { tools: void 0, toolChoice: void 0, toolWarnings };
4582
4584
  }
4583
4585
  const openaiTools2 = [];
4586
+ const namespaceTools = /* @__PURE__ */ new Map();
4584
4587
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4585
4588
  for (const tool of tools) {
4586
4589
  switch (tool.type) {
4587
4590
  case "function": {
4588
4591
  const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4589
- const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4590
- openaiTools2.push({
4591
- type: "function",
4592
- name: tool.name,
4593
- description: tool.description,
4594
- parameters: tool.inputSchema,
4595
- ...tool.strict != null ? { strict: tool.strict } : {},
4596
- ...deferLoading != null ? { defer_loading: deferLoading } : {}
4592
+ const openaiFunctionTool = prepareFunctionTool({
4593
+ tool,
4594
+ options: openaiOptions
4597
4595
  });
4596
+ const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
4597
+ if (namespace == null) {
4598
+ openaiTools2.push(openaiFunctionTool);
4599
+ } else {
4600
+ let namespaceTool = namespaceTools.get(namespace.name);
4601
+ if (namespaceTool == null) {
4602
+ namespaceTool = {
4603
+ type: "namespace",
4604
+ name: namespace.name,
4605
+ description: namespace.description,
4606
+ tools: []
4607
+ };
4608
+ namespaceTools.set(namespace.name, namespaceTool);
4609
+ openaiTools2.push(namespaceTool);
4610
+ } else if (namespaceTool.description !== namespace.description) {
4611
+ throw new UnsupportedFunctionalityError5({
4612
+ functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
4613
+ });
4614
+ }
4615
+ namespaceTool.tools.push(openaiFunctionTool);
4616
+ }
4598
4617
  break;
4599
4618
  }
4600
4619
  case "provider": {
@@ -4807,6 +4826,20 @@ async function prepareResponsesTools({
4807
4826
  }
4808
4827
  }
4809
4828
  }
4829
+ function prepareFunctionTool({
4830
+ tool,
4831
+ options
4832
+ }) {
4833
+ const deferLoading = options == null ? void 0 : options.deferLoading;
4834
+ return {
4835
+ type: "function",
4836
+ name: tool.name,
4837
+ description: tool.description,
4838
+ parameters: tool.inputSchema,
4839
+ ...tool.strict != null ? { strict: tool.strict } : {},
4840
+ ...deferLoading != null ? { defer_loading: deferLoading } : {}
4841
+ };
4842
+ }
4810
4843
  function mapShellEnvironment(environment) {
4811
4844
  if (environment.type === "containerReference") {
4812
4845
  const env2 = environment;
@@ -6934,7 +6967,7 @@ var OpenAITranscriptionModel = class {
6934
6967
  };
6935
6968
 
6936
6969
  // src/version.ts
6937
- var VERSION = true ? "3.0.67" : "0.0.0-test";
6970
+ var VERSION = true ? "3.0.69" : "0.0.0-test";
6938
6971
 
6939
6972
  // src/openai-provider.ts
6940
6973
  function createOpenAI(options = {}) {