@ai-sdk/openai 3.0.68 → 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.
@@ -4748,20 +4748,37 @@ async function prepareResponsesTools({
4748
4748
  return { tools: void 0, toolChoice: void 0, toolWarnings };
4749
4749
  }
4750
4750
  const openaiTools = [];
4751
+ const namespaceTools = /* @__PURE__ */ new Map();
4751
4752
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4752
4753
  for (const tool of tools) {
4753
4754
  switch (tool.type) {
4754
4755
  case "function": {
4755
4756
  const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4756
- const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4757
- openaiTools.push({
4758
- type: "function",
4759
- name: tool.name,
4760
- description: tool.description,
4761
- parameters: tool.inputSchema,
4762
- ...tool.strict != null ? { strict: tool.strict } : {},
4763
- ...deferLoading != null ? { defer_loading: deferLoading } : {}
4757
+ const openaiFunctionTool = prepareFunctionTool({
4758
+ tool,
4759
+ options: openaiOptions
4764
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
+ }
4765
4782
  break;
4766
4783
  }
4767
4784
  case "provider": {
@@ -4974,6 +4991,20 @@ async function prepareResponsesTools({
4974
4991
  }
4975
4992
  }
4976
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
+ }
4977
5008
  function mapShellEnvironment(environment) {
4978
5009
  if (environment.type === "containerReference") {
4979
5010
  const env2 = environment;