@prplkane/roundtable 0.6.6 → 0.7.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/CHANGELOG.md +604 -565
- package/LICENSE +21 -21
- package/README.md +184 -195
- package/SECURITY.md +324 -318
- package/docs/workflow.md +1475 -1439
- package/package.json +2 -2
- package/scripts/agent.mjs +2 -2
- package/scripts/mcp.mjs +179 -177
- package/skills/roundtable/SKILL.md +62 -59
- package/src/adapters/acp.js +318 -201
- package/src/adapters/agy.js +7 -7
- package/src/adapters/catalogue.js +37 -18
- package/src/adapters/claude.js +6 -6
- package/src/adapters/codex.js +6 -6
- package/src/adapters/common.js +1 -1
- package/src/adapters/config.js +8 -9
- package/src/adapters/models.js +32 -19
- package/src/adapters/spawn.js +3 -1
- package/src/agent-client.js +131 -120
- package/src/cli.js +21 -3
- package/src/diagnostics.js +1 -0
- package/src/engine.js +9 -5
- package/src/export.js +307 -307
- package/src/local-http.js +2 -2
- package/src/local-server.js +110 -110
- package/src/preflight.js +26 -6
- package/src/review-view.js +11 -0
- package/src/seats.js +368 -287
- package/src/server.js +1010 -945
- package/src/ui/app.js +2142 -1977
- package/src/ui/design/app.css +2 -1
- package/src/ui/design/preset-dusk.css +91 -91
- package/src/ui/design/tokens.css +129 -129
- package/src/ui/index.html +276 -272
- package/src/validate.js +10 -3
package/src/local-http.js
CHANGED
|
@@ -3,7 +3,7 @@ export function localClient(port, signal) {
|
|
|
3
3
|
const base = `http://127.0.0.1:${port}`;
|
|
4
4
|
let token = process.env.ROUNDTABLE_TOKEN || '';
|
|
5
5
|
const deadline = (ms) => signal ? AbortSignal.any([signal, AbortSignal.timeout(ms)]) : AbortSignal.timeout(ms);
|
|
6
|
-
async function request(route, body) {
|
|
6
|
+
async function request(route, body, timeoutMs = 15_000) {
|
|
7
7
|
signal?.throwIfAborted();
|
|
8
8
|
if (body !== undefined && !token) {
|
|
9
9
|
const page = await fetch(base, { redirect: 'error', signal: deadline(8000) });
|
|
@@ -11,7 +11,7 @@ export function localClient(port, signal) {
|
|
|
11
11
|
token = /<meta name="roundtable-token" content="([a-f0-9]{32})">/.exec(await page.text())?.[1] || '';
|
|
12
12
|
if (!token) throw new Error('This port did not serve a Roundtable launch token.');
|
|
13
13
|
}
|
|
14
|
-
const response = await fetch(`${base}${route}`, { method: body === undefined ? 'GET' : 'POST', redirect: 'error', signal: deadline(
|
|
14
|
+
const response = await fetch(`${base}${route}`, { method: body === undefined ? 'GET' : 'POST', redirect: 'error', signal: deadline(timeoutMs),
|
|
15
15
|
...(body === undefined ? {} : { headers: { 'content-type': 'application/json', 'x-roundtable-token': token }, body: JSON.stringify(body) }) });
|
|
16
16
|
let result;
|
|
17
17
|
try {
|
package/src/local-server.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
// A cheap, versioned health check; provider catalogues are not server readiness checks.
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { mkdtempSync, openSync, closeSync, readFileSync, rmSync } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import { realpath } from 'node:fs/promises';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import { setTimeout as delay } from 'node:timers/promises';
|
|
9
|
-
import { VERSION } from './version.js';
|
|
10
|
-
import { localClient } from './local-http.js';
|
|
11
|
-
|
|
12
|
-
export const LOCAL_API_VERSION =
|
|
13
|
-
const SERVER = fileURLToPath(new URL('./server.js', import.meta.url));
|
|
14
|
-
const transient = (message) => Object.assign(new Error(message), { transient: true });
|
|
15
|
-
async function canonical(dir) {
|
|
16
|
-
const resolved = await realpath(path.resolve(dir)).catch((e) => { if (e.code === 'ENOENT') return path.resolve(dir); throw e; });
|
|
17
|
-
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function inspectServer(config, { signal, allowOlder = false } = {}) {
|
|
21
|
-
signal?.throwIfAborted();
|
|
22
|
-
let response, body;
|
|
23
|
-
const deadline = AbortSignal.timeout(2000);
|
|
24
|
-
try {
|
|
25
|
-
response = await fetch(`http://127.0.0.1:${config.port}/api/health`, { redirect: 'error', signal: signal ? AbortSignal.any([signal, deadline]) : deadline });
|
|
26
|
-
if ([502, 503, 504].includes(response.status)) { await response.body?.cancel(); throw transient('The local board is still becoming ready.'); }
|
|
27
|
-
try { body = await response.json(); } catch (e) { if (!(e instanceof SyntaxError)) throw e; }
|
|
28
|
-
} catch (e) {
|
|
29
|
-
signal?.throwIfAborted();
|
|
30
|
-
if (e.cause?.code === 'ECONNREFUSED') return null;
|
|
31
|
-
if (e.transient || deadline.aborted || ['ECONNRESET', 'EPIPE', 'ETIMEDOUT', 'UND_ERR_SOCKET', 'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_HEADERS_TIMEOUT'].includes(e.cause?.code)) throw transient('The local board did not answer its health check yet.');
|
|
32
|
-
throw new Error('Could not verify the local board. Check the port; no review was started.', { cause: e });
|
|
33
|
-
}
|
|
34
|
-
if (!response.ok || body?.service !== 'roundtable' || body.apiVersion !== LOCAL_API_VERSION || !/^[a-f0-9]{32}$/.test(body.instanceId || '') || typeof body.dataDir !== 'string' || !path.isAbsolute(body.dataDir)) {
|
|
35
|
-
throw new Error('The selected port has an incompatible or older server. Stop that board from its original terminal or process, then retry. No review was started.');
|
|
36
|
-
}
|
|
37
|
-
if (body.mode !== (config.fake ? 'demo' : 'live')) throw new Error('The selected port is not a Roundtable server in the expected mode. Check --port and --fake.');
|
|
38
|
-
const expectedDir = config.dataDir ?? process.env.ROUNDTABLE_DEBATES_DIR;
|
|
39
|
-
if (expectedDir && await canonical(body.dataDir) !== await canonical(expectedDir)) throw new Error('The selected port uses a different data directory than ROUNDTABLE_DEBATES_DIR. Select its port or stop that board before using this directory. No review was started.');
|
|
40
|
-
if (!allowOlder && body.version !== VERSION) throw new Error(`The running board is version ${body.version}; this installation is ${VERSION}. When reviews are finished, run roundtable server restart --port ${config.port}${config.fake ? ' --fake' : ''}, then retry.`);
|
|
41
|
-
if (body.shuttingDown) throw transient('The local board is shutting down.');
|
|
42
|
-
return body;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Readiness reads may be retried. A review write is never part of this loop.
|
|
46
|
-
export async function ensureServer(config, { signal, timeoutMs = 35000 } = {}) {
|
|
47
|
-
const end = Date.now() + timeoutMs;
|
|
48
|
-
let spawned = false, spawnFailed = false, exited = null, ready = false, last;
|
|
49
|
-
// The board's stderr goes to a file, never a pipe: it outlives this process, and a pipe to a
|
|
50
|
-
// gone host would break its logging. The file sits in a fresh private temp directory (no
|
|
51
|
-
// predictable path for another user to plant), is read only when the board exits early, and
|
|
52
|
-
// goes once the board is ready (at once where an open file can be unlinked, else when the
|
|
53
|
-
// board exits while this process is still around).
|
|
54
|
-
let log = null;
|
|
55
|
-
const discard = () => { try { if (log) rmSync(path.dirname(log), { recursive: true, force: true }); } catch {} };
|
|
56
|
-
while (Date.now() < end) {
|
|
57
|
-
signal?.throwIfAborted();
|
|
58
|
-
try {
|
|
59
|
-
const status = await inspectServer(config, { signal });
|
|
60
|
-
if (status) { if (spawned) { ready = true; discard(); } return status; }
|
|
61
|
-
if (config.start === false) throw new Error('Roundtable is not running; start the local board or remove --no-start.');
|
|
62
|
-
if (!spawned) {
|
|
63
|
-
spawned = true;
|
|
64
|
-
// Survives the host connection, so closing chat cannot cancel a review or its timer.
|
|
65
|
-
let fd = null;
|
|
66
|
-
try { log = path.join(mkdtempSync(path.join(os.tmpdir(), 'roundtable-start-')), 'stderr.log'); fd = openSync(log, 'wx'); } catch {}
|
|
67
|
-
const child = spawn(process.execPath, [SERVER, '--no-open', ...(config.fake ? ['--fake'] : [])], {
|
|
68
|
-
env: { ...process.env, PORT: String(config.port), ...(config.dataDir ? { ROUNDTABLE_DEBATES_DIR: config.dataDir } : {}) },
|
|
69
|
-
detached: true, windowsHide: true, stdio: ['ignore', 'ignore', fd ?? 'ignore'],
|
|
70
|
-
});
|
|
71
|
-
if (fd != null) closeSync(fd);
|
|
72
|
-
child.once('error', () => { spawnFailed = true; });
|
|
73
|
-
child.once('exit', (code, sig) => { exited = { code, sig, at: Date.now() }; if (ready) discard(); });
|
|
74
|
-
child.unref();
|
|
75
|
-
}
|
|
76
|
-
} catch (e) { if (!e.transient) throw e; last = e; }
|
|
77
|
-
// A board that exits early may have lost the port or the data folder to one that another
|
|
78
|
-
// process started at the same moment (two hosts asking at once), so the port is still
|
|
79
|
-
// watched for a few seconds before the exit counts as the answer.
|
|
80
|
-
if (exited && Date.now() - exited.at > 5000) {
|
|
81
|
-
let tail = '';
|
|
82
|
-
// the board's own last word where it had one, else the message line of a crash, else the last line
|
|
83
|
-
try {
|
|
84
|
-
const lines = readFileSync(log, 'utf8').split(/\r?\n/).filter((l) => l.trim());
|
|
85
|
-
tail = (lines.findLast((l) => l.startsWith('[server]')) || lines.find((l) => /^\w*Error: /.test(l)) || lines.at(-1) || '').trim().slice(0, 200);
|
|
86
|
-
} catch {}
|
|
87
|
-
discard();
|
|
88
|
-
const sandboxed = /cannot listen.*\b(EPERM|EACCES)\b/.test(tail);
|
|
89
|
-
throw new Error(`The local board exited before it was ready${tail ? ` (${tail})` : ''}. ${sandboxed ? 'This environment blocks local servers: start the board from a normal terminal with roundtable server start, then retry.' : 'Run roundtable --no-open in a terminal for startup details.'} No review was started.`);
|
|
90
|
-
}
|
|
91
|
-
if (spawnFailed) break;
|
|
92
|
-
await delay(100, undefined, { signal });
|
|
93
|
-
}
|
|
94
|
-
throw new Error(`The local board could not become ready. Check whether another port owns its data folder, or run roundtable --no-open for startup details. No review was started.${last ? ` ${last.message}` : ''}`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function stopServer(config, { signal } = {}) {
|
|
98
|
-
const status = await inspectServer(config, { signal, allowOlder: true });
|
|
99
|
-
if (!status) return { ok: true, stopped: false };
|
|
100
|
-
await localClient(config.port, signal).request('/api/shutdown', { instanceId: status.instanceId });
|
|
101
|
-
for (let n = 0; n < 50; n++) {
|
|
102
|
-
await delay(100, undefined, { signal });
|
|
103
|
-
try {
|
|
104
|
-
const current = await inspectServer(config, { signal, allowOlder: true });
|
|
105
|
-
if (!current) return { ok: true, stopped: true };
|
|
106
|
-
if (current.instanceId !== status.instanceId) throw new Error('Another board took this port during shutdown. Read its status before retrying.');
|
|
107
|
-
} catch (e) { if (!e.transient) throw e; }
|
|
108
|
-
}
|
|
109
|
-
throw new Error('The board has not stopped yet. Read server status before retrying.');
|
|
110
|
-
}
|
|
1
|
+
// A cheap, versioned health check; provider catalogues are not server readiness checks.
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { mkdtempSync, openSync, closeSync, readFileSync, rmSync } from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import { realpath } from 'node:fs/promises';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
9
|
+
import { VERSION } from './version.js';
|
|
10
|
+
import { localClient } from './local-http.js';
|
|
11
|
+
|
|
12
|
+
export const LOCAL_API_VERSION = 2;
|
|
13
|
+
const SERVER = fileURLToPath(new URL('./server.js', import.meta.url));
|
|
14
|
+
const transient = (message) => Object.assign(new Error(message), { transient: true });
|
|
15
|
+
async function canonical(dir) {
|
|
16
|
+
const resolved = await realpath(path.resolve(dir)).catch((e) => { if (e.code === 'ENOENT') return path.resolve(dir); throw e; });
|
|
17
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function inspectServer(config, { signal, allowOlder = false } = {}) {
|
|
21
|
+
signal?.throwIfAborted();
|
|
22
|
+
let response, body;
|
|
23
|
+
const deadline = AbortSignal.timeout(2000);
|
|
24
|
+
try {
|
|
25
|
+
response = await fetch(`http://127.0.0.1:${config.port}/api/health`, { redirect: 'error', signal: signal ? AbortSignal.any([signal, deadline]) : deadline });
|
|
26
|
+
if ([502, 503, 504].includes(response.status)) { await response.body?.cancel(); throw transient('The local board is still becoming ready.'); }
|
|
27
|
+
try { body = await response.json(); } catch (e) { if (!(e instanceof SyntaxError)) throw e; }
|
|
28
|
+
} catch (e) {
|
|
29
|
+
signal?.throwIfAborted();
|
|
30
|
+
if (e.cause?.code === 'ECONNREFUSED') return null;
|
|
31
|
+
if (e.transient || deadline.aborted || ['ECONNRESET', 'EPIPE', 'ETIMEDOUT', 'UND_ERR_SOCKET', 'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_HEADERS_TIMEOUT'].includes(e.cause?.code)) throw transient('The local board did not answer its health check yet.');
|
|
32
|
+
throw new Error('Could not verify the local board. Check the port; no review was started.', { cause: e });
|
|
33
|
+
}
|
|
34
|
+
if (!response.ok || body?.service !== 'roundtable' || body.apiVersion !== LOCAL_API_VERSION || !/^[a-f0-9]{32}$/.test(body.instanceId || '') || typeof body.dataDir !== 'string' || !path.isAbsolute(body.dataDir)) {
|
|
35
|
+
throw new Error('The selected port has an incompatible or older server. Stop that board from its original terminal or process, then retry. No review was started.');
|
|
36
|
+
}
|
|
37
|
+
if (body.mode !== (config.fake ? 'demo' : 'live')) throw new Error('The selected port is not a Roundtable server in the expected mode. Check --port and --fake.');
|
|
38
|
+
const expectedDir = config.dataDir ?? process.env.ROUNDTABLE_DEBATES_DIR;
|
|
39
|
+
if (expectedDir && await canonical(body.dataDir) !== await canonical(expectedDir)) throw new Error('The selected port uses a different data directory than ROUNDTABLE_DEBATES_DIR. Select its port or stop that board before using this directory. No review was started.');
|
|
40
|
+
if (!allowOlder && body.version !== VERSION) throw new Error(`The running board is version ${body.version}; this installation is ${VERSION}. When reviews are finished, run roundtable server restart --port ${config.port}${config.fake ? ' --fake' : ''}, then retry.`);
|
|
41
|
+
if (body.shuttingDown) throw transient('The local board is shutting down.');
|
|
42
|
+
return body;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Readiness reads may be retried. A review write is never part of this loop.
|
|
46
|
+
export async function ensureServer(config, { signal, timeoutMs = 35000 } = {}) {
|
|
47
|
+
const end = Date.now() + timeoutMs;
|
|
48
|
+
let spawned = false, spawnFailed = false, exited = null, ready = false, last;
|
|
49
|
+
// The board's stderr goes to a file, never a pipe: it outlives this process, and a pipe to a
|
|
50
|
+
// gone host would break its logging. The file sits in a fresh private temp directory (no
|
|
51
|
+
// predictable path for another user to plant), is read only when the board exits early, and
|
|
52
|
+
// goes once the board is ready (at once where an open file can be unlinked, else when the
|
|
53
|
+
// board exits while this process is still around).
|
|
54
|
+
let log = null;
|
|
55
|
+
const discard = () => { try { if (log) rmSync(path.dirname(log), { recursive: true, force: true }); } catch {} };
|
|
56
|
+
while (Date.now() < end) {
|
|
57
|
+
signal?.throwIfAborted();
|
|
58
|
+
try {
|
|
59
|
+
const status = await inspectServer(config, { signal });
|
|
60
|
+
if (status) { if (spawned) { ready = true; discard(); } return status; }
|
|
61
|
+
if (config.start === false) throw new Error('Roundtable is not running; start the local board or remove --no-start.');
|
|
62
|
+
if (!spawned) {
|
|
63
|
+
spawned = true;
|
|
64
|
+
// Survives the host connection, so closing chat cannot cancel a review or its timer.
|
|
65
|
+
let fd = null;
|
|
66
|
+
try { log = path.join(mkdtempSync(path.join(os.tmpdir(), 'roundtable-start-')), 'stderr.log'); fd = openSync(log, 'wx'); } catch {}
|
|
67
|
+
const child = spawn(process.execPath, [SERVER, '--no-open', ...(config.fake ? ['--fake'] : [])], {
|
|
68
|
+
env: { ...process.env, PORT: String(config.port), ...(config.dataDir ? { ROUNDTABLE_DEBATES_DIR: config.dataDir } : {}) },
|
|
69
|
+
detached: true, windowsHide: true, stdio: ['ignore', 'ignore', fd ?? 'ignore'],
|
|
70
|
+
});
|
|
71
|
+
if (fd != null) closeSync(fd);
|
|
72
|
+
child.once('error', () => { spawnFailed = true; });
|
|
73
|
+
child.once('exit', (code, sig) => { exited = { code, sig, at: Date.now() }; if (ready) discard(); });
|
|
74
|
+
child.unref();
|
|
75
|
+
}
|
|
76
|
+
} catch (e) { if (!e.transient) throw e; last = e; }
|
|
77
|
+
// A board that exits early may have lost the port or the data folder to one that another
|
|
78
|
+
// process started at the same moment (two hosts asking at once), so the port is still
|
|
79
|
+
// watched for a few seconds before the exit counts as the answer.
|
|
80
|
+
if (exited && Date.now() - exited.at > 5000) {
|
|
81
|
+
let tail = '';
|
|
82
|
+
// the board's own last word where it had one, else the message line of a crash, else the last line
|
|
83
|
+
try {
|
|
84
|
+
const lines = readFileSync(log, 'utf8').split(/\r?\n/).filter((l) => l.trim());
|
|
85
|
+
tail = (lines.findLast((l) => l.startsWith('[server]')) || lines.find((l) => /^\w*Error: /.test(l)) || lines.at(-1) || '').trim().slice(0, 200);
|
|
86
|
+
} catch {}
|
|
87
|
+
discard();
|
|
88
|
+
const sandboxed = /cannot listen.*\b(EPERM|EACCES)\b/.test(tail);
|
|
89
|
+
throw new Error(`The local board exited before it was ready${tail ? ` (${tail})` : ''}. ${sandboxed ? 'This environment blocks local servers: start the board from a normal terminal with roundtable server start, then retry.' : 'Run roundtable --no-open in a terminal for startup details.'} No review was started.`);
|
|
90
|
+
}
|
|
91
|
+
if (spawnFailed) break;
|
|
92
|
+
await delay(100, undefined, { signal });
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`The local board could not become ready. Check whether another port owns its data folder, or run roundtable --no-open for startup details. No review was started.${last ? ` ${last.message}` : ''}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function stopServer(config, { signal } = {}) {
|
|
98
|
+
const status = await inspectServer(config, { signal, allowOlder: true });
|
|
99
|
+
if (!status) return { ok: true, stopped: false };
|
|
100
|
+
await localClient(config.port, signal).request('/api/shutdown', { instanceId: status.instanceId });
|
|
101
|
+
for (let n = 0; n < 50; n++) {
|
|
102
|
+
await delay(100, undefined, { signal });
|
|
103
|
+
try {
|
|
104
|
+
const current = await inspectServer(config, { signal, allowOlder: true });
|
|
105
|
+
if (!current) return { ok: true, stopped: true };
|
|
106
|
+
if (current.instanceId !== status.instanceId) throw new Error('Another board took this port during shutdown. Read its status before retrying.');
|
|
107
|
+
} catch (e) { if (!e.transient) throw e; }
|
|
108
|
+
}
|
|
109
|
+
throw new Error('The board has not stopped yet. Read server status before retrying.');
|
|
110
|
+
}
|
package/src/preflight.js
CHANGED
|
@@ -62,16 +62,32 @@ export function createPreflightCache({ check, now = Date.now, ttlMs = PREFLIGHT_
|
|
|
62
62
|
// The CLI's own login-status command, and how to read its answer. Antigravity has none; its
|
|
63
63
|
// model list (read at boot, and only answered for a logged-in user) stands in for it.
|
|
64
64
|
// plan(out): the subscription the status names, where it names one (claude: subscriptionType).
|
|
65
|
+
function textLoginStatus(out) {
|
|
66
|
+
const yes = /^logged in(?: using [^\r\n]+)?[.!]?$/im.test(out.trim());
|
|
67
|
+
const no = /^(?:not logged in|logged out|signed out)[.!]?$/im.test(out.trim());
|
|
68
|
+
return yes === no ? null : yes;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function claudeStatus(out) {
|
|
72
|
+
try { return JSON.parse(out.slice(out.indexOf('{'), out.lastIndexOf('}') + 1)); } catch { return null; }
|
|
73
|
+
}
|
|
74
|
+
|
|
65
75
|
export const STATUS = {
|
|
66
76
|
claude: {
|
|
67
77
|
args: ['auth', 'status'],
|
|
68
|
-
read: (out
|
|
69
|
-
|
|
78
|
+
read: (out, err = '') => {
|
|
79
|
+
if (out.includes('{')) {
|
|
80
|
+
const value = claudeStatus(out)?.loggedIn;
|
|
81
|
+
return typeof value === 'boolean' ? value : null;
|
|
82
|
+
}
|
|
83
|
+
return textLoginStatus(out + '\n' + err);
|
|
84
|
+
},
|
|
85
|
+
plan: (out) => claudeStatus(out)?.subscriptionType || null,
|
|
70
86
|
},
|
|
71
|
-
codex: { args: ['login', 'status'], read: (out) =>
|
|
87
|
+
codex: { args: ['login', 'status'], read: (out, err = '') => textLoginStatus(out + '\n' + err) },
|
|
72
88
|
};
|
|
73
89
|
|
|
74
|
-
const LOGIN = { claude: 'claude
|
|
90
|
+
const LOGIN = { claude: 'Run claude auth login in a terminal', codex: 'Run codex login in a terminal', agy: 'Open agy in a terminal and sign in' };
|
|
75
91
|
|
|
76
92
|
function untilText(ms, now) {
|
|
77
93
|
const s = Math.max(0, Math.round((ms - now) / 1000));
|
|
@@ -84,7 +100,10 @@ function untilText(ms, now) {
|
|
|
84
100
|
// limits differ by model (agy): only its group's windows count. Without one, every window does.
|
|
85
101
|
export function lamp({ vendor, installed, loggedIn, quota, account = null, model = null }, now = Date.now()) {
|
|
86
102
|
if (!installed) return { state: 'danger', kind: 'missing', note: `${vendor} CLI not found on this machine` };
|
|
87
|
-
if (loggedIn === false)
|
|
103
|
+
if (loggedIn === false) {
|
|
104
|
+
const action = account ? `Follow the profile sign-in instructions from roundtable doctor --vendor ${vendor} --profile ${account}` : LOGIN[vendor] || 'Sign in';
|
|
105
|
+
return { state: 'danger', kind: 'auth', note: `Signed out at the last check. ${action}, then select Refresh status.` };
|
|
106
|
+
}
|
|
88
107
|
const windows = quotaWindows(quota, model ? [model] : []);
|
|
89
108
|
if (windows.length) {
|
|
90
109
|
const worst = windows.reduce((a, w) => (w.used > a.used ? w : a));
|
|
@@ -92,9 +111,10 @@ export function lamp({ vendor, installed, loggedIn, quota, account = null, model
|
|
|
92
111
|
const reset = worst.resetsAt ? `, resets ${untilText(worst.resetsAt * 1000, now)}` : '';
|
|
93
112
|
if (worst.used >= 1) return { state: 'danger', kind: 'quota', note: `quota used up (${worst.label}${reset})`, resetsAt: worst.resetsAt ? worst.resetsAt * 1000 : null };
|
|
94
113
|
if (worst.used >= 0.9) return { state: 'warn', kind: 'quota-low', note: `quota nearly used: ${text}${reset}` };
|
|
114
|
+
if (loggedIn == null) return { state: 'warn', kind: 'unknown', note: `Sign-in unconfirmed · last reported usage: ${text}` };
|
|
95
115
|
return { state: 'ok', kind: null, note: `ready · ${text}` };
|
|
96
116
|
}
|
|
97
|
-
if (loggedIn
|
|
117
|
+
if (loggedIn == null) return { state: 'warn', kind: 'unknown', note: 'Sign-in could not be confirmed. Select Refresh status to check again.' };
|
|
98
118
|
return { state: 'ok', kind: null, note: 'logged in · quota unavailable' };
|
|
99
119
|
}
|
|
100
120
|
|
package/src/review-view.js
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
import { verdictSections, recommendationPick, optionLabel } from './contract.js';
|
|
3
3
|
export const escapeHtml = (value) => String(value ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
4
4
|
|
|
5
|
+
export function providerWarning(roles) {
|
|
6
|
+
const issues = new Map();
|
|
7
|
+
for (const { provider, account, role, lamp } of roles) {
|
|
8
|
+
if (lamp.cls !== 'danger') continue;
|
|
9
|
+
const message = `${provider}${account ? ` (${account})` : ''} — ${lamp.note}`;
|
|
10
|
+
if (!issues.has(message)) issues.set(message, []);
|
|
11
|
+
issues.get(message).push(role);
|
|
12
|
+
}
|
|
13
|
+
return [...issues].map(([message, affected]) => `${message}\nAffected roles · ${affected.join(', ')}`).join('\n\n');
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
export function groupQuestions(questions = []) {
|
|
6
17
|
const groups = new Map();
|
|
7
18
|
for (const q of questions) {
|