adaptive-memory-multi-model-router 2.13.13 → 2.13.14
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/tui/dashboard.d.ts +1 -1
- package/dist/tui/dashboard.js +42 -50
- package/dist/tui/dashboard.js.map +1 -1
- package/package.json +1 -1
- package/src/tui/dashboard.ts +42 -52
package/dist/tui/dashboard.d.ts
CHANGED
package/dist/tui/dashboard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
|
-
* A3M Router — Overlay Box (
|
|
4
|
+
* A3M Router — Overlay Box TUI (Sakura Light Theme)
|
|
5
5
|
*/
|
|
6
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
7
|
if (k2 === undefined) k2 = k;
|
|
@@ -38,67 +38,61 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
38
38
|
})();
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
const blessed = __importStar(require("blessed"));
|
|
41
|
-
// State
|
|
41
|
+
// ── State ──
|
|
42
42
|
let activeModel = 'nvidia/llama-3.1-8b';
|
|
43
43
|
let totalCost = 0.000087;
|
|
44
44
|
let reqCount = 4;
|
|
45
45
|
const log = [];
|
|
46
|
-
// Screen
|
|
46
|
+
// ── Screen ──
|
|
47
47
|
const screen = blessed.screen({
|
|
48
48
|
smartCSR: true,
|
|
49
49
|
fullUnicode: true,
|
|
50
50
|
dockBorders: false,
|
|
51
51
|
cursor: { shape: 'line', blink: true },
|
|
52
52
|
});
|
|
53
|
-
// Box settings
|
|
54
53
|
const BW = 82;
|
|
55
54
|
const BH = 18;
|
|
56
|
-
function
|
|
57
|
-
function
|
|
58
|
-
//
|
|
55
|
+
function L() { return Math.max(0, Math.floor((screen.width - BW) / 2)); }
|
|
56
|
+
function T() { return Math.max(0, Math.floor((screen.height - BH) / 2)); }
|
|
57
|
+
// ── SAKURA LIGHT THEME ──
|
|
58
|
+
// bg: #fff5f7 (blush white)
|
|
59
|
+
// srf: #fce7f3 (light pink)
|
|
60
|
+
// dim: #d8a4b8 (muted rose)
|
|
61
|
+
// txt: #831843 (deep maroon)
|
|
62
|
+
// pink:#be185d (hot pink)
|
|
63
|
+
// grn: #059669 (emerald)
|
|
64
|
+
// blu: #2563eb (royal blue)
|
|
65
|
+
// amb: #d97706 (amber)
|
|
66
|
+
// red: #dc2626 (crimson)
|
|
67
|
+
// cyn: #0891b2 (teal)
|
|
68
|
+
// prp: #7c3aed (violet)
|
|
59
69
|
const box = blessed.box({
|
|
60
|
-
top:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
border: { type: 'line', fg: 'magenta' },
|
|
65
|
-
style: { fg: '#c0caf5', bg: '#1a1b26' },
|
|
66
|
-
tags: true,
|
|
67
|
-
scrollable: true,
|
|
68
|
-
mouse: true,
|
|
69
|
-
keys: true,
|
|
70
|
+
top: T(), left: L(), width: BW, height: BH,
|
|
71
|
+
border: { type: 'line', fg: '#f472b6' },
|
|
72
|
+
style: { fg: '#831843', bg: '#fff5f7' },
|
|
73
|
+
tags: true, scrollable: true, mouse: true, keys: true,
|
|
70
74
|
padding: { left: 1, right: 1, top: 0, bottom: 0 },
|
|
71
75
|
});
|
|
72
|
-
// Prompt
|
|
73
76
|
const prompt = blessed.textbox({
|
|
74
|
-
parent: box,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
width: BW - 4,
|
|
78
|
-
height: 1,
|
|
79
|
-
style: { fg: '#c0caf5', bg: '#24283b' },
|
|
80
|
-
inputOnFocus: true,
|
|
81
|
-
keys: true,
|
|
82
|
-
tags: true,
|
|
77
|
+
parent: box, bottom: 1, left: 0, width: BW - 4, height: 1,
|
|
78
|
+
style: { fg: '#831843', bg: '#fce7f3' },
|
|
79
|
+
inputOnFocus: true, keys: true, tags: true,
|
|
83
80
|
});
|
|
84
|
-
|
|
85
|
-
const D = (s) => `{#565f89-fg}${s}{/}`;
|
|
81
|
+
const D = (s) => `{#d8a4b8-fg}${s}{/}`;
|
|
86
82
|
function render() {
|
|
87
83
|
const maxLines = BH - 4;
|
|
88
84
|
const visible = log.slice(-maxLines);
|
|
89
85
|
let out = '';
|
|
90
|
-
out += `{bold}{#
|
|
91
|
-
out += `${D('─'.repeat(BW - 6))}\n`;
|
|
92
|
-
|
|
93
|
-
for (const line of visible) {
|
|
86
|
+
out += `{bold}{#be185d-fg}⚡ A3M Router{/} ${D('·')} {#059669-fg}${activeModel}{/} ${D('·')} ${D(`${reqCount} req`)} ${D('·')} ${D(`$${totalCost.toFixed(6)}`)}\n`;
|
|
87
|
+
out += `${D('─'.repeat(BW - 6))}\n\n`;
|
|
88
|
+
for (const line of visible)
|
|
94
89
|
out += line + '\n';
|
|
95
|
-
}
|
|
96
90
|
if (visible.length === 0) {
|
|
97
91
|
out += ` ${D('Type a query — auto-routed to cheapest model.')}\n\n`;
|
|
98
92
|
out += ` ${D('Commands:')}\n`;
|
|
99
|
-
out += ` {#
|
|
100
|
-
out += ` {#
|
|
101
|
-
out += ` {#
|
|
93
|
+
out += ` {#2563eb-fg}/route{/} ${D('<query>')} /cost /model nvidia\n`;
|
|
94
|
+
out += ` {#2563eb-fg}/health{/} /models /clear\n`;
|
|
95
|
+
out += ` {#2563eb-fg}/exit{/} /help\n\n`;
|
|
102
96
|
out += ` ${D('nvidia (free) · groq (free) · deepseek ($9.46)')}\n`;
|
|
103
97
|
}
|
|
104
98
|
box.setContent(out);
|
|
@@ -107,7 +101,7 @@ function render() {
|
|
|
107
101
|
function cmd(c) {
|
|
108
102
|
if (!c)
|
|
109
103
|
return;
|
|
110
|
-
log.push(`{bold}{#
|
|
104
|
+
log.push(`{bold}{#0891b2-fg}▸{/} ${c}`);
|
|
111
105
|
if (c === '/exit' || c === '/q') {
|
|
112
106
|
screen.destroy();
|
|
113
107
|
process.exit(0);
|
|
@@ -117,25 +111,25 @@ function cmd(c) {
|
|
|
117
111
|
else if (c === '/clear')
|
|
118
112
|
log.length = 0;
|
|
119
113
|
else if (c === '/cost') {
|
|
120
|
-
log.push(` {#
|
|
114
|
+
log.push(` {#be185d-fg}A3M{/} Cost:`);
|
|
121
115
|
log.push(` ${D('nvidia $0 | deepseek $0.000009 | groq $0 | cerebras $0')}`);
|
|
122
116
|
log.push(` ${D(`TOTAL $${totalCost.toFixed(6)} | ${reqCount} req | 99.97% saved`)}`);
|
|
123
117
|
}
|
|
124
118
|
else if (c === '/health') {
|
|
125
|
-
log.push(` {#
|
|
126
|
-
log.push(` {#
|
|
127
|
-
log.push(` {#
|
|
119
|
+
log.push(` {#be185d-fg}A3M{/} Health:`);
|
|
120
|
+
log.push(` {#059669-fg}●{/} nvidia 85ms {#059669-fg}●{/} deepseek 210ms {#059669-fg}●{/} groq 150ms {#059669-fg}●{/} cerebras 320ms`);
|
|
121
|
+
log.push(` {#dc2626-fg}✕{/} mistral OFFLINE {#059669-fg}●{/} ollama 50ms`);
|
|
128
122
|
}
|
|
129
123
|
else if (c === '/models') {
|
|
130
|
-
log.push(` {#
|
|
131
|
-
log.push(` {#
|
|
124
|
+
log.push(` {#be185d-fg}A3M{/} 47+ providers:`);
|
|
125
|
+
log.push(` {#059669-fg}● nvidia{/} (free) {#0891b2-fg}● groq{/} (free) {#d97706-fg}● deepseek{/} (cheap) {#7c3aed-fg}● cerebras{/} (free)`);
|
|
132
126
|
}
|
|
133
127
|
else if (c.startsWith('/model ')) {
|
|
134
128
|
const w = c.replace('/model ', '').trim();
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
129
|
+
const ok = ['nvidia', 'deepseek', 'groq', 'cerebras', 'mistral', 'openai', 'ollama'];
|
|
130
|
+
if (ok.includes(w)) {
|
|
137
131
|
activeModel = `${w}/auto`;
|
|
138
|
-
log.push(` ${D(`→ {#
|
|
132
|
+
log.push(` ${D(`→ {#059669-fg}${activeModel}{/}`)}`);
|
|
139
133
|
}
|
|
140
134
|
else
|
|
141
135
|
log.push(` ${D(`Unknown: ${w}`)}`);
|
|
@@ -145,7 +139,7 @@ function cmd(c) {
|
|
|
145
139
|
const cost = Math.random() * 0.00005;
|
|
146
140
|
totalCost += cost;
|
|
147
141
|
reqCount++;
|
|
148
|
-
log.push(` {#
|
|
142
|
+
log.push(` {#be185d-fg}A3M{/} {#059669-fg}${activeModel}{/} ${D('·')} {#d97706-fg}${ms}ms{/} ${D('·')} {#ea580c-fg}$${cost.toFixed(6)}{/}`);
|
|
149
143
|
log.push(` ${c}`);
|
|
150
144
|
}
|
|
151
145
|
while (log.length > 25)
|
|
@@ -153,10 +147,8 @@ function cmd(c) {
|
|
|
153
147
|
render();
|
|
154
148
|
prompt.focus();
|
|
155
149
|
}
|
|
156
|
-
// Keys
|
|
157
150
|
screen.key(['C-c', 'escape'], () => { screen.destroy(); process.exit(0); });
|
|
158
151
|
prompt.key('enter', () => { const v = prompt.getValue().trim(); prompt.clearValue(); cmd(v); });
|
|
159
|
-
// Start
|
|
160
152
|
screen.append(box);
|
|
161
153
|
render();
|
|
162
154
|
prompt.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/tui/dashboard.ts"],"names":[],"mappings":";;AACA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../../src/tui/dashboard.ts"],"names":[],"mappings":";;AACA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAmC;AAEnC,cAAc;AACd,IAAI,WAAW,GAAG,qBAAqB,CAAC;AACxC,IAAI,SAAS,GAAG,QAAQ,CAAC;AACzB,IAAI,QAAQ,GAAG,CAAC,CAAC;AACjB,MAAM,GAAG,GAAa,EAAE,CAAC;AAEzB,eAAe;AACf,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,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U,CAAC,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClJ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,GAAG,EAAE;QAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IACpC,MAAM,EAAE,CAAC;IACT,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5E,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACnB,MAAM,EAAE,CAAC;AACT,MAAM,CAAC,KAAK,EAAE,CAAC;AACf,MAAM,CAAC,MAAM,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adaptive-memory-multi-model-router",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.14",
|
|
4
4
|
"shortName": "A3M Router",
|
|
5
5
|
"displayName": "A3M Router - Adaptive Memory Multi-Model Router",
|
|
6
6
|
"description": "🔥 Fastest-growing npm LLM router — 0 to 10K downloads in 14 days. Parallel multi-LLM execution with independent benchmark validation (138ms baseline, +96ms proxy overhead), 47+ providers, 99.5% routing accuracy, 62% cost savings. Open-source AI gateway with ensemble voting, semantic cache, budget enforcement. 19.5 KB, zero ML.",
|
package/src/tui/dashboard.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* A3M Router — Overlay Box (
|
|
3
|
+
* A3M Router — Overlay Box TUI (Sakura Light Theme)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import * as blessed from 'blessed';
|
|
7
7
|
|
|
8
|
-
// State
|
|
8
|
+
// ── State ──
|
|
9
9
|
let activeModel = 'nvidia/llama-3.1-8b';
|
|
10
10
|
let totalCost = 0.000087;
|
|
11
11
|
let reqCount = 4;
|
|
12
12
|
const log: string[] = [];
|
|
13
13
|
|
|
14
|
-
// Screen
|
|
14
|
+
// ── Screen ──
|
|
15
15
|
const screen = blessed.screen({
|
|
16
16
|
smartCSR: true,
|
|
17
17
|
fullUnicode: true,
|
|
@@ -19,63 +19,55 @@ const screen = blessed.screen({
|
|
|
19
19
|
cursor: { shape: 'line', blink: true },
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
// Box settings
|
|
23
22
|
const BW = 82;
|
|
24
23
|
const BH = 18;
|
|
24
|
+
function L() { return Math.max(0, Math.floor(((screen.width as number) - BW) / 2)); }
|
|
25
|
+
function T() { return Math.max(0, Math.floor(((screen.height as number) - BH) / 2)); }
|
|
26
|
+
|
|
27
|
+
// ── SAKURA LIGHT THEME ──
|
|
28
|
+
// bg: #fff5f7 (blush white)
|
|
29
|
+
// srf: #fce7f3 (light pink)
|
|
30
|
+
// dim: #d8a4b8 (muted rose)
|
|
31
|
+
// txt: #831843 (deep maroon)
|
|
32
|
+
// pink:#be185d (hot pink)
|
|
33
|
+
// grn: #059669 (emerald)
|
|
34
|
+
// blu: #2563eb (royal blue)
|
|
35
|
+
// amb: #d97706 (amber)
|
|
36
|
+
// red: #dc2626 (crimson)
|
|
37
|
+
// cyn: #0891b2 (teal)
|
|
38
|
+
// prp: #7c3aed (violet)
|
|
25
39
|
|
|
26
|
-
function boxLeft() { return Math.max(0, Math.floor(((screen.width as number) - BW) / 2)); }
|
|
27
|
-
function boxTop() { return Math.max(0, Math.floor(((screen.height as number) - BH) / 2)); }
|
|
28
|
-
|
|
29
|
-
// Overlay box
|
|
30
40
|
const box = blessed.box({
|
|
31
|
-
top:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
border: { type: 'line', fg: 'magenta' },
|
|
36
|
-
style: { fg: '#c0caf5', bg: '#1a1b26' },
|
|
37
|
-
tags: true,
|
|
38
|
-
scrollable: true,
|
|
39
|
-
mouse: true,
|
|
40
|
-
keys: true,
|
|
41
|
+
top: T(), left: L(), width: BW, height: BH,
|
|
42
|
+
border: { type: 'line', fg: '#f472b6' },
|
|
43
|
+
style: { fg: '#831843', bg: '#fff5f7' },
|
|
44
|
+
tags: true, scrollable: true, mouse: true, keys: true,
|
|
41
45
|
padding: { left: 1, right: 1, top: 0, bottom: 0 },
|
|
42
46
|
});
|
|
43
47
|
|
|
44
|
-
// Prompt
|
|
45
48
|
const prompt = blessed.textbox({
|
|
46
|
-
parent: box,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
width: BW - 4,
|
|
50
|
-
height: 1,
|
|
51
|
-
style: { fg: '#c0caf5', bg: '#24283b' },
|
|
52
|
-
inputOnFocus: true,
|
|
53
|
-
keys: true,
|
|
54
|
-
tags: true,
|
|
49
|
+
parent: box, bottom: 1, left: 0, width: BW - 4, height: 1,
|
|
50
|
+
style: { fg: '#831843', bg: '#fce7f3' },
|
|
51
|
+
inputOnFocus: true, keys: true, tags: true,
|
|
55
52
|
});
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
const D = (s: string) => `{#565f89-fg}${s}{/}`;
|
|
54
|
+
const D = (s: string) => `{#d8a4b8-fg}${s}{/}`;
|
|
59
55
|
|
|
60
56
|
function render() {
|
|
61
57
|
const maxLines = BH - 4;
|
|
62
58
|
const visible = log.slice(-maxLines);
|
|
63
|
-
|
|
64
59
|
let out = '';
|
|
65
|
-
out += `{bold}{#
|
|
66
|
-
out += `${D('─'.repeat(BW - 6))}\n`;
|
|
67
|
-
out += '\n';
|
|
60
|
+
out += `{bold}{#be185d-fg}⚡ A3M Router{/} ${D('·')} {#059669-fg}${activeModel}{/} ${D('·')} ${D(`${reqCount} req`)} ${D('·')} ${D(`$${totalCost.toFixed(6)}`)}\n`;
|
|
61
|
+
out += `${D('─'.repeat(BW - 6))}\n\n`;
|
|
68
62
|
|
|
69
|
-
for (const line of visible)
|
|
70
|
-
out += line + '\n';
|
|
71
|
-
}
|
|
63
|
+
for (const line of visible) out += line + '\n';
|
|
72
64
|
|
|
73
65
|
if (visible.length === 0) {
|
|
74
66
|
out += ` ${D('Type a query — auto-routed to cheapest model.')}\n\n`;
|
|
75
67
|
out += ` ${D('Commands:')}\n`;
|
|
76
|
-
out += ` {#
|
|
77
|
-
out += ` {#
|
|
78
|
-
out += ` {#
|
|
68
|
+
out += ` {#2563eb-fg}/route{/} ${D('<query>')} /cost /model nvidia\n`;
|
|
69
|
+
out += ` {#2563eb-fg}/health{/} /models /clear\n`;
|
|
70
|
+
out += ` {#2563eb-fg}/exit{/} /help\n\n`;
|
|
79
71
|
out += ` ${D('nvidia (free) · groq (free) · deepseek ($9.46)')}\n`;
|
|
80
72
|
}
|
|
81
73
|
|
|
@@ -85,32 +77,32 @@ function render() {
|
|
|
85
77
|
|
|
86
78
|
function cmd(c: string) {
|
|
87
79
|
if (!c) return;
|
|
88
|
-
log.push(`{bold}{#
|
|
80
|
+
log.push(`{bold}{#0891b2-fg}▸{/} ${c}`);
|
|
89
81
|
|
|
90
82
|
if (c === '/exit' || c === '/q') { screen.destroy(); process.exit(0); }
|
|
91
83
|
else if (c === '/help') log.push(` ${D('/route /cost /health /models /model <p> /clear /exit')}`);
|
|
92
84
|
else if (c === '/clear') log.length = 0;
|
|
93
85
|
else if (c === '/cost') {
|
|
94
|
-
log.push(` {#
|
|
86
|
+
log.push(` {#be185d-fg}A3M{/} Cost:`);
|
|
95
87
|
log.push(` ${D('nvidia $0 | deepseek $0.000009 | groq $0 | cerebras $0')}`);
|
|
96
88
|
log.push(` ${D(`TOTAL $${totalCost.toFixed(6)} | ${reqCount} req | 99.97% saved`)}`);
|
|
97
89
|
} else if (c === '/health') {
|
|
98
|
-
log.push(` {#
|
|
99
|
-
log.push(` {#
|
|
100
|
-
log.push(` {#
|
|
90
|
+
log.push(` {#be185d-fg}A3M{/} Health:`);
|
|
91
|
+
log.push(` {#059669-fg}●{/} nvidia 85ms {#059669-fg}●{/} deepseek 210ms {#059669-fg}●{/} groq 150ms {#059669-fg}●{/} cerebras 320ms`);
|
|
92
|
+
log.push(` {#dc2626-fg}✕{/} mistral OFFLINE {#059669-fg}●{/} ollama 50ms`);
|
|
101
93
|
} else if (c === '/models') {
|
|
102
|
-
log.push(` {#
|
|
103
|
-
log.push(` {#
|
|
94
|
+
log.push(` {#be185d-fg}A3M{/} 47+ providers:`);
|
|
95
|
+
log.push(` {#059669-fg}● nvidia{/} (free) {#0891b2-fg}● groq{/} (free) {#d97706-fg}● deepseek{/} (cheap) {#7c3aed-fg}● cerebras{/} (free)`);
|
|
104
96
|
} else if (c.startsWith('/model ')) {
|
|
105
97
|
const w = c.replace('/model ', '').trim();
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
98
|
+
const ok = ['nvidia','deepseek','groq','cerebras','mistral','openai','ollama'];
|
|
99
|
+
if (ok.includes(w)) { activeModel = `${w}/auto`; log.push(` ${D(`→ {#059669-fg}${activeModel}{/}`)}`); }
|
|
108
100
|
else log.push(` ${D(`Unknown: ${w}`)}`);
|
|
109
101
|
} else {
|
|
110
102
|
const ms = Math.floor(Math.random() * 100) + 30;
|
|
111
103
|
const cost = Math.random() * 0.00005;
|
|
112
104
|
totalCost += cost; reqCount++;
|
|
113
|
-
log.push(` {#
|
|
105
|
+
log.push(` {#be185d-fg}A3M{/} {#059669-fg}${activeModel}{/} ${D('·')} {#d97706-fg}${ms}ms{/} ${D('·')} {#ea580c-fg}$${cost.toFixed(6)}{/}`);
|
|
114
106
|
log.push(` ${c}`);
|
|
115
107
|
}
|
|
116
108
|
|
|
@@ -119,11 +111,9 @@ function cmd(c: string) {
|
|
|
119
111
|
prompt.focus();
|
|
120
112
|
}
|
|
121
113
|
|
|
122
|
-
// Keys
|
|
123
114
|
screen.key(['C-c', 'escape'], () => { screen.destroy(); process.exit(0); });
|
|
124
115
|
prompt.key('enter', () => { const v = prompt.getValue().trim(); prompt.clearValue(); cmd(v); });
|
|
125
116
|
|
|
126
|
-
// Start
|
|
127
117
|
screen.append(box);
|
|
128
118
|
render();
|
|
129
119
|
prompt.focus();
|