blun-king-cli 2.6.1 → 2.6.3
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/bin/blun.js +20 -7
- package/package.json +1 -1
package/bin/blun.js
CHANGED
|
@@ -25,12 +25,9 @@ if (!fs.existsSync(SKILLS_DIR)) fs.mkdirSync(SKILLS_DIR, { recursive: true });
|
|
|
25
25
|
|
|
26
26
|
// ── Default Config ──
|
|
27
27
|
function loadConfig() {
|
|
28
|
-
|
|
29
|
-
try { return JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8")); } catch(e) {}
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
28
|
+
var defaults = {
|
|
32
29
|
auth: { type: "api_key", api_key: "", oauth_token: "", oauth_expires: null },
|
|
33
|
-
api: { base_url: "http://176.9.158.30:3200", timeout: 60000 },
|
|
30
|
+
api: { base_url: "http://176.9.158.30:3200", timeout: 60000, key: "" },
|
|
34
31
|
telegram: { enabled: false, bot_token: "", chat_id: "" },
|
|
35
32
|
model: "blun-king-v100",
|
|
36
33
|
workdir: process.cwd(),
|
|
@@ -38,6 +35,20 @@ function loadConfig() {
|
|
|
38
35
|
verbose: false,
|
|
39
36
|
watchdog: { enabled: false, interval: 600 }
|
|
40
37
|
};
|
|
38
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
39
|
+
try {
|
|
40
|
+
var saved = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
|
|
41
|
+
// Deep merge saved over defaults
|
|
42
|
+
Object.keys(defaults).forEach(function(k) {
|
|
43
|
+
if (typeof defaults[k] === "object" && defaults[k] !== null && saved[k]) {
|
|
44
|
+
defaults[k] = Object.assign({}, defaults[k], saved[k]);
|
|
45
|
+
} else if (saved[k] !== undefined) {
|
|
46
|
+
defaults[k] = saved[k];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
} catch(e) {}
|
|
50
|
+
}
|
|
51
|
+
return defaults;
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
function saveConfig(cfg) {
|
|
@@ -74,8 +85,9 @@ function apiCall(method, endpoint, body) {
|
|
|
74
85
|
timeout: config.api.timeout
|
|
75
86
|
};
|
|
76
87
|
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
var authToken = config.api.key || config.auth.api_key;
|
|
89
|
+
if (authToken) {
|
|
90
|
+
options.headers["Authorization"] = "Bearer " + authToken;
|
|
79
91
|
} else if (config.auth.type === "oauth" && config.auth.oauth_token) {
|
|
80
92
|
options.headers["Authorization"] = "Bearer " + config.auth.oauth_token;
|
|
81
93
|
}
|
|
@@ -2625,6 +2637,7 @@ async function main() {
|
|
|
2625
2637
|
inputBuffer = "";
|
|
2626
2638
|
cursorPos = 0;
|
|
2627
2639
|
menuSelected = 0;
|
|
2640
|
+
uiStartRow = -1; // reset so drawUI doesn't try to erase old content
|
|
2628
2641
|
processing = false;
|
|
2629
2642
|
drawPrompt();
|
|
2630
2643
|
}
|