blun-king-cli 7.3.2 → 7.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/lib/chat.js +25 -7
- package/lib/client.js +10 -1
- package/package.json +1 -1
package/lib/chat.js
CHANGED
|
@@ -341,7 +341,14 @@ function startChat() {
|
|
|
341
341
|
// Show thinking indicator
|
|
342
342
|
printToScrollArea(chalk.dim(" ⠋ Thinking..."));
|
|
343
343
|
|
|
344
|
-
client.sendMessage(input, {
|
|
344
|
+
client.sendMessage(input, {
|
|
345
|
+
model: settings.model || "auto",
|
|
346
|
+
latencyMode: settings.latencyMode || "fast",
|
|
347
|
+
styleMode: settings.styleMode || "normal",
|
|
348
|
+
toolMode: settings.toolMode || "smart",
|
|
349
|
+
historyWindow: settings.historyWindow || 8,
|
|
350
|
+
language: settings.language || "de",
|
|
351
|
+
})
|
|
345
352
|
.then(function (res) {
|
|
346
353
|
if (res.status === 200 && res.data) {
|
|
347
354
|
var text = res.data.answer || res.data.response || res.data.text || res.data.message || JSON.stringify(res.data);
|
|
@@ -382,6 +389,13 @@ function startChat() {
|
|
|
382
389
|
function openDropdownBelow(items, onSelect, onClose) {
|
|
383
390
|
var active = true;
|
|
384
391
|
var selected = 0;
|
|
392
|
+
var menuHeight = items.length + 2; // items + help line + padding
|
|
393
|
+
// Temporarily increase panel height to make room for menu below panel
|
|
394
|
+
var savedHeight = INPUT_PANEL_HEIGHT;
|
|
395
|
+
INPUT_PANEL_HEIGHT = 5 + menuHeight; // 5 = panel itself
|
|
396
|
+
// Recalculate scroll region
|
|
397
|
+
setupLayout();
|
|
398
|
+
drawInputPanel();
|
|
385
399
|
|
|
386
400
|
function getMenuStart() {
|
|
387
401
|
var rows = getRows();
|
|
@@ -389,12 +403,15 @@ function startChat() {
|
|
|
389
403
|
return panelTop + 5; // right after the bottom frame of input panel
|
|
390
404
|
}
|
|
391
405
|
|
|
392
|
-
function
|
|
393
|
-
|
|
406
|
+
function restoreLayout() {
|
|
407
|
+
INPUT_PANEL_HEIGHT = savedHeight;
|
|
394
408
|
var rows = getRows();
|
|
395
|
-
|
|
396
|
-
|
|
409
|
+
// Clear the entire menu + panel area
|
|
410
|
+
for (var r = rows - INPUT_PANEL_HEIGHT - menuHeight; r <= rows; r++) {
|
|
411
|
+
process.stdout.write(cursorTo(Math.max(1, r), 1) + clearLine());
|
|
397
412
|
}
|
|
413
|
+
setupLayout();
|
|
414
|
+
drawInputPanel();
|
|
398
415
|
}
|
|
399
416
|
|
|
400
417
|
function drawMenu() {
|
|
@@ -428,7 +445,7 @@ function startChat() {
|
|
|
428
445
|
if ((key === "\u001b" && key.length === 1) || key === "\u0003") {
|
|
429
446
|
active = false;
|
|
430
447
|
process.stdin.removeAllListeners("data");
|
|
431
|
-
|
|
448
|
+
restoreLayout();
|
|
432
449
|
if (onClose) onClose();
|
|
433
450
|
startRawInput();
|
|
434
451
|
return;
|
|
@@ -452,6 +469,7 @@ function startChat() {
|
|
|
452
469
|
if (key === "\u001b[D" || key === "\u001b[C") {
|
|
453
470
|
if (items[selected].onCycle) {
|
|
454
471
|
items[selected].onCycle(key === "\u001b[C" ? 1 : -1);
|
|
472
|
+
drawInputPanel();
|
|
455
473
|
drawMenu();
|
|
456
474
|
}
|
|
457
475
|
return;
|
|
@@ -461,7 +479,7 @@ function startChat() {
|
|
|
461
479
|
if (key === "\r" || key === "\n") {
|
|
462
480
|
active = false;
|
|
463
481
|
process.stdin.removeAllListeners("data");
|
|
464
|
-
|
|
482
|
+
restoreLayout();
|
|
465
483
|
if (onSelect) onSelect(items[selected]);
|
|
466
484
|
startRawInput();
|
|
467
485
|
return;
|
package/lib/client.js
CHANGED
|
@@ -39,7 +39,16 @@ function request(method, urlPath, body) {
|
|
|
39
39
|
|
|
40
40
|
function sendMessage(message, options) {
|
|
41
41
|
options = options || {};
|
|
42
|
-
var body = {
|
|
42
|
+
var body = {
|
|
43
|
+
message: message,
|
|
44
|
+
model: options.model || "auto",
|
|
45
|
+
stream: false,
|
|
46
|
+
latency_mode: options.latencyMode || "fast",
|
|
47
|
+
style_mode: options.styleMode || "normal",
|
|
48
|
+
tool_mode: options.toolMode || "smart",
|
|
49
|
+
history_window: options.historyWindow || 8,
|
|
50
|
+
language: options.language || "de",
|
|
51
|
+
};
|
|
43
52
|
return request("POST", "/api/king/chat", body);
|
|
44
53
|
}
|
|
45
54
|
|