@sofer_agent/cli 0.3.18 → 0.3.20
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/sofer +2 -3
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +35 -35
- package/dist/chat.js.map +1 -1
- package/dist/tui.d.ts +36 -12
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +330 -0
- package/dist/tui.js.map +1 -0
- package/package.json +2 -5
- package/src/chat.ts +29 -43
- package/src/tui.ts +320 -0
- package/dist/tui.jsx +0 -182
- package/dist/tui.jsx.map +0 -1
- package/src/tui.tsx +0 -247
package/src/chat.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
agentPaths,
|
|
5
|
-
type SoferConfig,
|
|
6
|
-
loadConfig,
|
|
7
|
-
shortAgentId,
|
|
8
|
-
SoferAgent,
|
|
9
|
-
} from "@sofer_agent/core";
|
|
3
|
+
import { agentPaths, type SoferConfig, loadConfig, shortAgentId, SoferAgent } from "@sofer_agent/core";
|
|
10
4
|
import { loadSecrets } from "./env.js";
|
|
11
|
-
import {
|
|
5
|
+
import { SoferTui } from "./tui.js";
|
|
12
6
|
|
|
13
|
-
interface SessionMessage {
|
|
14
|
-
role: string;
|
|
15
|
-
content: unknown;
|
|
16
|
-
}
|
|
7
|
+
interface SessionMessage { role: string; content: unknown; }
|
|
17
8
|
|
|
18
9
|
function sessionPath(config: SoferConfig): string | null {
|
|
19
10
|
if (config.agentObjectId) return agentPaths.agent(shortAgentId(config.agentObjectId)).activityLog;
|
|
@@ -36,6 +27,15 @@ function saveSession(path: string, messages: SessionMessage[]): void {
|
|
|
36
27
|
writeFileSync(path, messages.map((m) => JSON.stringify(m)).join("\n") + "\n", "utf8");
|
|
37
28
|
}
|
|
38
29
|
|
|
30
|
+
function cleanError(raw: string): string {
|
|
31
|
+
try {
|
|
32
|
+
const obj = JSON.parse(raw);
|
|
33
|
+
if (obj?.error?.type === "overloaded_error") return "Claude is overloaded — try again in a moment.";
|
|
34
|
+
if (obj?.error?.message) return obj.error.message;
|
|
35
|
+
} catch { /* not JSON */ }
|
|
36
|
+
return raw;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
export async function chatCommand(): Promise<void> {
|
|
40
40
|
const config = loadConfig();
|
|
41
41
|
const secrets = loadSecrets();
|
|
@@ -43,46 +43,32 @@ export async function chatCommand(): Promise<void> {
|
|
|
43
43
|
console.error("Missing secrets. Run `sofer init` first.");
|
|
44
44
|
process.exit(1);
|
|
45
45
|
}
|
|
46
|
-
const agent = await SoferAgent.create(config, {
|
|
47
|
-
suiSecretKey: secrets.suiSecretKey,
|
|
48
|
-
anthropicApiKey: secrets.anthropicApiKey,
|
|
49
|
-
});
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const [, setInfo] = tuiState.info;
|
|
55
|
+
const sp = sessionPath(config);
|
|
56
|
+
if (sp) { const h = loadSession(sp); if (h.length > 0) agent.loadHistory(h); }
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
const tui = new SoferTui(agent, config);
|
|
59
|
+
agent.getBalance().then((b) => tui.setInfo({ balance: (Number(b) / 1e9).toFixed(4) })).catch(() => {});
|
|
62
60
|
|
|
63
|
-
await
|
|
61
|
+
await tui.run(async (line, signal) => {
|
|
64
62
|
try {
|
|
65
63
|
const { text, turnUsage } = await agent.chat(line, signal);
|
|
66
|
-
|
|
67
|
-
setInfo(
|
|
64
|
+
tui.addMessage("agent", text);
|
|
65
|
+
tui.setInfo({ lastTurnIn: turnUsage.inputTokens, lastTurnOut: turnUsage.outputTokens });
|
|
68
66
|
} catch (e) {
|
|
69
|
-
if (signal
|
|
70
|
-
|
|
71
|
-
} else {
|
|
72
|
-
const raw = e instanceof Error ? e.message : String(e);
|
|
73
|
-
setRows((prev) => [...prev, { role: "error", text: cleanError(raw) }]);
|
|
74
|
-
}
|
|
67
|
+
if (signal?.aborted) tui.addMessage("system", "turn interrupted.");
|
|
68
|
+
else tui.addMessage("error", cleanError(e instanceof Error ? e.message : String(e)));
|
|
75
69
|
}
|
|
76
|
-
agent.getBalance().then((
|
|
70
|
+
agent.getBalance().then((b) => tui.setInfo({ balance: (Number(b) / 1e9).toFixed(4) })).catch(() => {});
|
|
77
71
|
if (sp) saveSession(sp, agent.getHistory());
|
|
72
|
+
tui.render();
|
|
78
73
|
});
|
|
79
74
|
}
|
|
80
|
-
|
|
81
|
-
function cleanError(raw: string): string {
|
|
82
|
-
try {
|
|
83
|
-
const obj = JSON.parse(raw);
|
|
84
|
-
if (obj?.error?.type === "overloaded_error") return "Claude is overloaded — try again in a moment.";
|
|
85
|
-
if (obj?.error?.message) return obj.error.message;
|
|
86
|
-
} catch { /* not JSON */ }
|
|
87
|
-
return raw;
|
|
88
|
-
}
|
package/src/tui.ts
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import type { SoferAgent, SoferConfig } from "@sofer_agent/core";
|
|
2
|
+
|
|
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
|
+
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
|
+
|
|
28
|
+
export class SoferTui {
|
|
29
|
+
private state: ChatLine[] = [];
|
|
30
|
+
private inputBuf = "";
|
|
31
|
+
private columns = 90;
|
|
32
|
+
private rows = 28;
|
|
33
|
+
private chatW = 58;
|
|
34
|
+
private sideW = 26;
|
|
35
|
+
private bodyH = 22;
|
|
36
|
+
private scrollOff = Number.MAX_SAFE_INTEGER;
|
|
37
|
+
private status: "idle" | "thinking" = "idle";
|
|
38
|
+
private spinnerFrame = 0;
|
|
39
|
+
private spinnerTimer: ReturnType<typeof setInterval> | null = null;
|
|
40
|
+
private turnStartedAt = 0;
|
|
41
|
+
private abortCtrl: AbortController | null = null;
|
|
42
|
+
private info: TuiInfo = { lastTurnIn: 0, lastTurnOut: 0 };
|
|
43
|
+
private resolve: (() => void) | null = null;
|
|
44
|
+
private onLine: ((line: string, signal?: AbortSignal) => Promise<void>) | null = null;
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
private readonly agent: SoferAgent,
|
|
48
|
+
private readonly config: SoferConfig,
|
|
49
|
+
) {}
|
|
50
|
+
|
|
51
|
+
private measure(): void {
|
|
52
|
+
this.columns = Math.max(80, process.stdout.columns ?? 80);
|
|
53
|
+
this.rows = Math.max(24, process.stdout.rows ?? 24);
|
|
54
|
+
this.chatW = Math.min(120, Math.max(MIN_CHAT_W, this.columns - SIDEBAR_W - 3));
|
|
55
|
+
this.sideW = this.columns - this.chatW - 3;
|
|
56
|
+
this.bodyH = this.rows - 5;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
addMessage(role: ChatLine["role"], text: string): void {
|
|
60
|
+
this.state.push({ role, text });
|
|
61
|
+
this.scrollOff = Number.MAX_SAFE_INTEGER;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setInfo(info: Partial<TuiInfo>): void {
|
|
65
|
+
Object.assign(this.info, info);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private startSpinner(): void {
|
|
69
|
+
if (this.spinnerTimer) return;
|
|
70
|
+
this.status = "thinking";
|
|
71
|
+
this.turnStartedAt = Date.now();
|
|
72
|
+
this.spinnerFrame = 0;
|
|
73
|
+
this.spinnerTimer = setInterval(() => {
|
|
74
|
+
this.spinnerFrame = (this.spinnerFrame + 1) % SPINNER_FRAMES.length;
|
|
75
|
+
this.render();
|
|
76
|
+
}, SPINNER_MS);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private stopSpinner(): void {
|
|
80
|
+
this.status = "idle";
|
|
81
|
+
this.turnStartedAt = 0;
|
|
82
|
+
if (this.spinnerTimer) {
|
|
83
|
+
clearInterval(this.spinnerTimer);
|
|
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");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private buildFrame(): string {
|
|
155
|
+
const { columns, chatW, sideW, bodyH } = this;
|
|
156
|
+
const innerSideW = sideW - 2;
|
|
157
|
+
const sep = `${B.lt}${B.h.repeat(chatW)}${B.bt}${B.h.repeat(sideW)}${B.rt}`;
|
|
158
|
+
const inputW = columns - 2;
|
|
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
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private buildSidebar(width: number): string[] {
|
|
229
|
+
const { agent, config, info } = this;
|
|
230
|
+
const addr = `${agent.address.slice(0, 6)}…${agent.address.slice(-4)}`;
|
|
231
|
+
const totalIn = agent.usage.tokens.inputTokens;
|
|
232
|
+
const totalOut = agent.usage.tokens.outputTokens;
|
|
233
|
+
const cost = agent.usage.costUsd.toFixed(6);
|
|
234
|
+
|
|
235
|
+
const rows = [
|
|
236
|
+
`\x1b[1;36m${agent.name}\x1b[0m`,
|
|
237
|
+
`\x1b[90m${addr}\x1b[0m`,
|
|
238
|
+
"",
|
|
239
|
+
`${B.h.repeat(width)}`,
|
|
240
|
+
`\x1b[90mnetwork\x1b[0m ${config.network}`,
|
|
241
|
+
`\x1b[90mmodel\x1b[0m ${shortModel(config.brain.model)}`,
|
|
242
|
+
];
|
|
243
|
+
if (info.balance) rows.push("", `\x1b[90mbalance\x1b[0m \x1b[33m${info.balance} SUI\x1b[0m`);
|
|
244
|
+
rows.push(
|
|
245
|
+
"",
|
|
246
|
+
`\x1b[90mlast\x1b[0m in ${info.lastTurnIn} out ${info.lastTurnOut}`,
|
|
247
|
+
"",
|
|
248
|
+
`\x1b[90mtotal\x1b[0m in ${totalIn} out ${totalOut}`,
|
|
249
|
+
` \x1b[33m$${cost}\x1b[0m`,
|
|
250
|
+
);
|
|
251
|
+
return rows;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function wrapText(text: string, width: number): string[] {
|
|
256
|
+
if (!text) return [""];
|
|
257
|
+
const lines: string[] = [];
|
|
258
|
+
for (const para of text.split("\n")) {
|
|
259
|
+
const words = para.split(" ");
|
|
260
|
+
let cur = "";
|
|
261
|
+
for (const w of words) {
|
|
262
|
+
if (w.length > width) {
|
|
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);
|
|
269
|
+
}
|
|
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
|
+
|
|
286
|
+
function padRight(s: string, w: number): string {
|
|
287
|
+
const vl = visibleLen(s);
|
|
288
|
+
return vl >= w ? s : s + " ".repeat(w - vl);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function padTrunc(s: string, w: number): string {
|
|
292
|
+
const vl = visibleLen(s);
|
|
293
|
+
if (vl < w) return s + " ".repeat(w - vl);
|
|
294
|
+
if (vl === w) return s;
|
|
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++; }
|
|
302
|
+
}
|
|
303
|
+
return out;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function formatElapsed(ms: number): string {
|
|
307
|
+
const sec = Math.floor(ms / 1000);
|
|
308
|
+
if (sec < 60) return `${sec}s`;
|
|
309
|
+
const m = Math.floor(sec / 60);
|
|
310
|
+
return `${m}m${String(sec % 60).padStart(2, "0")}s`;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function shortModel(model: string): string {
|
|
314
|
+
const m = model.toLowerCase();
|
|
315
|
+
if (m.includes("sonnet")) return "Sonnet 4";
|
|
316
|
+
if (m.includes("haiku")) return "Haiku";
|
|
317
|
+
if (m.includes("opus")) return "Opus 4";
|
|
318
|
+
if (m.includes("fable")) return "Fable 5";
|
|
319
|
+
return model.length > 14 ? `${model.slice(0, 13)}…` : model;
|
|
320
|
+
}
|
package/dist/tui.jsx
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { render, useKeyboard, useTerminalDimensions } from "@opentui/solid";
|
|
2
|
-
import { For, createEffect, createSignal, onCleanup } from "solid-js";
|
|
3
|
-
const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
4
|
-
const SPINNER_MS = 80;
|
|
5
|
-
function formatElapsed(startedAt) {
|
|
6
|
-
if (!startedAt)
|
|
7
|
-
return "";
|
|
8
|
-
const sec = Math.floor((Date.now() - startedAt) / 1000);
|
|
9
|
-
if (sec < 60)
|
|
10
|
-
return `${sec}s`;
|
|
11
|
-
const m = Math.floor(sec / 60);
|
|
12
|
-
return `${m}m${String(sec % 60).padStart(2, "0")}s`;
|
|
13
|
-
}
|
|
14
|
-
function shortModel(model) {
|
|
15
|
-
const m = model.toLowerCase();
|
|
16
|
-
if (m.includes("sonnet"))
|
|
17
|
-
return "sonnet-4";
|
|
18
|
-
if (m.includes("haiku"))
|
|
19
|
-
return "haiku";
|
|
20
|
-
if (m.includes("opus"))
|
|
21
|
-
return "opus-4";
|
|
22
|
-
return model.length > 14 ? `${model.slice(0, 13)}…` : model;
|
|
23
|
-
}
|
|
24
|
-
function App(props) {
|
|
25
|
-
const { state, agent, config } = props;
|
|
26
|
-
const dims = useTerminalDimensions();
|
|
27
|
-
const [rows] = state.rows;
|
|
28
|
-
const [status] = state.status;
|
|
29
|
-
const [input, setInput] = state.input;
|
|
30
|
-
const [info] = state.info;
|
|
31
|
-
const [spinnerFrame, setSpinnerFrame] = state.spinnerFrame;
|
|
32
|
-
const [turnStartedAt] = state.turnStartedAt;
|
|
33
|
-
const [, setActiveAbort] = state.activeAbort;
|
|
34
|
-
const [activeAbort] = state.activeAbort;
|
|
35
|
-
createEffect(() => {
|
|
36
|
-
if (status() !== "thinking") {
|
|
37
|
-
setSpinnerFrame(0);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const id = setInterval(() => setSpinnerFrame((f) => (f + 1) % SPINNER_FRAMES.length), SPINNER_MS);
|
|
41
|
-
onCleanup(() => clearInterval(id));
|
|
42
|
-
});
|
|
43
|
-
useKeyboard((evt) => {
|
|
44
|
-
if (evt.ctrl && evt.name === "c") {
|
|
45
|
-
evt.preventDefault();
|
|
46
|
-
props.onExit();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (evt.name === "escape") {
|
|
50
|
-
const ab = activeAbort();
|
|
51
|
-
if (ab && !ab.signal.aborted)
|
|
52
|
-
ab.abort();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (status() === "thinking")
|
|
56
|
-
return;
|
|
57
|
-
if (evt.name === "return") {
|
|
58
|
-
const text = input().trim();
|
|
59
|
-
if (!text)
|
|
60
|
-
return;
|
|
61
|
-
if (text === "/exit" || text === "/quit") {
|
|
62
|
-
props.onExit();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const ctrl = new AbortController();
|
|
66
|
-
setActiveAbort(ctrl);
|
|
67
|
-
state.rows[1](prev => [...prev, { role: "you", text }]);
|
|
68
|
-
setInput("");
|
|
69
|
-
state.status[1]("thinking");
|
|
70
|
-
state.turnStartedAt[1](Date.now());
|
|
71
|
-
props.onSubmit(text, ctrl.signal).finally(() => {
|
|
72
|
-
state.status[1]("idle");
|
|
73
|
-
state.turnStartedAt[1](null);
|
|
74
|
-
setActiveAbort(null);
|
|
75
|
-
});
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (evt.name === "backspace" || evt.name === "delete") {
|
|
79
|
-
setInput((p) => p.slice(0, -1));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (evt.sequence && !evt.ctrl && !evt.meta && !evt.option) {
|
|
83
|
-
setInput((p) => p + evt.sequence);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const sidebarW = Math.min(30, Math.floor(dims().width * 0.22));
|
|
87
|
-
const chatW = dims().width - sidebarW;
|
|
88
|
-
const addr = () => `${agent.address.slice(0, 6)}…${agent.address.slice(-4)}`;
|
|
89
|
-
return (<box flexDirection="row" width={dims().width} height={dims().height}>
|
|
90
|
-
{/* Chat area */}
|
|
91
|
-
<box flexDirection="column" width={chatW} height={dims().height}>
|
|
92
|
-
<scrollbox flexGrow={1} flexShrink={1} stickyScroll stickyStart="bottom" contentOptions={{ flexDirection: "column", paddingLeft: 1, paddingRight: 1, paddingTop: 1, paddingBottom: 1 }}>
|
|
93
|
-
<For each={rows()}>
|
|
94
|
-
{(line) => {
|
|
95
|
-
const color = line.role === "you" ? "#67e8f9"
|
|
96
|
-
: line.role === "agent" ? "#86efac"
|
|
97
|
-
: line.role === "error" ? "#fca5a5"
|
|
98
|
-
: "#9ca3af";
|
|
99
|
-
const label = line.role === "you" ? "you"
|
|
100
|
-
: line.role === "agent" ? agent.name.toLowerCase().slice(0, 5)
|
|
101
|
-
: line.role === "error" ? "err"
|
|
102
|
-
: "sys";
|
|
103
|
-
return (<box flexDirection="row">
|
|
104
|
-
<text fg={color} flexShrink={0}>{` ${label.padEnd(5)} `}</text>
|
|
105
|
-
<text wrapMode="word" flexGrow={1} fg="#e5e7eb">
|
|
106
|
-
{line.text}
|
|
107
|
-
</text>
|
|
108
|
-
</box>);
|
|
109
|
-
}}
|
|
110
|
-
</For>
|
|
111
|
-
</scrollbox>
|
|
112
|
-
|
|
113
|
-
<box flexDirection="row" flexShrink={0} paddingLeft={3} paddingRight={2} marginTop={1}>
|
|
114
|
-
<text fg="#67e8f9" flexGrow={1}>
|
|
115
|
-
{(() => {
|
|
116
|
-
if (status() !== "thinking")
|
|
117
|
-
return " ";
|
|
118
|
-
const frame = SPINNER_FRAMES[spinnerFrame()];
|
|
119
|
-
const elapsed = formatElapsed(turnStartedAt());
|
|
120
|
-
return elapsed
|
|
121
|
-
? `${frame} thinking… ${elapsed} (esc to interrupt)`
|
|
122
|
-
: `${frame} thinking… (esc to interrupt)`;
|
|
123
|
-
})()}
|
|
124
|
-
</text>
|
|
125
|
-
</box>
|
|
126
|
-
|
|
127
|
-
<box flexDirection="row" flexShrink={0} minHeight={3} maxHeight={8} borderStyle="rounded" borderColor="#374151" paddingLeft={1} paddingRight={1} marginLeft={2} marginRight={2}>
|
|
128
|
-
<text fg="#67e8f9" flexShrink={0}>{"› "}</text>
|
|
129
|
-
<text wrapMode="word" flexGrow={1} fg="#e5e7eb">
|
|
130
|
-
{`${input()}${status() === "idle" ? "▋" : ""}`}
|
|
131
|
-
</text>
|
|
132
|
-
</box>
|
|
133
|
-
|
|
134
|
-
<box flexDirection="row" flexShrink={0} paddingLeft={2} paddingRight={2}>
|
|
135
|
-
<text fg="#9ca3af">
|
|
136
|
-
{[
|
|
137
|
-
addr(),
|
|
138
|
-
config.network,
|
|
139
|
-
shortModel(config.brain.model),
|
|
140
|
-
info().balance ? `${info().balance} SUI` : null,
|
|
141
|
-
`in ${agent.usage.tokens.inputTokens} out ${agent.usage.tokens.outputTokens} $${agent.usage.costUsd.toFixed(4)}`,
|
|
142
|
-
"/exit",
|
|
143
|
-
].filter(Boolean).join(" · ")}
|
|
144
|
-
</text>
|
|
145
|
-
</box>
|
|
146
|
-
</box>
|
|
147
|
-
|
|
148
|
-
{/* Sidebar */}
|
|
149
|
-
<box flexDirection="column" width={sidebarW} borderStyle="single" borderColor="#374151" paddingLeft={2} paddingRight={1}>
|
|
150
|
-
<text fg="#86efac">{agent.name}</text>
|
|
151
|
-
<text fg="#9ca3af">{addr()}</text>
|
|
152
|
-
<text>{" "}</text>
|
|
153
|
-
<text fg="#6b7280">{"─".repeat(sidebarW - 4)}</text>
|
|
154
|
-
<text fg="#9ca3af">{`network ${config.network}`}</text>
|
|
155
|
-
<text fg="#9ca3af">{`model ${shortModel(config.brain.model)}`}</text>
|
|
156
|
-
{info().balance ? <text fg="#fbbf24">{`balance ${info().balance} SUI`}</text> : null}
|
|
157
|
-
<text>{" "}</text>
|
|
158
|
-
<text fg="#6b7280">{"─".repeat(sidebarW - 4)}</text>
|
|
159
|
-
<text fg="#9ca3af">{`last in ${info().lastTurnIn} out ${info().lastTurnOut}`}</text>
|
|
160
|
-
<text fg="#9ca3af">{`total in ${agent.usage.tokens.inputTokens}`}</text>
|
|
161
|
-
<text fg="#9ca3af">{` out ${agent.usage.tokens.outputTokens}`}</text>
|
|
162
|
-
<text fg="#fbbf24">{` $${agent.usage.costUsd.toFixed(6)}`}</text>
|
|
163
|
-
</box>
|
|
164
|
-
</box>);
|
|
165
|
-
}
|
|
166
|
-
export function createTuiState() {
|
|
167
|
-
return {
|
|
168
|
-
rows: createSignal([]),
|
|
169
|
-
status: createSignal("idle"),
|
|
170
|
-
input: createSignal(""),
|
|
171
|
-
info: createSignal({ lastTurnIn: 0, lastTurnOut: 0 }),
|
|
172
|
-
spinnerFrame: createSignal(0),
|
|
173
|
-
turnStartedAt: createSignal(null),
|
|
174
|
-
activeAbort: createSignal(null),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
export async function runTui(state, agent, config, onSubmit) {
|
|
178
|
-
return new Promise((resolve) => {
|
|
179
|
-
render(() => (<App state={state} agent={agent} config={config} onSubmit={onSubmit} onExit={resolve}/>));
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
//# sourceMappingURL=tui.jsx.map
|
package/dist/tui.jsx.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tui.jsx","sourceRoot":"","sources":["../src/tui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEtE,MAAM,cAAc,GAAG,CAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,CAAU,CAAC;AAC1E,MAAM,UAAU,GAAG,EAAE,CAAC;AAuBtB,SAAS,aAAa,CAAC,SAAwB;IAC7C,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC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