qwenproxy-cli 1.0.0 → 1.0.2
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 +14 -14
- package/README.md +906 -906
- package/bin/qwenproxy.js +5 -1
- package/package.json +77 -78
- package/src/api/error-classifier.ts +159 -159
- package/src/api/error-helpers.ts +118 -118
- package/src/api/models.ts +261 -261
- package/src/api/server.ts +860 -859
- package/src/cache/memory-cache.ts +385 -385
- package/src/clean-cache.ts +204 -204
- package/src/core/account-concurrency.ts +671 -671
- package/src/core/account-manager.ts +301 -297
- package/src/core/account-priority.ts +163 -163
- package/src/core/accounts.ts +186 -186
- package/src/core/config.ts +383 -383
- package/src/core/crypto-utils.ts +79 -79
- package/src/core/database.ts +276 -276
- package/src/core/errors.ts +118 -118
- package/src/core/logger.ts +269 -269
- package/src/core/memory-usage.ts +84 -84
- package/src/core/metrics.ts +291 -291
- package/src/core/model-alias.ts +77 -77
- package/src/core/model-registry.ts +544 -544
- package/src/core/mutex.ts +119 -119
- package/src/core/paths.ts +199 -199
- package/src/core/prompt-limits.ts +214 -214
- package/src/core/reasoning-effort.ts +102 -102
- package/src/core/stream-registry.ts +96 -96
- package/src/core/waf-isolation.ts +117 -117
- package/src/core/watchdog.ts +195 -195
- package/src/delete-chats.ts +23 -23
- package/src/index.ts +65 -64
- package/src/login.ts +147 -147
- package/src/reset-cooldowns.ts +11 -11
- package/src/routes/anthropic/index.ts +355 -355
- package/src/routes/anthropic/translate.ts +522 -522
- package/src/routes/anthropic/types.ts +154 -154
- package/src/routes/anthropic/validation.ts +144 -144
- package/src/routes/chat/account.ts +1817 -1817
- package/src/routes/chat/context.ts +241 -241
- package/src/routes/chat/errors.ts +85 -85
- package/src/routes/chat/helpers.ts +268 -268
- package/src/routes/chat/index.ts +618 -618
- package/src/routes/chat/media.ts +285 -285
- package/src/routes/chat/retry-policy.ts +754 -754
- package/src/routes/chat/stop.ts +98 -98
- package/src/routes/chat/streaming.ts +2710 -2710
- package/src/routes/chat/validation.ts +526 -526
- package/src/routes/chat.ts +2 -2
- package/src/routes/completions.ts +290 -290
- package/src/routes/images.ts +139 -139
- package/src/routes/responses/adapter.ts +503 -503
- package/src/routes/responses/index.ts +405 -405
- package/src/routes/responses/state.ts +230 -230
- package/src/routes/responses/streaming.ts +528 -528
- package/src/routes/responses/types.ts +285 -285
- package/src/routes/responses/validation.ts +202 -202
- package/src/routes/upload.ts +731 -731
- package/src/routes/videos.ts +214 -214
- package/src/services/auth-playwright.ts +173 -173
- package/src/services/captcha-coordinator.ts +161 -161
- package/src/services/captcha-solver.ts +553 -553
- package/src/services/chat-cleanup.ts +80 -80
- package/src/services/context-meter.ts +317 -317
- package/src/services/fingerprint.ts +242 -242
- package/src/services/human-behavior.ts +173 -173
- package/src/services/media-generation.ts +1748 -1748
- package/src/services/playwright.ts +2878 -2800
- package/src/services/qwen-chat-pool.ts +345 -345
- package/src/services/qwen-errors.ts +133 -133
- package/src/services/qwen-headers.ts +79 -79
- package/src/services/qwen-thread-state.ts +393 -393
- package/src/services/qwen-url.ts +19 -19
- package/src/services/qwen.ts +3126 -3126
- package/src/services/session-keeper.ts +88 -88
- package/src/services/token-estimation-metrics.ts +118 -118
- package/src/sync/claude-code.ts +75 -75
- package/src/sync/codex.ts +123 -123
- package/src/sync/index.ts +362 -362
- package/src/sync/omp.ts +105 -105
- package/src/sync/opencode.ts +214 -214
- package/src/sync/types.ts +53 -53
- package/src/sync/utils.ts +27 -27
- package/src/sync-clients.ts +189 -189
- package/src/tools/instructions.ts +137 -137
- package/src/tools/manifest.ts +81 -81
- package/src/tools/parser.ts +2989 -2989
- package/src/tools/toolcall-tags.ts +142 -142
- package/src/tui/app.ts +259 -264
- package/src/tui/index.ts +61 -61
- package/src/tui/markdown.ts +258 -258
- package/src/tui/proxy-client.ts +331 -326
- package/src/tui/screen.ts +294 -278
- package/src/tui/server-manager.ts +270 -270
- package/src/tui/theme.ts +432 -432
- package/src/tui/types.ts +33 -33
- package/src/tui/views/accounts-view.ts +656 -656
- package/src/tui/views/chat-view.ts +1018 -823
- package/src/tui/views/logs-view.ts +479 -413
- package/src/tui/views/status-view.ts +204 -204
- package/src/tui/views/storage-view.ts +304 -291
- package/src/tui/views/sync-view.ts +409 -409
- package/src/types/ali-oss.d.ts +32 -32
- package/src/update-cli.ts +121 -0
- package/src/utils/context-truncation.ts +84 -84
- package/src/utils/json.ts +380 -380
- package/src/utils/session-id.ts +37 -37
- package/src/utils/tool-call-guard.ts +84 -84
- package/src/utils/types.ts +109 -109
|
@@ -1,204 +1,204 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QwenProxy TUI - Status and Live Dashboard View (Tab 1)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { TuiView, ProxyStatusSnapshot } from "../types.ts";
|
|
6
|
-
import type { KeyEvent } from "../screen.ts";
|
|
7
|
-
import { theme, glyphs, drawBox, pad } from "../theme.ts";
|
|
8
|
-
import { fetchProxyStatus, resetAllCooldowns, formatUptime } from "../proxy-client.ts";
|
|
9
|
-
import { ServerManager } from "../server-manager.ts";
|
|
10
|
-
|
|
11
|
-
export class StatusView implements TuiView {
|
|
12
|
-
public readonly id = "status";
|
|
13
|
-
public readonly title = "Status";
|
|
14
|
-
public readonly tabNumber = 1;
|
|
15
|
-
|
|
16
|
-
private statusData: ProxyStatusSnapshot | null = null;
|
|
17
|
-
private actionMessage = "";
|
|
18
|
-
private actionMessageTimeout: NodeJS.Timeout | null = null;
|
|
19
|
-
private hoveredActionRow: number | null = null;
|
|
20
|
-
private lastLeftW = 34;
|
|
21
|
-
|
|
22
|
-
constructor() {
|
|
23
|
-
this.refresh();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async refresh(): Promise<void> {
|
|
27
|
-
try {
|
|
28
|
-
if (process.stdout.isTTY && !process.env.NODE_TEST_CONTEXT) {
|
|
29
|
-
const sManager = ServerManager.getInstance();
|
|
30
|
-
if (sManager.getState() === "error") {
|
|
31
|
-
void sManager.ensureStarted();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
this.statusData = await fetchProxyStatus();
|
|
35
|
-
} catch {}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public onActivate(): void {
|
|
39
|
-
this.refresh();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public getShortcuts(): Array<{ key: string; label: string }> {
|
|
43
|
-
return [
|
|
44
|
-
{ key: "r", label: "Recarregar" },
|
|
45
|
-
{ key: "z", label: "Zerar Cooldowns" },
|
|
46
|
-
];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private setMessage(msg: string): void {
|
|
50
|
-
this.actionMessage = msg;
|
|
51
|
-
clearTimeout(this.actionMessageTimeout!);
|
|
52
|
-
this.actionMessageTimeout = setTimeout(() => {
|
|
53
|
-
this.actionMessage = "";
|
|
54
|
-
}, 4000);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public async handleKey(key: KeyEvent): Promise<boolean | void> {
|
|
58
|
-
// Mouse hover over quick actions
|
|
59
|
-
if (key.name === "hover" && key.mouse) {
|
|
60
|
-
const { row, col } = key.mouse;
|
|
61
|
-
const leftW = this.lastLeftW || 34;
|
|
62
|
-
if (col >= 2 && col <= leftW - 1 && (row === 13 || row === 14)) {
|
|
63
|
-
if (this.hoveredActionRow !== row) {
|
|
64
|
-
this.hoveredActionRow = row;
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
} else if (this.hoveredActionRow !== null) {
|
|
68
|
-
this.hoveredActionRow = null;
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Mouse click interactions
|
|
74
|
-
if (key.name === "click" && key.mouse) {
|
|
75
|
-
const { row, col } = key.mouse;
|
|
76
|
-
const leftW = this.lastLeftW || 34;
|
|
77
|
-
if (col >= 2 && col <= leftW - 1) {
|
|
78
|
-
if (row === 13) {
|
|
79
|
-
await this.refresh();
|
|
80
|
-
this.setMessage(theme.green("✓ Status atualizado"));
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
if (row === 14) {
|
|
84
|
-
const cleared = resetAllCooldowns();
|
|
85
|
-
await this.refresh();
|
|
86
|
-
this.setMessage(theme.green(`✓ Cooldowns zerados: ${cleared} conta(s) liberada(s)`));
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if ((key.name === "r" || key.name === "R") && !key.ctrl) {
|
|
93
|
-
await this.refresh();
|
|
94
|
-
this.setMessage(theme.green("✓ Status atualizado"));
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if ((key.name === "z" || key.name === "Z") && !key.ctrl) {
|
|
99
|
-
const cleared = resetAllCooldowns();
|
|
100
|
-
await this.refresh();
|
|
101
|
-
this.setMessage(theme.green(`✓ Cooldowns zerados: ${cleared} conta(s) liberada(s)`));
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public render(width: number, height: number, snapshot?: ProxyStatusSnapshot | null): string[] {
|
|
107
|
-
const data = snapshot || this.statusData;
|
|
108
|
-
const isOnline = data?.online ?? false;
|
|
109
|
-
const contentH = Math.max(10, height);
|
|
110
|
-
|
|
111
|
-
// Two-column layout
|
|
112
|
-
const leftW = Math.max(34, Math.floor(width * 0.42));
|
|
113
|
-
this.lastLeftW = leftW;
|
|
114
|
-
const rightW = Math.max(34, width - leftW - 1);
|
|
115
|
-
|
|
116
|
-
// Left Column: System & Proxy Status
|
|
117
|
-
const serverState = ServerManager.getInstance().getState();
|
|
118
|
-
let onlineBadge: string;
|
|
119
|
-
if (isOnline || serverState === "online") {
|
|
120
|
-
onlineBadge = theme.green(`${glyphs.bullet} Online`);
|
|
121
|
-
} else if (serverState === "warming") {
|
|
122
|
-
onlineBadge = theme.yellow(`🟡 Iniciando...`);
|
|
123
|
-
} else if (serverState === "error") {
|
|
124
|
-
onlineBadge = theme.red(`✗ Erro`);
|
|
125
|
-
} else {
|
|
126
|
-
onlineBadge = theme.muted(`${glyphs.circle} Offline`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const uptimeSecs = data?.uptimeSeconds || Math.floor(process.uptime());
|
|
130
|
-
const uptimeStr = formatUptime(uptimeSecs);
|
|
131
|
-
|
|
132
|
-
const baseUrl = `http://${data?.host || "127.0.0.1"}:${data?.port || 7936}/v1`;
|
|
133
|
-
|
|
134
|
-
const leftContent = [
|
|
135
|
-
"",
|
|
136
|
-
` ${theme.bold("Status:")} ${onlineBadge}`,
|
|
137
|
-
` ${theme.bold("Base URL:")} ${theme.cyan(baseUrl)}`,
|
|
138
|
-
` ${theme.bold("Uptime:")} ${theme.cyan(uptimeStr)}`,
|
|
139
|
-
` ${theme.bold("RAM:")} ${theme.cyan(String(data?.rssMb || 0) + " MB")}`,
|
|
140
|
-
` ${theme.bold("Conexões:")} ${data?.activeStreams ? theme.yellow(String(data.activeStreams) + " ativas") : "0 ativas"}`,
|
|
141
|
-
"",
|
|
142
|
-
` ${theme.bold("Ações:")}`,
|
|
143
|
-
` ${this.hoveredActionRow === 13 ? theme.bgHover(` ${theme.cyan("[ R ] Recarregar")} `) : `${theme.cyan("[ R ]")} Recarregar`}`,
|
|
144
|
-
` ${this.hoveredActionRow === 14 ? theme.bgHover(` ${theme.yellow("[ Z ] Zerar Cooldowns")} `) : `${theme.yellow("[ Z ]")} Zerar Cooldowns`}`,
|
|
145
|
-
"",
|
|
146
|
-
this.actionMessage ? ` ${this.actionMessage}` : "",
|
|
147
|
-
];
|
|
148
|
-
|
|
149
|
-
const leftBox = drawBox({
|
|
150
|
-
title: "Sistema",
|
|
151
|
-
width: leftW,
|
|
152
|
-
height: contentH,
|
|
153
|
-
borderColor: theme.borderInactive,
|
|
154
|
-
titleColor: theme.cyan,
|
|
155
|
-
content: leftContent,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// Right Column: Accounts Pool Status
|
|
159
|
-
const accounts = data?.accounts || [];
|
|
160
|
-
const readyCount = accounts.filter((a) => !a.onCooldown && a.headersReady).length;
|
|
161
|
-
const rightContent: string[] = [
|
|
162
|
-
"",
|
|
163
|
-
` ${theme.dim("# Conta Status")}`,
|
|
164
|
-
` ${theme.dim("───────────────────────────────────────")}`,
|
|
165
|
-
];
|
|
166
|
-
|
|
167
|
-
if (accounts.length === 0) {
|
|
168
|
-
rightContent.push(` ${theme.muted("Nenhuma conta adicionada. (Vá em [5] Contas)")}`);
|
|
169
|
-
} else {
|
|
170
|
-
accounts.slice(0, contentH - 5).forEach((acc, idx) => {
|
|
171
|
-
const num = pad(String(idx + 1), 3);
|
|
172
|
-
const name = pad(acc.emailOrName, 22);
|
|
173
|
-
let status = theme.green(`${glyphs.bullet} Pronto`);
|
|
174
|
-
if (acc.onCooldown) {
|
|
175
|
-
const mins = Math.max(1, Math.round(acc.remainingCooldownMs / 60000));
|
|
176
|
-
status = theme.yellow(`⚠ Cooldown ${mins}m`);
|
|
177
|
-
} else if (!acc.headersReady) {
|
|
178
|
-
status = theme.yellow(`◐ Aquecendo...`);
|
|
179
|
-
}
|
|
180
|
-
rightContent.push(` ${num} ${name} ${status}`);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const rightBox = drawBox({
|
|
185
|
-
title: `Contas (${readyCount}/${accounts.length})`,
|
|
186
|
-
width: rightW,
|
|
187
|
-
height: contentH,
|
|
188
|
-
borderColor: theme.borderInactive,
|
|
189
|
-
titleColor: theme.lavender,
|
|
190
|
-
content: rightContent,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
// Merge columns side by side
|
|
194
|
-
const mergedLines: string[] = [];
|
|
195
|
-
const maxRows = Math.max(leftBox.length, rightBox.length);
|
|
196
|
-
for (let r = 0; r < maxRows; r++) {
|
|
197
|
-
const leftRow = leftBox[r] || " ".repeat(leftW);
|
|
198
|
-
const rightRow = rightBox[r] || " ".repeat(rightW);
|
|
199
|
-
mergedLines.push(leftRow + " " + rightRow);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return mergedLines;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* QwenProxy TUI - Status and Live Dashboard View (Tab 1)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { TuiView, ProxyStatusSnapshot } from "../types.ts";
|
|
6
|
+
import type { KeyEvent } from "../screen.ts";
|
|
7
|
+
import { theme, glyphs, drawBox, pad } from "../theme.ts";
|
|
8
|
+
import { fetchProxyStatus, resetAllCooldowns, formatUptime } from "../proxy-client.ts";
|
|
9
|
+
import { ServerManager } from "../server-manager.ts";
|
|
10
|
+
|
|
11
|
+
export class StatusView implements TuiView {
|
|
12
|
+
public readonly id = "status";
|
|
13
|
+
public readonly title = "Status";
|
|
14
|
+
public readonly tabNumber = 1;
|
|
15
|
+
|
|
16
|
+
private statusData: ProxyStatusSnapshot | null = null;
|
|
17
|
+
private actionMessage = "";
|
|
18
|
+
private actionMessageTimeout: NodeJS.Timeout | null = null;
|
|
19
|
+
private hoveredActionRow: number | null = null;
|
|
20
|
+
private lastLeftW = 34;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
this.refresh();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async refresh(): Promise<void> {
|
|
27
|
+
try {
|
|
28
|
+
if (process.stdout.isTTY && !process.env.NODE_TEST_CONTEXT) {
|
|
29
|
+
const sManager = ServerManager.getInstance();
|
|
30
|
+
if (sManager.getState() === "error") {
|
|
31
|
+
void sManager.ensureStarted();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.statusData = await fetchProxyStatus();
|
|
35
|
+
} catch {}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public onActivate(): void {
|
|
39
|
+
this.refresh();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public getShortcuts(): Array<{ key: string; label: string }> {
|
|
43
|
+
return [
|
|
44
|
+
{ key: "r", label: "Recarregar" },
|
|
45
|
+
{ key: "z", label: "Zerar Cooldowns" },
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private setMessage(msg: string): void {
|
|
50
|
+
this.actionMessage = msg;
|
|
51
|
+
clearTimeout(this.actionMessageTimeout!);
|
|
52
|
+
this.actionMessageTimeout = setTimeout(() => {
|
|
53
|
+
this.actionMessage = "";
|
|
54
|
+
}, 4000);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public async handleKey(key: KeyEvent): Promise<boolean | void> {
|
|
58
|
+
// Mouse hover over quick actions
|
|
59
|
+
if (key.name === "hover" && key.mouse) {
|
|
60
|
+
const { row, col } = key.mouse;
|
|
61
|
+
const leftW = this.lastLeftW || 34;
|
|
62
|
+
if (col >= 2 && col <= leftW - 1 && (row === 13 || row === 14)) {
|
|
63
|
+
if (this.hoveredActionRow !== row) {
|
|
64
|
+
this.hoveredActionRow = row;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
} else if (this.hoveredActionRow !== null) {
|
|
68
|
+
this.hoveredActionRow = null;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Mouse click interactions
|
|
74
|
+
if (key.name === "click" && key.mouse) {
|
|
75
|
+
const { row, col } = key.mouse;
|
|
76
|
+
const leftW = this.lastLeftW || 34;
|
|
77
|
+
if (col >= 2 && col <= leftW - 1) {
|
|
78
|
+
if (row === 13) {
|
|
79
|
+
await this.refresh();
|
|
80
|
+
this.setMessage(theme.green("✓ Status atualizado"));
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (row === 14) {
|
|
84
|
+
const cleared = resetAllCooldowns();
|
|
85
|
+
await this.refresh();
|
|
86
|
+
this.setMessage(theme.green(`✓ Cooldowns zerados: ${cleared} conta(s) liberada(s)`));
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if ((key.name === "r" || key.name === "R") && !key.ctrl) {
|
|
93
|
+
await this.refresh();
|
|
94
|
+
this.setMessage(theme.green("✓ Status atualizado"));
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if ((key.name === "z" || key.name === "Z") && !key.ctrl) {
|
|
99
|
+
const cleared = resetAllCooldowns();
|
|
100
|
+
await this.refresh();
|
|
101
|
+
this.setMessage(theme.green(`✓ Cooldowns zerados: ${cleared} conta(s) liberada(s)`));
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public render(width: number, height: number, snapshot?: ProxyStatusSnapshot | null): string[] {
|
|
107
|
+
const data = snapshot || this.statusData;
|
|
108
|
+
const isOnline = data?.online ?? false;
|
|
109
|
+
const contentH = Math.max(10, height);
|
|
110
|
+
|
|
111
|
+
// Two-column layout
|
|
112
|
+
const leftW = Math.max(34, Math.floor(width * 0.42));
|
|
113
|
+
this.lastLeftW = leftW;
|
|
114
|
+
const rightW = Math.max(34, width - leftW - 1);
|
|
115
|
+
|
|
116
|
+
// Left Column: System & Proxy Status
|
|
117
|
+
const serverState = ServerManager.getInstance().getState();
|
|
118
|
+
let onlineBadge: string;
|
|
119
|
+
if (isOnline || serverState === "online") {
|
|
120
|
+
onlineBadge = theme.green(`${glyphs.bullet} Online`);
|
|
121
|
+
} else if (serverState === "warming") {
|
|
122
|
+
onlineBadge = theme.yellow(`🟡 Iniciando...`);
|
|
123
|
+
} else if (serverState === "error") {
|
|
124
|
+
onlineBadge = theme.red(`✗ Erro`);
|
|
125
|
+
} else {
|
|
126
|
+
onlineBadge = theme.muted(`${glyphs.circle} Offline`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const uptimeSecs = data?.uptimeSeconds || Math.floor(process.uptime());
|
|
130
|
+
const uptimeStr = formatUptime(uptimeSecs);
|
|
131
|
+
|
|
132
|
+
const baseUrl = `http://${data?.host || "127.0.0.1"}:${data?.port || 7936}/v1`;
|
|
133
|
+
|
|
134
|
+
const leftContent = [
|
|
135
|
+
"",
|
|
136
|
+
` ${theme.bold("Status:")} ${onlineBadge}`,
|
|
137
|
+
` ${theme.bold("Base URL:")} ${theme.cyan(baseUrl)}`,
|
|
138
|
+
` ${theme.bold("Uptime:")} ${theme.cyan(uptimeStr)}`,
|
|
139
|
+
` ${theme.bold("RAM:")} ${theme.cyan(String(data?.rssMb || 0) + " MB")}`,
|
|
140
|
+
` ${theme.bold("Conexões:")} ${data?.activeStreams ? theme.yellow(String(data.activeStreams) + " ativas") : "0 ativas"}`,
|
|
141
|
+
"",
|
|
142
|
+
` ${theme.bold("Ações:")}`,
|
|
143
|
+
` ${this.hoveredActionRow === 13 ? theme.bgHover(` ${theme.cyan("[ R ] Recarregar")} `) : `${theme.cyan("[ R ]")} Recarregar`}`,
|
|
144
|
+
` ${this.hoveredActionRow === 14 ? theme.bgHover(` ${theme.yellow("[ Z ] Zerar Cooldowns")} `) : `${theme.yellow("[ Z ]")} Zerar Cooldowns`}`,
|
|
145
|
+
"",
|
|
146
|
+
this.actionMessage ? ` ${this.actionMessage}` : "",
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
const leftBox = drawBox({
|
|
150
|
+
title: "Sistema",
|
|
151
|
+
width: leftW,
|
|
152
|
+
height: contentH,
|
|
153
|
+
borderColor: theme.borderInactive,
|
|
154
|
+
titleColor: theme.cyan,
|
|
155
|
+
content: leftContent,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Right Column: Accounts Pool Status
|
|
159
|
+
const accounts = data?.accounts || [];
|
|
160
|
+
const readyCount = accounts.filter((a) => !a.onCooldown && a.headersReady).length;
|
|
161
|
+
const rightContent: string[] = [
|
|
162
|
+
"",
|
|
163
|
+
` ${theme.dim("# Conta Status")}`,
|
|
164
|
+
` ${theme.dim("───────────────────────────────────────")}`,
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
if (accounts.length === 0) {
|
|
168
|
+
rightContent.push(` ${theme.muted("Nenhuma conta adicionada. (Vá em [5] Contas)")}`);
|
|
169
|
+
} else {
|
|
170
|
+
accounts.slice(0, contentH - 5).forEach((acc, idx) => {
|
|
171
|
+
const num = pad(String(idx + 1), 3);
|
|
172
|
+
const name = pad(acc.emailOrName, 22);
|
|
173
|
+
let status = theme.green(`${glyphs.bullet} Pronto`);
|
|
174
|
+
if (acc.onCooldown) {
|
|
175
|
+
const mins = Math.max(1, Math.round(acc.remainingCooldownMs / 60000));
|
|
176
|
+
status = theme.yellow(`⚠ Cooldown ${mins}m`);
|
|
177
|
+
} else if (!acc.headersReady) {
|
|
178
|
+
status = theme.yellow(`◐ Aquecendo...`);
|
|
179
|
+
}
|
|
180
|
+
rightContent.push(` ${num} ${name} ${status}`);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const rightBox = drawBox({
|
|
185
|
+
title: `Contas (${readyCount}/${accounts.length})`,
|
|
186
|
+
width: rightW,
|
|
187
|
+
height: contentH,
|
|
188
|
+
borderColor: theme.borderInactive,
|
|
189
|
+
titleColor: theme.lavender,
|
|
190
|
+
content: rightContent,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Merge columns side by side
|
|
194
|
+
const mergedLines: string[] = [];
|
|
195
|
+
const maxRows = Math.max(leftBox.length, rightBox.length);
|
|
196
|
+
for (let r = 0; r < maxRows; r++) {
|
|
197
|
+
const leftRow = leftBox[r] || " ".repeat(leftW);
|
|
198
|
+
const rightRow = rightBox[r] || " ".repeat(rightW);
|
|
199
|
+
mergedLines.push(leftRow + " " + rightRow);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return mergedLines;
|
|
203
|
+
}
|
|
204
|
+
}
|