@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
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// claude no list command headless; the aliases in config.js are the hints
|
|
4
|
-
// codex the model table in models.js and the levels in config.js. Not ~/.codex/config.toml: the
|
|
5
|
-
// seat runs with --ignore-user-config, so that file cannot describe its defaults
|
|
6
|
-
// agy `agy models` prints "<id>\t<label>" lines (slow: a network call), cached after one read
|
|
1
|
+
// Direct CLI choices for the setup screen. ACP profiles advertise their own session options.
|
|
7
2
|
import { ADAPTERS } from './config.js';
|
|
8
|
-
import { resolveBinary, runProcess } from './spawn.js';
|
|
3
|
+
import { resolveBinary, runProcess, cleanEnv } from './spawn.js';
|
|
9
4
|
import { MODELS, agyFamilies } from './models.js';
|
|
10
5
|
|
|
11
6
|
// "gemini-4-argon-high\tGemini 4 Argon (High)" lines; anything else (the "Fetching..." line) is skipped.
|
|
@@ -15,22 +10,36 @@ export function parseAgyModels(text) {
|
|
|
15
10
|
.map(([id, label]) => ({ id: id.trim(), label: label.trim() }));
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
let agyCache = null;
|
|
19
13
|
export async function readAgyModels({ timeoutMs = 30_000 } = {}) {
|
|
20
|
-
if (agyCache) return agyCache;
|
|
21
14
|
try {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const res = await runProcess(resolveBinary('agy'), ['models'], { timeoutMs });
|
|
16
|
+
return res.code === 0 ? parseAgyModels(res.stdout) : [];
|
|
17
|
+
} catch { return []; }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function parseCodexModels(text) {
|
|
21
|
+
const rows = JSON.parse(text).models;
|
|
22
|
+
if (!Array.isArray(rows)) return [];
|
|
23
|
+
return rows.filter((m) => m?.visibility === 'list' && typeof m.slug === 'string' && m.slug.length > 0)
|
|
24
|
+
.map((m) => {
|
|
25
|
+
const hint = MODELS.codex.find((h) => h.id === m.slug);
|
|
26
|
+
const efforts = Array.isArray(m.supported_reasoning_levels) ? m.supported_reasoning_levels.map((l) => l?.effort).filter((l) => typeof l === 'string') : null;
|
|
27
|
+
return { id: m.slug, label: hint?.label || m.display_name || m.slug, ...(hint?.note ? { note: hint.note } : {}), ...(efforts ? { efforts } : {}) };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function readCodexModels() {
|
|
32
|
+
try {
|
|
33
|
+
const bin = resolveBinary('codex', ADAPTERS.codex.npmBin);
|
|
34
|
+
const res = await runProcess(bin, ['debug', 'models'], { timeoutMs: 10_000, env: cleanEnv() });
|
|
35
|
+
return res.code === 0 ? parseCodexModels(res.stdout) : [];
|
|
27
36
|
} catch { return []; }
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
// One object for the setup screen, per vendor: models, efforts, defaults, and the pool the
|
|
31
40
|
// vendor's quota is drawn against. `agyModels` is injectable so tests never spawn the CLI.
|
|
32
|
-
export async function vendorCatalogue({ agyModels = readAgyModels } = {}) {
|
|
33
|
-
const agy = await agyModels();
|
|
41
|
+
export async function vendorCatalogue({ agyModels = readAgyModels, codexModels = readCodexModels } = {}) {
|
|
42
|
+
const [agy, codex] = await Promise.all([agyModels(), codexModels()]);
|
|
34
43
|
const out = {};
|
|
35
44
|
for (const [vendor, a] of Object.entries(ADAPTERS)) {
|
|
36
45
|
const entry = {
|
|
@@ -41,8 +50,18 @@ export async function vendorCatalogue({ agyModels = readAgyModels } = {}) {
|
|
|
41
50
|
if (MODELS[vendor]) entry.models = MODELS[vendor].slice();
|
|
42
51
|
if (vendor === 'claude') entry.defaultLabel = 'Opus 5.5';
|
|
43
52
|
// The installed CLI chooses its default; a static model table cannot establish it.
|
|
44
|
-
if (vendor === 'codex')
|
|
45
|
-
|
|
53
|
+
if (vendor === 'codex') {
|
|
54
|
+
entry.defaultLabel = 'CLI default';
|
|
55
|
+
if (codex.length) {
|
|
56
|
+
entry.models = codex;
|
|
57
|
+
entry.efforts = [...new Set([...entry.efforts, ...codex.flatMap((m) => m.efforts || [])])];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (vendor === 'agy' && agy.length) {
|
|
61
|
+
entry.models = agy;
|
|
62
|
+
entry.families = agyFamilies(agy);
|
|
63
|
+
entry.efforts = [...new Set([...entry.efforts, ...entry.families.flatMap((f) => f.levels)])];
|
|
64
|
+
}
|
|
46
65
|
out[vendor] = entry;
|
|
47
66
|
}
|
|
48
67
|
return out;
|
package/src/adapters/claude.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Claude Code: `claude -p --output-format stream-json --verbose`, prompt on stdin, `--resume <id>`.
|
|
2
|
-
// Quirks: total_cost_usd is cumulative for the session on resume; common.js takes the delta.
|
|
3
|
-
// stream-json is used only so the rate_limit_event line (remaining quota) comes with each reply.
|
|
4
|
-
import { makeAdapter } from './common.js';
|
|
5
|
-
import { claudeQuota } from './quota.js';
|
|
6
|
-
export const run = makeAdapter('claude', { normaliseQuota: claudeQuota });
|
|
1
|
+
// Claude Code: `claude -p --output-format stream-json --verbose`, prompt on stdin, `--resume <id>`.
|
|
2
|
+
// Quirks: total_cost_usd is cumulative for the session on resume; common.js takes the delta.
|
|
3
|
+
// stream-json is used only so the rate_limit_event line (remaining quota) comes with each reply.
|
|
4
|
+
import { makeAdapter } from './common.js';
|
|
5
|
+
import { claudeQuota } from './quota.js';
|
|
6
|
+
export const run = makeAdapter('claude', { normaliseQuota: claudeQuota });
|
package/src/adapters/codex.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Codex: `codex exec --json`, prompt on stdin (`-`), `exec resume <id>`.
|
|
2
|
-
// Quirks: usage comes in the turn.completed event, no cost; `resume` rejects --sandbox so the
|
|
3
|
-
// policy is passed with -c sandbox_mode; the PATH entry is an npm .cmd shim, so spawn.js runs
|
|
4
|
-
// bin/codex.js through node instead.
|
|
5
|
-
import { makeAdapter } from './common.js';
|
|
6
|
-
export const run = makeAdapter('codex');
|
|
1
|
+
// Codex: `codex exec --json`, prompt on stdin (`-`), `exec resume <id>`.
|
|
2
|
+
// Quirks: usage comes in the turn.completed event, no cost; `resume` rejects --sandbox so the
|
|
3
|
+
// policy is passed with -c sandbox_mode; the PATH entry is an npm .cmd shim, so spawn.js runs
|
|
4
|
+
// bin/codex.js through node instead.
|
|
5
|
+
import { makeAdapter } from './common.js';
|
|
6
|
+
export const run = makeAdapter('codex');
|
package/src/adapters/common.js
CHANGED
|
@@ -102,7 +102,7 @@ export function buildArgs(cfg, { prompt, sessionId = null, model = null, effort
|
|
|
102
102
|
if (model && cfg.model) extra.push(...cfg.model(model));
|
|
103
103
|
if (instructionsFile) extra.push('-c', `model_instructions_file=${JSON.stringify(instructionsFile)}`);
|
|
104
104
|
// Skip the effort flag when the model id already names the level (agy), so nothing is said twice.
|
|
105
|
-
if (effort && cfg.effort && !(model && cfg.effortInModel && cfg.effortInModel.test(model))) extra.push(...cfg.effort(effort));
|
|
105
|
+
if (effort && cfg.effort && !(model && cfg.effortInModel && (cfg.effortInModel.test(model) || model.endsWith(`-${effort}`)))) extra.push(...cfg.effort(effort));
|
|
106
106
|
if (extra.length) {
|
|
107
107
|
const at = args[args.length - 1] === '-' ? args.length - 1 : args.length;
|
|
108
108
|
args.splice(at, 0, ...extra);
|
package/src/adapters/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { effortSuffix } from './models.js';
|
|
1
2
|
// One row per vendor. Everything the adapters need to know about a vendor lives here.
|
|
2
3
|
//
|
|
3
4
|
// kind 'cli': the vendor's own CLI on the user's subscription (the normal seat);
|
|
@@ -187,9 +188,9 @@ export const ADAPTERS = {
|
|
|
187
188
|
model: (m) => ['--model', m],
|
|
188
189
|
effort: (e) => ['--effort', e],
|
|
189
190
|
effortLevels: ['low', 'medium', 'high'], // `claude --help`: "--effort <level>"
|
|
190
|
-
// Request no extended-thinking budget for hidden-mood seats, which select Haiku
|
|
191
|
+
// Request no extended-thinking budget for hidden-mood seats, which select Haiku.
|
|
191
192
|
minimalEnv: { MAX_THINKING_TOKENS: '0' },
|
|
192
|
-
modelHints: [
|
|
193
|
+
modelHints: [], // direct CLI fallback in models.js
|
|
193
194
|
pool: 'Anthropic subscription',
|
|
194
195
|
promptVia: 'stdin',
|
|
195
196
|
output: 'jsonl',
|
|
@@ -275,7 +276,7 @@ export const ADAPTERS = {
|
|
|
275
276
|
// CLI effort vocabulary; availability depends on the selected model and installed CLI.
|
|
276
277
|
// ~/.codex/config.toml is not a source: --ignore-user-config keeps it from the seat.
|
|
277
278
|
effortLevels: ['low', 'medium', 'high', 'xhigh', 'max', 'ultra'],
|
|
278
|
-
modelHints: [], //
|
|
279
|
+
modelHints: [], // catalogue.js reads the CLI listing and falls back to models.js
|
|
279
280
|
pool: 'ChatGPT subscription',
|
|
280
281
|
promptVia: 'stdin',
|
|
281
282
|
output: 'jsonl',
|
|
@@ -350,11 +351,9 @@ export const ADAPTERS = {
|
|
|
350
351
|
resume: (id, base) => [...base, '--conversation', id],
|
|
351
352
|
model: (m) => ['--model', m],
|
|
352
353
|
effort: (e) => ['--effort', e],
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
effortLevels: ['low', 'medium', 'high'],
|
|
357
|
-
effortInModel: /-(low|medium|high)$/, // `agy models` ids end in the level: gemini-4-argon-high
|
|
354
|
+
// Listed variants carry their own level. Discovery adds any new advertised levels.
|
|
355
|
+
effortLevels: ['low', 'medium', 'high', 'xhigh', 'max'],
|
|
356
|
+
effortInModel: effortSuffix,
|
|
358
357
|
modelHints: [], // filled from `agy models` (catalogue.js)
|
|
359
358
|
// `/usage`: limits per model group (Gemini; Claude and GPT; Gemini 4 Argon on some plans),
|
|
360
359
|
// each with a weekly and usually a 5-hour window; AI credits, when enabled, take over after.
|
|
@@ -424,7 +423,7 @@ export const ADAPTERS = {
|
|
|
424
423
|
},
|
|
425
424
|
acp: {
|
|
426
425
|
kind: 'acp', label: 'AgentLink (ACP)', binary: 'agentlink',
|
|
427
|
-
npmBin: ['@
|
|
426
|
+
npmBin: ['@prplkane/agentlink', 'src/cli.mjs'],
|
|
428
427
|
args: [], resume: null, model: null, effort: null, home: null,
|
|
429
428
|
effortLevels: [], modelHints: [], paths: { cost: null, quota: null },
|
|
430
429
|
quota: null, usageUrl: null, colour: 'dusk', limitedIsolation: true,
|
package/src/adapters/models.js
CHANGED
|
@@ -9,16 +9,15 @@
|
|
|
9
9
|
|
|
10
10
|
export const MODELS = {
|
|
11
11
|
claude: [
|
|
12
|
-
{ id: 'fable', label: 'Fable 5.
|
|
12
|
+
{ id: 'claude-fable-5-2', label: 'Fable 5.2' },
|
|
13
13
|
{ id: 'opus', label: 'Opus 5.5', note: 'default' },
|
|
14
14
|
{ id: 'sonnet', label: 'Sonnet 5.5' },
|
|
15
15
|
// Pin the intended Haiku version instead of relying on the CLI alias.
|
|
16
|
-
{ id: 'claude-haiku-
|
|
16
|
+
{ id: 'claude-haiku-5-5', label: 'Haiku 5.5', note: 'lightest' },
|
|
17
17
|
],
|
|
18
18
|
codex: [
|
|
19
|
-
{ id: 'gpt-6-astra', label: 'GPT-6 Astra' },
|
|
20
|
-
{ id: 'gpt-6.
|
|
21
|
-
{ id: 'gpt-6-sol', label: 'GPT-6 Sol' },
|
|
19
|
+
{ id: 'gpt-6.2-astra', label: 'GPT-6.2 Astra' },
|
|
20
|
+
{ id: 'gpt-6.2-sol', label: 'GPT-6.2 Sol' },
|
|
22
21
|
{ id: 'gpt-6.1-terra', label: 'GPT-6.1 Terra' },
|
|
23
22
|
// efforts: only where a model takes fewer levels than its vendor offers (`codex debug models`
|
|
24
23
|
// supported_reasoning_levels: the Luna models stop at max)
|
|
@@ -41,16 +40,16 @@ export function modelsByCapability(models = []) {
|
|
|
41
40
|
|
|
42
41
|
// The effort levels a model takes: its vendor's levels, narrowed where the table names fewer.
|
|
43
42
|
// A model the table does not know (a typed id, the CLI default) keeps the vendor's levels.
|
|
44
|
-
export function modelEfforts(vendor, model, levels = []) {
|
|
45
|
-
const known =
|
|
46
|
-
return known?.efforts
|
|
43
|
+
export function modelEfforts(vendor, model, levels = [], models = MODELS[vendor] || []) {
|
|
44
|
+
const known = models.find((m) => m.id === String(model || '').trim());
|
|
45
|
+
return known?.efforts || levels;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
// Retired for ChatGPT sign-in: a call with one of these fails. id -> [date, replacement].
|
|
50
49
|
export const RETIRED = {
|
|
51
50
|
codex: {
|
|
52
|
-
'gpt-5.5': ['2026-10-14', 'gpt-6.
|
|
53
|
-
'gpt-5.3-codex-spark': ['2026-09-14', 'gpt-6.
|
|
51
|
+
'gpt-5.5': ['2026-10-14', 'gpt-6.2-sol'], 'gpt-5.4': ['2026-08-31', 'gpt-6.2-sol'], 'gpt-5.4-mini': ['2026-08-31', 'gpt-6-luna'],
|
|
52
|
+
'gpt-5.3-codex-spark': ['2026-09-14', 'gpt-6.2-sol'], 'gpt-5.3-codex': ['deprecated', 'gpt-6.2-sol'], 'gpt-5.2': ['deprecated', 'gpt-6.2-sol'],
|
|
54
53
|
},
|
|
55
54
|
};
|
|
56
55
|
|
|
@@ -60,17 +59,31 @@ export function retired(vendor, id) {
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
// agy ids carry the effort level ("gemini-4-argon-high"): one entry per model, the levels it has.
|
|
62
|
+
const levelOrder = ['low', 'medium', 'high', 'xhigh', 'max', 'ultra'];
|
|
63
|
+
export const effortSuffix = /-(low|medium|high|xhigh|max|ultra)$/;
|
|
63
64
|
export function agyFamilies(models = []) {
|
|
64
|
-
const
|
|
65
|
-
for (const
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const families = new Map();
|
|
66
|
+
for (const { id, label = id } of models) {
|
|
67
|
+
// A future level can identify itself in the vendor label, e.g. "Neon (Deep)" / neon-deep.
|
|
68
|
+
const named = /\s*\(([a-z0-9_-]+)\)\s*$/i.exec(label);
|
|
69
|
+
const suffix = named?.[1].toLowerCase();
|
|
70
|
+
const level = suffix && id.endsWith(`-${suffix}`) ? suffix : effortSuffix.exec(id)?.[1];
|
|
71
|
+
const base = level ? id.slice(0, -level.length - 1) : id;
|
|
72
|
+
if (!families.has(base)) families.set(base, { id: base, label: level && named ? label.slice(0, named.index) : label, levels: [] });
|
|
73
|
+
const levels = families.get(base).levels;
|
|
74
|
+
if (level && !levels.includes(level)) levels.push(level);
|
|
71
75
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
76
|
+
const rank = (level) => levelOrder.includes(level) ? levelOrder.indexOf(level) : levelOrder.length;
|
|
77
|
+
for (const family of families.values()) family.levels.sort((a, b) => rank(a) - rank(b));
|
|
78
|
+
return [...families.values()];
|
|
79
|
+
}
|
|
80
|
+
export function agyFamily(families, model) {
|
|
81
|
+
return families.find((f) => f.id === model) || families.find((f) => f.levels.some((level) => model === `${f.id}-${level}`));
|
|
82
|
+
}
|
|
83
|
+
export function agySelection(family, picked, effort) {
|
|
84
|
+
const levels = family?.levels || [];
|
|
85
|
+
const level = levels.includes(effort) ? effort : levels.includes('medium') ? 'medium' : levels[0];
|
|
86
|
+
return { model: level ? `${family.id}-${level}` : picked, effort: level || '' };
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
// agy's quota comes in groups, each with its own windows (quota.js agyQuota). Which group a model
|
package/src/adapters/spawn.js
CHANGED
|
@@ -11,7 +11,9 @@ const WIN = process.platform === 'win32';
|
|
|
11
11
|
// without one, and a shell would mangle quoted prompt text).
|
|
12
12
|
export function resolveBinary(name, npmBin, { platform = process.platform, env = process.env, exists = existsSync } = {}) {
|
|
13
13
|
const P = platform === 'win32' ? path.win32 : path.posix;
|
|
14
|
-
|
|
14
|
+
// Match Node's Windows environment handling, including duplicate-key ordering.
|
|
15
|
+
const pathKey = platform === 'win32' ? Object.keys(env).sort().find(key => key.toUpperCase() === 'PATH') || 'PATH' : 'PATH';
|
|
16
|
+
const dirs = (env[pathKey] || '').split(P.delimiter).filter(Boolean);
|
|
15
17
|
const exts = platform === 'win32' ? ['.exe'] : [''];
|
|
16
18
|
for (const dir of dirs) {
|
|
17
19
|
for (const ext of exts) {
|
package/src/agent-client.js
CHANGED
|
@@ -1,120 +1,131 @@
|
|
|
1
|
-
import { LIMITS } from './validate.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
import { LIMITS } from './validate.js';
|
|
2
|
+
import { PROFILE_PROVIDERS, providerProfile } from './seats.js';
|
|
3
|
+
import { localClient } from './local-http.js';
|
|
4
|
+
|
|
5
|
+
export const HELP = {
|
|
6
|
+
usage: 'roundtable agent <status|models|check|start|wait|answer|hold|finish|stop|resume|verdict> [--port 4747] [--id review-id] [--input file|-] [--seconds 25] [--after-round round] [--refresh]',
|
|
7
|
+
commands: {
|
|
8
|
+
status: 'Without --id: cached provider setup. With --id: current step, questions, latest positions and verdict. --refresh checks saved AgentLink profile availability without opening sessions.',
|
|
9
|
+
models: 'Read advertised model and effort names, IDs and saved profile defaults without sending a prompt. Supply --input with account, allowLimitedIsolation: true and an optional model.',
|
|
10
|
+
check: 'Validate --input and estimate calls/tokens without creating a review.',
|
|
11
|
+
start: 'Start the review in --input. Uses the selected providers. Returns its id immediately.',
|
|
12
|
+
wait: 'Wait up to --seconds (1–30) for a question or completion. After presenting questions, use --after-round N to wait for the next step without asking the same questions again. Returns one state object, not an event log.',
|
|
13
|
+
answer: 'Send --input {round, answers:[{id:"q1",text:"..."}], message:"optional note"}, labelled as an agent note. Read the current state first; never invent a missing answer.',
|
|
14
|
+
hold: 'Send --input {round} to give the user another answer window. This is a bounded extension, not an indefinite pause. It makes no model call.',
|
|
15
|
+
stop: 'Cancel all in-flight calls, including the chairman; keep completed replies. A verdict runs later only if explicitly requested.',
|
|
16
|
+
finish: 'End discussion and write the verdict from collected replies. Available after one complete round has a usable reply; may make a chairman call.',
|
|
17
|
+
resume: 'Resume an interrupted review. May make provider calls.',
|
|
18
|
+
verdict: 'Request a missing or failed verdict from saved replies. May make a provider call.',
|
|
19
|
+
},
|
|
20
|
+
acp: 'Codex, Claude and Antigravity seats and chairmen default to AgentLink. Bare vendor codex, claude or agy selects its saved profile. For an exact profile, select vendor="acp" and account="profile-name" for each seat and the chairman. Requires stateless memory and allowLimitedIsolation=true after the person accepts profile-owned permissions, customization and billing. Roundtable denies client tools and stops reported tool activity. AgentLink must already be installed/configured. Set transport=cli explicitly for direct CLI seats. Missing token usage stays unknown and stops further calls for that seat under its cap; no live quota is inferred.',
|
|
21
|
+
setup: 'Use roundtable server status to inspect the local board; roundtable server start launches it hidden if needed (add --fake for a free test). After an update, server restart refuses active reviews. This client reads its launch token locally; it never prints or stores the token.',
|
|
22
|
+
input: 'check/start accept the same {fieldNotes,seats,chairman,options} JSON as the board. Check available providers first. Every result with an id carries board, a link where a person can watch the review in a browser; offer it, do not open it.',
|
|
23
|
+
recipe: {
|
|
24
|
+
questions: 'When nextAction.type is ask_user, present gate.questions with an available user-input tool; if unavailable, ask in normal chat. Tell the user when the answer window closes (gate.secondsUntilAutoContinue, or gate.autoContinueAtIso; autoContinueAt is epoch milliseconds) and that unknowns stay unknown. Send the user\'s own reply as answers with from "user"; anything you add yourself goes in message, or in an answer with from "assistant". Do not just print JSON or answer for the user. In an async host, use nextAction.waitCommand while the question is pending; await_user means it has already been shown, so do not ask again. Read status before sending the user reply; if the round has advanced, preserve the reply and report that it was not submitted. Use hold only when the person needs more time, never as an automatic keepalive.',
|
|
25
|
+
size: 'Normally use two seats, critiqueRounds 1 (the engine default), memory stateless and an explicit budget per vendor: up to five calls before repairs. Use 0 only for a requested quick comparison and disclose that the seats did not respond to each other. Consider 2 for a requested deep review or a decision with several consequential trade-offs, within the user\'s time and budget. Consensus can end discussion early. Do not automatically start another review or exceed agreed limits because disagreement remains.',
|
|
26
|
+
completion: 'A start acknowledgement or seat positions are not a completed review. Keep waiting through status running and verdict until status done and verdict.status ready. If interrupted, failed, skipped or missing, report that limitation instead of supplying your own chairman result. Include the review id, board link and depth.completedCritiqueRounds in the final report.',
|
|
27
|
+
lenses: 'Give every seat a different lens, taken from what the decision could get wrong: risk, cost, evidence, reversibility, long-term effects, user impact. Two seats with one lens mostly agree, which wastes a call.',
|
|
28
|
+
moods: 'Pair one sceptical seat (grill) with one practical seat (builder). Use steelman when the user already leans one way, contrarian when the seats would otherwise agree too early.',
|
|
29
|
+
effort: 'Leave model and effort blank to follow the profile defaults. To pin a model or reasoning level, show the names reported by roundtable_models and send the corresponding IDs. Shared defaults are managed with agentlink defaults PROFILE.',
|
|
30
|
+
context: 'constraints, known, assumed, reversibility and deadline go into every prompt. Fill them only with facts the user stated; put guesses under assumed, never under known. Leave a field empty rather than invent it.',
|
|
31
|
+
unattended: 'Use options.unattended true for a background job with nobody to answer: it skips all pauses and keeps missing facts as assumptions. Live chat or browser reviews leave it false: ordinary checkpoints last autoContinueMs (15 seconds by default), questions last questionWaitMs (2 minutes). No answer continues automatically, without accepting a recommendation. Both modes respect the review wall clock.',
|
|
32
|
+
isolation: 'AgentLink seats and direct Antigravity require options.allowLimitedIsolation=true. Set it only when the user has agreed to its limits: session rules deny documented tools, but the CLI cannot disable all shared customizations or MCP discovery. Choose another provider otherwise. Reported prohibited tool activity still stops the seat.',
|
|
33
|
+
terms: 'Direct Antigravity also requires options.acknowledgeTermsRisk=true, for every seat, chairman or searcher on agy. Google\'s Antigravity FAQ says wrapping agy in third-party applications is not supported under consumer plans and that third-party access can get the account suspended or terminated. Show the person directProviders[].terms.notice and its url from status, and set the option only when they have agreed for this review; an acknowledgment on the board does not answer for an agent request. Choose another provider otherwise.',
|
|
34
|
+
research: 'Only when the user requests web research: options.research={query:"public search question",maxSearches:4,timeoutMs:120000}. Adds one fresh CLI call, the searcher, before discussion; only this query goes into research. Optional vendor ("codex", "claude" or "agy"; default "codex"; agy also needs allowLimitedIsolation and acknowledgeTermsRisk), model, effort and account set the searcher; without model and effort it runs that vendor\'s lightest model at low effort on the default login. All seats receive the same saved provider-supplied sources. Reported search operations are bounded, but an operation may start before its report arrives. Failed or interrupted research never reruns automatically.',
|
|
35
|
+
agreement: 'When gate.reopenCalls is present, every seat already agrees. Empty answers and no message go straight to the verdict. Any answer text or message runs one more round at reopenCalls calls. Send text only if it could change a seat\'s position; a fact that confirms what the seats already said is better left for the verdict.',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export async function runAgent(command, flags = {}, input, signal) {
|
|
40
|
+
if (command === 'guide') return HELP;
|
|
41
|
+
if (!Object.hasOwn(HELP.commands, command)) throw new Error('Unknown agent command. Use agent --help.');
|
|
42
|
+
const port = Number(flags.port || process.env.PORT || 4747);
|
|
43
|
+
if (!Number.isInteger(port) || port < LIMITS.port[0] || port > LIMITS.port[1]) throw new Error('Port must be a number from 1 to 65535.');
|
|
44
|
+
if (flags.id && !/^[a-z0-9-]+$/.test(flags.id)) throw new Error('Invalid review id.');
|
|
45
|
+
const { base, request } = localClient(port, signal);
|
|
46
|
+
const route = flags.id ? `/api/debates/${flags.id}` : null;
|
|
47
|
+
const board = (id) => `${base}/#${id}`; // where a person can watch this review in a browser
|
|
48
|
+
let result;
|
|
49
|
+
if (command === 'status' && !route) {
|
|
50
|
+
const setup = await request('/api/seats?cached=1');
|
|
51
|
+
const inventory = await request('/api/profiles', {});
|
|
52
|
+
const pools = inventory.profiles.map((p) => 'acp@' + p.name);
|
|
53
|
+
const readiness = !pools.length ? { pools: [] } : flags.refresh
|
|
54
|
+
? await request('/api/preflight', { pools, fresh: true })
|
|
55
|
+
: await request('/api/preflight?pools=' + encodeURIComponent(pools.join(',')));
|
|
56
|
+
result = { mode: setup.runtime.mode, cataloguePending: setup.runtime.cataloguePending === true, defaultTransport: 'agentlink', agentLink: inventory,
|
|
57
|
+
providers: Object.keys(PROFILE_PROVIDERS).map((vendor) => {
|
|
58
|
+
const profile = providerProfile(vendor, inventory.profiles);
|
|
59
|
+
return { vendor, transport: 'agentlink', account: profile?.name || null, configured: !!profile, ...(profile?.defaults ? { defaults: profile.defaults } : {}) };
|
|
60
|
+
}),
|
|
61
|
+
directProviders: setup.vendors.filter((v) => v.kind !== 'acp').map((v) => ({ vendor: v.vendor, kind: v.kind, ...(v.kind === 'cli' ? { transport: 'cli' } : {}),
|
|
62
|
+
models: (v.catalogue?.models || []).map((m) => typeof m === 'string' ? m : m.id), efforts: v.catalogue?.efforts || [],
|
|
63
|
+
...(v.terms ? { terms: { notice: v.terms.notice, url: v.terms.url, acknowledgedOnBoard: v.terms.acknowledgedAt != null } } : {}) })),
|
|
64
|
+
readiness: readiness.pools, defaults: setup.defaults, next: 'Check a JSON review with agent check --input file. No model call has been made.' };
|
|
65
|
+
} else if (command === 'models') result = await request('/api/profile-models', input || {}, 45_000);
|
|
66
|
+
else if (command === 'check') result = await request('/api/preview', input, 40_000);
|
|
67
|
+
else if (command === 'start') { const started = await request('/api/debates', input, 40_000); result = { id: started.slug, board: board(started.slug), next: `agent wait --port ${port} --id ${started.slug}` }; }
|
|
68
|
+
else {
|
|
69
|
+
if (!route) throw new Error('This command needs --id from agent start or the board URL.');
|
|
70
|
+
if (command === 'status') result = { ...(await request(`${route}/state`)), board: board(flags.id) };
|
|
71
|
+
else if (command === 'wait') {
|
|
72
|
+
const seconds = Number(flags.seconds || 25);
|
|
73
|
+
if (!Number.isInteger(seconds) || seconds < LIMITS.waitSeconds[0] || seconds > LIMITS.waitSeconds[1]) throw new Error('Wait seconds must be a whole number from 1 to 30.');
|
|
74
|
+
const afterRound = flags['after-round'] == null ? -1 : Number(flags['after-round']);
|
|
75
|
+
if (!Number.isInteger(afterRound) || afterRound < -1 || afterRound > LIMITS.critiqueRounds[1] || flags['after-round'] != null && afterRound < 0) throw new Error('After round must be a whole number from 0 to 8.');
|
|
76
|
+
result = await request(`${route}/state`);
|
|
77
|
+
if (['researching', 'running', 'verdict'].includes(result.status) || result.status === 'waiting' && (result.gate?.round === afterRound || result.gate?.mode === 'countdown' && !result.gate.questions.length)) {
|
|
78
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), seconds * 1000);
|
|
79
|
+
const waiting = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
|
|
80
|
+
let reader;
|
|
81
|
+
// Node 22 can lose fetch's abort link after collection while an SSE body
|
|
82
|
+
// is idle. Cancel the held reader directly so its pending read settles.
|
|
83
|
+
const cancelRead = () => { reader?.cancel().catch(() => {}); };
|
|
84
|
+
waiting.addEventListener('abort', cancelRead, { once: true });
|
|
85
|
+
try {
|
|
86
|
+
const response = await fetch(`${base}${route}/events`, { redirect: 'error', signal: waiting, headers: { 'last-event-id': result.revision } });
|
|
87
|
+
if (!response.ok) throw new Error('Could not wait for review events.');
|
|
88
|
+
reader = response.body.getReader();
|
|
89
|
+
waiting.throwIfAborted();
|
|
90
|
+
const decoder = new TextDecoder(); let buffer = '', finished = false;
|
|
91
|
+
while (!finished) {
|
|
92
|
+
const next = await reader.read(); if (next.done) break;
|
|
93
|
+
buffer += decoder.decode(next.value, { stream: true });
|
|
94
|
+
let end;
|
|
95
|
+
while ((end = buffer.indexOf('\n\n')) >= 0) {
|
|
96
|
+
const event = buffer.slice(0, end).split('\n').find((line) => line.startsWith('data: ')); buffer = buffer.slice(end + 2);
|
|
97
|
+
if (event) {
|
|
98
|
+
const update = JSON.parse(event.slice(6));
|
|
99
|
+
if (['done', 'error', 'interrupted'].includes(update.type) || update.type === 'gate' && update.round !== afterRound && (update.questions?.length || update.mode === 'blocking')) finished = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
signal?.throwIfAborted();
|
|
104
|
+
} catch (error) { signal?.throwIfAborted(); if (!controller.signal.aborted) throw error; }
|
|
105
|
+
finally {
|
|
106
|
+
clearTimeout(timer);
|
|
107
|
+
waiting.removeEventListener('abort', cancelRead);
|
|
108
|
+
if (reader) await reader.cancel().catch(() => {});
|
|
109
|
+
}
|
|
110
|
+
result = await request(`${route}/state`);
|
|
111
|
+
}
|
|
112
|
+
result = { ...result, board: board(flags.id) };
|
|
113
|
+
if (result.nextAction?.type === 'ask_user' && result.gate.round === afterRound) {
|
|
114
|
+
result.nextAction = { ...result.nextAction, type: 'await_user', instruction: 'These questions have already been presented. Keep the existing prompt pending; do not ask again or invent answers. Read status before submitting a reply. Use waitCommand to wait for another step without extending the response window.' };
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
const body = structuredClone(input ?? {});
|
|
118
|
+
if (!body || typeof body !== 'object' || Array.isArray(body)) throw new Error('Input must be a JSON object.');
|
|
119
|
+
if (['answer', 'finish', 'stop', 'resume'].includes(command)) body.source = 'agent';
|
|
120
|
+
if (['answer', 'hold'].includes(command) && !Number.isInteger(body.round)) throw new Error('An answer or time extension needs the round number from the current state.');
|
|
121
|
+
result = await request(`${route}/${command === 'answer' ? 'continue' : command === 'verdict' ? 'synthesize' : command}`, body);
|
|
122
|
+
result = { ...result, id: flags.id, board: board(flags.id), next: `agent wait --port ${port} --id ${flags.id}` };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (['ask_user', 'await_user'].includes(result.nextAction?.type)) {
|
|
126
|
+
result.nextAction.command = `agent answer --port ${port} --id ${flags.id} --input -`;
|
|
127
|
+
result.nextAction.waitCommand = `agent wait --port ${port} --id ${flags.id} --after-round ${result.gate.round}`;
|
|
128
|
+
result.nextAction.extend = { command: `agent hold --port ${port} --id ${flags.id} --input -`, input: { round: result.gate.round } };
|
|
129
|
+
}
|
|
130
|
+
return { ok: true, ...result };
|
|
131
|
+
}
|