@prplkane/roundtable 0.6.4 → 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 -529
- package/README.md +184 -189
- package/SECURITY.md +324 -299
- package/docs/workflow.md +1475 -1344
- package/package.json +2 -2
- package/scripts/agent.mjs +2 -2
- package/scripts/mcp.mjs +179 -175
- package/skills/roundtable/SKILL.md +62 -57
- package/src/adapters/acp.js +318 -0
- package/src/adapters/catalogue.js +37 -18
- package/src/adapters/common.js +1 -1
- package/src/adapters/config.js +18 -9
- package/src/adapters/index.js +2 -1
- package/src/adapters/models.js +32 -19
- package/src/adapters/spawn.js +3 -1
- package/src/agent-client.js +131 -108
- package/src/cli.js +21 -3
- package/src/diagnostics.js +1 -0
- package/src/doctor.js +7 -0
- package/src/engine.js +11 -7
- package/src/local-http.js +2 -2
- package/src/local-server.js +110 -110
- package/src/notes.js +8 -4
- package/src/preflight.js +26 -6
- package/src/prompts.js +1 -1
- package/src/review-view.js +15 -2
- package/src/seats.js +368 -272
- package/src/server.js +1010 -928
- package/src/snapshot.js +10 -3
- package/src/ui/app.js +2142 -1967
- package/src/ui/design/app.css +2 -1
- package/src/ui/index.html +276 -272
- package/src/validate.js +14 -4
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/notes.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Note sources are declared by the client, not authenticated identities. Keep legacy human
|
|
2
|
-
// strings readable while retaining attribution on notes submitted by the agent client
|
|
2
|
+
// strings readable while retaining attribution on notes submitted by the agent client:
|
|
3
|
+
// 'agent' is the assistant's own note, 'relayed' the user's answers as the assistant reported them.
|
|
4
|
+
export const SOURCES = ['human', 'agent', 'relayed'];
|
|
3
5
|
export function noteRecord(note) {
|
|
4
6
|
return {
|
|
5
7
|
text: typeof note === 'string' ? note : String(note?.text || ''),
|
|
6
|
-
source: note?.source
|
|
8
|
+
source: SOURCES.includes(note?.source) ? note.source : 'human',
|
|
7
9
|
};
|
|
8
10
|
}
|
|
9
11
|
|
|
@@ -12,5 +14,7 @@ export function storedNote(note) {
|
|
|
12
14
|
return record.source === 'human' ? record.text : record;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
const AUTHORS = { human: 'Human', agent: 'Agent coordinator', relayed: 'Human (relayed by the assistant)' };
|
|
18
|
+
const LABELS = { human: 'You said', agent: 'Agent note', relayed: 'You said, via your assistant' };
|
|
19
|
+
export const noteAuthor = (note) => AUTHORS[noteRecord(note).source];
|
|
20
|
+
export const noteLabel = (note) => LABELS[noteRecord(note).source];
|
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/prompts.js
CHANGED
|
@@ -102,7 +102,7 @@ export function statelessPrefix({ fieldNotes, lens, mood, seatCount, unattended
|
|
|
102
102
|
export function notesBlock(notes) {
|
|
103
103
|
const list = (notes || []).filter((n) => n?.text && n.text.trim());
|
|
104
104
|
if (!list.length) return [];
|
|
105
|
-
return ['### Discussion notes (agent
|
|
105
|
+
return ['### Discussion notes (a relayed note is the human\'s answer as their assistant reported it; an agent note is the assistant\'s own and not a human answer)', ...list.map((n, i) => inputRecord('note', n.text, {
|
|
106
106
|
author: noteAuthor(n), source: noteRecord(n).source, round: n.round,
|
|
107
107
|
after: n.round < 0 ? 'Before round 0' : `After round ${n.round}`, latest: i === list.length - 1,
|
|
108
108
|
})), ''];
|
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) {
|
|
@@ -15,13 +26,15 @@ export function groupQuestions(questions = []) {
|
|
|
15
26
|
return [...groups.values()];
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
// attributed: each answer line says whether the assistant relayed the user's words or wrote its own.
|
|
30
|
+
const ANSWER_LABEL = { user: "Answer (the user's words, relayed by the assistant)", assistant: "Answer (the assistant's own, not the user's)" };
|
|
31
|
+
export function answerMessage(questions, answers = [], note = '', { attributed = false } = {}) {
|
|
19
32
|
const groups = groupQuestions(questions), seen = new Set(), lines = [];
|
|
20
33
|
for (const answer of answers) {
|
|
21
34
|
const group = groups.find((q) => q.id === answer.id);
|
|
22
35
|
if (!group || seen.has(answer.id)) throw Object.assign(new Error('The question list changed. Review the current questions before sending your answers.'), { status: 409 });
|
|
23
36
|
seen.add(answer.id);
|
|
24
|
-
if (answer.text.trim()) lines.push(`Question (${group.sources.join(', ')}): ${group.question}\
|
|
37
|
+
if (answer.text.trim()) lines.push(`Question (${group.sources.join(', ')}): ${group.question}\n${attributed ? ANSWER_LABEL[answer.from] || ANSWER_LABEL.assistant : 'Answer'}: ${answer.text.trim()}`);
|
|
25
38
|
}
|
|
26
39
|
if (note.trim()) lines.push(note.trim());
|
|
27
40
|
return lines.join('\n\n');
|