@poolzin/pool-bot 2026.2.4 → 2026.2.6
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/agents/auth-profiles/profiles.js +9 -0
- package/dist/agents/auth-profiles.js +1 -1
- package/dist/agents/huggingface-models.js +166 -0
- package/dist/agents/model-auth.js +6 -0
- package/dist/agents/model-forward-compat.js +187 -0
- package/dist/agents/pi-embedded-runner/model.js +10 -56
- package/dist/browser/constants.js +1 -1
- package/dist/browser/profiles.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli/config-cli.js +17 -3
- package/dist/cli/program/register.onboard.js +38 -5
- package/dist/commands/auth-choice-options.js +71 -7
- package/dist/commands/auth-choice.apply.api-providers.js +202 -97
- package/dist/commands/auth-choice.apply.huggingface.js +130 -0
- package/dist/commands/auth-choice.apply.openrouter.js +77 -0
- package/dist/commands/auth-choice.apply.plugin-provider.js +1 -56
- package/dist/commands/auth-choice.apply.vllm.js +92 -0
- package/dist/commands/auth-choice.preferred-provider.js +10 -0
- package/dist/commands/models/auth.js +1 -58
- package/dist/commands/models/list.errors.js +14 -0
- package/dist/commands/models/list.list-command.js +32 -21
- package/dist/commands/models/list.registry.js +120 -28
- package/dist/commands/models/list.status-command.js +1 -0
- package/dist/commands/models/shared.js +14 -0
- package/dist/commands/onboard-auth.config-core.js +265 -8
- package/dist/commands/onboard-auth.credentials.js +47 -6
- package/dist/commands/onboard-auth.js +3 -3
- package/dist/commands/onboard-auth.models.js +67 -0
- package/dist/commands/onboard-custom.js +181 -70
- package/dist/commands/onboard-non-interactive/api-keys.js +10 -1
- package/dist/commands/onboard-non-interactive/local/auth-choice-inference.js +15 -7
- package/dist/commands/onboard-non-interactive/local/auth-choice.js +322 -124
- package/dist/commands/provider-auth-helpers.js +61 -0
- package/dist/commands/zai-endpoint-detect.js +97 -0
- package/dist/config/legacy.migrations.part-3.js +57 -0
- package/dist/terminal/theme.js +1 -1
- package/package.json +1 -1
|
@@ -2,13 +2,15 @@ import { upsertAuthProfile } from "../../../agents/auth-profiles.js";
|
|
|
2
2
|
import { normalizeProviderId } from "../../../agents/model-selection.js";
|
|
3
3
|
import { parseDurationMs } from "../../../cli/parse-duration.js";
|
|
4
4
|
import { upsertSharedEnvVar } from "../../../infra/env-file.js";
|
|
5
|
+
import { shortenHomePath } from "../../../utils.js";
|
|
5
6
|
import { normalizeSecretInput } from "../../../utils/normalize-secret-input.js";
|
|
6
7
|
import { buildTokenProfileId, validateAnthropicSetupToken } from "../../auth-token.js";
|
|
7
8
|
import { applyGoogleGeminiModelDefault } from "../../google-gemini-model-default.js";
|
|
9
|
+
import { applyAuthProfileConfig, applyCloudflareAiGatewayConfig, applyHuggingfaceConfig, applyKimiCodeConfig, applyLitellmConfig, applyMinimaxApiConfig, applyMinimaxConfig, applyMoonshotConfig, applyMoonshotConfigCn, applyNvidiaConfig, applyOpencodeZenConfig, applyOpenrouterConfig, applyQianfanConfig, applySyntheticConfig, applyTogetherConfig, applyVeniceConfig, applyVercelAiGatewayConfig, applyXaiConfig, applyXiaomiConfig, applyZaiConfig, setAnthropicApiKey, setCloudflareAiGatewayConfig, setGeminiApiKey, setHuggingfaceApiKey, setKimiCodingApiKey, setLitellmApiKey, setMinimaxApiKey, setMoonshotApiKey, setNvidiaApiKey, setOpencodeZenApiKey, setOpenrouterApiKey, setQianfanApiKey, setSyntheticApiKey, setTogetherApiKey, setVeniceApiKey, setVercelAiGatewayApiKey, setXaiApiKey, setXiaomiApiKey, setZaiApiKey, } from "../../onboard-auth.js";
|
|
10
|
+
import { applyCustomApiConfig, CustomApiError, parseNonInteractiveCustomApiFlags, resolveCustomProviderId, } from "../../onboard-custom.js";
|
|
8
11
|
import { applyOpenAIConfig } from "../../openai-model-default.js";
|
|
9
|
-
import {
|
|
12
|
+
import { detectZaiEndpoint } from "../../zai-endpoint-detect.js";
|
|
10
13
|
import { resolveNonInteractiveApiKey } from "../api-keys.js";
|
|
11
|
-
import { shortenHomePath } from "../../../utils.js";
|
|
12
14
|
export async function applyNonInteractiveAuthChoice(params) {
|
|
13
15
|
const { authChoice, opts, runtime, baseConfig } = params;
|
|
14
16
|
let nextConfig = params.nextConfig;
|
|
@@ -28,6 +30,14 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
28
30
|
runtime.exit(1);
|
|
29
31
|
return null;
|
|
30
32
|
}
|
|
33
|
+
if (authChoice === "vllm") {
|
|
34
|
+
runtime.error([
|
|
35
|
+
'Auth choice "vllm" requires interactive mode.',
|
|
36
|
+
"Use interactive onboard/configure to enter base URL, API key, and model ID.",
|
|
37
|
+
].join("\n"));
|
|
38
|
+
runtime.exit(1);
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
31
41
|
if (authChoice === "apiKey") {
|
|
32
42
|
const resolved = await resolveNonInteractiveApiKey({
|
|
33
43
|
provider: "anthropic",
|
|
@@ -37,10 +47,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
37
47
|
envVar: "ANTHROPIC_API_KEY",
|
|
38
48
|
runtime,
|
|
39
49
|
});
|
|
40
|
-
if (!resolved)
|
|
50
|
+
if (!resolved) {
|
|
41
51
|
return null;
|
|
42
|
-
|
|
52
|
+
}
|
|
53
|
+
if (resolved.source !== "profile") {
|
|
43
54
|
await setAnthropicApiKey(resolved.key);
|
|
55
|
+
}
|
|
44
56
|
return applyAuthProfileConfig(nextConfig, {
|
|
45
57
|
profileId: "anthropic:default",
|
|
46
58
|
provider: "anthropic",
|
|
@@ -109,10 +121,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
109
121
|
envVar: "GEMINI_API_KEY",
|
|
110
122
|
runtime,
|
|
111
123
|
});
|
|
112
|
-
if (!resolved)
|
|
124
|
+
if (!resolved) {
|
|
113
125
|
return null;
|
|
114
|
-
|
|
126
|
+
}
|
|
127
|
+
if (resolved.source !== "profile") {
|
|
115
128
|
await setGeminiApiKey(resolved.key);
|
|
129
|
+
}
|
|
116
130
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
117
131
|
profileId: "google:default",
|
|
118
132
|
provider: "google",
|
|
@@ -120,7 +134,11 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
120
134
|
});
|
|
121
135
|
return applyGoogleGeminiModelDefault(nextConfig).next;
|
|
122
136
|
}
|
|
123
|
-
if (authChoice === "zai-api-key"
|
|
137
|
+
if (authChoice === "zai-api-key" ||
|
|
138
|
+
authChoice === "zai-coding-global" ||
|
|
139
|
+
authChoice === "zai-coding-cn" ||
|
|
140
|
+
authChoice === "zai-global" ||
|
|
141
|
+
authChoice === "zai-cn") {
|
|
124
142
|
const resolved = await resolveNonInteractiveApiKey({
|
|
125
143
|
provider: "zai",
|
|
126
144
|
cfg: baseConfig,
|
|
@@ -129,16 +147,112 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
129
147
|
envVar: "ZAI_API_KEY",
|
|
130
148
|
runtime,
|
|
131
149
|
});
|
|
132
|
-
if (!resolved)
|
|
150
|
+
if (!resolved) {
|
|
133
151
|
return null;
|
|
134
|
-
|
|
152
|
+
}
|
|
153
|
+
if (resolved.source !== "profile") {
|
|
135
154
|
await setZaiApiKey(resolved.key);
|
|
155
|
+
}
|
|
136
156
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
137
157
|
profileId: "zai:default",
|
|
138
158
|
provider: "zai",
|
|
139
159
|
mode: "api_key",
|
|
140
160
|
});
|
|
141
|
-
|
|
161
|
+
// Determine endpoint from authChoice or detect from the API key.
|
|
162
|
+
let endpoint;
|
|
163
|
+
let modelIdOverride;
|
|
164
|
+
if (authChoice === "zai-coding-global") {
|
|
165
|
+
endpoint = "coding-global";
|
|
166
|
+
}
|
|
167
|
+
else if (authChoice === "zai-coding-cn") {
|
|
168
|
+
endpoint = "coding-cn";
|
|
169
|
+
}
|
|
170
|
+
else if (authChoice === "zai-global") {
|
|
171
|
+
endpoint = "global";
|
|
172
|
+
}
|
|
173
|
+
else if (authChoice === "zai-cn") {
|
|
174
|
+
endpoint = "cn";
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const detected = await detectZaiEndpoint({ apiKey: resolved.key });
|
|
178
|
+
if (detected) {
|
|
179
|
+
endpoint = detected.endpoint;
|
|
180
|
+
modelIdOverride = detected.modelId;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
endpoint = "global";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return applyZaiConfig(nextConfig, {
|
|
187
|
+
endpoint,
|
|
188
|
+
...(modelIdOverride ? { modelId: modelIdOverride } : {}),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (authChoice === "xiaomi-api-key") {
|
|
192
|
+
const resolved = await resolveNonInteractiveApiKey({
|
|
193
|
+
provider: "xiaomi",
|
|
194
|
+
cfg: baseConfig,
|
|
195
|
+
flagValue: opts.xiaomiApiKey,
|
|
196
|
+
flagName: "--xiaomi-api-key",
|
|
197
|
+
envVar: "XIAOMI_API_KEY",
|
|
198
|
+
runtime,
|
|
199
|
+
});
|
|
200
|
+
if (!resolved) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
if (resolved.source !== "profile") {
|
|
204
|
+
await setXiaomiApiKey(resolved.key);
|
|
205
|
+
}
|
|
206
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
207
|
+
profileId: "xiaomi:default",
|
|
208
|
+
provider: "xiaomi",
|
|
209
|
+
mode: "api_key",
|
|
210
|
+
});
|
|
211
|
+
return applyXiaomiConfig(nextConfig);
|
|
212
|
+
}
|
|
213
|
+
if (authChoice === "xai-api-key") {
|
|
214
|
+
const resolved = await resolveNonInteractiveApiKey({
|
|
215
|
+
provider: "xai",
|
|
216
|
+
cfg: baseConfig,
|
|
217
|
+
flagValue: opts.xaiApiKey,
|
|
218
|
+
flagName: "--xai-api-key",
|
|
219
|
+
envVar: "XAI_API_KEY",
|
|
220
|
+
runtime,
|
|
221
|
+
});
|
|
222
|
+
if (!resolved) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
if (resolved.source !== "profile") {
|
|
226
|
+
setXaiApiKey(resolved.key);
|
|
227
|
+
}
|
|
228
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
229
|
+
profileId: "xai:default",
|
|
230
|
+
provider: "xai",
|
|
231
|
+
mode: "api_key",
|
|
232
|
+
});
|
|
233
|
+
return applyXaiConfig(nextConfig);
|
|
234
|
+
}
|
|
235
|
+
if (authChoice === "qianfan-api-key") {
|
|
236
|
+
const resolved = await resolveNonInteractiveApiKey({
|
|
237
|
+
provider: "qianfan",
|
|
238
|
+
cfg: baseConfig,
|
|
239
|
+
flagValue: opts.qianfanApiKey,
|
|
240
|
+
flagName: "--qianfan-api-key",
|
|
241
|
+
envVar: "QIANFAN_API_KEY",
|
|
242
|
+
runtime,
|
|
243
|
+
});
|
|
244
|
+
if (!resolved) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
if (resolved.source !== "profile") {
|
|
248
|
+
setQianfanApiKey(resolved.key);
|
|
249
|
+
}
|
|
250
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
251
|
+
profileId: "qianfan:default",
|
|
252
|
+
provider: "qianfan",
|
|
253
|
+
mode: "api_key",
|
|
254
|
+
});
|
|
255
|
+
return applyQianfanConfig(nextConfig);
|
|
142
256
|
}
|
|
143
257
|
if (authChoice === "openai-api-key") {
|
|
144
258
|
const resolved = await resolveNonInteractiveApiKey({
|
|
@@ -150,8 +264,9 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
150
264
|
runtime,
|
|
151
265
|
allowProfile: false,
|
|
152
266
|
});
|
|
153
|
-
if (!resolved)
|
|
267
|
+
if (!resolved) {
|
|
154
268
|
return null;
|
|
269
|
+
}
|
|
155
270
|
const key = resolved.key;
|
|
156
271
|
const result = upsertSharedEnvVar({ key: "OPENAI_API_KEY", value: key });
|
|
157
272
|
process.env.OPENAI_API_KEY = key;
|
|
@@ -167,10 +282,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
167
282
|
envVar: "OPENROUTER_API_KEY",
|
|
168
283
|
runtime,
|
|
169
284
|
});
|
|
170
|
-
if (!resolved)
|
|
285
|
+
if (!resolved) {
|
|
171
286
|
return null;
|
|
172
|
-
|
|
287
|
+
}
|
|
288
|
+
if (resolved.source !== "profile") {
|
|
173
289
|
await setOpenrouterApiKey(resolved.key);
|
|
290
|
+
}
|
|
174
291
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
175
292
|
profileId: "openrouter:default",
|
|
176
293
|
provider: "openrouter",
|
|
@@ -178,6 +295,28 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
178
295
|
});
|
|
179
296
|
return applyOpenrouterConfig(nextConfig);
|
|
180
297
|
}
|
|
298
|
+
if (authChoice === "litellm-api-key") {
|
|
299
|
+
const resolved = await resolveNonInteractiveApiKey({
|
|
300
|
+
provider: "litellm",
|
|
301
|
+
cfg: baseConfig,
|
|
302
|
+
flagValue: opts.litellmApiKey,
|
|
303
|
+
flagName: "--litellm-api-key",
|
|
304
|
+
envVar: "LITELLM_API_KEY",
|
|
305
|
+
runtime,
|
|
306
|
+
});
|
|
307
|
+
if (!resolved) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
if (resolved.source !== "profile") {
|
|
311
|
+
await setLitellmApiKey(resolved.key);
|
|
312
|
+
}
|
|
313
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
314
|
+
profileId: "litellm:default",
|
|
315
|
+
provider: "litellm",
|
|
316
|
+
mode: "api_key",
|
|
317
|
+
});
|
|
318
|
+
return applyLitellmConfig(nextConfig);
|
|
319
|
+
}
|
|
181
320
|
if (authChoice === "ai-gateway-api-key") {
|
|
182
321
|
const resolved = await resolveNonInteractiveApiKey({
|
|
183
322
|
provider: "vercel-ai-gateway",
|
|
@@ -187,10 +326,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
187
326
|
envVar: "AI_GATEWAY_API_KEY",
|
|
188
327
|
runtime,
|
|
189
328
|
});
|
|
190
|
-
if (!resolved)
|
|
329
|
+
if (!resolved) {
|
|
191
330
|
return null;
|
|
192
|
-
|
|
331
|
+
}
|
|
332
|
+
if (resolved.source !== "profile") {
|
|
193
333
|
await setVercelAiGatewayApiKey(resolved.key);
|
|
334
|
+
}
|
|
194
335
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
195
336
|
profileId: "vercel-ai-gateway:default",
|
|
196
337
|
provider: "vercel-ai-gateway",
|
|
@@ -198,6 +339,41 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
198
339
|
});
|
|
199
340
|
return applyVercelAiGatewayConfig(nextConfig);
|
|
200
341
|
}
|
|
342
|
+
if (authChoice === "cloudflare-ai-gateway-api-key") {
|
|
343
|
+
const accountId = opts.cloudflareAiGatewayAccountId?.trim() ?? "";
|
|
344
|
+
const gatewayId = opts.cloudflareAiGatewayGatewayId?.trim() ?? "";
|
|
345
|
+
if (!accountId || !gatewayId) {
|
|
346
|
+
runtime.error([
|
|
347
|
+
'Auth choice "cloudflare-ai-gateway-api-key" requires Account ID and Gateway ID.',
|
|
348
|
+
"Use --cloudflare-ai-gateway-account-id and --cloudflare-ai-gateway-gateway-id.",
|
|
349
|
+
].join("\n"));
|
|
350
|
+
runtime.exit(1);
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
const resolved = await resolveNonInteractiveApiKey({
|
|
354
|
+
provider: "cloudflare-ai-gateway",
|
|
355
|
+
cfg: baseConfig,
|
|
356
|
+
flagValue: opts.cloudflareAiGatewayApiKey,
|
|
357
|
+
flagName: "--cloudflare-ai-gateway-api-key",
|
|
358
|
+
envVar: "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
|
359
|
+
runtime,
|
|
360
|
+
});
|
|
361
|
+
if (!resolved) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
if (resolved.source !== "profile") {
|
|
365
|
+
await setCloudflareAiGatewayConfig(accountId, gatewayId, resolved.key);
|
|
366
|
+
}
|
|
367
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
368
|
+
profileId: "cloudflare-ai-gateway:default",
|
|
369
|
+
provider: "cloudflare-ai-gateway",
|
|
370
|
+
mode: "api_key",
|
|
371
|
+
});
|
|
372
|
+
return applyCloudflareAiGatewayConfig(nextConfig, {
|
|
373
|
+
accountId,
|
|
374
|
+
gatewayId,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
201
377
|
if (authChoice === "moonshot-api-key") {
|
|
202
378
|
const resolved = await resolveNonInteractiveApiKey({
|
|
203
379
|
provider: "moonshot",
|
|
@@ -207,10 +383,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
207
383
|
envVar: "MOONSHOT_API_KEY",
|
|
208
384
|
runtime,
|
|
209
385
|
});
|
|
210
|
-
if (!resolved)
|
|
386
|
+
if (!resolved) {
|
|
211
387
|
return null;
|
|
212
|
-
|
|
388
|
+
}
|
|
389
|
+
if (resolved.source !== "profile") {
|
|
213
390
|
await setMoonshotApiKey(resolved.key);
|
|
391
|
+
}
|
|
214
392
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
215
393
|
profileId: "moonshot:default",
|
|
216
394
|
provider: "moonshot",
|
|
@@ -227,10 +405,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
227
405
|
envVar: "MOONSHOT_API_KEY",
|
|
228
406
|
runtime,
|
|
229
407
|
});
|
|
230
|
-
if (!resolved)
|
|
408
|
+
if (!resolved) {
|
|
231
409
|
return null;
|
|
232
|
-
|
|
410
|
+
}
|
|
411
|
+
if (resolved.source !== "profile") {
|
|
233
412
|
await setMoonshotApiKey(resolved.key);
|
|
413
|
+
}
|
|
234
414
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
235
415
|
profileId: "moonshot:default",
|
|
236
416
|
provider: "moonshot",
|
|
@@ -247,10 +427,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
247
427
|
envVar: "KIMI_API_KEY",
|
|
248
428
|
runtime,
|
|
249
429
|
});
|
|
250
|
-
if (!resolved)
|
|
430
|
+
if (!resolved) {
|
|
251
431
|
return null;
|
|
252
|
-
|
|
432
|
+
}
|
|
433
|
+
if (resolved.source !== "profile") {
|
|
253
434
|
await setKimiCodingApiKey(resolved.key);
|
|
435
|
+
}
|
|
254
436
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
255
437
|
profileId: "kimi-coding:default",
|
|
256
438
|
provider: "kimi-coding",
|
|
@@ -267,10 +449,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
267
449
|
envVar: "SYNTHETIC_API_KEY",
|
|
268
450
|
runtime,
|
|
269
451
|
});
|
|
270
|
-
if (!resolved)
|
|
452
|
+
if (!resolved) {
|
|
271
453
|
return null;
|
|
272
|
-
|
|
454
|
+
}
|
|
455
|
+
if (resolved.source !== "profile") {
|
|
273
456
|
await setSyntheticApiKey(resolved.key);
|
|
457
|
+
}
|
|
274
458
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
275
459
|
profileId: "synthetic:default",
|
|
276
460
|
provider: "synthetic",
|
|
@@ -287,10 +471,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
287
471
|
envVar: "VENICE_API_KEY",
|
|
288
472
|
runtime,
|
|
289
473
|
});
|
|
290
|
-
if (!resolved)
|
|
474
|
+
if (!resolved) {
|
|
291
475
|
return null;
|
|
292
|
-
|
|
476
|
+
}
|
|
477
|
+
if (resolved.source !== "profile") {
|
|
293
478
|
await setVeniceApiKey(resolved.key);
|
|
479
|
+
}
|
|
294
480
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
295
481
|
profileId: "venice:default",
|
|
296
482
|
provider: "venice",
|
|
@@ -298,99 +484,55 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
298
484
|
});
|
|
299
485
|
return applyVeniceConfig(nextConfig);
|
|
300
486
|
}
|
|
301
|
-
if (authChoice === "
|
|
487
|
+
if (authChoice === "minimax-cloud" ||
|
|
488
|
+
authChoice === "minimax-api" ||
|
|
489
|
+
authChoice === "minimax-api-lightning") {
|
|
302
490
|
const resolved = await resolveNonInteractiveApiKey({
|
|
303
|
-
provider: "
|
|
491
|
+
provider: "minimax",
|
|
304
492
|
cfg: baseConfig,
|
|
305
|
-
flagValue: opts.
|
|
306
|
-
flagName: "--
|
|
307
|
-
envVar: "
|
|
493
|
+
flagValue: opts.minimaxApiKey,
|
|
494
|
+
flagName: "--minimax-api-key",
|
|
495
|
+
envVar: "MINIMAX_API_KEY",
|
|
308
496
|
runtime,
|
|
309
497
|
});
|
|
310
|
-
if (!resolved)
|
|
498
|
+
if (!resolved) {
|
|
311
499
|
return null;
|
|
312
|
-
|
|
313
|
-
|
|
500
|
+
}
|
|
501
|
+
if (resolved.source !== "profile") {
|
|
502
|
+
await setMinimaxApiKey(resolved.key);
|
|
503
|
+
}
|
|
314
504
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
315
|
-
profileId: "
|
|
316
|
-
provider: "
|
|
505
|
+
profileId: "minimax:default",
|
|
506
|
+
provider: "minimax",
|
|
317
507
|
mode: "api_key",
|
|
318
508
|
});
|
|
319
|
-
|
|
509
|
+
const modelId = authChoice === "minimax-api-lightning" ? "MiniMax-M2.1-lightning" : "MiniMax-M2.1";
|
|
510
|
+
return applyMinimaxApiConfig(nextConfig, modelId);
|
|
320
511
|
}
|
|
321
|
-
if (authChoice === "
|
|
322
|
-
|
|
323
|
-
provider: "xai",
|
|
324
|
-
cfg: baseConfig,
|
|
325
|
-
flagValue: opts.xaiApiKey,
|
|
326
|
-
flagName: "--xai-api-key",
|
|
327
|
-
envVar: "XAI_API_KEY",
|
|
328
|
-
runtime,
|
|
329
|
-
});
|
|
330
|
-
if (!resolved)
|
|
331
|
-
return null;
|
|
332
|
-
if (resolved.source !== "profile")
|
|
333
|
-
setXaiApiKey(resolved.key);
|
|
334
|
-
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
335
|
-
profileId: "xai:default",
|
|
336
|
-
provider: "xai",
|
|
337
|
-
mode: "api_key",
|
|
338
|
-
});
|
|
339
|
-
return applyXaiConfig(nextConfig);
|
|
512
|
+
if (authChoice === "minimax") {
|
|
513
|
+
return applyMinimaxConfig(nextConfig);
|
|
340
514
|
}
|
|
341
|
-
if (authChoice === "
|
|
515
|
+
if (authChoice === "opencode-zen") {
|
|
342
516
|
const resolved = await resolveNonInteractiveApiKey({
|
|
343
|
-
provider: "
|
|
517
|
+
provider: "opencode",
|
|
344
518
|
cfg: baseConfig,
|
|
345
|
-
flagValue: opts.
|
|
346
|
-
flagName: "--
|
|
347
|
-
envVar: "
|
|
519
|
+
flagValue: opts.opencodeZenApiKey,
|
|
520
|
+
flagName: "--opencode-zen-api-key",
|
|
521
|
+
envVar: "OPENCODE_API_KEY (or OPENCODE_ZEN_API_KEY)",
|
|
348
522
|
runtime,
|
|
349
523
|
});
|
|
350
|
-
if (!resolved)
|
|
351
|
-
return null;
|
|
352
|
-
if (resolved.source !== "profile")
|
|
353
|
-
setQianfanApiKey(resolved.key);
|
|
354
|
-
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
355
|
-
profileId: "qianfan:default",
|
|
356
|
-
provider: "qianfan",
|
|
357
|
-
mode: "api_key",
|
|
358
|
-
});
|
|
359
|
-
return applyQianfanConfig(nextConfig);
|
|
360
|
-
}
|
|
361
|
-
if (authChoice === "cloudflare-ai-gateway-api-key") {
|
|
362
|
-
const accountId = opts.cloudflareAiGatewayAccountId?.trim() ?? "";
|
|
363
|
-
const gatewayId = opts.cloudflareAiGatewayGatewayId?.trim() ?? "";
|
|
364
|
-
if (!accountId || !gatewayId) {
|
|
365
|
-
runtime.error([
|
|
366
|
-
'Auth choice "cloudflare-ai-gateway-api-key" requires Account ID and Gateway ID.',
|
|
367
|
-
"Use --cloudflare-ai-gateway-account-id and --cloudflare-ai-gateway-gateway-id.",
|
|
368
|
-
].join("\n"));
|
|
369
|
-
runtime.exit(1);
|
|
524
|
+
if (!resolved) {
|
|
370
525
|
return null;
|
|
371
526
|
}
|
|
372
|
-
const resolved = await resolveNonInteractiveApiKey({
|
|
373
|
-
provider: "cloudflare-ai-gateway",
|
|
374
|
-
cfg: baseConfig,
|
|
375
|
-
flagValue: opts.cloudflareAiGatewayApiKey,
|
|
376
|
-
flagName: "--cloudflare-ai-gateway-api-key",
|
|
377
|
-
envVar: "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
|
378
|
-
runtime,
|
|
379
|
-
});
|
|
380
|
-
if (!resolved)
|
|
381
|
-
return null;
|
|
382
527
|
if (resolved.source !== "profile") {
|
|
383
|
-
await
|
|
528
|
+
await setOpencodeZenApiKey(resolved.key);
|
|
384
529
|
}
|
|
385
530
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
386
|
-
profileId: "
|
|
387
|
-
provider: "
|
|
531
|
+
profileId: "opencode:default",
|
|
532
|
+
provider: "opencode",
|
|
388
533
|
mode: "api_key",
|
|
389
534
|
});
|
|
390
|
-
return
|
|
391
|
-
accountId,
|
|
392
|
-
gatewayId,
|
|
393
|
-
});
|
|
535
|
+
return applyOpencodeZenConfig(nextConfig);
|
|
394
536
|
}
|
|
395
537
|
if (authChoice === "together-api-key") {
|
|
396
538
|
const resolved = await resolveNonInteractiveApiKey({
|
|
@@ -401,10 +543,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
401
543
|
envVar: "TOGETHER_API_KEY",
|
|
402
544
|
runtime,
|
|
403
545
|
});
|
|
404
|
-
if (!resolved)
|
|
546
|
+
if (!resolved) {
|
|
405
547
|
return null;
|
|
406
|
-
|
|
548
|
+
}
|
|
549
|
+
if (resolved.source !== "profile") {
|
|
407
550
|
await setTogetherApiKey(resolved.key);
|
|
551
|
+
}
|
|
408
552
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
409
553
|
profileId: "together:default",
|
|
410
554
|
provider: "together",
|
|
@@ -412,50 +556,104 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
412
556
|
});
|
|
413
557
|
return applyTogetherConfig(nextConfig);
|
|
414
558
|
}
|
|
415
|
-
if (authChoice === "
|
|
416
|
-
authChoice === "minimax-api" ||
|
|
417
|
-
authChoice === "minimax-api-lightning") {
|
|
559
|
+
if (authChoice === "huggingface-api-key") {
|
|
418
560
|
const resolved = await resolveNonInteractiveApiKey({
|
|
419
|
-
provider: "
|
|
561
|
+
provider: "huggingface",
|
|
420
562
|
cfg: baseConfig,
|
|
421
|
-
flagValue: opts.
|
|
422
|
-
flagName: "--
|
|
423
|
-
envVar: "
|
|
563
|
+
flagValue: opts.huggingfaceApiKey,
|
|
564
|
+
flagName: "--huggingface-api-key",
|
|
565
|
+
envVar: "HF_TOKEN",
|
|
424
566
|
runtime,
|
|
425
567
|
});
|
|
426
|
-
if (!resolved)
|
|
568
|
+
if (!resolved) {
|
|
427
569
|
return null;
|
|
428
|
-
|
|
429
|
-
|
|
570
|
+
}
|
|
571
|
+
if (resolved.source !== "profile") {
|
|
572
|
+
await setHuggingfaceApiKey(resolved.key);
|
|
573
|
+
}
|
|
430
574
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
431
|
-
profileId: "
|
|
432
|
-
provider: "
|
|
575
|
+
profileId: "huggingface:default",
|
|
576
|
+
provider: "huggingface",
|
|
433
577
|
mode: "api_key",
|
|
434
578
|
});
|
|
435
|
-
|
|
436
|
-
return applyMinimaxApiConfig(nextConfig, modelId);
|
|
579
|
+
return applyHuggingfaceConfig(nextConfig);
|
|
437
580
|
}
|
|
438
|
-
if (authChoice === "
|
|
439
|
-
return applyMinimaxConfig(nextConfig);
|
|
440
|
-
if (authChoice === "opencode-zen") {
|
|
581
|
+
if (authChoice === "nvidia-api-key") {
|
|
441
582
|
const resolved = await resolveNonInteractiveApiKey({
|
|
442
|
-
provider: "
|
|
583
|
+
provider: "nvidia",
|
|
443
584
|
cfg: baseConfig,
|
|
444
|
-
flagValue: opts.
|
|
445
|
-
flagName: "--
|
|
446
|
-
envVar: "
|
|
585
|
+
flagValue: opts.nvidiaApiKey,
|
|
586
|
+
flagName: "--nvidia-api-key",
|
|
587
|
+
envVar: "NVIDIA_API_KEY",
|
|
447
588
|
runtime,
|
|
448
589
|
});
|
|
449
590
|
if (!resolved)
|
|
450
591
|
return null;
|
|
451
592
|
if (resolved.source !== "profile")
|
|
452
|
-
|
|
593
|
+
setNvidiaApiKey(resolved.key);
|
|
453
594
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
454
|
-
profileId: "
|
|
455
|
-
provider: "
|
|
595
|
+
profileId: "nvidia:default",
|
|
596
|
+
provider: "nvidia",
|
|
456
597
|
mode: "api_key",
|
|
457
598
|
});
|
|
458
|
-
return
|
|
599
|
+
return applyNvidiaConfig(nextConfig);
|
|
600
|
+
}
|
|
601
|
+
if (authChoice === "custom-api-key") {
|
|
602
|
+
try {
|
|
603
|
+
const customAuth = parseNonInteractiveCustomApiFlags({
|
|
604
|
+
baseUrl: opts.customBaseUrl,
|
|
605
|
+
modelId: opts.customModelId,
|
|
606
|
+
compatibility: opts.customCompatibility,
|
|
607
|
+
apiKey: opts.customApiKey,
|
|
608
|
+
providerId: opts.customProviderId,
|
|
609
|
+
});
|
|
610
|
+
const resolvedProviderId = resolveCustomProviderId({
|
|
611
|
+
config: nextConfig,
|
|
612
|
+
baseUrl: customAuth.baseUrl,
|
|
613
|
+
providerId: customAuth.providerId,
|
|
614
|
+
});
|
|
615
|
+
const resolvedCustomApiKey = await resolveNonInteractiveApiKey({
|
|
616
|
+
provider: resolvedProviderId.providerId,
|
|
617
|
+
cfg: baseConfig,
|
|
618
|
+
flagValue: customAuth.apiKey,
|
|
619
|
+
flagName: "--custom-api-key",
|
|
620
|
+
envVar: "CUSTOM_API_KEY",
|
|
621
|
+
envVarName: "CUSTOM_API_KEY",
|
|
622
|
+
runtime,
|
|
623
|
+
required: false,
|
|
624
|
+
});
|
|
625
|
+
const result = applyCustomApiConfig({
|
|
626
|
+
config: nextConfig,
|
|
627
|
+
baseUrl: customAuth.baseUrl,
|
|
628
|
+
modelId: customAuth.modelId,
|
|
629
|
+
compatibility: customAuth.compatibility,
|
|
630
|
+
apiKey: resolvedCustomApiKey?.key,
|
|
631
|
+
providerId: customAuth.providerId,
|
|
632
|
+
});
|
|
633
|
+
if (result.providerIdRenamedFrom && result.providerId) {
|
|
634
|
+
runtime.log(`Custom provider ID "${result.providerIdRenamedFrom}" already exists for a different base URL. Using "${result.providerId}".`);
|
|
635
|
+
}
|
|
636
|
+
return result.config;
|
|
637
|
+
}
|
|
638
|
+
catch (err) {
|
|
639
|
+
if (err instanceof CustomApiError) {
|
|
640
|
+
switch (err.code) {
|
|
641
|
+
case "missing_required":
|
|
642
|
+
case "invalid_compatibility":
|
|
643
|
+
runtime.error(err.message);
|
|
644
|
+
break;
|
|
645
|
+
default:
|
|
646
|
+
runtime.error(`Invalid custom provider config: ${err.message}`);
|
|
647
|
+
break;
|
|
648
|
+
}
|
|
649
|
+
runtime.exit(1);
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
653
|
+
runtime.error(`Invalid custom provider config: ${reason}`);
|
|
654
|
+
runtime.exit(1);
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
459
657
|
}
|
|
460
658
|
if (authChoice === "oauth" ||
|
|
461
659
|
authChoice === "chutes" ||
|