@broberg/lens-daemon 0.1.56 → 0.1.58
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/package.json +1 -1
- package/src/flow.ts +70 -7
- package/src/http.ts +14 -1
- package/src/mcp.ts +12 -2
- package/src/secret-fill.ts +14 -0
- package/src/service.ts +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@broberg/lens-daemon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
4
4
|
"description": "The Lens module of the cardmem daemon (flows, critic, coverage, capture sessions, the /lens/* routes and the cardmem-lens MCP) as a package. The daemon mounts createLensRouter(deps) + createLensMcpRouter(deps). Bun runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/flow.ts
CHANGED
|
@@ -34,7 +34,7 @@ import { takeShot, settleForShot } from './capture.ts';
|
|
|
34
34
|
import { runCritic, topFindingMessage, type CriticMode, type CriticReport } from './critic.ts';
|
|
35
35
|
import { waitForBuild, observeBuild } from './build-marker.ts';
|
|
36
36
|
import { fillAndVerify } from './fill.ts';
|
|
37
|
-
import { fillSecret } from './secret-fill.ts';
|
|
37
|
+
import { fillSecret, getVaultWriter, type VaultReceipt, type VaultTarget } from './secret-fill.ts';
|
|
38
38
|
import { storagePayload, type StorageSeed } from './seed-storage.ts';
|
|
39
39
|
import { passwordInUrl, type FilledPassword, type PasswordInUrlFinding } from './password-in-url.ts';
|
|
40
40
|
import { assertTestMailbox, cleanupMail, fillFromMail, httpMailSource, type MailFrom, type MailSource } from './mail-fill.ts';
|
|
@@ -164,6 +164,8 @@ export type FlowStep =
|
|
|
164
164
|
// state (a cookie banner, an optional step) without failing the whole run.
|
|
165
165
|
| { type: 'autocomplete'; testid: string; value: string; option: string; pickText?: string; pickIndex?: number; label?: string; timeout?: number }
|
|
166
166
|
| { type: 'capture'; testid: string; as: string; from?: 'text' | 'value'; label?: string; timeout?: number }
|
|
167
|
+
/** F010.15 — the value goes straight into cardmem's vault; the run only ever holds its receipt. */
|
|
168
|
+
| { type: 'capture'; testid: string; to: 'vault'; vault: VaultTarget; label?: string; timeout?: number }
|
|
167
169
|
| { type: 'conditional'; testid: string; present: boolean; steps: FlowStep[]; label?: string; timeout?: number }
|
|
168
170
|
| { type: 'loop'; data: Array<Record<string, unknown>>; steps: FlowStep[]; label?: string; parallel?: number }
|
|
169
171
|
// F009.125 — open the loaded extension's popup as its own page in the SAME browser,
|
|
@@ -213,6 +215,9 @@ export interface Flow {
|
|
|
213
215
|
* uses passkeys by itself (no dialog), on every page of the run incl. popups.
|
|
214
216
|
* The passkey lives only for the run. Chromium only. */
|
|
215
217
|
passkeys?: 'unavailable' | 'virtual';
|
|
218
|
+
/** F009.141 — a named browser («in <name>:») signs in as its OWN user. Without an
|
|
219
|
+
* entry it uses the run's auth, as before. */
|
|
220
|
+
browsers?: Record<string, { auth: AuthConfig }>;
|
|
216
221
|
steps: FlowStep[];
|
|
217
222
|
}
|
|
218
223
|
|
|
@@ -603,6 +608,22 @@ export function parseFlow(input: unknown): Flow {
|
|
|
603
608
|
if (f.passkeys !== undefined && f.passkeys !== 'unavailable' && f.passkeys !== 'virtual') {
|
|
604
609
|
throw new Error('flow.passkeys must be "unavailable" or "virtual" (or left out)');
|
|
605
610
|
}
|
|
611
|
+
let browsers: Record<string, { auth: AuthConfig }> | undefined;
|
|
612
|
+
if (f.browsers !== undefined) {
|
|
613
|
+
const b = f.browsers as unknown;
|
|
614
|
+
if (!b || typeof b !== 'object' || Array.isArray(b)) throw new Error('flow.browsers must be {<name>: {auth: {...}}}');
|
|
615
|
+
browsers = {};
|
|
616
|
+
for (const [name, v] of Object.entries(b as Record<string, unknown>)) {
|
|
617
|
+
if (name === 'main' || !BROWSER_NAME.test(name)) {
|
|
618
|
+
throw new Error(`flow.browsers: "${name}" is not a named browser (a-z, 0-9, _ or -, starting with a letter; "main" is the run's own auth)`);
|
|
619
|
+
}
|
|
620
|
+
const e = v as { auth?: unknown } | null;
|
|
621
|
+
if (!e || typeof e !== 'object' || Array.isArray(e) || Object.keys(e).some((k) => k !== 'auth') || !e.auth || typeof e.auth !== 'object' || Array.isArray(e.auth)) {
|
|
622
|
+
throw new Error(`flow.browsers.${name} must be {auth: {...}} — an auth object and nothing else`);
|
|
623
|
+
}
|
|
624
|
+
browsers[name] = { auth: e.auth as AuthConfig };
|
|
625
|
+
}
|
|
626
|
+
}
|
|
606
627
|
if (!extension && usesPopup(f.steps as FlowStep[])) {
|
|
607
628
|
throw new Error('openPopup / in:"popup" need flow.extension — there is no extension loaded to open a popup from');
|
|
608
629
|
}
|
|
@@ -617,6 +638,7 @@ export function parseFlow(input: unknown): Flow {
|
|
|
617
638
|
...(browser ? { browser } : {}),
|
|
618
639
|
...(networkShapes ? { network_shapes: networkShapes } : {}),
|
|
619
640
|
...(f.passkeys === 'unavailable' || f.passkeys === 'virtual' ? { passkeys: f.passkeys } : {}),
|
|
641
|
+
...(browsers ? { browsers } : {}),
|
|
620
642
|
steps: f.steps as FlowStep[],
|
|
621
643
|
};
|
|
622
644
|
}
|
|
@@ -766,7 +788,7 @@ export const STEP_FIELDS: Record<string, string[]> = {
|
|
|
766
788
|
uploadFile: ['testid', 'path'],
|
|
767
789
|
uploadSelector: ['selector', 'path', 'frame'],
|
|
768
790
|
autocomplete: ['testid', 'value', 'option', 'pickText', 'pickIndex'],
|
|
769
|
-
capture: ['testid', 'as', 'from'],
|
|
791
|
+
capture: ['testid', 'as', 'from', 'to', 'vault'],
|
|
770
792
|
conditional: ['testid', 'present', 'steps'],
|
|
771
793
|
loop: ['data', 'steps', 'parallel'],
|
|
772
794
|
openPopup: ['path'],
|
|
@@ -883,7 +905,18 @@ function validateAndNormalizeSteps(steps: unknown[], depth = 0, inParallel = fal
|
|
|
883
905
|
throw new Error('autocomplete step requires pickText (string) or pickIndex (number)');
|
|
884
906
|
}
|
|
885
907
|
}
|
|
886
|
-
if (s.type === 'capture' &&
|
|
908
|
+
if (s.type === 'capture' && (s as { to?: unknown }).to !== undefined) {
|
|
909
|
+
// F010.15 — to vault: a target, and never a variable that would hold the value.
|
|
910
|
+
const c = s as { to?: unknown; vault?: unknown; as?: unknown; from?: unknown };
|
|
911
|
+
const v = c.vault as Partial<VaultTarget> | undefined;
|
|
912
|
+
if (c.to !== 'vault') throw new Error('capture step: "to" must be "vault"');
|
|
913
|
+
if (c.as !== undefined || c.from !== undefined) throw new Error('capture to vault takes no "as"/"from" — the value must never become a flow variable');
|
|
914
|
+
if (!v || typeof v !== 'object' || typeof v.project !== 'string' || !v.project.trim() || typeof v.name !== 'string' || !v.name.trim()
|
|
915
|
+
|| Object.keys(v).some((k) => !['project', 'name', 'env_var_name'].includes(k))
|
|
916
|
+
|| (v.env_var_name !== undefined && (typeof v.env_var_name !== 'string' || !/^[A-Z_][A-Z0-9_]*$/.test(v.env_var_name)))) {
|
|
917
|
+
throw new Error('capture to vault needs vault: {project, name, env_var_name?} (env_var_name in UPPER_SNAKE_CASE)');
|
|
918
|
+
}
|
|
919
|
+
} else if (s.type === 'capture' && typeof (s as { as?: unknown }).as !== 'string') {
|
|
887
920
|
throw new Error('capture step requires a string "as" name');
|
|
888
921
|
}
|
|
889
922
|
// F009.121 — a fill carries its value inline OR names where to read a secret
|
|
@@ -1385,6 +1418,11 @@ function parseManuscriptStep(s: string): FlowStep {
|
|
|
1385
1418
|
throw new Error(`autocomplete step "${s}" needs a pick after [option]: "text" or #index`);
|
|
1386
1419
|
}
|
|
1387
1420
|
case 'capture': {
|
|
1421
|
+
// F010.15 — "capture [testid] to vault <project>/<name> [as <ENV_VAR>]".
|
|
1422
|
+
const v = s.match(/^capture\s+\[([^\]]+)\]\s+to\s+vault\s+([\w.-]+)\/(.+?)(?:\s+as\s+([A-Z_][A-Z0-9_]*))?\s*$/);
|
|
1423
|
+
if (v) {
|
|
1424
|
+
return { type: 'capture', testid: v[1]!.trim(), to: 'vault' as const, vault: { project: v[2]!, name: v[3]!.trim(), ...(v[4] ? { env_var_name: v[4] } : {}) } };
|
|
1425
|
+
}
|
|
1388
1426
|
// "capture [testid] as <name>" (element text) or "... as <name> value" (input value).
|
|
1389
1427
|
const m = s.match(/^capture\s+\[([^\]]+)\]\s+as\s+(\w+)(\s+value)?\s*$/i);
|
|
1390
1428
|
if (!m) throw new Error(`capture step "${s}" needs "capture [testid] as <name> [value]"`);
|
|
@@ -1683,7 +1721,7 @@ function describe(step: FlowStep): string {
|
|
|
1683
1721
|
case 'uploadFile': return `upload ${Array.isArray(step.path) ? `${step.path.length} files` : (step.path.startsWith('data:') ? 'data:…' : step.path)} → ${step.testid}`;
|
|
1684
1722
|
case 'press': return `press ${step.key}${step.testid ? ` @${step.testid}` : ''}`;
|
|
1685
1723
|
case 'autocomplete': return `autocomplete ${step.testid} → ${step.pickText !== undefined ? `"${step.pickText}"` : `#${step.pickIndex}`}`;
|
|
1686
|
-
case 'capture': return `capture ${step.testid} → {{${step.as}}}`;
|
|
1724
|
+
case 'capture': return 'to' in step ? `capture ${step.testid} → vault ${step.vault.project}/${step.vault.name}` : `capture ${step.testid} → {{${step.as}}}`;
|
|
1687
1725
|
case 'conditional': return `${step.present ? 'if' : 'unless'} [${step.testid}]`;
|
|
1688
1726
|
case 'loop': return 'loop';
|
|
1689
1727
|
case 'openPopup': return `openPopup ${step.path ?? '(manifest popup)'}`;
|
|
@@ -2150,7 +2188,7 @@ async function sampleMotion(
|
|
|
2150
2188
|
const MOTION_SAMPLE_MS = 250;
|
|
2151
2189
|
|
|
2152
2190
|
|
|
2153
|
-
async function execStep(page: Page, step: FlowStep, base: string, vars: Record<string, unknown>, critic: CriticMode, localPath?: string, sink?: CriticSink, pwSink?: FilledPassword[], readySink?: NotListeningFinding[], secretRoot?: string, mailCtx?: { source: MailSource; consumed: Array<{ to: string; id: string }> }): Promise<Buffer | null | { __inspect: string } | { __via: string; __build?: string; __redirect?: string }> {
|
|
2191
|
+
async function execStep(page: Page, step: FlowStep, base: string, vars: Record<string, unknown>, critic: CriticMode, localPath?: string, sink?: CriticSink, pwSink?: FilledPassword[], readySink?: NotListeningFinding[], secretRoot?: string, mailCtx?: { source: MailSource; consumed: Array<{ to: string; id: string }> }): Promise<Buffer | null | { __inspect: string } | { __vault: VaultReceipt } | { __via: string; __build?: string; __redirect?: string }> {
|
|
2154
2192
|
switch (step.type) {
|
|
2155
2193
|
case 'goto': {
|
|
2156
2194
|
const p = subst(step.path, vars);
|
|
@@ -2689,6 +2727,27 @@ async function execStep(page: Page, step: FlowStep, base: string, vars: Record<s
|
|
|
2689
2727
|
case 'capture': {
|
|
2690
2728
|
const loc = page.locator(sel(step.testid)).first();
|
|
2691
2729
|
await loc.waitFor({ state: 'attached', timeout: stepTimeout(step) });
|
|
2730
|
+
if ('to' in step) {
|
|
2731
|
+
// F010.15 — read in the daemon, stored in the vault, never returned. Every
|
|
2732
|
+
// message below names the target and never the value.
|
|
2733
|
+
const writer = getVaultWriter();
|
|
2734
|
+
if (!writer) throw new Error(`capture [${step.testid}] to vault: this daemon is not signed in to cardmem — nothing stored`);
|
|
2735
|
+
const value = (await loc.evaluate((el) => {
|
|
2736
|
+
const v = (el as HTMLInputElement).value;
|
|
2737
|
+
return typeof v === 'string' && v ? v : (el.textContent ?? '');
|
|
2738
|
+
}, undefined, { timeout: stepTimeout(step) })).trim();
|
|
2739
|
+
if (!value) throw new Error(`capture [${step.testid}] to vault: the element holds no value — nothing stored`);
|
|
2740
|
+
// Known to the run from here on, so F010.14 redacts it from every later report.
|
|
2741
|
+
pwSink?.push({ anchor: step.testid, value });
|
|
2742
|
+
let receipt: VaultReceipt;
|
|
2743
|
+
try {
|
|
2744
|
+
receipt = await writer(step.vault, value);
|
|
2745
|
+
} catch (err) {
|
|
2746
|
+
const why = (err instanceof Error ? err.message : String(err)).split(value).join('[redacted]');
|
|
2747
|
+
throw new Error(`capture [${step.testid}] to vault ${step.vault.project}/${step.vault.name}: storing failed (${why}) — nothing confirmed stored`);
|
|
2748
|
+
}
|
|
2749
|
+
return { __vault: receipt };
|
|
2750
|
+
}
|
|
2692
2751
|
vars[step.as] =
|
|
2693
2752
|
step.from === 'value'
|
|
2694
2753
|
? await loc.inputValue({ timeout: stepTimeout(step) })
|
|
@@ -2935,8 +2994,10 @@ export async function runFlow(flow: Flow, env: AuthEnv, opts: RunFlowOptions = {
|
|
|
2935
2994
|
resolvePage = res;
|
|
2936
2995
|
rejectPage = rej;
|
|
2937
2996
|
});
|
|
2997
|
+
// F009.141 — its own user when the flow names one, else the run's.
|
|
2998
|
+
const own = flow.browsers?.[name];
|
|
2938
2999
|
const closed = withPage(
|
|
2939
|
-
{ prepareContext: prepare, seedStorage, viewport: opts.viewport, engine: opts.engine, locale: opts.locale, timezone: opts.timezone, reducedMotion: opts.reducedMotion },
|
|
3000
|
+
{ prepareContext: own ? authPrepare(own.auth, env) : prepare, seedStorage, viewport: opts.viewport, engine: opts.engine, locale: opts.locale, timezone: opts.timezone, reducedMotion: opts.reducedMotion },
|
|
2940
3001
|
async (p) => {
|
|
2941
3002
|
collectFailures(p);
|
|
2942
3003
|
resolvePage(p);
|
|
@@ -3092,6 +3153,8 @@ export async function runFlow(flow: Flow, env: AuthEnv, opts: RunFlowOptions = {
|
|
|
3092
3153
|
// F010.14 — never a password in the report, whatever the page keeps in its attributes.
|
|
3093
3154
|
const inspect = obj && '__inspect' in obj ? redactInspect((obj as { __inspect: string }).__inspect, filledPasswords) : null;
|
|
3094
3155
|
const via = obj && '__via' in obj ? (obj as { __via: string }).__via : null;
|
|
3156
|
+
// F010.15 — a vault capture reports its receipt only: id, name, masked preview.
|
|
3157
|
+
const vault = obj && '__vault' in obj ? JSON.stringify((obj as { __vault: VaultReceipt }).__vault) : null;
|
|
3095
3158
|
// F074.30 — a waitForBuild step KNOWS the live sha; it wins over the
|
|
3096
3159
|
// best-effort read taken before driving.
|
|
3097
3160
|
if (obj && '__build' in obj) observedBuild = (obj as { __build: string }).__build;
|
|
@@ -3151,7 +3214,7 @@ export async function runFlow(flow: Flow, env: AuthEnv, opts: RunFlowOptions = {
|
|
|
3151
3214
|
...navOffset,
|
|
3152
3215
|
ms_step_duration: Date.now() - stepStartedAt,
|
|
3153
3216
|
testid: testidOf(step),
|
|
3154
|
-
detail: redirect ?? inspect ?? (via ? `resolved via ${via}` : null),
|
|
3217
|
+
detail: redirect ?? inspect ?? vault ?? (via ? `resolved via ${via}` : null),
|
|
3155
3218
|
screenshot: Buffer.isBuffer(out) ? out : null,
|
|
3156
3219
|
// Attached on a PASSING step too. `high > 0` decides the status; it must
|
|
3157
3220
|
// not decide what gets reported. A screen with four medium findings and
|
package/src/http.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// all hit these. Artifact bytes are served here too, so an <img> in the
|
|
6
6
|
// dashboard points straight at the daemon.
|
|
7
7
|
|
|
8
|
-
import { setVaultReader } from './secret-fill.ts';
|
|
8
|
+
import { setVaultReader, setVaultWriter } from './secret-fill.ts';
|
|
9
9
|
import { browsersPresent } from './ensure-chromium.ts';
|
|
10
10
|
import { chromeCloneStatus } from './chrome-clones.ts';
|
|
11
11
|
import { Hono } from 'hono';
|
|
@@ -50,6 +50,19 @@ export function createLensRouter(deps: LensDeps): Hono {
|
|
|
50
50
|
const r = await cloud.callTool<{ value?: unknown }>('cardmem_get_secret', { secret_id: secretId });
|
|
51
51
|
return typeof r?.value === 'string' ? r.value : '';
|
|
52
52
|
});
|
|
53
|
+
// F010.15 — `capture … to vault` writes through the same key, the other way.
|
|
54
|
+
setVaultWriter(async (t, value) => {
|
|
55
|
+
const cloud = deps.cloud?.();
|
|
56
|
+
if (!cloud) throw new Error('not signed in to cardmem');
|
|
57
|
+
const r = await cloud.callTool<{ id?: unknown; name?: unknown; preview?: unknown }>('cardmem_create_secret', {
|
|
58
|
+
project: t.project,
|
|
59
|
+
name: t.name,
|
|
60
|
+
value,
|
|
61
|
+
...(t.env_var_name ? { env_var_name: t.env_var_name } : {}),
|
|
62
|
+
});
|
|
63
|
+
if (typeof r?.id !== 'string' || !r.id) throw new Error('cardmem did not return a secret id — nothing confirmed stored');
|
|
64
|
+
return { secret_id: r.id, name: typeof r.name === 'string' ? r.name : t.name, preview: typeof r.preview === 'string' ? r.preview : '' };
|
|
65
|
+
});
|
|
53
66
|
// lens F001.5 — the routes that used to be registered one by one in the
|
|
54
67
|
// daemon's index.ts. First, so their specific paths win as they did there.
|
|
55
68
|
registerDaemonRoutes(r, deps);
|
package/src/mcp.ts
CHANGED
|
@@ -374,7 +374,12 @@ export const TOOLS = [
|
|
|
374
374
|
'F255.7 — do not start until the app is serving the build under test. A commit sha waits for THAT build; true waits for any change from the build live at run start. Polls GET /api/health for a `build` field (the fleet contract), from the runner with no-store, requiring 3 consecutive matching reads so a fleet mid-rollout cannot end the wait early. Fails loudly if the app exposes no marker. Use it right after a deploy — otherwise a green run may be verifying the build you just replaced.',
|
|
375
375
|
},
|
|
376
376
|
auth: authSchema,
|
|
377
|
-
|
|
377
|
+
browsers: {
|
|
378
|
+
type: 'object',
|
|
379
|
+
description:
|
|
380
|
+
'F009.141 — {<name>: {auth: <auth object, same shape as flow.auth>}}: the named browser that steps address with browser:"<name>" (manuscript «- in <name>: …») signs in as its OWN user instead of the run\'s — two different people in one run (a mintEndpoint with a different body per browser, or two storageStates). A named browser without an entry keeps the run\'s auth. Relative paths resolve against local_path like flow.auth. "main" is the run\'s own auth and cannot be named here.',
|
|
381
|
+
},
|
|
382
|
+
browser: browserSchema,
|
|
378
383
|
network_shapes: {
|
|
379
384
|
type: ['boolean', 'object'],
|
|
380
385
|
description:
|
|
@@ -411,7 +416,7 @@ export const TOOLS = [
|
|
|
411
416
|
{
|
|
412
417
|
name: 'lens_run_manuscript',
|
|
413
418
|
description:
|
|
414
|
-
`Compile a human-readable markdown manuscript (fmc-automation style: "# flow: name", "base: <url>", then one "- <verb> …" per line) into a flow and run it E2E. VERBS (${MANUSCRIPT_VERBS.length}, this is the complete list): ${MANUSCRIPT_VERBS.join(' / ')}. Shapes: "- goto /x" · "- fill [testid] = value" · a PASSWORD without plaintext: "- fill [testid] from file <path>" (absolute, or relative to local_path) or "- fill [testid] from env <NAME>" (F009.121 — password inputs only; the value never appears in the run, the report or a screenshot) · "- click [testid]" · "- press Enter" (global) or "- press Enter [testid]" (on a focused element) · "- expectText [testid] ~ text" · "- drag [source] -> [target]" or "- drag [node] by 120,-40" (a canvas offset; both move in 10 mousemoves so React Flow / d3-drag nodes really move — "steps N" to change, F009.123) · "- upload [input-testid] = <fixture>" · an input with NO testid, also inside an open shadow root: "- uploadSelector <css> = <fixture>[, <fixture>]" (F009.136; fixtures repo-relative to local_path or data:) · a CODE FROM MAIL: "- fill [testid] from mail to jam@jams.party subject ~ Jam match /\\b\\d{6}\\b/" (F009.137 — waits ≤60 s for a mail received after the step started, read through mail-mcp; only the test mailbox webhouse.developer@gmail.com / jam@jams.party; the mail is deleted after the run, report carries mail {consumed, cleaned}; the code never appears in the report) · a VALUE ONLY THE OWNER HAS (an npm/authenticator code, a password): "- fill [testid] from owner \"<question>\"" (add "as password" or "as text"; default code) — asked in ARS through buddy's «ars ask», the owner types it there and nowhere else; declined / expired fail the step by that word; the value never appears in the report (F010.6) · the BUILT SCREEN'S HTML after the click path: "- inspect html [testid]" (or "- inspect html" for the whole body) — the step detail is that outerHTML, for cardmem_check_mockup_fidelity's built_html (F009.138) · a WINDOW THE PAGE OPENS (window.open / target=_blank — an OAuth dialog like «Continue with Facebook/Google»): "- waitForPopup" takes it over (also one opened by the click just before), "- in opened: <step>" acts in it, "- waitForPopupClose" waits for it to close; steps without the prefix stay in the opener (F009.139) · "- assert: <js>" · "- screenshot label" · frame-aware "- fillSelector <css> = <value> @frame <iframe>" and "- clickSelector <css> @frame <iframe>" · "- waitForUrl <substring>". TWO BROWSERS AT ONCE (F009.122): prefix a step with "in <name>:" — "- in b: goto /" · "- in b: expectText [note] == Hej" — and it runs in its own browser (own cookies + storage), open alongside the default one for the rest of the run; steps without the prefix run in the default browser. Click modifiers: "- click [testid] via enter" (F255.1, for Angular/MDC buttons a mouse click does not activate) and "- click [testid] @ 50%,28%" (F255.4, aim at a point inside a canvas/3D surface). A field that already HOLDS a value may no longer render an input — a combobox typically swaps to its selected state, so "fill" times out there while "press ArrowDown" / "press Enter" still drive it (fd-sundhed, 2026-08-21). The authoring shortcut — write prose, not JSON.`,
|
|
419
|
+
`Compile a human-readable markdown manuscript (fmc-automation style: "# flow: name", "base: <url>", then one "- <verb> …" per line) into a flow and run it E2E. VERBS (${MANUSCRIPT_VERBS.length}, this is the complete list): ${MANUSCRIPT_VERBS.join(' / ')}. Shapes: "- goto /x" · "- fill [testid] = value" · a PASSWORD without plaintext: "- fill [testid] from file <path>" (absolute, or relative to local_path) or "- fill [testid] from env <NAME>" (F009.121 — password inputs only; the value never appears in the run, the report or a screenshot) · "- click [testid]" · "- press Enter" (global) or "- press Enter [testid]" (on a focused element) · "- expectText [testid] ~ text" · "- drag [source] -> [target]" or "- drag [node] by 120,-40" (a canvas offset; both move in 10 mousemoves so React Flow / d3-drag nodes really move — "steps N" to change, F009.123) · "- upload [input-testid] = <fixture>" · an input with NO testid, also inside an open shadow root: "- uploadSelector <css> = <fixture>[, <fixture>]" (F009.136; fixtures repo-relative to local_path or data:) · a CODE FROM MAIL: "- fill [testid] from mail to jam@jams.party subject ~ Jam match /\\b\\d{6}\\b/" (F009.137 — waits ≤60 s for a mail received after the step started, read through mail-mcp; only the test mailbox webhouse.developer@gmail.com / jam@jams.party; the mail is deleted after the run, report carries mail {consumed, cleaned}; the code never appears in the report) · a VALUE ONLY THE OWNER HAS (an npm/authenticator code, a password): "- fill [testid] from owner \"<question>\"" (add "as password" or "as text"; default code) — asked in ARS through buddy's «ars ask», the owner types it there and nowhere else; declined / expired fail the step by that word; the value never appears in the report (F010.6) · a VALUE THE PAGE SHOWS THAT MUST GO STRAIGHT TO THE VAULT (a new API key a console shows once): "- capture [testid] to vault <project>/<name> as <ENV_VAR>" — the daemon reads it and stores it in cardmem's vault with its own key; the report carries only {secret_id, name, preview}, and every later inspect redacts it (F010.15; flow JSON: {type:"capture", testid, to:"vault", vault:{project, name, env_var_name?}}) · the BUILT SCREEN'S HTML after the click path: "- inspect html [testid]" (or "- inspect html" for the whole body) — the step detail is that outerHTML, for cardmem_check_mockup_fidelity's built_html (F009.138) · a WINDOW THE PAGE OPENS (window.open / target=_blank — an OAuth dialog like «Continue with Facebook/Google»): "- waitForPopup" takes it over (also one opened by the click just before), "- in opened: <step>" acts in it, "- waitForPopupClose" waits for it to close; steps without the prefix stay in the opener (F009.139) · "- assert: <js>" · "- screenshot label" · frame-aware "- fillSelector <css> = <value> @frame <iframe>" and "- clickSelector <css> @frame <iframe>" · "- waitForUrl <substring>". TWO BROWSERS AT ONCE (F009.122): prefix a step with "in <name>:" — "- in b: goto /" · "- in b: expectText [note] == Hej" — and it runs in its own browser (own cookies + storage), open alongside the default one for the rest of the run; steps without the prefix run in the default browser. Click modifiers: "- click [testid] via enter" (F255.1, for Angular/MDC buttons a mouse click does not activate) and "- click [testid] @ 50%,28%" (F255.4, aim at a point inside a canvas/3D surface). A field that already HOLDS a value may no longer render an input — a combobox typically swaps to its selected state, so "fill" times out there while "press ArrowDown" / "press Enter" still drive it (fd-sundhed, 2026-08-21). The authoring shortcut — write prose, not JSON.`,
|
|
415
420
|
inputSchema: {
|
|
416
421
|
type: 'object',
|
|
417
422
|
required: ['project', 'manuscript'],
|
|
@@ -427,6 +432,11 @@ export const TOOLS = [
|
|
|
427
432
|
timezone: timezoneSchema,
|
|
428
433
|
reduced_motion: reducedMotionSchema,
|
|
429
434
|
storage: storageSchema,
|
|
435
|
+
browsers: {
|
|
436
|
+
type: 'object',
|
|
437
|
+
description:
|
|
438
|
+
'F009.141 — {<name>: {auth: <auth object, same shape as flow.auth>}}: the named browser that steps address with browser:"<name>" (manuscript «- in <name>: …») signs in as its OWN user instead of the run\'s — two different people in one run (a mintEndpoint with a different body per browser, or two storageStates). A named browser without an entry keeps the run\'s auth. Relative paths resolve against local_path like flow.auth. "main" is the run\'s own auth and cannot be named here.',
|
|
439
|
+
},
|
|
430
440
|
browser: browserSchema,
|
|
431
441
|
record: {
|
|
432
442
|
type: 'boolean',
|
package/src/secret-fill.ts
CHANGED
|
@@ -19,6 +19,20 @@ export function setVaultReader(fn: VaultReader | null): void {
|
|
|
19
19
|
vaultReader = fn;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// F010.15 — the other direction: a value READ off the page (a new API key a provider
|
|
23
|
+
// console shows once) is stored in cardmem's vault by the DAEMON, with its own
|
|
24
|
+
// cardmem key, so it never passes through an agent. Installed by createLensRouter.
|
|
25
|
+
export interface VaultTarget { project: string; name: string; env_var_name?: string }
|
|
26
|
+
export interface VaultReceipt { secret_id: string; name: string; preview: string }
|
|
27
|
+
type VaultWriter = (target: VaultTarget, value: string) => Promise<VaultReceipt>;
|
|
28
|
+
let vaultWriter: VaultWriter | null = null;
|
|
29
|
+
export function setVaultWriter(fn: VaultWriter | null): void {
|
|
30
|
+
vaultWriter = fn;
|
|
31
|
+
}
|
|
32
|
+
export function getVaultWriter(): VaultWriter | null {
|
|
33
|
+
return vaultWriter;
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
/** Read the secret. Every error names WHERE it looked and never WHAT it found. */
|
|
23
37
|
export async function readSecret(
|
|
24
38
|
vf: SecretFrom,
|
package/src/service.ts
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
listBaselineVersions,
|
|
34
34
|
revertBaseline,
|
|
35
35
|
} from './store.ts';
|
|
36
|
-
import { runFlow, parseFlow, parseRunBrowser, compileManuscript, type FlowResult, type FlowStepResult } from './flow.ts';
|
|
36
|
+
import { runFlow, parseFlow, parseRunBrowser, compileManuscript, type Flow, type FlowResult, type FlowStepResult } from './flow.ts';
|
|
37
37
|
// F074.24 — the daemon HOSTS the engine's own runFlow for flat cloud-shape
|
|
38
38
|
// FlowRequests (one wire-shape, driven via @broberg/lens-client). The engine
|
|
39
39
|
// natively speaks the cloud grammar (all 12 action-verbs), self-heals via the
|
|
@@ -946,6 +946,16 @@ export async function runFlatFlow(deps: LensDeps, input: FlatFlowInput) {
|
|
|
946
946
|
* per-step report + screenshots, return the E2E result. F074.24: a flat cloud
|
|
947
947
|
* FlowRequest is delegated to the engine's runFlow; the native {project, flow}
|
|
948
948
|
* body keeps the daemon's own manuscript executor. */
|
|
949
|
+
/** F009.141 — a named browser's own auth resolves its relative paths exactly like
|
|
950
|
+
* flow.auth: against local_path, inside the daemon sandbox. */
|
|
951
|
+
export function resolveBrowserAuths(flow: Flow, localPath: string | undefined, sandboxRoots: string[]): void {
|
|
952
|
+
if (!flow.browsers) return;
|
|
953
|
+
const root = localPath ? resolveSandboxedPath(localPath, sandboxRoots) : undefined;
|
|
954
|
+
for (const b of Object.values(flow.browsers)) {
|
|
955
|
+
if (root) b.auth = resolveAuthPaths(b.auth, root) as AuthConfig;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
949
959
|
export async function lensRunFlow(deps: LensDeps, input: RunFlowInput) {
|
|
950
960
|
const project = requireProject(input.project);
|
|
951
961
|
const flow = parseFlow(input.flow);
|
|
@@ -972,6 +982,7 @@ export async function lensRunFlow(deps: LensDeps, input: RunFlowInput) {
|
|
|
972
982
|
// F074.36 — and the run now REPORTS which of those two it used, or why neither.
|
|
973
983
|
const provenance = authProvenance(flow.auth, input.local_path, deps.sandboxRoots);
|
|
974
984
|
flow.auth = provenance.auth;
|
|
985
|
+
resolveBrowserAuths(flow, input.local_path, deps.sandboxRoots);
|
|
975
986
|
const result = await runFlow(flow, process.env as AuthEnv, {
|
|
976
987
|
from: input.from,
|
|
977
988
|
engine: input.engine,
|
|
@@ -1001,6 +1012,8 @@ export interface RunManuscriptInput {
|
|
|
1001
1012
|
local_path?: string;
|
|
1002
1013
|
/** F009.136 — {channel:'chrome', profile?, visible?}: run in that browser build. */
|
|
1003
1014
|
browser?: unknown;
|
|
1015
|
+
/** F009.141 — {<name>: {auth}}: each named browser («in <name>:») signs in as its own user. */
|
|
1016
|
+
browsers?: unknown;
|
|
1004
1017
|
/** F252.2 — run the manuscript at a non-default viewport/device so mobile-only
|
|
1005
1018
|
* UI (behind lg:hidden etc.) can be click-driven, not just DOM-asserted. */
|
|
1006
1019
|
viewport?: { width: number; height: number } | string;
|
|
@@ -1044,6 +1057,12 @@ export async function lensRunManuscript(deps: LensDeps, input: RunManuscriptInpu
|
|
|
1044
1057
|
// has to infer from a confusing failure.
|
|
1045
1058
|
const provenance = authProvenance(coerceAuth(input.auth) ?? flow.auth, input.local_path, deps.sandboxRoots);
|
|
1046
1059
|
flow.auth = provenance.auth;
|
|
1060
|
+
// F009.141 — the manuscript language has no auth line; the call carries each
|
|
1061
|
+
// named browser's own login, validated by the same parser as a JSON flow.
|
|
1062
|
+
if (input.browsers !== undefined) {
|
|
1063
|
+
flow.browsers = parseFlow({ name: flow.name, base_url: flow.base_url, steps: [{ type: 'goto', path: '/' }], browsers: input.browsers }).browsers;
|
|
1064
|
+
}
|
|
1065
|
+
resolveBrowserAuths(flow, input.local_path, deps.sandboxRoots);
|
|
1047
1066
|
const result = await runFlow(flow, process.env as AuthEnv, {
|
|
1048
1067
|
engine: input.engine,
|
|
1049
1068
|
...resolveLocale(input, manifestLocale(input.local_path, deps.sandboxRoots)),
|