blun-king-cli 5.2.1 → 5.2.2
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/blun-cli.js +39 -45
- package/package.json +1 -1
package/blun-cli.js
CHANGED
|
@@ -2646,56 +2646,50 @@ async function main() {
|
|
|
2646
2646
|
}
|
|
2647
2647
|
}
|
|
2648
2648
|
|
|
2649
|
-
// API Key
|
|
2650
|
-
// Test if key actually works by hitting /health
|
|
2651
|
-
var hasKey = false;
|
|
2649
|
+
// API Key — ALWAYS prompt (like Claude Code login)
|
|
2652
2650
|
var existingKey = config.api.key || config.auth.api_key || "";
|
|
2651
|
+
console.log("");
|
|
2652
|
+
console.log(C.yellow + C.bold + " API Key" + C.reset);
|
|
2653
2653
|
if (existingKey.length > 3) {
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
} catch(e) { hasKey = false; }
|
|
2658
|
-
}
|
|
2659
|
-
if (!hasKey) {
|
|
2660
|
-
console.log("");
|
|
2661
|
-
console.log(C.yellow + C.bold + " API Key required" + C.reset);
|
|
2662
|
-
if (existingKey.length > 3) {
|
|
2663
|
-
console.log(C.red + " Saved key didn't work — please re-enter." + C.reset);
|
|
2664
|
-
}
|
|
2654
|
+
console.log(C.gray + " Current: " + C.green + existingKey.slice(0, 8) + "..." + C.reset);
|
|
2655
|
+
console.log(C.gray + " Press Enter to keep, or type a new key:" + C.reset);
|
|
2656
|
+
} else {
|
|
2665
2657
|
console.log(C.gray + " Enter your BLUN King API key:" + C.reset);
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
if (key === "\x7f" || key === "\b") {
|
|
2683
|
-
if (buf.length > 0) { buf = buf.slice(0, -1); process.stdout.write("\b \b"); }
|
|
2684
|
-
return;
|
|
2685
|
-
}
|
|
2686
|
-
buf += key;
|
|
2687
|
-
process.stdout.write("*");
|
|
2658
|
+
}
|
|
2659
|
+
process.stdout.write(C.brightBlue + " API Key: " + C.reset);
|
|
2660
|
+
var apiKeyAnswer = await new Promise(function(resolve) {
|
|
2661
|
+
var buf = "";
|
|
2662
|
+
process.stdin.setRawMode(true);
|
|
2663
|
+
process.stdin.resume();
|
|
2664
|
+
process.stdin.setEncoding("utf8");
|
|
2665
|
+
function onKeyApi(key) {
|
|
2666
|
+
if (key === "\x03") { process.exit(0); }
|
|
2667
|
+
if (key === "\r" || key === "\n") {
|
|
2668
|
+
process.stdin.removeListener("data", onKeyApi);
|
|
2669
|
+
process.stdin.setRawMode(false);
|
|
2670
|
+
process.stdin.pause();
|
|
2671
|
+
process.stdout.write("\n");
|
|
2672
|
+
resolve(buf.trim());
|
|
2673
|
+
return;
|
|
2688
2674
|
}
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
printSuccess("API key saved.");
|
|
2696
|
-
} else {
|
|
2697
|
-
printError("No API key — some features won't work.");
|
|
2675
|
+
if (key === "\x7f" || key === "\b") {
|
|
2676
|
+
if (buf.length > 0) { buf = buf.slice(0, -1); process.stdout.write("\b \b"); }
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
buf += key;
|
|
2680
|
+
process.stdout.write("*");
|
|
2698
2681
|
}
|
|
2682
|
+
process.stdin.on("data", onKeyApi);
|
|
2683
|
+
});
|
|
2684
|
+
if (apiKeyAnswer) {
|
|
2685
|
+
config.api.key = apiKeyAnswer;
|
|
2686
|
+
config.auth.api_key = apiKeyAnswer;
|
|
2687
|
+
saveConfig(config);
|
|
2688
|
+
printSuccess("API key saved.");
|
|
2689
|
+
} else if (existingKey.length > 3) {
|
|
2690
|
+
printSuccess("Using saved key.");
|
|
2691
|
+
} else {
|
|
2692
|
+
printError("No API key — some features won't work.");
|
|
2699
2693
|
}
|
|
2700
2694
|
|
|
2701
2695
|
printHeader();
|