oxedyne/daimond/dev/shot_governor.mjs
2.0 KiB, 1 run
created by r2519314175:153, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | // shot_governor.mjs — a visual capture of the spend gate in the real app. |
| 2 | // |
| 3 | // Drives a Diamond conductor into a large fan-out (60 spawn_agent calls in one |
| 4 | // steer) and captures the predictive gate modal it raises BEFORE any worker |
| 5 | // runs — the "fifty agents in a blink" case, stopped at the door. Then a small |
| 6 | // fan-out to show it clears silently. |
| 7 | // |
| 8 | // Needs dev/serve.mjs (DAIMOND_PORT, default 8777) and dev/mockllm.mjs |
| 9 | // (DAIMOND_MOCK_PORT, default 9099). |
| 10 | import { open, shot } from './harness.mjs'; |
| 11 | |
| 12 | const s = await open({ name: 'governor-shot', signIn: true, connect: true }); |
| 13 | const { page } = s; |
| 14 | |
| 15 | // A fresh Diamond through the real UI. |
| 16 | await page.click('#new-diamond-btn'); |
| 17 | await page.waitForSelector('.dlg-input', { timeout: 8000 }); |
| 18 | await page.fill('.dlg-input', 'Audit the codebase'); |
| 19 | await page.click('.dlg-ok'); |
| 20 | await page.waitForSelector('#steer-input', { timeout: 10000 }); |
| 21 | await page.waitForTimeout(400); |
| 22 | |
| 23 | // A conductor turn that dispatches 60 agents at once. |
| 24 | const specs = []; |
| 25 | for (let i = 0; i < 60; i++) specs.push(`spawn_agent {"name":"a${i}","task":"inspect module ${i}"}`); |
| 26 | const steer = '@tools ' + specs.join(' ;; '); |
| 27 | await page.fill('#steer-input', steer); |
| 28 | await page.click('#steer-send'); |
| 29 | |
| 30 | // The gate should raise the app's confirm modal before dispatch. |
| 31 | const gate = await page.waitForSelector('.dlg-card, .dialog, [class*="dlg"]', { timeout: 15000 }).catch(() => null); |
| 32 | await page.waitForTimeout(400); |
| 33 | const modalText = await page.evaluate(() => { |
| 34 | const el = document.querySelector('.dlg-card, .dialog, [class*="dlg"]'); |
| 35 | return el ? el.innerText.replace(/\s+/g, ' ').trim() : '(no modal found)'; |
| 36 | }); |
| 37 | console.log('GATE MODAL:', modalText); |
| 38 | await shot(s, 'governor-gate-60'); |
| 39 | |
| 40 | // Decline it: nothing should be dispatched. |
| 41 | const cancel = await page.$('.dlg-cancel, .dlg-no, button[data-role="cancel"]'); |
| 42 | if (cancel) await cancel.click(); |
| 43 | else await page.keyboard.press('Escape'); |
| 44 | await page.waitForTimeout(500); |
| 45 | await shot(s, 'governor-after-decline'); |
| 46 | |
| 47 | await s.close(); |
| 48 | console.log('done — screenshots written'); |