@poolzin/pool-bot 2026.2.5 → 2026.2.7
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 +5 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/config-cli.js +17 -3
- package/dist/cli/program/register.onboard.js +34 -11
- package/dist/commands/auth-choice-options.js +60 -7
- package/dist/commands/auth-choice.apply.api-providers.js +149 -98
- 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.vllm.js +92 -0
- package/dist/commands/auth-choice.preferred-provider.js +9 -0
- package/dist/commands/onboard-auth.config-core.js +207 -8
- package/dist/commands/onboard-auth.credentials.js +35 -5
- package/dist/commands/onboard-auth.js +3 -3
- package/dist/commands/onboard-auth.models.js +45 -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 +14 -7
- package/dist/commands/onboard-non-interactive/local/auth-choice.js +322 -144
- package/dist/commands/zai-endpoint-detect.js +97 -0
- package/dist/config/legacy.migrations.part-3.js +57 -0
- package/dist/daemon/constants.js +7 -3
- package/dist/tui/components/filterable-select-list.js +5 -2
- package/dist/tui/components/searchable-select-list.js +6 -1
- package/dist/tui/tui-command-handlers.js +13 -5
- package/package.json +5 -5
|
@@ -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,119 +484,55 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
298
484
|
});
|
|
299
485
|
return applyVeniceConfig(nextConfig);
|
|
300
486
|
}
|
|
301
|
-
if (authChoice === "
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
cfg: baseConfig,
|
|
305
|
-
flagValue: opts.xiaomiApiKey,
|
|
306
|
-
flagName: "--xiaomi-api-key",
|
|
307
|
-
envVar: "XIAOMI_API_KEY",
|
|
308
|
-
runtime,
|
|
309
|
-
});
|
|
310
|
-
if (!resolved)
|
|
311
|
-
return null;
|
|
312
|
-
if (resolved.source !== "profile")
|
|
313
|
-
await setXiaomiApiKey(resolved.key);
|
|
314
|
-
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
315
|
-
profileId: "xiaomi:default",
|
|
316
|
-
provider: "xiaomi",
|
|
317
|
-
mode: "api_key",
|
|
318
|
-
});
|
|
319
|
-
return applyXiaomiConfig(nextConfig);
|
|
320
|
-
}
|
|
321
|
-
if (authChoice === "xai-api-key") {
|
|
487
|
+
if (authChoice === "minimax-cloud" ||
|
|
488
|
+
authChoice === "minimax-api" ||
|
|
489
|
+
authChoice === "minimax-api-lightning") {
|
|
322
490
|
const resolved = await resolveNonInteractiveApiKey({
|
|
323
|
-
provider: "
|
|
491
|
+
provider: "minimax",
|
|
324
492
|
cfg: baseConfig,
|
|
325
|
-
flagValue: opts.
|
|
326
|
-
flagName: "--
|
|
327
|
-
envVar: "
|
|
493
|
+
flagValue: opts.minimaxApiKey,
|
|
494
|
+
flagName: "--minimax-api-key",
|
|
495
|
+
envVar: "MINIMAX_API_KEY",
|
|
328
496
|
runtime,
|
|
329
497
|
});
|
|
330
|
-
if (!resolved)
|
|
498
|
+
if (!resolved) {
|
|
331
499
|
return null;
|
|
332
|
-
|
|
333
|
-
|
|
500
|
+
}
|
|
501
|
+
if (resolved.source !== "profile") {
|
|
502
|
+
await setMinimaxApiKey(resolved.key);
|
|
503
|
+
}
|
|
334
504
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
335
|
-
profileId: "
|
|
336
|
-
provider: "
|
|
505
|
+
profileId: "minimax:default",
|
|
506
|
+
provider: "minimax",
|
|
337
507
|
mode: "api_key",
|
|
338
508
|
});
|
|
339
|
-
|
|
509
|
+
const modelId = authChoice === "minimax-api-lightning" ? "MiniMax-M2.1-lightning" : "MiniMax-M2.1";
|
|
510
|
+
return applyMinimaxApiConfig(nextConfig, modelId);
|
|
340
511
|
}
|
|
341
|
-
if (authChoice === "
|
|
342
|
-
|
|
343
|
-
provider: "qianfan",
|
|
344
|
-
cfg: baseConfig,
|
|
345
|
-
flagValue: opts.qianfanApiKey,
|
|
346
|
-
flagName: "--qianfan-api-key",
|
|
347
|
-
envVar: "QIANFAN_API_KEY",
|
|
348
|
-
runtime,
|
|
349
|
-
});
|
|
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);
|
|
512
|
+
if (authChoice === "minimax") {
|
|
513
|
+
return applyMinimaxConfig(nextConfig);
|
|
360
514
|
}
|
|
361
|
-
if (authChoice === "
|
|
515
|
+
if (authChoice === "opencode-zen") {
|
|
362
516
|
const resolved = await resolveNonInteractiveApiKey({
|
|
363
|
-
provider: "
|
|
517
|
+
provider: "opencode",
|
|
364
518
|
cfg: baseConfig,
|
|
365
|
-
flagValue: opts.
|
|
366
|
-
flagName: "--
|
|
367
|
-
envVar: "
|
|
519
|
+
flagValue: opts.opencodeZenApiKey,
|
|
520
|
+
flagName: "--opencode-zen-api-key",
|
|
521
|
+
envVar: "OPENCODE_API_KEY (or OPENCODE_ZEN_API_KEY)",
|
|
368
522
|
runtime,
|
|
369
523
|
});
|
|
370
|
-
if (!resolved)
|
|
371
|
-
return null;
|
|
372
|
-
if (resolved.source !== "profile")
|
|
373
|
-
setNvidiaApiKey(resolved.key);
|
|
374
|
-
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
375
|
-
profileId: "nvidia:default",
|
|
376
|
-
provider: "nvidia",
|
|
377
|
-
mode: "api_key",
|
|
378
|
-
});
|
|
379
|
-
return applyNvidiaConfig(nextConfig);
|
|
380
|
-
}
|
|
381
|
-
if (authChoice === "cloudflare-ai-gateway-api-key") {
|
|
382
|
-
const accountId = opts.cloudflareAiGatewayAccountId?.trim() ?? "";
|
|
383
|
-
const gatewayId = opts.cloudflareAiGatewayGatewayId?.trim() ?? "";
|
|
384
|
-
if (!accountId || !gatewayId) {
|
|
385
|
-
runtime.error([
|
|
386
|
-
'Auth choice "cloudflare-ai-gateway-api-key" requires Account ID and Gateway ID.',
|
|
387
|
-
"Use --cloudflare-ai-gateway-account-id and --cloudflare-ai-gateway-gateway-id.",
|
|
388
|
-
].join("\n"));
|
|
389
|
-
runtime.exit(1);
|
|
524
|
+
if (!resolved) {
|
|
390
525
|
return null;
|
|
391
526
|
}
|
|
392
|
-
const resolved = await resolveNonInteractiveApiKey({
|
|
393
|
-
provider: "cloudflare-ai-gateway",
|
|
394
|
-
cfg: baseConfig,
|
|
395
|
-
flagValue: opts.cloudflareAiGatewayApiKey,
|
|
396
|
-
flagName: "--cloudflare-ai-gateway-api-key",
|
|
397
|
-
envVar: "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
|
398
|
-
runtime,
|
|
399
|
-
});
|
|
400
|
-
if (!resolved)
|
|
401
|
-
return null;
|
|
402
527
|
if (resolved.source !== "profile") {
|
|
403
|
-
await
|
|
528
|
+
await setOpencodeZenApiKey(resolved.key);
|
|
404
529
|
}
|
|
405
530
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
406
|
-
profileId: "
|
|
407
|
-
provider: "
|
|
531
|
+
profileId: "opencode:default",
|
|
532
|
+
provider: "opencode",
|
|
408
533
|
mode: "api_key",
|
|
409
534
|
});
|
|
410
|
-
return
|
|
411
|
-
accountId,
|
|
412
|
-
gatewayId,
|
|
413
|
-
});
|
|
535
|
+
return applyOpencodeZenConfig(nextConfig);
|
|
414
536
|
}
|
|
415
537
|
if (authChoice === "together-api-key") {
|
|
416
538
|
const resolved = await resolveNonInteractiveApiKey({
|
|
@@ -421,10 +543,12 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
421
543
|
envVar: "TOGETHER_API_KEY",
|
|
422
544
|
runtime,
|
|
423
545
|
});
|
|
424
|
-
if (!resolved)
|
|
546
|
+
if (!resolved) {
|
|
425
547
|
return null;
|
|
426
|
-
|
|
548
|
+
}
|
|
549
|
+
if (resolved.source !== "profile") {
|
|
427
550
|
await setTogetherApiKey(resolved.key);
|
|
551
|
+
}
|
|
428
552
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
429
553
|
profileId: "together:default",
|
|
430
554
|
provider: "together",
|
|
@@ -432,50 +556,104 @@ export async function applyNonInteractiveAuthChoice(params) {
|
|
|
432
556
|
});
|
|
433
557
|
return applyTogetherConfig(nextConfig);
|
|
434
558
|
}
|
|
435
|
-
if (authChoice === "
|
|
436
|
-
authChoice === "minimax-api" ||
|
|
437
|
-
authChoice === "minimax-api-lightning") {
|
|
559
|
+
if (authChoice === "huggingface-api-key") {
|
|
438
560
|
const resolved = await resolveNonInteractiveApiKey({
|
|
439
|
-
provider: "
|
|
561
|
+
provider: "huggingface",
|
|
440
562
|
cfg: baseConfig,
|
|
441
|
-
flagValue: opts.
|
|
442
|
-
flagName: "--
|
|
443
|
-
envVar: "
|
|
563
|
+
flagValue: opts.huggingfaceApiKey,
|
|
564
|
+
flagName: "--huggingface-api-key",
|
|
565
|
+
envVar: "HF_TOKEN",
|
|
444
566
|
runtime,
|
|
445
567
|
});
|
|
446
|
-
if (!resolved)
|
|
568
|
+
if (!resolved) {
|
|
447
569
|
return null;
|
|
448
|
-
|
|
449
|
-
|
|
570
|
+
}
|
|
571
|
+
if (resolved.source !== "profile") {
|
|
572
|
+
await setHuggingfaceApiKey(resolved.key);
|
|
573
|
+
}
|
|
450
574
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
451
|
-
profileId: "
|
|
452
|
-
provider: "
|
|
575
|
+
profileId: "huggingface:default",
|
|
576
|
+
provider: "huggingface",
|
|
453
577
|
mode: "api_key",
|
|
454
578
|
});
|
|
455
|
-
|
|
456
|
-
return applyMinimaxApiConfig(nextConfig, modelId);
|
|
579
|
+
return applyHuggingfaceConfig(nextConfig);
|
|
457
580
|
}
|
|
458
|
-
if (authChoice === "
|
|
459
|
-
return applyMinimaxConfig(nextConfig);
|
|
460
|
-
if (authChoice === "opencode-zen") {
|
|
581
|
+
if (authChoice === "nvidia-api-key") {
|
|
461
582
|
const resolved = await resolveNonInteractiveApiKey({
|
|
462
|
-
provider: "
|
|
583
|
+
provider: "nvidia",
|
|
463
584
|
cfg: baseConfig,
|
|
464
|
-
flagValue: opts.
|
|
465
|
-
flagName: "--
|
|
466
|
-
envVar: "
|
|
585
|
+
flagValue: opts.nvidiaApiKey,
|
|
586
|
+
flagName: "--nvidia-api-key",
|
|
587
|
+
envVar: "NVIDIA_API_KEY",
|
|
467
588
|
runtime,
|
|
468
589
|
});
|
|
469
590
|
if (!resolved)
|
|
470
591
|
return null;
|
|
471
592
|
if (resolved.source !== "profile")
|
|
472
|
-
|
|
593
|
+
setNvidiaApiKey(resolved.key);
|
|
473
594
|
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
474
|
-
profileId: "
|
|
475
|
-
provider: "
|
|
595
|
+
profileId: "nvidia:default",
|
|
596
|
+
provider: "nvidia",
|
|
476
597
|
mode: "api_key",
|
|
477
598
|
});
|
|
478
|
-
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
|
+
}
|
|
479
657
|
}
|
|
480
658
|
if (authChoice === "oauth" ||
|
|
481
659
|
authChoice === "chutes" ||
|