@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/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'].join('\n');
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]) { console.error(`unknown command: ${cmd}\n\n${USAGE}`); process.exit(2); }
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); }
@@ -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/engine.js CHANGED
@@ -323,9 +323,12 @@ export function createDebate({ fieldNotes, seats, chairman, options = {}, runner
323
323
  }
324
324
  }
325
325
 
326
- const oneCall = (seat, round) => projectRound({ seats: [seat], round, baselines,
327
- memory: resumes && seat.sessionId != null ? 'resume' : 'stateless', researchTokens: researchInputTokens(fieldNotes.research || []) });
328
- const chairmanCall = (chairman = state.chairman) => projectChairman({ chairman, baselines, researchTokens: researchInputTokens(fieldNotes.research || []) });
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.
@@ -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 (const e of ledger) {
590
- const v = at(e.seat.vendor);
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;