@prplkane/roundtable 0.6.3 → 0.6.6

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.
@@ -422,11 +422,21 @@ export const ADAPTERS = {
422
422
  colour: 'steel',
423
423
  readOnly: 'no tools in the request',
424
424
  },
425
+ acp: {
426
+ kind: 'acp', label: 'AgentLink (ACP)', binary: 'agentlink',
427
+ npmBin: ['@local/agentlink', 'src/cli.mjs'],
428
+ args: [], resume: null, model: null, effort: null, home: null,
429
+ effortLevels: [], modelHints: [], paths: { cost: null, quota: null },
430
+ quota: null, usageUrl: null, colour: 'dusk', limitedIsolation: true,
431
+ pool: 'Selected AgentLink profile; billing and quota belong to its agent',
432
+ isolation: 'fresh ACP sessions in separate working directories; profile-owned tools and customization are not sandboxed',
433
+ readOnly: 'client tools denied; reported tool activity stops the seat; configure the profile agent to disable its own tools',
434
+ },
425
435
  };
426
436
 
427
437
  // A vendor whose seats draw on separate pools per account: a CLI with a state directory
428
438
  // (named login profiles), or an endpoint vendor (one pool per host). Pool keys (seats.poolKey)
429
439
  // carry the account only for these.
430
- export const poolsByAccount = (a) => !!a?.home || a?.kind === 'api';
440
+ export const poolsByAccount = (a) => !!a?.home || a?.kind === 'api' || a?.kind === 'acp';
431
441
 
432
442
  export const ARGV_LIMIT = 24000;
@@ -2,10 +2,11 @@ import { run as claude } from './claude.js';
2
2
  import { run as codex } from './codex.js';
3
3
  import { run as agy } from './agy.js';
4
4
  import { run as api } from './endpoint.js';
5
+ import { run as acp } from './acp.js';
5
6
  import { ADAPTERS, poolsByAccount } from './config.js';
6
7
  import { readCodexQuota, readAgyQuota, readClaudeQuota } from './quota.js';
7
8
 
8
- export const adapters = { claude, codex, agy, api };
9
+ export const adapters = { claude, codex, agy, api, acp };
9
10
  // Vendors whose quota needs a separate read (no model call). The others ride on replies or have none.
10
11
  export const quotaReaders = { claude: readClaudeQuota, codex: readCodexQuota, agy: readAgyQuota };
11
12
  export { ADAPTERS, poolsByAccount };
@@ -15,10 +15,11 @@ export const HELP = {
15
15
  resume: 'Resume an interrupted review. May make provider calls.',
16
16
  verdict: 'Request a missing or failed verdict from saved replies. May make a provider call.',
17
17
  },
18
+ acp: 'To use a saved AgentLink 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. Missing token usage stays unknown and stops further calls for that seat under its cap; no live quota is inferred.',
18
19
  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.',
19
20
  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.',
20
21
  recipe: {
21
- 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 the autoContinueAt deadline and that unknowns stay unknown. 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.',
22
+ 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.',
22
23
  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.',
23
24
  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.',
24
25
  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.',
@@ -64,11 +65,17 @@ export async function runAgent(command, flags = {}, input, signal) {
64
65
  result = await request(`${route}/state`);
65
66
  if (['researching', 'running', 'verdict'].includes(result.status) || result.status === 'waiting' && (result.gate?.round === afterRound || result.gate?.mode === 'countdown' && !result.gate.questions.length)) {
66
67
  const controller = new AbortController(), timer = setTimeout(() => controller.abort(), seconds * 1000);
68
+ const waiting = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
67
69
  let reader;
70
+ // Node 22 can lose fetch's abort link after collection while an SSE body
71
+ // is idle. Cancel the held reader directly so its pending read settles.
72
+ const cancelRead = () => { reader?.cancel().catch(() => {}); };
73
+ waiting.addEventListener('abort', cancelRead, { once: true });
68
74
  try {
69
- const response = await fetch(`${base}${route}/events`, { redirect: 'error', signal: signal ? AbortSignal.any([signal, controller.signal]) : controller.signal, headers: { 'last-event-id': result.revision } });
75
+ const response = await fetch(`${base}${route}/events`, { redirect: 'error', signal: waiting, headers: { 'last-event-id': result.revision } });
70
76
  if (!response.ok) throw new Error('Could not wait for review events.');
71
77
  reader = response.body.getReader();
78
+ waiting.throwIfAborted();
72
79
  const decoder = new TextDecoder(); let buffer = '', finished = false;
73
80
  while (!finished) {
74
81
  const next = await reader.read(); if (next.done) break;
@@ -82,8 +89,13 @@ export async function runAgent(command, flags = {}, input, signal) {
82
89
  }
83
90
  }
84
91
  }
92
+ signal?.throwIfAborted();
85
93
  } catch (error) { signal?.throwIfAborted(); if (!controller.signal.aborted) throw error; }
86
- finally { clearTimeout(timer); if (reader) await reader.cancel().catch(() => {}); }
94
+ finally {
95
+ clearTimeout(timer);
96
+ waiting.removeEventListener('abort', cancelRead);
97
+ if (reader) await reader.cancel().catch(() => {});
98
+ }
87
99
  result = await request(`${route}/state`);
88
100
  }
89
101
  result = { ...result, board: board(flags.id) };
package/src/doctor.js CHANGED
@@ -13,6 +13,7 @@ import { fileURLToPath } from 'node:url';
13
13
  import { ADAPTERS } from './adapters/config.js';
14
14
  import { resolveBinary, runProcess, profileHome, dataDir } from './adapters/spawn.js';
15
15
  import { dataDirectory } from './history.js';
16
+ import { paintVendor } from './terminal.js';
16
17
 
17
18
  // Shell lines that log a profile in, per vendor, for the platform the user is on. Pure.
18
19
  export function loginInstructions(vendor, profile, where = {}) {
@@ -46,9 +47,20 @@ async function main() {
46
47
  const catalogue = await vendorCatalogue(ADAPTERS.agy.terms && !acknowledgeTermsRisk ? { agyModels: async () => [] } : {});
47
48
  console.log(`roundtable doctor (${process.platform}, node ${process.version}, data dir ${dataDir()})`);
48
49
  console.log(live ? 'live: one trivial model call per vendor' : 'static only; add --live for one trivial model call per vendor');
50
+ const missing = []; // CLIs not on PATH: one line at the end, a full block only when asked for by --vendor
49
51
  for (const [vendor, a] of Object.entries(ADAPTERS)) {
50
52
  if (only && only !== vendor) continue;
51
- console.log(`\n== ${a.label} (${vendor}) pool: ${a.pool}`);
53
+ let bin = null, lookup = null;
54
+ if (a.kind === 'cli') try { bin = resolveBinary(a.binary, a.npmBin); } catch (e) { lookup = e.message; }
55
+ if (a.kind === 'cli' && !bin && only !== vendor) { missing.push(`${a.label} (${a.binary})`); continue; }
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
+ }
52
64
  if (a.kind === 'api') { // no binary: everything about an endpoint seat is on its card
53
65
  console.log(' seat it on the board: base URL (…/v1), model id, and for a hosted API the NAME of the key variable');
54
66
  console.log(` efforts ${a.effortLevels.join(', ')} (reasoning_effort, sent only when set)`);
@@ -58,8 +70,7 @@ async function main() {
58
70
  }
59
71
  const held = !!a.terms && !acknowledgeTermsRisk;
60
72
  const heldLine = `held: nothing is sent to ${a.binary} without --acknowledge-terms-risk`;
61
- let bin = null;
62
- try { bin = resolveBinary(a.binary, a.npmBin); console.log(` binary ${bin.prefix.length ? `${bin.prefix[0]} (via node)` : bin.file}`); } catch (e) { console.log(` binary NOT FOUND: ${e.message}`); }
73
+ console.log(` binary ${bin ? bin.prefix.length ? `${bin.prefix[0]} (via node)` : bin.file : `NOT FOUND: ${lookup}`}`);
63
74
  if (bin) console.log(` version ${await version(bin, vendor)}`);
64
75
  const c = catalogue[vendor];
65
76
  if (held) console.log(` models ${heldLine}`);
@@ -88,6 +99,7 @@ async function main() {
88
99
  }
89
100
  if (profile) for (const l of loginInstructions(vendor, profile)) console.log(` profile ${l}`);
90
101
  }
102
+ if (missing.length) console.log(`\nnot installed: ${missing.join(', ')}; install and sign in to seat them, or add --vendor <name> for that block`);
91
103
  if (!profile) console.log('\nadd --profile <name> to see how to log a named account profile in for each vendor');
92
104
  }
93
105
 
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 });
@@ -516,7 +516,7 @@ export function createDebate({ fieldNotes, seats, chairman, options = {}, runner
516
516
  // effort, once. The board is told which and why; the record keeps the fallback chairman.
517
517
  function fallbackChairman(from) {
518
518
  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);
519
+ const seat = state.seats.find((s) => !tried.has(`${s.vendor}@${s.account || ''}`) && !downOf(s) && !policyBlocked(s) && (s.vendor !== from.vendor || s.vendor === 'acp'));
520
520
  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
521
  }
522
522