@metorial/sdk 1.1.1 → 2.0.0

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/dist/index.cjs CHANGED
@@ -2,440 +2,168 @@
2
2
 
3
3
  var core = require('@metorial/core');
4
4
  var mcpSession = require('@metorial/mcp-session');
5
- var openai = require('@metorial/openai');
6
- var anthropic = require('@metorial/anthropic');
7
- var deepseek = require('@metorial/deepseek');
8
- var google = require('@metorial/google');
9
- var mistral = require('@metorial/mistral');
10
- var xai = require('@metorial/xai');
11
- var togetherai = require('@metorial/togetherai');
12
5
 
13
6
  // src/metorial.ts
14
- var runWithOpenAI = async (config) => {
15
- let {
16
- message,
17
- serverDeployments,
18
- client,
19
- model,
20
- maxSteps = 25,
21
- tools: requestedTools,
22
- withProviderSession,
23
- ...openaiOptions
24
- } = config;
25
- return withProviderSession(
26
- openai.metorialOpenAI.chatCompletions,
27
- {
28
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
29
- },
30
- async (session) => {
31
- let tools = requestedTools ? session.tools.filter((t) => requestedTools.includes(t.name)) : session.tools;
32
- let messages = [
33
- { role: "user", content: message }
34
- ];
35
- for (let step = 0; step < maxSteps; step++) {
36
- let response = await client.chat.completions.create({
37
- model,
38
- messages,
39
- tools,
40
- ...openaiOptions
41
- });
42
- let choice = response.choices[0];
43
- if (!choice.message.tool_calls) {
44
- return {
45
- text: choice.message.content || "",
46
- steps: step + 1
47
- };
48
- }
49
- let toolResponses = await session.callTools(choice.message.tool_calls);
50
- messages.push(
51
- { role: "assistant", tool_calls: choice.message.tool_calls },
52
- ...toolResponses
53
- );
54
- }
55
- throw new Error(`Max steps (${maxSteps}) reached without final response`);
56
- }
57
- );
58
- };
59
- var runWithAnthropic = async (config) => {
60
- let {
61
- message,
62
- serverDeployments,
63
- client,
64
- model,
65
- maxSteps = 25,
66
- tools: requestedTools,
67
- withProviderSession,
68
- max_tokens = 4096,
69
- ...anthropicOptions
70
- } = config;
71
- return withProviderSession(
72
- anthropic.metorialAnthropic,
73
- {
74
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
75
- },
76
- async (session) => {
77
- let tools = requestedTools ? session.tools.filter((t) => requestedTools.includes(t.name)) : session.tools;
78
- let messages = [
79
- { role: "user", content: message }
80
- ];
81
- let uniqueTools = Array.from(new Map(tools.map((t) => [t.name, t])).values());
82
- for (let step = 0; step < maxSteps; step++) {
83
- let response = await client.messages.create({
84
- model,
85
- max_tokens,
86
- messages,
87
- tools: uniqueTools,
88
- ...anthropicOptions
89
- });
90
- if (response.stop_reason !== "tool_use") {
91
- let textContent = response.content.find(
92
- (block) => block.type === "text"
93
- );
94
- return {
95
- text: (textContent == null ? void 0 : textContent.text) || "",
96
- steps: step + 1
97
- };
98
- }
99
- let toolUseBlocks = response.content.filter(
100
- (block) => block.type === "tool_use"
101
- );
102
- let toolResponse = await session.callTools(toolUseBlocks);
103
- let toolResponseMessage = {
104
- role: "user",
105
- content: toolResponse.content.map((block) => ({
106
- type: "tool_result",
107
- tool_use_id: block.tool_use_id,
108
- content: block.content
109
- }))
110
- };
111
- messages.push(
112
- { role: "assistant", content: response.content },
113
- toolResponseMessage
114
- );
115
- }
116
- throw new Error(`Max steps (${maxSteps}) reached without final response`);
117
- }
118
- );
119
- };
120
- var runWithDeepSeek = async (config) => {
121
- let {
122
- message,
123
- serverDeployments,
124
- client,
125
- model,
126
- maxSteps = 25,
127
- tools: requestedTools,
128
- withProviderSession,
129
- ...deepseekOptions
130
- } = config;
131
- return withProviderSession(
132
- deepseek.metorialDeepseek,
133
- {
134
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
135
- },
136
- async (session) => {
137
- let tools = requestedTools ? session.tools.filter((t) => {
138
- var _a;
139
- return requestedTools.includes(((_a = t.function) == null ? void 0 : _a.name) || t.name);
140
- }) : session.tools;
141
- let uniqueTools = Array.from(
142
- new Map(tools.map((t) => {
143
- var _a;
144
- return [((_a = t.function) == null ? void 0 : _a.name) || t.name, t];
145
- })).values()
146
- );
147
- let messages = [
148
- { role: "user", content: message }
149
- ];
150
- for (let step = 0; step < maxSteps; step++) {
151
- let response = await client.chat.completions.create({
152
- model,
153
- messages,
154
- tools: uniqueTools,
155
- ...deepseekOptions
156
- });
157
- let choice = response.choices[0];
158
- if (!choice.message.tool_calls || choice.message.tool_calls.length === 0) {
159
- return {
160
- text: choice.message.content || "",
161
- steps: step + 1
162
- };
163
- }
164
- let toolResponses = await session.callTools(choice.message.tool_calls);
165
- messages.push(
166
- { role: "assistant", tool_calls: choice.message.tool_calls },
167
- ...toolResponses
168
- );
169
- }
170
- throw new Error(`Max steps (${maxSteps}) reached without final response`);
171
- }
172
- );
173
- };
174
- var runWithGoogle = async (config) => {
175
- let {
176
- message,
177
- serverDeployments,
178
- client,
179
- model,
180
- maxSteps = 25,
181
- tools: requestedTools,
182
- withProviderSession,
183
- ...googleOptions
184
- } = config;
185
- return withProviderSession(
186
- google.metorialGoogle,
187
- {
188
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
189
- },
190
- async (session) => {
191
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
192
- let tools = requestedTools ? session.tools.filter((t) => requestedTools.includes(t.name)) : session.tools;
193
- let response = await client.models.generateContent({
194
- model,
195
- contents: [
196
- {
197
- role: "user",
198
- parts: [{ text: message }]
199
- }
200
- ],
201
- config: {
202
- tools,
203
- ...googleOptions
204
- }
205
- });
206
- let text = (_e = (_d = (_c = (_b = (_a = response.candidates) == null ? void 0 : _a[0]) == null ? void 0 : _b.content) == null ? void 0 : _c.parts) == null ? void 0 : _d[0]) == null ? void 0 : _e.text;
207
- let functionCalls = (_i = (_h = (_g = (_f = response.candidates) == null ? void 0 : _f[0]) == null ? void 0 : _g.content) == null ? void 0 : _h.parts) == null ? void 0 : _i.filter((part) => part.functionCall).map((part) => part.functionCall);
208
- if (functionCalls && functionCalls.length > 0) {
209
- let toolResponses = await session.callTools(functionCalls);
210
- return {
211
- text: text || "",
212
- toolResponses,
213
- steps: 1
214
- };
215
- }
216
- return {
217
- text: text || "",
218
- steps: 1
219
- };
7
+ var Metorial = class {
8
+ constructor(init) {
9
+ let apiHost = init.apiHost;
10
+ let mcpHost = init.mcpHost;
11
+ if (mcpHost && !apiHost) {
12
+ apiHost = mcpHost.replace("://connect.", "://api.");
220
13
  }
221
- );
222
- };
223
- var extractTextFromContent = (content) => {
224
- if (typeof content === "string") {
225
- return content;
14
+ this.pulsarSdk = core.createMetorialPulsarCoreSDK({ ...init, apiHost });
15
+ this.magnetarSdk = core.createMetorialMagnetarCoreSDK({ ...init, apiHost, mcpHost });
226
16
  }
227
- if (Array.isArray(content)) {
228
- return content.filter((chunk) => chunk && typeof chunk === "object").map((chunk) => chunk.text || chunk.content || JSON.stringify(chunk)).join("");
17
+ // ── Magnetar (default) ───────────────────────────────────────────
18
+ get providers() {
19
+ return this.magnetarSdk.providers;
229
20
  }
230
- return "";
231
- };
232
- var runWithMistral = async (config) => {
233
- let {
234
- message,
235
- serverDeployments,
236
- client,
237
- model,
238
- maxSteps = 25,
239
- tools: requestedTools,
240
- withProviderSession,
241
- ...mistralOptions
242
- } = config;
243
- return withProviderSession(
244
- mistral.metorialMistral,
245
- {
246
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
247
- },
248
- async (session) => {
249
- let tools = requestedTools ? session.tools.filter((t) => {
250
- var _a;
251
- return requestedTools.includes(((_a = t.function) == null ? void 0 : _a.name) || t.name);
252
- }) : session.tools;
253
- let fixedTools = tools.map((tool) => {
254
- var _a;
255
- if ((_a = tool.function) == null ? void 0 : _a.parameters) {
256
- let fixedParams = { ...tool.function.parameters };
257
- fixedParams.additionalProperties = false;
258
- if (fixedParams.properties) {
259
- Object.values(fixedParams.properties).forEach((prop) => {
260
- if (prop && typeof prop === "object" && prop.type === "object") {
261
- prop.additionalProperties = false;
262
- }
263
- });
264
- }
265
- return {
266
- ...tool,
267
- function: {
268
- ...tool.function,
269
- parameters: fixedParams
270
- }
271
- };
272
- }
273
- return tool;
274
- });
275
- let messages = [
276
- { role: "user", content: message }
277
- ];
278
- for (let step = 0; step < maxSteps; step++) {
279
- let response = await client.chat.complete({
280
- model,
281
- messages,
282
- tools: fixedTools,
283
- ...mistralOptions
284
- });
285
- let choice = response.choices[0];
286
- let toolCalls = choice.message.toolCalls;
287
- if (!toolCalls || toolCalls.length === 0) {
288
- return {
289
- text: extractTextFromContent(choice.message.content),
290
- steps: step + 1
291
- };
292
- }
293
- let toolResponses = await session.callTools(toolCalls);
294
- messages.push(
295
- { role: "assistant", toolCalls },
296
- ...toolResponses
297
- );
298
- }
299
- throw new Error(`Max steps (${maxSteps}) reached without final response`);
300
- }
301
- );
302
- };
303
- var runWithXAI = async (config) => {
304
- let {
305
- message,
306
- serverDeployments,
307
- client,
308
- model,
309
- maxSteps = 25,
310
- tools: requestedTools,
311
- withProviderSession,
312
- ...xaiOptions
313
- } = config;
314
- return withProviderSession(
315
- xai.metorialXai,
316
- {
317
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
318
- },
319
- async (session) => {
320
- let tools = requestedTools ? session.tools.filter((t) => {
321
- var _a;
322
- return requestedTools.includes(((_a = t.function) == null ? void 0 : _a.name) || t.name);
323
- }) : session.tools;
324
- let uniqueTools = Array.from(
325
- new Map(tools.map((t) => [t.function.name, t])).values()
326
- );
327
- let messages = [
328
- { role: "user", content: message }
329
- ];
330
- for (let step = 0; step < maxSteps; step++) {
331
- let response = await client.chat.completions.create({
332
- model,
333
- messages,
334
- tools: uniqueTools,
335
- ...xaiOptions
336
- });
337
- let choice = response.choices[0];
338
- if (!choice.message.tool_calls || choice.message.tool_calls.length === 0) {
339
- return {
340
- text: choice.message.content || "",
341
- steps: step + 1
342
- };
343
- }
344
- let toolResponses = await session.callTools(choice.message.tool_calls);
345
- messages.push(
346
- { role: "assistant", tool_calls: choice.message.tool_calls },
347
- ...toolResponses
348
- );
349
- }
350
- throw new Error(`Max steps (${maxSteps}) reached without final response`);
351
- }
352
- );
353
- };
354
- var runWithTogetherAI = async (config) => {
355
- let {
356
- message,
357
- serverDeployments,
358
- client,
359
- model,
360
- maxSteps = 25,
361
- tools: requestedTools,
362
- withProviderSession,
363
- ...togetheraiOptions
364
- } = config;
365
- return withProviderSession(
366
- togetherai.metorialTogetherAi,
367
- {
368
- serverDeployments: Array.isArray(serverDeployments) ? serverDeployments : [serverDeployments]
369
- },
370
- async (session) => {
371
- let tools = requestedTools ? session.tools.filter((t) => {
372
- var _a;
373
- return requestedTools.includes(((_a = t.function) == null ? void 0 : _a.name) || t.name);
374
- }) : session.tools;
375
- let messages = [
376
- { role: "user", content: message }
377
- ];
378
- for (let step = 0; step < maxSteps; step++) {
379
- let response = await client.chat.completions.create({
380
- model,
381
- messages,
382
- tools,
383
- ...togetheraiOptions
384
- });
385
- let choice = response.choices[0];
386
- if (!choice.message.tool_calls || choice.message.tool_calls.length === 0) {
387
- return {
388
- text: choice.message.content || "",
389
- steps: step + 1
390
- };
391
- }
392
- let toolResponses = await session.callTools(choice.message.tool_calls);
393
- messages.push(
394
- { role: "assistant", tool_calls: choice.message.tool_calls },
395
- ...toolResponses
396
- );
397
- }
398
- throw new Error(`Max steps (${maxSteps}) reached without final response`);
399
- }
400
- );
401
- };
402
-
403
- // src/metorial.ts
404
- var Metorial = class {
405
- constructor(init) {
406
- this.sdk = core.createMetorialCoreSDK(init);
21
+ get providerDeployments() {
22
+ let deployments = this.magnetarSdk.providerDeployments;
23
+ return {
24
+ ...deployments,
25
+ setupSessions: Object.assign(deployments.setupSessions, {
26
+ waitForCompletion: this.waitForSetupSession.bind(this)
27
+ })
28
+ };
407
29
  }
408
- get instance() {
409
- return this.sdk.instance;
30
+ get sessions() {
31
+ return this.magnetarSdk.sessions;
410
32
  }
411
- get secrets() {
412
- return this.sdk.secrets;
33
+ get sessionTemplates() {
34
+ return this.magnetarSdk.sessionTemplates;
35
+ }
36
+ get providerRuns() {
37
+ return this.magnetarSdk.providerRuns;
38
+ }
39
+ get instance() {
40
+ return this.magnetarSdk.instance;
413
41
  }
42
+ // ── Backward compat (Pulsar endpoints at top level) ──────────────
414
43
  get servers() {
415
- return this.sdk.servers;
44
+ return this.pulsarSdk.servers;
416
45
  }
417
- get sessions() {
418
- return this.sdk.sessions;
46
+ get secrets() {
47
+ return this.pulsarSdk.secrets;
419
48
  }
420
49
  get oauth() {
421
50
  return {
422
- ...this.sdk.oauth,
51
+ ...this.pulsarSdk.oauth,
423
52
  waitForCompletion: this.waitForOAuthCompletion.bind(this)
424
53
  };
425
54
  }
426
55
  get _config() {
427
- return this.sdk._config;
56
+ return this.pulsarSdk._config;
428
57
  }
58
+ // ── v1 namespace (legacy Pulsar) ─────────────────────────────────
59
+ get v1() {
60
+ let pulsarSdk = this.pulsarSdk;
61
+ let self = this;
62
+ return {
63
+ get instance() {
64
+ return pulsarSdk.instance;
65
+ },
66
+ get secrets() {
67
+ return pulsarSdk.secrets;
68
+ },
69
+ get servers() {
70
+ return pulsarSdk.servers;
71
+ },
72
+ get sessions() {
73
+ return pulsarSdk.sessions;
74
+ },
75
+ get oauth() {
76
+ return self.oauth;
77
+ },
78
+ get _config() {
79
+ return pulsarSdk._config;
80
+ },
81
+ mcp: {
82
+ createSession: (init) => new mcpSession.MetorialMcpSession(pulsarSdk, init),
83
+ withSession: self._pulsarWithSession.bind(self),
84
+ withProviderSession: self._pulsarWithProviderSession.bind(self),
85
+ createConnection: self._pulsarCreateMcpConnection.bind(self)
86
+ },
87
+ withSession: self._pulsarWithSession.bind(self),
88
+ withProviderSession: self._pulsarWithProviderSession.bind(self),
89
+ createMcpConnection: self._pulsarCreateMcpConnection.bind(self)
90
+ };
91
+ }
92
+ // ── MCP (Magnetar default) ───────────────────────────────────────
429
93
  get mcp() {
430
94
  return {
431
- createSession: (init) => new mcpSession.MetorialMcpSession(this.sdk, init),
95
+ createSession: (init) => new mcpSession.MetorialMagnetarMcpSession(this.magnetarSdk, init),
432
96
  withSession: this.withSession.bind(this),
433
97
  withProviderSession: this.withProviderSession.bind(this),
434
98
  createConnection: this.createMcpConnection.bind(this)
435
99
  };
436
100
  }
101
+ session(init) {
102
+ return new mcpSession.MetorialMagnetarMcpSession(this.magnetarSdk, init);
103
+ }
437
104
  async createMcpConnection(init) {
438
- let session = new mcpSession.MetorialMcpSession(this.sdk, {
105
+ let session = new mcpSession.MetorialMagnetarMcpSession(this.magnetarSdk, init);
106
+ return await session.getClient();
107
+ }
108
+ async withSession(init, action) {
109
+ let session = new mcpSession.MetorialMagnetarMcpSession(this.magnetarSdk, init);
110
+ try {
111
+ return await action(session);
112
+ } finally {
113
+ await session.close();
114
+ }
115
+ }
116
+ async withProviderSession(provider, init, action) {
117
+ if (init.streaming) {
118
+ return this.withMagnetarStreamingSession(provider, init, action);
119
+ }
120
+ return this.withSession(init, async (session) => {
121
+ let providerData = await provider(session);
122
+ return action({
123
+ ...providerData,
124
+ session,
125
+ getSession: session.getSession.bind(session),
126
+ getCapabilities: session.getCapabilities.bind(session),
127
+ getToolManager: session.getToolManager.bind(session),
128
+ closeSession: async () => {
129
+ }
130
+ });
131
+ });
132
+ }
133
+ async withMagnetarStreamingSession(provider, init, action) {
134
+ let session = new mcpSession.MetorialMagnetarMcpSession(this.magnetarSdk, init);
135
+ let sessionClosed = false;
136
+ const closeSession = async () => {
137
+ if (!sessionClosed) {
138
+ sessionClosed = true;
139
+ await session.close();
140
+ }
141
+ };
142
+ try {
143
+ let providerData = await provider(session);
144
+ let result = await action({
145
+ ...providerData,
146
+ session,
147
+ getSession: session.getSession.bind(session),
148
+ getCapabilities: session.getCapabilities.bind(session),
149
+ getToolManager: session.getToolManager.bind(session),
150
+ closeSession
151
+ });
152
+ let timeout = setTimeout(async () => {
153
+ if (!sessionClosed) {
154
+ await closeSession();
155
+ }
156
+ }, 6e4);
157
+ timeout.unref();
158
+ return result;
159
+ } catch (error) {
160
+ await closeSession();
161
+ throw error;
162
+ }
163
+ }
164
+ // ── Pulsar MCP helpers (used by v1) ──────────────────────────────
165
+ async _pulsarCreateMcpConnection(init) {
166
+ let session = new mcpSession.MetorialMcpSession(this.pulsarSdk, {
439
167
  serverDeployments: [init]
440
168
  });
441
169
  let deployments = await session.getServerDeployments();
@@ -443,19 +171,19 @@ var Metorial = class {
443
171
  deploymentId: deployments[0].id
444
172
  });
445
173
  }
446
- async withSession(init, action) {
447
- let session = new mcpSession.MetorialMcpSession(this.sdk, init);
174
+ async _pulsarWithSession(init, action) {
175
+ let session = new mcpSession.MetorialMcpSession(this.pulsarSdk, init);
448
176
  try {
449
177
  return await action(session);
450
178
  } finally {
451
179
  await session.close();
452
180
  }
453
181
  }
454
- async withProviderSession(provider, init, action) {
182
+ async _pulsarWithProviderSession(provider, init, action) {
455
183
  if (init.streaming) {
456
184
  return this.withStreamingSession(provider, init, action);
457
185
  }
458
- return this.withSession(init, async (session) => {
186
+ return this._pulsarWithSession(init, async (session) => {
459
187
  let providerData = await provider(session);
460
188
  return action({
461
189
  ...providerData,
@@ -469,12 +197,11 @@ var Metorial = class {
469
197
  });
470
198
  }
471
199
  async withStreamingSession(provider, init, action) {
472
- let session = new mcpSession.MetorialMcpSession(this.sdk, init);
200
+ let session = new mcpSession.MetorialMcpSession(this.pulsarSdk, init);
473
201
  let sessionClosed = false;
474
202
  const closeSession = async () => {
475
203
  if (!sessionClosed) {
476
204
  sessionClosed = true;
477
- console.log("[Metorial] Closing streaming session");
478
205
  await session.close();
479
206
  }
480
207
  };
@@ -490,42 +217,51 @@ var Metorial = class {
490
217
  getToolManager: session.getToolManager.bind(session),
491
218
  closeSession
492
219
  });
493
- setTimeout(async () => {
220
+ let timeout = setTimeout(async () => {
494
221
  if (!sessionClosed) {
495
- console.log("[Metorial] Streaming timeout reached - auto-closing session");
496
222
  await closeSession();
497
223
  }
498
224
  }, 6e4);
225
+ timeout.unref();
499
226
  return result;
500
227
  } catch (error) {
501
228
  await closeSession();
502
229
  throw error;
503
230
  }
504
231
  }
505
- inferProvider(model) {
506
- let modelLower = model.toLowerCase();
507
- if (modelLower.startsWith("claude-")) {
508
- return "anthropic";
509
- }
510
- if (modelLower.startsWith("gpt-") || modelLower.startsWith("o1-")) {
511
- return "openai";
512
- }
513
- if (modelLower.includes("deepseek")) {
514
- return "deepseek";
515
- }
516
- if (modelLower.startsWith("gemini-") || modelLower.includes("google")) {
517
- return "google";
518
- }
519
- if (modelLower.startsWith("mistral-") || modelLower.includes("mistral")) {
520
- return "mistral";
521
- }
522
- if (modelLower.startsWith("x-") || modelLower === "grok-beta") {
523
- return "xai";
232
+ async waitForSetupSession(sessions, options) {
233
+ var _a, _b;
234
+ let sessionList = Array.isArray(sessions) ? sessions : [sessions];
235
+ let pollInterval = Math.max((_a = options == null ? void 0 : options.pollInterval) != null ? _a : 5e3, 2e3);
236
+ let timeout = (_b = options == null ? void 0 : options.timeout) != null ? _b : 6e5;
237
+ let startTime = Date.now();
238
+ if (sessionList.length === 0) {
239
+ return [];
524
240
  }
525
- if (modelLower.includes("together") || modelLower.includes("llama") || modelLower.includes("mixtral") || modelLower.includes("qwen") || modelLower.includes("/")) {
526
- return "togetherai";
241
+ while (true) {
242
+ if (Date.now() - startTime > timeout) {
243
+ throw new Error(`Setup session timed out after ${timeout / 1e3} seconds`);
244
+ }
245
+ try {
246
+ let statuses = await Promise.all(
247
+ sessionList.map((s) => this.magnetarSdk.providerDeployments.setupSessions.get(s.id))
248
+ );
249
+ let failed = statuses.filter((s) => s.status === "failed");
250
+ if (failed.length > 0) {
251
+ throw new Error(`${failed.length} setup session(s) failed`);
252
+ }
253
+ let allCompleted = statuses.every((s) => s.status === "completed");
254
+ if (allCompleted) {
255
+ return statuses;
256
+ }
257
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
258
+ } catch (error) {
259
+ if (error instanceof Error && (error.message.includes("setup session") && (error.message.includes("failed") || error.message.includes("timed out")))) {
260
+ throw error;
261
+ }
262
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
263
+ }
527
264
  }
528
- throw new Error(`Unable to infer provider from model "${model}".`);
529
265
  }
530
266
  async waitForOAuthCompletion(sessions, options) {
531
267
  var _a, _b;
@@ -562,57 +298,8 @@ var Metorial = class {
562
298
  }
563
299
  }
564
300
  }
565
- async run(config) {
566
- let provider = this.inferProvider(config.model);
567
- switch (provider) {
568
- case "openai":
569
- return runWithOpenAI({
570
- ...config,
571
- client: config.client,
572
- withProviderSession: this.withProviderSession.bind(this)
573
- });
574
- case "anthropic":
575
- return runWithAnthropic({
576
- ...config,
577
- client: config.client,
578
- withProviderSession: this.withProviderSession.bind(this)
579
- });
580
- case "deepseek":
581
- return runWithDeepSeek({
582
- ...config,
583
- client: config.client,
584
- withProviderSession: this.withProviderSession.bind(this)
585
- });
586
- case "google":
587
- return runWithGoogle({
588
- ...config,
589
- client: config.client,
590
- withProviderSession: this.withProviderSession.bind(this)
591
- });
592
- case "mistral":
593
- return runWithMistral({
594
- ...config,
595
- client: config.client,
596
- withProviderSession: this.withProviderSession.bind(this)
597
- });
598
- case "xai":
599
- return runWithXAI({
600
- ...config,
601
- client: config.client,
602
- withProviderSession: this.withProviderSession.bind(this)
603
- });
604
- case "togetherai":
605
- return runWithTogetherAI({
606
- ...config,
607
- client: config.client,
608
- withProviderSession: this.withProviderSession.bind(this)
609
- });
610
- default:
611
- throw new Error(`Unsupported provider: ${provider}`);
612
- }
613
- }
614
301
  };
615
302
 
616
303
  exports.Metorial = Metorial;
617
- //# sourceMappingURL=out.js.map
304
+ //# sourceMappingURL=index.cjs.map
618
305
  //# sourceMappingURL=index.cjs.map