@sofer_agent/cli 0.3.19 → 0.4.0
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/chat.d.ts.map +1 -1
- package/dist/chat.js +8 -2
- package/dist/chat.js.map +1 -1
- package/dist/tui.d.ts +21 -30
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +159 -265
- package/dist/tui.js.map +1 -1
- package/package.json +4 -2
- package/src/chat.ts +8 -2
- package/src/tui.ts +173 -251
package/dist/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAsCA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAsCA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAkCjD"}
|
package/dist/chat.js
CHANGED
|
@@ -46,7 +46,14 @@ export async function chatCommand() {
|
|
|
46
46
|
console.error("Missing secrets. Run `sofer init` first.");
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
let agent;
|
|
50
|
+
try {
|
|
51
|
+
agent = await SoferAgent.create(config, { suiSecretKey: secrets.suiSecretKey, anthropicApiKey: secrets.anthropicApiKey });
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.error("Failed to start agent (RPC may be down):", e.message);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
50
57
|
const sp = sessionPath(config);
|
|
51
58
|
if (sp) {
|
|
52
59
|
const h = loadSession(sp);
|
|
@@ -70,7 +77,6 @@ export async function chatCommand() {
|
|
|
70
77
|
agent.getBalance().then((b) => tui.setInfo({ balance: (Number(b) / 1e9).toFixed(4) })).catch(() => { });
|
|
71
78
|
if (sp)
|
|
72
79
|
saveSession(sp, agent.getHistory());
|
|
73
|
-
tui.render();
|
|
74
80
|
});
|
|
75
81
|
}
|
|
76
82
|
//# sourceMappingURL=chat.js.map
|
package/dist/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAoB,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIpC,SAAS,WAAW,CAAC,MAAmB;IACtC,IAAI,MAAM,CAAC,aAAa;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC;IAClG,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IACxG,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAC3B,IAAI,CAAC;YAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,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9D,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvF,CAAC;QACD,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACvG,IAAI,EAAE;YAAE,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,47 +1,38 @@
|
|
|
1
1
|
import type { SoferAgent, SoferConfig } from "@sofer_agent/core";
|
|
2
|
-
export interface ChatLine {
|
|
3
|
-
role: "you" | "agent" | "system" | "error";
|
|
4
|
-
text: string;
|
|
5
|
-
}
|
|
6
|
-
export interface TuiInfo {
|
|
7
|
-
lastTurnIn: number;
|
|
8
|
-
lastTurnOut: number;
|
|
9
|
-
balance?: string;
|
|
10
|
-
}
|
|
11
2
|
export declare class SoferTui {
|
|
12
3
|
private readonly agent;
|
|
13
4
|
private readonly config;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private bodyH;
|
|
21
|
-
private scrollOff;
|
|
5
|
+
private screen;
|
|
6
|
+
private chat;
|
|
7
|
+
private input;
|
|
8
|
+
private sidebar;
|
|
9
|
+
private spinnerBox;
|
|
10
|
+
private footer;
|
|
22
11
|
private status;
|
|
12
|
+
private abortCtrl;
|
|
23
13
|
private spinnerFrame;
|
|
24
14
|
private spinnerTimer;
|
|
25
15
|
private turnStartedAt;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
16
|
+
private lastTurnIn;
|
|
17
|
+
private lastTurnOut;
|
|
18
|
+
private balance?;
|
|
28
19
|
private resolve;
|
|
29
20
|
private onLine;
|
|
21
|
+
private agentName;
|
|
30
22
|
constructor(agent: SoferAgent, config: SoferConfig);
|
|
31
|
-
private
|
|
32
|
-
addMessage(role:
|
|
33
|
-
setInfo(info:
|
|
23
|
+
private submit;
|
|
24
|
+
addMessage(role: string, text: string): void;
|
|
25
|
+
setInfo(info: {
|
|
26
|
+
lastTurnIn?: number;
|
|
27
|
+
lastTurnOut?: number;
|
|
28
|
+
balance?: string;
|
|
29
|
+
}): void;
|
|
34
30
|
private startSpinner;
|
|
35
31
|
private stopSpinner;
|
|
32
|
+
private renderSpinner;
|
|
33
|
+
private buildSidebarContent;
|
|
34
|
+
private renderFooter;
|
|
36
35
|
run(onLine: (line: string, signal?: AbortSignal) => Promise<void>): Promise<void>;
|
|
37
36
|
private shutdown;
|
|
38
|
-
private handleInput;
|
|
39
|
-
private submit;
|
|
40
|
-
private handleResize;
|
|
41
|
-
render(): void;
|
|
42
|
-
private buildFrame;
|
|
43
|
-
private wrapMessage;
|
|
44
|
-
private roleLabel;
|
|
45
|
-
private buildSidebar;
|
|
46
37
|
}
|
|
47
38
|
//# sourceMappingURL=tui.d.ts.map
|
package/dist/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIjE,qBAAa,QAAQ;IAoBjB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,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|
|
2
|
-
const MIN_CHAT_W = 34;
|
|
3
|
-
const GUTTER = " ";
|
|
4
|
-
const LABEL_W = 6;
|
|
5
|
-
const INDENT = `${GUTTER}${" ".repeat(LABEL_W + 1)}`;
|
|
1
|
+
import blessed from "blessed";
|
|
6
2
|
const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
7
|
-
const SPINNER_MS = 80;
|
|
8
|
-
const B = {
|
|
9
|
-
tl: "╭", tr: "╮", bl: "╰", br: "╯",
|
|
10
|
-
h: "─", v: "│",
|
|
11
|
-
lt: "├", rt: "┤", tt: "┬", bt: "┴",
|
|
12
|
-
};
|
|
13
3
|
export class SoferTui {
|
|
14
4
|
agent;
|
|
15
5
|
config;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
bodyH = 22;
|
|
23
|
-
scrollOff = Number.MAX_SAFE_INTEGER;
|
|
6
|
+
screen;
|
|
7
|
+
chat;
|
|
8
|
+
input;
|
|
9
|
+
sidebar;
|
|
10
|
+
spinnerBox;
|
|
11
|
+
footer;
|
|
24
12
|
status = "idle";
|
|
13
|
+
abortCtrl = null;
|
|
25
14
|
spinnerFrame = 0;
|
|
26
15
|
spinnerTimer = null;
|
|
27
16
|
turnStartedAt = 0;
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
lastTurnIn = 0;
|
|
18
|
+
lastTurnOut = 0;
|
|
19
|
+
balance;
|
|
30
20
|
resolve = null;
|
|
31
21
|
onLine = null;
|
|
22
|
+
agentName;
|
|
32
23
|
constructor(agent, config) {
|
|
33
24
|
this.agent = agent;
|
|
34
25
|
this.config = config;
|
|
26
|
+
this.agentName = agent.name.toLowerCase();
|
|
27
|
+
this.screen = blessed.screen({ smartCSR: true, title: "sofer" });
|
|
28
|
+
this.chat = blessed.log({
|
|
29
|
+
parent: this.screen,
|
|
30
|
+
top: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
width: "75%",
|
|
33
|
+
height: "80%",
|
|
34
|
+
border: { type: "line" },
|
|
35
|
+
label: ` ${this.agentName} `,
|
|
36
|
+
scrollable: true,
|
|
37
|
+
alwaysScroll: true,
|
|
38
|
+
scrollOnInput: true,
|
|
39
|
+
keys: true,
|
|
40
|
+
vi: true,
|
|
41
|
+
mouse: true,
|
|
42
|
+
tags: true,
|
|
43
|
+
});
|
|
44
|
+
this.sidebar = blessed.box({
|
|
45
|
+
parent: this.screen,
|
|
46
|
+
top: 0,
|
|
47
|
+
left: "75%",
|
|
48
|
+
width: "25%",
|
|
49
|
+
height: "80%",
|
|
50
|
+
border: { type: "line" },
|
|
51
|
+
label: " stats ",
|
|
52
|
+
content: this.buildSidebarContent(),
|
|
53
|
+
tags: true,
|
|
54
|
+
});
|
|
55
|
+
this.spinnerBox = blessed.box({
|
|
56
|
+
parent: this.screen,
|
|
57
|
+
top: "80%",
|
|
58
|
+
left: 0,
|
|
59
|
+
width: "100%",
|
|
60
|
+
height: 3,
|
|
61
|
+
content: "",
|
|
62
|
+
tags: true,
|
|
63
|
+
});
|
|
64
|
+
this.input = blessed.textbox({
|
|
65
|
+
parent: this.screen,
|
|
66
|
+
top: "83%",
|
|
67
|
+
left: 0,
|
|
68
|
+
width: "100%",
|
|
69
|
+
height: 3,
|
|
70
|
+
inputOnFocus: true,
|
|
71
|
+
border: { type: "line" },
|
|
72
|
+
label: " you ",
|
|
73
|
+
keys: true,
|
|
74
|
+
vi: true,
|
|
75
|
+
style: { focus: { border: { fg: "cyan" } } },
|
|
76
|
+
});
|
|
77
|
+
this.footer = blessed.box({
|
|
78
|
+
parent: this.screen,
|
|
79
|
+
bottom: 0,
|
|
80
|
+
left: 0,
|
|
81
|
+
width: "100%",
|
|
82
|
+
height: 1,
|
|
83
|
+
content: "",
|
|
84
|
+
tags: true,
|
|
85
|
+
});
|
|
86
|
+
this.renderFooter();
|
|
87
|
+
this.input.key(["enter"], () => this.submit());
|
|
88
|
+
this.input.key(["escape"], () => {
|
|
89
|
+
if (this.status === "thinking" && this.abortCtrl) {
|
|
90
|
+
this.abortCtrl.abort();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.input.clearValue();
|
|
94
|
+
this.screen.render();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
this.input.on("cancel", () => this.input.clearValue());
|
|
98
|
+
this.screen.key(["C-c"], () => this.shutdown());
|
|
99
|
+
this.screen.key(["C-d"], () => {
|
|
100
|
+
if (this.input.getValue() === "")
|
|
101
|
+
this.shutdown();
|
|
102
|
+
});
|
|
35
103
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
104
|
+
submit() {
|
|
105
|
+
const text = this.input.getValue().trim();
|
|
106
|
+
this.input.clearValue();
|
|
107
|
+
if (!text)
|
|
108
|
+
return;
|
|
109
|
+
if (text === "/exit" || text === "/quit") {
|
|
110
|
+
this.shutdown();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.chat.log(`{cyan-fg} you {/cyan-fg} ${text}`);
|
|
114
|
+
this.abortCtrl = new AbortController();
|
|
115
|
+
this.startSpinner();
|
|
116
|
+
this.screen.render();
|
|
117
|
+
this.onLine?.(text, this.abortCtrl.signal).finally(() => {
|
|
118
|
+
this.abortCtrl = null;
|
|
119
|
+
this.stopSpinner();
|
|
120
|
+
this.sidebar.setContent(this.buildSidebarContent());
|
|
121
|
+
this.renderFooter();
|
|
122
|
+
this.screen.render();
|
|
123
|
+
});
|
|
42
124
|
}
|
|
43
125
|
addMessage(role, text) {
|
|
44
|
-
|
|
45
|
-
|
|
126
|
+
const color = role === "agent" ? "green-fg"
|
|
127
|
+
: role === "error" ? "red-fg"
|
|
128
|
+
: role === "system" ? "gray-fg"
|
|
129
|
+
: "cyan-fg";
|
|
130
|
+
const label = role === "agent" ? this.agentName
|
|
131
|
+
: role === "error" ? "err"
|
|
132
|
+
: role === "system" ? "sys"
|
|
133
|
+
: "you";
|
|
134
|
+
this.chat.log(`{${color}} ${label.padEnd(5)} {/${color}} ${text}`);
|
|
46
135
|
}
|
|
47
136
|
setInfo(info) {
|
|
48
|
-
|
|
137
|
+
if (info.lastTurnIn !== undefined)
|
|
138
|
+
this.lastTurnIn = info.lastTurnIn;
|
|
139
|
+
if (info.lastTurnOut !== undefined)
|
|
140
|
+
this.lastTurnOut = info.lastTurnOut;
|
|
141
|
+
if (info.balance !== undefined)
|
|
142
|
+
this.balance = info.balance;
|
|
49
143
|
}
|
|
50
144
|
startSpinner() {
|
|
51
|
-
if (this.spinnerTimer)
|
|
52
|
-
return;
|
|
53
145
|
this.status = "thinking";
|
|
54
146
|
this.turnStartedAt = Date.now();
|
|
55
147
|
this.spinnerFrame = 0;
|
|
56
148
|
this.spinnerTimer = setInterval(() => {
|
|
57
149
|
this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER_FRAMES.length;
|
|
58
|
-
this.
|
|
59
|
-
|
|
150
|
+
this.renderSpinner();
|
|
151
|
+
this.screen.render();
|
|
152
|
+
}, 80);
|
|
60
153
|
}
|
|
61
154
|
stopSpinner() {
|
|
62
155
|
this.status = "idle";
|
|
@@ -65,248 +158,49 @@ export class SoferTui {
|
|
|
65
158
|
clearInterval(this.spinnerTimer);
|
|
66
159
|
this.spinnerTimer = null;
|
|
67
160
|
}
|
|
161
|
+
this.spinnerBox.setContent("");
|
|
68
162
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
process.stdin.setRawMode?.(true);
|
|
74
|
-
process.stdin.on("data", this.handleInput);
|
|
75
|
-
process.stdout.on("resize", this.handleResize);
|
|
76
|
-
process.on("SIGWINCH", this.handleResize);
|
|
77
|
-
this.render();
|
|
78
|
-
return new Promise((resolve) => { this.resolve = resolve; });
|
|
79
|
-
}
|
|
80
|
-
shutdown() {
|
|
81
|
-
this.stopSpinner();
|
|
82
|
-
process.stdin.setRawMode?.(false);
|
|
83
|
-
process.stdin.removeAllListeners("data");
|
|
84
|
-
process.stdout.removeAllListeners("resize");
|
|
85
|
-
process.removeAllListeners("SIGWINCH");
|
|
86
|
-
this.render();
|
|
87
|
-
process.stdout.write("\n");
|
|
88
|
-
this.resolve?.();
|
|
89
|
-
}
|
|
90
|
-
handleInput = (data) => {
|
|
91
|
-
for (const ch of data.toString()) {
|
|
92
|
-
const code = ch.charCodeAt(0);
|
|
93
|
-
if (code === 3) {
|
|
94
|
-
this.shutdown();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (code === 4 && this.inputBuf.length === 0) {
|
|
98
|
-
this.shutdown();
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (code === 27) {
|
|
102
|
-
if (this.status === "thinking" && this.abortCtrl) {
|
|
103
|
-
this.abortCtrl.abort();
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.inputBuf = "";
|
|
107
|
-
this.render();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (this.status === "thinking")
|
|
111
|
-
continue;
|
|
112
|
-
if (code === 13) {
|
|
113
|
-
this.submit();
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (code === 127) {
|
|
117
|
-
this.inputBuf = this.inputBuf.slice(0, -1);
|
|
118
|
-
this.render();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (ch >= " ") {
|
|
122
|
-
this.inputBuf += ch;
|
|
123
|
-
this.render();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
async submit() {
|
|
128
|
-
const line = this.inputBuf.trim();
|
|
129
|
-
this.inputBuf = "";
|
|
130
|
-
if (!line) {
|
|
131
|
-
this.render();
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (line === "/exit" || line === "/quit") {
|
|
135
|
-
this.shutdown();
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
this.addMessage("you", line);
|
|
139
|
-
this.abortCtrl = new AbortController();
|
|
140
|
-
this.startSpinner();
|
|
141
|
-
this.render();
|
|
142
|
-
await this.onLine?.(line, this.abortCtrl.signal);
|
|
143
|
-
this.abortCtrl = null;
|
|
144
|
-
this.stopSpinner();
|
|
145
|
-
this.render();
|
|
146
|
-
}
|
|
147
|
-
handleResize = () => { this.measure(); this.render(); };
|
|
148
|
-
render() {
|
|
149
|
-
this.measure();
|
|
150
|
-
process.stdout.write("\x1b[?25l\x1b[2J\x1b[H" + this.buildFrame() + "\x1b[?25h");
|
|
151
|
-
}
|
|
152
|
-
buildFrame() {
|
|
153
|
-
const { columns, chatW, sideW, bodyH } = this;
|
|
154
|
-
const innerSideW = sideW - 2;
|
|
155
|
-
const sep = `${B.lt}${B.h.repeat(chatW)}${B.bt}${B.h.repeat(sideW)}${B.rt}`;
|
|
156
|
-
const inputW = columns - 2;
|
|
157
|
-
let buf = `${B.tl}${B.h.repeat(chatW)}${B.tt}${B.h.repeat(sideW)}${B.tr}\n`;
|
|
158
|
-
const wrapped = this.state.flatMap((m) => this.wrapMessage(m, chatW));
|
|
159
|
-
const maxScroll = Math.max(0, wrapped.length - bodyH);
|
|
160
|
-
if (this.scrollOff > maxScroll)
|
|
161
|
-
this.scrollOff = maxScroll;
|
|
162
|
-
if (this.scrollOff < 0)
|
|
163
|
-
this.scrollOff = 0;
|
|
164
|
-
const visible = wrapped.slice(this.scrollOff, this.scrollOff + bodyH);
|
|
165
|
-
const sidebarLines = this.buildSidebar(innerSideW);
|
|
166
|
-
const sbTop = Math.max(0, Math.floor((bodyH - sidebarLines.length) / 2));
|
|
167
|
-
for (let r = 0; r < bodyH; r++) {
|
|
168
|
-
buf += B.v;
|
|
169
|
-
const line = visible[r];
|
|
170
|
-
if (line)
|
|
171
|
-
buf += padTrunc(line, chatW);
|
|
172
|
-
else
|
|
173
|
-
buf += " ".repeat(chatW);
|
|
174
|
-
buf += B.v;
|
|
175
|
-
const sbIdx = r - sbTop;
|
|
176
|
-
const sbLine = (sbIdx >= 0 && sbIdx < sidebarLines.length) ? sidebarLines[sbIdx] : "";
|
|
177
|
-
buf += ` ${padRight(sbLine, innerSideW)} `;
|
|
178
|
-
buf += `${B.v}\n`;
|
|
179
|
-
}
|
|
180
|
-
buf += `${sep}\n`;
|
|
181
|
-
if (this.status === "thinking") {
|
|
182
|
-
const frame = SPINNER_FRAMES[this.spinnerFrame];
|
|
183
|
-
const elapsed = this.turnStartedAt ? formatElapsed(Date.now() - this.turnStartedAt) : "";
|
|
184
|
-
const st = ` ${frame} thinking…${elapsed ? ` ${elapsed}` : ""} (esc to interrupt)`;
|
|
185
|
-
buf += `${B.v}\x1b[36m${st}\x1b[0m${" ".repeat(Math.max(0, columns - 2 - st.length - 2))}${B.v}\n`;
|
|
186
|
-
}
|
|
187
|
-
buf += `${B.tl}${B.h.repeat(inputW)}${B.tr}\n`;
|
|
188
|
-
const cursorCh = this.status === "idle" ? "\x1b[5m▋\x1b[25m" : "";
|
|
189
|
-
const inputMaxW = inputW - 4;
|
|
190
|
-
const vi = this.inputBuf.slice(Math.max(0, this.inputBuf.length - inputMaxW));
|
|
191
|
-
buf += `${B.v} \x1b[36m>\x1b[0m ${vi}${cursorCh}${" ".repeat(Math.max(0, inputMaxW - vi.length))} ${B.v}\n`;
|
|
192
|
-
buf += `${B.bl}${B.h.repeat(inputW)}${B.br}\n`;
|
|
193
|
-
const totalIn = this.agent.usage.tokens.inputTokens;
|
|
194
|
-
const totalOut = this.agent.usage.tokens.outputTokens;
|
|
195
|
-
const cost = this.agent.usage.costUsd.toFixed(4);
|
|
196
|
-
const ft = `\x1b[90m${this.agent.address.slice(0, 10)}… · in ${totalIn} out ${totalOut} $${cost} /exit\x1b[0m`;
|
|
197
|
-
buf += `${padTrunc(ft, columns)}\n`;
|
|
198
|
-
const cursorRow = bodyH + 4 + (this.status === "thinking" ? 1 : 0);
|
|
199
|
-
const cursorCol = 4 + Math.min(vi.length + (cursorCh ? 0 : 0), inputMaxW);
|
|
200
|
-
buf += `\x1b[${cursorRow};${cursorCol}H`;
|
|
201
|
-
return buf;
|
|
202
|
-
}
|
|
203
|
-
wrapMessage(msg, width) {
|
|
204
|
-
const label = this.roleLabel(msg.role);
|
|
205
|
-
const bodyWidth = Math.max(10, width - GUTTER.length - LABEL_W - 1);
|
|
206
|
-
const lines = wrapText(msg.text, bodyWidth);
|
|
207
|
-
return lines.map((l, i) => i === 0 ? `${GUTTER}${label} ${l}` : `${INDENT}${l}`);
|
|
163
|
+
renderSpinner() {
|
|
164
|
+
const frame = SPINNER_FRAMES[this.spinnerFrame];
|
|
165
|
+
const elapsed = this.turnStartedAt ? formatElapsed(Date.now() - this.turnStartedAt) : "";
|
|
166
|
+
this.spinnerBox.setContent(`{cyan-fg}${frame} thinking…${elapsed ? ` ${elapsed}` : ""} (esc to interrupt){/cyan-fg}`);
|
|
208
167
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
case "you": return "\x1b[36myou \x1b[0m";
|
|
212
|
-
case "agent": return `\x1b[32m${this.agent.name.toLowerCase().padEnd(LABEL_W)}\x1b[0m`;
|
|
213
|
-
case "system": return "\x1b[90msys \x1b[0m";
|
|
214
|
-
case "error": return "\x1b[31merr \x1b[0m";
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
buildSidebar(width) {
|
|
218
|
-
const { agent, config, info } = this;
|
|
168
|
+
buildSidebarContent() {
|
|
169
|
+
const { agent, config } = this;
|
|
219
170
|
const addr = `${agent.address.slice(0, 6)}…${agent.address.slice(-4)}`;
|
|
171
|
+
const cost = agent.usage.costUsd.toFixed(6);
|
|
220
172
|
const totalIn = agent.usage.tokens.inputTokens;
|
|
221
173
|
const totalOut = agent.usage.tokens.outputTokens;
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
`\x1b[90m${addr}\x1b[0m`,
|
|
174
|
+
const lines = [
|
|
175
|
+
`{bold}{green-fg}${agent.name}{/green-fg}{/bold}`,
|
|
176
|
+
`{gray-fg}${addr}{/gray-fg}`,
|
|
226
177
|
"",
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
`\x1b[90mmodel\x1b[0m ${shortModel(config.brain.model)}`,
|
|
178
|
+
`{gray-fg}network ${config.network}{/gray-fg}`,
|
|
179
|
+
`{gray-fg}model ${shortModel(config.brain.model)}{/gray-fg}`,
|
|
230
180
|
];
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return
|
|
181
|
+
if (this.balance)
|
|
182
|
+
lines.push("", `{gray-fg}balance {/gray-fg}{yellow-fg}${this.balance} SUI{/yellow-fg}`);
|
|
183
|
+
lines.push("", `{gray-fg}last{/gray-fg} in ${this.lastTurnIn} out ${this.lastTurnOut}`, "", `{gray-fg}total{/gray-fg} in ${totalIn} out ${totalOut}`, ` {yellow-fg}$${cost}{/yellow-fg}`);
|
|
184
|
+
return lines.join("\n");
|
|
235
185
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const words = para.split(" ");
|
|
243
|
-
let cur = "";
|
|
244
|
-
for (const w of words) {
|
|
245
|
-
if (w.length > width) {
|
|
246
|
-
if (cur) {
|
|
247
|
-
lines.push(cur);
|
|
248
|
-
cur = "";
|
|
249
|
-
}
|
|
250
|
-
for (let i = 0; i < w.length; i += width)
|
|
251
|
-
lines.push(w.slice(i, i + width));
|
|
252
|
-
}
|
|
253
|
-
else if (cur && cur.length + 1 + w.length > width) {
|
|
254
|
-
lines.push(cur);
|
|
255
|
-
cur = w;
|
|
256
|
-
}
|
|
257
|
-
else
|
|
258
|
-
cur = cur ? `${cur} ${w}` : w;
|
|
259
|
-
}
|
|
260
|
-
if (cur)
|
|
261
|
-
lines.push(cur);
|
|
186
|
+
renderFooter() {
|
|
187
|
+
const { agent } = this;
|
|
188
|
+
const totalIn = agent.usage.tokens.inputTokens;
|
|
189
|
+
const totalOut = agent.usage.tokens.outputTokens;
|
|
190
|
+
const cost = agent.usage.costUsd.toFixed(4);
|
|
191
|
+
this.footer.setContent(`{gray-fg}${agent.address.slice(0, 12)}… · in ${totalIn} out ${totalOut} $${cost} /exit{/gray-fg}`);
|
|
262
192
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
function visibleLen(s) {
|
|
270
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape stripping
|
|
271
|
-
const re = /\x1b\[\d*;?\d*m/g;
|
|
272
|
-
let len = 0, last = 0, m = re.exec(s);
|
|
273
|
-
while (m !== null) {
|
|
274
|
-
len += m.index - last;
|
|
275
|
-
last = m.index + m[0].length;
|
|
276
|
-
m = re.exec(s);
|
|
193
|
+
async run(onLine) {
|
|
194
|
+
this.onLine = onLine;
|
|
195
|
+
this.input.focus();
|
|
196
|
+
this.screen.render();
|
|
197
|
+
return new Promise((resolve) => { this.resolve = resolve; });
|
|
277
198
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return vl >= w ? s : s + " ".repeat(w - vl);
|
|
283
|
-
}
|
|
284
|
-
function padTrunc(s, w) {
|
|
285
|
-
const vl = visibleLen(s);
|
|
286
|
-
if (vl < w)
|
|
287
|
-
return s + " ".repeat(w - vl);
|
|
288
|
-
if (vl === w)
|
|
289
|
-
return s;
|
|
290
|
-
let out = "", visible = 0, i = 0;
|
|
291
|
-
while (i < s.length && visible < w) {
|
|
292
|
-
if (s[i] === "\x1b" && s[i + 1] === "[") {
|
|
293
|
-
const end = s.indexOf("m", i);
|
|
294
|
-
if (end !== -1) {
|
|
295
|
-
out += s.slice(i, end + 1);
|
|
296
|
-
i = end + 1;
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
out += s[i];
|
|
300
|
-
i++;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
out += s[i];
|
|
305
|
-
visible++;
|
|
306
|
-
i++;
|
|
307
|
-
}
|
|
199
|
+
shutdown() {
|
|
200
|
+
this.stopSpinner();
|
|
201
|
+
this.screen.destroy();
|
|
202
|
+
this.resolve?.();
|
|
308
203
|
}
|
|
309
|
-
return out;
|
|
310
204
|
}
|
|
311
205
|
function formatElapsed(ms) {
|
|
312
206
|
const sec = Math.floor(ms / 1000);
|
package/dist/tui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,MAAM,GAAG,IAAI,CAAC;AACpB,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC;AACrD,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1E,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,MAAM,CAAC,GAAG;IACR,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG;IAClC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG;IACd,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG;CACnC,CAAC;AAaF,MAAM,OAAO,QAAQ;IAmBA;IACA;IAnBX,KAAK,GAAe,EAAE,CAAC;IACvB,QAAQ,GAAG,EAAE,CAAC;IACd,OAAO,GAAG,EAAE,CAAC;IACb,IAAI,GAAG,EAAE,CAAC;I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CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sofer_agent/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sofer": "./bin/sofer"
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@clack/prompts": "^1.5.1",
|
|
30
|
-
"@sofer_agent/core": "0.3.3"
|
|
30
|
+
"@sofer_agent/core": "0.3.3",
|
|
31
|
+
"@types/blessed": "^0.1.27",
|
|
32
|
+
"blessed": "^0.1.81"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/node": "^22.10.2",
|
package/src/chat.ts
CHANGED
|
@@ -43,7 +43,14 @@ export async function chatCommand(): Promise<void> {
|
|
|
43
43
|
console.error("Missing secrets. Run `sofer init` first.");
|
|
44
44
|
process.exit(1);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
let agent: SoferAgent;
|
|
48
|
+
try {
|
|
49
|
+
agent = await SoferAgent.create(config, { suiSecretKey: secrets.suiSecretKey, anthropicApiKey: secrets.anthropicApiKey });
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error("Failed to start agent (RPC may be down):", (e as Error).message);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
47
54
|
|
|
48
55
|
const sp = sessionPath(config);
|
|
49
56
|
if (sp) { const h = loadSession(sp); if (h.length > 0) agent.loadHistory(h); }
|
|
@@ -62,6 +69,5 @@ export async function chatCommand(): Promise<void> {
|
|
|
62
69
|
}
|
|
63
70
|
agent.getBalance().then((b) => tui.setInfo({ balance: (Number(b) / 1e9).toFixed(4) })).catch(() => {});
|
|
64
71
|
if (sp) saveSession(sp, agent.getHistory());
|
|
65
|
-
tui.render();
|
|
66
72
|
});
|
|
67
73
|
}
|
package/src/tui.ts
CHANGED
|
@@ -1,306 +1,228 @@
|
|
|
1
|
+
import blessed from "blessed";
|
|
1
2
|
import type { SoferAgent, SoferConfig } from "@sofer_agent/core";
|
|
2
3
|
|
|
3
|
-
const SIDEBAR_W = 28;
|
|
4
|
-
const MIN_CHAT_W = 34;
|
|
5
|
-
const GUTTER = " ";
|
|
6
|
-
const LABEL_W = 6;
|
|
7
|
-
const INDENT = `${GUTTER}${" ".repeat(LABEL_W + 1)}`;
|
|
8
4
|
const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
9
|
-
const SPINNER_MS = 80;
|
|
10
|
-
|
|
11
|
-
const B = {
|
|
12
|
-
tl: "╭", tr: "╮", bl: "╰", br: "╯",
|
|
13
|
-
h: "─", v: "│",
|
|
14
|
-
lt: "├", rt: "┤", tt: "┬", bt: "┴",
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export interface ChatLine {
|
|
18
|
-
role: "you" | "agent" | "system" | "error";
|
|
19
|
-
text: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface TuiInfo {
|
|
23
|
-
lastTurnIn: number;
|
|
24
|
-
lastTurnOut: number;
|
|
25
|
-
balance?: string;
|
|
26
|
-
}
|
|
27
5
|
|
|
28
6
|
export class SoferTui {
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private bodyH = 22;
|
|
36
|
-
private scrollOff = Number.MAX_SAFE_INTEGER;
|
|
7
|
+
private screen: ReturnType<typeof blessed.screen>;
|
|
8
|
+
private chat: ReturnType<typeof blessed.log>;
|
|
9
|
+
private input: ReturnType<typeof blessed.textbox>;
|
|
10
|
+
private sidebar: ReturnType<typeof blessed.box>;
|
|
11
|
+
private spinnerBox: ReturnType<typeof blessed.box>;
|
|
12
|
+
private footer: ReturnType<typeof blessed.box>;
|
|
37
13
|
private status: "idle" | "thinking" = "idle";
|
|
14
|
+
private abortCtrl: AbortController | null = null;
|
|
38
15
|
private spinnerFrame = 0;
|
|
39
16
|
private spinnerTimer: ReturnType<typeof setInterval> | null = null;
|
|
40
17
|
private turnStartedAt = 0;
|
|
41
|
-
private
|
|
42
|
-
private
|
|
18
|
+
private lastTurnIn = 0;
|
|
19
|
+
private lastTurnOut = 0;
|
|
20
|
+
private balance?: string;
|
|
43
21
|
private resolve: (() => void) | null = null;
|
|
44
22
|
private onLine: ((line: string, signal?: AbortSignal) => Promise<void>) | null = null;
|
|
23
|
+
private agentName: string;
|
|
45
24
|
|
|
46
25
|
constructor(
|
|
47
26
|
private readonly agent: SoferAgent,
|
|
48
27
|
private readonly config: SoferConfig,
|
|
49
|
-
) {
|
|
28
|
+
) {
|
|
29
|
+
this.agentName = agent.name.toLowerCase();
|
|
30
|
+
|
|
31
|
+
this.screen = blessed.screen({ smartCSR: true, title: "sofer" });
|
|
32
|
+
|
|
33
|
+
this.chat = blessed.log({
|
|
34
|
+
parent: this.screen,
|
|
35
|
+
top: 0,
|
|
36
|
+
left: 0,
|
|
37
|
+
width: "75%",
|
|
38
|
+
height: "80%",
|
|
39
|
+
border: { type: "line" },
|
|
40
|
+
label: ` ${this.agentName} `,
|
|
41
|
+
scrollable: true,
|
|
42
|
+
alwaysScroll: true,
|
|
43
|
+
scrollOnInput: true,
|
|
44
|
+
keys: true,
|
|
45
|
+
vi: true,
|
|
46
|
+
mouse: true,
|
|
47
|
+
tags: true,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
this.sidebar = blessed.box({
|
|
51
|
+
parent: this.screen,
|
|
52
|
+
top: 0,
|
|
53
|
+
left: "75%",
|
|
54
|
+
width: "25%",
|
|
55
|
+
height: "80%",
|
|
56
|
+
border: { type: "line" },
|
|
57
|
+
label: " stats ",
|
|
58
|
+
content: this.buildSidebarContent(),
|
|
59
|
+
tags: true,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this.spinnerBox = blessed.box({
|
|
63
|
+
parent: this.screen,
|
|
64
|
+
top: "80%",
|
|
65
|
+
left: 0,
|
|
66
|
+
width: "100%",
|
|
67
|
+
height: 3,
|
|
68
|
+
content: "",
|
|
69
|
+
tags: true,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
this.input = blessed.textbox({
|
|
73
|
+
parent: this.screen,
|
|
74
|
+
top: "83%",
|
|
75
|
+
left: 0,
|
|
76
|
+
width: "100%",
|
|
77
|
+
height: 3,
|
|
78
|
+
inputOnFocus: true,
|
|
79
|
+
border: { type: "line" },
|
|
80
|
+
label: " you ",
|
|
81
|
+
keys: true,
|
|
82
|
+
vi: true,
|
|
83
|
+
style: { focus: { border: { fg: "cyan" } } },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
this.footer = blessed.box({
|
|
87
|
+
parent: this.screen,
|
|
88
|
+
bottom: 0,
|
|
89
|
+
left: 0,
|
|
90
|
+
width: "100%",
|
|
91
|
+
height: 1,
|
|
92
|
+
content: "",
|
|
93
|
+
tags: true,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
this.renderFooter();
|
|
97
|
+
|
|
98
|
+
this.input.key(["enter"], () => this.submit());
|
|
99
|
+
this.input.key(["escape"], () => {
|
|
100
|
+
if (this.status === "thinking" && this.abortCtrl) {
|
|
101
|
+
this.abortCtrl.abort();
|
|
102
|
+
} else {
|
|
103
|
+
this.input.clearValue();
|
|
104
|
+
this.screen.render();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
this.input.on("cancel", () => this.input.clearValue());
|
|
50
108
|
|
|
51
|
-
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.sideW = this.columns - this.chatW - 3;
|
|
56
|
-
this.bodyH = this.rows - 5;
|
|
109
|
+
this.screen.key(["C-c"], () => this.shutdown());
|
|
110
|
+
this.screen.key(["C-d"], () => {
|
|
111
|
+
if (this.input.getValue() === "") this.shutdown();
|
|
112
|
+
});
|
|
57
113
|
}
|
|
58
114
|
|
|
59
|
-
|
|
60
|
-
this.
|
|
61
|
-
this.
|
|
115
|
+
private submit(): void {
|
|
116
|
+
const text = this.input.getValue().trim();
|
|
117
|
+
this.input.clearValue();
|
|
118
|
+
if (!text) return;
|
|
119
|
+
if (text === "/exit" || text === "/quit") { this.shutdown(); return; }
|
|
120
|
+
|
|
121
|
+
this.chat.log(`{cyan-fg} you {/cyan-fg} ${text}`);
|
|
122
|
+
this.abortCtrl = new AbortController();
|
|
123
|
+
this.startSpinner();
|
|
124
|
+
this.screen.render();
|
|
125
|
+
|
|
126
|
+
this.onLine?.(text, this.abortCtrl.signal).finally(() => {
|
|
127
|
+
this.abortCtrl = null;
|
|
128
|
+
this.stopSpinner();
|
|
129
|
+
this.sidebar.setContent(this.buildSidebarContent());
|
|
130
|
+
this.renderFooter();
|
|
131
|
+
this.screen.render();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
addMessage(role: string, text: string): void {
|
|
136
|
+
const color = role === "agent" ? "green-fg"
|
|
137
|
+
: role === "error" ? "red-fg"
|
|
138
|
+
: role === "system" ? "gray-fg"
|
|
139
|
+
: "cyan-fg";
|
|
140
|
+
const label = role === "agent" ? this.agentName
|
|
141
|
+
: role === "error" ? "err"
|
|
142
|
+
: role === "system" ? "sys"
|
|
143
|
+
: "you";
|
|
144
|
+
this.chat.log(`{${color}} ${label.padEnd(5)} {/${color}} ${text}`);
|
|
62
145
|
}
|
|
63
146
|
|
|
64
|
-
setInfo(info:
|
|
65
|
-
|
|
147
|
+
setInfo(info: { lastTurnIn?: number; lastTurnOut?: number; balance?: string }): void {
|
|
148
|
+
if (info.lastTurnIn !== undefined) this.lastTurnIn = info.lastTurnIn;
|
|
149
|
+
if (info.lastTurnOut !== undefined) this.lastTurnOut = info.lastTurnOut;
|
|
150
|
+
if (info.balance !== undefined) this.balance = info.balance;
|
|
66
151
|
}
|
|
67
152
|
|
|
68
153
|
private startSpinner(): void {
|
|
69
|
-
if (this.spinnerTimer) return;
|
|
70
154
|
this.status = "thinking";
|
|
71
155
|
this.turnStartedAt = Date.now();
|
|
72
156
|
this.spinnerFrame = 0;
|
|
73
157
|
this.spinnerTimer = setInterval(() => {
|
|
74
158
|
this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER_FRAMES.length;
|
|
75
|
-
this.
|
|
76
|
-
|
|
159
|
+
this.renderSpinner();
|
|
160
|
+
this.screen.render();
|
|
161
|
+
}, 80);
|
|
77
162
|
}
|
|
78
163
|
|
|
79
164
|
private stopSpinner(): void {
|
|
80
165
|
this.status = "idle";
|
|
81
166
|
this.turnStartedAt = 0;
|
|
82
|
-
if (this.spinnerTimer) {
|
|
83
|
-
|
|
84
|
-
this.spinnerTimer = null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async run(onLine: (line: string, signal?: AbortSignal) => Promise<void>): Promise<void> {
|
|
89
|
-
this.onLine = onLine;
|
|
90
|
-
this.measure();
|
|
91
|
-
if (process.stdin.isTTY) process.stdin.setRawMode?.(true);
|
|
92
|
-
process.stdin.on("data", this.handleInput);
|
|
93
|
-
process.stdout.on("resize", this.handleResize);
|
|
94
|
-
process.on("SIGWINCH", this.handleResize);
|
|
95
|
-
this.render();
|
|
96
|
-
return new Promise<void>((resolve) => { this.resolve = resolve; });
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private shutdown(): void {
|
|
100
|
-
this.stopSpinner();
|
|
101
|
-
process.stdin.setRawMode?.(false);
|
|
102
|
-
process.stdin.removeAllListeners("data");
|
|
103
|
-
process.stdout.removeAllListeners("resize");
|
|
104
|
-
process.removeAllListeners("SIGWINCH");
|
|
105
|
-
this.render();
|
|
106
|
-
process.stdout.write("\n");
|
|
107
|
-
this.resolve?.();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private handleInput = (data: Buffer): void => {
|
|
111
|
-
for (const ch of data.toString()) {
|
|
112
|
-
const code = ch.charCodeAt(0);
|
|
113
|
-
if (code === 3) { this.shutdown(); return; }
|
|
114
|
-
if (code === 4 && this.inputBuf.length === 0) { this.shutdown(); return; }
|
|
115
|
-
if (code === 27) {
|
|
116
|
-
if (this.status === "thinking" && this.abortCtrl) { this.abortCtrl.abort(); return; }
|
|
117
|
-
this.inputBuf = "";
|
|
118
|
-
this.render();
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (this.status === "thinking") continue;
|
|
122
|
-
if (code === 13) { this.submit(); return; }
|
|
123
|
-
if (code === 127) {
|
|
124
|
-
this.inputBuf = this.inputBuf.slice(0, -1);
|
|
125
|
-
this.render();
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (ch >= " ") { this.inputBuf += ch; this.render(); }
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
private async submit(): Promise<void> {
|
|
133
|
-
const line = this.inputBuf.trim();
|
|
134
|
-
this.inputBuf = "";
|
|
135
|
-
if (!line) { this.render(); return; }
|
|
136
|
-
if (line === "/exit" || line === "/quit") { this.shutdown(); return; }
|
|
137
|
-
this.addMessage("you", line);
|
|
138
|
-
this.abortCtrl = new AbortController();
|
|
139
|
-
this.startSpinner();
|
|
140
|
-
this.render();
|
|
141
|
-
await this.onLine?.(line, this.abortCtrl.signal);
|
|
142
|
-
this.abortCtrl = null;
|
|
143
|
-
this.stopSpinner();
|
|
144
|
-
this.render();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private handleResize = (): void => { this.measure(); this.render(); };
|
|
148
|
-
|
|
149
|
-
render(): void {
|
|
150
|
-
this.measure();
|
|
151
|
-
process.stdout.write("\x1b[?25l\x1b[2J\x1b[H" + this.buildFrame() + "\x1b[?25h");
|
|
167
|
+
if (this.spinnerTimer) { clearInterval(this.spinnerTimer); this.spinnerTimer = null; }
|
|
168
|
+
this.spinnerBox.setContent("");
|
|
152
169
|
}
|
|
153
170
|
|
|
154
|
-
private
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
let buf = `${B.tl}${B.h.repeat(chatW)}${B.tt}${B.h.repeat(sideW)}${B.tr}\n`;
|
|
161
|
-
|
|
162
|
-
const wrapped = this.state.flatMap((m) => this.wrapMessage(m, chatW));
|
|
163
|
-
const maxScroll = Math.max(0, wrapped.length - bodyH);
|
|
164
|
-
if (this.scrollOff > maxScroll) this.scrollOff = maxScroll;
|
|
165
|
-
if (this.scrollOff < 0) this.scrollOff = 0;
|
|
166
|
-
const visible = wrapped.slice(this.scrollOff, this.scrollOff + bodyH);
|
|
167
|
-
|
|
168
|
-
const sidebarLines = this.buildSidebar(innerSideW);
|
|
169
|
-
const sbTop = Math.max(0, Math.floor((bodyH - sidebarLines.length) / 2));
|
|
170
|
-
|
|
171
|
-
for (let r = 0; r < bodyH; r++) {
|
|
172
|
-
buf += B.v;
|
|
173
|
-
const line = visible[r];
|
|
174
|
-
if (line) buf += padTrunc(line, chatW);
|
|
175
|
-
else buf += " ".repeat(chatW);
|
|
176
|
-
buf += B.v;
|
|
177
|
-
const sbIdx = r - sbTop;
|
|
178
|
-
const sbLine = (sbIdx >= 0 && sbIdx < sidebarLines.length) ? sidebarLines[sbIdx]! : "";
|
|
179
|
-
buf += ` ${padRight(sbLine, innerSideW)} `;
|
|
180
|
-
buf += `${B.v}\n`;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
buf += `${sep}\n`;
|
|
184
|
-
|
|
185
|
-
if (this.status === "thinking") {
|
|
186
|
-
const frame = SPINNER_FRAMES[this.spinnerFrame]!;
|
|
187
|
-
const elapsed = this.turnStartedAt ? formatElapsed(Date.now() - this.turnStartedAt) : "";
|
|
188
|
-
const st = ` ${frame} thinking…${elapsed ? ` ${elapsed}` : ""} (esc to interrupt)`;
|
|
189
|
-
buf += `${B.v}\x1b[36m${st}\x1b[0m${" ".repeat(Math.max(0, columns - 2 - st.length - 2))}${B.v}\n`;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
buf += `${B.tl}${B.h.repeat(inputW)}${B.tr}\n`;
|
|
193
|
-
const cursorCh = this.status === "idle" ? "\x1b[5m▋\x1b[25m" : "";
|
|
194
|
-
const inputMaxW = inputW - 4;
|
|
195
|
-
const vi = this.inputBuf.slice(Math.max(0, this.inputBuf.length - inputMaxW));
|
|
196
|
-
buf += `${B.v} \x1b[36m>\x1b[0m ${vi}${cursorCh}${" ".repeat(Math.max(0, inputMaxW - vi.length))} ${B.v}\n`;
|
|
197
|
-
buf += `${B.bl}${B.h.repeat(inputW)}${B.br}\n`;
|
|
198
|
-
|
|
199
|
-
const totalIn = this.agent.usage.tokens.inputTokens;
|
|
200
|
-
const totalOut = this.agent.usage.tokens.outputTokens;
|
|
201
|
-
const cost = this.agent.usage.costUsd.toFixed(4);
|
|
202
|
-
const ft = `\x1b[90m${this.agent.address.slice(0, 10)}… · in ${totalIn} out ${totalOut} $${cost} /exit\x1b[0m`;
|
|
203
|
-
buf += `${padTrunc(ft, columns)}\n`;
|
|
204
|
-
|
|
205
|
-
const cursorRow = bodyH + 4 + (this.status === "thinking" ? 1 : 0);
|
|
206
|
-
const cursorCol = 4 + Math.min(vi.length + (cursorCh ? 0 : 0), inputMaxW);
|
|
207
|
-
buf += `\x1b[${cursorRow};${cursorCol}H`;
|
|
208
|
-
|
|
209
|
-
return buf;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
private wrapMessage(msg: ChatLine, width: number): string[] {
|
|
213
|
-
const label = this.roleLabel(msg.role);
|
|
214
|
-
const bodyWidth = Math.max(10, width - GUTTER.length - LABEL_W - 1);
|
|
215
|
-
const lines = wrapText(msg.text, bodyWidth);
|
|
216
|
-
return lines.map((l, i) => i === 0 ? `${GUTTER}${label} ${l}` : `${INDENT}${l}`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
private roleLabel(role: ChatLine["role"]): string {
|
|
220
|
-
switch (role) {
|
|
221
|
-
case "you": return "\x1b[36myou \x1b[0m";
|
|
222
|
-
case "agent": return `\x1b[32m${this.agent.name.toLowerCase().padEnd(LABEL_W)}\x1b[0m`;
|
|
223
|
-
case "system": return "\x1b[90msys \x1b[0m";
|
|
224
|
-
case "error": return "\x1b[31merr \x1b[0m";
|
|
225
|
-
}
|
|
171
|
+
private renderSpinner(): void {
|
|
172
|
+
const frame = SPINNER_FRAMES[this.spinnerFrame]!;
|
|
173
|
+
const elapsed = this.turnStartedAt ? formatElapsed(Date.now() - this.turnStartedAt) : "";
|
|
174
|
+
this.spinnerBox.setContent(
|
|
175
|
+
`{cyan-fg}${frame} thinking…${elapsed ? ` ${elapsed}` : ""} (esc to interrupt){/cyan-fg}`,
|
|
176
|
+
);
|
|
226
177
|
}
|
|
227
178
|
|
|
228
|
-
private
|
|
229
|
-
const { agent, config
|
|
179
|
+
private buildSidebarContent(): string {
|
|
180
|
+
const { agent, config } = this;
|
|
230
181
|
const addr = `${agent.address.slice(0, 6)}…${agent.address.slice(-4)}`;
|
|
182
|
+
const cost = agent.usage.costUsd.toFixed(6);
|
|
231
183
|
const totalIn = agent.usage.tokens.inputTokens;
|
|
232
184
|
const totalOut = agent.usage.tokens.outputTokens;
|
|
233
|
-
const cost = agent.usage.costUsd.toFixed(6);
|
|
234
185
|
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
186
|
+
const lines = [
|
|
187
|
+
`{bold}{green-fg}${agent.name}{/green-fg}{/bold}`,
|
|
188
|
+
`{gray-fg}${addr}{/gray-fg}`,
|
|
238
189
|
"",
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
`\x1b[90mmodel\x1b[0m ${shortModel(config.brain.model)}`,
|
|
190
|
+
`{gray-fg}network ${config.network}{/gray-fg}`,
|
|
191
|
+
`{gray-fg}model ${shortModel(config.brain.model)}{/gray-fg}`,
|
|
242
192
|
];
|
|
243
|
-
if (
|
|
244
|
-
|
|
193
|
+
if (this.balance) lines.push("", `{gray-fg}balance {/gray-fg}{yellow-fg}${this.balance} SUI{/yellow-fg}`);
|
|
194
|
+
lines.push(
|
|
245
195
|
"",
|
|
246
|
-
|
|
196
|
+
`{gray-fg}last{/gray-fg} in ${this.lastTurnIn} out ${this.lastTurnOut}`,
|
|
247
197
|
"",
|
|
248
|
-
|
|
249
|
-
`
|
|
198
|
+
`{gray-fg}total{/gray-fg} in ${totalIn} out ${totalOut}`,
|
|
199
|
+
` {yellow-fg}$${cost}{/yellow-fg}`,
|
|
250
200
|
);
|
|
251
|
-
return
|
|
201
|
+
return lines.join("\n");
|
|
252
202
|
}
|
|
253
|
-
}
|
|
254
203
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (cur) { lines.push(cur); cur = ""; }
|
|
264
|
-
for (let i = 0; i < w.length; i += width) lines.push(w.slice(i, i + width));
|
|
265
|
-
} else if (cur && cur.length + 1 + w.length > width) { lines.push(cur); cur = w; }
|
|
266
|
-
else cur = cur ? `${cur} ${w}` : w;
|
|
267
|
-
}
|
|
268
|
-
if (cur) lines.push(cur);
|
|
204
|
+
private renderFooter(): void {
|
|
205
|
+
const { agent } = this;
|
|
206
|
+
const totalIn = agent.usage.tokens.inputTokens;
|
|
207
|
+
const totalOut = agent.usage.tokens.outputTokens;
|
|
208
|
+
const cost = agent.usage.costUsd.toFixed(4);
|
|
209
|
+
this.footer.setContent(
|
|
210
|
+
`{gray-fg}${agent.address.slice(0, 12)}… · in ${totalIn} out ${totalOut} $${cost} /exit{/gray-fg}`,
|
|
211
|
+
);
|
|
269
212
|
}
|
|
270
|
-
return lines.length > 0 ? lines : [""];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function stripAnsi(s: string): string {
|
|
274
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape stripping
|
|
275
|
-
return s.replace(/\x1b\[\d*;?\d*m/g, "");
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function visibleLen(s: string): number {
|
|
279
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape stripping
|
|
280
|
-
const re = /\x1b\[\d*;?\d*m/g;
|
|
281
|
-
let len = 0, last = 0, m = re.exec(s);
|
|
282
|
-
while (m !== null) { len += m.index - last; last = m.index + m[0].length; m = re.exec(s); }
|
|
283
|
-
return len + s.length - last;
|
|
284
|
-
}
|
|
285
213
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
214
|
+
async run(onLine: (line: string, signal?: AbortSignal) => Promise<void>): Promise<void> {
|
|
215
|
+
this.onLine = onLine;
|
|
216
|
+
this.input.focus();
|
|
217
|
+
this.screen.render();
|
|
218
|
+
return new Promise<void>((resolve) => { this.resolve = resolve; });
|
|
219
|
+
}
|
|
290
220
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
let out = "", visible = 0, i = 0;
|
|
296
|
-
while (i < s.length && visible < w) {
|
|
297
|
-
if (s[i] === "\x1b" && s[i + 1] === "[") {
|
|
298
|
-
const end = s.indexOf("m", i);
|
|
299
|
-
if (end !== -1) { out += s.slice(i, end + 1); i = end + 1; }
|
|
300
|
-
else { out += s[i]; i++; }
|
|
301
|
-
} else { out += s[i]; visible++; i++; }
|
|
221
|
+
private shutdown(): void {
|
|
222
|
+
this.stopSpinner();
|
|
223
|
+
this.screen.destroy();
|
|
224
|
+
this.resolve?.();
|
|
302
225
|
}
|
|
303
|
-
return out;
|
|
304
226
|
}
|
|
305
227
|
|
|
306
228
|
function formatElapsed(ms: number): string {
|