archbyte 0.3.3 → 0.3.4
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/cli/setup.js +64 -1
- package/package.json +1 -1
package/dist/cli/setup.js
CHANGED
|
@@ -340,8 +340,71 @@ export async function handleSetup() {
|
|
|
340
340
|
s2.stop(result ? "valid" : "invalid", result ? "green" : "red");
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
+
// After retries exhausted — offer to switch providers
|
|
343
344
|
if (result === false) {
|
|
344
|
-
|
|
345
|
+
const others = PROVIDERS.filter((p) => p.name !== provider);
|
|
346
|
+
if (others.length > 0) {
|
|
347
|
+
console.log();
|
|
348
|
+
console.log(chalk.yellow(" Key didn't work. Try a different provider?"));
|
|
349
|
+
const switchIdx = await select(" Switch provider:", [
|
|
350
|
+
...others.map((p) => `${p.label} ${chalk.gray(p.hint)}`),
|
|
351
|
+
chalk.gray("Skip — save as-is"),
|
|
352
|
+
]);
|
|
353
|
+
if (switchIdx < others.length) {
|
|
354
|
+
const alt = others[switchIdx];
|
|
355
|
+
config.provider = alt.name;
|
|
356
|
+
console.log(chalk.green(`\n ✓ Provider: ${alt.label}`));
|
|
357
|
+
const altKey = await askHidden(chalk.bold(" API key: "));
|
|
358
|
+
if (!altKey) {
|
|
359
|
+
console.log(chalk.yellow(" No key entered. Keeping original provider."));
|
|
360
|
+
config.provider = provider;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
if (!profiles[alt.name])
|
|
364
|
+
profiles[alt.name] = { apiKey: "" };
|
|
365
|
+
profiles[alt.name].apiKey = altKey;
|
|
366
|
+
console.log(chalk.green(` ✓ API key: ${maskKey(altKey)}`));
|
|
367
|
+
// Model selection for the new provider
|
|
368
|
+
const altModels = PROVIDER_MODELS[alt.name];
|
|
369
|
+
if (altModels) {
|
|
370
|
+
const mIdx = await select("\n Choose a model:", altModels.map((m) => `${m.label} ${chalk.gray(m.hint)}`));
|
|
371
|
+
const chosen = altModels[mIdx];
|
|
372
|
+
if (chosen.id) {
|
|
373
|
+
profiles[alt.name].model = chosen.id;
|
|
374
|
+
console.log(chalk.green(` ✓ Model: ${chosen.label}`));
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
const defaults = {
|
|
378
|
+
anthropic: "claude-opus-4-6",
|
|
379
|
+
openai: "gpt-5.2",
|
|
380
|
+
google: "gemini-2.5-pro",
|
|
381
|
+
};
|
|
382
|
+
const dm = defaults[alt.name] ?? resolveModel(alt.name, "standard");
|
|
383
|
+
profiles[alt.name].model = dm;
|
|
384
|
+
console.log(chalk.green(` ✓ Model: ${dm} (default)`));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const altValidationModel = profiles[alt.name].model ?? resolveModel(alt.name, "fast");
|
|
388
|
+
const s3 = spinner(`Validating credentials with ${altValidationModel}`);
|
|
389
|
+
result = await validateProviderSilent(alt.name, altKey, altValidationModel);
|
|
390
|
+
if (result === "quota") {
|
|
391
|
+
s3.stop("valid (quota exceeded — key accepted)", "yellow");
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
s3.stop(result ? "valid" : "invalid", result ? "green" : "red");
|
|
395
|
+
}
|
|
396
|
+
if (result === false) {
|
|
397
|
+
console.log(chalk.yellow(" Warning: credentials unverified. Saving anyway."));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
console.log(chalk.yellow(" Warning: credentials unverified. Saving anyway."));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
console.log(chalk.yellow(" Warning: credentials unverified. Saving anyway."));
|
|
407
|
+
}
|
|
345
408
|
}
|
|
346
409
|
}
|
|
347
410
|
// Clean up legacy top-level keys
|