@yourgpt/llm-sdk 2.5.1-beta.1 → 2.5.1-beta.2

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.
Files changed (58) hide show
  1. package/README.md +1 -19
  2. package/dist/adapters/index.d.mts +4 -4
  3. package/dist/adapters/index.d.ts +4 -4
  4. package/dist/adapters/index.js +14 -139
  5. package/dist/adapters/index.mjs +14 -139
  6. package/dist/{base-Cxq3ni0t.d.ts → base-C58Dsr9p.d.ts} +1 -5
  7. package/dist/{base-BYQKp9TW.d.mts → base-tNgbBaSo.d.mts} +1 -5
  8. package/dist/fallback/index.d.mts +4 -4
  9. package/dist/fallback/index.d.ts +4 -4
  10. package/dist/index.d.mts +8 -60
  11. package/dist/index.d.ts +8 -60
  12. package/dist/index.js +0 -59
  13. package/dist/index.mjs +0 -59
  14. package/dist/providers/anthropic/index.d.mts +3 -3
  15. package/dist/providers/anthropic/index.d.ts +3 -3
  16. package/dist/providers/anthropic/index.js +10 -91
  17. package/dist/providers/anthropic/index.mjs +10 -91
  18. package/dist/providers/azure/index.d.mts +3 -3
  19. package/dist/providers/azure/index.d.ts +3 -3
  20. package/dist/providers/azure/index.js +1 -0
  21. package/dist/providers/azure/index.mjs +1 -0
  22. package/dist/providers/fireworks/index.d.mts +1 -1
  23. package/dist/providers/fireworks/index.d.ts +1 -1
  24. package/dist/providers/fireworks/index.js +1 -0
  25. package/dist/providers/fireworks/index.mjs +1 -0
  26. package/dist/providers/google/index.d.mts +3 -3
  27. package/dist/providers/google/index.d.ts +3 -3
  28. package/dist/providers/google/index.js +3 -51
  29. package/dist/providers/google/index.mjs +3 -51
  30. package/dist/providers/ollama/index.d.mts +4 -4
  31. package/dist/providers/ollama/index.d.ts +4 -4
  32. package/dist/providers/ollama/index.js +1 -0
  33. package/dist/providers/ollama/index.mjs +1 -0
  34. package/dist/providers/openai/index.d.mts +3 -3
  35. package/dist/providers/openai/index.d.ts +3 -3
  36. package/dist/providers/openai/index.js +3 -51
  37. package/dist/providers/openai/index.mjs +3 -51
  38. package/dist/providers/openrouter/index.d.mts +3 -3
  39. package/dist/providers/openrouter/index.d.ts +3 -3
  40. package/dist/providers/openrouter/index.js +3 -51
  41. package/dist/providers/openrouter/index.mjs +3 -51
  42. package/dist/providers/togetherai/index.d.mts +3 -3
  43. package/dist/providers/togetherai/index.d.ts +3 -3
  44. package/dist/providers/togetherai/index.js +3 -51
  45. package/dist/providers/togetherai/index.mjs +3 -51
  46. package/dist/providers/xai/index.d.mts +3 -3
  47. package/dist/providers/xai/index.d.ts +3 -3
  48. package/dist/providers/xai/index.js +3 -51
  49. package/dist/providers/xai/index.mjs +3 -51
  50. package/dist/{types-mwMhCwOq.d.mts → types-B6dhnguR.d.mts} +1 -1
  51. package/dist/{types-TMilS-Dz.d.ts → types-BQ31QIsA.d.ts} +2 -2
  52. package/dist/{types-BvkiJ1dd.d.mts → types-BSSiJW2o.d.mts} +2 -2
  53. package/dist/{types-D774b0dg.d.mts → types-BkQCSiIt.d.mts} +2 -57
  54. package/dist/{types-D774b0dg.d.ts → types-BkQCSiIt.d.ts} +2 -57
  55. package/dist/{types-ChORafYS.d.ts → types-CCxPmkmK.d.ts} +1 -1
  56. package/dist/yourgpt/index.d.mts +1 -1
  57. package/dist/yourgpt/index.d.ts +1 -1
  58. package/package.json +1 -1
@@ -87,63 +87,6 @@ function toAnthropicOutputConfig(rf) {
87
87
  }
88
88
  };
89
89
  }
90
- function toAnthropicMcp(mcpServers) {
91
- if (!mcpServers || mcpServers.length === 0) {
92
- return { mcpServers: [], tools: [], betas: [] };
93
- }
94
- const serverEntries = [];
95
- const toolEntries = [];
96
- for (const mcp of mcpServers) {
97
- const authHeader = mcp.headers?.Authorization ?? mcp.headers?.authorization;
98
- const token = authHeader?.replace(/^Bearer\s+/i, "");
99
- serverEntries.push({
100
- type: "url",
101
- url: mcp.url,
102
- name: mcp.label,
103
- ...token ? { authorization_token: token } : {}
104
- });
105
- if (mcp.allowedTools && mcp.allowedTools.length > 0) {
106
- toolEntries.push({
107
- type: "mcp_toolset",
108
- mcp_server_name: mcp.label,
109
- configs: Object.fromEntries(
110
- mcp.allowedTools.map((toolName) => [toolName, {}])
111
- )
112
- });
113
- }
114
- }
115
- return {
116
- mcpServers: serverEntries,
117
- tools: toolEntries,
118
- betas: ["mcp-client-2025-11-20"]
119
- };
120
- }
121
- function isStringEffort(effort) {
122
- return typeof effort === "string" && (effort === "minimal" || effort === "low" || effort === "medium" || effort === "high");
123
- }
124
- var ANTHROPIC_ADAPTIVE_MODELS = /(claude-opus-4-7|claude-opus-4-6|claude-sonnet-4-6)/i;
125
- function toAnthropicThinking(effort, modelId) {
126
- if (!effort) return {};
127
- if (typeof effort === "object" && "raw" in effort) {
128
- return { thinking: effort.raw };
129
- }
130
- const isAdaptive = !!modelId && ANTHROPIC_ADAPTIVE_MODELS.test(modelId);
131
- if (typeof effort === "object" && "budgetTokens" in effort) {
132
- return {
133
- thinking: { type: "enabled", budget_tokens: effort.budgetTokens }
134
- };
135
- }
136
- if (!isStringEffort(effort)) return {};
137
- if (isAdaptive) {
138
- const mapped = effort === "minimal" ? "low" : effort;
139
- return {
140
- thinking: { type: "adaptive" },
141
- outputConfigEffort: mapped
142
- };
143
- }
144
- const budget = effort === "high" ? 16e3 : effort === "medium" ? 8e3 : effort === "low" ? 4e3 : 2048;
145
- return { thinking: { type: "enabled", budget_tokens: budget } };
146
- }
147
90
  function hasMediaAttachments(message) {
148
91
  const attachments = message.metadata?.attachments;
149
92
  return attachments?.some(
@@ -979,58 +922,36 @@ var AnthropicAdapter = class {
979
922
  if (serverToolConfiguration) {
980
923
  options.server_tool_configuration = serverToolConfiguration;
981
924
  }
982
- const modelForThinking = request.config?.model || this.model;
983
- const thinkingTranslation = toAnthropicThinking(
984
- request.config?.reasoningEffort,
985
- modelForThinking
986
- );
987
925
  const outputConfig = toAnthropicOutputConfig(responseFormat);
988
- if (outputConfig || thinkingTranslation.outputConfigEffort) {
989
- options.output_config = {
990
- ...outputConfig ?? {},
991
- ...thinkingTranslation.outputConfigEffort ? { effort: thinkingTranslation.outputConfigEffort } : {}
992
- };
926
+ if (outputConfig) {
927
+ options.output_config = outputConfig;
993
928
  }
994
- if (thinkingTranslation.thinking) {
995
- options.thinking = thinkingTranslation.thinking;
996
- } else if (this.config.thinking?.type === "enabled") {
929
+ if (this.config.thinking?.type === "enabled") {
997
930
  options.thinking = {
998
931
  type: "enabled",
999
932
  budget_tokens: this.config.thinking.budgetTokens || 1e4
1000
933
  };
1001
934
  }
1002
- const mcp = toAnthropicMcp(request.config?.mcpServers);
1003
- const betas = [];
1004
- if (mcp.mcpServers.length > 0) {
1005
- options.mcp_servers = mcp.mcpServers;
1006
- betas.push(...mcp.betas);
1007
- if (mcp.tools.length > 0) {
1008
- const existingTools = Array.isArray(options.tools) ? options.tools : [];
1009
- options.tools = [...existingTools, ...mcp.tools];
1010
- }
1011
- }
1012
- return { options, messages, betas };
935
+ return { options, messages };
1013
936
  }
1014
937
  /**
1015
938
  * Non-streaming completion (for debugging/comparison with original studio-ai)
1016
939
  */
1017
940
  async complete(request) {
1018
941
  const client = await this.getClient();
1019
- const { options, betas } = this.buildRequestOptions(request);
942
+ const { options } = this.buildRequestOptions(request);
1020
943
  const nonStreamingOptions = {
1021
944
  ...options,
1022
945
  stream: false
1023
946
  };
1024
947
  try {
1025
- const finalOptions = betas.length > 0 ? { ...nonStreamingOptions, betas } : nonStreamingOptions;
1026
- const messagesApi = betas.length > 0 ? client.beta.messages : client.messages;
1027
948
  logProviderPayload(
1028
949
  "anthropic",
1029
950
  "request payload",
1030
- finalOptions,
951
+ nonStreamingOptions,
1031
952
  request.debug
1032
953
  );
1033
- const response = await messagesApi.create(finalOptions);
954
+ const response = await client.messages.create(nonStreamingOptions);
1034
955
  logProviderPayload(
1035
956
  "anthropic",
1036
957
  "response payload",
@@ -1065,19 +986,17 @@ var AnthropicAdapter = class {
1065
986
  }
1066
987
  async *stream(request) {
1067
988
  const client = await this.getClient();
1068
- const { options, betas } = this.buildRequestOptions(request);
989
+ const { options } = this.buildRequestOptions(request);
1069
990
  const messageId = generateMessageId();
1070
991
  yield { type: "message:start", id: messageId };
1071
992
  try {
1072
- const finalOptions = betas.length > 0 ? { ...options, betas } : options;
1073
- const streamApi = betas.length > 0 ? client.beta.messages : client.messages;
1074
993
  logProviderPayload(
1075
994
  "anthropic",
1076
995
  "request payload",
1077
- finalOptions,
996
+ options,
1078
997
  request.debug
1079
998
  );
1080
- const stream = await streamApi.stream(finalOptions);
999
+ const stream = await client.messages.stream(options);
1081
1000
  let currentToolUse = null;
1082
1001
  let isInThinkingBlock = false;
1083
1002
  const collectedCitations = [];
@@ -1,7 +1,7 @@
1
- import { b as AzureProviderConfig, A as AIProvider } from '../../types-BvkiJ1dd.mjs';
2
- import '../../types-D774b0dg.mjs';
1
+ import { b as AzureProviderConfig, A as AIProvider } from '../../types-BSSiJW2o.mjs';
2
+ import '../../types-BkQCSiIt.mjs';
3
3
  import 'zod';
4
- import '../../base-BYQKp9TW.mjs';
4
+ import '../../base-tNgbBaSo.mjs';
5
5
 
6
6
  /**
7
7
  * Azure OpenAI Provider
@@ -1,7 +1,7 @@
1
- import { b as AzureProviderConfig, A as AIProvider } from '../../types-TMilS-Dz.js';
2
- import '../../types-D774b0dg.js';
1
+ import { b as AzureProviderConfig, A as AIProvider } from '../../types-BQ31QIsA.js';
2
+ import '../../types-BkQCSiIt.js';
3
3
  import 'zod';
4
- import '../../base-Cxq3ni0t.js';
4
+ import '../../base-C58Dsr9p.js';
5
5
 
6
6
  /**
7
7
  * Azure OpenAI Provider
@@ -112,6 +112,7 @@ function normalizeObjectJsonSchema(schema) {
112
112
  function toOpenAIResponseFormat(rf) {
113
113
  if (!rf) return void 0;
114
114
  if (rf.type === "json_object") return { type: "json_object" };
115
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
115
116
  return {
116
117
  type: "json_schema",
117
118
  json_schema: {
@@ -110,6 +110,7 @@ function normalizeObjectJsonSchema(schema) {
110
110
  function toOpenAIResponseFormat(rf) {
111
111
  if (!rf) return void 0;
112
112
  if (rf.type === "json_object") return { type: "json_object" };
113
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
113
114
  return {
114
115
  type: "json_schema",
115
116
  json_schema: {
@@ -1,4 +1,4 @@
1
- import { L as LanguageModel } from '../../types-D774b0dg.mjs';
1
+ import { L as LanguageModel } from '../../types-BkQCSiIt.mjs';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { L as LanguageModel } from '../../types-D774b0dg.js';
1
+ import { L as LanguageModel } from '../../types-BkQCSiIt.js';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -38,6 +38,7 @@ function normalizeObjectJsonSchema(schema) {
38
38
  function toOpenAIResponseFormat(rf) {
39
39
  if (!rf) return void 0;
40
40
  if (rf.type === "json_object") return { type: "json_object" };
41
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
41
42
  return {
42
43
  type: "json_schema",
43
44
  json_schema: {
@@ -36,6 +36,7 @@ function normalizeObjectJsonSchema(schema) {
36
36
  function toOpenAIResponseFormat(rf) {
37
37
  if (!rf) return void 0;
38
38
  if (rf.type === "json_object") return { type: "json_object" };
39
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
39
40
  return {
40
41
  type: "json_schema",
41
42
  json_schema: {
@@ -1,7 +1,7 @@
1
- import { L as LanguageModel } from '../../types-D774b0dg.mjs';
2
- import { G as GoogleProviderConfig, A as AIProvider } from '../../types-BvkiJ1dd.mjs';
1
+ import { L as LanguageModel } from '../../types-BkQCSiIt.mjs';
2
+ import { G as GoogleProviderConfig, A as AIProvider } from '../../types-BSSiJW2o.mjs';
3
3
  import 'zod';
4
- import '../../base-BYQKp9TW.mjs';
4
+ import '../../base-tNgbBaSo.mjs';
5
5
 
6
6
  /**
7
7
  * Google Provider - OpenAI-Compatible
@@ -1,7 +1,7 @@
1
- import { L as LanguageModel } from '../../types-D774b0dg.js';
2
- import { G as GoogleProviderConfig, A as AIProvider } from '../../types-TMilS-Dz.js';
1
+ import { L as LanguageModel } from '../../types-BkQCSiIt.js';
2
+ import { G as GoogleProviderConfig, A as AIProvider } from '../../types-BQ31QIsA.js';
3
3
  import 'zod';
4
- import '../../base-Cxq3ni0t.js';
4
+ import '../../base-C58Dsr9p.js';
5
5
 
6
6
  /**
7
7
  * Google Provider - OpenAI-Compatible
@@ -114,6 +114,7 @@ function buildOpenAITokenParams(modelId, maxTokens, temperature) {
114
114
  function toOpenAIResponseFormat(rf) {
115
115
  if (!rf) return void 0;
116
116
  if (rf.type === "json_object") return { type: "json_object" };
117
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
117
118
  return {
118
119
  type: "json_schema",
119
120
  json_schema: {
@@ -132,33 +133,6 @@ function toOpenAIResponsesTextFormat(rf) {
132
133
  strict: rf.json_schema.strict ?? true
133
134
  };
134
135
  }
135
- function toOpenAIResponsesMcpTools(mcpServers) {
136
- if (!mcpServers || mcpServers.length === 0) return [];
137
- return mcpServers.map((mcp) => ({
138
- type: "mcp",
139
- server_label: mcp.label,
140
- server_url: mcp.url,
141
- ...mcp.headers ? { headers: mcp.headers } : {},
142
- ...mcp.allowedTools ? { allowed_tools: mcp.allowedTools } : {},
143
- require_approval: mcp.requireApproval ?? "never"
144
- }));
145
- }
146
- function isStringEffort(effort) {
147
- return typeof effort === "string" && (effort === "minimal" || effort === "low" || effort === "medium" || effort === "high");
148
- }
149
- function toOpenAIReasoning(effort) {
150
- if (!effort) return void 0;
151
- if (typeof effort === "object" && "raw" in effort) return effort.raw;
152
- if (typeof effort === "object" && "budgetTokens" in effort) {
153
- const budget = effort.budgetTokens;
154
- const mapped = budget >= 16e3 ? "high" : budget >= 8e3 ? "medium" : "low";
155
- return { effort: mapped, summary: "auto" };
156
- }
157
- if (isStringEffort(effort)) {
158
- return { effort, summary: "auto" };
159
- }
160
- return void 0;
161
- }
162
136
  function formatTools(actions) {
163
137
  return actions.map((action) => ({
164
138
  type: "function",
@@ -579,14 +553,6 @@ var OpenAIAdapter = class _OpenAIAdapter {
579
553
  return this.client;
580
554
  }
581
555
  shouldUseResponsesApi(request) {
582
- if (request.config?.mcpServers && request.config.mcpServers.length > 0 || request.config?.reasoningEffort !== void 0) {
583
- if (this.provider !== "openai" && this.provider !== "azure") {
584
- throw new Error(
585
- `[llm-sdk] Provider "${this.provider}" does not support MCP servers or per-request reasoning effort. Use OpenAI or Anthropic for these features.`
586
- );
587
- }
588
- return true;
589
- }
590
556
  return request.providerToolOptions?.openai?.nativeToolSearch?.enabled === true && request.providerToolOptions.openai.nativeToolSearch.useResponsesApi !== false && Array.isArray(request.toolDefinitions) && request.toolDefinitions.length > 0;
591
557
  }
592
558
  buildResponsesInput(request) {
@@ -647,7 +613,7 @@ var OpenAIAdapter = class _OpenAIAdapter {
647
613
  strict: true,
648
614
  defer_loading: tool.deferLoading === true
649
615
  }));
650
- return nativeTools.length > 0 ? [{ type: "tool_search" }, ...nativeTools] : [];
616
+ return [{ type: "tool_search" }, ...nativeTools];
651
617
  }
652
618
  parseResponsesResult(response) {
653
619
  const content = typeof response?.output_text === "string" ? response.output_text : "";
@@ -679,30 +645,16 @@ var OpenAIAdapter = class _OpenAIAdapter {
679
645
  const responsesTextFormat = toOpenAIResponsesTextFormat(
680
646
  request.config?.responseFormat
681
647
  );
682
- const mcpTools = toOpenAIResponsesMcpTools(request.config?.mcpServers);
683
- const modelId = request.config?.model || this.model;
684
- const reasoning = isOpenAIReasoningModel(modelId) ? toOpenAIReasoning(request.config?.reasoningEffort) : void 0;
685
- if (request.config?.reasoningEffort && !isOpenAIReasoningModel(modelId)) {
686
- console.warn(
687
- `[llm-sdk] openai/${modelId} is not a reasoning model; \`reasoningEffort\` is ignored. Use o1/o3/o4/gpt-5.x for reasoning.`
688
- );
689
- }
690
- const functionTools = this.buildResponsesTools(
691
- request.toolDefinitions ?? []
692
- );
693
- const tools = [...functionTools, ...mcpTools];
694
648
  const payload = {
695
649
  model: request.config?.model || this.model,
696
650
  instructions: request.systemPrompt,
697
651
  input: this.buildResponsesInput(request),
698
- tools: tools.length > 0 ? tools : void 0,
652
+ tools: this.buildResponsesTools(request.toolDefinitions ?? []),
699
653
  tool_choice: openaiToolOptions?.toolChoice === "required" ? "required" : openaiToolOptions?.toolChoice === "auto" ? "auto" : void 0,
700
654
  parallel_tool_calls: openaiToolOptions?.parallelToolCalls,
701
655
  temperature: request.config?.temperature ?? this.config.temperature,
702
656
  max_output_tokens: request.config?.maxTokens ?? this.config.maxTokens,
703
657
  ...responsesTextFormat ? { text: { format: responsesTextFormat } } : {},
704
- ...reasoning ? { reasoning } : {},
705
- store: false,
706
658
  stream: false
707
659
  };
708
660
  logProviderPayload("openai", "request payload", payload, request.debug);
@@ -112,6 +112,7 @@ function buildOpenAITokenParams(modelId, maxTokens, temperature) {
112
112
  function toOpenAIResponseFormat(rf) {
113
113
  if (!rf) return void 0;
114
114
  if (rf.type === "json_object") return { type: "json_object" };
115
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
115
116
  return {
116
117
  type: "json_schema",
117
118
  json_schema: {
@@ -130,33 +131,6 @@ function toOpenAIResponsesTextFormat(rf) {
130
131
  strict: rf.json_schema.strict ?? true
131
132
  };
132
133
  }
133
- function toOpenAIResponsesMcpTools(mcpServers) {
134
- if (!mcpServers || mcpServers.length === 0) return [];
135
- return mcpServers.map((mcp) => ({
136
- type: "mcp",
137
- server_label: mcp.label,
138
- server_url: mcp.url,
139
- ...mcp.headers ? { headers: mcp.headers } : {},
140
- ...mcp.allowedTools ? { allowed_tools: mcp.allowedTools } : {},
141
- require_approval: mcp.requireApproval ?? "never"
142
- }));
143
- }
144
- function isStringEffort(effort) {
145
- return typeof effort === "string" && (effort === "minimal" || effort === "low" || effort === "medium" || effort === "high");
146
- }
147
- function toOpenAIReasoning(effort) {
148
- if (!effort) return void 0;
149
- if (typeof effort === "object" && "raw" in effort) return effort.raw;
150
- if (typeof effort === "object" && "budgetTokens" in effort) {
151
- const budget = effort.budgetTokens;
152
- const mapped = budget >= 16e3 ? "high" : budget >= 8e3 ? "medium" : "low";
153
- return { effort: mapped, summary: "auto" };
154
- }
155
- if (isStringEffort(effort)) {
156
- return { effort, summary: "auto" };
157
- }
158
- return void 0;
159
- }
160
134
  function formatTools(actions) {
161
135
  return actions.map((action) => ({
162
136
  type: "function",
@@ -577,14 +551,6 @@ var OpenAIAdapter = class _OpenAIAdapter {
577
551
  return this.client;
578
552
  }
579
553
  shouldUseResponsesApi(request) {
580
- if (request.config?.mcpServers && request.config.mcpServers.length > 0 || request.config?.reasoningEffort !== void 0) {
581
- if (this.provider !== "openai" && this.provider !== "azure") {
582
- throw new Error(
583
- `[llm-sdk] Provider "${this.provider}" does not support MCP servers or per-request reasoning effort. Use OpenAI or Anthropic for these features.`
584
- );
585
- }
586
- return true;
587
- }
588
554
  return request.providerToolOptions?.openai?.nativeToolSearch?.enabled === true && request.providerToolOptions.openai.nativeToolSearch.useResponsesApi !== false && Array.isArray(request.toolDefinitions) && request.toolDefinitions.length > 0;
589
555
  }
590
556
  buildResponsesInput(request) {
@@ -645,7 +611,7 @@ var OpenAIAdapter = class _OpenAIAdapter {
645
611
  strict: true,
646
612
  defer_loading: tool.deferLoading === true
647
613
  }));
648
- return nativeTools.length > 0 ? [{ type: "tool_search" }, ...nativeTools] : [];
614
+ return [{ type: "tool_search" }, ...nativeTools];
649
615
  }
650
616
  parseResponsesResult(response) {
651
617
  const content = typeof response?.output_text === "string" ? response.output_text : "";
@@ -677,30 +643,16 @@ var OpenAIAdapter = class _OpenAIAdapter {
677
643
  const responsesTextFormat = toOpenAIResponsesTextFormat(
678
644
  request.config?.responseFormat
679
645
  );
680
- const mcpTools = toOpenAIResponsesMcpTools(request.config?.mcpServers);
681
- const modelId = request.config?.model || this.model;
682
- const reasoning = isOpenAIReasoningModel(modelId) ? toOpenAIReasoning(request.config?.reasoningEffort) : void 0;
683
- if (request.config?.reasoningEffort && !isOpenAIReasoningModel(modelId)) {
684
- console.warn(
685
- `[llm-sdk] openai/${modelId} is not a reasoning model; \`reasoningEffort\` is ignored. Use o1/o3/o4/gpt-5.x for reasoning.`
686
- );
687
- }
688
- const functionTools = this.buildResponsesTools(
689
- request.toolDefinitions ?? []
690
- );
691
- const tools = [...functionTools, ...mcpTools];
692
646
  const payload = {
693
647
  model: request.config?.model || this.model,
694
648
  instructions: request.systemPrompt,
695
649
  input: this.buildResponsesInput(request),
696
- tools: tools.length > 0 ? tools : void 0,
650
+ tools: this.buildResponsesTools(request.toolDefinitions ?? []),
697
651
  tool_choice: openaiToolOptions?.toolChoice === "required" ? "required" : openaiToolOptions?.toolChoice === "auto" ? "auto" : void 0,
698
652
  parallel_tool_calls: openaiToolOptions?.parallelToolCalls,
699
653
  temperature: request.config?.temperature ?? this.config.temperature,
700
654
  max_output_tokens: request.config?.maxTokens ?? this.config.maxTokens,
701
655
  ...responsesTextFormat ? { text: { format: responsesTextFormat } } : {},
702
- ...reasoning ? { reasoning } : {},
703
- store: false,
704
656
  stream: false
705
657
  };
706
658
  logProviderPayload("openai", "request payload", payload, request.debug);
@@ -1,8 +1,8 @@
1
- import { c as OllamaProviderConfig, A as AIProvider } from '../../types-BvkiJ1dd.mjs';
2
- export { d as OllamaModelOptions } from '../../types-BvkiJ1dd.mjs';
3
- import '../../types-D774b0dg.mjs';
1
+ import { c as OllamaProviderConfig, A as AIProvider } from '../../types-BSSiJW2o.mjs';
2
+ export { d as OllamaModelOptions } from '../../types-BSSiJW2o.mjs';
3
+ import '../../types-BkQCSiIt.mjs';
4
4
  import 'zod';
5
- import '../../base-BYQKp9TW.mjs';
5
+ import '../../base-tNgbBaSo.mjs';
6
6
 
7
7
  /**
8
8
  * Ollama Provider
@@ -1,8 +1,8 @@
1
- import { c as OllamaProviderConfig, A as AIProvider } from '../../types-TMilS-Dz.js';
2
- export { d as OllamaModelOptions } from '../../types-TMilS-Dz.js';
3
- import '../../types-D774b0dg.js';
1
+ import { c as OllamaProviderConfig, A as AIProvider } from '../../types-BQ31QIsA.js';
2
+ export { d as OllamaModelOptions } from '../../types-BQ31QIsA.js';
3
+ import '../../types-BkQCSiIt.js';
4
4
  import 'zod';
5
- import '../../base-Cxq3ni0t.js';
5
+ import '../../base-C58Dsr9p.js';
6
6
 
7
7
  /**
8
8
  * Ollama Provider
@@ -81,6 +81,7 @@ function parameterToJsonSchema(param) {
81
81
  function toOllamaFormat(rf) {
82
82
  if (!rf) return void 0;
83
83
  if (rf.type === "json_object") return "json";
84
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
84
85
  return rf.json_schema.schema;
85
86
  }
86
87
  function formatTools(actions) {
@@ -79,6 +79,7 @@ function parameterToJsonSchema(param) {
79
79
  function toOllamaFormat(rf) {
80
80
  if (!rf) return void 0;
81
81
  if (rf.type === "json_object") return "json";
82
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
82
83
  return rf.json_schema.schema;
83
84
  }
84
85
  function formatTools(actions) {
@@ -1,7 +1,7 @@
1
- import { L as LanguageModel } from '../../types-D774b0dg.mjs';
2
- import { O as OpenAIProviderConfig, A as AIProvider } from '../../types-BvkiJ1dd.mjs';
1
+ import { L as LanguageModel } from '../../types-BkQCSiIt.mjs';
2
+ import { O as OpenAIProviderConfig, A as AIProvider } from '../../types-BSSiJW2o.mjs';
3
3
  import 'zod';
4
- import '../../base-BYQKp9TW.mjs';
4
+ import '../../base-tNgbBaSo.mjs';
5
5
 
6
6
  /**
7
7
  * OpenAI Provider - Modern Pattern
@@ -1,7 +1,7 @@
1
- import { L as LanguageModel } from '../../types-D774b0dg.js';
2
- import { O as OpenAIProviderConfig, A as AIProvider } from '../../types-TMilS-Dz.js';
1
+ import { L as LanguageModel } from '../../types-BkQCSiIt.js';
2
+ import { O as OpenAIProviderConfig, A as AIProvider } from '../../types-BQ31QIsA.js';
3
3
  import 'zod';
4
- import '../../base-Cxq3ni0t.js';
4
+ import '../../base-C58Dsr9p.js';
5
5
 
6
6
  /**
7
7
  * OpenAI Provider - Modern Pattern
@@ -114,6 +114,7 @@ function buildOpenAITokenParams(modelId, maxTokens, temperature) {
114
114
  function toOpenAIResponseFormat(rf) {
115
115
  if (!rf) return void 0;
116
116
  if (rf.type === "json_object") return { type: "json_object" };
117
+ if (rf.type !== "json_schema" || !rf.json_schema) return void 0;
117
118
  return {
118
119
  type: "json_schema",
119
120
  json_schema: {
@@ -132,33 +133,6 @@ function toOpenAIResponsesTextFormat(rf) {
132
133
  strict: rf.json_schema.strict ?? true
133
134
  };
134
135
  }
135
- function toOpenAIResponsesMcpTools(mcpServers) {
136
- if (!mcpServers || mcpServers.length === 0) return [];
137
- return mcpServers.map((mcp) => ({
138
- type: "mcp",
139
- server_label: mcp.label,
140
- server_url: mcp.url,
141
- ...mcp.headers ? { headers: mcp.headers } : {},
142
- ...mcp.allowedTools ? { allowed_tools: mcp.allowedTools } : {},
143
- require_approval: mcp.requireApproval ?? "never"
144
- }));
145
- }
146
- function isStringEffort(effort) {
147
- return typeof effort === "string" && (effort === "minimal" || effort === "low" || effort === "medium" || effort === "high");
148
- }
149
- function toOpenAIReasoning(effort) {
150
- if (!effort) return void 0;
151
- if (typeof effort === "object" && "raw" in effort) return effort.raw;
152
- if (typeof effort === "object" && "budgetTokens" in effort) {
153
- const budget = effort.budgetTokens;
154
- const mapped = budget >= 16e3 ? "high" : budget >= 8e3 ? "medium" : "low";
155
- return { effort: mapped, summary: "auto" };
156
- }
157
- if (isStringEffort(effort)) {
158
- return { effort, summary: "auto" };
159
- }
160
- return void 0;
161
- }
162
136
  function formatTools(actions) {
163
137
  return actions.map((action) => ({
164
138
  type: "function",
@@ -566,14 +540,6 @@ var OpenAIAdapter = class _OpenAIAdapter {
566
540
  return this.client;
567
541
  }
568
542
  shouldUseResponsesApi(request) {
569
- if (request.config?.mcpServers && request.config.mcpServers.length > 0 || request.config?.reasoningEffort !== void 0) {
570
- if (this.provider !== "openai" && this.provider !== "azure") {
571
- throw new Error(
572
- `[llm-sdk] Provider "${this.provider}" does not support MCP servers or per-request reasoning effort. Use OpenAI or Anthropic for these features.`
573
- );
574
- }
575
- return true;
576
- }
577
543
  return request.providerToolOptions?.openai?.nativeToolSearch?.enabled === true && request.providerToolOptions.openai.nativeToolSearch.useResponsesApi !== false && Array.isArray(request.toolDefinitions) && request.toolDefinitions.length > 0;
578
544
  }
579
545
  buildResponsesInput(request) {
@@ -634,7 +600,7 @@ var OpenAIAdapter = class _OpenAIAdapter {
634
600
  strict: true,
635
601
  defer_loading: tool.deferLoading === true
636
602
  }));
637
- return nativeTools.length > 0 ? [{ type: "tool_search" }, ...nativeTools] : [];
603
+ return [{ type: "tool_search" }, ...nativeTools];
638
604
  }
639
605
  parseResponsesResult(response) {
640
606
  const content = typeof response?.output_text === "string" ? response.output_text : "";
@@ -666,30 +632,16 @@ var OpenAIAdapter = class _OpenAIAdapter {
666
632
  const responsesTextFormat = toOpenAIResponsesTextFormat(
667
633
  request.config?.responseFormat
668
634
  );
669
- const mcpTools = toOpenAIResponsesMcpTools(request.config?.mcpServers);
670
- const modelId = request.config?.model || this.model;
671
- const reasoning = isOpenAIReasoningModel(modelId) ? toOpenAIReasoning(request.config?.reasoningEffort) : void 0;
672
- if (request.config?.reasoningEffort && !isOpenAIReasoningModel(modelId)) {
673
- console.warn(
674
- `[llm-sdk] openai/${modelId} is not a reasoning model; \`reasoningEffort\` is ignored. Use o1/o3/o4/gpt-5.x for reasoning.`
675
- );
676
- }
677
- const functionTools = this.buildResponsesTools(
678
- request.toolDefinitions ?? []
679
- );
680
- const tools = [...functionTools, ...mcpTools];
681
635
  const payload = {
682
636
  model: request.config?.model || this.model,
683
637
  instructions: request.systemPrompt,
684
638
  input: this.buildResponsesInput(request),
685
- tools: tools.length > 0 ? tools : void 0,
639
+ tools: this.buildResponsesTools(request.toolDefinitions ?? []),
686
640
  tool_choice: openaiToolOptions?.toolChoice === "required" ? "required" : openaiToolOptions?.toolChoice === "auto" ? "auto" : void 0,
687
641
  parallel_tool_calls: openaiToolOptions?.parallelToolCalls,
688
642
  temperature: request.config?.temperature ?? this.config.temperature,
689
643
  max_output_tokens: request.config?.maxTokens ?? this.config.maxTokens,
690
644
  ...responsesTextFormat ? { text: { format: responsesTextFormat } } : {},
691
- ...reasoning ? { reasoning } : {},
692
- store: false,
693
645
  stream: false
694
646
  };
695
647
  logProviderPayload("openai", "request payload", payload, request.debug);