agenticmail 0.3.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/LICENSE +35 -0
- package/README.md +352 -0
- package/REFERENCE.md +597 -0
- package/dist/chat-ui-MQIYQOFL.js +139 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5180 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -0
- package/dist/ws-chat-OVLCQILI.js +242 -0
- package/package.json +67 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// src/chat-ui.ts
|
|
2
|
+
var ESC = "\x1B";
|
|
3
|
+
var reset = `${ESC}[0m`;
|
|
4
|
+
var bold = (s) => `${ESC}[1m${s}${reset}`;
|
|
5
|
+
var green = (s) => `${ESC}[32m${s}${reset}`;
|
|
6
|
+
var cyan = (s) => `${ESC}[36m${s}${reset}`;
|
|
7
|
+
var pink = (s) => `${ESC}[38;5;211m${s}${reset}`;
|
|
8
|
+
var gray = (s) => `${ESC}[90m${s}${reset}`;
|
|
9
|
+
function getTermWidth() {
|
|
10
|
+
try {
|
|
11
|
+
return process.stdout.columns || 100;
|
|
12
|
+
} catch {
|
|
13
|
+
return 100;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function mdToAnsi(text) {
|
|
17
|
+
return text.replace(/\*\*(.+?)\*\*/g, `${ESC}[1m$1${reset}`).replace(/__(.+?)__/g, `${ESC}[1m$1${reset}`).replace(/(?<!\w)\*(.+?)\*(?!\w)/g, `${ESC}[3m$1${reset}`).replace(/(?<!\w)_(.+?)_(?!\w)/g, `${ESC}[3m$1${reset}`).replace(/~~(.+?)~~/g, `${ESC}[9m$1${reset}`).replace(/`([^`]+)`/g, `${ESC}[7m $1 ${reset}`).replace(/^(#{1,3})\s+(.+)$/gm, (_m, _h, t) => `${ESC}[1m${ESC}[4m${t}${reset}`).replace(/^(\s*)[-*]\s+/gm, "$1\u2022 ");
|
|
18
|
+
}
|
|
19
|
+
function stripAnsi(s) {
|
|
20
|
+
return s.replace(/\x1b\[[0-9;]*m/g, "");
|
|
21
|
+
}
|
|
22
|
+
function wordWrapAnsi(text, maxWidth) {
|
|
23
|
+
const lines = [];
|
|
24
|
+
for (const paragraph of text.split("\n")) {
|
|
25
|
+
if (stripAnsi(paragraph).length === 0) {
|
|
26
|
+
lines.push("");
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const words = paragraph.split(" ");
|
|
30
|
+
let current = "";
|
|
31
|
+
let currentVisLen = 0;
|
|
32
|
+
for (const word of words) {
|
|
33
|
+
const wordVisLen = stripAnsi(word).length;
|
|
34
|
+
if (currentVisLen + wordVisLen + 1 > maxWidth && currentVisLen > 0) {
|
|
35
|
+
lines.push(current);
|
|
36
|
+
current = word;
|
|
37
|
+
currentVisLen = wordVisLen;
|
|
38
|
+
} else {
|
|
39
|
+
current = current ? current + " " + word : word;
|
|
40
|
+
currentVisLen = currentVisLen ? currentVisLen + 1 + wordVisLen : wordVisLen;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (current) lines.push(current);
|
|
44
|
+
}
|
|
45
|
+
return lines;
|
|
46
|
+
}
|
|
47
|
+
function renderBubble(text, side) {
|
|
48
|
+
const termW = getTermWidth();
|
|
49
|
+
const maxContentW = Math.min(Math.floor(termW * 0.6), 72);
|
|
50
|
+
const converted = mdToAnsi(text);
|
|
51
|
+
const displayLines = wordWrapAnsi(converted, maxContentW);
|
|
52
|
+
const contentW = Math.max(...displayLines.map((l) => stripAnsi(l).length), 6);
|
|
53
|
+
const borderW = contentW + 2;
|
|
54
|
+
const output = [];
|
|
55
|
+
const colorFn = side === "left" ? gray : pink;
|
|
56
|
+
const top = colorFn(`\u256D${"\u2500".repeat(borderW)}\u256E`);
|
|
57
|
+
const bot = colorFn(`\u2570${"\u2500".repeat(borderW)}\u256F`);
|
|
58
|
+
if (side === "left") {
|
|
59
|
+
output.push(` ${top}`);
|
|
60
|
+
for (const line of displayLines) {
|
|
61
|
+
const pad = " ".repeat(Math.max(0, contentW - stripAnsi(line).length));
|
|
62
|
+
output.push(` ${colorFn("\u2502")} ${line}${pad} ${colorFn("\u2502")}`);
|
|
63
|
+
}
|
|
64
|
+
output.push(` ${bot}`);
|
|
65
|
+
} else {
|
|
66
|
+
const totalW = borderW + 2;
|
|
67
|
+
const indent = " ".repeat(Math.max(termW - totalW - 2, 2));
|
|
68
|
+
output.push(`${indent}${top}`);
|
|
69
|
+
for (const line of displayLines) {
|
|
70
|
+
const pad = " ".repeat(Math.max(0, contentW - stripAnsi(line).length));
|
|
71
|
+
output.push(`${indent}${colorFn("\u2502")} ${bold(line)}${pad} ${colorFn("\u2502")}`);
|
|
72
|
+
}
|
|
73
|
+
output.push(`${indent}${bot}`);
|
|
74
|
+
}
|
|
75
|
+
return output.join("\n");
|
|
76
|
+
}
|
|
77
|
+
function renderAgentLabel(name = "Fola") {
|
|
78
|
+
return ` ${"\u{1F380}"} ${bold(cyan(name))}`;
|
|
79
|
+
}
|
|
80
|
+
function renderUserLabel(name = "You") {
|
|
81
|
+
const termW = getTermWidth();
|
|
82
|
+
const visLen = name.length + 4;
|
|
83
|
+
const indent = Math.max(termW - visLen - 2, 2);
|
|
84
|
+
return `${" ".repeat(indent)}${bold(green(name))} \u{1F464}`;
|
|
85
|
+
}
|
|
86
|
+
function renderThinking(message) {
|
|
87
|
+
return ` ${gray(`\u22EF ${message}`)}`;
|
|
88
|
+
}
|
|
89
|
+
function renderConnected() {
|
|
90
|
+
return ` ${green("\u25CF")} ${bold("Connected")} ${gray("\u2014 real-time streaming")}`;
|
|
91
|
+
}
|
|
92
|
+
function renderConnecting() {
|
|
93
|
+
return ` ${gray("\u25CB Connecting...")}`;
|
|
94
|
+
}
|
|
95
|
+
function renderSystemMessage(text) {
|
|
96
|
+
const termW = getTermWidth();
|
|
97
|
+
const padLen = Math.max(Math.floor((termW - text.length) / 2), 2);
|
|
98
|
+
return `${" ".repeat(padLen)}${gray(text)}`;
|
|
99
|
+
}
|
|
100
|
+
function getInputPrompt() {
|
|
101
|
+
return ` ${green("\u203A")} `;
|
|
102
|
+
}
|
|
103
|
+
var THINKING_MESSAGES = [
|
|
104
|
+
"brewing thoughts...",
|
|
105
|
+
"consulting the oracle...",
|
|
106
|
+
"neurons firing...",
|
|
107
|
+
"channeling genius...",
|
|
108
|
+
"loading brilliance...",
|
|
109
|
+
"warming up the brain cells...",
|
|
110
|
+
"plot twist incoming...",
|
|
111
|
+
"assembling words with care...",
|
|
112
|
+
"hold my coffee...",
|
|
113
|
+
"calculating the meaning of life...",
|
|
114
|
+
"asking the universe...",
|
|
115
|
+
"summoning eloquence...",
|
|
116
|
+
"crafting something beautiful...",
|
|
117
|
+
"let me cook...",
|
|
118
|
+
"one sec, being brilliant...",
|
|
119
|
+
"the gears are turning...",
|
|
120
|
+
"connecting the dots...",
|
|
121
|
+
"processing at the speed of thought...",
|
|
122
|
+
"this one deserves a good answer...",
|
|
123
|
+
"thinking harder than usual..."
|
|
124
|
+
];
|
|
125
|
+
function randomThinking() {
|
|
126
|
+
return THINKING_MESSAGES[Math.floor(Math.random() * THINKING_MESSAGES.length)];
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
THINKING_MESSAGES,
|
|
130
|
+
getInputPrompt,
|
|
131
|
+
randomThinking,
|
|
132
|
+
renderAgentLabel,
|
|
133
|
+
renderBubble,
|
|
134
|
+
renderConnected,
|
|
135
|
+
renderConnecting,
|
|
136
|
+
renderSystemMessage,
|
|
137
|
+
renderThinking,
|
|
138
|
+
renderUserLabel
|
|
139
|
+
};
|
package/dist/cli.d.ts
ADDED