@librechat/agents 3.6.15 → 3.6.16

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 (117) hide show
  1. package/README.md +41 -0
  2. package/dist/cjs/agents/AgentContext.cjs +1 -1
  3. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  4. package/dist/cjs/graphs/Graph.cjs +9 -7
  5. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  6. package/dist/cjs/llm/init.cjs +1 -0
  7. package/dist/cjs/llm/init.cjs.map +1 -1
  8. package/dist/cjs/llm/invoke.cjs +9 -2
  9. package/dist/cjs/llm/invoke.cjs.map +1 -1
  10. package/dist/cjs/llm/openai/index.cjs +1 -1
  11. package/dist/cjs/llm/prepareProviderRequest.cjs +6 -3
  12. package/dist/cjs/llm/prepareProviderRequest.cjs.map +1 -1
  13. package/dist/cjs/llm/providerRegistry.cjs +69 -0
  14. package/dist/cjs/llm/providerRegistry.cjs.map +1 -0
  15. package/dist/cjs/llm/providers.cjs +38 -25
  16. package/dist/cjs/llm/providers.cjs.map +1 -1
  17. package/dist/cjs/llm/request.cjs +6 -4
  18. package/dist/cjs/llm/request.cjs.map +1 -1
  19. package/dist/cjs/llm/truncation.cjs +2 -1
  20. package/dist/cjs/llm/truncation.cjs.map +1 -1
  21. package/dist/cjs/main.cjs +18 -15
  22. package/dist/cjs/messages/format.cjs.map +1 -1
  23. package/dist/cjs/messages/prune.cjs +8 -4
  24. package/dist/cjs/messages/prune.cjs.map +1 -1
  25. package/dist/cjs/provider-registration.cjs +4 -0
  26. package/dist/cjs/run.cjs +2 -2
  27. package/dist/cjs/stream.cjs +1 -1
  28. package/dist/cjs/stream.cjs.map +1 -1
  29. package/dist/cjs/summarization/node.cjs +2 -2
  30. package/dist/cjs/summarization/node.cjs.map +1 -1
  31. package/dist/cjs/utils/llm.cjs +6 -4
  32. package/dist/cjs/utils/llm.cjs.map +1 -1
  33. package/dist/esm/agents/AgentContext.mjs +1 -1
  34. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  35. package/dist/esm/graphs/Graph.mjs +10 -8
  36. package/dist/esm/graphs/Graph.mjs.map +1 -1
  37. package/dist/esm/llm/init.mjs +1 -0
  38. package/dist/esm/llm/init.mjs.map +1 -1
  39. package/dist/esm/llm/invoke.mjs +9 -2
  40. package/dist/esm/llm/invoke.mjs.map +1 -1
  41. package/dist/esm/llm/openai/index.mjs +1 -1
  42. package/dist/esm/llm/prepareProviderRequest.mjs +7 -4
  43. package/dist/esm/llm/prepareProviderRequest.mjs.map +1 -1
  44. package/dist/esm/llm/providerRegistry.mjs +64 -0
  45. package/dist/esm/llm/providerRegistry.mjs.map +1 -0
  46. package/dist/esm/llm/providers.mjs +36 -22
  47. package/dist/esm/llm/providers.mjs.map +1 -1
  48. package/dist/esm/llm/request.mjs +6 -4
  49. package/dist/esm/llm/request.mjs.map +1 -1
  50. package/dist/esm/llm/truncation.mjs +2 -1
  51. package/dist/esm/llm/truncation.mjs.map +1 -1
  52. package/dist/esm/main.mjs +12 -10
  53. package/dist/esm/messages/format.mjs.map +1 -1
  54. package/dist/esm/messages/prune.mjs +8 -4
  55. package/dist/esm/messages/prune.mjs.map +1 -1
  56. package/dist/esm/provider-registration.mjs +3 -0
  57. package/dist/esm/run.mjs +2 -2
  58. package/dist/esm/stream.mjs +1 -1
  59. package/dist/esm/stream.mjs.map +1 -1
  60. package/dist/esm/summarization/node.mjs +2 -2
  61. package/dist/esm/summarization/node.mjs.map +1 -1
  62. package/dist/esm/utils/llm.mjs +6 -4
  63. package/dist/esm/utils/llm.mjs.map +1 -1
  64. package/dist/types/agents/AgentContext.d.ts +5 -5
  65. package/dist/types/index.d.ts +2 -0
  66. package/dist/types/llm/contextOverflowRecovery.d.ts +2 -2
  67. package/dist/types/llm/init.d.ts +21 -14
  68. package/dist/types/llm/invoke.d.ts +5 -6
  69. package/dist/types/llm/prepareProviderRequest.d.ts +5 -6
  70. package/dist/types/llm/providerRegistry.d.ts +11 -0
  71. package/dist/types/llm/providers.d.ts +4 -5
  72. package/dist/types/llm/request.d.ts +2 -3
  73. package/dist/types/llm/truncation.d.ts +2 -2
  74. package/dist/types/messages/core.d.ts +1 -2
  75. package/dist/types/messages/format.d.ts +3 -3
  76. package/dist/types/messages/prune.d.ts +3 -2
  77. package/dist/types/provider-registration.d.ts +15 -0
  78. package/dist/types/stream.d.ts +1 -2
  79. package/dist/types/summarization/node.d.ts +1 -2
  80. package/dist/types/types/activityLabel.d.ts +3 -4
  81. package/dist/types/types/graph.d.ts +4 -5
  82. package/dist/types/types/llm.d.ts +54 -13
  83. package/dist/types/types/reasoningLabel.d.ts +2 -3
  84. package/dist/types/types/run.d.ts +3 -3
  85. package/dist/types/types/summarize.d.ts +2 -2
  86. package/dist/types/utils/errors.d.ts +3 -3
  87. package/dist/types/utils/llm.d.ts +4 -4
  88. package/dist/types/utils/llmConfig.d.ts +2 -2
  89. package/package.json +9 -1
  90. package/src/agents/AgentContext.ts +27 -26
  91. package/src/graphs/Graph.ts +14 -14
  92. package/src/index.ts +5 -0
  93. package/src/llm/contextOverflowRecovery.ts +2 -2
  94. package/src/llm/init.ts +40 -17
  95. package/src/llm/invoke.ts +36 -21
  96. package/src/llm/prepareProviderRequest.ts +19 -18
  97. package/src/llm/providerRegistry.ts +134 -0
  98. package/src/llm/providers.ts +73 -30
  99. package/src/llm/request.ts +10 -6
  100. package/src/llm/truncation.ts +9 -3
  101. package/src/messages/core.ts +2 -2
  102. package/src/messages/format.ts +14 -16
  103. package/src/messages/prune.ts +22 -17
  104. package/src/provider-registration.ts +29 -0
  105. package/src/run.ts +1 -1
  106. package/src/session/AgentSession.ts +1 -1
  107. package/src/stream.ts +7 -8
  108. package/src/summarization/node.ts +7 -7
  109. package/src/types/activityLabel.ts +3 -4
  110. package/src/types/graph.ts +5 -5
  111. package/src/types/llm.ts +95 -13
  112. package/src/types/reasoningLabel.ts +2 -3
  113. package/src/types/run.ts +3 -3
  114. package/src/types/summarize.ts +2 -2
  115. package/src/utils/errors.ts +3 -3
  116. package/src/utils/llm.ts +22 -15
  117. package/src/utils/llmConfig.ts +4 -4
@@ -657,7 +657,7 @@ async function executeSummarizationWithFallback(params: {
657
657
  * `log('error', ...)` path below rather than bubbling up silently.
658
658
  */
659
659
  const summarizationModel = initializeModel({
660
- provider: clientConfig.provider as Providers,
660
+ provider: clientConfig.provider,
661
661
  clientOptions: clientConfig.clientOptions as t.ClientOptions,
662
662
  tools: agentContext.getToolsForBinding(),
663
663
  }) as t.ChatModel;
@@ -670,13 +670,13 @@ async function executeSummarizationWithFallback(params: {
670
670
  priorSummaryText,
671
671
  config: summarizeConfig,
672
672
  stepId,
673
- provider: clientConfig.provider as Providers,
673
+ provider: clientConfig.provider,
674
674
  reasoningKey: agentContext.reasoningKey,
675
675
  graph,
676
676
  usePromptCache,
677
677
  promptCacheTtl:
678
- (clientConfig.provider as Providers) === Providers.ANTHROPIC ||
679
- (clientConfig.provider as Providers) === Providers.OPENROUTER
678
+ clientConfig.provider === Providers.ANTHROPIC ||
679
+ clientConfig.provider === Providers.OPENROUTER
680
680
  ? resolvePromptCacheTtl(
681
681
  (
682
682
  clientConfig.clientOptions as {
@@ -737,7 +737,7 @@ async function executeSummarizationWithFallback(params: {
737
737
  const onChunk = createSummarizationChunkHandler({
738
738
  stepId,
739
739
  config: traceConfig(summarizeConfig, 'cache_hit_compaction'),
740
- provider: clientConfig.provider as Providers,
740
+ provider: clientConfig.provider,
741
741
  reasoningKey: agentContext.reasoningKey,
742
742
  graph,
743
743
  });
@@ -1509,7 +1509,7 @@ export function createSummarizationChunkHandler({
1509
1509
  }: {
1510
1510
  stepId?: string;
1511
1511
  config?: RunnableConfig;
1512
- provider?: Providers;
1512
+ provider?: t.ProviderName;
1513
1513
  reasoningKey?: 'reasoning_content' | 'reasoning';
1514
1514
  graph?: StreamLimitState & { getBreakerController?: () => AbortController };
1515
1515
  }): OnChunk | undefined {
@@ -1622,7 +1622,7 @@ async function summarizeWithCacheHit({
1622
1622
  priorSummaryText: string;
1623
1623
  config?: RunnableConfig;
1624
1624
  stepId?: string;
1625
- provider: Providers;
1625
+ provider: t.ProviderName;
1626
1626
  reasoningKey?: 'reasoning_content' | 'reasoning';
1627
1627
  graph?: StreamLimitState & { getBreakerSignal?: () => AbortSignal };
1628
1628
  usePromptCache?: boolean;
@@ -1,7 +1,6 @@
1
1
  import type { RunnableConfig } from '@langchain/core/runnables';
2
2
  import type { AssistantTextPhase } from '@/types/assistantPhase';
3
- import type { ClientOptions } from '@/types/llm';
4
- import type { Providers } from '@/common';
3
+ import type { ClientOptions, ProviderName } from '@/types/llm';
5
4
 
6
5
  /** One tool call's contribution to the label payload (host-assembled). */
7
6
  export type ActivityLabelToolEntry = {
@@ -25,7 +24,7 @@ export type ActivityLabelToolEntry = {
25
24
  * `activity_label` content type's formatter exclusions.
26
25
  */
27
26
  export type RunActivityLabelOptions = {
28
- provider: Providers;
27
+ provider: ProviderName;
29
28
  clientOptions?: ClientOptions;
30
29
  /**
31
30
  * Agent that executed the labeled batch. Selects that agent's Langfuse
@@ -85,7 +84,7 @@ export type ActivityPhaseEntry = {
85
84
 
86
85
  /** Options for `Run.generateActivityPhaseLabel`. */
87
86
  export type RunActivityPhaseLabelOptions = {
88
- provider: Providers;
87
+ provider: ProviderName;
89
88
  clientOptions?: ClientOptions;
90
89
  /**
91
90
  * Logical activities in run order. The SDK requires at least two so hosts
@@ -40,10 +40,10 @@ import type {
40
40
  StreamPreemption,
41
41
  TokenBudgetBreakdown,
42
42
  } from '@/types/run';
43
- import type { Providers, Callback, GraphNodeKeys } from '@/common';
44
43
  import type { SubagentTaskConfig } from '@/types/subagentTasks';
45
44
  import type { StandardGraph, MultiAgentGraph } from '@/graphs';
46
- import type { ClientOptions } from '@/types/llm';
45
+ import type { ProviderClientOptionsConfig } from '@/types/llm';
46
+ import type { Callback, GraphNodeKeys } from '@/common';
47
47
 
48
48
  /** Interface for bound model with stream and invoke methods */
49
49
  export interface ChatModel {
@@ -824,7 +824,7 @@ export interface LangfuseConfig {
824
824
  deterministicTraceId?: boolean;
825
825
  }
826
826
 
827
- export interface AgentInputs {
827
+ interface AgentInputFields {
828
828
  agentId: string;
829
829
  /**
830
830
  * Partition key for transient code-session ids and file refs. Agents with
@@ -839,12 +839,10 @@ export interface AgentInputs {
839
839
  toolEnd?: boolean;
840
840
  toolMap?: ToolMap;
841
841
  tools?: GraphTools;
842
- provider: Providers;
843
842
  /** Stable/cacheable system instructions. */
844
843
  instructions?: string;
845
844
  streamBuffer?: number;
846
845
  maxContextTokens?: number;
847
- clientOptions?: ClientOptions;
848
846
  /** Per-agent Langfuse tracing configuration. */
849
847
  langfuse?: LangfuseConfig;
850
848
  /** Dynamic system tail appended after stable instructions without provider cache markers. */
@@ -914,6 +912,8 @@ export interface AgentInputs {
914
912
  graphTools?: GenericTool[];
915
913
  }
916
914
 
915
+ export type AgentInputs = AgentInputFields & ProviderClientOptionsConfig;
916
+
917
917
  export interface ContextPruningConfig {
918
918
  enabled?: boolean;
919
919
  keepLastAssistants?: number;
package/src/types/llm.ts CHANGED
@@ -8,6 +8,7 @@ import type {
8
8
  } from '@langchain/openai';
9
9
  import type {
10
10
  BindToolsInput,
11
+ BaseChatModel,
11
12
  BaseChatModelParams,
12
13
  } from '@langchain/core/language_models/chat_models';
13
14
  import type { GoogleGenerativeAIChatInput } from '@langchain/google-genai';
@@ -21,6 +22,7 @@ import type { AnthropicInput } from '@langchain/anthropic';
21
22
  import type { Runnable } from '@langchain/core/runnables';
22
23
  import type { OpenAI as OpenAIClient } from 'openai';
23
24
  import type { ChatXAIInput } from '@langchain/xai';
25
+ import type { CustomProviderOptionsMap } from '../provider-registration';
24
26
  import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
25
27
  import type { PromptCacheTtl } from '@/messages/cache';
26
28
  import {
@@ -138,7 +140,7 @@ export type DeepSeekClientOptions = Partial<ChatDeepSeekInput> &
138
140
  StreamSmoothingOptions;
139
141
  export type XAIClientOptions = ChatXAIInput & StreamSmoothingOptions;
140
142
 
141
- export type ClientOptions =
143
+ export type BuiltInClientOptions =
142
144
  | OpenAIClientOptions
143
145
  | AzureClientOptions
144
146
  | AnthropicClientOptions
@@ -149,24 +151,86 @@ export type ClientOptions =
149
151
  | DeepSeekClientOptions
150
152
  | XAIClientOptions;
151
153
 
152
- export type SharedLLMConfig = {
153
- provider: Providers;
154
+ type CustomProviderName = Extract<keyof CustomProviderOptionsMap, string>;
155
+
156
+ type LooseRuntimeProviderName = string & {
157
+ readonly __runtimeProviderName?: never;
158
+ };
159
+
160
+ export type ProviderName =
161
+ | keyof ProviderOptionsMap
162
+ | CustomProviderName
163
+ | LooseRuntimeProviderName;
164
+
165
+ declare const RUNTIME_PROVIDER_NAME: unique symbol;
166
+
167
+ /** A runtime provider without declaration-merged option types. */
168
+ export type RuntimeProviderName = string & {
169
+ readonly [RUNTIME_PROVIDER_NAME]: true;
170
+ };
171
+
172
+ export type ClientOptions =
173
+ | BuiltInClientOptions
174
+ | CustomProviderOptionsMap[CustomProviderName];
175
+
176
+ export type SharedLLMConfig<
177
+ P extends
178
+ | keyof ProviderOptionsMap
179
+ | CustomProviderName
180
+ | RuntimeProviderName = keyof ProviderOptionsMap,
181
+ > = {
182
+ provider: P;
183
+ model?: string;
154
184
  _lc_stream_delay?: number;
155
185
  };
156
186
 
157
- export interface FallbackConfig {
158
- provider: Providers;
159
- clientOptions?: ClientOptions;
187
+ type CustomProviderClientOptionsConfig<P extends CustomProviderName> = {
188
+ provider: P;
189
+ } & (object extends CustomProviderOptionsMap[P]
190
+ ? { clientOptions?: CustomProviderOptionsMap[P] }
191
+ : { clientOptions: CustomProviderOptionsMap[P] });
192
+
193
+ export type ProviderClientOptionsConfig =
194
+ | {
195
+ provider: keyof ProviderOptionsMap;
196
+ clientOptions?: BuiltInClientOptions;
197
+ }
198
+ | {
199
+ [P in CustomProviderName]: CustomProviderClientOptionsConfig<P>;
200
+ }[CustomProviderName]
201
+ | {
202
+ provider: RuntimeProviderName;
203
+ clientOptions: ClientOptions;
204
+ };
205
+
206
+ export type FallbackConfig = ProviderClientOptionsConfig & {
160
207
  /** Context window used to corroborate ambiguous fallback overflow errors. */
161
208
  maxContextTokens?: number;
162
- }
209
+ };
210
+
211
+ type LLMConfigFor<P extends CustomProviderName> = SharedLLMConfig<P> &
212
+ CustomProviderOptionsMap[P] & {
213
+ /** Optional provider fallbacks in order of attempt */
214
+ fallbacks?: FallbackConfig[];
215
+ };
163
216
 
164
- export type LLMConfig = SharedLLMConfig &
165
- ClientOptions & {
217
+ export type BuiltInLLMConfig = SharedLLMConfig &
218
+ BuiltInClientOptions & {
166
219
  /** Optional provider fallbacks in order of attempt */
167
220
  fallbacks?: FallbackConfig[];
168
221
  };
169
222
 
223
+ export type LLMConfig =
224
+ | BuiltInLLMConfig
225
+ | {
226
+ [P in CustomProviderName]: LLMConfigFor<P>;
227
+ }[CustomProviderName]
228
+ | (SharedLLMConfig<RuntimeProviderName> &
229
+ ClientOptions & {
230
+ /** Optional provider fallbacks in order of attempt */
231
+ fallbacks?: FallbackConfig[];
232
+ });
233
+
170
234
  export type ProviderOptionsMap = {
171
235
  [Providers.AZURE]: AzureClientOptions;
172
236
  [Providers.OPENAI]: OpenAIClientOptions;
@@ -182,7 +246,7 @@ export type ProviderOptionsMap = {
182
246
  [Providers.MOONSHOT]: OpenAIClientOptions;
183
247
  };
184
248
 
185
- export type ChatModelMap = {
249
+ export interface ChatModelMap {
186
250
  [Providers.XAI]: ChatXAI;
187
251
  [Providers.OPENAI]: ChatOpenAI;
188
252
  [Providers.AZURE]: AzureChatOpenAI;
@@ -195,14 +259,32 @@ export type ChatModelMap = {
195
259
  [Providers.BEDROCK]: CustomChatBedrockConverse;
196
260
  [Providers.GOOGLE]: CustomChatGoogleGenerativeAI;
197
261
  [Providers.MOONSHOT]: ChatMoonshot;
198
- };
262
+ }
263
+
264
+ export type ProviderOptionsFor<P extends ProviderName> =
265
+ P extends keyof ProviderOptionsMap
266
+ ? ProviderOptionsMap[P]
267
+ : P extends CustomProviderName
268
+ ? CustomProviderOptionsMap[P]
269
+ : BuiltInClientOptions;
270
+
271
+ export type ProviderModelFor<P extends ProviderName> =
272
+ P extends keyof ChatModelMap
273
+ ? ChatModelMap[P] & BaseChatModel
274
+ : BaseChatModel;
275
+
276
+ export type ProviderModelConstructor<P extends ProviderName> = new (
277
+ config: ProviderOptionsFor<P>
278
+ ) => ProviderModelFor<P>;
199
279
 
200
280
  export type ChatModelConstructorMap = {
201
281
  [P in Providers]: new (config: ProviderOptionsMap[P]) => ChatModelMap[P];
202
282
  };
203
283
 
204
- export type ChatModelInstance = ChatModelMap[Providers];
284
+ export type ChatModelInstance = BaseChatModel;
205
285
 
206
- export type ModelWithTools = ChatModelInstance & {
286
+ export type ModelWithTools = BaseChatModel & {
207
287
  bindTools(tools: CommonToolType[]): Runnable;
208
288
  };
289
+
290
+ export type { CustomProviderOptionsMap } from '../provider-registration';
@@ -1,7 +1,6 @@
1
1
  import type { RunnableConfig } from '@langchain/core/runnables';
2
2
  import type { UsageMetadata } from '@langchain/core/messages';
3
- import type { ClientOptions } from '@/types/llm';
4
- import type { Providers } from '@/common';
3
+ import type { ClientOptions, ProviderName } from '@/types/llm';
5
4
 
6
5
  /** Lifecycle state of the visible reasoning snapshot being labeled. */
7
6
  export type ReasoningLabelStatus = 'streaming' | 'complete';
@@ -15,7 +14,7 @@ export type ReasoningLabelResult = {
15
14
 
16
15
  /** Options for `Run.generateReasoningLabel`. */
17
16
  export type RunReasoningLabelOptions = {
18
- provider: Providers;
17
+ provider: ProviderName;
19
18
  clientOptions?: ClientOptions;
20
19
  /**
21
20
  * Complete user-visible reasoning accumulated for this step so far. Hidden
package/src/types/run.ts CHANGED
@@ -22,7 +22,7 @@ import type * as l from '@/types/llm';
22
22
  export type ZodObjectAny = z.ZodObject<any, any, any, any>;
23
23
  export type BaseGraphConfig = {
24
24
  llmConfig: l.LLMConfig;
25
- provider?: e.Providers;
25
+ provider?: l.ProviderName;
26
26
  clientOptions?: l.ClientOptions;
27
27
  /** Optional compile options for workflow.compile() */
28
28
  compileOptions?: g.CompileOptions;
@@ -47,7 +47,7 @@ export type SupervisedGraphConfig = BaseGraphConfig & {
47
47
  routingPolicies?: Array<{
48
48
  stage: string;
49
49
  agents?: string[];
50
- model?: e.Providers;
50
+ model?: l.ProviderName;
51
51
  parallel?: boolean;
52
52
  /** Optional simple condition on content/tools */
53
53
  when?:
@@ -70,7 +70,7 @@ export type SupervisedGraphConfig = BaseGraphConfig & {
70
70
 
71
71
  export type RunTitleOptions = {
72
72
  inputText: string;
73
- provider: e.Providers;
73
+ provider: l.ProviderName;
74
74
  contentParts: (s.MessageContentComplex | undefined)[];
75
75
  titlePrompt?: string;
76
76
  skipLanguage?: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { SummaryContentBlock } from '@/types/stream';
2
- import type { Providers } from '@/common';
2
+ import type { ProviderName } from '@/types/llm';
3
3
 
4
4
  export type SummarizationTrigger = {
5
5
  type:
@@ -35,7 +35,7 @@ export type RetainRecentConfig = {
35
35
  };
36
36
 
37
37
  export type SummarizationConfig = {
38
- provider?: Providers;
38
+ provider?: ProviderName;
39
39
  model?: string;
40
40
  parameters?: Record<string, unknown>;
41
41
  prompt?: string;
@@ -12,7 +12,7 @@
12
12
  * into a forced summarization pass instead of surfacing the error.
13
13
  */
14
14
  import { ContextOverflowError } from '@langchain/core/errors';
15
- import type { Providers } from '@/common';
15
+ import type { ProviderName } from '@/types';
16
16
 
17
17
  /**
18
18
  * Why the request was rejected. Both kinds are fixed by shrinking the
@@ -49,7 +49,7 @@ export interface ContextOverflowInfo {
49
49
  promptTokens?: number;
50
50
  /** Which layer produced the verdict. Surfaced in logs and asserted in tests. */
51
51
  source: 'langchain' | 'pattern';
52
- provider?: Providers;
52
+ provider?: ProviderName;
53
53
  }
54
54
 
55
55
  interface OverflowPattern {
@@ -80,7 +80,7 @@ interface OverflowPattern {
80
80
  const CONTEXT_PRESSURE_RATIO = 0.8;
81
81
 
82
82
  export interface ContextOverflowContext {
83
- provider?: Providers;
83
+ provider?: ProviderName;
84
84
  /** Our own estimate of the prompt size for the call that failed. */
85
85
  estimatedPromptTokens?: number;
86
86
  /** The budget we believed applied when we built that prompt. */
package/src/utils/llm.ts CHANGED
@@ -1,37 +1,44 @@
1
1
  // src/utils/llm.ts
2
+ import type { ProviderName } from '@/types';
3
+ import { getProviderFamily } from '@/llm/providerRegistry';
2
4
  import { Providers } from '@/common';
3
5
 
4
- export function isOpenAILike(provider?: string | Providers): boolean {
6
+ export function isOpenAILike(provider?: ProviderName): boolean {
5
7
  if (provider == null) {
6
8
  return false;
7
9
  }
8
10
  return (
9
- [
10
- Providers.OPENAI,
11
- Providers.AZURE,
12
- Providers.OPENROUTER,
13
- Providers.XAI,
14
- Providers.DEEPSEEK,
15
- ] as string[]
16
- ).includes(provider);
11
+ getProviderFamily(provider) === 'openai' ||
12
+ (
13
+ [
14
+ Providers.OPENAI,
15
+ Providers.AZURE,
16
+ Providers.OPENROUTER,
17
+ Providers.XAI,
18
+ Providers.DEEPSEEK,
19
+ ] as string[]
20
+ ).includes(provider)
21
+ );
17
22
  }
18
23
 
19
- export function isGoogleLike(provider?: string | Providers): boolean {
24
+ export function isGoogleLike(provider?: ProviderName): boolean {
20
25
  if (provider == null) {
21
26
  return false;
22
27
  }
23
- return ([Providers.GOOGLE, Providers.VERTEXAI] as string[]).includes(
24
- provider
28
+ return (
29
+ getProviderFamily(provider) === 'google' ||
30
+ ([Providers.GOOGLE, Providers.VERTEXAI] as string[]).includes(provider)
25
31
  );
26
32
  }
27
33
 
28
34
  /** Returns true for native Anthropic or Bedrock running a Claude model. */
29
35
  export function isAnthropicLike(
30
- provider?: string | Providers,
36
+ provider?: ProviderName,
31
37
  clientOptions?: { model?: string }
32
38
  ): boolean {
33
- if (provider === Providers.ANTHROPIC) return true;
34
- if (provider === Providers.BEDROCK) {
39
+ const family = provider == null ? undefined : getProviderFamily(provider);
40
+ if (provider === Providers.ANTHROPIC || family === 'anthropic') return true;
41
+ if (provider === Providers.BEDROCK || family === 'bedrock') {
35
42
  return (
36
43
  clientOptions?.model == null ||
37
44
  /claude/i.test(String(clientOptions.model))
@@ -3,7 +3,7 @@ import type * as or from '@/llm/openrouter';
3
3
  import type * as t from '@/types';
4
4
  import { Providers } from '@/common';
5
5
 
6
- export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
6
+ export const llmConfigs: Record<string, t.BuiltInLLMConfig | undefined> = {
7
7
  [Providers.OPENAI]: {
8
8
  provider: Providers.OPENAI,
9
9
  model: 'gpt-4.1',
@@ -68,7 +68,7 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
68
68
  modelKwargs: {
69
69
  max_tokens: 10000,
70
70
  },
71
- } as or.ChatOpenRouterCallOptions & t.LLMConfig,
71
+ } as or.ChatOpenRouterCallOptions & t.BuiltInLLMConfig,
72
72
  [Providers.AZURE]: {
73
73
  provider: Providers.AZURE,
74
74
  temperature: 0.7,
@@ -159,7 +159,7 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
159
159
  // location: 'global',
160
160
  // thinkingBudget: -1,
161
161
  // includeThoughts: true,
162
- } as t.VertexAIClientOptions & t.LLMConfig,
162
+ } as t.VertexAIClientOptions & t.BuiltInLLMConfig,
163
163
  [Providers.GOOGLE]: {
164
164
  provider: Providers.GOOGLE,
165
165
  model: 'gemini-2.5-flash',
@@ -194,7 +194,7 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
194
194
  },
195
195
  };
196
196
 
197
- export function getLLMConfig(provider: string): t.LLMConfig {
197
+ export function getLLMConfig(provider: string): t.BuiltInLLMConfig {
198
198
  const config = llmConfigs[provider];
199
199
  if (config === undefined) {
200
200
  throw new Error(`Unsupported provider: ${provider}`);