clearotron 0.7.0 → 0.8.0-beta.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.
Files changed (98) hide show
  1. package/THIRD-PARTY-NOTICES.md +71 -2
  2. package/build-info.json +2 -2
  3. package/demo/multi-country-focus-search/run/common-law-grid.json +1 -1
  4. package/docs/CLIENT-MCP.md +17 -0
  5. package/docs/assets/README.md +19 -3
  6. package/docs/assets/portal-clearance-report.jpg +0 -0
  7. package/docs/assets/portal-conflict-landscape.jpg +0 -0
  8. package/docs/assets/portal-new-clearance.png +0 -0
  9. package/driver/CHANGELOG.md +48 -0
  10. package/driver/config-inventory.mjs +15 -2
  11. package/driver/dev-portal.mjs +2 -0
  12. package/driver/effort-model.mjs +34 -4
  13. package/driver/engine/CONTRACT.md +8 -0
  14. package/driver/engine/anthropic-agent.mjs +74 -16
  15. package/driver/engine/jx-turn.mjs +11 -3
  16. package/driver/engine/openai-agent.mjs +33 -7
  17. package/driver/engine/run-choices.mjs +28 -7
  18. package/driver/engine/speed.mjs +107 -0
  19. package/driver/enqueue-schema.mjs +8 -0
  20. package/driver/enqueue.mjs +14 -2
  21. package/driver/jx-units.mjs +2 -2
  22. package/driver/jx.mjs +1 -1
  23. package/driver/knockout-plain-language.mjs +96 -0
  24. package/driver/ladder/attempt-record.mjs +14 -2
  25. package/driver/ladder/dispatch.mjs +2 -2
  26. package/driver/ladder/form-repair.mjs +1 -1
  27. package/driver/ladder/stage.mjs +7 -1
  28. package/driver/mark-logos.mjs +6 -1
  29. package/driver/order-receipt.mjs +184 -0
  30. package/driver/package.json +4 -1
  31. package/driver/picture-shrink-worker.mjs +21 -0
  32. package/driver/picture-thumbnail.mjs +132 -0
  33. package/driver/pipeline-knockout.mjs +14 -0
  34. package/driver/portal-confirmation.mjs +3 -0
  35. package/driver/portal-report.mjs +44 -1
  36. package/driver/portal-routes/run.mjs +19 -9
  37. package/driver/portal-runs.mjs +118 -63
  38. package/driver/portal-service.mjs +17 -2
  39. package/driver/predelivery-lint.mjs +3 -3
  40. package/driver/progress.mjs +33 -5
  41. package/driver/publish/column-queries.mjs +86 -0
  42. package/driver/publish/index.mjs +4 -4
  43. package/driver/publish/knockout.mjs +35 -8
  44. package/driver/publish/page-shell.mjs +5 -1
  45. package/driver/publish/read-document.mjs +3 -0
  46. package/driver/publish/render-knockout.mjs +61 -16
  47. package/driver/publish/render.mjs +171 -30
  48. package/driver/publish/search-depth.mjs +45 -1
  49. package/driver/publish/strings.mjs +23 -0
  50. package/driver/publish/templates/report.css +73 -0
  51. package/driver/research-answers.mjs +17 -6
  52. package/driver/research-checks.mjs +22 -4
  53. package/driver/research-records.mjs +81 -0
  54. package/driver/run-quote.mjs +3 -0
  55. package/driver/run-speed.mjs +89 -0
  56. package/driver/runner.mjs +50 -21
  57. package/driver/saved-register-pages.mjs +23 -22
  58. package/driver/stage-freshness.mjs +5 -0
  59. package/driver/stages.mjs +2 -2
  60. package/driver/steps/open-run.mjs +12 -1
  61. package/driver/suite-census.json +199 -37
  62. package/driver/tokens.mjs +3 -0
  63. package/driver/urgent-count.mjs +54 -0
  64. package/driver/usage-ledger.mjs +8 -2
  65. package/driver/web-pictures.mjs +532 -0
  66. package/mcp-server/CHANGELOG.md +16 -0
  67. package/mcp-server/lib/document-reads.mjs +28 -0
  68. package/mcp-server/lib/events.mjs +21 -12
  69. package/mcp-server/lib/findings.mjs +2 -1
  70. package/mcp-server/lib/knockout.mjs +3 -2
  71. package/mcp-server/lib/ops.mjs +103 -6
  72. package/mcp-server/lib/options.mjs +4 -0
  73. package/mcp-server/lib/plan.mjs +38 -4
  74. package/mcp-server/lib/result-shapes.mjs +66 -0
  75. package/mcp-server/lib/runs.mjs +46 -44
  76. package/mcp-server/lib/urgent.mjs +29 -0
  77. package/mcp-server/package.json +1 -1
  78. package/mcp-server/result-shapes.json +2978 -0
  79. package/mcp-server/server.mjs +67 -14
  80. package/package.json +4 -1
  81. package/portal-ui/dist/assets/{index-qNDhqCw9.js → index-DEkVU2FD.js} +1909 -766
  82. package/portal-ui/dist/assets/{index-CxAkJXIT.css → index-W6SAoDkS.css} +238 -1
  83. package/portal-ui/dist/index.html +2 -2
  84. package/portal-ui/package.json +1 -1
  85. package/providers/jx/src/turn-envelope.mjs +3 -1
  86. package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
  87. package/providers/oauth-mcp-bridge/package.json +1 -1
  88. package/providers/signa/src/core.js +54 -12
  89. package/scripts/README.md +3 -0
  90. package/scripts/e2e-first-time.mjs +2 -2
  91. package/scripts/mint-result-shapes.mjs +199 -0
  92. package/scripts/readme-pictures.mjs +227 -0
  93. package/scripts/render-check.mjs +4 -1
  94. package/scripts/report-sections-render-check.mjs +191 -0
  95. package/scripts/settings-render-check.mjs +68 -11
  96. package/shared/brand.mjs +8 -0
  97. package/skills/clearotron-account/SKILL.md +24 -0
  98. package/skills/clearotron-ops/SKILL.md +23 -9
@@ -64,6 +64,11 @@ const RUNS = Array.from({ length: 12 }, (_, i) => {
64
64
  issuedAt: `2026-09-${day}T12:00:00.000Z`, product, productName, runId: `tmpa-read-${i + 1}`,
65
65
  }
66
66
  })
67
+ // THE CASES THE SEARCH HISTORY TELLS APART (refinement picture search-history.png, approved 2026-11-25): two
68
+ // reports of one day, issued at different times, and a search still running. The newest is the report read.
69
+ Object.assign(RUNS[0], { date: '2026-09-18', issuedAt: '2026-09-18T15:45:00.000Z' })
70
+ Object.assign(RUNS[1], { date: '2026-09-18', issuedAt: '2026-09-18T09:20:00.000Z' })
71
+ Object.assign(RUNS[2], { state: 'running', report: null, date: '2026-09-17', issuedAt: '2026-09-17T08:00:00.000Z', band: null, tone: null })
67
72
  const RUN_ID = RUNS[0].runId
68
73
 
69
74
  const MIME = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml', '.json': 'application/json', '.png': 'image/png', '.woff2': 'font/woff2' }
@@ -240,6 +245,192 @@ for (const width of [1440, 400]) {
240
245
  }
241
246
  }
242
247
 
248
+ // ── THE HEADER'S TWO STATES (board ReportHeader, approved 2026-11-25) ────────────────────────────────────
249
+ //
250
+ // At the top of the page the header is today's, with "Search history" over the chips. Past it, the same
251
+ // header is one pinned row, in the board's order, and the switch moves nothing in the document. The search
252
+ // history opens from that row and reads as the refinement picture does; Escape closes it and gives focus
253
+ // back. A phone keeps today's header, so it never becomes the single row.
254
+ for (const theme of ['light', 'dark']) {
255
+ const at = `1440 ${theme} header`
256
+ await cmd('Emulation.setDeviceMetricsOverride', { width: 1440, height: 900, deviceScaleFactor: 1, mobile: false })
257
+ await cmd('Page.navigate', { url: `${origin}/portal/` })
258
+ await value(`(() => { try { localStorage.setItem('cordillera-theme', '${theme}') } catch (e) {} return 1 })()`)
259
+ await cmd('Page.navigate', { url: `${origin}/portal/result/${RUN_ID}` })
260
+ if (!(await until(`document.querySelectorAll('.report-nav .pill').length === ${RUNS.length} && Boolean(document.querySelector('iframe'))`))) {
261
+ fail.push(`${at}: the report never drew its header and frame`); continue
262
+ }
263
+ await wait(800)
264
+ const top = await value(`({ label: [...document.querySelectorAll('.report-nav .eyebrow')].map((e) => e.textContent.trim()), compact: Boolean(document.querySelector('.report-head.compact')), ask: /Ask AI/.test(document.querySelector('.report-head-row').textContent || '') })`)
265
+ if (!(top && top.label.includes('Search history') && !top.label.includes('Reads') && !top.compact)) fail.push(`${at}: at the top the header is not today's with "Search history" over the chips (${JSON.stringify(top)})`)
266
+ else ok.push(`${at}: at the top, today's header with "Search history" over the chips`)
267
+ const docTop = `Math.round(document.querySelector('iframe').getBoundingClientRect().top + window.scrollY)`
268
+ const before = await value(docTop)
269
+ const past = await value(`Math.round(document.querySelector('.report-head-slot').getBoundingClientRect().bottom + window.scrollY - ${56} + 240)`)
270
+ await value(`(window.scrollTo(0, ${past}), 1)`)
271
+ await until(`Boolean(document.querySelector('.report-head.compact'))`, 3000)
272
+ await wait(300)
273
+ const after = await value(docTop)
274
+ if (before !== after) fail.push(`${at}: the switch moved the report from ${before} to ${after} in the page`)
275
+ else ok.push(`${at}: the switch to the single row moves nothing in the page (report at ${after})`)
276
+ const row = await value(`(() => {
277
+ const h = document.querySelector('.report-head.compact'); if (!h) return null;
278
+ const kids = [...h.querySelector('.report-head-row').children];
279
+ const where = (pred) => kids.findIndex(pred);
280
+ const name = h.querySelector('h1'); const cs = name ? getComputedStyle(name) : null;
281
+ return {
282
+ back: (h.querySelector('.report-back-icon') || {}).getAttribute?.('aria-label') ?? null,
283
+ order: [where((k) => k.classList.contains('report-back-icon')), where((k) => k.tagName === 'H1'), where((k) => k.classList.contains('risk-dot')),
284
+ where((k) => k.classList.contains('report-history')), where((k) => k.classList.contains('report-sections')),
285
+ where((k) => /Ask AI/.test(k.textContent || '')), where((k) => /Export/.test(k.textContent || ''))],
286
+ history: (h.querySelector('.report-history-btn') || {}).textContent?.trim() ?? null,
287
+ oneRow: Math.round(h.getBoundingClientRect().height),
288
+ ellipsis: cs ? cs.textOverflow === 'ellipsis' && cs.whiteSpace === 'nowrap' : false,
289
+ pinnedAt: Math.round(h.getBoundingClientRect().top),
290
+ };
291
+ })()`)
292
+ // Ask AI is drawn where this deployment offers it, in both states or in neither: this fixture offers none.
293
+ const drawn = row ? row.order.filter((n, i) => !(i === 5 && !top?.ask)) : []
294
+ const inOrder = row && (row.order[5] >= 0) === Boolean(top?.ask) && drawn.every((n, i) => n >= 0 && (i === 0 || n > drawn[i - 1]))
295
+ if (!row || !inOrder || row.back !== 'All Clearances' || row.history !== `Search history · ${RUNS.length}` || row.pinnedAt !== 56 || !row.ellipsis || row.oneRow > 64) {
296
+ fail.push(`${at}: the single row is not the board's (${JSON.stringify(row)})`)
297
+ } else ok.push(`${at}: one pinned row, ${row.oneRow}px, in the board's order: back, name, band, "${row.history}", sections, ${top?.ask ? 'Ask AI, ' : ''}Export`)
298
+ await value(`(document.querySelector('.report-history-btn').click(), 1)`)
299
+ await until(`Boolean(document.querySelector('.report-history-list'))`, 3000)
300
+ const list = await value(`[...document.querySelectorAll('.report-history-row')].map((b) => ({ text: b.innerText.replace(/\s+/g, ' ').trim(), current: b.getAttribute('aria-current') === 'true', latest: Boolean(b.querySelector('.report-history-tag')), live: (b.querySelector('.report-history-live') || {}).textContent || null }))`)
301
+ const want = list && list.length === RUNS.length
302
+ && list.filter((r) => r.current).length === 1 && list[0].current
303
+ && list.filter((r) => r.latest).length === 1 && list[0].latest
304
+ && /09-18 · 15:45 UTC/.test(list[0].text) && /09-18 · 09:20 UTC/.test(list[1].text)
305
+ && list[2].live === 'Running' && !/UTC/.test(list[2].text)
306
+ && list.slice(3).every((r) => !/UTC/.test(r.text))
307
+ if (!want) fail.push(`${at}: the search history does not read as the refinement picture (${JSON.stringify(list)})`)
308
+ else ok.push(`${at}: the search history lists ${list.length}, newest first: the one read ticked, "Latest report" once, times only on one day's two reports, "Running" with no time`)
309
+ await shot(`header-pinned-history-${theme}.png`)
310
+ await value(`(document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })), 1)`)
311
+ await wait(150)
312
+ const closed = await value(`!document.querySelector('.report-history-list') && document.activeElement === document.querySelector('.report-history-btn')`)
313
+ if (!closed) fail.push(`${at}: Escape did not close the search history and give focus back to its button`)
314
+ else ok.push(`${at}: Escape closes the search history and gives focus back`)
315
+ await value(`(window.scrollTo(0, 0), 1)`)
316
+ await until(`!document.querySelector('.report-head.compact')`, 3000)
317
+ if (await value(`Boolean(document.querySelector('.report-head.compact'))`)) fail.push(`${at}: back at the top, the full header did not return`)
318
+ else ok.push(`${at}: back at the top, the full header returns`)
319
+ await shot(`header-top-${theme}.png`)
320
+ }
321
+ {
322
+ const at = '400 light header'
323
+ await cmd('Emulation.setDeviceMetricsOverride', { width: 400, height: 900, deviceScaleFactor: 1, mobile: true })
324
+ await cmd('Page.navigate', { url: `${origin}/portal/result/${RUN_ID}` })
325
+ await until(`document.querySelectorAll('.report-nav .pill').length === ${RUNS.length}`)
326
+ await value(`(window.scrollTo(0, 3000), 1)`)
327
+ await wait(500)
328
+ const phone = await value(`({ compact: Boolean(document.querySelector('.report-head.compact')), pinned: Math.round(document.querySelector('.report-head').getBoundingClientRect().top) })`)
329
+ if (!phone || phone.compact || phone.pinned !== 56) fail.push(`${at}: a phone does not keep today's pinned header (${JSON.stringify(phone)})`)
330
+ else ok.push(`${at}: a phone keeps today's pinned header`)
331
+ }
332
+
333
+ // ── THE PINNED ROW AT A LAPTOP WIDTH, SIDEBAR OPEN (design, 2026-11-26) ───────────────────────────────────────
334
+ // At 1,280 px with the sidebar open the row must keep the seven-letter name whole, "Ask AI" on one line and every
335
+ // section link readable, or the full header is pinned instead, every part of it in reach. 1,600 px is the control:
336
+ // there the row pins as before.
337
+ for (const [width, mustPin] of [[1280, false], [1332, false], [1600, true]]) {
338
+ for (const theme of ['light', 'dark']) {
339
+ const at = `${width} ${theme} sidebar open`
340
+ await cmd('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false })
341
+ await cmd('Page.navigate', { url: `${origin}/portal/` })
342
+ await value(`(() => { try { localStorage.setItem('cordillera-theme', '${theme}') } catch (e) {} return 1 })()`)
343
+ await cmd('Page.navigate', { url: `${origin}/portal/result/${RUN_ID}` })
344
+ if (!(await until(`document.querySelectorAll('nav.report-sections .report-section').length === ${SECTIONS.length} && Boolean(document.querySelector('.sidebar, nav[aria-label]'))`))) {
345
+ fail.push(`${at}: the report never drew its header`); continue
346
+ }
347
+ await wait(600)
348
+ await value('(window.scrollTo(0, 3000), 1)')
349
+ await wait(800)
350
+ const row = await value(`(() => { const h = document.querySelector('.report-head'); const compact = h.classList.contains('compact'), full = h.classList.contains('pinned-full');
351
+ const q = (s) => h.querySelector(s); const name = q('.report-head-name'), strip = q('.report-sections'), ask = q('.ask-ai-btn'), r = q('.report-head-row');
352
+ const everyStrip = [...document.querySelectorAll('.report-head .report-sections, .report-nav .report-sections')].every((s) => s.scrollWidth <= s.clientWidth + 1);
353
+ return { compact, full, everyStrip, pinned: Math.round(h.getBoundingClientRect().top), name: name.textContent.trim(), nameCut: name.scrollWidth > name.clientWidth + 1,
354
+ stripCut: strip ? strip.scrollWidth > strip.clientWidth + 1 : null, askLines: ask ? Math.round(ask.getBoundingClientRect().height) : null,
355
+ rowSpill: r.scrollWidth > r.clientWidth + 1, sidebar: Math.round((document.querySelector('.report-head-slot') || h).getBoundingClientRect().left) } })()`)
356
+ if (!row) { fail.push(`${at}: the header could not be measured`); continue }
357
+ if (row.compact) {
358
+ if (row.nameCut || row.stripCut || row.rowSpill || (row.askLines ?? 0) > 40)
359
+ fail.push(`${at}: the pinned row does not fit: ${JSON.stringify(row)}`)
360
+ else ok.push(`${at}: the pinned row keeps "${row.name}" whole, Ask AI on one line and every section link (header starts at ${row.sidebar}px)`)
361
+ } else if (mustPin) fail.push(`${at}: the row no longer pins at a width it fitted before: ${JSON.stringify(row)}`)
362
+ else if (!row.full || row.pinned !== 56 || row.nameCut || !row.everyStrip)
363
+ fail.push(`${at}: the row does not fit, and the full header is not pinned whole in its place: ${JSON.stringify(row)}`)
364
+ else ok.push(`${at}: the row cannot hold the name, Ask AI and the sections here, so the full header is pinned under the top bar, "${row.name}" whole and every section link in reach`)
365
+ await shot(`header-${width}-sidebar-${theme}.png`)
366
+ }
367
+ }
368
+
369
+ // ── A CARD'S ADDRESS, AND THE PAGE SCROLLING FOR THE FRAME ────────────────────────────────────────────────────
370
+ // The document cannot write the clipboard, know the portal's address or scroll the page, so it asks the page. A
371
+ // card's "Copy link" must put this report screen's address with the card named on the clipboard and see its tick;
372
+ // that address must open the report at the card, under the header; and a scroll-by from the frame must move the
373
+ // page by exactly that distance.
374
+ const inFrame = (expression) => new Promise((r) => { const i = ++id; pending.set(i, r); ws.send(JSON.stringify({ id: i, sessionId: frameSession, method: 'Runtime.evaluate',
375
+ params: { expression, awaitPromise: true, returnByValue: true, userGesture: true } })) }).then((a) => a.result?.result?.value ?? null)
376
+ /** Open `url` and check it lands the page with `card` just under the pinned header (and, if `fullHeader`, that the header pinned is the full one). */
377
+ async function landsUnderHeader(at, url, card, picture, fullHeader = false) {
378
+ await cmd('Page.navigate', { url })
379
+ await until(`document.querySelectorAll('nav.report-sections .report-section').length === ${SECTIONS.length}`)
380
+ await wait(1500)
381
+ const landed = await value(`(() => { const f = document.querySelector('iframe'); const h = document.querySelector('.report-head');
382
+ return { frameTop: f.getBoundingClientRect().top, headBottom: h.getBoundingClientRect().bottom, scrollY: window.scrollY, full: h.classList.contains('pinned-full') } })()`)
383
+ const cardTop = await inFrame(`Math.round(document.getElementById(${JSON.stringify(card)}).getBoundingClientRect().top + window.scrollY)`)
384
+ const onScreen = landed && cardTop !== null ? Math.round(landed.frameTop + cardTop) : null
385
+ if (onScreen === null) fail.push(`${at}: the landing could not be measured`)
386
+ else if (fullHeader && !landed.full) fail.push(`${at}: the full header is not the one pinned here, so this landing tests nothing (${JSON.stringify(landed)})`)
387
+ else if (landed.scrollY < 100 || onScreen < landed.headBottom - 2 || onScreen > landed.headBottom + 120)
388
+ fail.push(`${at}: the card's address left the card at ${onScreen}px, with the header ending at ${Math.round(landed.headBottom)}px (scrolled ${Math.round(landed.scrollY)})`)
389
+ else ok.push(`${at}: the card's address opens the report at ${card}, ${onScreen - Math.round(landed.headBottom)}px under the header`)
390
+ await shot(picture)
391
+ }
392
+ {
393
+ const at = '1440 light card link'
394
+ await cmd('Emulation.setDeviceMetricsOverride', { width: 1440, height: 900, deviceScaleFactor: 1, mobile: false })
395
+ await cmd('Page.navigate', { url: `${origin}/portal/` })
396
+ await value(`(() => { try { localStorage.setItem('cordillera-theme', 'light') } catch (e) {} return 1 })()`)
397
+ await send('Browser.grantPermissions', { origin, permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'] })
398
+ // A headless page is never focused, and the clipboard refuses an unfocused document, read or write.
399
+ await cmd('Emulation.setFocusEmulationEnabled', { enabled: true })
400
+ await cmd('Page.navigate', { url: `${origin}/portal/result/${RUN_ID}?ask=open#elsewhere` })
401
+ await until(`document.querySelectorAll('nav.report-sections .report-section').length === ${SECTIONS.length}`)
402
+ await wait(800)
403
+ const card = await inFrame(`(() => { const b = [...document.querySelectorAll('.card .copy-fi')].pop(); if (!b) return null;
404
+ b.scrollIntoView(); b.click(); return b.closest('.card').id })()`)
405
+ if (!card) fail.push(`${at}: the report shows no card with a Copy link inside the portal`)
406
+ else {
407
+ await wait(500)
408
+ const copied = await value(`navigator.clipboard.readText().catch((e) => 'unreadable: ' + e.message)`)
409
+ const ticked = await inFrame(`Boolean(document.getElementById(${JSON.stringify(card)})?.querySelector('.copy-fi.copied'))`)
410
+ const expected = `${origin}/portal/result/${RUN_ID}?card=${card}`
411
+ if (copied !== expected) fail.push(`${at}: the clipboard holds ${JSON.stringify(copied)}, not ${expected}`)
412
+ else if (!ticked) fail.push(`${at}: the card's Copy link shows no tick after the copy landed`)
413
+ else ok.push(`${at}: Copy link on ${card} puts this report's address with the card named on the clipboard, and the card shows its tick`)
414
+ await shot('card-link-copied.png')
415
+
416
+ // LANDING: the copied address opens the report at that card, below the pinned header.
417
+ await landsUnderHeader(at, expected, card, 'card-link-landed.png')
418
+
419
+ // SCROLL-BY: the frame asks the page to move by a distance, and the page moves by exactly that.
420
+ const before = await value('window.scrollY')
421
+ await inFrame(`(parent.postMessage({ source: 'cordillera-report', type: 'scrollBy', dy: 150 }, '*'), 1)`)
422
+ await wait(400)
423
+ const after = await value('window.scrollY')
424
+ if (after - before !== 150) fail.push(`${at}: a scroll-by of 150 moved the page by ${after - before}`)
425
+ else ok.push(`${at}: a scroll-by of 150 from the frame moves the page by 150`)
426
+
427
+ // LANDING UNDER THE FULL HEADER. At 1,280 px with the sidebar open the row cannot fit, so the full header is pinned
428
+ // once the jump has passed it, taller than the row the jump allowed for: the card must land under that header.
429
+ await cmd('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false })
430
+ await landsUnderHeader('1280 light card link, full header pinned', expected, card, 'card-link-landed-full-header.png', true)
431
+ }
432
+ }
433
+
243
434
  for (const line of ok) console.log(` ok ${line}`)
244
435
  for (const line of fail) console.log(` FAIL ${line}`)
245
436
  try { ws.close() } catch { /* going anyway */ }
@@ -71,7 +71,12 @@ const adminConfig = {
71
71
  }
72
72
  const about = productIdentity()
73
73
 
74
- const state = { contact: CONTACT, reset: null, programMissing: false }
74
+ const state = { contact: CONTACT, reset: null, programMissing: false, nothingSet: false }
75
+
76
+ // NOTHING SET UP (boards approved 2026-11-25): no AI chosen, no register, no keys. Every Needed row is red with
77
+ // the setup command beside it, the research row says a Knockout search can still run, and the Optional rows
78
+ // stay neutral. The driver's own inventory again, against an empty environment.
79
+ const bareDeployment = { OAUTH_BRIDGE_CREDS_DIR: credsDir, PATH: process.env.PATH ?? '', HOME: process.env.HOME ?? '' }
75
80
  // THE PAGE'S OWN LOADS, COUNTED. A screen that asks the server twice paints exactly like one that asks once,
76
81
  // and each request spends the person's rate budget, so the only instrument that sees a double load is a count.
77
82
  const loads = []
@@ -89,6 +94,10 @@ const server = createServer((req, res) => {
89
94
  accountNames: { northwind: 'Northwind Foods' }, brand: 'Northwind Group', administratorContact: state.contact })
90
95
  }
91
96
  if (path === '/portal/admin/config' && !wantsPage) {
97
+ if (state.nothingSet) {
98
+ return json({ ...adminConfig, engine: { ...engineInventory(bareDeployment), binaryPresent: true, program: 'claude', install: null },
99
+ providers: providerInventory(bareDeployment) })
100
+ }
92
101
  return json(state.programMissing ? { ...adminConfig, engine: { ...adminConfig.engine, binaryPresent: false } } : adminConfig)
93
102
  }
94
103
  if (path === '/portal/api/about') return json(about)
@@ -257,19 +266,27 @@ const settingsProbe = `(() => {
257
266
  mono: [...r.querySelectorAll('.cfg-note.mono')].map((n) => flat(n.textContent)),
258
267
  guide: r.querySelector('.cfg-act a.pill') ? { text: flat(r.querySelector('.cfg-act a.pill').textContent), href: r.querySelector('.cfg-act a.pill').getAttribute('href'), target: r.querySelector('.cfg-act a.pill').getAttribute('target') } : null,
259
268
  stateRight: Math.round(r.querySelector('.cfg-state').getBoundingClientRect().right),
269
+ dot: r.querySelector('.cfg-dot')?.className ?? null,
270
+ command: flat(r.querySelector('.cfg-cmd code')?.textContent) || null,
271
+ copy: flat(r.querySelector('.cfg-cmd button')?.textContent) || null,
260
272
  })
273
+ // NEEDED, THEN OPTIONAL (board approved 2026-11-25). The engine is the first category under Needed.
274
+ const cats = (g, group) => [...(g?.querySelectorAll('.cfg-cat') ?? [])].map((c) => ({
275
+ group,
276
+ label: flat(c.querySelector('.cfg-sub')?.textContent),
277
+ note: flat(c.querySelector('.cfg-cat-note')?.textContent) || null,
278
+ rows: [...c.querySelectorAll('.cfg-row')].map(row),
279
+ }))
280
+ const all = [...cats(groups[1], 'Needed'), ...cats(groups[2], 'Optional')]
261
281
  const pageText = document.body.innerText
262
282
  return {
263
283
  renderedChars: flat(screen.innerText).length,
264
284
  title: flat(screen.querySelector('h1.page-title')?.textContent),
265
285
  sections: groups.map((g) => flat(g.querySelector(':scope > .eyebrow')?.textContent)),
286
+ headings: groups.map((g) => g.querySelector(':scope > .eyebrow')?.tagName ?? null),
266
287
  signIn: [...(groups[0]?.querySelectorAll('.cfg-row') ?? [])].map(row),
267
- engine: [...(groups[1]?.querySelectorAll('.cfg-row') ?? [])].map(row),
268
- categories: [...(groups[2]?.querySelectorAll('.cfg-cat') ?? [])].map((c) => ({
269
- label: flat(c.querySelector('.cfg-sub')?.textContent),
270
- note: flat(c.querySelector('.cfg-cat-note')?.textContent) || null,
271
- rows: [...c.querySelectorAll('.cfg-row')].map(row),
272
- })),
288
+ engine: all.find((c) => c.label === 'Engine')?.rows ?? [],
289
+ categories: all.filter((c) => c.label !== 'Engine'),
273
290
  leaks: ${LEAKS}.flatMap((re) => { const m = re.exec(pageText); return m ? [m[0]] : [] }),
274
291
  }
275
292
  })()`
@@ -410,7 +427,8 @@ for (const theme of ['light', 'dark']) {
410
427
  out[`settings-${theme}`] = s
411
428
  ok(s.renderedChars > 400, `the page rendered real text (${s.renderedChars} chars) — every absence below is worthless without it`)
412
429
  ok(s.title === 'Installation settings', `the page is titled "Installation settings" (saw "${s.title}")`)
413
- ok(same(s.sections, ['Sign-in', 'Engine', 'Providers']), `three sections: Sign-in, Engine, Providers (saw ${JSON.stringify(s.sections)})`)
430
+ ok(same(s.sections, ['Sign-in', 'Needed', 'Optional']), `three sections: Sign-in, Needed, Optional (saw ${JSON.stringify(s.sections)})`)
431
+ ok(same(s.headings, ['DIV', 'H2', 'H2']), `Needed and Optional are headings (saw ${JSON.stringify(s.headings)})`)
414
432
  ok(s.signIn.length === 1, `Sign-in is one row (saw ${s.signIn.length})`)
415
433
  const si = s.signIn[0]
416
434
  ok(si && si.name === SPEC.signInName && si.val === null && si.state === 'Configured',
@@ -419,17 +437,27 @@ for (const theme of ['light', 'dark']) {
419
437
  const rights = [...s.signIn, ...s.engine, ...s.categories.flatMap((c) => c.rows)].map((r) => r.stateRight)
420
438
  ok(rights.length >= 9 && new Set(rights).size === 1, `every state lines up in one column (right edges ${JSON.stringify([...new Set(rights)])})`)
421
439
  ok(s.engine.length === 1 && s.engine[0].name === 'Anthropic' && s.engine[0].state === 'Subscription',
422
- `Engine carries the engine row alone (saw ${JSON.stringify(s.engine)})`)
440
+ `Engine, first under Needed, carries the engine row alone (saw ${JSON.stringify(s.engine)})`)
423
441
  ok(!s.engine.some((r) => /web search/i.test(r.name)), "the engine's own web search, off on both engines, has no row under Engine")
424
442
  ok(same(s.categories.map((c) => c.label), SPEC.categories), `four provider categories, in order (saw ${JSON.stringify(s.categories.map((c) => c.label))})`)
443
+ ok(same(s.categories.map((c) => c.group), ['Needed', 'Needed', 'Optional', 'Optional']),
444
+ `the register and the research key are Needed, the Chinese marketplace and case law Optional (saw ${JSON.stringify(s.categories.map((c) => [c.label, c.group]))})`)
425
445
  const repeated = s.categories.flatMap((c) => c.rows.filter((r) => [r.name, r.val ?? '', ...r.notes].some((t) => t.includes(c.label))).map((r) => `${c.label} on ${r.name}`))
426
446
  ok(repeated.length === 0, `no category name is repeated on a row (saw ${JSON.stringify(repeated)})`)
427
447
  ok(!s.categories.flatMap((c) => c.rows).some((r) => /web search/i.test(r.name)), 'the engine\'s web search is not also listed as a provider')
428
448
  const rows = Object.fromEntries(s.categories.flatMap((c) => c.rows).map((r) => [r.name, r]))
429
449
  ok(rows.Corsearch?.state === 'Configured' && rows.Perplexity?.state === 'Configured', 'the configured register and research key read Configured')
430
- ok(rows.SerpAPI?.state === 'Missing' && same(rows.SerpAPI?.notes, ['A key is needed'])
450
+ // AN OPTIONAL KEY ABSENT IS NOT A FAULT: "Not set up", the off look with an open dot, its guide, and the
451
+ // setup command with Copy (boards approved 2026-11-25).
452
+ ok(rows.SerpAPI?.state === 'Not set up' && same(rows.SerpAPI?.notes, ['A key is needed'])
431
453
  && rows.SerpAPI?.guide?.text === 'Setup guide' && /providers\/README\.md#research-and-support-sources$/.test(rows.SerpAPI?.guide?.href ?? '') && rows.SerpAPI?.guide?.target === '_blank',
432
- `a missing key says "A key is needed" beside a Setup guide that opens its guide (saw ${JSON.stringify(rows.SerpAPI)})`)
454
+ `an optional missing key reads "Not set up" with "A key is needed" beside a Setup guide that opens its guide (saw ${JSON.stringify(rows.SerpAPI)})`)
455
+ ok(/\boff\b/.test(rows.SerpAPI?.dot ?? '') && /\bopen\b/.test(rows.SerpAPI?.dot ?? '') && !/\bbad\b/.test(rows.SerpAPI?.dot ?? ''),
456
+ `an optional source not set up takes the neutral open dot (saw ${JSON.stringify(rows.SerpAPI?.dot)})`)
457
+ ok(rows.SerpAPI?.command === 'npx clearotron install' && rows.SerpAPI?.copy === 'Copy',
458
+ `the optional key's row shows the setup command with Copy (saw ${JSON.stringify([rows.SerpAPI?.command, rows.SerpAPI?.copy])})`)
459
+ ok(['CourtListener', 'Legal Data Hunter', 'EUR-Lex', 'EUIPO Boards of Appeal', 'Corsearch', 'Perplexity'].every((n) => rows[n]?.command === null),
460
+ 'a sign-in, a configured source or one this build does not ship shows a command')
433
461
  for (const name of ['CourtListener', 'Legal Data Hunter']) {
434
462
  ok(rows[name]?.state === 'Not set up' && same(rows[name]?.notes, ['One-time sign-in needed']) && rows[name]?.guide?.text === 'Setup guide'
435
463
  && /oauth-mcp-bridge\/README\.md#one-time-setup-per-remote-mcp-server$/.test(rows[name]?.guide?.href ?? ''),
@@ -473,6 +501,35 @@ for (const theme of ['light', 'dark']) {
473
501
  }
474
502
  state.programMissing = false
475
503
 
504
+ // ── Installation settings, nothing set up
505
+ console.log('\nInstallation settings, nothing set up:')
506
+ state.nothingSet = true
507
+ if (await open('/portal/admin/config', "document.querySelectorAll('.cfg-row').length >= 9", 'Installation settings drew its rows with nothing set up')) {
508
+ await setTheme(theme)
509
+ const bare = (await evalIn(settingsProbe)) ?? {}
510
+ const rowsBare = Object.fromEntries(bare.categories.flatMap((c) => c.rows).map((r) => [r.name, r]))
511
+ ok(bare.engine?.[0]?.state === 'Missing' && bare.engine?.[0]?.command === 'npx clearotron install',
512
+ `the Engine row with no AI chosen shows the setup command (saw ${JSON.stringify(bare.engine?.[0])})`)
513
+ ok(rowsBare['No register selected']?.state === 'Missing' && rowsBare['No register selected']?.command === 'npx clearotron install',
514
+ `no register chosen shows the setup command (saw ${JSON.stringify(rowsBare['No register selected'])})`)
515
+ ok(rowsBare.Perplexity?.state === 'Missing' && same(rowsBare.Perplexity?.notes, ['A key is needed. A Knockout search can still run.'])
516
+ && /\bbad\b/.test(rowsBare.Perplexity?.dot ?? '') && rowsBare.Perplexity?.command === 'npx clearotron install',
517
+ `the research row says a Knockout search can still run, red, with the command (saw ${JSON.stringify(rowsBare.Perplexity)})`)
518
+ ok(!Object.values(rowsBare).some((r) => r.name !== 'Perplexity' && r.notes.some((n) => /Knockout search can still run/.test(n))),
519
+ 'the Knockout sentence is on another row')
520
+ ok(rowsBare.SerpAPI?.state === 'Not set up' && /\bopen\b/.test(rowsBare.SerpAPI?.dot ?? ''), `SerpAPI stays neutral (saw ${JSON.stringify(rowsBare.SerpAPI)})`)
521
+ ok(bare.leaks.length === 0, `no variable name, credential path or README reference anywhere on the page (saw ${JSON.stringify(bare.leaks)})`)
522
+ await capture(`installation-settings-nothing-set-${theme}`)
523
+ // AT PHONE WIDTH the command lines and their Copy stay inside the page.
524
+ await cmd('Emulation.setDeviceMetricsOverride', { width: 390, height: 900, deviceScaleFactor: 1, mobile: true })
525
+ await sleep(250)
526
+ const sideways = (await evalIn('document.documentElement.scrollWidth - document.documentElement.clientWidth')) ?? null
527
+ ok(sideways === 0, `Installation settings at 390 px does not scroll sideways (${sideways}px)`)
528
+ await cmd('Emulation.clearDeviceMetricsOverride', {})
529
+ await capture(`installation-settings-nothing-set-${theme}-390`, 390)
530
+ }
531
+ state.nothingSet = false
532
+
476
533
  // ── Preferences, contact set and unset
477
534
  for (const [label, contact] of [['contact-set', CONTACT], ['contact-unset', null]]) {
478
535
  console.log(`\nPreferences, ${label}:`)
package/shared/brand.mjs CHANGED
@@ -609,6 +609,14 @@ const REPORT_DARK_RULES = [
609
609
  // are crimson text like a link: on the dark ground --crimson measured 1.77:1, so they take the links' colour.
610
610
  ['a,.wm,details.drill>summary,.rr-all>summary', `color:${D.crimsonText}`],
611
611
  ['.wm .ridge path', `fill:${D.crimsonText}`],
612
+ // The folded list's "Show all {n}" control is crimson words like the report's other "Show all" links.
613
+ ['.lb-show,.rgroup.lowerband>summary:hover .lb-show', `color:${D.crimsonText}`],
614
+ // The web and marketplace names' addresses: report.css's .crow .curl out-ranks the bare link rule above, and kept
615
+ // the light crimson on the dark ground (about 1.8:1, measured 2026-11-26).
616
+ ['.crow .curl', `color:${D.crimsonText}`],
617
+ // The citation that opened the conflict panel is outlined in the accent, which is a fill in the dark theme.
618
+ ['.fa-ords a.cite-on', `outline-color:${D.crimsonText}`],
619
+ ['.rgroup.lowerband>summary:hover .lb-show', `border-color:${D.crimsonText}`],
612
620
  ['.tbbtn:hover,.util:hover,.tb-back:hover,.theme-toggle.tt-page:hover', `color:${D.crimsonText};border-color:${D.crimsonText}`],
613
621
  ['.rep-stickyhead', 'background:rgba(15,14,12,.82)'],
614
622
  // The section strip's current entry is set in the light ink with a dark tint, which on the dark bar left it the
@@ -230,6 +230,30 @@ that would actually be searched, the expected turnaround, and any blockers. Rela
230
230
  would surprise them — most often a scope narrower than the words they used. Only then `start_run`,
231
231
  with the same arguments.
232
232
 
233
+ **When time is short, offer Urgent, and let the user choose.** Urgent requests the AI service's faster
234
+ setting wherever it is available. The search and report are the same. Offer it when the deadline (an
235
+ order's `deadline`, or a time the user states) falls before the end of the Standard turnaround in
236
+ `plan_run`'s `howSoon`, or when the user says urgent, today, ASAP or the like. State Urgent's
237
+ turnaround, that it uses 2 searches, and what the account has left today, all as `plan_run` reports
238
+ them, then ask: Urgent or Standard? Pass `urgent: true` to `start_run` only when they answer Urgent.
239
+ Never set it yourself, and never because a deadline looks tight.
240
+
241
+ - If `howSoon.urgentAvailable` is false, give the notice in its `urgentNote`, and offer Standard if it
242
+ fits.
243
+ - If Urgent exceeds today's allowance, give the remaining count and Urgent's cost from the preview.
244
+ Offer Standard if it fits. If the user chose Urgent, wait for agreement before submitting Standard.
245
+ With no searches left today, neither option fits.
246
+
247
+ For example, with invented names:
248
+
249
+ > **User:** Can you clear Name A for software in the EU and US? I need it before my 3pm call with the client.
250
+ >
251
+ > **You:** I can run a Multi-country focus search for Name A in the EU and US. Standard takes 1.5 to 2.5 hours, so it may not be back before 3pm. Urgent takes 30 minutes to 1 hour and uses 2 of the 4 searches Company A has left today. Same search and same report, run on the AI service's faster setting. Run it Urgent, or Standard?
252
+ >
253
+ > **User:** Urgent.
254
+
255
+ Then `start_run` with the same arguments and `urgent: true`.
256
+
233
257
  **An accepted `start_run` means submitted, not started.** The search waits for a free slot and a check
234
258
  that it can run. Tell the user it is submitted, never that it is starting or running. Report a start
235
259
  once the matching run has a status, and give its actual state.
@@ -50,6 +50,19 @@ account's default, or a saved search), the territories and marketplaces that wou
50
50
  the turnaround, and any blockers, as questions to put back. It is a check, not a gate. Put what it
51
51
  reports in the confirmation, above all a search or a scope narrower than the words the requester used.
52
52
 
53
+ **When time is short, offer Urgent, and start on the answer.** Urgent requests the AI service's faster
54
+ setting wherever it is available. The search and report are the same. Offer it when the deadline falls
55
+ before the end of the Standard turnaround in `plan_run`'s `howSoon`, or when the requester says urgent,
56
+ today, ASAP or the like. In the confirmation, state Urgent's turnaround, that it uses 2 searches, and
57
+ what the account has left today, all as `plan_run` reports them, and ask: Urgent or Standard? This is
58
+ the one question that waits for its answer: start the search when it comes, with `urgent: true` only on
59
+ Urgent. Never set it yourself.
60
+ - If `howSoon.urgentAvailable` is false, give the notice in its `urgentNote`, and start at Standard at
61
+ once if it fits.
62
+ - If Urgent exceeds today's allowance, give the remaining count and Urgent's cost from the preview.
63
+ Offer Standard if it fits. If the requester chose Urgent, wait for agreement before submitting
64
+ Standard. With no searches left today, neither option fits.
65
+
53
66
  **4. Send the confirmation in three groups, in this order.**
54
67
  - **Corrections and commitments:** a correction to the mark, the deadline diarised, the recipients, the
55
68
  billing, and anything instructed that you will do or cannot do.
@@ -60,15 +73,16 @@ reports in the confirmation, above all a search or a scope narrower than the wor
60
73
  - **Given:** what the request stated, said back briefly.
61
74
 
62
75
  End with **"Submitted on this understanding — reply to correct anything."** Call `start_run` with the
63
- same arguments at once. If validation refuses the submission, correct the named input and try once more.
64
- If the ID is already queued or processing, check the existing order. If the outcome is unknown, check its
65
- status before trying again. Confirm submission only after acceptance or after verifying that this order
66
- was already submitted. Give the requester the actionable reason in plain words. Keep raw diagnostics for
67
- staff.
68
-
69
- **5. What holds a search back.** Only two things: a mark that cannot be made out (absent, or with no
70
- clearly likely reading), and goods and classes both absent. Ask for the missing item, and start when the
71
- answer arrives. Nothing else holds a search:
76
+ same arguments at once. When you asked Urgent or Standard, end with that question instead, and call
77
+ `start_run` when it is answered. If validation refuses the submission, correct the named input and try
78
+ once more. If the ID is already queued or processing, check the existing order. If the outcome is
79
+ unknown, check its status before trying again. Confirm submission only after acceptance or after
80
+ verifying that this order was already submitted. Give the requester the actionable reason in plain
81
+ words. Keep raw diagnostics for staff.
82
+
83
+ **5. What holds a search back.** Besides the Urgent question, only two things: a mark that cannot be
84
+ made out (absent, or with no clearly likely reading), and goods and classes both absent. Ask for the
85
+ missing item, and start when the answer arrives. Nothing else holds a search:
72
86
  - A mark with one obvious mistyping is searched on the corrected reading, with the correction first in
73
87
  the confirmation ("the form wrote NOVAPLUSE; searched as NOVAPULSE — say so if that is wrong").
74
88
  - A missing reference never holds a search.