@deepstrike/sdk 0.1.7 → 0.1.9
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.
- package/README.md +19 -6
- package/dist/agent.js +4 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +10 -1
- package/dist/providers/anthropic.d.ts +11 -2
- package/dist/providers/anthropic.js +46 -10
- package/dist/providers/base.d.ts +3 -0
- package/dist/providers/base.js +79 -0
- package/dist/providers/catalog.d.ts +14 -0
- package/dist/providers/catalog.js +45 -0
- package/dist/providers/deepseek.d.ts +9 -0
- package/dist/providers/deepseek.js +64 -0
- package/dist/providers/gemini.d.ts +14 -0
- package/dist/providers/gemini.js +142 -0
- package/dist/providers/kimi.d.ts +7 -0
- package/dist/providers/kimi.js +8 -0
- package/dist/providers/minimax.d.ts +7 -0
- package/dist/providers/minimax.js +10 -0
- package/dist/providers/openai-chat.d.ts +27 -0
- package/dist/providers/openai-chat.js +41 -0
- package/dist/providers/openai-responses.d.ts +42 -0
- package/dist/providers/openai-responses.js +220 -0
- package/dist/providers/openai.d.ts +4 -36
- package/dist/providers/openai.js +12 -121
- package/dist/providers/profiles.d.ts +342 -0
- package/dist/providers/profiles.js +190 -0
- package/dist/providers/qwen.d.ts +18 -0
- package/dist/providers/qwen.js +103 -0
- package/dist/runtime/server.d.ts +7 -0
- package/dist/runtime/server.js +37 -0
- package/dist/types.d.ts +17 -2
- package/package.json +5 -3
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
export type ProviderId = "openai" | "minimax" | "deepseek" | "kimi" | "qwen" | "gemini";
|
|
2
|
+
export type EndpointProtocol = "anthropic-messages" | "openai-chat" | "openai-responses" | "gemini";
|
|
3
|
+
export interface EndpointProfile {
|
|
4
|
+
id: string;
|
|
5
|
+
providerId: ProviderId;
|
|
6
|
+
protocol: EndpointProtocol;
|
|
7
|
+
baseURL: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ModelProfile {
|
|
10
|
+
id: string;
|
|
11
|
+
providerId: ProviderId;
|
|
12
|
+
defaultEndpointId: string;
|
|
13
|
+
contextWindow?: number;
|
|
14
|
+
modalities: {
|
|
15
|
+
input: Array<"text" | "image" | "audio">;
|
|
16
|
+
output: Array<"text">;
|
|
17
|
+
};
|
|
18
|
+
tools: {
|
|
19
|
+
supported: boolean;
|
|
20
|
+
};
|
|
21
|
+
reasoning: {
|
|
22
|
+
supported: boolean;
|
|
23
|
+
preserveAcrossToolTurns: boolean;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const endpointProfiles: {
|
|
27
|
+
readonly "openai.chat": {
|
|
28
|
+
readonly id: "openai.chat";
|
|
29
|
+
readonly providerId: "openai";
|
|
30
|
+
readonly protocol: "openai-chat";
|
|
31
|
+
readonly baseURL: "https://api.openai.com/v1";
|
|
32
|
+
};
|
|
33
|
+
readonly "openai.responses": {
|
|
34
|
+
readonly id: "openai.responses";
|
|
35
|
+
readonly providerId: "openai";
|
|
36
|
+
readonly protocol: "openai-responses";
|
|
37
|
+
readonly baseURL: "https://api.openai.com/v1";
|
|
38
|
+
};
|
|
39
|
+
readonly "minimax.anthropic": {
|
|
40
|
+
readonly id: "minimax.anthropic";
|
|
41
|
+
readonly providerId: "minimax";
|
|
42
|
+
readonly protocol: "anthropic-messages";
|
|
43
|
+
readonly baseURL: "https://api.minimaxi.com/anthropic";
|
|
44
|
+
};
|
|
45
|
+
readonly "deepseek.openai": {
|
|
46
|
+
readonly id: "deepseek.openai";
|
|
47
|
+
readonly providerId: "deepseek";
|
|
48
|
+
readonly protocol: "openai-chat";
|
|
49
|
+
readonly baseURL: "https://api.deepseek.com";
|
|
50
|
+
};
|
|
51
|
+
readonly "kimi.openai": {
|
|
52
|
+
readonly id: "kimi.openai";
|
|
53
|
+
readonly providerId: "kimi";
|
|
54
|
+
readonly protocol: "openai-chat";
|
|
55
|
+
readonly baseURL: "https://api.moonshot.cn/v1";
|
|
56
|
+
};
|
|
57
|
+
readonly "qwen.dashscope": {
|
|
58
|
+
readonly id: "qwen.dashscope";
|
|
59
|
+
readonly providerId: "qwen";
|
|
60
|
+
readonly protocol: "openai-chat";
|
|
61
|
+
readonly baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1";
|
|
62
|
+
};
|
|
63
|
+
readonly "gemini.google": {
|
|
64
|
+
readonly id: "gemini.google";
|
|
65
|
+
readonly providerId: "gemini";
|
|
66
|
+
readonly protocol: "gemini";
|
|
67
|
+
readonly baseURL: "https://generativelanguage.googleapis.com";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare const modelProfiles: {
|
|
71
|
+
readonly "openai/gpt-4o": {
|
|
72
|
+
readonly id: "openai/gpt-4o";
|
|
73
|
+
readonly providerId: "openai";
|
|
74
|
+
readonly defaultEndpointId: "openai.chat";
|
|
75
|
+
readonly contextWindow: 128000;
|
|
76
|
+
readonly modalities: {
|
|
77
|
+
readonly input: ["text", "image"];
|
|
78
|
+
readonly output: ["text"];
|
|
79
|
+
};
|
|
80
|
+
readonly tools: {
|
|
81
|
+
readonly supported: true;
|
|
82
|
+
};
|
|
83
|
+
readonly reasoning: {
|
|
84
|
+
readonly supported: false;
|
|
85
|
+
readonly preserveAcrossToolTurns: false;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly "openai/gpt-4o-mini": {
|
|
89
|
+
readonly id: "openai/gpt-4o-mini";
|
|
90
|
+
readonly providerId: "openai";
|
|
91
|
+
readonly defaultEndpointId: "openai.chat";
|
|
92
|
+
readonly contextWindow: 128000;
|
|
93
|
+
readonly modalities: {
|
|
94
|
+
readonly input: ["text", "image"];
|
|
95
|
+
readonly output: ["text"];
|
|
96
|
+
};
|
|
97
|
+
readonly tools: {
|
|
98
|
+
readonly supported: true;
|
|
99
|
+
};
|
|
100
|
+
readonly reasoning: {
|
|
101
|
+
readonly supported: false;
|
|
102
|
+
readonly preserveAcrossToolTurns: false;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly "openai/gpt-5": {
|
|
106
|
+
readonly id: "openai/gpt-5";
|
|
107
|
+
readonly providerId: "openai";
|
|
108
|
+
readonly defaultEndpointId: "openai.responses";
|
|
109
|
+
readonly modalities: {
|
|
110
|
+
readonly input: ["text", "image"];
|
|
111
|
+
readonly output: ["text"];
|
|
112
|
+
};
|
|
113
|
+
readonly tools: {
|
|
114
|
+
readonly supported: true;
|
|
115
|
+
};
|
|
116
|
+
readonly reasoning: {
|
|
117
|
+
readonly supported: true;
|
|
118
|
+
readonly preserveAcrossToolTurns: true;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
readonly "openai/gpt-5-mini": {
|
|
122
|
+
readonly id: "openai/gpt-5-mini";
|
|
123
|
+
readonly providerId: "openai";
|
|
124
|
+
readonly defaultEndpointId: "openai.responses";
|
|
125
|
+
readonly modalities: {
|
|
126
|
+
readonly input: ["text", "image"];
|
|
127
|
+
readonly output: ["text"];
|
|
128
|
+
};
|
|
129
|
+
readonly tools: {
|
|
130
|
+
readonly supported: true;
|
|
131
|
+
};
|
|
132
|
+
readonly reasoning: {
|
|
133
|
+
readonly supported: true;
|
|
134
|
+
readonly preserveAcrossToolTurns: true;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
readonly "minimax/MiniMax-M2.7": {
|
|
138
|
+
readonly id: "minimax/MiniMax-M2.7";
|
|
139
|
+
readonly providerId: "minimax";
|
|
140
|
+
readonly defaultEndpointId: "minimax.anthropic";
|
|
141
|
+
readonly contextWindow: 204800;
|
|
142
|
+
readonly modalities: {
|
|
143
|
+
readonly input: ["text"];
|
|
144
|
+
readonly output: ["text"];
|
|
145
|
+
};
|
|
146
|
+
readonly tools: {
|
|
147
|
+
readonly supported: true;
|
|
148
|
+
};
|
|
149
|
+
readonly reasoning: {
|
|
150
|
+
readonly supported: true;
|
|
151
|
+
readonly preserveAcrossToolTurns: true;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
readonly "minimax/MiniMax-M2.5": {
|
|
155
|
+
readonly id: "minimax/MiniMax-M2.5";
|
|
156
|
+
readonly providerId: "minimax";
|
|
157
|
+
readonly defaultEndpointId: "minimax.anthropic";
|
|
158
|
+
readonly contextWindow: 204800;
|
|
159
|
+
readonly modalities: {
|
|
160
|
+
readonly input: ["text"];
|
|
161
|
+
readonly output: ["text"];
|
|
162
|
+
};
|
|
163
|
+
readonly tools: {
|
|
164
|
+
readonly supported: true;
|
|
165
|
+
};
|
|
166
|
+
readonly reasoning: {
|
|
167
|
+
readonly supported: true;
|
|
168
|
+
readonly preserveAcrossToolTurns: true;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
readonly "deepseek/deepseek-v4-flash": {
|
|
172
|
+
readonly id: "deepseek/deepseek-v4-flash";
|
|
173
|
+
readonly providerId: "deepseek";
|
|
174
|
+
readonly defaultEndpointId: "deepseek.openai";
|
|
175
|
+
readonly contextWindow: 1000000;
|
|
176
|
+
readonly modalities: {
|
|
177
|
+
readonly input: ["text"];
|
|
178
|
+
readonly output: ["text"];
|
|
179
|
+
};
|
|
180
|
+
readonly tools: {
|
|
181
|
+
readonly supported: true;
|
|
182
|
+
};
|
|
183
|
+
readonly reasoning: {
|
|
184
|
+
readonly supported: true;
|
|
185
|
+
readonly preserveAcrossToolTurns: true;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
readonly "deepseek/deepseek-v4-pro": {
|
|
189
|
+
readonly id: "deepseek/deepseek-v4-pro";
|
|
190
|
+
readonly providerId: "deepseek";
|
|
191
|
+
readonly defaultEndpointId: "deepseek.openai";
|
|
192
|
+
readonly contextWindow: 1000000;
|
|
193
|
+
readonly modalities: {
|
|
194
|
+
readonly input: ["text"];
|
|
195
|
+
readonly output: ["text"];
|
|
196
|
+
};
|
|
197
|
+
readonly tools: {
|
|
198
|
+
readonly supported: true;
|
|
199
|
+
};
|
|
200
|
+
readonly reasoning: {
|
|
201
|
+
readonly supported: true;
|
|
202
|
+
readonly preserveAcrossToolTurns: true;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
readonly "kimi/kimi-k2.5": {
|
|
206
|
+
readonly id: "kimi/kimi-k2.5";
|
|
207
|
+
readonly providerId: "kimi";
|
|
208
|
+
readonly defaultEndpointId: "kimi.openai";
|
|
209
|
+
readonly contextWindow: 256000;
|
|
210
|
+
readonly modalities: {
|
|
211
|
+
readonly input: ["text", "image"];
|
|
212
|
+
readonly output: ["text"];
|
|
213
|
+
};
|
|
214
|
+
readonly tools: {
|
|
215
|
+
readonly supported: true;
|
|
216
|
+
};
|
|
217
|
+
readonly reasoning: {
|
|
218
|
+
readonly supported: true;
|
|
219
|
+
readonly preserveAcrossToolTurns: false;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
readonly "kimi/kimi-k2.6": {
|
|
223
|
+
readonly id: "kimi/kimi-k2.6";
|
|
224
|
+
readonly providerId: "kimi";
|
|
225
|
+
readonly defaultEndpointId: "kimi.openai";
|
|
226
|
+
readonly modalities: {
|
|
227
|
+
readonly input: ["text"];
|
|
228
|
+
readonly output: ["text"];
|
|
229
|
+
};
|
|
230
|
+
readonly tools: {
|
|
231
|
+
readonly supported: true;
|
|
232
|
+
};
|
|
233
|
+
readonly reasoning: {
|
|
234
|
+
readonly supported: true;
|
|
235
|
+
readonly preserveAcrossToolTurns: false;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
readonly "qwen/qwen-max": {
|
|
239
|
+
readonly id: "qwen/qwen-max";
|
|
240
|
+
readonly providerId: "qwen";
|
|
241
|
+
readonly defaultEndpointId: "qwen.dashscope";
|
|
242
|
+
readonly contextWindow: 32768;
|
|
243
|
+
readonly modalities: {
|
|
244
|
+
readonly input: ["text", "image"];
|
|
245
|
+
readonly output: ["text"];
|
|
246
|
+
};
|
|
247
|
+
readonly tools: {
|
|
248
|
+
readonly supported: true;
|
|
249
|
+
};
|
|
250
|
+
readonly reasoning: {
|
|
251
|
+
readonly supported: false;
|
|
252
|
+
readonly preserveAcrossToolTurns: false;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
readonly "qwen/qwen-plus": {
|
|
256
|
+
readonly id: "qwen/qwen-plus";
|
|
257
|
+
readonly providerId: "qwen";
|
|
258
|
+
readonly defaultEndpointId: "qwen.dashscope";
|
|
259
|
+
readonly contextWindow: 131072;
|
|
260
|
+
readonly modalities: {
|
|
261
|
+
readonly input: ["text", "image"];
|
|
262
|
+
readonly output: ["text"];
|
|
263
|
+
};
|
|
264
|
+
readonly tools: {
|
|
265
|
+
readonly supported: true;
|
|
266
|
+
};
|
|
267
|
+
readonly reasoning: {
|
|
268
|
+
readonly supported: false;
|
|
269
|
+
readonly preserveAcrossToolTurns: false;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
readonly "qwen/qwq-plus": {
|
|
273
|
+
readonly id: "qwen/qwq-plus";
|
|
274
|
+
readonly providerId: "qwen";
|
|
275
|
+
readonly defaultEndpointId: "qwen.dashscope";
|
|
276
|
+
readonly contextWindow: 131072;
|
|
277
|
+
readonly modalities: {
|
|
278
|
+
readonly input: ["text"];
|
|
279
|
+
readonly output: ["text"];
|
|
280
|
+
};
|
|
281
|
+
readonly tools: {
|
|
282
|
+
readonly supported: true;
|
|
283
|
+
};
|
|
284
|
+
readonly reasoning: {
|
|
285
|
+
readonly supported: true;
|
|
286
|
+
readonly preserveAcrossToolTurns: false;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
readonly "gemini/gemini-2.0-flash": {
|
|
290
|
+
readonly id: "gemini/gemini-2.0-flash";
|
|
291
|
+
readonly providerId: "gemini";
|
|
292
|
+
readonly defaultEndpointId: "gemini.google";
|
|
293
|
+
readonly contextWindow: 1048576;
|
|
294
|
+
readonly modalities: {
|
|
295
|
+
readonly input: ["text", "image", "audio"];
|
|
296
|
+
readonly output: ["text"];
|
|
297
|
+
};
|
|
298
|
+
readonly tools: {
|
|
299
|
+
readonly supported: true;
|
|
300
|
+
};
|
|
301
|
+
readonly reasoning: {
|
|
302
|
+
readonly supported: false;
|
|
303
|
+
readonly preserveAcrossToolTurns: false;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
readonly "gemini/gemini-2.5-flash": {
|
|
307
|
+
readonly id: "gemini/gemini-2.5-flash";
|
|
308
|
+
readonly providerId: "gemini";
|
|
309
|
+
readonly defaultEndpointId: "gemini.google";
|
|
310
|
+
readonly contextWindow: 1048576;
|
|
311
|
+
readonly modalities: {
|
|
312
|
+
readonly input: ["text", "image", "audio"];
|
|
313
|
+
readonly output: ["text"];
|
|
314
|
+
};
|
|
315
|
+
readonly tools: {
|
|
316
|
+
readonly supported: true;
|
|
317
|
+
};
|
|
318
|
+
readonly reasoning: {
|
|
319
|
+
readonly supported: true;
|
|
320
|
+
readonly preserveAcrossToolTurns: false;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
readonly "gemini/gemini-2.5-pro": {
|
|
324
|
+
readonly id: "gemini/gemini-2.5-pro";
|
|
325
|
+
readonly providerId: "gemini";
|
|
326
|
+
readonly defaultEndpointId: "gemini.google";
|
|
327
|
+
readonly contextWindow: 1048576;
|
|
328
|
+
readonly modalities: {
|
|
329
|
+
readonly input: ["text", "image", "audio"];
|
|
330
|
+
readonly output: ["text"];
|
|
331
|
+
};
|
|
332
|
+
readonly tools: {
|
|
333
|
+
readonly supported: true;
|
|
334
|
+
};
|
|
335
|
+
readonly reasoning: {
|
|
336
|
+
readonly supported: true;
|
|
337
|
+
readonly preserveAcrossToolTurns: false;
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
export type ModelProfileId = keyof typeof modelProfiles;
|
|
342
|
+
export declare function getModelProfile(id: ModelProfileId): ModelProfile;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export const endpointProfiles = {
|
|
2
|
+
"openai.chat": {
|
|
3
|
+
id: "openai.chat",
|
|
4
|
+
providerId: "openai",
|
|
5
|
+
protocol: "openai-chat",
|
|
6
|
+
baseURL: "https://api.openai.com/v1",
|
|
7
|
+
},
|
|
8
|
+
"openai.responses": {
|
|
9
|
+
id: "openai.responses",
|
|
10
|
+
providerId: "openai",
|
|
11
|
+
protocol: "openai-responses",
|
|
12
|
+
baseURL: "https://api.openai.com/v1",
|
|
13
|
+
},
|
|
14
|
+
"minimax.anthropic": {
|
|
15
|
+
id: "minimax.anthropic",
|
|
16
|
+
providerId: "minimax",
|
|
17
|
+
protocol: "anthropic-messages",
|
|
18
|
+
baseURL: "https://api.minimaxi.com/anthropic",
|
|
19
|
+
},
|
|
20
|
+
"deepseek.openai": {
|
|
21
|
+
id: "deepseek.openai",
|
|
22
|
+
providerId: "deepseek",
|
|
23
|
+
protocol: "openai-chat",
|
|
24
|
+
baseURL: "https://api.deepseek.com",
|
|
25
|
+
},
|
|
26
|
+
"kimi.openai": {
|
|
27
|
+
id: "kimi.openai",
|
|
28
|
+
providerId: "kimi",
|
|
29
|
+
protocol: "openai-chat",
|
|
30
|
+
baseURL: "https://api.moonshot.cn/v1",
|
|
31
|
+
},
|
|
32
|
+
"qwen.dashscope": {
|
|
33
|
+
id: "qwen.dashscope",
|
|
34
|
+
providerId: "qwen",
|
|
35
|
+
protocol: "openai-chat",
|
|
36
|
+
baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
37
|
+
},
|
|
38
|
+
"gemini.google": {
|
|
39
|
+
id: "gemini.google",
|
|
40
|
+
providerId: "gemini",
|
|
41
|
+
protocol: "gemini",
|
|
42
|
+
baseURL: "https://generativelanguage.googleapis.com",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export const modelProfiles = {
|
|
46
|
+
"openai/gpt-4o": {
|
|
47
|
+
id: "openai/gpt-4o",
|
|
48
|
+
providerId: "openai",
|
|
49
|
+
defaultEndpointId: "openai.chat",
|
|
50
|
+
contextWindow: 128_000,
|
|
51
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
52
|
+
tools: { supported: true },
|
|
53
|
+
reasoning: { supported: false, preserveAcrossToolTurns: false },
|
|
54
|
+
},
|
|
55
|
+
"openai/gpt-4o-mini": {
|
|
56
|
+
id: "openai/gpt-4o-mini",
|
|
57
|
+
providerId: "openai",
|
|
58
|
+
defaultEndpointId: "openai.chat",
|
|
59
|
+
contextWindow: 128_000,
|
|
60
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
61
|
+
tools: { supported: true },
|
|
62
|
+
reasoning: { supported: false, preserveAcrossToolTurns: false },
|
|
63
|
+
},
|
|
64
|
+
"openai/gpt-5": {
|
|
65
|
+
id: "openai/gpt-5",
|
|
66
|
+
providerId: "openai",
|
|
67
|
+
defaultEndpointId: "openai.responses",
|
|
68
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
69
|
+
tools: { supported: true },
|
|
70
|
+
reasoning: { supported: true, preserveAcrossToolTurns: true },
|
|
71
|
+
},
|
|
72
|
+
"openai/gpt-5-mini": {
|
|
73
|
+
id: "openai/gpt-5-mini",
|
|
74
|
+
providerId: "openai",
|
|
75
|
+
defaultEndpointId: "openai.responses",
|
|
76
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
77
|
+
tools: { supported: true },
|
|
78
|
+
reasoning: { supported: true, preserveAcrossToolTurns: true },
|
|
79
|
+
},
|
|
80
|
+
"minimax/MiniMax-M2.7": {
|
|
81
|
+
id: "minimax/MiniMax-M2.7",
|
|
82
|
+
providerId: "minimax",
|
|
83
|
+
defaultEndpointId: "minimax.anthropic",
|
|
84
|
+
contextWindow: 204_800,
|
|
85
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
86
|
+
tools: { supported: true },
|
|
87
|
+
reasoning: { supported: true, preserveAcrossToolTurns: true },
|
|
88
|
+
},
|
|
89
|
+
"minimax/MiniMax-M2.5": {
|
|
90
|
+
id: "minimax/MiniMax-M2.5",
|
|
91
|
+
providerId: "minimax",
|
|
92
|
+
defaultEndpointId: "minimax.anthropic",
|
|
93
|
+
contextWindow: 204_800,
|
|
94
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
95
|
+
tools: { supported: true },
|
|
96
|
+
reasoning: { supported: true, preserveAcrossToolTurns: true },
|
|
97
|
+
},
|
|
98
|
+
"deepseek/deepseek-v4-flash": {
|
|
99
|
+
id: "deepseek/deepseek-v4-flash",
|
|
100
|
+
providerId: "deepseek",
|
|
101
|
+
defaultEndpointId: "deepseek.openai",
|
|
102
|
+
contextWindow: 1_000_000,
|
|
103
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
104
|
+
tools: { supported: true },
|
|
105
|
+
reasoning: { supported: true, preserveAcrossToolTurns: true },
|
|
106
|
+
},
|
|
107
|
+
"deepseek/deepseek-v4-pro": {
|
|
108
|
+
id: "deepseek/deepseek-v4-pro",
|
|
109
|
+
providerId: "deepseek",
|
|
110
|
+
defaultEndpointId: "deepseek.openai",
|
|
111
|
+
contextWindow: 1_000_000,
|
|
112
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
113
|
+
tools: { supported: true },
|
|
114
|
+
reasoning: { supported: true, preserveAcrossToolTurns: true },
|
|
115
|
+
},
|
|
116
|
+
"kimi/kimi-k2.5": {
|
|
117
|
+
id: "kimi/kimi-k2.5",
|
|
118
|
+
providerId: "kimi",
|
|
119
|
+
defaultEndpointId: "kimi.openai",
|
|
120
|
+
contextWindow: 256_000,
|
|
121
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
122
|
+
tools: { supported: true },
|
|
123
|
+
reasoning: { supported: true, preserveAcrossToolTurns: false },
|
|
124
|
+
},
|
|
125
|
+
"kimi/kimi-k2.6": {
|
|
126
|
+
id: "kimi/kimi-k2.6",
|
|
127
|
+
providerId: "kimi",
|
|
128
|
+
defaultEndpointId: "kimi.openai",
|
|
129
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
130
|
+
tools: { supported: true },
|
|
131
|
+
reasoning: { supported: true, preserveAcrossToolTurns: false },
|
|
132
|
+
},
|
|
133
|
+
"qwen/qwen-max": {
|
|
134
|
+
id: "qwen/qwen-max",
|
|
135
|
+
providerId: "qwen",
|
|
136
|
+
defaultEndpointId: "qwen.dashscope",
|
|
137
|
+
contextWindow: 32_768,
|
|
138
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
139
|
+
tools: { supported: true },
|
|
140
|
+
reasoning: { supported: false, preserveAcrossToolTurns: false },
|
|
141
|
+
},
|
|
142
|
+
"qwen/qwen-plus": {
|
|
143
|
+
id: "qwen/qwen-plus",
|
|
144
|
+
providerId: "qwen",
|
|
145
|
+
defaultEndpointId: "qwen.dashscope",
|
|
146
|
+
contextWindow: 131_072,
|
|
147
|
+
modalities: { input: ["text", "image"], output: ["text"] },
|
|
148
|
+
tools: { supported: true },
|
|
149
|
+
reasoning: { supported: false, preserveAcrossToolTurns: false },
|
|
150
|
+
},
|
|
151
|
+
"qwen/qwq-plus": {
|
|
152
|
+
id: "qwen/qwq-plus",
|
|
153
|
+
providerId: "qwen",
|
|
154
|
+
defaultEndpointId: "qwen.dashscope",
|
|
155
|
+
contextWindow: 131_072,
|
|
156
|
+
modalities: { input: ["text"], output: ["text"] },
|
|
157
|
+
tools: { supported: true },
|
|
158
|
+
reasoning: { supported: true, preserveAcrossToolTurns: false },
|
|
159
|
+
},
|
|
160
|
+
"gemini/gemini-2.0-flash": {
|
|
161
|
+
id: "gemini/gemini-2.0-flash",
|
|
162
|
+
providerId: "gemini",
|
|
163
|
+
defaultEndpointId: "gemini.google",
|
|
164
|
+
contextWindow: 1_048_576,
|
|
165
|
+
modalities: { input: ["text", "image", "audio"], output: ["text"] },
|
|
166
|
+
tools: { supported: true },
|
|
167
|
+
reasoning: { supported: false, preserveAcrossToolTurns: false },
|
|
168
|
+
},
|
|
169
|
+
"gemini/gemini-2.5-flash": {
|
|
170
|
+
id: "gemini/gemini-2.5-flash",
|
|
171
|
+
providerId: "gemini",
|
|
172
|
+
defaultEndpointId: "gemini.google",
|
|
173
|
+
contextWindow: 1_048_576,
|
|
174
|
+
modalities: { input: ["text", "image", "audio"], output: ["text"] },
|
|
175
|
+
tools: { supported: true },
|
|
176
|
+
reasoning: { supported: true, preserveAcrossToolTurns: false },
|
|
177
|
+
},
|
|
178
|
+
"gemini/gemini-2.5-pro": {
|
|
179
|
+
id: "gemini/gemini-2.5-pro",
|
|
180
|
+
providerId: "gemini",
|
|
181
|
+
defaultEndpointId: "gemini.google",
|
|
182
|
+
contextWindow: 1_048_576,
|
|
183
|
+
modalities: { input: ["text", "image", "audio"], output: ["text"] },
|
|
184
|
+
tools: { supported: true },
|
|
185
|
+
reasoning: { supported: true, preserveAcrossToolTurns: false },
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
export function getModelProfile(id) {
|
|
189
|
+
return modelProfiles[id];
|
|
190
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import type { LLMProvider, Message, StreamEvent, ToolSchema } from "../types.js";
|
|
3
|
+
import { CircuitBreaker } from "./base.js";
|
|
4
|
+
import { OpenAIChatAdapter } from "./openai-chat.js";
|
|
5
|
+
export declare class QwenProvider implements LLMProvider {
|
|
6
|
+
protected readonly model: string;
|
|
7
|
+
protected client: OpenAI;
|
|
8
|
+
protected circuit: CircuitBreaker;
|
|
9
|
+
protected maxRetries: number;
|
|
10
|
+
protected baseDelay: number;
|
|
11
|
+
protected readonly chat: OpenAIChatAdapter;
|
|
12
|
+
constructor(apiKey: string, model?: string, retry?: {
|
|
13
|
+
maxRetries: number;
|
|
14
|
+
baseDelay: number;
|
|
15
|
+
}, baseURL?: string);
|
|
16
|
+
complete(messages: Message[], tools: ToolSchema[]): Promise<Message>;
|
|
17
|
+
stream(messages: Message[], tools: ToolSchema[], extensions?: Record<string, unknown>): AsyncIterable<StreamEvent>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
import { withServerRuntimeGuard } from "../runtime/server.js";
|
|
3
|
+
import { CircuitBreaker } from "./base.js";
|
|
4
|
+
import { OpenAIChatAdapter } from "./openai-chat.js";
|
|
5
|
+
import { endpointProfiles } from "./profiles.js";
|
|
6
|
+
const QWEN_BASE = endpointProfiles["qwen.dashscope"].baseURL;
|
|
7
|
+
export class QwenProvider {
|
|
8
|
+
model;
|
|
9
|
+
client;
|
|
10
|
+
circuit;
|
|
11
|
+
maxRetries;
|
|
12
|
+
baseDelay;
|
|
13
|
+
chat = new OpenAIChatAdapter();
|
|
14
|
+
constructor(apiKey, model = "qwen-max", retry = { maxRetries: 3, baseDelay: 1000 }, baseURL = QWEN_BASE) {
|
|
15
|
+
this.model = model;
|
|
16
|
+
this.client = withServerRuntimeGuard(() => new OpenAI({ apiKey, baseURL }));
|
|
17
|
+
this.circuit = new CircuitBreaker();
|
|
18
|
+
this.maxRetries = retry.maxRetries;
|
|
19
|
+
this.baseDelay = retry.baseDelay;
|
|
20
|
+
}
|
|
21
|
+
async complete(messages, tools) {
|
|
22
|
+
if (this.circuit.isOpen())
|
|
23
|
+
throw new Error("Circuit breaker open");
|
|
24
|
+
const msgs = this.chat.buildMessages(messages);
|
|
25
|
+
let lastErr;
|
|
26
|
+
for (let i = 0; i < this.maxRetries; i++) {
|
|
27
|
+
try {
|
|
28
|
+
const resp = await this.client.chat.completions.create({
|
|
29
|
+
model: this.model,
|
|
30
|
+
messages: msgs,
|
|
31
|
+
...(tools.length ? { tools: this.chat.buildTools(tools) } : {}),
|
|
32
|
+
});
|
|
33
|
+
this.circuit.recordSuccess();
|
|
34
|
+
const choice = resp.choices[0].message;
|
|
35
|
+
const toolCalls = this.chat.normalizeToolCalls(choice.tool_calls ?? []);
|
|
36
|
+
return { role: "assistant", content: choice.content ?? "", tokenCount: resp.usage?.total_tokens, toolCalls };
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
lastErr = err;
|
|
40
|
+
this.circuit.recordFailure();
|
|
41
|
+
if (i < this.maxRetries - 1)
|
|
42
|
+
await new Promise(r => setTimeout(r, this.baseDelay * 2 ** i));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw lastErr;
|
|
46
|
+
}
|
|
47
|
+
async *stream(messages, tools, extensions) {
|
|
48
|
+
const enableThinking = Boolean(extensions?.enableThinking ?? extensions?.enable_thinking);
|
|
49
|
+
const thinkingBudget = extensions?.thinkingBudget ?? extensions?.thinking_budget;
|
|
50
|
+
const msgs = this.chat.buildMessages(messages);
|
|
51
|
+
const toolCallBufs = {};
|
|
52
|
+
const stream = await this.client.chat.completions.create({
|
|
53
|
+
model: this.model,
|
|
54
|
+
messages: msgs,
|
|
55
|
+
...(tools.length ? { tools: this.chat.buildTools(tools) } : {}),
|
|
56
|
+
stream: true,
|
|
57
|
+
stream_options: { include_usage: true },
|
|
58
|
+
...(enableThinking ? {
|
|
59
|
+
extra_body: {
|
|
60
|
+
enable_thinking: true,
|
|
61
|
+
...(typeof thinkingBudget === "number" ? { thinking_budget: thinkingBudget } : {}),
|
|
62
|
+
},
|
|
63
|
+
} : {}),
|
|
64
|
+
});
|
|
65
|
+
let totalTokens = 0;
|
|
66
|
+
for await (const chunk of stream) {
|
|
67
|
+
if (chunk.usage) {
|
|
68
|
+
totalTokens = chunk.usage.total_tokens;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const choice = chunk.choices[0];
|
|
72
|
+
if (!choice)
|
|
73
|
+
continue;
|
|
74
|
+
const delta = choice.delta;
|
|
75
|
+
if (delta.reasoning_content)
|
|
76
|
+
yield { type: "thinking_delta", delta: delta.reasoning_content };
|
|
77
|
+
if (delta.content)
|
|
78
|
+
yield { type: "text_delta", delta: delta.content };
|
|
79
|
+
for (const tc of delta.tool_calls ?? []) {
|
|
80
|
+
const idx = tc.index;
|
|
81
|
+
if (!toolCallBufs[idx])
|
|
82
|
+
toolCallBufs[idx] = { id: tc.id ?? "", name: "", argsBuf: "" };
|
|
83
|
+
if (tc.function?.name)
|
|
84
|
+
toolCallBufs[idx].name += tc.function.name;
|
|
85
|
+
toolCallBufs[idx].argsBuf += tc.function?.arguments ?? "";
|
|
86
|
+
}
|
|
87
|
+
if (choice.finish_reason === "tool_calls") {
|
|
88
|
+
for (const tb of Object.values(toolCallBufs)) {
|
|
89
|
+
let args = {};
|
|
90
|
+
try {
|
|
91
|
+
args = JSON.parse(tb.argsBuf || "{}");
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
args = {};
|
|
95
|
+
}
|
|
96
|
+
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (totalTokens > 0)
|
|
101
|
+
yield { type: "usage", totalTokens };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some server-side tools install browser globals into Node for DOM work. SDKs
|
|
3
|
+
* that probe those globals during construction can then misclassify the host as
|
|
4
|
+
* a browser, so hide them only for the synchronous server-only bootstrap and
|
|
5
|
+
* restore the process exactly as we found it afterward.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withServerRuntimeGuard<T>(fn: () => T): T;
|