@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/agent-client.js
CHANGED
|
@@ -1,108 +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
|
-
if (
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -7,11 +7,13 @@
|
|
|
7
7
|
// roundtable doctor [--live] what this machine can seat
|
|
8
8
|
// roundtable export <slug> <dir>
|
|
9
9
|
// roundtable debate [...] one debate headless against a running server (see the script)
|
|
10
|
-
// --port <n> --no-open for the two board commands
|
|
10
|
+
// --port <n> --no-open for the two board commands; any other option there is refused
|
|
11
|
+
// roundtable --version the installed version
|
|
11
12
|
import { spawn } from 'node:child_process';
|
|
12
13
|
import path from 'node:path';
|
|
13
14
|
import { fileURLToPath } from 'node:url';
|
|
14
15
|
import { terminalBanner } from './terminal.js';
|
|
16
|
+
import { VERSION } from './version.js';
|
|
15
17
|
|
|
16
18
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
17
19
|
const SCRIPTS = {
|
|
@@ -28,11 +30,27 @@ const USAGE = ['roundtable [--port <n>] [--no-open] the board, opened in your
|
|
|
28
30
|
'roundtable setup --client codex connect an assistant across projects (also claude, agy, all)',
|
|
29
31
|
'roundtable setup --help inspect, update or remove that connection',
|
|
30
32
|
'roundtable server --help check, start, stop or restart the hidden board',
|
|
31
|
-
'roundtable mcp MCP tools over stdio; starts the local server as needed'
|
|
33
|
+
'roundtable mcp MCP tools over stdio; starts the local server as needed',
|
|
34
|
+
'roundtable --version the installed version'].join('\n');
|
|
32
35
|
// help first, wherever it is on the line: a bare `--help` must never start the real server
|
|
33
36
|
if (!['agent', 'setup', 'mcp', 'server'].includes(args[0]) && args.some((a) => a === 'help' || a === '--help' || a === '-h')) { process.stdout.write(terminalBanner()); console.log(USAGE); process.exit(0); }
|
|
37
|
+
// the version and nothing else, asked for first on the line (a later -v belongs to a subcommand)
|
|
38
|
+
if (['--version', '-v', '-V', 'version'].includes(args[0])) { console.log(VERSION); process.exit(0); }
|
|
39
|
+
const refuse = (why) => { console.error(`${why}\n\n${USAGE}`); process.exit(2); };
|
|
34
40
|
const cmd = args[0] && !args[0].startsWith('-') ? args.shift() : 'start';
|
|
35
|
-
if (!SCRIPTS[cmd])
|
|
41
|
+
if (!SCRIPTS[cmd]) refuse(`unknown command: ${cmd}`);
|
|
42
|
+
// The board commands take these options and no others. An unrecognised one used to fall through
|
|
43
|
+
// and start the board (a mistyped --port opened the live server on the default port), so it is
|
|
44
|
+
// refused here, before anything starts. The other commands check their own arguments.
|
|
45
|
+
if (['start', 'fake'].includes(cmd)) {
|
|
46
|
+
for (let i = 0; i < args.length; i++) {
|
|
47
|
+
if (args[i] === '--port') {
|
|
48
|
+
const n = /^\d{1,5}$/.test(args[i + 1] ?? '') ? Number(args[i + 1]) : 0;
|
|
49
|
+
if (n < 1 || n > 65535) refuse('--port needs a number from 1 to 65535');
|
|
50
|
+
i++;
|
|
51
|
+
} else if (!['--no-open', '--fake', '--fake-consensus'].includes(args[i])) refuse(`unknown option: ${args[i]}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
36
54
|
const env = { ...process.env };
|
|
37
55
|
const port = args.indexOf('--port');
|
|
38
56
|
if (port >= 0 && ['start', 'fake'].includes(cmd)) { env.PORT = args[port + 1]; args.splice(port, 2); }
|
package/src/diagnostics.js
CHANGED
|
@@ -23,6 +23,7 @@ const integer = (n, max) => Number.isInteger(n) && n >= 0 && n <= max;
|
|
|
23
23
|
export const diagnosticId = () => `RT-${randomBytes(8).toString('hex')}`;
|
|
24
24
|
|
|
25
25
|
export function diagnosticAction(pathname) {
|
|
26
|
+
if (pathname === '/api/profile-models') return 'catalogue';
|
|
26
27
|
if (pathname === '/api/seats') return 'setup';
|
|
27
28
|
if (pathname === '/api/health') return 'health';
|
|
28
29
|
if (pathname === '/api/shutdown') return 'shutdown';
|
package/src/doctor.js
CHANGED
|
@@ -54,6 +54,13 @@ async function main() {
|
|
|
54
54
|
if (a.kind === 'cli') try { bin = resolveBinary(a.binary, a.npmBin); } catch (e) { lookup = e.message; }
|
|
55
55
|
if (a.kind === 'cli' && !bin && only !== vendor) { missing.push(`${a.label} (${a.binary})`); continue; }
|
|
56
56
|
console.log(`\n== ${paintVendor(a)} (${vendor}) pool: ${a.pool}`);
|
|
57
|
+
if (a.kind === 'acp') {
|
|
58
|
+
console.log(' seat it choose AgentLink (ACP) and a saved profile on the board; use stateless memory');
|
|
59
|
+
console.log(' check it agentlink doctor; agentlink check PROFILE (initialization only)');
|
|
60
|
+
console.log(` isolation ${a.isolation}`);
|
|
61
|
+
console.log(' live call use an explicitly selected profile in a review; no default ACP agent is launched');
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
57
64
|
if (a.kind === 'api') { // no binary: everything about an endpoint seat is on its card
|
|
58
65
|
console.log(' seat it on the board: base URL (…/v1), model id, and for a hosted API the NAME of the key variable');
|
|
59
66
|
console.log(` efforts ${a.effortLevels.join(', ')} (reasoning_effort, sent only when set)`);
|
package/src/engine.js
CHANGED
|
@@ -80,7 +80,7 @@ export function createDebate({ fieldNotes, seats, chairman, options = {}, runner
|
|
|
80
80
|
delete seat.lastRawUsage;
|
|
81
81
|
return seat;
|
|
82
82
|
}),
|
|
83
|
-
chairman: chairman || { vendor: seats[0].vendor },
|
|
83
|
+
chairman: chairman || { vendor: seats[0].vendor, ...(seats[0].vendor === 'acp' ? { account: seats[0].account, model: seats[0].model } : {}) },
|
|
84
84
|
startedAt: null, deadlineAt: null, stopContext: null, fieldNotes, options: opts, usage: [], research: resume?.research || null,
|
|
85
85
|
};
|
|
86
86
|
const fire = (type, payload = {}) => emit(type, { ...payload, type });
|
|
@@ -323,9 +323,12 @@ export function createDebate({ fieldNotes, seats, chairman, options = {}, runner
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const
|
|
326
|
+
// A seat on a named account is also projected under `vendor@account`, so a budget on one
|
|
327
|
+
// AgentLink profile can be checked on its own; the bare vendor key still carries every seat.
|
|
328
|
+
const profiled = (seat, projection) => seat?.account && projection[seat.vendor] ? { ...projection, [`${seat.vendor}@${seat.account}`]: { ...projection[seat.vendor] } } : projection;
|
|
329
|
+
const oneCall = (seat, round) => profiled(seat, projectRound({ seats: [seat], round, baselines,
|
|
330
|
+
memory: resumes && seat.sessionId != null ? 'resume' : 'stateless', researchTokens: researchInputTokens(fieldNotes.research || []) }));
|
|
331
|
+
const chairmanCall = (chairman = state.chairman) => profiled(chairman, projectChairman({ chairman, baselines, researchTokens: researchInputTokens(fieldNotes.research || []) }));
|
|
329
332
|
|
|
330
333
|
// A seat's connection state, as the board shows it: idle, thinking, replied, reprompted,
|
|
331
334
|
// failed, timed-out. Emitted here so the UI only renders.
|
|
@@ -516,7 +519,7 @@ export function createDebate({ fieldNotes, seats, chairman, options = {}, runner
|
|
|
516
519
|
// effort, once. The board is told which and why; the record keeps the fallback chairman.
|
|
517
520
|
function fallbackChairman(from) {
|
|
518
521
|
const tried = new Set([`${from.vendor}@${from.account || ''}`]);
|
|
519
|
-
const seat = state.seats.find((s) => !tried.has(`${s.vendor}@${s.account || ''}`) && !downOf(s) && !policyBlocked(s) && s.vendor !== from.vendor);
|
|
522
|
+
const seat = state.seats.find((s) => !tried.has(`${s.vendor}@${s.account || ''}`) && !downOf(s) && !policyBlocked(s) && (s.vendor !== from.vendor || s.vendor === 'acp'));
|
|
520
523
|
return seat ? { vendor: seat.vendor, account: seat.account, colour: seat.colour, model: seat.endpoint ? seat.model : undefined, effort: undefined, ...(seat.endpoint ? { endpoint: seat.endpoint, keyEnv: seat.keyEnv } : {}) } : null;
|
|
521
524
|
}
|
|
522
525
|
|
|
@@ -586,8 +589,9 @@ export function createDebate({ fieldNotes, seats, chairman, options = {}, runner
|
|
|
586
589
|
function spentByVendor() {
|
|
587
590
|
const out = {};
|
|
588
591
|
const at = (vendor) => (out[vendor] ??= { tokens: 0, cost: 0, costUnknown: false, tokensUnknown: false });
|
|
589
|
-
for
|
|
590
|
-
|
|
592
|
+
// under the vendor, and under `vendor@account` for a seat on a named account (profile budgets)
|
|
593
|
+
for (const e of ledger) for (const key of e.seat.account ? [e.seat.vendor, `${e.seat.vendor}@${e.seat.account}`] : [e.seat.vendor]) {
|
|
594
|
+
const v = at(key);
|
|
591
595
|
if (usageUnknown(e.usage)) v.tokensUnknown = true;
|
|
592
596
|
if (e.usage) v.tokens += (e.usage.input || 0) + (e.usage.cacheRead || 0) + (e.usage.cacheWrite || 0) + (e.usage.output || 0);
|
|
593
597
|
const cost = e.usage?.cost ?? e.cost;
|
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 {
|