blun-king-cli 6.3.2 → 6.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/bin/blun.js +2 -2
- package/lib/auth.js +24 -25
- package/lib/chat.js +14 -8
- package/lib/ui.js +1 -1
- package/node_modules/inquirer/node_modules/wrap-ansi/index.js +0 -0
- package/package.json +1 -1
- package/node_modules/color-convert/CHANGELOG.md +0 -54
package/bin/blun.js
CHANGED
|
@@ -115,7 +115,7 @@ async function main() {
|
|
|
115
115
|
try {
|
|
116
116
|
const res = await client.sendMessage(question);
|
|
117
117
|
ui.stopSpinner(true);
|
|
118
|
-
const text = (res.data && (res.data.response || res.data.text || res.data.message)) || JSON.stringify(res.data);
|
|
118
|
+
const text = (res.data && (res.data.answer || res.data.response || res.data.text || res.data.message)) || JSON.stringify(res.data);
|
|
119
119
|
ui.renderResponse(text, "agent");
|
|
120
120
|
} catch (e) {
|
|
121
121
|
ui.stopSpinner(false);
|
|
@@ -181,4 +181,4 @@ async function main() {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
main().catch((e) => { console.error("Fatal:", e.message); process.exit(1); });
|
|
184
|
+
main().then(() => { process.exit(0); }).catch((e) => { console.error("Fatal:", e.message); process.exit(1); });
|
package/lib/auth.js
CHANGED
|
@@ -4,6 +4,7 @@ const os = require('os');
|
|
|
4
4
|
const https = require('https');
|
|
5
5
|
const readline = require('readline');
|
|
6
6
|
const chalk = require('chalk');
|
|
7
|
+
const inquirer = require('inquirer');
|
|
7
8
|
|
|
8
9
|
const CREDS_DIR = path.join(os.homedir(), '.blun');
|
|
9
10
|
const CREDS_FILE = path.join(CREDS_DIR, 'credentials.json');
|
|
@@ -40,17 +41,15 @@ function ensureAuth() {
|
|
|
40
41
|
return getStoredCredentials();
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
function httpsRequest(options, body) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (body) req.write(JSON.stringify(body)); req.end();
|
|
53
|
-
});
|
|
44
|
+
async function httpsRequest(options, body) {
|
|
45
|
+
const url = 'https://' + (options.hostname || BASE_URL) + options.path;
|
|
46
|
+
const fetchOpts = { method: options.method || 'GET', headers: options.headers || {} };
|
|
47
|
+
if (body) { fetchOpts.body = JSON.stringify(body); }
|
|
48
|
+
const res = await fetch(url, fetchOpts);
|
|
49
|
+
let data;
|
|
50
|
+
const text = await res.text();
|
|
51
|
+
try { data = JSON.parse(text); } catch { data = text; }
|
|
52
|
+
return { status: res.status, data };
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
function prompt(question) {
|
|
@@ -69,7 +68,7 @@ function promptPassword(question) {
|
|
|
69
68
|
const c = ch.toString('utf8');
|
|
70
69
|
if (c === '\n' || c === '\r' || c === '\u0004') {
|
|
71
70
|
if (stdin.setRawMode) stdin.setRawMode(wasRaw || false);
|
|
72
|
-
stdin.removeListener('data', onData); process.stdout.write('\n'); resolve(pw);
|
|
71
|
+
stdin.removeListener('data', onData); stdin.pause(); process.stdout.write('\n'); resolve(pw);
|
|
73
72
|
} else if (c === '\u007f' || c === '\b') {
|
|
74
73
|
if (pw.length > 0) { pw = pw.slice(0, -1); process.stdout.write('\b \b'); }
|
|
75
74
|
} else if (c === '\u0003') { process.exit(0); }
|
|
@@ -79,19 +78,19 @@ function promptPassword(question) {
|
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
async function promptMenu(title,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return
|
|
81
|
+
async function promptMenu(title, choices) {
|
|
82
|
+
const { answer } = await inquirer.prompt([{
|
|
83
|
+
type: 'list',
|
|
84
|
+
name: 'answer',
|
|
85
|
+
message: title,
|
|
86
|
+
choices: choices.map(c => ({ name: c.label, value: c.value }))
|
|
87
|
+
}]);
|
|
88
|
+
return answer;
|
|
90
89
|
}
|
|
91
90
|
async function login() {
|
|
92
91
|
console.log(chalk.bold.cyan('\n BLUN Login\n'));
|
|
93
|
-
const email = await prompt(
|
|
94
|
-
const password = await
|
|
92
|
+
const { email } = await inquirer.prompt([{ type: 'input', name: 'email', message: 'Email:' }]);
|
|
93
|
+
const { password } = await inquirer.prompt([{ type: 'password', name: 'password', message: 'Password:', mask: '*' }]);
|
|
95
94
|
if (!email || !password) throw new Error('Email and password required.');
|
|
96
95
|
const res = await httpsRequest({
|
|
97
96
|
hostname: BASE_URL, path: '/api/king/auth/login',
|
|
@@ -112,9 +111,9 @@ async function login() {
|
|
|
112
111
|
|
|
113
112
|
async function register() {
|
|
114
113
|
console.log(chalk.bold.cyan('\n BLUN Registration\n'));
|
|
115
|
-
const name = await prompt(
|
|
116
|
-
const email = await prompt(
|
|
117
|
-
const password = await
|
|
114
|
+
const { name } = await inquirer.prompt([{ type: 'input', name: 'name', message: 'Name:' }]);
|
|
115
|
+
const { email } = await inquirer.prompt([{ type: 'input', name: 'email', message: 'Email:' }]);
|
|
116
|
+
const { password } = await inquirer.prompt([{ type: 'password', name: 'password', message: 'Password:', mask: '*' }]);
|
|
118
117
|
if (!email || !password || !name) throw new Error('Name, email and password required.');
|
|
119
118
|
const res = await httpsRequest({
|
|
120
119
|
hostname: BASE_URL, path: '/api/king/auth/register',
|
package/lib/chat.js
CHANGED
|
@@ -10,14 +10,20 @@ async function startChat() {
|
|
|
10
10
|
ui.renderBanner();
|
|
11
11
|
|
|
12
12
|
if (!auth.isAuthenticated()) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
try {
|
|
14
|
+
const result = await auth.showWelcomeMenu();
|
|
15
|
+
if (result === 'local') localMode = true;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.log(chalk.red('\n ' + e.message));
|
|
18
|
+
console.log(chalk.yellow(' Trying again...\n'));
|
|
19
|
+
try {
|
|
20
|
+
const retry = await auth.showWelcomeMenu();
|
|
21
|
+
if (retry === 'local') localMode = true;
|
|
22
|
+
} catch (e2) {
|
|
23
|
+
console.log(chalk.red('\n ' + e2.message));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
|
-
if (result === 'local') localMode = true;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
const creds = auth.getStoredCredentials();
|
|
@@ -123,7 +129,7 @@ async function startChat() {
|
|
|
123
129
|
const res = await client.sendMessage(input, { model: settings.model || 'auto' });
|
|
124
130
|
ui.stopSpinner(true, 'Response received');
|
|
125
131
|
if (res.status === 200 && res.data) {
|
|
126
|
-
const text = res.data.response || res.data.text || res.data.message || JSON.stringify(res.data);
|
|
132
|
+
const text = res.data.answer || res.data.response || res.data.text || res.data.message || JSON.stringify(res.data);
|
|
127
133
|
ui.renderResponse(text, 'agent');
|
|
128
134
|
if (res.data.usage) ui.addTokens(res.data.usage.total_tokens || 0, 0.000003);
|
|
129
135
|
} else if (res.status === 401 || res.status === 403) {
|
package/lib/ui.js
CHANGED
|
@@ -40,7 +40,7 @@ function renderBanner() {
|
|
|
40
40
|
chalk.dim(" ") +
|
|
41
41
|
chalk.bold.white("BLUN King CLI") +
|
|
42
42
|
chalk.dim(" \u2502 ") +
|
|
43
|
-
chalk.green("
|
|
43
|
+
chalk.green("v" + require("../package.json").version) +
|
|
44
44
|
chalk.dim(" \u2502 ") +
|
|
45
45
|
chalk.yellow("Multi-KI Engine")
|
|
46
46
|
);
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# 1.0.0 - 2016-01-07
|
|
2
|
-
|
|
3
|
-
- Removed: unused speed test
|
|
4
|
-
- Added: Automatic routing between previously unsupported conversions
|
|
5
|
-
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
6
|
-
- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
|
|
7
|
-
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
8
|
-
- Removed: `convert()` class
|
|
9
|
-
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
10
|
-
- Changed: all functions to lookup dictionary
|
|
11
|
-
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
12
|
-
- Changed: `ansi` to `ansi256`
|
|
13
|
-
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
14
|
-
- Fixed: argument grouping for functions requiring only one argument
|
|
15
|
-
([#27](https://github.com/Qix-/color-convert/pull/27))
|
|
16
|
-
|
|
17
|
-
# 0.6.0 - 2015-07-23
|
|
18
|
-
|
|
19
|
-
- Added: methods to handle
|
|
20
|
-
[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
|
|
21
|
-
- rgb2ansi16
|
|
22
|
-
- rgb2ansi
|
|
23
|
-
- hsl2ansi16
|
|
24
|
-
- hsl2ansi
|
|
25
|
-
- hsv2ansi16
|
|
26
|
-
- hsv2ansi
|
|
27
|
-
- hwb2ansi16
|
|
28
|
-
- hwb2ansi
|
|
29
|
-
- cmyk2ansi16
|
|
30
|
-
- cmyk2ansi
|
|
31
|
-
- keyword2ansi16
|
|
32
|
-
- keyword2ansi
|
|
33
|
-
- ansi162rgb
|
|
34
|
-
- ansi162hsl
|
|
35
|
-
- ansi162hsv
|
|
36
|
-
- ansi162hwb
|
|
37
|
-
- ansi162cmyk
|
|
38
|
-
- ansi162keyword
|
|
39
|
-
- ansi2rgb
|
|
40
|
-
- ansi2hsl
|
|
41
|
-
- ansi2hsv
|
|
42
|
-
- ansi2hwb
|
|
43
|
-
- ansi2cmyk
|
|
44
|
-
- ansi2keyword
|
|
45
|
-
([#18](https://github.com/harthur/color-convert/pull/18))
|
|
46
|
-
|
|
47
|
-
# 0.5.3 - 2015-06-02
|
|
48
|
-
|
|
49
|
-
- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
|
|
50
|
-
([#15](https://github.com/harthur/color-convert/issues/15))
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
Check out commit logs for older releases
|