@dexto/core 1.6.0 → 1.6.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 (188) hide show
  1. package/dist/agent/DextoAgent.cjs +79 -5
  2. package/dist/agent/DextoAgent.d.ts +24 -2
  3. package/dist/agent/DextoAgent.d.ts.map +1 -1
  4. package/dist/agent/DextoAgent.js +79 -5
  5. package/dist/agent/agent-options.d.ts +6 -1
  6. package/dist/agent/agent-options.d.ts.map +1 -1
  7. package/dist/agent/schemas.d.ts +18 -18
  8. package/dist/approval/manager.cjs +87 -27
  9. package/dist/approval/manager.d.ts +10 -1
  10. package/dist/approval/manager.d.ts.map +1 -1
  11. package/dist/approval/manager.js +87 -27
  12. package/dist/approval/schemas.cjs +22 -8
  13. package/dist/approval/schemas.d.ts +276 -102
  14. package/dist/approval/schemas.d.ts.map +1 -1
  15. package/dist/approval/schemas.js +22 -8
  16. package/dist/context/manager.cjs +2 -2
  17. package/dist/context/manager.d.ts +2 -1
  18. package/dist/context/manager.d.ts.map +1 -1
  19. package/dist/context/manager.js +2 -2
  20. package/dist/context/types.d.ts +3 -2
  21. package/dist/context/types.d.ts.map +1 -1
  22. package/dist/events/index.d.ts +26 -13
  23. package/dist/events/index.d.ts.map +1 -1
  24. package/dist/hooks/index.d.ts +1 -1
  25. package/dist/hooks/index.d.ts.map +1 -1
  26. package/dist/hooks/types.d.ts +1 -22
  27. package/dist/hooks/types.d.ts.map +1 -1
  28. package/dist/llm/executor/provider-options.cjs +223 -28
  29. package/dist/llm/executor/provider-options.d.ts +3 -37
  30. package/dist/llm/executor/provider-options.d.ts.map +1 -1
  31. package/dist/llm/executor/provider-options.js +227 -27
  32. package/dist/llm/executor/stream-processor.cjs +57 -34
  33. package/dist/llm/executor/stream-processor.d.ts +12 -4
  34. package/dist/llm/executor/stream-processor.d.ts.map +1 -1
  35. package/dist/llm/executor/stream-processor.js +55 -32
  36. package/dist/llm/executor/turn-executor.cjs +66 -44
  37. package/dist/llm/executor/turn-executor.d.ts +3 -3
  38. package/dist/llm/executor/turn-executor.d.ts.map +1 -1
  39. package/dist/llm/executor/turn-executor.js +56 -34
  40. package/dist/llm/formatters/vercel.cjs +15 -3
  41. package/dist/llm/formatters/vercel.d.ts +1 -0
  42. package/dist/llm/formatters/vercel.d.ts.map +1 -1
  43. package/dist/llm/formatters/vercel.js +15 -3
  44. package/dist/llm/index.cjs +8 -0
  45. package/dist/llm/index.d.ts +2 -1
  46. package/dist/llm/index.d.ts.map +1 -1
  47. package/dist/llm/index.js +7 -0
  48. package/dist/llm/providers/local/schemas.d.ts +2 -2
  49. package/dist/llm/providers/openrouter-model-registry.cjs +66 -11
  50. package/dist/llm/providers/openrouter-model-registry.d.ts +26 -0
  51. package/dist/llm/providers/openrouter-model-registry.d.ts.map +1 -1
  52. package/dist/llm/providers/openrouter-model-registry.js +65 -11
  53. package/dist/llm/reasoning/anthropic-betas.cjs +31 -0
  54. package/dist/llm/reasoning/anthropic-betas.d.ts +3 -0
  55. package/dist/llm/reasoning/anthropic-betas.d.ts.map +1 -0
  56. package/dist/llm/reasoning/anthropic-betas.js +7 -0
  57. package/dist/llm/reasoning/anthropic-thinking.cjs +79 -0
  58. package/dist/llm/reasoning/anthropic-thinking.d.ts +15 -0
  59. package/dist/llm/reasoning/anthropic-thinking.d.ts.map +1 -0
  60. package/dist/llm/reasoning/anthropic-thinking.js +52 -0
  61. package/dist/llm/reasoning/openai-reasoning-effort.cjs +86 -0
  62. package/dist/llm/reasoning/openai-reasoning-effort.d.ts +5 -0
  63. package/dist/llm/reasoning/openai-reasoning-effort.d.ts.map +1 -0
  64. package/dist/llm/reasoning/openai-reasoning-effort.js +61 -0
  65. package/dist/llm/reasoning/profile.cjs +113 -0
  66. package/dist/llm/reasoning/profile.d.ts +13 -0
  67. package/dist/llm/reasoning/profile.d.ts.map +1 -0
  68. package/dist/llm/reasoning/profile.js +92 -0
  69. package/dist/llm/reasoning/profiles/anthropic.cjs +61 -0
  70. package/dist/llm/reasoning/profiles/anthropic.d.ts +8 -0
  71. package/dist/llm/reasoning/profiles/anthropic.d.ts.map +1 -0
  72. package/dist/llm/reasoning/profiles/anthropic.js +45 -0
  73. package/dist/llm/reasoning/profiles/bedrock.cjs +54 -0
  74. package/dist/llm/reasoning/profiles/bedrock.d.ts +3 -0
  75. package/dist/llm/reasoning/profiles/bedrock.d.ts.map +1 -0
  76. package/dist/llm/reasoning/profiles/bedrock.js +36 -0
  77. package/dist/llm/reasoning/profiles/google.cjs +45 -0
  78. package/dist/llm/reasoning/profiles/google.d.ts +9 -0
  79. package/dist/llm/reasoning/profiles/google.d.ts.map +1 -0
  80. package/dist/llm/reasoning/profiles/google.js +21 -0
  81. package/dist/llm/reasoning/profiles/openai-compatible.cjs +39 -0
  82. package/dist/llm/reasoning/profiles/openai-compatible.d.ts +3 -0
  83. package/dist/llm/reasoning/profiles/openai-compatible.d.ts.map +1 -0
  84. package/dist/llm/reasoning/profiles/openai-compatible.js +16 -0
  85. package/dist/llm/reasoning/profiles/openai.cjs +41 -0
  86. package/dist/llm/reasoning/profiles/openai.d.ts +3 -0
  87. package/dist/llm/reasoning/profiles/openai.d.ts.map +1 -0
  88. package/dist/llm/reasoning/profiles/openai.js +18 -0
  89. package/dist/llm/reasoning/profiles/openrouter.cjs +83 -0
  90. package/dist/llm/reasoning/profiles/openrouter.d.ts +10 -0
  91. package/dist/llm/reasoning/profiles/openrouter.d.ts.map +1 -0
  92. package/dist/llm/reasoning/profiles/openrouter.js +59 -0
  93. package/dist/llm/reasoning/profiles/shared.cjs +80 -0
  94. package/dist/llm/reasoning/profiles/shared.d.ts +25 -0
  95. package/dist/llm/reasoning/profiles/shared.d.ts.map +1 -0
  96. package/dist/llm/reasoning/profiles/shared.js +53 -0
  97. package/dist/llm/reasoning/profiles/vertex.cjs +46 -0
  98. package/dist/llm/reasoning/profiles/vertex.d.ts +3 -0
  99. package/dist/llm/reasoning/profiles/vertex.d.ts.map +1 -0
  100. package/dist/llm/reasoning/profiles/vertex.js +23 -0
  101. package/dist/llm/registry/auto-update.cjs +18 -0
  102. package/dist/llm/registry/auto-update.d.ts.map +1 -1
  103. package/dist/llm/registry/auto-update.js +18 -0
  104. package/dist/llm/registry/index.cjs +126 -26
  105. package/dist/llm/registry/index.d.ts +48 -4
  106. package/dist/llm/registry/index.d.ts.map +1 -1
  107. package/dist/llm/registry/index.js +136 -28
  108. package/dist/llm/registry/models.generated.cjs +5198 -59
  109. package/dist/llm/registry/models.generated.d.ts +1893 -76
  110. package/dist/llm/registry/models.generated.d.ts.map +1 -1
  111. package/dist/llm/registry/models.generated.js +5196 -58
  112. package/dist/llm/registry/sync.cjs +72 -1
  113. package/dist/llm/registry/sync.d.ts +21 -1
  114. package/dist/llm/registry/sync.d.ts.map +1 -1
  115. package/dist/llm/registry/sync.js +72 -1
  116. package/dist/llm/resolver.cjs +13 -1
  117. package/dist/llm/resolver.d.ts.map +1 -1
  118. package/dist/llm/resolver.js +13 -1
  119. package/dist/llm/schemas.cjs +75 -14
  120. package/dist/llm/schemas.d.ts +84 -27
  121. package/dist/llm/schemas.d.ts.map +1 -1
  122. package/dist/llm/schemas.js +75 -14
  123. package/dist/llm/services/factory.cjs +55 -8
  124. package/dist/llm/services/factory.d.ts +1 -1
  125. package/dist/llm/services/factory.d.ts.map +1 -1
  126. package/dist/llm/services/factory.js +58 -8
  127. package/dist/llm/services/vercel.cjs +2 -2
  128. package/dist/llm/services/vercel.js +2 -2
  129. package/dist/llm/types.d.ts +9 -0
  130. package/dist/llm/types.d.ts.map +1 -1
  131. package/dist/logger/default-logger-factory.d.ts +12 -12
  132. package/dist/logger/v2/dexto-logger.cjs +35 -0
  133. package/dist/logger/v2/dexto-logger.d.ts +19 -0
  134. package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
  135. package/dist/logger/v2/dexto-logger.js +35 -0
  136. package/dist/logger/v2/schemas.d.ts +6 -6
  137. package/dist/logger/v2/test-utils.cjs +2 -0
  138. package/dist/logger/v2/test-utils.d.ts.map +1 -1
  139. package/dist/logger/v2/test-utils.js +2 -0
  140. package/dist/logger/v2/types.d.ts +14 -1
  141. package/dist/logger/v2/types.d.ts.map +1 -1
  142. package/dist/mcp/schemas.d.ts +15 -15
  143. package/dist/memory/schemas.d.ts +4 -4
  144. package/dist/prompts/index.cjs +9 -0
  145. package/dist/prompts/index.d.ts +1 -0
  146. package/dist/prompts/index.d.ts.map +1 -1
  147. package/dist/prompts/index.js +10 -0
  148. package/dist/prompts/prompt-manager.cjs +2 -0
  149. package/dist/prompts/prompt-manager.d.ts.map +1 -1
  150. package/dist/prompts/prompt-manager.js +2 -0
  151. package/dist/prompts/providers/config-prompt-provider.cjs +11 -1
  152. package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
  153. package/dist/prompts/providers/config-prompt-provider.js +11 -1
  154. package/dist/prompts/schemas.cjs +2 -2
  155. package/dist/prompts/schemas.d.ts +7 -7
  156. package/dist/prompts/schemas.js +2 -2
  157. package/dist/prompts/types.d.ts +6 -2
  158. package/dist/prompts/types.d.ts.map +1 -1
  159. package/dist/systemPrompt/in-built-prompts.cjs +5 -5
  160. package/dist/systemPrompt/in-built-prompts.d.ts +1 -1
  161. package/dist/systemPrompt/in-built-prompts.d.ts.map +1 -1
  162. package/dist/systemPrompt/in-built-prompts.js +5 -5
  163. package/dist/systemPrompt/schemas.d.ts +5 -5
  164. package/dist/systemPrompt/types.d.ts +11 -0
  165. package/dist/systemPrompt/types.d.ts.map +1 -1
  166. package/dist/tools/display-types.d.ts +10 -0
  167. package/dist/tools/display-types.d.ts.map +1 -1
  168. package/dist/tools/index.cjs +3 -1
  169. package/dist/tools/index.d.ts +1 -0
  170. package/dist/tools/index.d.ts.map +1 -1
  171. package/dist/tools/index.js +1 -0
  172. package/dist/tools/presentation.cjs +49 -0
  173. package/dist/tools/presentation.d.ts +11 -0
  174. package/dist/tools/presentation.d.ts.map +1 -0
  175. package/dist/tools/presentation.js +24 -0
  176. package/dist/tools/tool-manager.cjs +389 -136
  177. package/dist/tools/tool-manager.d.ts +36 -24
  178. package/dist/tools/tool-manager.d.ts.map +1 -1
  179. package/dist/tools/tool-manager.js +389 -136
  180. package/dist/tools/types.d.ts +134 -55
  181. package/dist/tools/types.d.ts.map +1 -1
  182. package/dist/utils/path.cjs +10 -1
  183. package/dist/utils/path.d.ts +5 -2
  184. package/dist/utils/path.d.ts.map +1 -1
  185. package/dist/utils/path.js +10 -1
  186. package/dist/utils/service-initializer.d.ts +1 -0
  187. package/dist/utils/service-initializer.d.ts.map +1 -1
  188. package/package.json +7 -5
@@ -10,29 +10,44 @@ export declare const LLMConfigBaseSchema: z.ZodObject<{
10
10
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
11
11
  temperature: z.ZodOptional<z.ZodNumber>;
12
12
  allowedMediaTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
- reasoningEffort: z.ZodOptional<z.ZodEnum<["none", "minimal", "low", "medium", "high", "xhigh"]>>;
13
+ reasoning: z.ZodOptional<z.ZodObject<{
14
+ variant: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
15
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
16
+ }, "strict", z.ZodTypeAny, {
17
+ variant: string;
18
+ budgetTokens?: number | undefined;
19
+ }, {
20
+ variant: string;
21
+ budgetTokens?: number | undefined;
22
+ }>>;
14
23
  }, "strict", z.ZodTypeAny, {
15
24
  model: string;
16
25
  provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
17
26
  apiKey?: string | undefined;
18
27
  maxInputTokens?: number | undefined;
28
+ reasoning?: {
29
+ variant: string;
30
+ budgetTokens?: number | undefined;
31
+ } | undefined;
32
+ temperature?: number | undefined;
19
33
  maxIterations?: number | undefined;
20
34
  baseURL?: string | undefined;
21
35
  maxOutputTokens?: number | undefined;
22
- temperature?: number | undefined;
23
36
  allowedMediaTypes?: string[] | undefined;
24
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
25
37
  }, {
26
38
  model: string;
27
39
  provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
28
40
  apiKey?: string | undefined;
29
41
  maxInputTokens?: number | undefined;
42
+ reasoning?: {
43
+ variant: string;
44
+ budgetTokens?: number | undefined;
45
+ } | undefined;
46
+ temperature?: number | undefined;
30
47
  maxIterations?: number | undefined;
31
48
  baseURL?: string | undefined;
32
49
  maxOutputTokens?: number | undefined;
33
- temperature?: number | undefined;
34
50
  allowedMediaTypes?: string[] | undefined;
35
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
36
51
  }>;
37
52
  /**
38
53
  * LLM config schema.
@@ -51,55 +66,86 @@ export declare const LLMConfigSchema: z.ZodEffects<z.ZodObject<{
51
66
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
52
67
  temperature: z.ZodOptional<z.ZodNumber>;
53
68
  allowedMediaTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
54
- reasoningEffort: z.ZodOptional<z.ZodEnum<["none", "minimal", "low", "medium", "high", "xhigh"]>>;
69
+ reasoning: z.ZodOptional<z.ZodObject<{
70
+ variant: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
71
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
72
+ }, "strict", z.ZodTypeAny, {
73
+ variant: string;
74
+ budgetTokens?: number | undefined;
75
+ }, {
76
+ variant: string;
77
+ budgetTokens?: number | undefined;
78
+ }>>;
55
79
  }, "strict", z.ZodTypeAny, {
56
80
  model: string;
57
81
  provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
58
82
  apiKey?: string | undefined;
59
83
  maxInputTokens?: number | undefined;
84
+ reasoning?: {
85
+ variant: string;
86
+ budgetTokens?: number | undefined;
87
+ } | undefined;
88
+ temperature?: number | undefined;
60
89
  maxIterations?: number | undefined;
61
90
  baseURL?: string | undefined;
62
91
  maxOutputTokens?: number | undefined;
63
- temperature?: number | undefined;
64
92
  allowedMediaTypes?: string[] | undefined;
65
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
66
93
  }, {
67
94
  model: string;
68
95
  provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
69
96
  apiKey?: string | undefined;
70
97
  maxInputTokens?: number | undefined;
98
+ reasoning?: {
99
+ variant: string;
100
+ budgetTokens?: number | undefined;
101
+ } | undefined;
102
+ temperature?: number | undefined;
71
103
  maxIterations?: number | undefined;
72
104
  baseURL?: string | undefined;
73
105
  maxOutputTokens?: number | undefined;
74
- temperature?: number | undefined;
75
106
  allowedMediaTypes?: string[] | undefined;
76
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
77
107
  }>, {
78
108
  model: string;
79
109
  provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
80
110
  apiKey?: string | undefined;
81
111
  maxInputTokens?: number | undefined;
112
+ reasoning?: {
113
+ variant: string;
114
+ budgetTokens?: number | undefined;
115
+ } | undefined;
116
+ temperature?: number | undefined;
82
117
  maxIterations?: number | undefined;
83
118
  baseURL?: string | undefined;
84
119
  maxOutputTokens?: number | undefined;
85
- temperature?: number | undefined;
86
120
  allowedMediaTypes?: string[] | undefined;
87
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
88
121
  }, {
89
122
  model: string;
90
123
  provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova";
91
124
  apiKey?: string | undefined;
92
125
  maxInputTokens?: number | undefined;
126
+ reasoning?: {
127
+ variant: string;
128
+ budgetTokens?: number | undefined;
129
+ } | undefined;
130
+ temperature?: number | undefined;
93
131
  maxIterations?: number | undefined;
94
132
  baseURL?: string | undefined;
95
133
  maxOutputTokens?: number | undefined;
96
- temperature?: number | undefined;
97
134
  allowedMediaTypes?: string[] | undefined;
98
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
99
135
  }>;
100
136
  export type LLMConfig = z.input<typeof LLMConfigSchema>;
101
137
  export type ValidatedLLMConfig = z.output<typeof LLMConfigSchema>;
102
138
  export declare const LLMUpdatesSchema: z.ZodEffects<z.ZodObject<{
139
+ reasoning: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodObject<{
140
+ variant: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
141
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
142
+ }, "strict", z.ZodTypeAny, {
143
+ variant: string;
144
+ budgetTokens?: number | undefined;
145
+ }, {
146
+ variant: string;
147
+ budgetTokens?: number | undefined;
148
+ }>>>>;
103
149
  provider: z.ZodOptional<z.ZodEnum<["openai", "openai-compatible", "anthropic", "google", "groq", "xai", "cohere", "minimax", "glm", "openrouter", "litellm", "glama", "vertex", "bedrock", "local", "ollama", "dexto-nova"]>>;
104
150
  model: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
105
151
  apiKey: z.ZodOptional<z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>>;
@@ -109,51 +155,62 @@ export declare const LLMUpdatesSchema: z.ZodEffects<z.ZodObject<{
109
155
  maxOutputTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
110
156
  temperature: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
111
157
  allowedMediaTypes: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
112
- reasoningEffort: z.ZodOptional<z.ZodOptional<z.ZodEnum<["none", "minimal", "low", "medium", "high", "xhigh"]>>>;
113
158
  }, "strip", z.ZodTypeAny, {
159
+ apiKey?: string | undefined;
114
160
  model?: string | undefined;
115
161
  provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
116
- apiKey?: string | undefined;
117
162
  maxInputTokens?: number | undefined;
163
+ reasoning?: {
164
+ variant: string;
165
+ budgetTokens?: number | undefined;
166
+ } | null | undefined;
167
+ temperature?: number | undefined;
118
168
  maxIterations?: number | undefined;
119
169
  baseURL?: string | undefined;
120
170
  maxOutputTokens?: number | undefined;
121
- temperature?: number | undefined;
122
171
  allowedMediaTypes?: string[] | undefined;
123
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
124
172
  }, {
173
+ apiKey?: string | undefined;
125
174
  model?: string | undefined;
126
175
  provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
127
- apiKey?: string | undefined;
128
176
  maxInputTokens?: number | undefined;
177
+ reasoning?: {
178
+ variant: string;
179
+ budgetTokens?: number | undefined;
180
+ } | null | undefined;
181
+ temperature?: number | undefined;
129
182
  maxIterations?: number | undefined;
130
183
  baseURL?: string | undefined;
131
184
  maxOutputTokens?: number | undefined;
132
- temperature?: number | undefined;
133
185
  allowedMediaTypes?: string[] | undefined;
134
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
135
186
  }>, {
187
+ apiKey?: string | undefined;
136
188
  model?: string | undefined;
137
189
  provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
138
- apiKey?: string | undefined;
139
190
  maxInputTokens?: number | undefined;
191
+ reasoning?: {
192
+ variant: string;
193
+ budgetTokens?: number | undefined;
194
+ } | null | undefined;
195
+ temperature?: number | undefined;
140
196
  maxIterations?: number | undefined;
141
197
  baseURL?: string | undefined;
142
198
  maxOutputTokens?: number | undefined;
143
- temperature?: number | undefined;
144
199
  allowedMediaTypes?: string[] | undefined;
145
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
146
200
  }, {
201
+ apiKey?: string | undefined;
147
202
  model?: string | undefined;
148
203
  provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "minimax" | "glm" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | "dexto-nova" | undefined;
149
- apiKey?: string | undefined;
150
204
  maxInputTokens?: number | undefined;
205
+ reasoning?: {
206
+ variant: string;
207
+ budgetTokens?: number | undefined;
208
+ } | null | undefined;
209
+ temperature?: number | undefined;
151
210
  maxIterations?: number | undefined;
152
211
  baseURL?: string | undefined;
153
212
  maxOutputTokens?: number | undefined;
154
- temperature?: number | undefined;
155
213
  allowedMediaTypes?: string[] | undefined;
156
- reasoningEffort?: "low" | "none" | "minimal" | "medium" | "high" | "xhigh" | undefined;
157
214
  }>;
158
215
  export type LLMUpdates = z.input<typeof LLMUpdatesSchema>;
159
216
  export type { LLMUpdateContext } from '../llm/types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/llm/schemas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoFxB,4CAA4C;AAG5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBnB,CAAC;AAEd;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqH1B,CAAC;AAGH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAIlE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYvB,CAAC;AACP,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/llm/schemas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuFxB,4CAA4C;AAG5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBnB,CAAC;AAEd;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyJ1B,CAAC;AAGH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAIlE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4DvB,CAAC;AACP,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -14,6 +14,7 @@ import {
14
14
  getMaxInputTokensForModel
15
15
  } from "./registry/index.js";
16
16
  import { LLM_PROVIDERS } from "./types.js";
17
+ import { getReasoningProfile, supportsReasoningVariant } from "./reasoning/profile.js";
17
18
  const LLMConfigFields = {
18
19
  provider: z.enum(LLM_PROVIDERS).describe("LLM provider (e.g., 'openai', 'anthropic', 'google', 'groq')"),
19
20
  model: NonEmptyTrimmed.describe("Specific model name for the selected provider"),
@@ -31,18 +32,15 @@ const LLMConfigFields = {
31
32
  'MIME type patterns for media expansion (e.g., "image/*", "application/pdf"). If omitted, uses model capabilities from registry. Supports wildcards.'
32
33
  ),
33
34
  // Provider-specific options
34
- /**
35
- * OpenAI reasoning effort level for reasoning-capable models (o1, o3, codex, gpt-5.x).
36
- * Controls how many reasoning tokens the model generates before producing a response.
37
- * - 'none': No reasoning, fastest responses
38
- * - 'minimal': Barely any reasoning, very fast responses
39
- * - 'low': Light reasoning, fast responses
40
- * - 'medium': Balanced reasoning (OpenAI's recommended daily driver)
41
- * - 'high': Thorough reasoning for complex tasks
42
- * - 'xhigh': Extra high reasoning for quality-critical, non-latency-sensitive tasks
43
- */
44
- reasoningEffort: z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional().describe(
45
- "OpenAI reasoning effort level for reasoning models (o1, o3, codex). Options: 'none', 'minimal', 'low', 'medium' (recommended), 'high', 'xhigh'"
35
+ reasoning: z.object({
36
+ variant: NonEmptyTrimmed.describe(
37
+ "Model/provider-native reasoning variant (resolved by reasoning profile for the selected model)."
38
+ ),
39
+ budgetTokens: z.coerce.number().int().positive().optional().describe(
40
+ "Advanced escape hatch for budget-based providers (e.g., Anthropic/Gemini/Bedrock/OpenRouter)."
41
+ )
42
+ }).strict().optional().describe(
43
+ "Reasoning configuration using model/provider-native variants (tuning only; display is controlled separately)."
46
44
  )
47
45
  };
48
46
  const LLMConfigBaseSchema = z.object({
@@ -57,7 +55,7 @@ const LLMConfigBaseSchema = z.object({
57
55
  temperature: LLMConfigFields.temperature,
58
56
  allowedMediaTypes: LLMConfigFields.allowedMediaTypes,
59
57
  // Provider-specific options
60
- reasoningEffort: LLMConfigFields.reasoningEffort
58
+ reasoning: LLMConfigFields.reasoning
61
59
  }).strict();
62
60
  const LLMConfigSchema = LLMConfigBaseSchema.superRefine((data, ctx) => {
63
61
  const baseURLIsSet = data.baseURL != null && data.baseURL.trim() !== "";
@@ -147,8 +145,42 @@ const LLMConfigSchema = LLMConfigBaseSchema.superRefine((data, ctx) => {
147
145
  }
148
146
  }
149
147
  }
148
+ if (data.reasoning) {
149
+ const profile = getReasoningProfile(data.provider, data.model);
150
+ const variant = data.reasoning.variant;
151
+ const budgetTokens = data.reasoning.budgetTokens;
152
+ if (!supportsReasoningVariant(profile, variant)) {
153
+ ctx.addIssue({
154
+ code: z.ZodIssueCode.custom,
155
+ path: ["reasoning", "variant"],
156
+ message: `Reasoning variant '${variant}' is not supported for provider '${data.provider}' model '${data.model}'. Supported: ${profile.variants.map((entry) => entry.id).join(", ")}`,
157
+ params: {
158
+ code: LLMErrorCode.MODEL_INCOMPATIBLE,
159
+ scope: ErrorScope.LLM,
160
+ type: ErrorType.USER
161
+ }
162
+ });
163
+ }
164
+ if (typeof budgetTokens === "number" && !profile.supportsBudgetTokens) {
165
+ ctx.addIssue({
166
+ code: z.ZodIssueCode.custom,
167
+ path: ["reasoning", "budgetTokens"],
168
+ message: `Reasoning budgetTokens are not supported for provider '${data.provider}' model '${data.model}'. Remove reasoning.budgetTokens to use provider defaults.`,
169
+ params: {
170
+ code: LLMErrorCode.MODEL_INCOMPATIBLE,
171
+ scope: ErrorScope.LLM,
172
+ type: ErrorType.USER
173
+ }
174
+ });
175
+ }
176
+ }
150
177
  });
151
- const LLMUpdatesSchema = z.object({ ...LLMConfigFields }).partial().superRefine((data, ctx) => {
178
+ const LLMUpdatesSchema = z.object({
179
+ ...LLMConfigFields,
180
+ // Special-case: allow `null` as an explicit "clear reasoning config" sentinel for switch flows.
181
+ // Full configs (LLMConfigSchema) still require `reasoning` to be an object when present.
182
+ reasoning: LLMConfigFields.reasoning.nullable()
183
+ }).partial().superRefine((data, ctx) => {
152
184
  if (!data.model && !data.provider) {
153
185
  ctx.addIssue({
154
186
  code: z.ZodIssueCode.custom,
@@ -156,6 +188,35 @@ const LLMUpdatesSchema = z.object({ ...LLMConfigFields }).partial().superRefine(
156
188
  path: []
157
189
  });
158
190
  }
191
+ if (data.reasoning && data.reasoning !== null && typeof data.provider === "string" && typeof data.model === "string") {
192
+ const profile = getReasoningProfile(data.provider, data.model);
193
+ const variant = data.reasoning.variant;
194
+ const budgetTokens = data.reasoning.budgetTokens;
195
+ if (!supportsReasoningVariant(profile, variant)) {
196
+ ctx.addIssue({
197
+ code: z.ZodIssueCode.custom,
198
+ path: ["reasoning", "variant"],
199
+ message: `Reasoning variant '${variant}' is not supported for provider '${data.provider}' model '${data.model}'. Supported: ${profile.variants.map((entry) => entry.id).join(", ")}`,
200
+ params: {
201
+ code: LLMErrorCode.MODEL_INCOMPATIBLE,
202
+ scope: ErrorScope.LLM,
203
+ type: ErrorType.USER
204
+ }
205
+ });
206
+ }
207
+ if (typeof budgetTokens === "number" && !profile.supportsBudgetTokens) {
208
+ ctx.addIssue({
209
+ code: z.ZodIssueCode.custom,
210
+ path: ["reasoning", "budgetTokens"],
211
+ message: `Reasoning budgetTokens are not supported for provider '${data.provider}' model '${data.model}'. Remove reasoning.budgetTokens to use provider defaults.`,
212
+ params: {
213
+ code: LLMErrorCode.MODEL_INCOMPATIBLE,
214
+ scope: ErrorScope.LLM,
215
+ type: ErrorType.USER
216
+ }
217
+ });
218
+ }
219
+ }
159
220
  });
160
221
  export {
161
222
  LLMConfigBaseSchema,
@@ -24,6 +24,7 @@ __export(factory_exports, {
24
24
  module.exports = __toCommonJS(factory_exports);
25
25
  var import_errors = require("../errors.js");
26
26
  var import_openai = require("@ai-sdk/openai");
27
+ var import_openai_compatible = require("@ai-sdk/openai-compatible");
27
28
  var import_google = require("@ai-sdk/google");
28
29
  var import_anthropic = require("@ai-sdk/anthropic");
29
30
  var import_groq = require("@ai-sdk/groq");
@@ -31,11 +32,19 @@ var import_xai = require("@ai-sdk/xai");
31
32
  var import_google_vertex = require("@ai-sdk/google-vertex");
32
33
  var import_anthropic2 = require("@ai-sdk/google-vertex/anthropic");
33
34
  var import_amazon_bedrock = require("@ai-sdk/amazon-bedrock");
35
+ var import_ai_sdk_provider = require("@openrouter/ai-sdk-provider");
34
36
  var import_vercel = require("./vercel.js");
35
37
  var import_cohere = require("@ai-sdk/cohere");
36
38
  var import_ai_sdk_adapter = require("../providers/local/ai-sdk-adapter.js");
37
39
  var import_registry = require("../registry/index.js");
38
40
  var import_api_key_resolver = require("../../utils/api-key-resolver.js");
41
+ var import_anthropic_betas = require("../reasoning/anthropic-betas.js");
42
+ var import_anthropic_thinking = require("../reasoning/anthropic-thinking.js");
43
+ function isLanguageModel(value) {
44
+ if (!value || typeof value !== "object") return false;
45
+ const candidate = value;
46
+ return typeof candidate["modelId"] === "string" && (typeof candidate["doGenerate"] === "function" || typeof candidate["doStream"] === "function");
47
+ }
39
48
  const DEXTO_GATEWAY_HEADERS = {
40
49
  SESSION_ID: "X-Dexto-Session-ID",
41
50
  CLIENT_SOURCE: "X-Dexto-Source",
@@ -57,11 +66,29 @@ function createVercelModel(llmConfig, context) {
57
66
  if (!compatibleBaseURL) {
58
67
  throw import_errors.LLMError.baseUrlMissing("openai-compatible");
59
68
  }
60
- return (0, import_openai.createOpenAI)({ apiKey: apiKey ?? "", baseURL: compatibleBaseURL }).chat(model);
69
+ const provider2 = (0, import_openai_compatible.createOpenAICompatible)({
70
+ name: "openaiCompatible",
71
+ baseURL: compatibleBaseURL,
72
+ ...apiKey?.trim() ? { apiKey } : {}
73
+ });
74
+ return provider2.chatModel(model);
61
75
  }
62
76
  case "openrouter": {
63
77
  const orBaseURL = baseURL || "https://openrouter.ai/api/v1";
64
- return (0, import_openai.createOpenAI)({ apiKey: apiKey ?? "", baseURL: orBaseURL }).responses(model);
78
+ const provider2 = (0, import_ai_sdk_provider.createOpenRouter)({
79
+ apiKey: apiKey ?? "",
80
+ baseURL: orBaseURL,
81
+ compatibility: "strict"
82
+ });
83
+ const chatModel = provider2.chat(model);
84
+ if (!isLanguageModel(chatModel)) {
85
+ throw import_errors.LLMError.generationFailed(
86
+ "OpenRouter provider returned an invalid language model instance",
87
+ "openrouter",
88
+ model
89
+ );
90
+ }
91
+ return chatModel;
65
92
  }
66
93
  case "minimax": {
67
94
  const minimaxBaseURL = baseURL || "https://api.minimax.chat/v1";
@@ -92,9 +119,22 @@ function createVercelModel(llmConfig, context) {
92
119
  if (process.env.DEXTO_CLI_VERSION) {
93
120
  headers[DEXTO_GATEWAY_HEADERS.CLIENT_VERSION] = process.env.DEXTO_CLI_VERSION;
94
121
  }
95
- return (0, import_openai.createOpenAI)({ apiKey: apiKey ?? "", baseURL: dextoBaseURL, headers }).chat(
96
- model
97
- );
122
+ const provider2 = (0, import_ai_sdk_provider.createOpenRouter)({
123
+ apiKey: apiKey ?? "",
124
+ baseURL: dextoBaseURL,
125
+ headers,
126
+ // This is an OpenRouter-compatible gateway; keep strict mode to enable OR features.
127
+ compatibility: "strict"
128
+ });
129
+ const chatModel = provider2.chat(model);
130
+ if (!isLanguageModel(chatModel)) {
131
+ throw import_errors.LLMError.generationFailed(
132
+ "Dexto gateway provider returned an invalid language model instance",
133
+ "dexto-nova",
134
+ model
135
+ );
136
+ }
137
+ return chatModel;
98
138
  }
99
139
  case "vertex": {
100
140
  const projectId = process.env.GOOGLE_VERTEX_PROJECT;
@@ -106,9 +146,11 @@ function createVercelModel(llmConfig, context) {
106
146
  }
107
147
  const location = process.env.GOOGLE_VERTEX_LOCATION;
108
148
  if (model.includes("claude")) {
149
+ const headers = (0, import_anthropic_thinking.supportsAnthropicInterleavedThinking)(model) ? { [import_anthropic_betas.ANTHROPIC_BETA_HEADER]: import_anthropic_betas.ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0;
109
150
  return (0, import_anthropic2.createVertexAnthropic)({
110
151
  project: projectId,
111
- location: location || "us-east5"
152
+ location: location || "us-east5",
153
+ ...headers ? { headers } : {}
112
154
  })(model);
113
155
  }
114
156
  return (0, import_google_vertex.createVertex)({
@@ -132,8 +174,13 @@ function createVercelModel(llmConfig, context) {
132
174
  }
133
175
  return (0, import_amazon_bedrock.createAmazonBedrock)({ region })(modelId);
134
176
  }
135
- case "anthropic":
136
- return (0, import_anthropic.createAnthropic)({ apiKey: apiKey ?? "" })(model);
177
+ case "anthropic": {
178
+ const headers = (0, import_anthropic_thinking.supportsAnthropicInterleavedThinking)(model) ? { [import_anthropic_betas.ANTHROPIC_BETA_HEADER]: import_anthropic_betas.ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0;
179
+ return (0, import_anthropic.createAnthropic)({
180
+ apiKey: apiKey ?? "",
181
+ ...headers ? { headers } : {}
182
+ })(model);
183
+ }
137
184
  case "google":
138
185
  return (0, import_google.createGoogleGenerativeAI)({ apiKey: apiKey ?? "" })(model);
139
186
  case "groq":
@@ -1,7 +1,7 @@
1
1
  import { ToolManager } from '../../tools/tool-manager.js';
2
2
  import { ValidatedLLMConfig } from '../schemas.js';
3
3
  import { VercelLLMService } from './vercel.js';
4
- import { LanguageModel } from 'ai';
4
+ import type { LanguageModel } from 'ai';
5
5
  import { SessionEventBus } from '../../events/index.js';
6
6
  import type { ConversationHistoryProvider } from '../../session/history/types.js';
7
7
  import type { SystemPromptManager } from '../../systemPrompt/manager.js';
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAUnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAWvD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC7B,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC/B,aAAa,CAoLf;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,2BAA2B,EAC5C,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,0BAA0B,EAAE,eAAe,EACnE,MAAM,EAAE,MAAM,EACd,kBAAkB,CAAC,EAAE,OAAO,mCAAmC,EAAE,kBAAkB,GAAG,IAAI,GAC3F,gBAAgB,CAelB"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAYnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AA0BvD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC7B,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC/B,aAAa,CA6Nf;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,2BAA2B,EAC5C,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,0BAA0B,EAAE,eAAe,EACnE,MAAM,EAAE,MAAM,EACd,kBAAkB,CAAC,EAAE,OAAO,mCAAmC,EAAE,kBAAkB,GAAG,IAAI,GAC3F,gBAAgB,CAelB"}
@@ -1,6 +1,7 @@
1
1
  import "../../chunk-PTJYTZNU.js";
2
2
  import { LLMError } from "../errors.js";
3
3
  import { createOpenAI } from "@ai-sdk/openai";
4
+ import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
4
5
  import { createGoogleGenerativeAI } from "@ai-sdk/google";
5
6
  import { createAnthropic } from "@ai-sdk/anthropic";
6
7
  import { createGroq } from "@ai-sdk/groq";
@@ -8,11 +9,22 @@ import { createXai } from "@ai-sdk/xai";
8
9
  import { createVertex } from "@ai-sdk/google-vertex";
9
10
  import { createVertexAnthropic } from "@ai-sdk/google-vertex/anthropic";
10
11
  import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock";
12
+ import { createOpenRouter } from "@openrouter/ai-sdk-provider";
11
13
  import { VercelLLMService } from "./vercel.js";
12
14
  import { createCohere } from "@ai-sdk/cohere";
13
15
  import { createLocalLanguageModel } from "../providers/local/ai-sdk-adapter.js";
14
16
  import { requiresApiKey } from "../registry/index.js";
15
17
  import { getPrimaryApiKeyEnvVar, resolveApiKeyForProvider } from "../../utils/api-key-resolver.js";
18
+ import {
19
+ ANTHROPIC_BETA_HEADER,
20
+ ANTHROPIC_INTERLEAVED_THINKING_BETA
21
+ } from "../reasoning/anthropic-betas.js";
22
+ import { supportsAnthropicInterleavedThinking } from "../reasoning/anthropic-thinking.js";
23
+ function isLanguageModel(value) {
24
+ if (!value || typeof value !== "object") return false;
25
+ const candidate = value;
26
+ return typeof candidate["modelId"] === "string" && (typeof candidate["doGenerate"] === "function" || typeof candidate["doStream"] === "function");
27
+ }
16
28
  const DEXTO_GATEWAY_HEADERS = {
17
29
  SESSION_ID: "X-Dexto-Session-ID",
18
30
  CLIENT_SOURCE: "X-Dexto-Source",
@@ -34,11 +46,29 @@ function createVercelModel(llmConfig, context) {
34
46
  if (!compatibleBaseURL) {
35
47
  throw LLMError.baseUrlMissing("openai-compatible");
36
48
  }
37
- return createOpenAI({ apiKey: apiKey ?? "", baseURL: compatibleBaseURL }).chat(model);
49
+ const provider2 = createOpenAICompatible({
50
+ name: "openaiCompatible",
51
+ baseURL: compatibleBaseURL,
52
+ ...apiKey?.trim() ? { apiKey } : {}
53
+ });
54
+ return provider2.chatModel(model);
38
55
  }
39
56
  case "openrouter": {
40
57
  const orBaseURL = baseURL || "https://openrouter.ai/api/v1";
41
- return createOpenAI({ apiKey: apiKey ?? "", baseURL: orBaseURL }).responses(model);
58
+ const provider2 = createOpenRouter({
59
+ apiKey: apiKey ?? "",
60
+ baseURL: orBaseURL,
61
+ compatibility: "strict"
62
+ });
63
+ const chatModel = provider2.chat(model);
64
+ if (!isLanguageModel(chatModel)) {
65
+ throw LLMError.generationFailed(
66
+ "OpenRouter provider returned an invalid language model instance",
67
+ "openrouter",
68
+ model
69
+ );
70
+ }
71
+ return chatModel;
42
72
  }
43
73
  case "minimax": {
44
74
  const minimaxBaseURL = baseURL || "https://api.minimax.chat/v1";
@@ -69,9 +99,22 @@ function createVercelModel(llmConfig, context) {
69
99
  if (process.env.DEXTO_CLI_VERSION) {
70
100
  headers[DEXTO_GATEWAY_HEADERS.CLIENT_VERSION] = process.env.DEXTO_CLI_VERSION;
71
101
  }
72
- return createOpenAI({ apiKey: apiKey ?? "", baseURL: dextoBaseURL, headers }).chat(
73
- model
74
- );
102
+ const provider2 = createOpenRouter({
103
+ apiKey: apiKey ?? "",
104
+ baseURL: dextoBaseURL,
105
+ headers,
106
+ // This is an OpenRouter-compatible gateway; keep strict mode to enable OR features.
107
+ compatibility: "strict"
108
+ });
109
+ const chatModel = provider2.chat(model);
110
+ if (!isLanguageModel(chatModel)) {
111
+ throw LLMError.generationFailed(
112
+ "Dexto gateway provider returned an invalid language model instance",
113
+ "dexto-nova",
114
+ model
115
+ );
116
+ }
117
+ return chatModel;
75
118
  }
76
119
  case "vertex": {
77
120
  const projectId = process.env.GOOGLE_VERTEX_PROJECT;
@@ -83,9 +126,11 @@ function createVercelModel(llmConfig, context) {
83
126
  }
84
127
  const location = process.env.GOOGLE_VERTEX_LOCATION;
85
128
  if (model.includes("claude")) {
129
+ const headers = supportsAnthropicInterleavedThinking(model) ? { [ANTHROPIC_BETA_HEADER]: ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0;
86
130
  return createVertexAnthropic({
87
131
  project: projectId,
88
- location: location || "us-east5"
132
+ location: location || "us-east5",
133
+ ...headers ? { headers } : {}
89
134
  })(model);
90
135
  }
91
136
  return createVertex({
@@ -109,8 +154,13 @@ function createVercelModel(llmConfig, context) {
109
154
  }
110
155
  return createAmazonBedrock({ region })(modelId);
111
156
  }
112
- case "anthropic":
113
- return createAnthropic({ apiKey: apiKey ?? "" })(model);
157
+ case "anthropic": {
158
+ const headers = supportsAnthropicInterleavedThinking(model) ? { [ANTHROPIC_BETA_HEADER]: ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0;
159
+ return createAnthropic({
160
+ apiKey: apiKey ?? "",
161
+ ...headers ? { headers } : {}
162
+ })(model);
163
+ }
114
164
  case "google":
115
165
  return createGoogleGenerativeAI({ apiKey: apiKey ?? "" })(model);
116
166
  case "groq":
@@ -151,7 +151,7 @@ class VercelLLMService {
151
151
  temperature: this.config.temperature,
152
152
  baseURL: this.config.baseURL,
153
153
  // Provider-specific options
154
- reasoningEffort: this.config.reasoningEffort
154
+ reasoning: this.config.reasoning
155
155
  },
156
156
  { provider: this.config.provider, model: this.getModelId() },
157
157
  this.logger,
@@ -199,7 +199,7 @@ class VercelLLMService {
199
199
  const parts = typeof content === "string" ? [{ type: "text", text: content }] : content;
200
200
  await this.contextManager.addUserMessage(parts);
201
201
  const executor = this.createTurnExecutor(options?.signal);
202
- const contributorContext = { mcpManager: this.toolManager.getMcpManager() };
202
+ const contributorContext = await this.toolManager.buildContributorContext();
203
203
  const result = await executor.execute(contributorContext, true);
204
204
  return {
205
205
  text: result.text ?? ""
@@ -88,7 +88,7 @@ class VercelLLMService {
88
88
  temperature: this.config.temperature,
89
89
  baseURL: this.config.baseURL,
90
90
  // Provider-specific options
91
- reasoningEffort: this.config.reasoningEffort
91
+ reasoning: this.config.reasoning
92
92
  },
93
93
  { provider: this.config.provider, model: this.getModelId() },
94
94
  this.logger,
@@ -136,7 +136,7 @@ class VercelLLMService {
136
136
  const parts = typeof content === "string" ? [{ type: "text", text: content }] : content;
137
137
  await this.contextManager.addUserMessage(parts);
138
138
  const executor = this.createTurnExecutor(options?.signal);
139
- const contributorContext = { mcpManager: this.toolManager.getMcpManager() };
139
+ const contributorContext = await this.toolManager.buildContributorContext();
140
140
  const result = await executor.execute(contributorContext, true);
141
141
  return {
142
142
  text: result.text ?? ""