@ai-sdk/openai 3.0.0-beta.109 → 3.0.0-beta.110

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.
@@ -237,6 +237,9 @@ function convertToOpenAIChatMessages({
237
237
  }
238
238
  case "tool": {
239
239
  for (const toolResponse of content) {
240
+ if (toolResponse.type === "tool-approval-response") {
241
+ continue;
242
+ }
240
243
  const output = toolResponse.output;
241
244
  let contentValue;
242
245
  switch (output.type) {
@@ -2710,6 +2713,9 @@ async function convertToOpenAIResponsesInput({
2710
2713
  }
2711
2714
  case "tool": {
2712
2715
  for (const part of content) {
2716
+ if (part.type === "tool-approval-response") {
2717
+ continue;
2718
+ }
2713
2719
  const output = part.output;
2714
2720
  const resolvedToolName = toolNameMapping.toProviderToolName(
2715
2721
  part.toolName
@@ -3917,16 +3923,14 @@ var mcpArgsSchema = lazySchema19(
3917
3923
  authorization: z21.string().optional(),
3918
3924
  connectorId: z21.string().optional(),
3919
3925
  headers: z21.record(z21.string(), z21.string()).optional(),
3920
- // TODO: Integrate this MCP tool approval with our SDK's existing tool approval architecture
3921
- // requireApproval: z
3922
- // .union([
3923
- // z.enum(['always', 'never']),
3924
- // z.object({
3925
- // readOnly: z.boolean().optional(),
3926
- // toolNames: z.array(z.string()).optional(),
3927
- // }),
3928
- // ])
3929
- // .optional(),
3926
+ requireApproval: z21.union([
3927
+ z21.enum(["always", "never"]),
3928
+ z21.object({
3929
+ never: z21.object({
3930
+ toolNames: z21.array(z21.string()).optional()
3931
+ }).optional()
3932
+ })
3933
+ ]).optional(),
3930
3934
  serverDescription: z21.string().optional(),
3931
3935
  serverUrl: z21.string().optional()
3932
3936
  }).refine(
@@ -3938,36 +3942,14 @@ var mcpArgsSchema = lazySchema19(
3938
3942
  var mcpInputSchema = lazySchema19(() => zodSchema19(z21.object({})));
3939
3943
  var mcpOutputSchema = lazySchema19(
3940
3944
  () => zodSchema19(
3941
- z21.discriminatedUnion("type", [
3942
- z21.object({
3943
- type: z21.literal("call"),
3944
- serverLabel: z21.string(),
3945
- name: z21.string(),
3946
- arguments: z21.string(),
3947
- output: z21.string().nullable().optional(),
3948
- error: z21.union([z21.string(), jsonValueSchema]).optional()
3949
- }),
3950
- z21.object({
3951
- type: z21.literal("listTools"),
3952
- serverLabel: z21.string(),
3953
- tools: z21.array(
3954
- z21.object({
3955
- name: z21.string(),
3956
- description: z21.string().optional(),
3957
- inputSchema: jsonValueSchema,
3958
- annotations: z21.record(z21.string(), jsonValueSchema).optional()
3959
- })
3960
- ),
3961
- error: z21.union([z21.string(), jsonValueSchema]).optional()
3962
- }),
3963
- z21.object({
3964
- type: z21.literal("approvalRequest"),
3965
- serverLabel: z21.string(),
3966
- name: z21.string(),
3967
- arguments: z21.string(),
3968
- approvalRequestId: z21.string()
3969
- })
3970
- ])
3945
+ z21.object({
3946
+ type: z21.literal("call"),
3947
+ serverLabel: z21.string(),
3948
+ name: z21.string(),
3949
+ arguments: z21.string(),
3950
+ output: z21.string().nullable().optional(),
3951
+ error: z21.union([z21.string(), jsonValueSchema]).optional()
3952
+ })
3971
3953
  )
3972
3954
  );
3973
3955
  var mcpToolFactory = createProviderToolFactoryWithOutputSchema7({
@@ -4746,54 +4728,9 @@ var OpenAIResponsesLanguageModel = class {
4746
4728
  break;
4747
4729
  }
4748
4730
  case "mcp_list_tools": {
4749
- content.push({
4750
- type: "tool-call",
4751
- toolCallId: part.id,
4752
- toolName: toolNameMapping.toCustomToolName("mcp"),
4753
- input: JSON.stringify({}),
4754
- providerExecuted: true
4755
- });
4756
- content.push({
4757
- type: "tool-result",
4758
- toolCallId: part.id,
4759
- toolName: toolNameMapping.toCustomToolName("mcp"),
4760
- result: {
4761
- type: "listTools",
4762
- serverLabel: part.server_label,
4763
- tools: part.tools.map((t) => {
4764
- var _a2, _b2;
4765
- return {
4766
- name: t.name,
4767
- description: (_a2 = t.description) != null ? _a2 : void 0,
4768
- inputSchema: t.input_schema,
4769
- annotations: (_b2 = t.annotations) != null ? _b2 : void 0
4770
- };
4771
- }),
4772
- ...part.error != null ? { error: part.error } : {}
4773
- }
4774
- });
4775
4731
  break;
4776
4732
  }
4777
4733
  case "mcp_approval_request": {
4778
- content.push({
4779
- type: "tool-call",
4780
- toolCallId: part.id,
4781
- toolName: toolNameMapping.toCustomToolName("mcp"),
4782
- input: JSON.stringify({}),
4783
- providerExecuted: true
4784
- });
4785
- content.push({
4786
- type: "tool-result",
4787
- toolCallId: part.id,
4788
- toolName: toolNameMapping.toCustomToolName("mcp"),
4789
- result: {
4790
- type: "approvalRequest",
4791
- serverLabel: part.server_label,
4792
- name: part.name,
4793
- arguments: part.arguments,
4794
- approvalRequestId: part.approval_request_id
4795
- }
4796
- });
4797
4734
  break;
4798
4735
  }
4799
4736
  case "computer_call": {
@@ -5231,25 +5168,6 @@ var OpenAIResponsesLanguageModel = class {
5231
5168
  });
5232
5169
  } else if (value.item.type === "mcp_list_tools") {
5233
5170
  ongoingToolCalls[value.output_index] = void 0;
5234
- controller.enqueue({
5235
- type: "tool-result",
5236
- toolCallId: value.item.id,
5237
- toolName: toolNameMapping.toCustomToolName("mcp"),
5238
- result: {
5239
- type: "listTools",
5240
- serverLabel: value.item.server_label,
5241
- tools: value.item.tools.map((t) => {
5242
- var _a2, _b2;
5243
- return {
5244
- name: t.name,
5245
- description: (_a2 = t.description) != null ? _a2 : void 0,
5246
- inputSchema: t.input_schema,
5247
- annotations: (_b2 = t.annotations) != null ? _b2 : void 0
5248
- };
5249
- }),
5250
- ...value.item.error != null ? { error: value.item.error } : {}
5251
- }
5252
- });
5253
5171
  } else if (value.item.type === "apply_patch_call") {
5254
5172
  ongoingToolCalls[value.output_index] = void 0;
5255
5173
  if (value.item.status === "completed") {
@@ -5270,18 +5188,6 @@ var OpenAIResponsesLanguageModel = class {
5270
5188
  }
5271
5189
  } else if (value.item.type === "mcp_approval_request") {
5272
5190
  ongoingToolCalls[value.output_index] = void 0;
5273
- controller.enqueue({
5274
- type: "tool-result",
5275
- toolCallId: value.item.id,
5276
- toolName: toolNameMapping.toCustomToolName("mcp"),
5277
- result: {
5278
- type: "approvalRequest",
5279
- serverLabel: value.item.server_label,
5280
- name: value.item.name,
5281
- arguments: value.item.arguments,
5282
- approvalRequestId: value.item.approval_request_id
5283
- }
5284
- });
5285
5191
  } else if (value.item.type === "local_shell_call") {
5286
5192
  ongoingToolCalls[value.output_index] = void 0;
5287
5193
  controller.enqueue({