omnitrix 0.0.0-stage → 0.5.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 +202 -0
- package/NOTICE +4 -0
- package/README.md +343 -2
- package/dist/cli.js +1001 -0
- package/dist/dashboard-launch.js +188 -0
- package/dist/dashboard.js +466 -0
- package/dist/drivers/anthropic.js +46 -0
- package/dist/drivers/cli.js +432 -0
- package/dist/drivers/http.js +214 -0
- package/dist/drivers/index.js +21 -0
- package/dist/drivers/ollama.js +76 -0
- package/dist/drivers/openai.js +64 -0
- package/dist/engine.js +1205 -0
- package/dist/index.js +6 -0
- package/dist/init.js +57 -0
- package/dist/mcp.js +352 -0
- package/dist/models.js +87 -0
- package/dist/owner.js +59 -0
- package/dist/providers.js +48 -0
- package/dist/quota.js +215 -0
- package/dist/router.js +246 -0
- package/dist/seats.js +119 -0
- package/dist/stats.js +47 -0
- package/dist/statusline.js +76 -0
- package/dist/store.js +303 -0
- package/dist/team.js +406 -0
- package/dist/types.js +24 -0
- package/dist/usage.js +365 -0
- package/dist/verify.js +144 -0
- package/dist/version.js +1 -0
- package/dist/worktree.js +146 -0
- package/package.json +67 -4
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
// A small local web page with the same numbers as `omnitrix list`. One live stream sends every change to
|
|
2
|
+
// every open page, so nobody has to reload it.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { Engine } from './engine.js';
|
|
7
|
+
import { refreshQuotas } from './quota.js';
|
|
8
|
+
import { ensureHome, homeDir, writeJson } from './store.js';
|
|
9
|
+
import { verifySummary } from './verify.js';
|
|
10
|
+
import { VERSION } from './version.js';
|
|
11
|
+
/** The newest jobs for the page. A second check is shown on the job it checks, not as a job of its own. */
|
|
12
|
+
export function recentJobs(engine, limit = 30) {
|
|
13
|
+
return engine.listJobs(limit * 2).filter((j) => !j.checkOf).slice(0, limit).map((j) => ({
|
|
14
|
+
id: j.id,
|
|
15
|
+
status: j.status,
|
|
16
|
+
accountId: j.accountId,
|
|
17
|
+
model: j.model,
|
|
18
|
+
createdAt: j.createdAt,
|
|
19
|
+
updatedAt: j.updatedAt,
|
|
20
|
+
verdict: j.verdict,
|
|
21
|
+
error: j.error?.slice(0, 200),
|
|
22
|
+
usage: j.usage,
|
|
23
|
+
task: { title: j.task.title, type: j.task.type },
|
|
24
|
+
// omnitrix's own check of a code job, as one line; a failed test or files outside the task stand out
|
|
25
|
+
verify: j.verify ? { summary: verifySummary(j.verify), warn: !!j.verify.outside?.length || (!!j.verify.test && j.verify.test.status !== 'passed' && j.verify.test.status !== 'running') } : undefined,
|
|
26
|
+
check: j.check ? { status: j.check.status, by: j.check.by, note: j.check.note?.slice(0, 400) } : undefined,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/** Where the dashboard on a port writes its process id, so it can be found, checked and stopped. */
|
|
30
|
+
export function dashboardFile(port) {
|
|
31
|
+
return path.join(homeDir(), `dashboard-${port}.json`);
|
|
32
|
+
}
|
|
33
|
+
// How often the stream looks for changes, how often slow provider checks may start, and how often an
|
|
34
|
+
// unchanged page hears that the server is still there.
|
|
35
|
+
const LOOK_MS = 1000;
|
|
36
|
+
const SLOW_MS = 5000;
|
|
37
|
+
const ALIVE_MS = 5000;
|
|
38
|
+
// After a tab is opened, it takes a moment to connect; a second setup in that time must not open another.
|
|
39
|
+
const OPEN_GRACE_MS = 20_000;
|
|
40
|
+
// More pages than anyone keeps open; a program opening streams without end is turned away.
|
|
41
|
+
const MAX_VIEWERS = 16;
|
|
42
|
+
// A page that stops reading is dropped before its unsent updates pile up.
|
|
43
|
+
const MAX_BUFFERED = 1024 * 1024;
|
|
44
|
+
export function startDashboard(port) {
|
|
45
|
+
const engine = new Engine();
|
|
46
|
+
const viewers = new Set();
|
|
47
|
+
let latest = '';
|
|
48
|
+
let slowAt = 0;
|
|
49
|
+
let openedAt = 0;
|
|
50
|
+
const snapshot = () => JSON.stringify({ version: VERSION, accounts: engine.pool(), jobs: recentJobs(engine) });
|
|
51
|
+
// Quota reads and local server probes run in the background and are throttled; the page never waits for them.
|
|
52
|
+
const slowChecks = () => {
|
|
53
|
+
if (Date.now() - slowAt < SLOW_MS)
|
|
54
|
+
return;
|
|
55
|
+
slowAt = Date.now();
|
|
56
|
+
void refreshQuotas(engine.config().accounts);
|
|
57
|
+
engine.checkLocal().catch(() => { });
|
|
58
|
+
};
|
|
59
|
+
const send = (res, text) => {
|
|
60
|
+
try {
|
|
61
|
+
res.write(text);
|
|
62
|
+
if (res.writableLength > MAX_BUFFERED)
|
|
63
|
+
throw new Error('not reading');
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
viewers.delete(res);
|
|
67
|
+
res.destroy();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
// One reading for all open pages; nothing is read while no page is open.
|
|
71
|
+
const look = () => {
|
|
72
|
+
if (!viewers.size)
|
|
73
|
+
return;
|
|
74
|
+
slowChecks();
|
|
75
|
+
let body;
|
|
76
|
+
try {
|
|
77
|
+
body = snapshot();
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return; // a file half-written by another process; the next look reads it whole
|
|
81
|
+
}
|
|
82
|
+
if (body === latest)
|
|
83
|
+
return;
|
|
84
|
+
latest = body;
|
|
85
|
+
for (const res of viewers)
|
|
86
|
+
send(res, `data: ${body}\n\n`);
|
|
87
|
+
};
|
|
88
|
+
const lookTimer = setInterval(look, LOOK_MS);
|
|
89
|
+
const aliveTimer = setInterval(() => {
|
|
90
|
+
for (const res of viewers)
|
|
91
|
+
send(res, `event: alive\ndata: ${Date.now()}\n\n`);
|
|
92
|
+
}, ALIVE_MS);
|
|
93
|
+
lookTimer.unref();
|
|
94
|
+
aliveTimer.unref();
|
|
95
|
+
const json = (res, value) => {
|
|
96
|
+
res.writeHead(200, { 'content-type': 'application/json', 'cache-control': 'no-store', 'x-content-type-options': 'nosniff' }).end(JSON.stringify(value));
|
|
97
|
+
};
|
|
98
|
+
const server = http.createServer((req, res) => {
|
|
99
|
+
// only answer requests made to this machine by name (blocks DNS-rebinding tricks)
|
|
100
|
+
const host = (req.headers.host ?? '').split(':')[0];
|
|
101
|
+
if (host !== '127.0.0.1' && host !== 'localhost') {
|
|
102
|
+
res.writeHead(403).end('forbidden');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// Any website can make the browser call this server, and each status call starts a quota read.
|
|
106
|
+
// Browsers label such calls; only our own page, a typed address or a tool that sends no label gets in.
|
|
107
|
+
const site = req.headers['sec-fetch-site'];
|
|
108
|
+
if (site !== undefined && site !== 'same-origin' && site !== 'none') {
|
|
109
|
+
res.writeHead(403).end('forbidden');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (req.url === '/api/events') {
|
|
113
|
+
if (viewers.size >= MAX_VIEWERS) {
|
|
114
|
+
res.writeHead(503, { 'retry-after': '10' }).end('too many open pages');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
res.writeHead(200, { 'content-type': 'text/event-stream', 'cache-control': 'no-store', 'x-content-type-options': 'nosniff', connection: 'keep-alive' });
|
|
118
|
+
// a page that loses the stream asks again after two seconds
|
|
119
|
+
res.write('retry: 2000\n\n');
|
|
120
|
+
if (!viewers.size || !latest) {
|
|
121
|
+
try {
|
|
122
|
+
latest = snapshot();
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
latest = latest || '';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (latest)
|
|
129
|
+
res.write(`data: ${latest}\n\n`);
|
|
130
|
+
viewers.add(res);
|
|
131
|
+
slowChecks();
|
|
132
|
+
res.on('close', () => viewers.delete(res));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (req.url === '/api/status') {
|
|
136
|
+
slowChecks();
|
|
137
|
+
json(res, { version: VERSION, now: Date.now(), accounts: engine.pool(), jobs: recentJobs(engine) });
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (req.url === '/api/ping') {
|
|
141
|
+
json(res, { omnitrix: true, version: VERSION, pid: process.pid, viewers: viewers.size });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// asked by `omnitrix dashboard` and `omnitrix init` before they open a tab: one tab is enough
|
|
145
|
+
if (req.url === '/api/claim-open') {
|
|
146
|
+
const open = viewers.size === 0 && Date.now() - openedAt > OPEN_GRACE_MS;
|
|
147
|
+
if (open)
|
|
148
|
+
openedAt = Date.now();
|
|
149
|
+
json(res, { open });
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (req.url === '/' || req.url === '/index.html') {
|
|
153
|
+
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'content-security-policy': "default-src 'self'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; frame-ancestors 'none'", 'x-content-type-options': 'nosniff', 'x-frame-options': 'DENY' }).end(PAGE);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
res.writeHead(404).end('not found');
|
|
157
|
+
});
|
|
158
|
+
// a client that never finishes sending its request is cut off; the live stream itself has no time limit
|
|
159
|
+
server.headersTimeout = 5000;
|
|
160
|
+
server.requestTimeout = 10_000;
|
|
161
|
+
server.listen(port, '127.0.0.1');
|
|
162
|
+
const close = () => new Promise((resolve) => {
|
|
163
|
+
clearInterval(lookTimer);
|
|
164
|
+
clearInterval(aliveTimer);
|
|
165
|
+
for (const res of viewers)
|
|
166
|
+
res.end();
|
|
167
|
+
viewers.clear();
|
|
168
|
+
server.closeAllConnections?.();
|
|
169
|
+
server.close(() => resolve());
|
|
170
|
+
});
|
|
171
|
+
return { url: `http://127.0.0.1:${port}`, server, close };
|
|
172
|
+
}
|
|
173
|
+
/** Run the dashboard until the process is stopped, recording where it runs. */
|
|
174
|
+
export function serveDashboard(port) {
|
|
175
|
+
const d = startDashboard(port);
|
|
176
|
+
d.server.on('error', (err) => {
|
|
177
|
+
process.stderr.write(err.code === 'EADDRINUSE' ? `port ${port} is already in use\n` : `dashboard: ${err.message}\n`);
|
|
178
|
+
process.exit(1);
|
|
179
|
+
});
|
|
180
|
+
d.server.on('listening', () => {
|
|
181
|
+
try {
|
|
182
|
+
ensureHome();
|
|
183
|
+
writeJson(dashboardFile(port), { pid: process.pid, port, version: VERSION, startedAt: Date.now() });
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// the dashboard works without it; `omnitrix dashboard --stop` then cannot find it
|
|
187
|
+
}
|
|
188
|
+
console.log(`dashboard: ${d.url}`);
|
|
189
|
+
});
|
|
190
|
+
const done = () => {
|
|
191
|
+
try {
|
|
192
|
+
const saved = JSON.parse(fs.readFileSync(dashboardFile(port), 'utf8'));
|
|
193
|
+
if (saved.pid === process.pid)
|
|
194
|
+
fs.rmSync(dashboardFile(port), { force: true });
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// nothing recorded
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
process.on('exit', done);
|
|
201
|
+
for (const sig of ['SIGINT', 'SIGTERM'])
|
|
202
|
+
process.on(sig, () => process.exit(0));
|
|
203
|
+
}
|
|
204
|
+
// The page is one self-contained file: no fonts, scripts or images from other hosts, so it works offline
|
|
205
|
+
// and sends nothing anywhere. The script below avoids backticks and backslashes because it lives in a
|
|
206
|
+
// template literal.
|
|
207
|
+
const PAGE = /* html */ `<!doctype html>
|
|
208
|
+
<html lang="en">
|
|
209
|
+
<head>
|
|
210
|
+
<meta charset="utf-8">
|
|
211
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
212
|
+
<title>omnitrix</title>
|
|
213
|
+
<style>
|
|
214
|
+
:root{
|
|
215
|
+
--bg:#f6f6f3;--surface:#ffffff;--tile:#efeee9;--line:rgba(20,20,19,.11);--line-strong:rgba(20,20,19,.2);
|
|
216
|
+
--ink:#141413;--ink-2:#4d4c48;--ink-3:#66655f;
|
|
217
|
+
--accent:#2563c9;--accent-bg:#e6eefb;--track:#e7e6e0;
|
|
218
|
+
--ok:#1b6f35;--ok-bg:#e3f2e7;--warn:#8a5a00;--warn-bg:#fbf0d4;--bad:#b42323;--bad-bg:#fbe7e7;--idle:#55544f;--idle-bg:#ecebe6;
|
|
219
|
+
--focus:#2563c9;--r:12px;--r-sm:8px;
|
|
220
|
+
--font:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
|
|
221
|
+
--mono:ui-monospace,"Cascadia Mono",Consolas,Menlo,monospace;
|
|
222
|
+
color-scheme:light;
|
|
223
|
+
}
|
|
224
|
+
@media (prefers-color-scheme:dark){:root{
|
|
225
|
+
--bg:#181816;--surface:#21211f;--tile:#2a2a27;--line:rgba(255,255,255,.1);--line-strong:rgba(255,255,255,.2);
|
|
226
|
+
--ink:#f0efea;--ink-2:#c9c8bf;--ink-3:#a3a299;
|
|
227
|
+
--accent:#6ea3f2;--accent-bg:#1d2d45;--track:#34342f;
|
|
228
|
+
--ok:#6fcf8b;--ok-bg:#16301f;--warn:#e9bf5c;--warn-bg:#382c0e;--bad:#f28b8b;--bad-bg:#3b1c1c;--idle:#bdbcb3;--idle-bg:#2f2f2b;
|
|
229
|
+
--focus:#6ea3f2;color-scheme:dark;
|
|
230
|
+
}}
|
|
231
|
+
*{box-sizing:border-box}
|
|
232
|
+
html{scroll-padding-top:72px}
|
|
233
|
+
body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.5 var(--font);-webkit-font-smoothing:antialiased}
|
|
234
|
+
a{color:var(--accent)}
|
|
235
|
+
:focus-visible{outline:2px solid var(--focus);outline-offset:2px;border-radius:4px}
|
|
236
|
+
.wrap{max-width:1180px;margin:0 auto;padding:10px 24px 48px}
|
|
237
|
+
header{display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 -24px 20px;padding:14px 24px;position:sticky;top:0;z-index:5;background:var(--bg)}
|
|
238
|
+
@supports (background:color-mix(in srgb,red 50%,transparent)){header{background:color-mix(in srgb,var(--bg) 88%,transparent);-webkit-backdrop-filter:blur(18px) saturate(140%);backdrop-filter:blur(18px) saturate(140%)}}
|
|
239
|
+
.brand{display:flex;align-items:center;gap:10px}
|
|
240
|
+
.brand h1{font-size:20px;font-weight:600;margin:0;line-height:1.2;letter-spacing:-.015em}
|
|
241
|
+
.chip{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;line-height:1;padding:5px 9px;border-radius:999px;background:var(--tile);color:var(--ink-2);white-space:nowrap}
|
|
242
|
+
.fresh{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--ink-2)}
|
|
243
|
+
.dot{width:8px;height:8px;border-radius:50%;background:var(--ok);flex:none}
|
|
244
|
+
.fresh.stale .dot{background:var(--warn)}.fresh.stale{color:var(--warn)}
|
|
245
|
+
.kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:28px}
|
|
246
|
+
.kpi{background:var(--tile);border-radius:var(--r);padding:14px 16px}
|
|
247
|
+
.kpi span{display:block;font-size:13px;color:var(--ink-2)}
|
|
248
|
+
.kpi b{display:block;font-size:26px;font-weight:600;line-height:1.15;margin-top:4px;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
|
|
249
|
+
h2{font-size:15px;font-weight:600;margin:0 0 12px;letter-spacing:-.005em;display:flex;align-items:baseline;gap:8px}
|
|
250
|
+
h2 small{font-size:13px;font-weight:400;color:var(--ink-3)}
|
|
251
|
+
.kpi em{display:block;font-style:normal;font-size:13px;color:var(--warn);margin-top:2px}
|
|
252
|
+
.ver{font-size:13px;color:var(--ink-3)}
|
|
253
|
+
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(300px,100%),1fr));gap:14px;margin-bottom:32px}
|
|
254
|
+
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:16px 18px;display:flex;flex-direction:column;gap:12px;min-width:0}
|
|
255
|
+
.head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
|
|
256
|
+
.title{display:flex;align-items:center;gap:10px;min-width:0}
|
|
257
|
+
.title svg{flex:none;color:var(--ink-2)}
|
|
258
|
+
.title h3{font-size:16px;font-weight:600;margin:0;line-height:1.3;letter-spacing:-.01em;overflow-wrap:break-word}
|
|
259
|
+
.sub{font-size:13px;color:var(--ink-3);margin-top:1px;overflow-wrap:break-word}
|
|
260
|
+
.state{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:500;padding:4px 10px;border-radius:999px;white-space:nowrap}
|
|
261
|
+
.state i{width:7px;height:7px;border-radius:50%;background:currentColor}
|
|
262
|
+
.s-ok{background:var(--ok-bg);color:var(--ok)}.s-busy{background:var(--accent-bg);color:var(--accent)}
|
|
263
|
+
.s-warn{background:var(--warn-bg);color:var(--warn)}.s-bad{background:var(--bad-bg);color:var(--bad)}.s-idle{background:var(--idle-bg);color:var(--idle)}
|
|
264
|
+
.note{font-size:13.5px;border-radius:var(--r-sm);padding:9px 11px;background:var(--tile);color:var(--ink-2)}
|
|
265
|
+
.note.warn{background:var(--warn-bg);color:var(--warn)}.note.bad{background:var(--bad-bg);color:var(--bad)}
|
|
266
|
+
.note code,.empty code{font:12.5px var(--mono);background:var(--surface);color:var(--ink);padding:1px 6px;border-radius:5px;border:1px solid var(--line)}
|
|
267
|
+
.win+.win{margin-top:10px}
|
|
268
|
+
.row{display:flex;justify-content:space-between;gap:10px;font-size:13.5px}
|
|
269
|
+
.row span:first-child{color:var(--ink-2)}.row b{font-weight:600;font-variant-numeric:tabular-nums}
|
|
270
|
+
.row b.low{color:var(--warn)}.row b.out{color:var(--bad)}
|
|
271
|
+
.bar{height:8px;border-radius:99px;background:var(--track);overflow:hidden;margin:6px 0 4px}
|
|
272
|
+
.bar i{display:block;height:100%;border-radius:99px;background:var(--accent);transition:width .4s ease}
|
|
273
|
+
.bar i.low{background:var(--warn)}.bar i.out{background:var(--bad)}
|
|
274
|
+
.when{font-size:12.5px;letter-spacing:.005em;color:var(--ink-3)}
|
|
275
|
+
.when.pace{color:var(--warn)}
|
|
276
|
+
.prov{font-size:12.5px;letter-spacing:.005em;color:var(--ink-3);display:flex;align-items:center;gap:6px}
|
|
277
|
+
.stats{display:flex;flex-wrap:wrap;gap:4px 16px;font-size:13px;color:var(--ink-2);border-top:1px solid var(--line);padding-top:10px}
|
|
278
|
+
.stats b{font-weight:600;color:var(--ink);font-variant-numeric:tabular-nums}
|
|
279
|
+
.stats .prov{margin-left:auto}
|
|
280
|
+
details{font-size:13px;color:var(--ink-2)}
|
|
281
|
+
summary{cursor:pointer;color:var(--ink-2);width:max-content;padding:4px 0;min-height:24px}
|
|
282
|
+
summary:hover{color:var(--ink)}
|
|
283
|
+
summary:active{color:var(--ink)}
|
|
284
|
+
.models{margin:8px 0 0;padding:0;list-style:none;display:flex;flex-wrap:wrap;gap:6px}
|
|
285
|
+
.models li{font:12px var(--mono);background:var(--tile);border-radius:6px;padding:3px 7px;overflow-wrap:anywhere}
|
|
286
|
+
.jobs{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);overflow:hidden;list-style:none;margin:0;padding:0}
|
|
287
|
+
.job{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:4px 14px;align-items:start;padding:12px 16px;border-top:1px solid var(--line)}
|
|
288
|
+
.job:first-child{border-top:0}
|
|
289
|
+
.job .t{font-weight:500;overflow-wrap:anywhere}
|
|
290
|
+
.job .m{font:12px/1.6 var(--mono);color:var(--ink-3);overflow-wrap:anywhere}
|
|
291
|
+
.job .r{font-size:13px;color:var(--ink-3);text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
|
|
292
|
+
.job details{grid-column:2/4;margin-top:4px}
|
|
293
|
+
.job .err{color:var(--bad);font:12.5px/1.5 var(--mono);margin-top:6px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
294
|
+
.job .vf{grid-column:2/4;color:var(--ink-2);font-size:12.5px;line-height:1.5;overflow-wrap:anywhere}
|
|
295
|
+
.job .vf.warn{color:var(--warn)}.stats .warn{color:var(--warn)}
|
|
296
|
+
.empty{background:var(--surface);border:1px dashed var(--line-strong);border-radius:var(--r);padding:22px;color:var(--ink-2)}
|
|
297
|
+
.empty h3{margin:0 0 6px;font-size:16px;color:var(--ink)}
|
|
298
|
+
.empty ol{margin:10px 0 0;padding-left:20px;line-height:2}
|
|
299
|
+
footer{font-size:12.5px;letter-spacing:.005em;color:var(--ink-3);margin-top:28px}
|
|
300
|
+
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
301
|
+
@media (max-width:720px){.wrap{padding:6px 16px 40px}header{margin:0 -16px 16px;padding:12px 16px}html{scroll-padding-top:112px}.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.kpi b{font-size:22px}.job{grid-template-columns:auto minmax(0,1fr)}.job .r{grid-column:2;text-align:left}.job details{grid-column:1/3}.job .vf{grid-column:2/3}}
|
|
302
|
+
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
|
|
303
|
+
@media (max-height:500px){header{position:static}html{scroll-padding-top:0}}
|
|
304
|
+
@media (prefers-reduced-transparency:reduce),(prefers-contrast:more){header{background:var(--bg);-webkit-backdrop-filter:none;backdrop-filter:none;border-bottom:1px solid var(--line)}}
|
|
305
|
+
@media (prefers-contrast:more){:root{--line:var(--line-strong);--ink-3:var(--ink-2)}.card,.jobs,.kpi,.bar{border:1px solid var(--ink-3)}}
|
|
306
|
+
@media (forced-colors:active){.bar{border:1px solid CanvasText}.bar i,.dot,.state i{forced-color-adjust:none;background:Highlight}header{background:Canvas;-webkit-backdrop-filter:none;backdrop-filter:none}}
|
|
307
|
+
</style>
|
|
308
|
+
</head>
|
|
309
|
+
<body>
|
|
310
|
+
<div class="wrap">
|
|
311
|
+
<header>
|
|
312
|
+
<div class="brand"><h1>omnitrix</h1><span class="ver" id="ver"></span></div>
|
|
313
|
+
<div class="fresh" id="fresh"><span class="dot" aria-hidden="true"></span><span id="fresh-text">Connecting</span></div>
|
|
314
|
+
<div class="sr" id="announce" role="status"></div>
|
|
315
|
+
</header>
|
|
316
|
+
<main>
|
|
317
|
+
<section class="kpis" id="kpis" aria-label="Summary for the last 24 hours"></section>
|
|
318
|
+
<section aria-labelledby="acc-h"><h2 id="acc-h">Accounts <small id="acc-sub"></small></h2><div class="grid" id="accounts"></div></section>
|
|
319
|
+
<section aria-labelledby="job-h"><h2 id="job-h">Recent jobs <small>newest first</small></h2><div id="jobs"></div></section>
|
|
320
|
+
</main>
|
|
321
|
+
<footer>This page only shows status. Change accounts and settings with the omnitrix command.</footer>
|
|
322
|
+
</div>
|
|
323
|
+
<script>
|
|
324
|
+
var esc=function(s){return String(s==null?'':s).replace(/[&<>"']/g,function(c){return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]})};
|
|
325
|
+
var fmt=function(n){n=Number(n)||0;return n>=999500?(n/1e6).toFixed(1)+'M':n>=1e3?(Math.round(n/100)/10)+'k':String(Math.round(n))};
|
|
326
|
+
var money=function(c){c=Number(c)||0;return c>0&&c<0.005?'under $0.01':'$'+c.toFixed(2)};
|
|
327
|
+
var clock=function(t){return new Date(t).toLocaleString([],{weekday:'short',hour:'numeric',minute:'2-digit'})};
|
|
328
|
+
var span=function(ms){var m=Math.max(0,Math.round(ms/60000));return m<1?'under a minute':m<60?m+' min':m<1440?Math.floor(m/60)+' h'+(m%60?' '+(m%60)+' min':''):Math.floor(m/1440)+' d '+Math.floor(m%1440/60)+' h'};
|
|
329
|
+
var ago=function(t){var s=Math.round((Date.now()-t)/1000);return s<60?s+' s ago':s<3600?Math.round(s/60)+' min ago':s<172800?Math.round(s/3600)+' h ago':Math.round(s/86400)+' days ago'};
|
|
330
|
+
function icon(name){
|
|
331
|
+
var p={terminal:'<rect x="3" y="4" width="18" height="16" rx="2.5"/><path d="M7 9l3 3-3 3M12 15h5"/>',
|
|
332
|
+
cloud:'<path d="M7 18a4.5 4.5 0 0 1-.5-9 6 6 0 0 1 11.5 1.5A3.75 3.75 0 0 1 17.5 18z"/>',
|
|
333
|
+
chip:'<rect x="6" y="6" width="12" height="12" rx="2"/><path d="M9 2v4M15 2v4M9 18v4M15 18v4M2 9h4M2 15h4M18 9h4M18 15h4"/>'}[name];
|
|
334
|
+
return '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'+p+'</svg>';
|
|
335
|
+
}
|
|
336
|
+
var STATES={ready:['Ready','s-ok'],busy:['Working','s-busy'],cooling:['Resting','s-warn'],exhausted:['Out of quota','s-bad'],offline:['Offline','s-warn'],auth_error:['Needs sign-in','s-bad'],disabled:['Turned off','s-idle']};
|
|
337
|
+
var SOURCES={measured:'Measured by the provider',estimated:'Counted by omnitrix against your limits',untracked:'Not tracked'};
|
|
338
|
+
function windowHtml(w){
|
|
339
|
+
var pct=w.unit==='percent', left=pct?Math.max(0,Math.min(100,w.remaining)):(w.limit>0?Math.max(0,Math.min(100,w.remaining/w.limit*100)):0);
|
|
340
|
+
var cls=left<=0?'out':left<20?'low':'';
|
|
341
|
+
var amount=pct?Math.round(left)+'% left':fmt(w.remaining)+' of '+fmt(w.limit)+' '+esc(w.unit)+' left';
|
|
342
|
+
var label=esc(w.name)+(pct?'':' ('+esc(w.unit)+')');
|
|
343
|
+
var reset=w.resetsAt?'<div class="when">Resets in '+esc(span(w.resetsAt-Date.now()))+', '+esc(clock(w.resetsAt))+'</div>':'';
|
|
344
|
+
// the server only sends runsOutAt when the current pace empties the window before it resets
|
|
345
|
+
if(w.runsOutAt&&w.runsOutAt>Date.now())reset+='<div class="when pace">At this pace it runs out in about '+esc(span(w.runsOutAt-Date.now()))+', '+esc(clock(w.runsOutAt))+'</div>';
|
|
346
|
+
return '<div class="win"><div class="row"><span>'+label+'</span><b class="'+cls+'">'+amount+'</b></div>'
|
|
347
|
+
+'<div class="bar" role="progressbar" aria-label="'+label+' remaining" aria-valuemin="0" aria-valuemax="100" aria-valuenow="'+Math.round(left)+'" aria-valuetext="'+esc(amount)+'"><i class="'+cls+'" style="width:'+left.toFixed(1)+'%"></i></div>'+reset+'</div>';
|
|
348
|
+
}
|
|
349
|
+
function cardHtml(a,open){
|
|
350
|
+
var u=a.usage, st=STATES[a.state]||['Unknown','s-idle'];
|
|
351
|
+
var ico=a.local?'chip':a.driver==='cli'?'terminal':'cloud';
|
|
352
|
+
var facts=[a.owner?'Owned by '+esc(a.owner):'',esc(a.id),u.plan?esc(u.plan)+' plan':'',a.local?'Runs on this PC':'',a.trainsOnData?'Public tasks only':'',a.running?a.running+' job'+(a.running>1?'s':'')+' running':''];
|
|
353
|
+
var sub=facts.filter(Boolean).join(' · ');
|
|
354
|
+
var notes='';
|
|
355
|
+
if(a.state!=='ready'&&a.state!=='busy'){
|
|
356
|
+
var DEFAULT={exhausted:'No quota left in the current window',offline:'omnitrix cannot reach this account',cooling:'Taking a short break after errors',auth_error:'Not signed in',disabled:'Turned off in omnitrix'};
|
|
357
|
+
// the engine's own reasons are lower case ("rate limited"); here they start a sentence. Provider
|
|
358
|
+
// messages pass through untouched, since they may begin with a name like "openai".
|
|
359
|
+
var why=String(a.reason||DEFAULT[a.state]||'').replace(/[.]+$/,'');
|
|
360
|
+
if(/^(rate limited|provider error|no answer|every model is paused)/.test(why))why=why.charAt(0).toUpperCase()+why.slice(1);
|
|
361
|
+
var back=a.until?' Back in '+esc(span(a.until-Date.now()))+', '+esc(clock(a.until))+'.':'';
|
|
362
|
+
var fix=a.state==='auth_error'?' Run <code>omnitrix login '+esc(a.id)+'</code> to sign in again.':a.state==='disabled'?' Run <code>omnitrix enable '+esc(a.id)+'</code> to turn it on.':'';
|
|
363
|
+
var text=(why?esc(why)+'.':'')+back+fix;
|
|
364
|
+
if(text)notes+='<div class="note '+(st[1]==='s-bad'?'bad':st[1]==='s-warn'?'warn':'')+'">'+text+'</div>';
|
|
365
|
+
}
|
|
366
|
+
var paused=a.pausedModels||[];
|
|
367
|
+
if(paused.length)notes+='<div class="note warn">Resting after errors: '+esc(paused.join(', '))+'.'+(paused.length<(a.models||[]).length?' omnitrix uses the other models meanwhile.':'')+'</div>';
|
|
368
|
+
var quota=u.windows.length?u.windows.map(windowHtml).join('')
|
|
369
|
+
:a.local?'<div class="note">No usage limit. It runs on this PC.</div>'
|
|
370
|
+
:a.state==='auth_error'||a.state==='disabled'?''
|
|
371
|
+
:a.driver==='cli'?'<div class="note">This plan does not publish its limits, so omnitrix shows what it has sent below.</div>'
|
|
372
|
+
:'<div class="note">No limit is known for this account, so omnitrix cannot show what is left. To track one, run <code>omnitrix set '+esc(a.id)+' --rpd 1000</code> with your real daily limit.</div>';
|
|
373
|
+
var models=a.models||[], shown=models.slice(0,40);
|
|
374
|
+
var modelHtml=models.length?'<details data-key="m-'+esc(a.id)+'"'+(open['m-'+a.id]?' open':'')+'><summary>'+models.length+' model'+(models.length>1?'s':'')+'</summary><ul class="models">'+shown.map(function(m){return '<li>'+esc(m)+'</li>'}).join('')+(models.length>shown.length?'<li>and '+(models.length-shown.length)+' more</li>':'')+'</ul></details>':'';
|
|
375
|
+
return '<article class="card" aria-label="'+esc(a.label)+'">'
|
|
376
|
+
+'<div class="head"><div class="title">'+icon(ico)+'<div><h3>'+esc(a.label)+'</h3><div class="sub">'+sub+'</div></div></div><span class="state '+st[1]+'"><i aria-hidden="true"></i>'+st[0]+'</span></div>'
|
|
377
|
+
+(quota?'<div>'+quota+'</div>':'')+notes
|
|
378
|
+
+'<div class="stats"><span>Last 24 h</span><span><b>'+u.requestsToday+'</b> answered</span>'+(u.failedToday?'<span class="warn"><b>'+u.failedToday+'</b> failed</span>':'')+'<span><b>'+fmt(u.tokensToday)+'</b> tokens</span>'+(u.costToday?'<span><b>'+money(u.costToday)+'</b></span>':'')
|
|
379
|
+
+(u.windows.length?'<span class="prov">'+esc(SOURCES[u.source]||u.source)+(u.updatedAt&&!u.stale?', updated '+esc(ago(u.updatedAt)):'')+'</span>':'')+'</div>'
|
|
380
|
+
+(u.stale&&u.updatedAt?'<div class="note warn">omnitrix could not read these numbers again. They are from '+esc(clock(u.updatedAt))+' and may be out of date.</div>':'')
|
|
381
|
+
+modelHtml+'</article>';
|
|
382
|
+
}
|
|
383
|
+
var JOB={done:['Done','s-ok'],running:['Running','s-busy'],queued:['Waiting','s-idle'],failed:['Failed','s-bad'],cancelled:['Cancelled','s-idle']};
|
|
384
|
+
function jobHtml(j,open){
|
|
385
|
+
var st=JOB[j.status]||[j.status,'s-idle'];
|
|
386
|
+
var tokens=j.usage?fmt(j.usage.inputTokens+j.usage.outputTokens)+' tokens':'';
|
|
387
|
+
var verdict=j.verdict?(j.verdict==='accepted'?'Accepted by Claude':'Rejected by Claude'):'';
|
|
388
|
+
var err=j.error&&j.status!=='done'?'<details data-key="e-'+esc(j.id)+'"'+(open['e-'+j.id]?' open':'')+'><summary>Why it '+(j.status==='failed'?'failed':'stopped')+'</summary><div class="err">'+esc(j.error)+'</div></details>':'';
|
|
389
|
+
return '<li class="job"><span class="state '+st[1]+'"><i aria-hidden="true"></i>'+st[0]+'</span>'
|
|
390
|
+
+'<div><div class="t">'+esc(j.task.title)+'</div><div class="m">'+esc(j.task.type)+(j.accountId?' · '+esc(j.accountId)+(j.model?' / '+esc(j.model):''):'')+'</div></div>'
|
|
391
|
+
+'<div class="r">'+[tokens,ago(j.createdAt)].filter(Boolean).join(' · ')+(verdict?'<div>'+verdict+'</div>':'')+'</div>'+err
|
|
392
|
+
+(j.verify?'<div class="vf'+(j.verify.warn?' warn':'')+'">Checked by omnitrix: '+esc(j.verify.summary)+'</div>':'')+checkHtml(j.check)+'</li>';
|
|
393
|
+
}
|
|
394
|
+
// the second model's check, on the job it checks; a check that could not run is not a failure of the job
|
|
395
|
+
function checkHtml(c){
|
|
396
|
+
if(!c)return '';
|
|
397
|
+
var by=c.by?' by '+esc(c.by):'', note=c.note?' '+esc(c.note):'';
|
|
398
|
+
var text=c.status==='pass'?'Second check'+by+': passed.'+note
|
|
399
|
+
:c.status==='fail'?'Second check'+by+': failed.'+note
|
|
400
|
+
:c.status==='unclear'?'Second check'+by+' gave no clear answer.'+note
|
|
401
|
+
:c.status==='pending'?'Second check is running.'
|
|
402
|
+
:'Second check not run:'+note;
|
|
403
|
+
return '<div class="vf'+(c.status==='fail'||c.status==='unclear'?' warn':'')+'">'+text+'</div>';
|
|
404
|
+
}
|
|
405
|
+
var last=0, wasStale=null, lastRaw='', drawnMinute=-1, started=Date.now(), connected=false, savedAt=0, down=false;
|
|
406
|
+
function tick(){
|
|
407
|
+
var el=document.getElementById('fresh'), t=document.getElementById('fresh-text');
|
|
408
|
+
// a stream that dropped counts as lost at once; a quiet one only after it missed its signs of life
|
|
409
|
+
var stale=connected?(down||Date.now()-last>15000):Date.now()-started>8000;
|
|
410
|
+
el.className='fresh'+(stale?' stale':'');
|
|
411
|
+
t.textContent=!connected&&!last?(stale?'Cannot reach omnitrix. Trying again. If this stays, run omnitrix dashboard in a terminal.':'Connecting')
|
|
412
|
+
:!connected?(stale?'Cannot reach omnitrix. Trying again. Showing data from '+new Date(savedAt).toLocaleTimeString()+'.':'Connecting. Showing data from '+new Date(savedAt).toLocaleTimeString()+'.')
|
|
413
|
+
:stale?'Connection lost. Trying again. Showing data from '+new Date(last).toLocaleTimeString()+'.':'Live, updated '+ago(last);
|
|
414
|
+
// screen readers hear only a change between live and unreachable, not every second of the clock
|
|
415
|
+
if(stale!==wasStale){document.getElementById('announce').textContent=stale?'omnitrix cannot be reached':(last?'omnitrix is live':'');wasStale=stale}
|
|
416
|
+
}
|
|
417
|
+
function draw(d){
|
|
418
|
+
var focused=document.activeElement&&document.activeElement.closest?document.activeElement.closest('details[data-key]'):null;
|
|
419
|
+
var focusKey=focused?focused.getAttribute('data-key'):null;
|
|
420
|
+
var open={};document.querySelectorAll('details[data-key]').forEach(function(x){if(x.open)open[x.getAttribute('data-key')]=true});
|
|
421
|
+
document.getElementById('ver').textContent='v'+d.version;
|
|
422
|
+
var acc=d.accounts, ready=acc.filter(function(a){return a.state==='ready'||a.state==='busy'}).length;
|
|
423
|
+
var sum=function(k){return acc.reduce(function(s,a){return s+(a.usage[k]||0)},0)};
|
|
424
|
+
var attention=acc.filter(function(a){return a.enabled&&a.state!=='ready'&&a.state!=='busy'}).length;
|
|
425
|
+
document.getElementById('kpis').innerHTML='<div class="kpi"><span>Accounts ready</span><b>'+ready+' of '+acc.length+'</b>'+(attention?'<em>'+attention+' need'+(attention>1?'':'s')+' attention</em>':'')+'</div>'
|
|
426
|
+
+[['Requests, last 24 h',String(sum('requestsToday'))],['Tokens, last 24 h',fmt(sum('tokensToday'))],['Known cost, last 24 h',money(sum('costToday'))]]
|
|
427
|
+
.map(function(k){return '<div class="kpi"><span>'+k[0]+'</span><b>'+esc(k[1])+'</b></div>'}).join('');
|
|
428
|
+
document.getElementById('acc-sub').textContent=acc.length?acc.length+' connected':'';
|
|
429
|
+
document.getElementById('accounts').innerHTML=acc.length?acc.map(function(a){return cardHtml(a,open)}).join('')
|
|
430
|
+
:'<div class="empty"><h3>Connect your first account</h3>omnitrix has no accounts yet. In a terminal:<ol><li><code>omnitrix init --apply</code> connects the AI tools, API keys and local models it finds on this PC</li><li><code>omnitrix providers</code> lists what you can connect</li><li><code>omnitrix add ollama</code> adds models on this PC</li><li><code>omnitrix setup-claude</code> connects omnitrix to Claude Code</li></ol></div>';
|
|
431
|
+
document.getElementById('jobs').innerHTML=d.jobs.length?'<ul class="jobs">'+d.jobs.map(function(j){return jobHtml(j,open)}).join('')+'</ul>'
|
|
432
|
+
:'<div class="empty"><h3>No jobs yet</h3>Ask Claude to hand out a task, and it shows up here.</div>';
|
|
433
|
+
if(focusKey){var again=document.querySelector('details[data-key="'+focusKey+'"] summary');if(again)again.focus({preventScroll:true})}
|
|
434
|
+
tick();
|
|
435
|
+
}
|
|
436
|
+
// Draws a new state, and the same state again once a minute so times such as "5 min ago" stay right.
|
|
437
|
+
function show(raw,live){
|
|
438
|
+
var minute=Math.floor(Date.now()/60000);
|
|
439
|
+
if(live){last=Date.now();connected=true}
|
|
440
|
+
if(raw===lastRaw&&minute===drawnMinute){tick();return}
|
|
441
|
+
var d;try{d=JSON.parse(raw)}catch(e){return}
|
|
442
|
+
lastRaw=raw;drawnMinute=minute;
|
|
443
|
+
if(live){try{localStorage.setItem('omnitrix-state',raw);localStorage.setItem('omnitrix-state-at',String(Date.now()))}catch(e){}}
|
|
444
|
+
draw(d);
|
|
445
|
+
}
|
|
446
|
+
// The last state this browser saw is drawn at once, then the live stream takes over.
|
|
447
|
+
try{var saved=localStorage.getItem('omnitrix-state');savedAt=Number(localStorage.getItem('omnitrix-state-at'))||0;if(saved)show(saved,false)}catch(e){}
|
|
448
|
+
var stream=null;
|
|
449
|
+
function connect(){
|
|
450
|
+
if(!window.EventSource){poll();return}
|
|
451
|
+
stream=new EventSource('/api/events');
|
|
452
|
+
stream.onopen=function(){down=false;tick()};
|
|
453
|
+
stream.onmessage=function(e){down=false;show(e.data,true)};
|
|
454
|
+
stream.addEventListener('alive',function(){down=false;last=Date.now();connected=true;if(lastRaw)show(lastRaw,false);tick()});
|
|
455
|
+
stream.onerror=function(){down=true;tick()};
|
|
456
|
+
}
|
|
457
|
+
async function poll(){
|
|
458
|
+
try{show(await (await fetch('/api/status',{cache:'no-store'})).text(),true)}catch(e){tick()}
|
|
459
|
+
setTimeout(poll,4000);
|
|
460
|
+
}
|
|
461
|
+
// The browser retries a dropped stream by itself; if it gives up, for example while the server restarts, start a new one.
|
|
462
|
+
setInterval(function(){if(stream&&stream.readyState===2)connect()},3000);
|
|
463
|
+
connect();setInterval(tick,1000);
|
|
464
|
+
</script>
|
|
465
|
+
</body>
|
|
466
|
+
</html>`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolveKey } from '../store.js';
|
|
2
|
+
import { DriverError } from '../types.js';
|
|
3
|
+
import { getJson, joinUrl, missingKey, postJson, readRateHeaders } from './http.js';
|
|
4
|
+
function headers(account) {
|
|
5
|
+
const key = resolveKey(account);
|
|
6
|
+
if (!key)
|
|
7
|
+
throw new DriverError(missingKey(account), 'auth');
|
|
8
|
+
return { 'x-api-key': key, 'anthropic-version': '2023-06-01' };
|
|
9
|
+
}
|
|
10
|
+
/** The Anthropic Messages format. Also spoken by DeepSeek, Kimi, GLM and MiniMax at their /anthropic URLs. */
|
|
11
|
+
export async function runAnthropic(req) {
|
|
12
|
+
const { account } = req;
|
|
13
|
+
if (!account.baseUrl)
|
|
14
|
+
throw new DriverError(`account ${account.id} has no base URL`, 'bad_request');
|
|
15
|
+
const body = {
|
|
16
|
+
model: req.model,
|
|
17
|
+
max_tokens: req.maxOutputTokens ?? 8192,
|
|
18
|
+
messages: [{
|
|
19
|
+
role: 'user',
|
|
20
|
+
content: req.images?.length
|
|
21
|
+
? [{ type: 'text', text: req.prompt }, ...req.images.map((i) => ({ type: 'image', source: { type: 'base64', media_type: i.mime, data: i.data } }))]
|
|
22
|
+
: req.prompt,
|
|
23
|
+
}],
|
|
24
|
+
};
|
|
25
|
+
if (req.system)
|
|
26
|
+
body.system = req.system;
|
|
27
|
+
const { json, headers: h } = await postJson(joinUrl(account.baseUrl, 'v1/messages'), headers(account), body, req.timeoutMs, req.signal);
|
|
28
|
+
const blocks = Array.isArray(json?.content) ? json.content : [];
|
|
29
|
+
const text = blocks.filter((b) => b?.type === 'text').map((b) => b.text).join('');
|
|
30
|
+
if (!blocks.length)
|
|
31
|
+
throw new DriverError(`unexpected response: ${JSON.stringify(json).slice(0, 200)}`, 'server');
|
|
32
|
+
const usage = json?.usage ?? {};
|
|
33
|
+
return {
|
|
34
|
+
text,
|
|
35
|
+
inputTokens: Number(usage.input_tokens ?? 0) + Number(usage.cache_read_input_tokens ?? 0) + Number(usage.cache_creation_input_tokens ?? 0),
|
|
36
|
+
outputTokens: Number(usage.output_tokens ?? 0),
|
|
37
|
+
rate: readRateHeaders(h),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export async function listAnthropicModels(account) {
|
|
41
|
+
if (!account.baseUrl)
|
|
42
|
+
return [];
|
|
43
|
+
const json = await getJson(joinUrl(account.baseUrl, 'v1/models'), headers(account));
|
|
44
|
+
const list = Array.isArray(json?.data) ? json.data : [];
|
|
45
|
+
return list.map((m) => String(m.id ?? '')).filter(Boolean);
|
|
46
|
+
}
|