@deepstrike/sdk 0.1.12 → 0.1.14

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 (55) hide show
  1. package/README.md +82 -52
  2. package/dist/collaboration/harness.js +6 -1
  3. package/dist/collaboration/modes/creator-verifier.d.ts +2 -2
  4. package/dist/collaboration/modes/creator-verifier.js +2 -2
  5. package/dist/collaboration/pool.d.ts +4 -35
  6. package/dist/collaboration/pool.js +18 -44
  7. package/dist/harness/harness.d.ts +19 -7
  8. package/dist/harness/harness.js +27 -22
  9. package/dist/index.d.ts +19 -7
  10. package/dist/index.js +15 -3
  11. package/dist/kernel.d.ts +1 -0
  12. package/dist/kernel.js +10 -1
  13. package/dist/memory/protocols.d.ts +0 -4
  14. package/dist/providers/anthropic.d.ts +7 -2
  15. package/dist/providers/anthropic.js +48 -9
  16. package/dist/providers/base.d.ts +1 -0
  17. package/dist/providers/base.js +6 -0
  18. package/dist/providers/deepseek.d.ts +4 -2
  19. package/dist/providers/deepseek.js +49 -1
  20. package/dist/providers/gemini.d.ts +4 -2
  21. package/dist/providers/gemini.js +24 -5
  22. package/dist/providers/kimi.d.ts +3 -1
  23. package/dist/providers/kimi.js +10 -0
  24. package/dist/providers/minimax.d.ts +3 -1
  25. package/dist/providers/minimax.js +8 -0
  26. package/dist/providers/ollama.d.ts +5 -2
  27. package/dist/providers/ollama.js +63 -7
  28. package/dist/providers/openai-responses.d.ts +4 -2
  29. package/dist/providers/openai-responses.js +23 -3
  30. package/dist/providers/openai.d.ts +4 -2
  31. package/dist/providers/openai.js +44 -3
  32. package/dist/providers/profiles.d.ts +502 -6
  33. package/dist/providers/profiles.js +225 -82
  34. package/dist/providers/qwen.d.ts +5 -2
  35. package/dist/providers/qwen.js +59 -11
  36. package/dist/runtime/credential-vault.d.ts +18 -0
  37. package/dist/runtime/credential-vault.js +33 -0
  38. package/dist/runtime/execution-plane.d.ts +38 -0
  39. package/dist/runtime/execution-plane.js +146 -0
  40. package/dist/runtime/mcp-proxy-plane.d.ts +51 -0
  41. package/dist/runtime/mcp-proxy-plane.js +204 -0
  42. package/dist/runtime/process-sandbox-plane.d.ts +32 -0
  43. package/dist/runtime/process-sandbox-plane.js +109 -0
  44. package/dist/runtime/remote-vpc-plane.d.ts +48 -0
  45. package/dist/runtime/remote-vpc-plane.js +82 -0
  46. package/dist/runtime/runner.d.ts +49 -0
  47. package/dist/runtime/runner.js +364 -0
  48. package/dist/runtime/session-log.d.ts +67 -0
  49. package/dist/runtime/session-log.js +84 -0
  50. package/dist/tools/index.d.ts +7 -2
  51. package/dist/tools/index.js +83 -0
  52. package/dist/types.d.ts +52 -1
  53. package/package.json +3 -2
  54. package/dist/agent.d.ts +0 -88
  55. package/dist/agent.js +0 -430
@@ -1,4 +1,10 @@
1
1
  export const endpointProfiles = {
2
+ "anthropic.messages": {
3
+ id: "anthropic.messages",
4
+ providerId: "anthropic",
5
+ protocol: "anthropic-messages",
6
+ baseURL: "https://api.anthropic.com",
7
+ },
2
8
  "openai.chat": {
3
9
  id: "openai.chat",
4
10
  providerId: "openai",
@@ -43,146 +49,283 @@ export const endpointProfiles = {
43
49
  },
44
50
  };
45
51
  export const modelProfiles = {
46
- "openai/gpt-4o": {
47
- id: "openai/gpt-4o",
48
- providerId: "openai",
49
- defaultEndpointId: "openai.chat",
50
- contextWindow: 128_000,
52
+ "anthropic/claude-opus-4-7": {
53
+ id: "anthropic/claude-opus-4-7",
54
+ providerId: "anthropic",
55
+ defaultEndpointId: "anthropic.messages",
56
+ contextWindow: 200_000,
57
+ modalities: { input: ["text", "image"], output: ["text"] },
58
+ tools: { supported: true },
59
+ reasoning: { supported: true, preserveAcrossToolTurns: true },
60
+ policy: { maxTurns: 50 },
61
+ },
62
+ "anthropic/claude-opus-4-6": {
63
+ id: "anthropic/claude-opus-4-6",
64
+ providerId: "anthropic",
65
+ defaultEndpointId: "anthropic.messages",
66
+ contextWindow: 200_000,
67
+ modalities: { input: ["text", "image"], output: ["text"] },
68
+ tools: { supported: true },
69
+ reasoning: { supported: true, preserveAcrossToolTurns: true },
70
+ policy: { maxTurns: 50 },
71
+ },
72
+ "anthropic/claude-sonnet-4-6": {
73
+ id: "anthropic/claude-sonnet-4-6",
74
+ providerId: "anthropic",
75
+ defaultEndpointId: "anthropic.messages",
76
+ contextWindow: 200_000,
77
+ modalities: { input: ["text", "image"], output: ["text"] },
78
+ tools: { supported: true },
79
+ reasoning: { supported: true, preserveAcrossToolTurns: false },
80
+ policy: { maxTurns: 25 },
81
+ },
82
+ "anthropic/claude-haiku-4-5": {
83
+ id: "anthropic/claude-haiku-4-5",
84
+ providerId: "anthropic",
85
+ defaultEndpointId: "anthropic.messages",
86
+ contextWindow: 200_000,
51
87
  modalities: { input: ["text", "image"], output: ["text"] },
52
88
  tools: { supported: true },
53
89
  reasoning: { supported: false, preserveAcrossToolTurns: false },
90
+ policy: { maxTurns: 15 },
91
+ },
92
+ // ── OpenAI ─────────────────────────────────────────────────────────────────
93
+ "openai/gpt-4o": {
94
+ id: "openai/gpt-4o", providerId: "openai", defaultEndpointId: "openai.chat",
95
+ contextWindow: 128_000,
96
+ modalities: { input: ["text", "image"], output: ["text"] },
97
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
98
+ policy: { maxTurns: 25 },
54
99
  },
55
100
  "openai/gpt-4o-mini": {
56
- id: "openai/gpt-4o-mini",
57
- providerId: "openai",
58
- defaultEndpointId: "openai.chat",
101
+ id: "openai/gpt-4o-mini", providerId: "openai", defaultEndpointId: "openai.chat",
59
102
  contextWindow: 128_000,
60
103
  modalities: { input: ["text", "image"], output: ["text"] },
61
- tools: { supported: true },
62
- reasoning: { supported: false, preserveAcrossToolTurns: false },
104
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
105
+ policy: { maxTurns: 15 },
106
+ },
107
+ "openai/gpt-4.1": {
108
+ id: "openai/gpt-4.1", providerId: "openai", defaultEndpointId: "openai.responses",
109
+ contextWindow: 1_047_576,
110
+ modalities: { input: ["text", "image"], output: ["text"] },
111
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
112
+ policy: { maxTurns: 35 },
113
+ },
114
+ "openai/gpt-4.1-mini": {
115
+ id: "openai/gpt-4.1-mini", providerId: "openai", defaultEndpointId: "openai.responses",
116
+ contextWindow: 1_047_576,
117
+ modalities: { input: ["text", "image"], output: ["text"] },
118
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
119
+ policy: { maxTurns: 20 },
120
+ },
121
+ "openai/gpt-4.1-nano": {
122
+ id: "openai/gpt-4.1-nano", providerId: "openai", defaultEndpointId: "openai.responses",
123
+ contextWindow: 1_047_576,
124
+ modalities: { input: ["text", "image"], output: ["text"] },
125
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
126
+ policy: { maxTurns: 15 },
63
127
  },
64
128
  "openai/gpt-5": {
65
- id: "openai/gpt-5",
66
- providerId: "openai",
67
- defaultEndpointId: "openai.responses",
129
+ id: "openai/gpt-5", providerId: "openai", defaultEndpointId: "openai.responses",
68
130
  modalities: { input: ["text", "image"], output: ["text"] },
69
- tools: { supported: true },
70
- reasoning: { supported: true, preserveAcrossToolTurns: true },
131
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
132
+ policy: { maxTurns: 50 },
71
133
  },
72
134
  "openai/gpt-5-mini": {
73
- id: "openai/gpt-5-mini",
74
- providerId: "openai",
75
- defaultEndpointId: "openai.responses",
135
+ id: "openai/gpt-5-mini", providerId: "openai", defaultEndpointId: "openai.responses",
76
136
  modalities: { input: ["text", "image"], output: ["text"] },
77
- tools: { supported: true },
78
- reasoning: { supported: true, preserveAcrossToolTurns: true },
137
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
138
+ policy: { maxTurns: 25 },
79
139
  },
140
+ "openai/o3": {
141
+ id: "openai/o3", providerId: "openai", defaultEndpointId: "openai.responses",
142
+ modalities: { input: ["text", "image"], output: ["text"] },
143
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
144
+ policy: { maxTurns: 50 },
145
+ },
146
+ "openai/o3-mini": {
147
+ id: "openai/o3-mini", providerId: "openai", defaultEndpointId: "openai.responses",
148
+ modalities: { input: ["text"], output: ["text"] },
149
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
150
+ policy: { maxTurns: 25 },
151
+ },
152
+ "openai/o4-mini": {
153
+ id: "openai/o4-mini", providerId: "openai", defaultEndpointId: "openai.responses",
154
+ modalities: { input: ["text", "image"], output: ["text"] },
155
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
156
+ policy: { maxTurns: 25 },
157
+ },
158
+ // ── MiniMax ────────────────────────────────────────────────────────────────
80
159
  "minimax/MiniMax-M2.7": {
81
- id: "minimax/MiniMax-M2.7",
82
- providerId: "minimax",
83
- defaultEndpointId: "minimax.anthropic",
160
+ id: "minimax/MiniMax-M2.7", providerId: "minimax", defaultEndpointId: "minimax.anthropic",
84
161
  contextWindow: 204_800,
85
162
  modalities: { input: ["text"], output: ["text"] },
86
- tools: { supported: true },
87
- reasoning: { supported: true, preserveAcrossToolTurns: true },
163
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
164
+ policy: { maxTurns: 35 },
88
165
  },
89
166
  "minimax/MiniMax-M2.5": {
90
- id: "minimax/MiniMax-M2.5",
91
- providerId: "minimax",
92
- defaultEndpointId: "minimax.anthropic",
167
+ id: "minimax/MiniMax-M2.5", providerId: "minimax", defaultEndpointId: "minimax.anthropic",
93
168
  contextWindow: 204_800,
94
169
  modalities: { input: ["text"], output: ["text"] },
95
- tools: { supported: true },
96
- reasoning: { supported: true, preserveAcrossToolTurns: true },
170
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
171
+ policy: { maxTurns: 25 },
172
+ },
173
+ "minimax/MiniMax-Text-01": {
174
+ id: "minimax/MiniMax-Text-01", providerId: "minimax", defaultEndpointId: "minimax.anthropic",
175
+ contextWindow: 1_000_000,
176
+ modalities: { input: ["text"], output: ["text"] },
177
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
178
+ policy: { maxTurns: 20 },
179
+ },
180
+ // ── DeepSeek ───────────────────────────────────────────────────────────────
181
+ "deepseek/deepseek-chat": {
182
+ id: "deepseek/deepseek-chat", providerId: "deepseek", defaultEndpointId: "deepseek.openai",
183
+ contextWindow: 64_000,
184
+ modalities: { input: ["text"], output: ["text"] },
185
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
186
+ policy: { maxTurns: 25 },
187
+ },
188
+ "deepseek/deepseek-reasoner": {
189
+ id: "deepseek/deepseek-reasoner", providerId: "deepseek", defaultEndpointId: "deepseek.openai",
190
+ contextWindow: 64_000,
191
+ modalities: { input: ["text"], output: ["text"] },
192
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
193
+ policy: { maxTurns: 50 },
97
194
  },
98
195
  "deepseek/deepseek-v4-flash": {
99
- id: "deepseek/deepseek-v4-flash",
100
- providerId: "deepseek",
101
- defaultEndpointId: "deepseek.openai",
196
+ id: "deepseek/deepseek-v4-flash", providerId: "deepseek", defaultEndpointId: "deepseek.openai",
102
197
  contextWindow: 1_000_000,
103
198
  modalities: { input: ["text"], output: ["text"] },
104
- tools: { supported: true },
105
- reasoning: { supported: true, preserveAcrossToolTurns: true },
199
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
200
+ policy: { maxTurns: 20 },
106
201
  },
107
202
  "deepseek/deepseek-v4-pro": {
108
- id: "deepseek/deepseek-v4-pro",
109
- providerId: "deepseek",
110
- defaultEndpointId: "deepseek.openai",
203
+ id: "deepseek/deepseek-v4-pro", providerId: "deepseek", defaultEndpointId: "deepseek.openai",
111
204
  contextWindow: 1_000_000,
112
205
  modalities: { input: ["text"], output: ["text"] },
113
- tools: { supported: true },
114
- reasoning: { supported: true, preserveAcrossToolTurns: true },
206
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: true },
207
+ policy: { maxTurns: 35 },
208
+ },
209
+ // ── Kimi ───────────────────────────────────────────────────────────────────
210
+ "kimi/moonshot-v1-8k": {
211
+ id: "kimi/moonshot-v1-8k", providerId: "kimi", defaultEndpointId: "kimi.openai",
212
+ contextWindow: 8_000,
213
+ modalities: { input: ["text"], output: ["text"] },
214
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
215
+ policy: { maxTurns: 15 },
216
+ },
217
+ "kimi/moonshot-v1-32k": {
218
+ id: "kimi/moonshot-v1-32k", providerId: "kimi", defaultEndpointId: "kimi.openai",
219
+ contextWindow: 32_000,
220
+ modalities: { input: ["text"], output: ["text"] },
221
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
222
+ policy: { maxTurns: 20 },
223
+ },
224
+ "kimi/moonshot-v1-128k": {
225
+ id: "kimi/moonshot-v1-128k", providerId: "kimi", defaultEndpointId: "kimi.openai",
226
+ contextWindow: 128_000,
227
+ modalities: { input: ["text", "image"], output: ["text"] },
228
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
229
+ policy: { maxTurns: 30 },
115
230
  },
116
231
  "kimi/kimi-k2.5": {
117
- id: "kimi/kimi-k2.5",
118
- providerId: "kimi",
119
- defaultEndpointId: "kimi.openai",
232
+ id: "kimi/kimi-k2.5", providerId: "kimi", defaultEndpointId: "kimi.openai",
120
233
  contextWindow: 256_000,
121
234
  modalities: { input: ["text", "image"], output: ["text"] },
122
- tools: { supported: true },
123
- reasoning: { supported: true, preserveAcrossToolTurns: false },
235
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
236
+ policy: { maxTurns: 30 },
124
237
  },
125
238
  "kimi/kimi-k2.6": {
126
- id: "kimi/kimi-k2.6",
127
- providerId: "kimi",
128
- defaultEndpointId: "kimi.openai",
239
+ id: "kimi/kimi-k2.6", providerId: "kimi", defaultEndpointId: "kimi.openai",
129
240
  modalities: { input: ["text"], output: ["text"] },
130
- tools: { supported: true },
131
- reasoning: { supported: true, preserveAcrossToolTurns: false },
241
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
242
+ policy: { maxTurns: 35 },
132
243
  },
244
+ // ── Qwen ───────────────────────────────────────────────────────────────────
133
245
  "qwen/qwen-max": {
134
- id: "qwen/qwen-max",
135
- providerId: "qwen",
136
- defaultEndpointId: "qwen.dashscope",
246
+ id: "qwen/qwen-max", providerId: "qwen", defaultEndpointId: "qwen.dashscope",
137
247
  contextWindow: 32_768,
138
248
  modalities: { input: ["text", "image"], output: ["text"] },
139
- tools: { supported: true },
140
- reasoning: { supported: false, preserveAcrossToolTurns: false },
249
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
250
+ policy: { maxTurns: 25 },
141
251
  },
142
252
  "qwen/qwen-plus": {
143
- id: "qwen/qwen-plus",
144
- providerId: "qwen",
145
- defaultEndpointId: "qwen.dashscope",
253
+ id: "qwen/qwen-plus", providerId: "qwen", defaultEndpointId: "qwen.dashscope",
146
254
  contextWindow: 131_072,
147
255
  modalities: { input: ["text", "image"], output: ["text"] },
148
- tools: { supported: true },
149
- reasoning: { supported: false, preserveAcrossToolTurns: false },
256
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
257
+ policy: { maxTurns: 20 },
150
258
  },
151
259
  "qwen/qwq-plus": {
152
- id: "qwen/qwq-plus",
153
- providerId: "qwen",
154
- defaultEndpointId: "qwen.dashscope",
260
+ id: "qwen/qwq-plus", providerId: "qwen", defaultEndpointId: "qwen.dashscope",
155
261
  contextWindow: 131_072,
156
262
  modalities: { input: ["text"], output: ["text"] },
157
- tools: { supported: true },
158
- reasoning: { supported: true, preserveAcrossToolTurns: false },
263
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
264
+ policy: { maxTurns: 40 },
159
265
  },
160
- "gemini/gemini-2.0-flash": {
161
- id: "gemini/gemini-2.0-flash",
162
- providerId: "gemini",
163
- defaultEndpointId: "gemini.google",
266
+ "qwen/qwen3-235b-a22b": {
267
+ id: "qwen/qwen3-235b-a22b", providerId: "qwen", defaultEndpointId: "qwen.dashscope",
268
+ contextWindow: 131_072,
269
+ modalities: { input: ["text"], output: ["text"] },
270
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
271
+ policy: { maxTurns: 35 },
272
+ },
273
+ "qwen/qwen3-72b": {
274
+ id: "qwen/qwen3-72b", providerId: "qwen", defaultEndpointId: "qwen.dashscope",
275
+ contextWindow: 131_072,
276
+ modalities: { input: ["text"], output: ["text"] },
277
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
278
+ policy: { maxTurns: 25 },
279
+ },
280
+ "qwen/qwen3-32b": {
281
+ id: "qwen/qwen3-32b", providerId: "qwen", defaultEndpointId: "qwen.dashscope",
282
+ contextWindow: 131_072,
283
+ modalities: { input: ["text"], output: ["text"] },
284
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
285
+ policy: { maxTurns: 20 },
286
+ },
287
+ // ── Gemini ─────────────────────────────────────────────────────────────────
288
+ "gemini/gemini-2.5-pro": {
289
+ id: "gemini/gemini-2.5-pro", providerId: "gemini", defaultEndpointId: "gemini.google",
164
290
  contextWindow: 1_048_576,
165
291
  modalities: { input: ["text", "image", "audio"], output: ["text"] },
166
- tools: { supported: true },
167
- reasoning: { supported: false, preserveAcrossToolTurns: false },
292
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
293
+ policy: { maxTurns: 35 },
168
294
  },
169
295
  "gemini/gemini-2.5-flash": {
170
- id: "gemini/gemini-2.5-flash",
171
- providerId: "gemini",
172
- defaultEndpointId: "gemini.google",
296
+ id: "gemini/gemini-2.5-flash", providerId: "gemini", defaultEndpointId: "gemini.google",
173
297
  contextWindow: 1_048_576,
174
298
  modalities: { input: ["text", "image", "audio"], output: ["text"] },
175
- tools: { supported: true },
176
- reasoning: { supported: true, preserveAcrossToolTurns: false },
299
+ tools: { supported: true }, reasoning: { supported: true, preserveAcrossToolTurns: false },
300
+ policy: { maxTurns: 20 },
177
301
  },
178
- "gemini/gemini-2.5-pro": {
179
- id: "gemini/gemini-2.5-pro",
180
- providerId: "gemini",
181
- defaultEndpointId: "gemini.google",
302
+ "gemini/gemini-2.0-flash": {
303
+ id: "gemini/gemini-2.0-flash", providerId: "gemini", defaultEndpointId: "gemini.google",
182
304
  contextWindow: 1_048_576,
183
305
  modalities: { input: ["text", "image", "audio"], output: ["text"] },
184
- tools: { supported: true },
185
- reasoning: { supported: true, preserveAcrossToolTurns: false },
306
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
307
+ policy: { maxTurns: 15 },
308
+ },
309
+ "gemini/gemini-2.0-flash-lite": {
310
+ id: "gemini/gemini-2.0-flash-lite", providerId: "gemini", defaultEndpointId: "gemini.google",
311
+ contextWindow: 1_048_576,
312
+ modalities: { input: ["text", "image", "audio"], output: ["text"] },
313
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
314
+ policy: { maxTurns: 10 },
315
+ },
316
+ "gemini/gemini-1.5-pro": {
317
+ id: "gemini/gemini-1.5-pro", providerId: "gemini", defaultEndpointId: "gemini.google",
318
+ contextWindow: 2_097_152,
319
+ modalities: { input: ["text", "image", "audio"], output: ["text"] },
320
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
321
+ policy: { maxTurns: 30 },
322
+ },
323
+ "gemini/gemini-1.5-flash": {
324
+ id: "gemini/gemini-1.5-flash", providerId: "gemini", defaultEndpointId: "gemini.google",
325
+ contextWindow: 1_048_576,
326
+ modalities: { input: ["text", "image", "audio"], output: ["text"] },
327
+ tools: { supported: true }, reasoning: { supported: false, preserveAcrossToolTurns: false },
328
+ policy: { maxTurns: 15 },
186
329
  },
187
330
  };
188
331
  export function getModelProfile(id) {
@@ -1,5 +1,5 @@
1
1
  import OpenAI from "openai";
2
- import type { LLMProvider, Message, RenderedContext, StreamEvent, ToolSchema } from "../types.js";
2
+ import type { LLMProvider, Message, RenderedContext, StreamEvent, ToolSchema, RuntimePolicy } from "../types.js";
3
3
  import { CircuitBreaker } from "./base.js";
4
4
  import { OpenAIChatAdapter } from "./openai-chat.js";
5
5
  export declare class QwenProvider implements LLMProvider {
@@ -13,6 +13,9 @@ export declare class QwenProvider implements LLMProvider {
13
13
  maxRetries: number;
14
14
  baseDelay: number;
15
15
  }, baseURL?: string);
16
- complete(context: RenderedContext, tools: ToolSchema[]): Promise<Message>;
16
+ runtimePolicy(): RuntimePolicy;
17
+ complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<Message>;
17
18
  stream(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): AsyncIterable<StreamEvent>;
19
+ private thinkingExtraBody;
20
+ private requestExtensions;
18
21
  }
@@ -1,9 +1,21 @@
1
1
  import OpenAI from "openai";
2
2
  import { withServerRuntimeGuard } from "../runtime/server.js";
3
- import { CircuitBreaker } from "./base.js";
3
+ import { CircuitBreaker, omitExtensionKeys } from "./base.js";
4
4
  import { OpenAIChatAdapter } from "./openai-chat.js";
5
5
  import { endpointProfiles } from "./profiles.js";
6
6
  const QWEN_BASE = endpointProfiles["qwen.dashscope"].baseURL;
7
+ const QWEN_POLICIES = {
8
+ "qwen-max": { maxTurns: 25 },
9
+ "qwen-plus": { maxTurns: 20 },
10
+ "qwen-turbo": { maxTurns: 15 },
11
+ "qwq-plus": { maxTurns: 40 },
12
+ "qwq-32b": { maxTurns: 35 },
13
+ "qwen3-235b-a22b": { maxTurns: 35 },
14
+ "qwen3-72b": { maxTurns: 25 },
15
+ "qwen3-32b": { maxTurns: 20 },
16
+ "qwen3-14b": { maxTurns: 15 },
17
+ "qwen3-8b": { maxTurns: 15 },
18
+ };
7
19
  export class QwenProvider {
8
20
  model;
9
21
  client;
@@ -18,17 +30,23 @@ export class QwenProvider {
18
30
  this.maxRetries = retry.maxRetries;
19
31
  this.baseDelay = retry.baseDelay;
20
32
  }
21
- async complete(context, tools) {
33
+ runtimePolicy() {
34
+ return QWEN_POLICIES[this.model] ?? {};
35
+ }
36
+ async complete(context, tools, extensions) {
22
37
  if (this.circuit.isOpen())
23
38
  throw new Error("Circuit breaker open");
24
39
  const msgs = this.chat.buildMessages(context);
40
+ const extraBody = this.thinkingExtraBody(extensions);
25
41
  let lastErr;
26
42
  for (let i = 0; i < this.maxRetries; i++) {
27
43
  try {
28
44
  const resp = await this.client.chat.completions.create({
45
+ ...this.requestExtensions(extensions),
29
46
  model: this.model,
30
47
  messages: msgs,
31
48
  ...(tools.length ? { tools: this.chat.buildTools(tools) } : {}),
49
+ ...(extraBody ? { extra_body: extraBody } : {}),
32
50
  });
33
51
  this.circuit.recordSuccess();
34
52
  const choice = resp.choices[0].message;
@@ -45,22 +63,18 @@ export class QwenProvider {
45
63
  throw lastErr;
46
64
  }
47
65
  async *stream(context, tools, extensions) {
48
- const enableThinking = Boolean(extensions?.enableThinking ?? extensions?.enable_thinking);
49
- const thinkingBudget = extensions?.thinkingBudget ?? extensions?.thinking_budget;
50
66
  const msgs = this.chat.buildMessages(context);
51
67
  const toolCallBufs = {};
68
+ const emittedToolCallIndexes = new Set();
69
+ const extraBody = this.thinkingExtraBody(extensions);
52
70
  const stream = await this.client.chat.completions.create({
71
+ ...this.requestExtensions(extensions),
53
72
  model: this.model,
54
73
  messages: msgs,
55
74
  ...(tools.length ? { tools: this.chat.buildTools(tools) } : {}),
56
75
  stream: true,
57
76
  stream_options: { include_usage: true },
58
- ...(enableThinking ? {
59
- extra_body: {
60
- enable_thinking: true,
61
- ...(typeof thinkingBudget === "number" ? { thinking_budget: thinkingBudget } : {}),
62
- },
63
- } : {}),
77
+ ...(extraBody ? { extra_body: extraBody } : {}),
64
78
  });
65
79
  let totalTokens = 0;
66
80
  for await (const chunk of stream) {
@@ -85,7 +99,10 @@ export class QwenProvider {
85
99
  toolCallBufs[idx].argsBuf += tc.function?.arguments ?? "";
86
100
  }
87
101
  if (choice.finish_reason === "tool_calls") {
88
- for (const tb of Object.values(toolCallBufs)) {
102
+ for (const [index, tb] of Object.entries(toolCallBufs)) {
103
+ const idx = Number(index);
104
+ if (emittedToolCallIndexes.has(idx))
105
+ continue;
89
106
  let args = {};
90
107
  try {
91
108
  args = JSON.parse(tb.argsBuf || "{}");
@@ -93,11 +110,42 @@ export class QwenProvider {
93
110
  catch {
94
111
  args = {};
95
112
  }
113
+ emittedToolCallIndexes.add(idx);
96
114
  yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
97
115
  }
98
116
  }
99
117
  }
118
+ for (const [index, tb] of Object.entries(toolCallBufs)) {
119
+ const idx = Number(index);
120
+ if (emittedToolCallIndexes.has(idx))
121
+ continue;
122
+ let args = {};
123
+ try {
124
+ args = JSON.parse(tb.argsBuf || "{}");
125
+ }
126
+ catch {
127
+ args = {};
128
+ }
129
+ emittedToolCallIndexes.add(idx);
130
+ yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
131
+ }
100
132
  if (totalTokens > 0)
101
133
  yield { type: "usage", totalTokens };
102
134
  }
135
+ thinkingExtraBody(extensions) {
136
+ const enableThinking = Boolean(extensions?.enableThinking ?? extensions?.enable_thinking);
137
+ const thinkingBudget = extensions?.thinkingBudget ?? extensions?.thinking_budget;
138
+ if (!enableThinking)
139
+ return undefined;
140
+ return {
141
+ enable_thinking: true,
142
+ ...(typeof thinkingBudget === "number" ? { thinking_budget: thinkingBudget } : {}),
143
+ };
144
+ }
145
+ requestExtensions(extensions) {
146
+ return omitExtensionKeys(extensions, [
147
+ "model", "messages", "tools", "stream", "stream_options", "extra_body",
148
+ "enableThinking", "enable_thinking", "thinkingBudget", "thinking_budget",
149
+ ]);
150
+ }
103
151
  }
@@ -0,0 +1,18 @@
1
+ export interface CredentialVault {
2
+ get(key: string): Promise<string | undefined>;
3
+ }
4
+ export declare class EnvCredentialVault implements CredentialVault {
5
+ get(key: string): Promise<string | undefined>;
6
+ }
7
+ export declare class InMemoryCredentialVault implements CredentialVault {
8
+ private store;
9
+ constructor(init?: Record<string, string>);
10
+ set(key: string, value: string): this;
11
+ get(key: string): Promise<string | undefined>;
12
+ }
13
+ /** Tries each vault in order, returning the first defined value. */
14
+ export declare class ChainedCredentialVault implements CredentialVault {
15
+ private readonly vaults;
16
+ constructor(vaults: CredentialVault[]);
17
+ get(key: string): Promise<string | undefined>;
18
+ }
@@ -0,0 +1,33 @@
1
+ export class EnvCredentialVault {
2
+ async get(key) {
3
+ return process.env[key];
4
+ }
5
+ }
6
+ export class InMemoryCredentialVault {
7
+ store;
8
+ constructor(init) {
9
+ this.store = new Map(Object.entries(init ?? {}));
10
+ }
11
+ set(key, value) {
12
+ this.store.set(key, value);
13
+ return this;
14
+ }
15
+ async get(key) {
16
+ return this.store.get(key);
17
+ }
18
+ }
19
+ /** Tries each vault in order, returning the first defined value. */
20
+ export class ChainedCredentialVault {
21
+ vaults;
22
+ constructor(vaults) {
23
+ this.vaults = vaults;
24
+ }
25
+ async get(key) {
26
+ for (const vault of this.vaults) {
27
+ const val = await vault.get(key);
28
+ if (val !== undefined)
29
+ return val;
30
+ }
31
+ return undefined;
32
+ }
33
+ }
@@ -0,0 +1,38 @@
1
+ import type { ToolCall, ToolSchema, StreamEvent, ToolSuspendEvent } from "../types.js";
2
+ import type { RegisteredTool } from "../tools/index.js";
3
+ import type { DreamStore } from "../memory/protocols.js";
4
+ import type { KnowledgeSource } from "../knowledge/source.js";
5
+ export interface RunContext {
6
+ agentId?: string;
7
+ skillDir?: string;
8
+ dreamStore?: DreamStore;
9
+ knowledgeSource?: KnowledgeSource;
10
+ governance?: {
11
+ setTime?(nowMs: bigint): void;
12
+ evaluate(name: string, argsJson: string): {
13
+ kind: string;
14
+ reason?: string;
15
+ retryAfterMs?: number;
16
+ };
17
+ };
18
+ onToolSuspend?: (event: ToolSuspendEvent) => Promise<unknown> | unknown;
19
+ }
20
+ export interface ExecutionPlane {
21
+ register(...tools: RegisteredTool[]): this;
22
+ unregister(name: string): this;
23
+ schemas(): ToolSchema[];
24
+ /**
25
+ * Execute a batch of calls. Yields StreamEvents during execution.
26
+ * Guarantees exactly one `tool_result` event per call in `calls`.
27
+ * The runner collects those events to build ToolResult[] for the kernel.
28
+ */
29
+ executeAll(calls: ToolCall[], ctx: RunContext): AsyncIterable<StreamEvent>;
30
+ }
31
+ export declare class LocalExecutionPlane implements ExecutionPlane {
32
+ private tools;
33
+ register(...tools: RegisteredTool[]): this;
34
+ unregister(name: string): this;
35
+ schemas(): ToolSchema[];
36
+ executeAll(calls: ToolCall[], ctx: RunContext): AsyncIterable<StreamEvent>;
37
+ private executeSingle;
38
+ }