@prplkane/roundtable 0.6.6 → 0.8.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 +61 -0
- package/README.md +83 -91
- package/SECURITY.md +25 -19
- package/docs/workflow.md +112 -63
- package/package.json +2 -2
- package/scripts/agent.mjs +2 -2
- package/scripts/mcp.mjs +5 -2
- package/skills/roundtable/SKILL.md +6 -0
- package/src/adapters/acp.js +247 -67
- package/src/adapters/catalogue.js +37 -18
- package/src/adapters/common.js +49 -7
- package/src/adapters/config.js +13 -9
- package/src/adapters/endpoint.js +2 -1
- package/src/adapters/models.js +32 -19
- package/src/adapters/spawn.js +3 -1
- package/src/agent-client.js +27 -14
- package/src/cli.js +21 -3
- package/src/diagnostics.js +1 -0
- package/src/engine.js +73 -28
- package/src/estimate.js +41 -6
- package/src/export.js +12 -6
- package/src/history.js +11 -3
- package/src/local-http.js +16 -6
- package/src/local-server.js +1 -1
- package/src/preflight.js +26 -6
- package/src/progress.js +18 -0
- package/src/prompts.js +33 -30
- package/src/research.js +46 -7
- package/src/review-view.js +11 -0
- package/src/seats.js +101 -20
- package/src/server.js +127 -40
- package/src/snapshot.js +4 -3
- package/src/source-check.js +173 -0
- package/src/store.js +2 -2
- package/src/ui/app.js +307 -128
- package/src/ui/design/app.css +3 -2
- package/src/ui/help.js +2 -1
- package/src/ui/index.html +13 -6
- package/src/validate.js +15 -3
package/src/ui/app.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_SEARCHER, defaultSearchLimit, verificationNote } from '/src/research.js';
|
|
1
2
|
import { rollup, hasUsableRound, positions } from '/src/engine.js';
|
|
2
3
|
import { optionLabel } from '/src/contract.js';
|
|
3
|
-
import { poolKey, poolVendor, poolAccount, hostKey, seatKind,
|
|
4
|
+
import { poolKey, poolVendor, poolAccount, hostKey, seatKind, PROFILE_PROVIDERS, providerProfile, profileChoicesFor, nextSeatLens, fillMissingSeatLenses, seatSetupIssue, hiddenMood, lightestModel, keyEnvName, HIDDEN_MOODS } from '/src/seats.js';
|
|
4
5
|
import { avatar } from '/ui/avatars.js';
|
|
5
|
-
import { modelsByCapability, retired, quotaWindows, quotaGroup, modelEfforts } from '/src/adapters/models.js';
|
|
6
|
+
import { agyFamily, agySelection, modelsByCapability, retired, quotaWindows, quotaGroup, modelEfforts } from '/src/adapters/models.js';
|
|
6
7
|
import { project, projectedWindows, unknownUsageMessage } from '/src/estimate.js';
|
|
7
8
|
import { PREFLIGHT_TTL_MS, lamp as preflightLamp } from '/src/preflight.js';
|
|
8
9
|
import { createBrowserDiagnostics, requestAction } from '/ui/diagnostics.js';
|
|
@@ -13,9 +14,9 @@ import { scanMarkup, startScan, stopScan } from '/ui/scan.js';
|
|
|
13
14
|
import { icon } from '/ui/icons.js';
|
|
14
15
|
import { loaderMarkup } from '/ui/loader.js';
|
|
15
16
|
import { noteRecord, noteLabel } from '/src/notes.js';
|
|
16
|
-
import { progressText } from '/src/progress.js';
|
|
17
|
+
import { progressText, providerHistoryText } from '/src/progress.js';
|
|
17
18
|
import { unlock as unlockSound, setSound, soundEnabled, playCue } from '/ui/sound.js';
|
|
18
|
-
import { groupQuestions, answerMessage, stopExplanation, cancellationReason, remainingWindow, argumentHtml, ceremonyOutcome, verdictView, verdictResultText, verdictHeadline, defaultSearchQuery } from '/src/review-view.js';
|
|
19
|
+
import { providerWarning, groupQuestions, answerMessage, stopExplanation, cancellationReason, remainingWindow, argumentHtml, ceremonyOutcome, verdictView, verdictResultText, verdictHeadline, defaultSearchQuery } from '/src/review-view.js';
|
|
19
20
|
|
|
20
21
|
const $ = (id) => document.getElementById(id);
|
|
21
22
|
const helpNotes = installHelp();
|
|
@@ -112,7 +113,57 @@ $('save-diagnostics').addEventListener('click', async () => {
|
|
|
112
113
|
} catch (e) { $('diagnostics-status').textContent = `Could not save the error log. ${e.message}`; }
|
|
113
114
|
finally { button.disabled = false; $('diagnostics-status').hidden = false; }
|
|
114
115
|
});
|
|
115
|
-
|
|
116
|
+
let profileInventory = { profiles: [] };
|
|
117
|
+
const directVendor = (v) => Object.hasOwn(PROFILE_PROVIDERS, v);
|
|
118
|
+
const rawVendor = (value) => value.startsWith('acp@') ? 'acp' : value;
|
|
119
|
+
const chairVendor = () => rawVendor($('chairman').value);
|
|
120
|
+
function providerChoices() {
|
|
121
|
+
return profileChoicesFor(profileInventory.profiles).map((p) => ({
|
|
122
|
+
...p, label: p.vendor ? VENDOR_LABEL[p.vendor] : p.name, conventional: p.vendor,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
function providerOptions(vendor, account) {
|
|
126
|
+
const choices = providerChoices();
|
|
127
|
+
const current = vendor === 'acp' && choices.some((p) => p.name === account) ? 'acp@' + account : vendor;
|
|
128
|
+
const option = (value, label) => `<option value="${esc(value)}" ${value === current ? 'selected' : ''}>${esc(label)}</option>`;
|
|
129
|
+
const profiles = choices.map((p) => option('acp@' + p.name, p.label + (p.conventional && p.name !== p.conventional ? ' · ' + p.name : '') + (p.configured ? '' : ' (setup needed)'))).join('');
|
|
130
|
+
return `<optgroup label="AgentLink profiles">${profiles}${option('acp', 'Other saved profile…')}</optgroup><optgroup label="Direct connections">${Object.keys(VENDOR_META).filter((v) => v !== 'acp').map((v) => option(v, VENDOR_LABEL[v] + (directVendor(v) ? ' · direct CLI' : ''))).join('')}</optgroup>`;
|
|
131
|
+
}
|
|
132
|
+
async function refreshConnections() {
|
|
133
|
+
try {
|
|
134
|
+
const inventory = await requestJson('/api/profiles', {});
|
|
135
|
+
const vendor = chairVendor(), account = chairAccount();
|
|
136
|
+
for (const [name, state] of profileChoices) {
|
|
137
|
+
const saved = inventory.profiles.find((p) => p.name === name);
|
|
138
|
+
if (!saved || saved.defaults?.model !== state.defaults?.model || saved.defaults?.effort !== state.defaults?.effort) profileChoices.delete(name);
|
|
139
|
+
}
|
|
140
|
+
profileInventory = inventory;
|
|
141
|
+
$('chairman').innerHTML = providerOptions(vendor, account);
|
|
142
|
+
$('seat-setup-note').textContent = inventory.error || '';
|
|
143
|
+
$('seat-setup-note').hidden = !inventory.error;
|
|
144
|
+
renderChair(); renderSeats(); requestPreflight({ fresh: true });
|
|
145
|
+
} catch (e) { $('preflight-status').textContent = e.message; }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const directLoaded = new Set();
|
|
149
|
+
async function loadDirectCatalogue(vendor) {
|
|
150
|
+
if (!['codex', 'agy'].includes(vendor) || directLoaded.has(vendor)) return;
|
|
151
|
+
directLoaded.add(vendor);
|
|
152
|
+
try {
|
|
153
|
+
const cat = await requestJson('/api/direct-models', { vendor }, 40_000);
|
|
154
|
+
VENDOR_META[vendor].catalogue = cat;
|
|
155
|
+
$('models-' + vendor).innerHTML = cat.models.map((m) => `<option value="${esc(m.id)}">${esc(m.label)}</option>`).join('');
|
|
156
|
+
chairEffortOptions(); renderChair(); renderSeats(); renderSearcher();
|
|
157
|
+
} catch (e) { directLoaded.delete(vendor); $('preflight-status').textContent = e.message; }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function defaultAccounts() {
|
|
161
|
+
const choices = providerChoices();
|
|
162
|
+
return [...choices.filter((p) => p.configured), ...choices.filter((p) => !p.configured)].map((p) => p.name);
|
|
163
|
+
}
|
|
164
|
+
const newProfileSeat = (account, lens) => ({ vendor: 'acp', account, lens, mood: 'grill', moodText: '', model: '', effort: '' });
|
|
165
|
+
const directTransport = (vendor) => directVendor(vendor) ? { transport: 'cli' } : {};
|
|
166
|
+
|
|
116
167
|
const VENDOR_LABEL = {};
|
|
117
168
|
const VENDOR_META = {}; // vendor -> { kind, usageUrl, pool, catalogue, colour, profiles } from /api/seats
|
|
118
169
|
let MOODS = {}, COLOURS = ['rust', 'olive', 'teal', 'dusk', 'steel'], BASELINES = {};
|
|
@@ -131,7 +182,7 @@ const isApi = (vendor) => VENDOR_META[vendor]?.kind === 'api';
|
|
|
131
182
|
const isAcp = (vendor) => VENDOR_META[vendor]?.kind === 'acp';
|
|
132
183
|
// The pool a drafted seat draws on: a CLI's login profile, or an endpoint's host.
|
|
133
184
|
const seatAccount = (s) => (isApi(s.vendor) ? hostKey(s.endpoint || '') : (s.account || '').trim());
|
|
134
|
-
const chairAccount = () => (isApi(
|
|
185
|
+
const chairAccount = () => (isApi(chairVendor()) ? hostKey($('chairman-endpoint').value) : $('chairman-account').value.trim());
|
|
135
186
|
|
|
136
187
|
// ---------- state ----------
|
|
137
188
|
const S = {
|
|
@@ -168,8 +219,11 @@ const led = (state) => `<span class="led led-${esc(state || 'idle')}" title="${e
|
|
|
168
219
|
|
|
169
220
|
// ---------- setup screen ----------
|
|
170
221
|
async function setup() {
|
|
171
|
-
const
|
|
222
|
+
const [setupData, inventory] = await Promise.all([requestJson('/api/seats'), requestJson('/api/profiles', {})]);
|
|
223
|
+
profileInventory = inventory;
|
|
224
|
+
const { vendors, moods, colours, defaults, baselines, calibration, pools, runtime } = setupData;
|
|
172
225
|
const demo = runtime?.mode === 'demo';
|
|
226
|
+
S.demo = demo;
|
|
173
227
|
$('run-mode').textContent = demo ? 'Demo' : 'Live';
|
|
174
228
|
$('run-mode').className = `run-mode ${demo ? 'demo' : 'live'}`;
|
|
175
229
|
$('mode-note').textContent = demo ? 'Demo: replies and usage are scripted. No model calls are made.' : 'Live: debates send your field notes to the providers you select and use their quota or billing.';
|
|
@@ -184,8 +238,7 @@ async function setup() {
|
|
|
184
238
|
VENDOR_LABEL[v.vendor] = v.label;
|
|
185
239
|
VENDOR_META[v.vendor] = { kind: v.kind, usageUrl: v.usageUrl, pool: v.pool, catalogue: v.catalogue, colour: v.colour, profiles: v.profiles, limitedIsolation: v.limitedIsolation === true, terms: v.terms || null };
|
|
186
240
|
if (v.quota) S.quota[v.vendor] = v.quota;
|
|
187
|
-
|
|
188
|
-
if (v.search) $('searcher-vendor').insertAdjacentHTML('beforeend', `<option value="${v.vendor}">${esc(v.label)}</option>`);
|
|
241
|
+
if (v.search) $('searcher-vendor').insertAdjacentHTML('beforeend', `<option value="${v.vendor}">${esc(v.label)} · direct CLI</option>`);
|
|
189
242
|
// one datalist per vendor, so the model field offers what that CLI is known to accept
|
|
190
243
|
$('datalists').insertAdjacentHTML('beforeend', `<datalist id="models-${v.vendor}">${(v.catalogue?.models || []).map((m) => `<option value="${esc(m.id)}">${esc(m.label)}</option>`).join('')}</datalist>`);
|
|
191
244
|
}
|
|
@@ -194,6 +247,7 @@ async function setup() {
|
|
|
194
247
|
$('auto').value = defaults.autoContinueMs / 1000;
|
|
195
248
|
$('question-wait').value = (defaults.questionWaitMs || 120000) / 1000;
|
|
196
249
|
$('wall').value = defaults.wallClockMs / 60000;
|
|
250
|
+
$('provider-history-mode').value = defaults.providerHistory || 'prefer-ephemeral';
|
|
197
251
|
$('memory').value = defaults.memory || 'stateless';
|
|
198
252
|
try { const saved = JSON.parse(localStorage.getItem('roundtable.notes') || 'null'); if (saved) for (const [k, v] of Object.entries(saved)) if (k !== 'options' && $(k)) $(k).value = v; S.options = String(saved?.options || '').split('\n').map((o) => o.trim()).filter(Boolean); } catch {}
|
|
199
253
|
if (!S.options || S.options.length < 2) S.options = [...(S.options || []), '', ''].slice(0, Math.max(2, S.options?.length || 0));
|
|
@@ -211,19 +265,26 @@ async function setup() {
|
|
|
211
265
|
settings.chairman = { ...settings.chairman, keyEnv: keyEnvName(settings.chairman.keyEnv) };
|
|
212
266
|
try { localStorage.setItem('roundtable.settings', JSON.stringify(settings)); } catch {}
|
|
213
267
|
}
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
268
|
+
const accounts = defaultAccounts();
|
|
269
|
+
const migrate = (s) => {
|
|
270
|
+
if (!s || !directVendor(s.vendor) || s.transport === 'cli' || s.account || s.model || s.effort || settings.options?.memory === 'resume' || settings.options?.budget?.[s.vendor]) return s;
|
|
271
|
+
const account = providerProfile(s.vendor, inventory.profiles)?.name
|
|
272
|
+
|| providerChoices().find((p) => p.conventional === s.vendor && !p.configured)?.name;
|
|
273
|
+
return account ? { ...s, vendor: 'acp', account } : s;
|
|
274
|
+
};
|
|
275
|
+
const retained = Array.isArray(saved) ? saved.filter((s) => s && VENDOR_META[s.vendor]).map(migrate) : [];
|
|
276
|
+
S.draft = retained.length >= 2 ? fillMissingSeatLenses(retained) : [accounts[0], (inventory.profiles.length === 1 ? accounts[0] : accounts[1]) || accounts[0]].map((account, i) => newProfileSeat(account, ['risk and failure modes', 'cost and effort'][i]));
|
|
277
|
+
const filled = retained.filter((s) => !String(s.lens || '').trim()).length;
|
|
278
|
+
const setupNote = inventory.error || (filled ? `Added starter lenses to ${filled} unfinished seats.` : retained.some((s) => directVendor(s.vendor) && !s.transport) ? 'Your saved direct CLI settings are selected. Choose an AgentLink profile in the provider menu to switch.' : '');
|
|
279
|
+
$('seat-setup-note').hidden = !setupNote;
|
|
280
|
+
$('seat-setup-note').textContent = setupNote;
|
|
221
281
|
for (const [key, id, scale, min, max] of [
|
|
222
282
|
['critiqueRounds', 'critique-rounds', 1, 0, 8], ['autoContinueMs', 'auto', 1000, 100, 600_000], ['questionWaitMs', 'question-wait', 1000, 100, 600_000], ['wallClockMs', 'wall', 60_000, 60_000, 10_800_000],
|
|
223
283
|
]) {
|
|
224
284
|
const value = settings.options?.[key];
|
|
225
285
|
if (Number.isInteger(value) && value >= min && value <= max) $(id).value = value / scale;
|
|
226
286
|
}
|
|
287
|
+
if (['prefer-ephemeral', 'require-ephemeral', 'provider-default'].includes(settings.options?.providerHistory)) $('provider-history-mode').value = settings.options.providerHistory;
|
|
227
288
|
if (['stateless', 'resume'].includes(settings.options?.memory)) $('memory').value = settings.options.memory;
|
|
228
289
|
$('unattended').checked = settings.options?.unattended === true;
|
|
229
290
|
const research = settings.options?.research;
|
|
@@ -232,52 +293,61 @@ async function setup() {
|
|
|
232
293
|
syncResearchQuery();
|
|
233
294
|
$('notes').addEventListener('input', syncResearchQuery);
|
|
234
295
|
$('research-query-mode').addEventListener('change', () => { syncResearchQuery(); $('research-query').focus(); });
|
|
235
|
-
|
|
296
|
+
let customSearchLimit = research?.maxSearches != null;
|
|
297
|
+
$('research-scopes').value = (research?.sourceScopes || []).join('\n');
|
|
236
298
|
$('research-time').value = (research?.timeoutMs || 120000) / 1000;
|
|
237
299
|
// a new searcher starts on its vendor's lightest model at low effort; a saved one keeps its own
|
|
238
300
|
// (settings saved before the searcher had its own model name none, so they start light too)
|
|
239
301
|
const searchers = [...$('searcher-vendor').options].map((o) => o.value);
|
|
240
302
|
$('searcher-vendor').value = searchers.includes(research?.vendor) ? research.vendor : searchers.includes(DEFAULT_SEARCHER) ? DEFAULT_SEARCHER : searchers[0] || '';
|
|
303
|
+
$('research-searches').value = research?.maxSearches ?? defaultSearchLimit($('searcher-vendor').value);
|
|
241
304
|
const named = !!research && ['model', 'effort', 'account'].some((key) => Object.hasOwn(research, key)) && $('searcher-vendor').value === (research.vendor || DEFAULT_SEARCHER);
|
|
242
305
|
if (named) { $('searcher-model').value = research.model || ''; $('searcher-effort').value = research.effort || ''; } else lightSearcher($('searcher-vendor').value);
|
|
243
306
|
$('add-searcher').disabled = !searchers.length;
|
|
244
307
|
$('searcher-account').value = research?.account || '';
|
|
245
308
|
$('searcher-wrap').hidden = !research; $('add-searcher').hidden = !!research;
|
|
246
|
-
const ch = settings.chairman;
|
|
309
|
+
const ch = migrate(settings.chairman) || { vendor: S.draft[0].vendor, account: S.draft[0].account };
|
|
310
|
+
chair.innerHTML = providerOptions(ch.vendor, ch.account);
|
|
247
311
|
if (ch && VENDOR_META[ch.vendor]) {
|
|
248
|
-
chair.value = ch.vendor;
|
|
249
312
|
for (const field of ['model', 'account', 'endpoint', 'keyEnv']) if (typeof ch[field] === 'string') $(`chairman-${field === 'keyEnv' ? 'keyenv' : field}`).value = ch[field];
|
|
250
313
|
}
|
|
251
314
|
chairEffortOptions();
|
|
315
|
+
if (ch?.effort && isAcp(ch.vendor)) $('chairman-effort').innerHTML = effortOptions(ch.vendor, ch.effort, ch.model, ch.account);
|
|
252
316
|
if (ch?.effort && [...$('chairman-effort').options].some((o) => o.value === ch.effort)) $('chairman-effort').value = ch.effort;
|
|
253
317
|
renderSeats();
|
|
254
318
|
|
|
255
|
-
$('add-seat').addEventListener('click', () => {
|
|
319
|
+
$('add-seat').addEventListener('click', () => {
|
|
320
|
+
clearSetupValidation();
|
|
321
|
+
const accounts = defaultAccounts();
|
|
322
|
+
S.draft.push(newProfileSeat(accounts.find((name) => !S.draft.some((s) => s.vendor === 'acp' && s.account === name)) || accounts[0], nextSeatLens(S.draft)));
|
|
323
|
+
renderSeats();
|
|
324
|
+
});
|
|
256
325
|
$('seats').addEventListener('input', onSeatEdit);
|
|
257
326
|
$('seats').addEventListener('change', onSeatEdit);
|
|
258
327
|
$('seats').addEventListener('click', (ev) => {
|
|
328
|
+
if (ev.target.closest('.profile-models')) {
|
|
329
|
+
const seat = S.draft[Number(ev.target.closest('.seat').dataset.i)];
|
|
330
|
+
void loadProfileModels(seat.account, seat.model, true); return;
|
|
331
|
+
}
|
|
259
332
|
const pip = ev.target.closest('.pip');
|
|
260
333
|
if (pip) {
|
|
261
|
-
|
|
262
|
-
const s = S.draft[Number(pip.closest('.seat').dataset.i)];
|
|
334
|
+
const s = S.draft[Number(pip.closest('.seat').dataset.i)];
|
|
263
335
|
const fam = s.vendor === 'agy' && familyOf('agy', s.model);
|
|
264
336
|
if (fam) Object.assign(s, pickedModel('agy', fam.id, pip.dataset.level)); // a variant is always one level
|
|
265
337
|
else s.effort = s.effort === pip.dataset.level ? '' : pip.dataset.level;
|
|
266
338
|
renderSeats(); return;
|
|
267
339
|
}
|
|
268
340
|
const btn = ev.target.closest('.remove'); if (!btn) return;
|
|
269
|
-
S.initialDraft = null;
|
|
270
341
|
if (S.draft.length <= 2) { $('seats-error').textContent = 'A table needs at least two seats.'; return; }
|
|
271
342
|
S.draft.splice(Number(btn.closest('.seat').dataset.i), 1); renderSeats();
|
|
272
343
|
});
|
|
273
|
-
chair.addEventListener('change', () => {
|
|
274
|
-
|
|
275
|
-
|
|
344
|
+
chair.addEventListener('change', () => {
|
|
345
|
+
$('chairman-account').value = chair.value.startsWith('acp@') ? chair.value.slice(4) : '';
|
|
346
|
+
$('chairman-effort').value = ''; S.customChairModel = false; $('chairman-model').value = ''; chairEffortOptions(); renderChair(); renderProjection(); });
|
|
276
347
|
$('chair-pips').addEventListener('click', (ev) => {
|
|
277
348
|
const pip = ev.target.closest('.pip'); if (!pip) return;
|
|
278
|
-
S.initialChair = false;
|
|
279
349
|
const sel = $('chairman-effort');
|
|
280
|
-
const fam =
|
|
350
|
+
const fam = chairVendor() === 'agy' && familyOf('agy', $('chairman-model').value.trim());
|
|
281
351
|
if (fam) { const p = pickedModel('agy', fam.id, pip.dataset.level); $('chairman-model').value = p.model; sel.value = p.effort; }
|
|
282
352
|
else sel.value = sel.value === pip.dataset.level ? '' : pip.dataset.level; // the filled last pip again: back to default
|
|
283
353
|
renderChair(); renderProjection();
|
|
@@ -287,13 +357,18 @@ async function setup() {
|
|
|
287
357
|
const v = ev.target.value;
|
|
288
358
|
S.customChairModel = v === '__other';
|
|
289
359
|
if (S.customChairModel) { $('chairman-model').value = ''; renderChair(); $('chairman-model').focus(); return; }
|
|
290
|
-
const p = pickedModel(
|
|
291
|
-
$('chairman-model').value = p.model; if (p.effort !== undefined) $('chairman-effort').value = p.effort || '';
|
|
360
|
+
const p = pickedModel(chairVendor(), v, $('chairman-effort').value);
|
|
361
|
+
$('chairman-model').value = p.model; chairEffortOptions(); if (p.effort !== undefined) $('chairman-effort').value = p.effort || '';
|
|
362
|
+
if (isAcp(chairVendor()) && profileChoices.get(chairAccount())?.models) void loadProfileModels(chairAccount(), p.model);
|
|
292
363
|
renderChair(); renderProjection();
|
|
293
364
|
});
|
|
294
|
-
$('
|
|
365
|
+
$('chair-model-discovery').addEventListener('click', (ev) => {
|
|
366
|
+
if (ev.target.closest('.profile-models')) void loadProfileModels(chairAccount(), $('chairman-model').value.trim(), true);
|
|
367
|
+
});
|
|
368
|
+
$('chairman-account').addEventListener('input', () => { if (isAcp(chairVendor())) chair.innerHTML = providerOptions('acp', $('chairman-account').value.trim()); chairEffortOptions(); renderChair(); requestPreflight(); });
|
|
295
369
|
$('chairman').addEventListener('change', () => requestPreflight());
|
|
296
|
-
$('refresh-status').addEventListener('click',
|
|
370
|
+
$('refresh-status').addEventListener('click', refreshConnections);
|
|
371
|
+
$('start-refresh').addEventListener('click', refreshConnections);
|
|
297
372
|
// an endpoint chairman: a preset URL prefills the key variable's usual name (never a key)
|
|
298
373
|
$('chairman-endpoint').addEventListener('change', () => { const pre = ENDPOINT_PRESETS.find((e) => e.url === $('chairman-endpoint').value.trim()); if (pre?.keyEnv && !$('chairman-keyenv').value.trim()) $('chairman-keyenv').value = pre.keyEnv; renderChair(); requestPreflight(); });
|
|
299
374
|
for (const id of ['chairman-endpoint', 'chairman-keyenv']) $(id).addEventListener('input', () => { renderChair(); requestPreflight(); });
|
|
@@ -305,7 +380,12 @@ async function setup() {
|
|
|
305
380
|
$('add-searcher').addEventListener('click', () => { setSearcher(true); $('research-query').focus(); });
|
|
306
381
|
$('remove-searcher').addEventListener('click', () => { setSearcher(false); $('add-searcher').focus(); });
|
|
307
382
|
// another vendor: its own lightest model and login, not the last vendor's
|
|
308
|
-
$('
|
|
383
|
+
$('research-searches').addEventListener('input', () => { customSearchLimit = true; renderProjection(); });
|
|
384
|
+
$('searcher-vendor').addEventListener('change', () => {
|
|
385
|
+
const vendor = $('searcher-vendor').value;
|
|
386
|
+
if (!customSearchLimit) $('research-searches').value = defaultSearchLimit(vendor);
|
|
387
|
+
lightSearcher(vendor); renderSearcher(); renderProjection(); requestPreflight();
|
|
388
|
+
});
|
|
309
389
|
$('searcher-card').addEventListener('change', (ev) => {
|
|
310
390
|
if (ev.target.id !== 'searcher-model-pick') return;
|
|
311
391
|
S.customSearcherModel = ev.target.value === '__other';
|
|
@@ -369,13 +449,74 @@ function poolEntry(vendor, weightedTokens) {
|
|
|
369
449
|
// reports one (codex's config.toml is not a source: the seat runs with --ignore-user-config).
|
|
370
450
|
const defaultEffortLabel = (vendor) => { const d = VENDOR_META[vendor]?.catalogue?.defaultEffort; return d ? `default (${d})` : 'default'; };
|
|
371
451
|
// model: a model that takes fewer levels than its vendor offers (models.js modelEfforts) offers only those
|
|
372
|
-
const
|
|
452
|
+
const profileChoices = new Map();
|
|
453
|
+
function catalogueFor(vendor, account, model = '') {
|
|
454
|
+
if (!isAcp(vendor)) return VENDOR_META[vendor]?.catalogue || {};
|
|
455
|
+
const state = profileChoices.get(account?.trim());
|
|
456
|
+
const defaults = state?.defaults || profileInventory.profiles.find((p) => p.name === account)?.defaults || {};
|
|
457
|
+
const detail = state?.levels.get(model);
|
|
458
|
+
return { models: state?.models || [], efforts: detail?.efforts || [], effortChoices: detail?.effortChoices || [],
|
|
459
|
+
profileModel: state?.profileModel || defaults.model, defaultEffort: detail?.defaultEffort || (!model ? defaults.effort : '') };
|
|
460
|
+
}
|
|
461
|
+
function choiceName(choices, id) {
|
|
462
|
+
return choices?.find((c) => c.id === id)?.label || id;
|
|
463
|
+
}
|
|
464
|
+
function inheritedLabel(value, prefix = 'Profile default') {
|
|
465
|
+
return value ? `${prefix} · ${value}` : prefix;
|
|
466
|
+
}
|
|
467
|
+
function inheritedEffort(cat, model) {
|
|
468
|
+
return inheritedLabel(choiceName(cat.effortChoices, cat.defaultEffort), model && model !== cat.profileModel ? 'Session default' : 'Profile default');
|
|
469
|
+
}
|
|
470
|
+
function levelsFor(vendor, model, account) {
|
|
471
|
+
const cat = catalogueFor(vendor, account, model);
|
|
472
|
+
return modelEfforts(vendor, model, cat.efforts || [], cat.models);
|
|
473
|
+
}
|
|
474
|
+
const effortOptions = (vendor, chosen, model = '', account = '') => {
|
|
475
|
+
const cat = catalogueFor(vendor, account, model);
|
|
476
|
+
const none = isAcp(vendor) ? inheritedEffort(cat, model) : defaultEffortLabel(vendor);
|
|
477
|
+
const levels = levelsFor(vendor, model, account);
|
|
478
|
+
// Retain a saved ACP selection until the user edits it, including before discovery.
|
|
479
|
+
const options = isAcp(vendor) && chosen && !levels.includes(chosen) ? [...levels, chosen] : levels;
|
|
480
|
+
return `<option value="">${esc(none)}</option>` + options.map((e) => `<option value="${esc(e)}" ${e === chosen ? 'selected' : ''}>${esc(choiceName(cat.effortChoices, e))}</option>`).join('');
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
function profileControl(account) {
|
|
484
|
+
if (S.demo) return '<span class="seat-note">Scripted demo profile</span>';
|
|
485
|
+
const name = account?.trim();
|
|
486
|
+
const state = profileChoices.get(name);
|
|
487
|
+
const busy = !!state?.pending.size;
|
|
488
|
+
return `<button class="btn btn-small profile-models" type="button" ${!name || busy ? 'disabled' : ''}>${busy ? 'Reading models…' : state?.models ? 'Refresh profile models' : 'Load profile models'}</button>
|
|
489
|
+
<span class="seat-note" role="status">${esc(state?.message || '')}</span>`;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
async function loadProfileModels(account, model = '', refresh = false) {
|
|
493
|
+
const name = account?.trim();
|
|
494
|
+
if (!name) return;
|
|
495
|
+
let state = profileChoices.get(name);
|
|
496
|
+
if (!state || refresh) {
|
|
497
|
+
state = { levels: new Map(), pending: new Set(), message: '' };
|
|
498
|
+
profileChoices.set(name, state);
|
|
499
|
+
}
|
|
500
|
+
if (state.pending.has(model)) return;
|
|
501
|
+
state.pending.add(model);
|
|
502
|
+
const redraw = () => { chairEffortOptions(); renderChair(); renderSeats(); };
|
|
503
|
+
redraw();
|
|
504
|
+
try {
|
|
505
|
+
const result = await requestJson('/api/profile-models', { account: name, model, allowLimitedIsolation: true }, 45_000);
|
|
506
|
+
state.models = result.models;
|
|
507
|
+
state.defaults = result.defaults;
|
|
508
|
+
state.profileModel = result.profileModel;
|
|
509
|
+
state.levels.set(result.effortModel, result);
|
|
510
|
+
state.message = result.warning || (!result.models.length ? 'This profile offers its default model.' : model && !result.models.some((m) => m.id === model) ? 'The saved model is no longer offered. Choose a listed model or the profile default.' : '');
|
|
511
|
+
} catch (e) { state.message = e.message; }
|
|
512
|
+
finally { state.pending.delete(model); if (profileChoices.get(name) === state) redraw(); }
|
|
513
|
+
}
|
|
373
514
|
|
|
374
515
|
function chairEffortOptions() {
|
|
375
516
|
const sel = $('chairman-effort');
|
|
376
517
|
const keep = sel.value;
|
|
377
|
-
sel.innerHTML = effortOptions(
|
|
378
|
-
$('chairman-model').setAttribute('list', `models-${
|
|
518
|
+
sel.innerHTML = effortOptions(chairVendor(), keep, $('chairman-model').value.trim(), chairAccount());
|
|
519
|
+
$('chairman-model').setAttribute('list', `models-${chairVendor()}`);
|
|
379
520
|
}
|
|
380
521
|
|
|
381
522
|
// A seat's colour is its vendor's (signature-design family accents): rust Claude, olive Codex,
|
|
@@ -385,53 +526,54 @@ const vendorColour = (vendor) => VENDOR_META[vendor]?.colour || 'ink';
|
|
|
385
526
|
// The model picker: capability order, simple names and a separate custom-id mode.
|
|
386
527
|
// Antigravity lists one entry per model; its effort
|
|
387
528
|
// pips pick the variant. Returns { html, other } (other: show the free-text id field).
|
|
388
|
-
const familyOf = (vendor, model) => (VENDOR_META[vendor]?.catalogue?.families || []
|
|
389
|
-
function modelPicker(vendor, value, idAttr = '', custom = false) {
|
|
390
|
-
const cat =
|
|
391
|
-
const models = modelsByCapability(vendor === 'agy' ? cat.families || [] : cat.models || []);
|
|
529
|
+
const familyOf = (vendor, model) => agyFamily(VENDOR_META[vendor]?.catalogue?.families || [], model);
|
|
530
|
+
function modelPicker(vendor, value, idAttr = '', custom = false, account = '') {
|
|
531
|
+
const cat = catalogueFor(vendor, account, value);
|
|
532
|
+
const models = isAcp(vendor) ? cat.models : modelsByCapability(vendor === 'agy' ? cat.families || [] : cat.models || []);
|
|
392
533
|
const selected = vendor === 'agy' ? familyOf(vendor, value)?.id || value : value;
|
|
393
534
|
let current = !value ? '' : models.some((m) => m.id === selected) ? selected : '__other';
|
|
394
535
|
if (custom) current = '__other';
|
|
395
536
|
const opt = (m) => `<option value="${esc(m.id)}" ${m.id === current ? 'selected' : ''}>${esc(m.label)}${m.note ? ` · ${esc(m.note)}` : ''}</option>`;
|
|
396
|
-
const html = `<select class="flat model-pick" ${idAttr} aria-label="Model"><option value=""
|
|
537
|
+
const html = `<select class="flat model-pick" ${idAttr} aria-label="Model"><option value="">${esc(isAcp(vendor) ? inheritedLabel(choiceName(models, cat.profileModel)) : 'default')}</option>${models.length ? `<optgroup label="${isAcp(vendor) ? 'Profile models' : 'Models · most capable first'}">${models.map(opt).join('')}</optgroup>` : ''}<option value="__other" ${current === '__other' ? 'selected' : ''}>Custom model ID…</option></select>`;
|
|
397
538
|
return { html, other: current === '__other' };
|
|
398
539
|
}
|
|
399
540
|
// A picked model as the id to send: an Antigravity model takes its effort as the suffix.
|
|
400
541
|
function pickedModel(vendor, picked, effort) {
|
|
542
|
+
if (isAcp(vendor)) return { model: picked, effort: '' };
|
|
401
543
|
// a level the newly picked model does not take is dropped, back to the CLI's default
|
|
402
|
-
if (vendor !== 'agy' || !picked) return { model: picked, effort: effort && !
|
|
403
|
-
|
|
404
|
-
const level = fam?.levels.includes(effort) ? effort : fam?.levels.includes('medium') ? 'medium' : fam?.levels[0];
|
|
405
|
-
return { model: level ? `${picked}-${level}` : picked, effort: level || '' };
|
|
544
|
+
if (vendor !== 'agy' || !picked) return { model: picked, effort: effort && !levelsFor(vendor, picked).includes(effort) ? '' : effort };
|
|
545
|
+
return agySelection(familyOf(vendor, picked), picked, effort);
|
|
406
546
|
}
|
|
407
547
|
|
|
408
548
|
// Effort as pips, one per level the CLI accepts; none filled is the CLI's own default. An
|
|
409
549
|
// Antigravity model offers the levels its id comes in.
|
|
410
|
-
function pipsHtml(vendor, chosen, model = '') {
|
|
411
|
-
const levels = (vendor === 'agy' && familyOf(vendor, model)?.levels) ||
|
|
550
|
+
function pipsHtml(vendor, chosen, model = '', account = '') {
|
|
551
|
+
const levels = (vendor === 'agy' && familyOf(vendor, model)?.levels) || levelsFor(vendor, model, account);
|
|
552
|
+
const cat = catalogueFor(vendor, account, model);
|
|
553
|
+
const label = (id) => choiceName(cat.effortChoices, id);
|
|
412
554
|
const at = levels.indexOf(chosen);
|
|
413
|
-
return '<span class="pip-buttons">' + levels.map((l, i) => `<button type="button" class="pip ${i <= at ? 'on' : ''}" data-level="${l}" title="${l}" aria-label="Effort ${l}" aria-pressed="${l === chosen}"></button>`).join('') + '</span>'
|
|
414
|
-
+ `<span class="pip-label">${esc(chosen
|
|
555
|
+
return '<span class="pip-buttons">' + levels.map((l, i) => `<button type="button" class="pip ${i <= at ? 'on' : ''}" data-level="${esc(l)}" title="${esc(label(l) === l ? l : label(l) + ' (' + l + ')')}" aria-label="Effort ${esc(label(l))}" aria-pressed="${l === chosen}"></button>`).join('') + '</span>'
|
|
556
|
+
+ `<span class="pip-label">${esc(chosen ? label(chosen) : isAcp(vendor) ? inheritedEffort(cat, model) : defaultEffortLabel(vendor))}</span>`;
|
|
415
557
|
}
|
|
416
558
|
|
|
417
559
|
// The lamp: the pre-flight answer for the seat's pool when there is one (installed, logged in,
|
|
418
560
|
// quota; authenticated POST /api/preflight), else what the quota alone says. model: the seat's,
|
|
419
561
|
// for a quota in groups (agy), where only its group's windows count. The server's answer is for
|
|
420
562
|
// the whole pool, so its quota part is redone here with the latest figure for this model.
|
|
421
|
-
function poolLamp(vendor, account, model = '') {
|
|
563
|
+
function poolLamp(vendor, account, model = '', showChecking = true) {
|
|
422
564
|
const terms = VENDOR_META[vendor]?.terms;
|
|
423
565
|
if (terms && !terms.acknowledgedAt) return { cls: 'warn', kind: 'terms', note: 'Review the account notice before using this provider.' };
|
|
424
566
|
const key = poolKey(vendor, account, !!VENDOR_META[vendor]?.profiles);
|
|
425
567
|
const pf = S.preflight[key];
|
|
426
568
|
const q = S.quota[key];
|
|
427
|
-
if (S.preflighting) return { cls: 'idle', note: 'checking…' };
|
|
569
|
+
if (showChecking && S.preflighting) return { cls: 'idle', note: 'checking…' };
|
|
428
570
|
if (pf) {
|
|
429
571
|
const own = q && pf.installed && pf.loggedIn !== false && !['busy', 'check-failed'].includes(pf.kind)
|
|
430
572
|
? preflightLamp({ vendor, installed: true, loggedIn: pf.loggedIn, quota: q, account, model }) : null;
|
|
431
573
|
const at = own ? { ...pf, ...own } : pf;
|
|
432
574
|
const stale = pf.stale || pf.checkedAt != null && Date.now() - pf.checkedAt >= PREFLIGHT_TTL_MS;
|
|
433
575
|
return { cls: stale && at.state === 'ok' ? 'warn' : at.state,
|
|
434
|
-
note: at.note + (stale && pf.checkedAt != null ? ' · refresh status' : ''), kind: at.kind };
|
|
576
|
+
note: at.note + (stale && pf.checkedAt != null && !['auth', 'unknown'].includes(at.kind) ? ' · refresh status' : ''), kind: at.kind };
|
|
435
577
|
}
|
|
436
578
|
if (!quotaWindows(q, [model]).length) return { cls: 'idle', note: 'not checked yet' };
|
|
437
579
|
const own = preflightLamp({ vendor, installed: true, loggedIn: null, quota: q, account, model });
|
|
@@ -445,7 +587,7 @@ function lockHidden(s) {
|
|
|
445
587
|
if (isAcp(s.vendor)) { s.effort = ''; return; }
|
|
446
588
|
s.customModel = false;
|
|
447
589
|
const lightest = lightestModel(s.vendor, VENDOR_META[s.vendor]?.catalogue?.models);
|
|
448
|
-
|
|
590
|
+
s.model = lightest || (isApi(s.vendor) ? s.model : '');
|
|
449
591
|
s.effort = 'low';
|
|
450
592
|
}
|
|
451
593
|
|
|
@@ -457,7 +599,7 @@ function seatRow(s, i) {
|
|
|
457
599
|
const n = same.length > 1 ? ` ${same.indexOf(s) + 1}` : '';
|
|
458
600
|
const lamp = poolLamp(s.vendor, seatAccount(s), s.model);
|
|
459
601
|
// an endpoint seat has no catalogue: the model id is typed, and the card says it is required
|
|
460
|
-
const picker = api ? { html: '', other: true } : modelPicker(s.vendor, s.model || '', '', s.customModel);
|
|
602
|
+
const picker = api ? { html: '', other: true } : modelPicker(s.vendor, s.model || '', '', s.customModel, s.account);
|
|
461
603
|
const gone = retired(s.vendor, (s.model || '').trim());
|
|
462
604
|
const issue = S.seatIssue?.seatIndex === i ? S.seatIssue : null;
|
|
463
605
|
const invalid = (field) => issue?.field === field ? 'aria-invalid="true"' : '';
|
|
@@ -465,7 +607,7 @@ function seatRow(s, i) {
|
|
|
465
607
|
<div class="seat-hd">
|
|
466
608
|
<span class="avatar" title="${esc(s.mood === 'custom' ? 'custom mood' : s.mood)}">${avatar(hidden ? hidden.art : s.mood === 'custom' ? 'custom' : s.mood, hidden?.sprite)}</span>
|
|
467
609
|
<div class="seat-id">
|
|
468
|
-
<span class="chair-title"><select class="flat vendor" aria-label="Vendor">${
|
|
610
|
+
<span class="chair-title"><select class="flat vendor" aria-label="Vendor">${providerOptions(s.vendor, s.account)}</select>${n ? `<span class="seat-note">${n.trim()}</span>` : ''}<span class="kind-tag ${api ? 'api' : ''}" title="${api ? 'Billed by the endpoint, not a subscription' : isAcp(s.vendor) ? 'Billing belongs to the selected AgentLink profile' : 'The vendor CLI on your subscription'}">${esc(seatKind(VENDOR_META[s.vendor], s.endpoint))}</span></span>
|
|
469
611
|
${hidden && !api ? picker.html.replace('<select', '<select disabled title="Locked to the lightest model"') : picker.html}<input class="flat model" aria-label="Model id" list="models-${s.vendor}" value="${esc(s.model)}" placeholder="${api ? 'model id (required)' : 'model id'}" ${picker.other ? '' : 'hidden'}>
|
|
470
612
|
</div>
|
|
471
613
|
<span class="lamp ${lamp.cls}" title="${esc(lamp.note)}"></span>
|
|
@@ -480,10 +622,10 @@ function seatRow(s, i) {
|
|
|
480
622
|
${gone ? `<span class="seat-note danger">${esc(s.model)} was retired (${esc(gone.date)}); use ${esc(gone.instead)}.</span>` : ''}
|
|
481
623
|
${api ? `<label class="f"><span class="label">Endpoint</span><input class="flat endpoint" aria-label="Endpoint base URL" list="endpoints" value="${esc(s.endpoint || '')}" placeholder="http://localhost:11434/v1" title="The base URL of an OpenAI-compatible server, ending in /v1. Plain http only on this machine or a private network."></label>
|
|
482
624
|
<label class="f"><span class="label">Key var</span><input class="flat keyenv" aria-label="Key environment variable" value="${esc(s.keyEnv || '')}" placeholder="none (local server)" title="The NAME of the environment variable that holds the key, set in the shell roundtable was started from. Never the key itself."></label>` : ''}
|
|
483
|
-
<div class="f"><span class="label help-label" data-help="effort" tabindex="0" aria-describedby="help-effort">Effort</span><span class="pips ${hidden ? 'locked' : ''}">${pipsHtml(s.vendor, s.effort, s.model)}</span><select class="effort" hidden>${effortOptions(s.vendor, s.effort, s.model)}</select></div>
|
|
625
|
+
<div class="f"><span class="label help-label" data-help="effort" tabindex="0" aria-describedby="help-effort">Effort</span><span class="pips ${hidden ? 'locked' : ''}">${pipsHtml(s.vendor, s.effort, s.model, s.account)}</span><select class="effort" hidden>${effortOptions(s.vendor, s.effort, s.model, s.account)}</select></div>
|
|
484
626
|
<span class="seat-note lamp-note ${lamp.cls === 'danger' || lamp.cls === 'warn' ? lamp.cls : ''}" title="${esc(lamp.note)}" tabindex="0">${esc(lamp.note)}</span>
|
|
485
627
|
${cardNotices(s.vendor)}
|
|
486
|
-
${api ? '' : `<details class="seat-more" ${isAcp(s.vendor) ? 'open' : ''}><summary>${isAcp(s.vendor) ? 'AgentLink profile (required)' : 'Login profile'}${s.account ? `: ${esc(s.account)}` : ''}</summary><input class="flat account" aria-label="${isAcp(s.vendor) ? 'AgentLink profile' : 'Login profile'}" value="${esc(s.account || '')}" placeholder="${isAcp(s.vendor) ? 'saved profile name' : 'none: your usual login'}" title="${isAcp(s.vendor) ? 'A profile already configured centrally in AgentLink' : 'A second login of this CLI; node src/doctor.js shows how to log a profile in'}"
|
|
628
|
+
${api ? '' : `<details class="seat-more" ${isAcp(s.vendor) ? 'open' : ''}><summary>${isAcp(s.vendor) ? 'AgentLink profile (required)' : 'Login profile'}${s.account ? `: ${esc(s.account)}` : ''}</summary><input class="flat account" aria-label="${isAcp(s.vendor) ? 'AgentLink profile' : 'Login profile'}" value="${esc(s.account || '')}" placeholder="${isAcp(s.vendor) ? 'saved profile name' : 'none: your usual login'}" title="${isAcp(s.vendor) ? 'A profile already configured centrally in AgentLink' : 'A second login of this CLI; node src/doctor.js shows how to log a profile in'}">${isAcp(s.vendor) ? profileControl(s.account) : ''}</details>`}
|
|
487
629
|
</div>
|
|
488
630
|
</article>`;
|
|
489
631
|
}
|
|
@@ -496,10 +638,9 @@ function requestPreflight({ fresh = false } = {}) {
|
|
|
496
638
|
const revision = ++preflightRevision;
|
|
497
639
|
clearTimeout(preflightTimer);
|
|
498
640
|
preflightTimer = setTimeout(async () => {
|
|
499
|
-
const seats = [...S.draft, { vendor:
|
|
641
|
+
const seats = [...S.draft, { vendor: chairVendor(), account: $('chairman-account').value.trim(), endpoint: $('chairman-endpoint').value, keyEnv: $('chairman-keyenv').value }];
|
|
500
642
|
if (searcherOn()) seats.push(draftSearcher());
|
|
501
|
-
const keys = [...new Set(
|
|
502
|
-
...(S.initialDraft ? Object.keys(VENDOR_META).filter((v) => !isApi(v)) : [])])];
|
|
643
|
+
const keys = [...new Set(seats.map((s) => poolKey(s.vendor, seatAccount(s), !!VENDOR_META[s.vendor]?.profiles)))];
|
|
503
644
|
// an API pool is checked from its URL and key-variable NAME (no request leaves the server);
|
|
504
645
|
// those travel in the body, so its lamp follows every edit
|
|
505
646
|
const endpoints = {};
|
|
@@ -520,22 +661,10 @@ function requestPreflight({ fresh = false } = {}) {
|
|
|
520
661
|
S.preflight[p.key] = p;
|
|
521
662
|
if (p.quota && (p.quota.at ?? 0) >= (S.quota[p.key]?.at ?? 0)) S.quota[p.key] = p.quota;
|
|
522
663
|
}
|
|
523
|
-
if (S.initialDraft) {
|
|
524
|
-
const unchanged = JSON.stringify(S.draft) === S.initialDraft;
|
|
525
|
-
S.initialDraft = null; // choose once; a refresh never replaces an existing table
|
|
526
|
-
if (unchanged) {
|
|
527
|
-
const chosen = initialDraft(initialSeatVendors(Object.entries(VENDOR_META).map(([vendor, meta]) => ({ vendor, ...meta })), pools));
|
|
528
|
-
if (JSON.stringify(chosen) !== JSON.stringify(S.draft)) {
|
|
529
|
-
S.draft = chosen;
|
|
530
|
-
if (S.initialChair && chosen.length) { $('chairman').value = chosen[0].vendor; chairEffortOptions(); }
|
|
531
|
-
S.preflighting = false; renderSeats(); renderChair(); return;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
664
|
} catch (e) {
|
|
536
665
|
if (revision === preflightRevision) S.preflightError = e.message || 'Could not refresh status. Try Refresh status again.';
|
|
537
666
|
} finally {
|
|
538
|
-
if (revision === preflightRevision) { S.preflighting = false; updateLamps(); }
|
|
667
|
+
if (revision === preflightRevision) { S.preflighting = false; updateLamps(); updateProjectionReadings(); }
|
|
539
668
|
}
|
|
540
669
|
}, 400);
|
|
541
670
|
}
|
|
@@ -552,16 +681,21 @@ function updateLamps() {
|
|
|
552
681
|
const note = card.querySelector('.lamp-note');
|
|
553
682
|
if (note) { note.textContent = l.note; note.title = l.note; note.className = `seat-note lamp-note ${l.cls === 'danger' || l.cls === 'warn' ? l.cls : ''}`; }
|
|
554
683
|
});
|
|
555
|
-
const c = poolLamp(
|
|
684
|
+
const c = poolLamp(chairVendor(), chairAccount(), $('chairman-model').value.trim());
|
|
556
685
|
$('chair-lamp').className = `lamp ${c.cls}`; $('chair-lamp').title = c.note;
|
|
557
686
|
$('chair-note').textContent = c.note; $('chair-note').title = c.note; $('chair-note').className = `seat-note lamp-note ${c.cls === 'danger' || c.cls === 'warn' ? c.cls : ''}`;
|
|
558
|
-
S.startConfirm
|
|
687
|
+
if (S.startConfirm && $('setup-error').textContent === S.startConfirm) $('setup-error').textContent = '';
|
|
688
|
+
S.startConfirm = null;
|
|
689
|
+
$('start-refresh').hidden = true;
|
|
690
|
+
$('start').disabled = !!S.startPending;
|
|
691
|
+
$('start').textContent = S.startPending ? 'Opening…' : 'Open the table';
|
|
559
692
|
}
|
|
560
693
|
|
|
561
694
|
// The chairman card: vendor colour, the gavel, effort pips; its controls keep their ids.
|
|
562
695
|
function renderChair() {
|
|
563
696
|
const restoreFocus = rememberFocus($('chair-card'));
|
|
564
|
-
const v =
|
|
697
|
+
const v = chairVendor();
|
|
698
|
+
void loadDirectCatalogue(v);
|
|
565
699
|
const card = $('chair-card');
|
|
566
700
|
card.style.setProperty('--seat', `var(--seat-${vendorColour(v)})`);
|
|
567
701
|
$('chair-avatar').innerHTML = avatar('chairman');
|
|
@@ -573,11 +707,12 @@ function renderChair() {
|
|
|
573
707
|
$('chair-profile').open = isAcp(v);
|
|
574
708
|
$('chairman-account').placeholder = isAcp(v) ? 'saved profile name' : 'none: your usual login';
|
|
575
709
|
$('chairman-account').setAttribute('aria-label', isAcp(v) ? 'Chairman AgentLink profile' : 'Chairman login profile');
|
|
576
|
-
const picker = api ? { html: '', other: true } : modelPicker(v, $('chairman-model').value.trim(), 'id="chair-model-pick"', S.customChairModel);
|
|
710
|
+
const picker = api ? { html: '', other: true } : modelPicker(v, $('chairman-model').value.trim(), 'id="chair-model-pick"', S.customChairModel, chairAccount());
|
|
577
711
|
$('chair-model-slot').innerHTML = picker.html;
|
|
578
712
|
$('chairman-model').hidden = !picker.other;
|
|
579
713
|
$('chairman-model').placeholder = api ? 'model id (required)' : 'model id';
|
|
580
|
-
$('chair-pips').innerHTML = pipsHtml(v, $('chairman-effort').value, $('chairman-model').value.trim());
|
|
714
|
+
$('chair-pips').innerHTML = pipsHtml(v, $('chairman-effort').value, $('chairman-model').value.trim(), chairAccount());
|
|
715
|
+
$('chair-model-discovery').innerHTML = isAcp(v) ? profileControl(chairAccount()) : '';
|
|
581
716
|
$('chair-iso').innerHTML = cardNotices(v);
|
|
582
717
|
updateLamps();
|
|
583
718
|
restoreFocus();
|
|
@@ -586,7 +721,7 @@ function renderChair() {
|
|
|
586
721
|
// Antigravity cannot be sealed off (config.js limitedIsolation). The card that runs on it says so,
|
|
587
722
|
// its tip explains, and choosing it there is the consent the board sends (isolationAccepted).
|
|
588
723
|
// An agent request has no card, so it must send options.allowLimitedIsolation itself.
|
|
589
|
-
const isoNote = (vendor) => (VENDOR_META[vendor]?.limitedIsolation
|
|
724
|
+
const isoNote = (vendor) => (!S.demo && VENDOR_META[vendor]?.limitedIsolation
|
|
590
725
|
? isAcp(vendor) ? '<span class="seat-note warn iso-note">Limited isolation: the profile owns tools, customization and billing. Use a trusted profile with tools disabled. Stateless memory only; missing token usage stops further seat calls.</span>'
|
|
591
726
|
: '<span class="seat-note warn iso-note help-label" data-help="isolation" tabindex="0" aria-describedby="help-isolation">Limited isolation: your Antigravity customizations and MCP servers still load</span>' : '');
|
|
592
727
|
const isolationAccepted = () => [...draftSeats(), draftChairman(), searcherOn() ? draftSearcher() : null].some((s) => VENDOR_META[s?.vendor]?.limitedIsolation);
|
|
@@ -668,11 +803,10 @@ $('vendor-terms').addEventListener('cancel', (event) => { if ($('vendor-terms-ca
|
|
|
668
803
|
// Not a seat: one call before round 0 that gathers cited sources from its visible query. A card
|
|
669
804
|
// next to the chairman's, added and removed like a seat, with its own vendor, model, effort and
|
|
670
805
|
// login. The vendor list holds only CLIs that can search with every other tool off (/api/seats).
|
|
671
|
-
const DEFAULT_SEARCHER = 'codex'; // research.js: what an agent request without a vendor gets
|
|
672
806
|
const searcherOn = () => !$('searcher-wrap').hidden;
|
|
673
807
|
const searcherAccount = () => (VENDOR_META[$('searcher-vendor').value]?.profiles ? $('searcher-account').value.trim() : '');
|
|
674
808
|
function draftSearcher() {
|
|
675
|
-
return { vendor: $('searcher-vendor').value, model: $('searcher-model').value.trim() || undefined, effort: $('searcher-effort').value || undefined, account: searcherAccount() || undefined };
|
|
809
|
+
return { vendor: $('searcher-vendor').value, maxSearches: Number($('research-searches').value), model: $('searcher-model').value.trim() || undefined, effort: $('searcher-effort').value || undefined, account: searcherAccount() || undefined };
|
|
676
810
|
}
|
|
677
811
|
// The lightest model at low effort: finding and quoting sources needs little reasoning. An
|
|
678
812
|
// Antigravity id carries its level, so its "low" is part of the model.
|
|
@@ -701,6 +835,7 @@ function renderSearcher() {
|
|
|
701
835
|
if (!searcherOn()) return;
|
|
702
836
|
const restoreFocus = rememberFocus($('searcher-card'));
|
|
703
837
|
const v = $('searcher-vendor').value;
|
|
838
|
+
void loadDirectCatalogue(v);
|
|
704
839
|
$('searcher-card').style.setProperty('--seat', `var(--seat-${vendorColour(v)})`);
|
|
705
840
|
$('searcher-avatar').innerHTML = avatar('searcher');
|
|
706
841
|
$('searcher-profile').hidden = !VENDOR_META[v]?.profiles; // no login profiles for a CLI without a state directory
|
|
@@ -773,6 +908,7 @@ function rememberFocus(root) {
|
|
|
773
908
|
};
|
|
774
909
|
}
|
|
775
910
|
function renderSeats() {
|
|
911
|
+
for (const s of S.draft) void loadDirectCatalogue(s.vendor);
|
|
776
912
|
helpNotes.close();
|
|
777
913
|
const restoreFocus = rememberFocus($('seats'));
|
|
778
914
|
$('seats').innerHTML = S.draft.map(seatRow).join('');
|
|
@@ -784,7 +920,6 @@ function renderSeats() {
|
|
|
784
920
|
function onSeatEdit(ev) {
|
|
785
921
|
const row = ev.target.closest('.seat'); if (!row) return;
|
|
786
922
|
clearSetupValidation();
|
|
787
|
-
S.initialDraft = null;
|
|
788
923
|
const s = S.draft[Number(row.dataset.i)];
|
|
789
924
|
if (ev.target.classList.contains('model-pick')) {
|
|
790
925
|
if (ev.type !== 'change') return;
|
|
@@ -792,10 +927,16 @@ function onSeatEdit(ev) {
|
|
|
792
927
|
s.customModel = v === '__other';
|
|
793
928
|
if (s.customModel) { s.model = ''; renderSeats(); $('seats').querySelectorAll('.seat')[S.draft.indexOf(s)]?.querySelector('.model')?.focus(); return; }
|
|
794
929
|
Object.assign(s, pickedModel(s.vendor, v, s.effort));
|
|
930
|
+
if (isAcp(s.vendor) && profileChoices.get(s.account?.trim())?.models) void loadProfileModels(s.account, s.model);
|
|
795
931
|
renderSeats(); renderProjection(); return;
|
|
796
932
|
}
|
|
797
|
-
|
|
798
|
-
|
|
933
|
+
if (ev.target.classList.contains('vendor')) {
|
|
934
|
+
if (ev.type !== 'change') return;
|
|
935
|
+
const choice = ev.target.value;
|
|
936
|
+
delete s.transport;
|
|
937
|
+
Object.assign(s, { vendor: rawVendor(choice), account: choice.startsWith('acp@') ? choice.slice(4) : '', customModel: false, model: '', effort: '' });
|
|
938
|
+
lockHidden(s); renderSeats(); return;
|
|
939
|
+
}
|
|
799
940
|
s.lens = row.querySelector('.lens').value;
|
|
800
941
|
s.mood = row.querySelector('.mood').value;
|
|
801
942
|
s.moodText = row.querySelector('.mood-text').value;
|
|
@@ -809,7 +950,6 @@ function onSeatEdit(ev) {
|
|
|
809
950
|
const pre = ev.type === 'change' && ev.target.classList.contains('endpoint') && ENDPOINT_PRESETS.find((e) => e.url === s.endpoint.trim());
|
|
810
951
|
if (pre?.keyEnv && !s.keyEnv.trim()) s.keyEnv = pre.keyEnv;
|
|
811
952
|
}
|
|
812
|
-
if (s.vendor !== vendorBefore) { s.customModel = false; s.model = ''; s.effort = ''; lockHidden(s); renderSeats(); return; } // the catalogue changed
|
|
813
953
|
if (ev.type === 'change' && (ev.target.classList.contains('mood-text') || ev.target.classList.contains('mood'))) lockHidden(s);
|
|
814
954
|
if (ev.type === 'change' && ev.target.classList.contains('mood-text')) { renderSeats(); renderProjection(); return; }
|
|
815
955
|
// the avatar follows the mood, the lamp the login profile or the endpoint: redraw the cards (not while typing)
|
|
@@ -818,8 +958,8 @@ function onSeatEdit(ev) {
|
|
|
818
958
|
row.querySelector('.mood-text').hidden = s.mood !== 'custom';
|
|
819
959
|
if (ev.target.classList.contains('model')) {
|
|
820
960
|
// a typed id: drop a level that model does not take, and redraw its pips
|
|
821
|
-
if (s.vendor !== 'agy' && s.effort && !
|
|
822
|
-
const pips = row.querySelector('.pips'); if (pips) pips.innerHTML = pipsHtml(s.vendor, s.effort, s.model);
|
|
961
|
+
if (s.vendor !== 'agy' && !isAcp(s.vendor) && s.effort && !levelsFor(s.vendor, s.model).includes(s.effort)) { s.effort = ''; row.querySelector('.effort').value = ''; }
|
|
962
|
+
const pips = row.querySelector('.pips'); if (pips) pips.innerHTML = pipsHtml(s.vendor, s.effort, s.model, s.account);
|
|
823
963
|
updateLamps(); // agy: the lamp follows the model's quota group
|
|
824
964
|
}
|
|
825
965
|
renderProjection();
|
|
@@ -827,7 +967,7 @@ function onSeatEdit(ev) {
|
|
|
827
967
|
|
|
828
968
|
function draftSeats() {
|
|
829
969
|
return S.draft.map((s, i) => ({
|
|
830
|
-
vendor: s.vendor, lens: s.lens.trim(), colour: vendorColour(s.vendor),
|
|
970
|
+
vendor: s.vendor, ...directTransport(s.vendor), lens: s.lens.trim(), colour: vendorColour(s.vendor),
|
|
831
971
|
mood: s.mood === 'custom' ? { preset: 'custom', text: s.moodText.trim() } : { preset: s.mood },
|
|
832
972
|
model: s.model.trim() || undefined, effort: s.effort || undefined, account: seatAccount(s) || undefined,
|
|
833
973
|
...(isApi(s.vendor) ? { endpoint: (s.endpoint || '').trim(), keyEnv: (s.keyEnv || '').trim() || undefined } : {}),
|
|
@@ -836,8 +976,8 @@ function draftSeats() {
|
|
|
836
976
|
// The chairman as the server takes it (normaliseChairman): an endpoint chairman carries its URL,
|
|
837
977
|
// key variable name and host-derived account, like a seat.
|
|
838
978
|
function draftChairman() {
|
|
839
|
-
const vendor =
|
|
840
|
-
return { vendor, model: $('chairman-model').value.trim() || undefined, effort: $('chairman-effort').value || undefined, account: chairAccount() || undefined,
|
|
979
|
+
const vendor = chairVendor();
|
|
980
|
+
return { vendor, ...directTransport(vendor), model: $('chairman-model').value.trim() || undefined, effort: $('chairman-effort').value || undefined, account: chairAccount() || undefined,
|
|
841
981
|
...(isApi(vendor) ? { endpoint: $('chairman-endpoint').value.trim(), keyEnv: $('chairman-keyenv').value.trim() || undefined } : {}) };
|
|
842
982
|
}
|
|
843
983
|
|
|
@@ -911,27 +1051,54 @@ const usageLink = (key) => { const m = VENDOR_META[poolVendor(key)]; return m?.u
|
|
|
911
1051
|
|
|
912
1052
|
// One block per vendor pool: live windows, the projected draw for this table stacked per seat,
|
|
913
1053
|
// and the measured per-round share where a calibration exists.
|
|
914
|
-
function
|
|
1054
|
+
function draftProjection() {
|
|
915
1055
|
const seats = draftSeats().map((s, i) => ({ ...s, id: `seat-${i}` }));
|
|
916
1056
|
const chairman = draftChairman();
|
|
917
|
-
const p = project({ seats, chairman, critiqueRounds: Number($('critique-rounds').value) || 0, baselines: BASELINES, memory: $('memory').value, research: searcherOn() ? draftSearcher() : null });
|
|
918
1057
|
const researcher = draftSearcher();
|
|
1058
|
+
const p = project({ seats, chairman, critiqueRounds: Number($('critique-rounds').value) || 0, baselines: BASELINES, memory: $('memory').value, research: searcherOn() ? researcher : null });
|
|
1059
|
+
const seatOf = (id) => (id === 'chairman' ? chairman : id === 'research' ? researcher : seats[Number(id.slice(5))]);
|
|
1060
|
+
return { seats, chairman, researcher, p, seatOf };
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// A completed status refresh updates the readings in place, preserving cap and manual quota inputs.
|
|
1064
|
+
function updateProjectionReadings({ p, seatOf } = draftProjection()) {
|
|
1065
|
+
for (const section of $('projection').querySelectorAll('.pool-window-section')) {
|
|
1066
|
+
const { vendor, pool } = section.dataset;
|
|
1067
|
+
const v = p.byVendor[vendor];
|
|
1068
|
+
if (!v) continue;
|
|
1069
|
+
const reading = section.querySelector('.pool-reading');
|
|
1070
|
+
const manual = section.querySelector('.pool-manual');
|
|
1071
|
+
const pf = S.preflight[pool];
|
|
1072
|
+
section.closest('.pool').querySelector('.pool-id span').hidden = pf?.loggedIn === false;
|
|
1073
|
+
if (!pool || pf?.loggedIn === false) {
|
|
1074
|
+
reading.textContent = pool ? 'Signed out at the last check. Current account quota is unavailable.' : 'Multiple profiles selected. Check each seat for its account status.';
|
|
1075
|
+
manual.hidden = false;
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
const pw = projectedWindows(S.calib, pool, v.seats.map((id) => p.bySeat[id])) || [];
|
|
1079
|
+
const windows = quotaWindows(S.quota[pool], v.seats.map((id) => seatOf(id)?.model || ''));
|
|
1080
|
+
manual.hidden = windows.length > 0;
|
|
1081
|
+
if (windows.length) {
|
|
1082
|
+
const estimates = windows.map((w) => { const x = pw.find((y) => y.label === w.label); return { ...w, adds: x?.pct ?? null, upper: !!x?.upperBound }; });
|
|
1083
|
+
const at = S.quota[pool]?.at;
|
|
1084
|
+
reading.innerHTML = `Usage reported${Number.isFinite(at) ? ' ' + agoText(at) : ' by provider'}<div class="readouts">${readouts(pool, estimates)}</div>`;
|
|
1085
|
+
} else {
|
|
1086
|
+
const estimates = pw.map((w) => w.upperBound
|
|
1087
|
+
? `Past reviews used ${k(w.pending)} tokens without a measurable change in the ${w.label} window.`
|
|
1088
|
+
: `This review may use about ${pct(w.pct)} of the ${w.label} window.`);
|
|
1089
|
+
reading.textContent = ['Current quota unavailable.', ...estimates].join(' ');
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
function renderProjection() {
|
|
1095
|
+
const draft = draftProjection();
|
|
1096
|
+
const { seats, chairman, researcher, p, seatOf } = draft;
|
|
919
1097
|
const label = (id) => (id === 'chairman' ? 'chairman' : id === 'research' ? 'searcher' : `${seats[Number(id.slice(5))]?.lens || id}`);
|
|
920
1098
|
const colourOf = (id) => (id === 'chairman' ? vendorColour(chairman.vendor) : id === 'research' ? vendorColour(researcher.vendor) : seats[Number(id.slice(5))]?.colour || 'ink');
|
|
921
1099
|
$('projection').innerHTML = Object.values(p.byVendor).map((v) => {
|
|
922
|
-
// the vendor's seats all on one account: that account's pool; mixed: the default one
|
|
923
|
-
const seatOf = (id) => (id === 'chairman' ? chairman : id === 'research' ? researcher : seats[Number(id.slice(5))]);
|
|
924
1100
|
const keys = new Set(v.seats.map((id) => seatPool(seatOf(id))));
|
|
925
|
-
const pool = keys.size === 1 ? [...keys][0] :
|
|
926
|
-
const q = S.quota[pool];
|
|
927
|
-
const pw = projectedWindows(S.calib, pool, v.seats.map((id) => p.bySeat[id])) || [];
|
|
928
|
-
// Live windows carry this debate's projected draw; without a live figure the projection is
|
|
929
|
-
// all there is, so it stays a sentence. A quota in groups (agy) shows the seated models' groups.
|
|
930
|
-
const windows = q ? quotaWindows(q, v.seats.map((id) => seatOf(id)?.model || '')).map((w) => { const x = pw.find((y) => y.label === w.label); return { ...w, adds: x ? x.pct : null, upper: !!x?.upperBound }; }) : [];
|
|
931
|
-
const projected = q ? '' : pw.length ? pw.map((w) => (w.upperBound
|
|
932
|
-
? `No movement of the ${esc(w.label)} window seen over ${k(w.pending)} tokens yet.`
|
|
933
|
-
: `About +${pct(w.pct)} of the ${esc(w.label)} window (${w.samples} measured move${w.samples === 1 ? '' : 's'}).`)).join(' ')
|
|
934
|
-
: 'Window share is unmeasured until a debate runs.';
|
|
1101
|
+
const pool = keys.size === 1 ? [...keys][0] : '';
|
|
935
1102
|
const cap = S.budget[v.vendor];
|
|
936
1103
|
// Seats of one vendor share its colour, so each segment of the bar gets its own shade and the
|
|
937
1104
|
// chairman a hatch; the legend beside each seat uses the same fill, so the split reads.
|
|
@@ -939,27 +1106,31 @@ function renderProjection() {
|
|
|
939
1106
|
const segments = v.seats.filter((id) => id !== 'chairman');
|
|
940
1107
|
const order = [...segments, ...v.seats.filter((id) => id === 'chairman')];
|
|
941
1108
|
return `<div class="pool">
|
|
942
|
-
<div class="pool-top">${poolId(pool)}<div class="pool-total"><b>≈ ${k(v.total)}</b><span>tokens${v.cost != null ? ` · ≈ $${v.cost.toFixed(2)}` : ''}</span></div></div>
|
|
1109
|
+
<div class="pool-top">${poolId(pool || v.vendor)}<div class="pool-total"><b>≈ ${k(v.total)}</b><span>estimated tokens${v.cost != null ? ` · ≈ $${v.cost.toFixed(2)}` : ''}</span></div></div>
|
|
943
1110
|
<div class="bar" aria-label="Projected share of the pool per seat">${order.map((id) => `<span class="${fill(id, segments.indexOf(id))}" style="--seat: var(--seat-${colourOf(id)}); width: ${(100 * p.bySeat[id].weighted / (v.weighted || 1)).toFixed(1)}%" title="${esc(label(id))}"></span>`).join('')}</div>
|
|
944
1111
|
<div class="pool-seats">${order.map((id) => {
|
|
945
1112
|
const row = p.bySeat[id];
|
|
946
1113
|
return `<span class="chip ${fill(id, segments.indexOf(id))}" style="--seat: var(--seat-${colourOf(id)})" title="${esc(row.calls)} calls${row.model ? ', ' + esc(row.model) : ''}${row.weight !== 1 ? `, model weight ×${row.weight}` : ''}"><span>${esc(label(id))}</span><b>${k(row.total)}</b><span>${row.cost != null ? `$${row.cost.toFixed(2)}` : ''}</span></span>`;
|
|
947
1114
|
}).join('')}</div>
|
|
1115
|
+
${v.seats.includes('research') ? `<p class="pool-note">Research estimate uses ${p.bySeat.research.samples ? `${p.bySeat.research.samples} matching historical call(s)` : 'a planning allowance with no matching history'}. Actual usage can vary.</p>` : ''}
|
|
948
1116
|
${v.weighted !== v.total ? `<p class="pool-note">≈ ${k(v.weighted)} pool units after model weight.</p>` : ''}
|
|
949
|
-
<div class="pool-window-section"
|
|
950
|
-
<div class="pool-cap" data-vendor="${esc(v.vendor)}"><label for="cap-${esc(v.vendor)}" title="Projected before each call, with the calls in flight and the verdict reserved. The vendor does not enforce it.">Cap</label><input id="cap-${esc(v.vendor)}" name="tokens" type="number" min="0" step="1000" placeholder="tokens" value="${cap?.tokens ?? ''}" aria-label="Token cap for ${esc(VENDOR_LABEL[v.vendor] || v.vendor)}">${v.cost != null || cap?.usd > 0 ? `<input name="usd" type="number" min="0" step="0.05" placeholder="$" value="${cap?.usd ?? ''}" aria-label="Dollar cap for ${esc(VENDOR_LABEL[v.vendor] || v.vendor)}">` : ''}${cap?.tokens > 0 && v.total > cap.tokens ? '<span class="warn">the projection is over this cap</span>' : ''}${usageLink(v.vendor)}</div>
|
|
1117
|
+
<div class="pool-window-section" data-vendor="${esc(v.vendor)}" data-pool="${esc(pool)}"><div class="pool-note pool-reading"></div><div class="pool-manual">${poolEntry(v.vendor, v.weighted)}</div></div>
|
|
1118
|
+
<div class="pool-cap" data-vendor="${esc(v.vendor)}"><label for="cap-${esc(v.vendor)}" title="Includes fresh input, cache reads and writes, and output. Projected before each call, with the calls in flight and the verdict reserved. The vendor does not enforce it.">Cap</label><input id="cap-${esc(v.vendor)}" name="tokens" type="number" min="0" step="1000" placeholder="tokens" value="${cap?.tokens ?? ''}" aria-label="Token cap for ${esc(VENDOR_LABEL[v.vendor] || v.vendor)}">${v.cost != null || cap?.usd > 0 ? `<input name="usd" type="number" min="0" step="0.05" placeholder="$" value="${cap?.usd ?? ''}" aria-label="Dollar cap for ${esc(VENDOR_LABEL[v.vendor] || v.vendor)}">` : ''}${cap?.tokens > 0 && v.total > cap.tokens ? '<span class="warn">the projection is over this cap</span>' : ''}${usageLink(v.vendor)}</div>
|
|
951
1119
|
${cap?.usd > 0 && v.cost == null ? '<p class="pool-note warn" data-dollar-warning>No dollar estimate is available. This dollar cap blocks calls; clear it to proceed with a token cap instead.</p>' : ''}
|
|
952
1120
|
</div>`;
|
|
953
1121
|
}).join('') || '<span class="muted">Seat at least one instance.</span>';
|
|
1122
|
+
updateProjectionReadings(draft);
|
|
954
1123
|
$('projection-summary').textContent = Object.values(p.byVendor).map((v) => `${VENDOR_LABEL[v.vendor] || v.vendor} ≈ ${k(v.total)}`).join(' · ');
|
|
955
1124
|
const vs = Object.values(p.byVendor);
|
|
956
1125
|
const rounds = Number($('critique-rounds').value) || 0;
|
|
957
1126
|
const priced = vs.filter((v) => v.cost != null);
|
|
958
|
-
$('start-
|
|
1127
|
+
$('start-profile-note').hidden = S.demo || ![...seats, chairman].some((s) => s?.vendor === 'acp');
|
|
1128
|
+
$('start-summary').innerHTML = seats.length ? `<b>${seats.length} seats</b> · ${seats.length * (rounds + 1) + 1 + (searcherOn() ? 1 : 0)} planned calls before retries · estimated ${k(vs.reduce((n, v) => n + v.total, 0))} tokens${priced.length ? ` · ≈ $${priced.reduce((n, v) => n + v.cost, 0).toFixed(2)} for ${priced.map((v) => esc(VENDOR_LABEL[v.vendor] || v.vendor)).join(', ')}` : ''}` : '';
|
|
959
1129
|
}
|
|
960
1130
|
|
|
961
1131
|
function clearSetupValidation() {
|
|
962
1132
|
S.seatIssue = null;
|
|
1133
|
+
$('start-refresh').hidden = true;
|
|
963
1134
|
$('setup-error').textContent = ''; $('seats-error').textContent = '';
|
|
964
1135
|
for (const el of $('seats').querySelectorAll('[aria-invalid]')) el.removeAttribute('aria-invalid');
|
|
965
1136
|
for (const el of $('seats').querySelectorAll('.seat-invalid')) el.classList.remove('seat-invalid');
|
|
@@ -993,16 +1164,17 @@ async function start() {
|
|
|
993
1164
|
const body = {
|
|
994
1165
|
fieldNotes, seats: draftSeats(),
|
|
995
1166
|
chairman: draftChairman(),
|
|
996
|
-
options: { critiqueRounds: Number($('critique-rounds').value), autoContinueMs: Number($('auto').value) * 1000, questionWaitMs: Number($('question-wait').value) * 1000, wallClockMs: Number($('wall').value) * 60000, memory: $('memory').value, unattended: $('unattended').checked, allowLimitedIsolation: isolationAccepted(), acknowledgeTermsRisk: termsAccepted(), budget: budgetBody(),
|
|
1167
|
+
options: { critiqueRounds: Number($('critique-rounds').value), autoContinueMs: Number($('auto').value) * 1000, questionWaitMs: Number($('question-wait').value) * 1000, wallClockMs: Number($('wall').value) * 60000, memory: $('memory').value, providerHistory: $('provider-history-mode').value, unattended: $('unattended').checked, allowLimitedIsolation: isolationAccepted(), acknowledgeTermsRisk: termsAccepted(), budget: budgetBody(),
|
|
997
1168
|
...(searcherOn() ? { research: { vendor: $('searcher-vendor').value, query: $('research-query').value.trim(), maxSearches: Number($('research-searches').value), timeoutMs: Number($('research-time').value) * 1000,
|
|
1169
|
+
sourceScopes: $('research-scopes').value.split(/\r?\n/).map(s => s.trim()).filter(Boolean),
|
|
998
1170
|
model: $('searcher-model').value.trim(), effort: $('searcher-effort').value, account: searcherAccount() } } : {}) },
|
|
999
1171
|
};
|
|
1000
1172
|
try {
|
|
1001
1173
|
localStorage.setItem('roundtable.notes', JSON.stringify(notes));
|
|
1002
|
-
localStorage.setItem('roundtable.seats', JSON.stringify(S.draft.map((s) => ({ ...s, keyEnv: keyEnvName(s.keyEnv) }))));
|
|
1174
|
+
localStorage.setItem('roundtable.seats', JSON.stringify(S.draft.map((s) => ({ ...s, ...directTransport(s.vendor), keyEnv: keyEnvName(s.keyEnv) }))));
|
|
1003
1175
|
localStorage.setItem('roundtable.budget', JSON.stringify(S.budget));
|
|
1004
1176
|
localStorage.setItem('roundtable.settings', JSON.stringify({ options: body.options, researchQueryMode: $('research-query-mode').value, chairman: {
|
|
1005
|
-
vendor:
|
|
1177
|
+
vendor: chairVendor(), ...directTransport(chairVendor()), model: $('chairman-model').value, effort: $('chairman-effort').value,
|
|
1006
1178
|
account: $('chairman-account').value, endpoint: $('chairman-endpoint').value, keyEnv: keyEnvName($('chairman-keyenv').value),
|
|
1007
1179
|
} }));
|
|
1008
1180
|
} catch {}
|
|
@@ -1017,20 +1189,22 @@ async function start() {
|
|
|
1017
1189
|
const unacknowledged = termsPending();
|
|
1018
1190
|
if (unacknowledged.length) { openTerms(unacknowledged[0]); return; }
|
|
1019
1191
|
// Confirm a known unavailable provider only after the form itself is valid.
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1192
|
+
const roles = [...body.seats, { ...body.chairman, lens: 'chairman' }];
|
|
1193
|
+
if (body.options.research) roles.push({ ...body.options.research, lens: 'searcher' });
|
|
1194
|
+
const warning = providerWarning(roles.map(({ vendor, account, model, lens }) => ({
|
|
1195
|
+
provider: VENDOR_LABEL[vendor], account, role: lens, lamp: poolLamp(vendor, account, model, false),
|
|
1196
|
+
})));
|
|
1197
|
+
if (warning && S.startConfirm !== warning) {
|
|
1198
|
+
S.startConfirm = warning;
|
|
1199
|
+
showSetupError({ message: warning });
|
|
1200
|
+
$('start-refresh').hidden = false;
|
|
1027
1201
|
$('start').textContent = 'Open anyway';
|
|
1028
1202
|
return;
|
|
1029
1203
|
}
|
|
1030
1204
|
const revision = viewRevision;
|
|
1031
1205
|
S.startPending = true; updateLamps();
|
|
1032
1206
|
try {
|
|
1033
|
-
const out = await requestJson('/api/debates', body);
|
|
1207
|
+
const out = await requestJson('/api/debates', body, 40_000);
|
|
1034
1208
|
if (revision === viewRevision) { openingSlug = out.slug; location.hash = out.slug; } // route() opens the board
|
|
1035
1209
|
} catch (e) {
|
|
1036
1210
|
showSetupError(e);
|
|
@@ -1332,19 +1506,19 @@ function renderUsage() {
|
|
|
1332
1506
|
// A sum over calls of which some reported nothing carries a "+" (at least this much), the same
|
|
1333
1507
|
// mark the debates list uses; the counts are in its title. A figure nobody reported is a dash.
|
|
1334
1508
|
const plus = (cov, what) => (cov && cov.reported < cov.of ? `<span class="partial" title="${cov.reported} of ${cov.of} calls report ${what}">+</span>` : '');
|
|
1335
|
-
const tokens = (n, x) => x.tokenCoverage?.reported === 0 ? '<span class="muted" title="No call reported token usage">unknown</span>'
|
|
1509
|
+
const tokens = (n, x) => x.tokenCoverage?.reported === 0 && !n ? '<span class="muted" title="No call reported token usage">unknown</span>'
|
|
1336
1510
|
: `${fmt(n)}${plus(x.tokenCoverage, 'token usage')}`;
|
|
1337
1511
|
const cost = (c, x) => (c == null ? '<span class="muted" title="This CLI does not report a cost">—</span>' : `$${c.toFixed(2)}${plus(x?.costCoverage, 'a cost')}`);
|
|
1338
1512
|
const secs = (ms) => `${Math.round((ms || 0) / 1000)}s`;
|
|
1339
1513
|
// last: the seat's input in the latest round it took part in (cache included), the figure that
|
|
1340
1514
|
// says whether rounds stay flat (stateless) or grow (resume)
|
|
1341
|
-
const row = (name, x, cls = '', last = null, position = null) => `<tr class="${cls}" data-position="${esc(position || 'none')}"><td>${name}</td><td class="data num">${tokens(x.input, x)}</td><td class="data num">${tokens(x.cacheRead + x.cacheWrite, x)}</td><td class="data num">${tokens(x.output, x)}</td><td class="data num">${cost(x.cost, x)}</td><td class="data num">${secs(x.ms)}</td><td class="data num">${last ? `<span title="Round ${esc(last.round)}">${tokens(last.usage.input + last.usage.cacheRead + last.usage.cacheWrite, last.usage)}</span>` : ''}</td></tr>`;
|
|
1515
|
+
const row = (name, x, cls = '', last = null, position = null) => `<tr class="${cls}" data-position="${esc(position || 'none')}"><td>${name}</td><td class="data num">${tokens(x.input, x)}</td><td class="data num">${tokens(x.cacheRead + x.cacheWrite, x)}</td><td class="data num">${tokens(x.output, x)}</td><td class="data num">${x.providerTotal == null ? '—' : fmt(x.providerTotal) + plus(x.providerTotalCoverage, 'complete CLI totals')}</td><td class="data num">${cost(x.cost, x)}</td><td class="data num">${secs(x.ms)}</td><td class="data num">${last ? `<span title="Round ${esc(last.round)}">${tokens(last.usage.input + last.usage.cacheRead + last.usage.cacheWrite, last.usage)}</span>` : ''}</td></tr>`;
|
|
1342
1516
|
const pools = [...new Set([...S.seats.map(seatPool), ...(S.chairman ? [seatPool(S.chairman)] : []), ...(u.bySeat.research ? [seatPool(u.bySeat.research.seat)] : [])])];
|
|
1343
1517
|
// the models this debate runs on a pool: a quota in groups (agy) shows only their groups
|
|
1344
1518
|
const seatedModels = (key) => [...S.seats, S.chairman || S.configuredChairman, u.bySeat.research?.seat].filter((s) => s && seatPool(s) === key).map((s) => s.model || '');
|
|
1345
1519
|
const rows = [];
|
|
1346
1520
|
for (const pool of pools) {
|
|
1347
|
-
rows.push(`<tr class="pool-row"><td colspan="
|
|
1521
|
+
rows.push(`<tr class="pool-row"><td colspan="8">${poolLine(pool, seatedModels(pool))}</td></tr>`);
|
|
1348
1522
|
if (u.bySeat.research && seatPool(u.bySeat.research.seat) === pool) { const rs = u.bySeat.research.seat; rows.push(row(`<span class="seat-cell" style="--seat: var(--seat-${esc(vendorColour(rs.vendor))})"><span class="seat-dot"></span><span><span class="seat-lens">searcher</span><span class="seat-meta">${esc([VENDOR_LABEL[rs.vendor] || rs.vendor, seatMeta(rs)].filter(Boolean).join(' · '))}</span></span></span>`, u.bySeat.research.usage)); }
|
|
1349
1523
|
const seated = [...S.seats.filter((s) => seatPool(s) === pool), ...(S.chairman && seatPool(S.chairman) === pool ? [S.chairman] : [])];
|
|
1350
1524
|
for (const seat of seated) {
|
|
@@ -1357,13 +1531,16 @@ function renderUsage() {
|
|
|
1357
1531
|
// the lens reads first; who runs it and on what sits beneath in the data face
|
|
1358
1532
|
const name = `<span class="seat-cell" style="--seat: var(--seat-${esc(seat.colour)})"><span class="seat-dot"></span><span><span class="seat-lens">${esc(seat.lens)}${isChair ? '' : led(S.conn[seat.id] || 'idle')}</span><span class="seat-meta">${esc([seatName(seat), seatMeta(seat)].filter(Boolean).join(' · '))}</span></span></span>`;
|
|
1359
1533
|
const out = seatDown(seat);
|
|
1360
|
-
rows.push(x ? row(name, x, '', last, position) : `<tr data-position="none"><td>${name}</td><td class="data ${out ? 'danger' : 'muted'}" colspan="
|
|
1534
|
+
rows.push(x ? row(name, x, '', last, position) : `<tr data-position="none"><td>${name}</td><td class="data ${out ? 'danger' : 'muted'}" colspan="7">${out ? `out: ${esc(ERROR_LINE[out.kind] || out.kind)} no tokens charged` : 'no call yet'}</td></tr>`);
|
|
1361
1535
|
}
|
|
1362
1536
|
}
|
|
1363
1537
|
const cur = S.rounds.length ? S.rounds.length - 1 : null;
|
|
1364
1538
|
if (cur != null && u.byRound[String(cur)]) rows.push(row(`Round ${cur}`, u.byRound[String(cur)], 'subtotal'));
|
|
1365
1539
|
rows.push(row('Debate total', u.total, 'total'));
|
|
1366
1540
|
$('usage').querySelector('tbody').innerHTML = rows.join('');
|
|
1541
|
+
const history = $('provider-history');
|
|
1542
|
+
history.textContent = providerHistoryText(S.rows);
|
|
1543
|
+
history.hidden = !history.textContent;
|
|
1367
1544
|
const keys = [...new Set([...S.seats, ...(S.chairman || S.configuredChairman ? [S.chairman || S.configuredChairman] : [])].map((seat) => poolKey(seat.vendor, seat.account, !!VENDOR_META[seat.vendor]?.profiles)))];
|
|
1368
1545
|
$('usage-summary').innerHTML = keys.map((key) => {
|
|
1369
1546
|
const q = S.quota[key];
|
|
@@ -1520,7 +1697,7 @@ function renderGate() {
|
|
|
1520
1697
|
? (isAcp(savedChair?.vendor) ? apiSeats[0]?.value : null) || pickable.find((v) => v !== S.verdict?.seat?.vendor) || pickable[0]
|
|
1521
1698
|
: isAcp(savedChair?.vendor) ? 'chair:acp' : (savedChair?.vendor || pickable[0]);
|
|
1522
1699
|
const synth = S.status === 'done' && S.synthesis && S.synthesis !== 'done' && canFinish
|
|
1523
|
-
? ` <span class="synth">Write the verdict with <select id="synth-chair" aria-label="Chairman for the verdict">${pickable.map((v) => `<option value="${v}" ${v === first ? 'selected' : ''}>${esc(VENDOR_LABEL[v])}${v === savedChair?.vendor ? esc([savedChair.model, savedChair.effort, savedChair.account].filter(Boolean).map((s) => ` · ${s}`).join('')) : ''}</option>`).join('')}${apiSeats.map((o) => `<option value="${esc(o.value)}" ${o.value === first ? 'selected' : ''}>${esc(o.label)}</option>`).join('')}</select> <button class="btn btn-small" id="synthesize" type="button" ${S.actionPending ? 'disabled' : ''}>${S.actionPending === 'synthesize' ? 'Starting…' : 'Write'}</button></span>` : '';
|
|
1700
|
+
? ` <span class="synth">Write the verdict with <select id="synth-chair" aria-label="Chairman for the verdict">${pickable.map((v) => `<option value="${v}" ${v === first ? 'selected' : ''}>${esc(VENDOR_LABEL[v])} · direct CLI${v === savedChair?.vendor ? esc([savedChair.model, savedChair.effort, savedChair.account].filter(Boolean).map((s) => ` · ${s}`).join('')) : ''}</option>`).join('')}${apiSeats.map((o) => `<option value="${esc(o.value)}" ${o.value === first ? 'selected' : ''}>${esc(o.label)}</option>`).join('')}</select> <button class="btn btn-small" id="synthesize" type="button" ${S.actionPending ? 'disabled' : ''}>${S.actionPending === 'synthesize' ? 'Starting…' : 'Write'}</button></span>` : '';
|
|
1524
1701
|
const focused = st.contains(document.activeElement) ? document.activeElement.id : null;
|
|
1525
1702
|
st.innerHTML = link + (S.status === 'done' ? `<span class="status ${S.synthesis === 'done' ? 'ok' : 'warn'}">${S.synthesis === 'done' ? 'Review finished' : S.stopReason === 'human' ? 'Review stopped' : 'Review ended without a verdict'}</span> ${esc(stopExplanation(S.stopReason, S.stopContext))}${synth} Record saved locally.${S.exported ? ' Decision record exported.' : ''}${S.exportError ? ` <span class="danger">Export failed: ${esc(S.exportError)}</span>` : ''}${S.replayed ? ' <span class="muted">saved review</span>' : ''}`
|
|
1526
1703
|
: interrupted ? `<span class="status warn">interrupted</span> ${S.interrupted?.round ? `after round ${S.interrupted.round - 1}` : 'before round 0 finished'}${S.interrupted?.partialRound != null ? `, round ${S.interrupted.partialRound} will be re-run` : ''}. Add a note or resume.`
|
|
@@ -1613,7 +1790,9 @@ function updateQuestionTime() {
|
|
|
1613
1790
|
// Which vendor would cross its cap, and by how much: shown wherever the gate status is.
|
|
1614
1791
|
function budgetLine() {
|
|
1615
1792
|
const b = S.budgetStop; if (!b) return '';
|
|
1616
|
-
|
|
1793
|
+
// a cap on one AgentLink profile is keyed vendor@profile
|
|
1794
|
+
const [vendor, profile] = String(b.vendor).split('@');
|
|
1795
|
+
const name = esc((VENDOR_LABEL[vendor] || vendor) + (profile ? ` profile ${profile}` : ''));
|
|
1617
1796
|
if (b.kind === 'usd-unknown') return `<span class="status danger">budget</span> ${name} has a dollar cap, but its cost is not reported, so the ${esc(b.what)} was not run. `;
|
|
1618
1797
|
if (b.kind === 'tokens-unknown') return `<span class="status danger">budget</span> ${name} did not report token usage. Further calls to this vendor are blocked under its token cap; ${esc(b.what)} was not run. `;
|
|
1619
1798
|
if (b.kind === 'seat-tokens-unknown') return `<span class="status warn">usage unknown</span> ${esc(unknownUsageMessage(b.cause))} Other seats can continue. `;
|
|
@@ -1654,7 +1833,7 @@ function renderResearch() {
|
|
|
1654
1833
|
}
|
|
1655
1834
|
stopScan();
|
|
1656
1835
|
if (r.status !== 'done') { $('research-body').textContent = r.error || 'Research was interrupted. It will not rerun automatically.'; return; }
|
|
1657
|
-
$('research-body').innerHTML = `<p class="hint">${r.searches} reported search operation${r.searches === 1 ? '' : 's'} · gathered ${esc(r.gatheredAt)}. Every seat and the chairman receive this same saved bundle.
|
|
1836
|
+
$('research-body').innerHTML = `<p class="hint">${r.searches} reported search operation${r.searches === 1 ? '' : 's'} · gathered ${esc(r.gatheredAt)}. Every seat and the chairman receive this same saved bundle. ${esc(verificationNote(r))}</p>`
|
|
1658
1837
|
+ (r.sources || []).map((s) => `<details><summary>${esc(s.id)} · ${esc(s.title)}</summary><p><a href="${esc(s.url)}" target="_blank" rel="noopener noreferrer">${esc(s.url)}</a></p><p>${esc(s.excerpt)}</p><p class="hint">Published: ${esc(s.publishedAt || 'not reported')}</p></details>`).join('');
|
|
1659
1838
|
}
|
|
1660
1839
|
|
|
@@ -1688,7 +1867,7 @@ function tick() {
|
|
|
1688
1867
|
}
|
|
1689
1868
|
|
|
1690
1869
|
// ---------- human bar ----------
|
|
1691
|
-
const post = (what, body = {}) => requestJson(`/api/debates/${S.slug}/${what}`, body);
|
|
1870
|
+
const post = (what, body = {}) => requestJson(`/api/debates/${S.slug}/${what}`, body, ['resume', 'synthesize'].includes(what) ? 40_000 : undefined);
|
|
1692
1871
|
async function boardAction(action, body, onSuccess) {
|
|
1693
1872
|
if (S.actionPending) return;
|
|
1694
1873
|
const revision = viewRevision;
|
|
@@ -1803,7 +1982,7 @@ $('gate-status').addEventListener('click', async (ev) => {
|
|
|
1803
1982
|
const savedChair = S.configuredChairman || S.chairman;
|
|
1804
1983
|
const chosen = seat || (pick === 'chair:acp' || pick === savedChair?.vendor ? savedChair : { vendor: pick });
|
|
1805
1984
|
const chairman = Object.fromEntries(['vendor', 'endpoint', 'keyEnv', 'model', 'effort', 'account'].filter((key) => chosen[key] != null).map((key) => [key, chosen[key]]));
|
|
1806
|
-
await boardAction('synthesize', { chairman });
|
|
1985
|
+
await boardAction('synthesize', { chairman: { ...chairman, ...directTransport(chairman.vendor) } });
|
|
1807
1986
|
if (revision === viewRevision) $('synthesize')?.focus({ preventScroll: true });
|
|
1808
1987
|
});
|
|
1809
1988
|
$('gate-status').addEventListener('change', (ev) => { if (ev.target.id === 'synth-chair') S.synthChoice = ev.target.value; });
|