@tangle-network/agent-app 0.63.16 → 0.63.18

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.
@@ -0,0 +1 @@
1
+ export declare function pruneJourneyArtifacts(outDir: string, retained: ReadonlySet<string>): void;
@@ -38,7 +38,36 @@ import "../chunk-BTEVD7HG.js";
38
38
  // src/journeys/journey.ts
39
39
  import { mkdirSync, writeFileSync } from "fs";
40
40
  import { hostname } from "os";
41
- import { join } from "path";
41
+ import { join as join2 } from "path";
42
+
43
+ // src/journeys/artifacts.ts
44
+ import { readdirSync, rmSync } from "fs";
45
+ import { join, resolve } from "path";
46
+ var groups = [
47
+ {
48
+ directory: "",
49
+ owns: (name) => name.endsWith("-desktop.png") || name.endsWith("-phone.png")
50
+ },
51
+ {
52
+ directory: "video",
53
+ owns: (name) => name.endsWith(".mp4") || name.endsWith(".srt") || name.endsWith("-trace.zip")
54
+ },
55
+ {
56
+ directory: "turns",
57
+ owns: (name) => name.endsWith(".md")
58
+ }
59
+ ];
60
+ function pruneJourneyArtifacts(outDir, retained) {
61
+ const keep = new Set([...retained].map((file) => resolve(file)));
62
+ for (const group of groups) {
63
+ const directory = join(resolve(outDir), group.directory);
64
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
65
+ if (!entry.isFile() && !entry.isSymbolicLink() || !group.owns(entry.name)) continue;
66
+ const file = join(directory, entry.name);
67
+ if (!keep.has(file)) rmSync(file);
68
+ }
69
+ }
70
+ }
42
71
 
43
72
  // src/journeys/page-reading.ts
44
73
  function promptHead(prompt) {
@@ -135,7 +164,7 @@ async function clickUntilSubmitted(ops) {
135
164
  if (ops.landed()) return;
136
165
  throw new Error(`Send never submitted: the composer refused ${ops.attempts} presses`);
137
166
  }
138
- async function settleText(read, wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), timeoutMs = 2e4) {
167
+ async function settleText(read, wait = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms)), timeoutMs = 2e4) {
139
168
  const deadline = Date.now() + timeoutMs;
140
169
  let previous = null;
141
170
  let stable = 0;
@@ -162,7 +191,7 @@ async function composerText(box) {
162
191
  // src/journeys/journey.ts
163
192
  var DESKTOP = { width: 1440, height: 900 };
164
193
  var PHONE = { width: 390, height: 844 };
165
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
194
+ var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
166
195
  var secs = (ms) => Math.round(ms / 100) / 10;
167
196
  var CURSOR_SCRIPT = `(() => {
168
197
  const install = () => {
@@ -190,10 +219,10 @@ var Journey = class {
190
219
  this.config = config;
191
220
  this.browser = browser;
192
221
  this.opts = opts;
193
- this.outDir = join(config.outDir, id);
194
- this.rawDir = join(config.stateDir, "raw", `${id}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`);
195
- mkdirSync(join(this.outDir, "video"), { recursive: true });
196
- mkdirSync(join(this.outDir, "turns"), { recursive: true });
222
+ this.outDir = join2(config.outDir, id);
223
+ this.rawDir = join2(config.stateDir, "raw", `${id}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`);
224
+ mkdirSync(join2(this.outDir, "video"), { recursive: true });
225
+ mkdirSync(join2(this.outDir, "turns"), { recursive: true });
197
226
  mkdirSync(this.rawDir, { recursive: true, mode: 448 });
198
227
  }
199
228
  id;
@@ -207,6 +236,7 @@ var Journey = class {
207
236
  turns = [];
208
237
  recorded = [];
209
238
  phones = /* @__PURE__ */ new Map();
239
+ screenshots = /* @__PURE__ */ new Set();
210
240
  startedAt = Date.now();
211
241
  /**
212
242
  * A recorded, traced 1440x900 context. A config identity starts signed in
@@ -217,7 +247,7 @@ var Journey = class {
217
247
  if (this.recorded.some((r) => r.label === label)) throw new Error(`a context labelled ${label} is already open`);
218
248
  if (!/^[a-z0-9][a-z0-9-]{0,30}$/.test(label)) throw new Error("context label: lowercase letters, digits and dashes");
219
249
  const storageState = identity === "anon" ? void 0 : (await storageStateFor(this.config, identity, opts)).path;
220
- const rawDir = join(this.rawDir, label);
250
+ const rawDir = join2(this.rawDir, label);
221
251
  const context = await this.browser.newContext({
222
252
  baseURL: this.config.baseUrl,
223
253
  storageState,
@@ -361,7 +391,7 @@ var Journey = class {
361
391
  async shot(name, page, opts = {}) {
362
392
  const r = this.recordedFor(page);
363
393
  const slug = name.replace(/[^a-z0-9-]+/gi, "-").toLowerCase();
364
- const desktop = join(this.outDir, `${slug}-desktop.png`);
394
+ const desktop = join2(this.outDir, `${slug}-desktop.png`);
365
395
  const cursor = (display) => r.page.evaluate((d) => {
366
396
  const c = document.getElementById("__journey_cursor");
367
397
  if (c) c.style.display = d;
@@ -369,9 +399,10 @@ var Journey = class {
369
399
  });
370
400
  await cursor("none");
371
401
  await r.page.screenshot({ path: desktop, fullPage: opts.fullPage ?? false });
402
+ this.screenshots.add(desktop);
372
403
  await cursor("");
373
404
  if (opts.phone === false) return { desktop };
374
- const phonePath = join(this.outDir, `${slug}-phone.png`);
405
+ const phonePath = join2(this.outDir, `${slug}-phone.png`);
375
406
  let ctx = this.phones.get(r.identity);
376
407
  if (!ctx) {
377
408
  const storageState = r.identity === "anon" ? void 0 : (await storageStateFor(this.config, r.identity)).path;
@@ -385,6 +416,7 @@ var Journey = class {
385
416
  });
386
417
  await sleep(1500);
387
418
  await phone.screenshot({ path: phonePath, fullPage: opts.fullPage ?? false });
419
+ this.screenshots.add(phonePath);
388
420
  } finally {
389
421
  await phone.close();
390
422
  }
@@ -598,14 +630,14 @@ var Journey = class {
598
630
  t.replyChars = this.config.chat.assistant ? Math.max(0, finalText.length - baselineChars) : Math.max(0, growth);
599
631
  Object.assign(t, scoreTurn({ timedOut: !finished, evidence: evidence.added(), replyChars: t.replyChars, stopPressed: t.stopPressedS !== null }));
600
632
  const n = this.turns.length;
601
- t.replyFile = join("turns", `${String(n).padStart(2, "0")}-${t.label}.md`);
633
+ t.replyFile = join2("turns", `${String(n).padStart(2, "0")}-${t.label}.md`);
602
634
  const reply = this.config.chat.assistant ? finalText.slice(baselineChars).trim() : "(this app configures no assistant selector; read the reply in the video or the trace)";
603
635
  const failures = t.failures.length ? `
604
636
 
605
637
  ## Failure evidence
606
638
 
607
639
  ${t.failures.map((f) => `- ${f}`).join("\n")}` : "";
608
- writeFileSync(join(this.outDir, t.replyFile), `# Turn ${n} (${t.label})
640
+ writeFileSync(join2(this.outDir, t.replyFile), `# Turn ${n} (${t.label})
609
641
 
610
642
  ## Prompt
611
643
 
@@ -639,7 +671,7 @@ ${reply}${failures}
639
671
  const stopped = [];
640
672
  for (const r of this.recorded) {
641
673
  const endedAt = Date.now();
642
- const rawTrace = join(r.rawDir, "trace.raw.zip");
674
+ const rawTrace = join2(r.rawDir, "trace.raw.zip");
643
675
  await r.context.tracing.stop({ path: rawTrace }).catch((e) => console.warn(`tracing.stop failed for ${r.label}: ${e}`));
644
676
  const video = r.page.video();
645
677
  await r.context.close();
@@ -651,7 +683,7 @@ ${reply}${failures}
651
683
  files.push(...postProcessVideo({
652
684
  webm,
653
685
  workDir: r.rawDir,
654
- videoDir: join(this.outDir, "video"),
686
+ videoDir: join2(this.outDir, "video"),
655
687
  label: r.label,
656
688
  t0: r.t0,
657
689
  wallSeconds: (endedAt - r.t0) / 1e3,
@@ -660,7 +692,7 @@ ${reply}${failures}
660
692
  }));
661
693
  }
662
694
  try {
663
- const clean = join(this.outDir, "video", `${r.label}-trace.zip`);
695
+ const clean = join2(this.outDir, "video", `${r.label}-trace.zip`);
664
696
  const result = scrubTrace(rawTrace, clean, [...needles.hard, ...needles.soft]);
665
697
  console.log(`trace ${r.label}: ${result.entries} entries, ${result.dropped} sensitive bodies dropped, ${result.rewritten} rewritten`);
666
698
  files.push(clean);
@@ -668,10 +700,15 @@ ${reply}${failures}
668
700
  console.warn(`trace ${r.label} not written: ${error.message}`);
669
701
  }
670
702
  }
671
- writeFileSync(join(this.outDir, "chapters.json"), JSON.stringify(this.chapters.map((c) => ({ ...c, at: new Date(c.at).toISOString(), until: c.until ? new Date(c.until).toISOString() : void 0, offsetS: secs(c.at - this.startedAt) })), null, 2));
672
- writeFileSync(join(this.outDir, "timings.json"), JSON.stringify({ journey: this.id, app: this.config.app, base: this.config.baseUrl, startedAt: new Date(this.startedAt).toISOString(), wallS: secs(Date.now() - this.startedAt), steps: this.steps, turns: this.turns }, null, 2));
703
+ writeFileSync(join2(this.outDir, "chapters.json"), JSON.stringify(this.chapters.map((c) => ({ ...c, at: new Date(c.at).toISOString(), until: c.until ? new Date(c.until).toISOString() : void 0, offsetS: secs(c.at - this.startedAt) })), null, 2));
704
+ writeFileSync(join2(this.outDir, "timings.json"), JSON.stringify({ journey: this.id, app: this.config.app, base: this.config.baseUrl, startedAt: new Date(this.startedAt).toISOString(), wallS: secs(Date.now() - this.startedAt), steps: this.steps, turns: this.turns }, null, 2));
673
705
  await this.browser.close();
674
706
  assertNoSecrets(this.outDir, needles);
707
+ pruneJourneyArtifacts(this.outDir, /* @__PURE__ */ new Set([
708
+ ...files,
709
+ ...this.screenshots,
710
+ ...this.turns.flatMap((turn) => turn.replyFile ? [join2(this.outDir, turn.replyFile)] : [])
711
+ ]));
675
712
  console.log(`
676
713
  ${this.id}: ${this.steps.length} steps, ${this.turns.length} turns, wall ${secs(Date.now() - this.startedAt)} s`);
677
714
  for (const t of this.turns) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/journeys/journey.ts","../../src/journeys/page-reading.ts","../../src/journeys/send.ts"],"sourcesContent":["/**\n * One recorded journey through a running agent app: signed-in recorded\n * contexts, chapters, a person's pacing, desktop and phone screenshots,\n * measured chat turns, and a `finish()` that turns the recording into files\n * that are safe to copy off the host.\n *\n * const j = await startJourney('core-path') // reads journeys.config.mjs\n * const page = await j.open('founder', 'member') // recorded, already signed in\n * await j.step('Founder opens the workspace', () => page.goto('/app'), page)\n * await j.shot('home', page) // home-desktop.png + home-phone.png\n * const turn = await j.sendNew(page, 'Research …', { from: `/app/${ws}/chat/new` })\n * await j.finish() // mp4s, srt, highlights, scrubbed trace, timings\n *\n * Output, all safe to copy (finish() refuses otherwise):\n * <outDir>/<id>/video/<label>-full.mp4 <label>-highlights.mp4 <label>.srt <label>-trace.zip\n * <outDir>/<id>/<name>-desktop.png <name>-phone.png timings.json chapters.json turns/*.md\n * Raw webm and unscrubbed traces stay in <stateDir>/raw on the host.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { hostname } from 'node:os'\nimport { join } from 'node:path'\nimport type { Browser, BrowserContext, Locator, Page } from 'playwright'\nimport { loadJourneysConfig, resolveJourneysConfig, threadRouteIn, type JourneysConfig, type ResolvedJourneysConfig, type ThreadRoute } from './config.js'\nimport { promptHead, readChatPage } from './page-reading.js'\nimport { scoreTurn, turnLooksActive, TurnEvidence, type TranscriptSnapshot, type TurnOutcome } from './score.js'\nimport { assertNoSecrets, scrubTrace } from './scrub.js'\nimport { clickUntilSubmitted, composerText, createSubmissionTracker, settleText } from './send.js'\nimport { secretNeedles, storageStateFor } from './session.js'\nimport { postProcessVideo, type Chapter } from './video.js'\n\nexport const DESKTOP = { width: 1440, height: 900 }\nexport const PHONE = { width: 390, height: 844 }\nconst sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))\nconst secs = (ms: number) => Math.round(ms / 100) / 10\n\n/** A visible pointer so a viewer can follow clicks in a headless recording. Hidden for screenshots. */\nconst CURSOR_SCRIPT = `(() => {\n const install = () => {\n if (document.getElementById('__journey_cursor') || !document.body) return\n const dot = document.createElement('div')\n dot.id = '__journey_cursor'\n dot.setAttribute('aria-hidden', 'true')\n Object.assign(dot.style, { position: 'fixed', zIndex: '2147483647', width: '24px', height: '24px',\n margin: '-12px 0 0 -12px', borderRadius: '50%', background: 'rgba(255,72,48,.28)',\n border: '2px solid rgba(255,72,48,.95)', pointerEvents: 'none', left: (window.__jx ?? -100) + 'px',\n top: (window.__jy ?? -100) + 'px', transition: 'transform .12s ease-out' })\n document.body.appendChild(dot)\n }\n addEventListener('mousemove', (e) => { window.__jx = e.clientX; window.__jy = e.clientY\n const d = document.getElementById('__journey_cursor'); if (d) { d.style.left = e.clientX + 'px'; d.style.top = e.clientY + 'px' } }, true)\n addEventListener('mousedown', () => { const d = document.getElementById('__journey_cursor'); if (d) d.style.transform = 'scale(.55)' }, true)\n addEventListener('mouseup', () => { const d = document.getElementById('__journey_cursor'); if (d) d.style.transform = 'scale(1)' }, true)\n // After hydration, so the framework never meets a node it did not render.\n addEventListener('load', () => setTimeout(install, 1500))\n setInterval(install, 2000)\n})()`\n\ninterface Recorded {\n label: string\n identity: string\n context: BrowserContext\n page: Page\n t0: number\n rawDir: string\n}\n\nexport interface TurnRecord {\n label: string\n prompt: string\n threadId: string | null\n sentAt: string\n /** Seconds from the Send press. */\n firstProgressS: number | null\n firstProgressText: string | null\n firstTextS: number | null\n /** Seconds from Send to the first failure evidence on the page, if any appeared. */\n firstFailureS: number | null\n completeS: number | null\n outcome: TurnOutcome\n /** Plain words for what went wrong, or null for a completed turn. */\n error: string | null\n /** Every piece of failure evidence the turn added. */\n failures: string[]\n /** Where evidence was read: after the turn's own prompt, or the whole transcript when the page did not show the prompt. */\n evidenceScope: 'after-prompt' | 'whole-transcript' | null\n replyChars: number\n /** Distinct status lines the transcript showed, with when they appeared. */\n stages: { s: number; text: string }[]\n /** Seconds from Send at which the journey pressed Stop, if it did. */\n stopPressedS: number | null\n replyFile: string | null\n}\n\nexport interface StepRecord {\n caption: string\n label: string | null\n startS: number\n durationS: number\n ok: boolean\n error?: string\n}\n\nexport interface SendOptions {\n caption?: string\n timeoutMs?: number\n /** Keystroke delay for the prompt. */\n delay?: number\n /** Press Stop at first text, or this many seconds after Send. */\n stopAfter?: 'first-text' | number\n}\n\n/** What the page shows right now, read in one evaluate. */\ninterface PageReading extends TranscriptSnapshot {\n status: string[]\n assistantChars: number\n transcriptChars: number\n stopVisible: boolean\n}\n\nexport class Journey {\n readonly outDir: string\n readonly rawDir: string\n readonly chapters: Chapter[] = []\n readonly steps: StepRecord[] = []\n readonly turns: TurnRecord[] = []\n private recorded: Recorded[] = []\n private phones = new Map<string, BrowserContext>()\n private readonly startedAt = Date.now()\n\n constructor(readonly id: string, readonly config: ResolvedJourneysConfig, readonly browser: Browser, private readonly opts: { cursor: boolean }) {\n this.outDir = join(config.outDir, id)\n this.rawDir = join(config.stateDir, 'raw', `${id}-${new Date().toISOString().replace(/[:.]/g, '-')}`)\n mkdirSync(join(this.outDir, 'video'), { recursive: true })\n mkdirSync(join(this.outDir, 'turns'), { recursive: true })\n mkdirSync(this.rawDir, { recursive: true, mode: 0o700 })\n }\n\n /**\n * A recorded, traced 1440x900 context. A config identity starts signed in\n * from the cached session (no login form is ever recorded); `'anon'` starts\n * signed out, for public pages. Open at most two per journey.\n */\n async open(label: string, identity: string, opts: { fresh?: boolean } = {}): Promise<Page> {\n if (this.recorded.some((r) => r.label === label)) throw new Error(`a context labelled ${label} is already open`)\n if (!/^[a-z0-9][a-z0-9-]{0,30}$/.test(label)) throw new Error('context label: lowercase letters, digits and dashes')\n const storageState = identity === 'anon' ? undefined : (await storageStateFor(this.config, identity, opts)).path\n const rawDir = join(this.rawDir, label)\n const context = await this.browser.newContext({\n baseURL: this.config.baseUrl,\n storageState,\n viewport: DESKTOP,\n recordVideo: { dir: rawDir, size: DESKTOP },\n locale: 'en-US',\n timezoneId: 'America/Denver',\n })\n context.setDefaultTimeout(20_000)\n context.setDefaultNavigationTimeout(60_000)\n if (this.opts.cursor) await context.addInitScript(CURSOR_SCRIPT)\n if (process.env.JOURNEY_DEBUG_CLOCK === '1') {\n // Wall-clock seconds since recording start on every frame, for calibrating captions.\n await context.addInitScript((t0: number) => {\n setInterval(() => {\n let d = document.getElementById('__journey_clock')\n if (!d && document.body) {\n d = document.createElement('div')\n d.id = '__journey_clock'\n Object.assign(d.style, { position: 'fixed', left: '50%', top: '0', zIndex: '2147483647', font: 'bold 20px monospace', background: '#ff0', color: '#000', padding: '2px 6px', pointerEvents: 'none' })\n document.body.appendChild(d)\n }\n if (d) d.textContent = ((Date.now() - t0) / 1000).toFixed(1)\n }, 100)\n }, Date.now())\n }\n await context.tracing.start({ screenshots: true, snapshots: true, title: `${this.id} ${label}` })\n const page = await context.newPage()\n this.recorded.push({ label, identity, context, page, t0: Date.now(), rawDir })\n return page\n }\n\n private recordedFor(page?: Page): Recorded {\n const r = page ? this.recorded.find((x) => x.page === page) : this.recorded[0]\n if (!r) throw new Error('no recorded context for that page; call open() first')\n return r\n }\n\n /** A chapter at this instant: one plain line, shown in the caption bar and the .srt. */\n mark(caption: string, page?: Page): void {\n const label = page ? this.recordedFor(page).label : null\n this.chapters.push({ at: Date.now(), caption, label, kind: 'step' })\n console.log(`[${secs(Date.now() - this.startedAt).toFixed(1)}s] ${label ? `${label}: ` : ''}${caption}`)\n }\n\n /** A timed step with its own chapter. A failure is recorded, captioned, then rethrown. */\n async step<T>(caption: string, work: () => Promise<T>, page?: Page): Promise<T> {\n this.mark(caption, page)\n const start = Date.now()\n const entry: StepRecord = { caption, label: page ? this.recordedFor(page).label : null, startS: secs(start - this.startedAt), durationS: 0, ok: true }\n this.steps.push(entry)\n try {\n return await work()\n } catch (error) {\n entry.ok = false\n entry.error = String((error as Error)?.message ?? error).slice(0, 400)\n this.mark(`Step failed: ${caption}`, page)\n throw error\n } finally {\n entry.durationS = secs(Date.now() - start)\n }\n }\n\n /** A waiting span: real speed in the full video, sped up and labelled in the highlights. */\n async wait<T>(caption: string, work: () => Promise<T>, page?: Page): Promise<T> {\n const label = page ? this.recordedFor(page).label : null\n const chapter: Chapter = { at: Date.now(), caption, label, kind: 'wait', until: Date.now() }\n this.chapters.push(chapter)\n console.log(`[${secs(Date.now() - this.startedAt).toFixed(1)}s] ${label ? `${label}: ` : ''}(wait) ${caption}`)\n try {\n return await work()\n } finally {\n chapter.until = Date.now()\n }\n }\n\n pause(ms = 700): Promise<void> {\n return sleep(ms)\n }\n\n /** Move the visible pointer there, pause, click, pause. */\n async click(target: Locator, opts: { pauseAfter?: number } = {}): Promise<void> {\n await target.scrollIntoViewIfNeeded()\n const box = await target.boundingBox()\n if (box) await target.page().mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 14 })\n await sleep(250)\n await target.click()\n await sleep(opts.pauseAfter ?? 600)\n }\n\n /** Type at a readable pace into an input or textarea. */\n async type(target: Locator, text: string, opts: { delay?: number } = {}): Promise<void> {\n await this.click(target, { pauseAfter: 200 })\n const delay = opts.delay ?? 28\n await target.pressSequentially(text, { delay, timeout: 30_000 + text.length * (delay + 60) })\n await sleep(400)\n }\n\n /** The composer's message input. */\n composerInput(page: Page): Locator {\n return page.locator(this.config.chat.composer).getByRole('textbox', { name: this.config.chat.inputName })\n }\n\n private composerButton(page: Page, name: string): Locator {\n return page.locator(this.config.chat.composer).getByRole('button', { name, exact: true })\n }\n\n /**\n * Type into the chat composer at a readable pace. A line break is typed as\n * Shift+Enter, because Enter sends. Retries fast when hydration dropped\n * keystrokes. Never `fill()` a rich-text composer.\n */\n async typePrompt(page: Page, prompt: string, opts: { delay?: number } = {}): Promise<void> {\n const box = this.composerInput(page)\n await box.waitFor({ state: 'visible', timeout: 30_000 })\n await sleep(1_200)\n const delay = opts.delay ?? (prompt.length > 400 ? 8 : 22)\n const want = prompt.replace(/\\s+/g, ' ').trim().slice(0, 80)\n for (let attempt = 0; attempt < 4; attempt += 1) {\n await this.click(box, { pauseAfter: 150 })\n await box.press('ControlOrMeta+a')\n await box.press('Backspace')\n const lines = prompt.split('\\n')\n for (let i = 0; i < lines.length; i += 1) {\n if (i > 0) await box.press('Shift+Enter')\n // Sized by length: a loaded host types slower than the context's 20 s default allows.\n const line = lines[i]!\n if (line) await box.pressSequentially(line, { delay: attempt === 0 ? delay : 0, timeout: 30_000 + line.length * (delay + 60) })\n }\n const text = (await composerText(box).catch(() => '')).replace(/\\s+/g, ' ').trim()\n if (text.includes(want)) return\n await sleep(1_000)\n }\n throw new Error('the composer never held the prompt')\n }\n\n /**\n * Which parts of the chat contract this page shows, without sending\n * anything. Run it on a second app before trusting turn timings there.\n */\n async checkChatContract(page: Page): Promise<Record<'transcript' | 'composer' | 'input' | 'send', boolean>> {\n const visible = (l: Locator) => l.first().isVisible().catch(() => false)\n return {\n transcript: await visible(page.locator(this.config.chat.transcript)),\n composer: await visible(page.locator(this.config.chat.composer)),\n input: await visible(this.composerInput(page)),\n send: await visible(this.composerButton(page, this.config.chat.sendName)),\n }\n }\n\n /**\n * Desktop screenshot of the recorded page, then the same URL in a phone\n * context (390x844, same identity). Look at both before judging the screen.\n */\n async shot(name: string, page?: Page, opts: { phone?: boolean; fullPage?: boolean; phoneUrl?: string } = {}): Promise<{ desktop: string; phone?: string }> {\n const r = this.recordedFor(page)\n const slug = name.replace(/[^a-z0-9-]+/gi, '-').toLowerCase()\n const desktop = join(this.outDir, `${slug}-desktop.png`)\n const cursor = (display: string) => r.page.evaluate((d) => { const c = document.getElementById('__journey_cursor'); if (c) c.style.display = d }, display).catch(() => {})\n await cursor('none')\n await r.page.screenshot({ path: desktop, fullPage: opts.fullPage ?? false })\n await cursor('')\n if (opts.phone === false) return { desktop }\n const phonePath = join(this.outDir, `${slug}-phone.png`)\n let ctx = this.phones.get(r.identity)\n if (!ctx) {\n const storageState = r.identity === 'anon' ? undefined : (await storageStateFor(this.config, r.identity)).path\n ctx = await this.browser.newContext({ baseURL: this.config.baseUrl, storageState, viewport: PHONE, deviceScaleFactor: 2, isMobile: true, hasTouch: true, locale: 'en-US', timezoneId: 'America/Denver' })\n this.phones.set(r.identity, ctx)\n }\n const phone = await ctx.newPage()\n try {\n await phone.goto(opts.phoneUrl ?? r.page.url(), { waitUntil: 'load' })\n await phone.waitForLoadState('networkidle', { timeout: 8_000 }).catch(() => {})\n await sleep(1_500)\n await phone.screenshot({ path: phonePath, fullPage: opts.fullPage ?? false })\n } finally {\n await phone.close()\n }\n return { desktop, phone: phonePath }\n }\n\n private budgetTurn(): void {\n if (this.turns.length >= this.config.maxTurns) {\n throw new Error(`this journey already sent ${this.turns.length} chat turns, its budget (maxTurns ${this.config.maxTurns})`)\n }\n }\n\n /**\n * Start a new thread: open `from` when given, type the prompt, press Send\n * like a person (again only while the page has not submitted; never deletes\n * a duplicate), wait for the thread, then measure the turn.\n */\n async sendNew(page: Page, prompt: string, opts: SendOptions & { from?: string } = {}): Promise<TurnRecord> {\n this.budgetTurn()\n if (opts.from && !page.url().startsWith(new URL(opts.from, this.config.baseUrl).href)) await page.goto(opts.from)\n await this.typePrompt(page, prompt, { delay: opts.delay })\n const send = this.composerButton(page, this.config.chat.sendName)\n await send.waitFor({ state: 'visible' })\n const box = await send.boundingBox()\n if (box) await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 14 })\n await sleep(400)\n const before = await this.read(page, prompt)\n const evidence = new TurnEvidence(this.patterns(), prompt)\n evidence.begin(before)\n const tracker = createSubmissionTracker(page.url(), this.config.chat.sendPaths)\n const count = (request: { method(): string; url(): string }) => tracker.observe(request.method(), request.url())\n page.on('request', count)\n this.mark(opts.caption ?? `Sends: \"${oneLine(prompt, 90)}\"`, page)\n const sentAt = Date.now()\n const onThread = () => threadRouteIn(page.url(), this.config) !== null\n try {\n await clickUntilSubmitted({\n landed: () => tracker.count > 0 || onThread(),\n ready: () => send.click({ trial: true, timeout: 5_000 }),\n click: () => send.click({ timeout: 5_000 }),\n wait: () => page.waitForRequest((r) => tracker.matches(r.method(), r.url()), { timeout: 1_000 }).then(() => undefined).catch(() => undefined),\n attempts: 15,\n })\n if (this.config.chat.threadPath) await page.waitForURL((url) => threadRouteIn(url.href, this.config) !== null, { timeout: 45_000 })\n } catch (error) {\n return this.notSent(page, prompt, sentAt, String((error as Error).message).slice(0, 300))\n } finally {\n page.off('request', count)\n }\n if (tracker.count > 1) console.warn(`the composer submitted ${tracker.count} times; a duplicate thread may exist (left in place)`)\n return this.measureTurn(page, prompt, sentAt, evidence, before, 0, opts)\n }\n\n /** A follow-up in the open thread: type, one Send press, measure. */\n async sendInThread(page: Page, prompt: string, opts: SendOptions = {}): Promise<TurnRecord> {\n this.budgetTurn()\n await this.typePrompt(page, prompt, { delay: opts.delay })\n const send = this.composerButton(page, this.config.chat.sendName)\n const before = await this.read(page, prompt)\n const evidence = new TurnEvidence(this.patterns(), prompt)\n evidence.begin(before)\n const tracker = createSubmissionTracker(page.url(), this.config.chat.sendPaths)\n const posted = page.waitForRequest((r) => tracker.matches(r.method(), r.url()), { timeout: 30_000 })\n this.mark(opts.caption ?? `Follows up: \"${oneLine(prompt, 90)}\"`, page)\n const sentAt = Date.now()\n await this.click(send, { pauseAfter: 0 })\n const sent = await posted.then(() => true).catch(() => false)\n if (!sent) return this.notSent(page, prompt, sentAt, 'no chat request within 30 s of pressing Send')\n return this.measureTurn(page, prompt, sentAt, evidence, before, Math.max(0, before.assistantChars), opts)\n }\n\n private patterns() {\n return { failure: this.config.chat.failureText, stopped: this.config.chat.stoppedText }\n }\n\n private blankTurn(page: Page, prompt: string, sentAt: number): TurnRecord {\n return {\n label: this.recordedFor(page).label, prompt, threadId: threadRouteIn(page.url(), this.config)?.threadId ?? null,\n sentAt: new Date(sentAt).toISOString(), firstProgressS: null, firstProgressText: null, firstTextS: null, firstFailureS: null, completeS: null,\n outcome: 'timeout', error: null, failures: [], evidenceScope: null, replyChars: 0, stages: [], stopPressedS: null, replyFile: null,\n }\n }\n\n private notSent(page: Page, prompt: string, sentAt: number, why: string): TurnRecord {\n const t = { ...this.blankTurn(page, prompt, sentAt), ...scoreTurn({ notSent: why, timedOut: false, evidence: { failures: [], stopped: [], retryAppeared: false }, replyChars: 0, stopPressed: false }) }\n this.turns.push(t)\n this.mark(`Turn not sent: ${oneLine(why, 90)}`, page)\n return t\n }\n\n /** One read of the transcript, composer and failure marks; with a prompt, the evidence that follows it. */\n private async read(page: Page, prompt: string | null = null): Promise<PageReading> {\n const c = this.config.chat\n const { assistant, ...reading } = await page.evaluate(readChatPage, {\n transcript: c.transcript, status: c.status, failureNodes: c.failureNodes, retrySource: c.retryName.source, retryFlags: c.retryName.flags,\n assistant: c.assistant, composer: c.composer, stopName: c.stopName, promptHead: prompt === null ? null : promptHead(prompt),\n })\n return { ...reading, assistantChars: assistant }\n }\n\n private async runningTurns(page: Page, route: ThreadRoute | null): Promise<string[] | null> {\n if (!route || !this.config.chat.runningTurns) return null\n const res = await page.request.get(this.config.chat.runningTurns(route))\n if (!res.ok()) throw new Error(`running turns answered ${res.status()}`)\n const body = (await res.json()) as { running?: unknown }\n if (!Array.isArray(body.running)) throw new Error('running turns returned no `running` array')\n return body.running.map(String)\n }\n\n /**\n * Time to first visible progress (a new status line or reply text), first\n * reply text, and the turn's end, polled every 300 ms. Failure evidence is\n * read after the turn's own prompt when the page shows it. The turn has ended\n * when, for two reads in a row, {@link turnLooksActive} is false and, where\n * the app lists running turns, the server lists none. Status lines already\n * on the page before Send are not progress. The outcome comes from\n * {@link scoreTurn}.\n */\n private async measureTurn(page: Page, prompt: string, sentAt: number, evidence: TurnEvidence, before: PageReading, baselineChars: number, opts: SendOptions): Promise<TurnRecord> {\n const t = this.blankTurn(page, prompt, sentAt)\n this.turns.push(t)\n const route = threadRouteIn(page.url(), this.config)\n t.threadId = route?.threadId ?? null\n const timeoutMs = opts.timeoutMs ?? 15 * 60_000\n const since = () => secs(Date.now() - sentAt)\n const standingStatus = new Set(before.status)\n // Without an assistant selector, reply text is transcript growth from the\n // first read after Send (the person's own message is on the page by then).\n let growthBase: number | null = null\n let growth = 0\n let sawActive = false\n let quiet = 0\n let lastServerCheck = 0\n let serverRunning: string[] | null = null\n let lastStage = ''\n let lastStatus = ''\n let statusChangedAt = Date.now()\n let finished = false\n await this.wait('Waiting for the agent', async () => {\n while (Date.now() - sentAt < timeoutMs) {\n const s = await this.read(page, prompt).catch(() => null)\n if (s) {\n t.evidenceScope = s.anchored ? 'after-prompt' : 'whole-transcript'\n const shown = evidence.observe(s)\n if (shown.length) {\n t.firstFailureS ??= since()\n this.mark(`Failure shown after ${since()} s: ${oneLine(shown[0]!, 90)}`, page)\n }\n const status = s.status.filter((line) => !standingStatus.has(line))\n growthBase ??= s.transcriptChars\n const chars = s.assistantChars >= 0 ? s.assistantChars - baselineChars : s.transcriptChars - growthBase - status.join(' ').length\n growth = Math.max(growth, chars)\n const stage = status.join(' | ').replace(/\\b\\d+(\\.\\d+)?\\s?s\\b/g, '').trim()\n if (stage && stage !== lastStage) {\n t.stages.push({ s: since(), text: status.join(' | ').slice(0, 160) })\n lastStage = stage\n }\n // Raw text, timers included: a ticking \"Preparing your workspace… 31s\" is changing.\n if (status.join(' | ') !== lastStatus) {\n lastStatus = status.join(' | ')\n statusChangedAt = Date.now()\n }\n if (t.firstProgressS === null && (status.length || chars > 0)) {\n t.firstProgressS = since()\n t.firstProgressText = status[0] ?? 'reply text'\n this.mark(`First visible progress after ${t.firstProgressS} s: ${oneLine(t.firstProgressText, 70)}`, page)\n }\n if (t.firstTextS === null && chars > 0) {\n t.firstTextS = since()\n this.mark(`First text after ${t.firstTextS} s`, page)\n }\n const stopDue = opts.stopAfter === 'first-text' ? t.firstTextS !== null : typeof opts.stopAfter === 'number' && since() >= opts.stopAfter\n if (t.stopPressedS === null && stopDue && s.stopVisible) {\n t.stopPressedS = since()\n this.mark(`Presses Stop after ${t.stopPressedS} s`, page)\n await this.click(this.composerButton(page, this.config.chat.stopName), { pauseAfter: 200 }).catch((e) => console.warn(`Stop press failed: ${e}`))\n }\n if (status.length > 0) sawActive = true\n const active = turnLooksActive({ stopVisible: s.stopVisible, statusLines: status.length, msSinceStatusChanged: Date.now() - statusChangedAt })\n quiet = active ? 0 : quiet + 1\n }\n if (route && this.config.chat.runningTurns && Date.now() - lastServerCheck > 2_000) {\n lastServerCheck = Date.now()\n // A failed read never implies the turn ended.\n serverRunning = await this.runningTurns(page, route).catch(() => serverRunning)\n if (serverRunning?.length) sawActive = true\n }\n const started = sawActive || t.firstTextS !== null || Date.now() - sentAt > 45_000\n const serverDone = !this.config.chat.runningTurns || !route || serverRunning?.length === 0\n if (started && quiet >= 2 && serverDone) {\n finished = true\n return\n }\n await sleep(300)\n }\n }, page)\n t.completeS = finished ? since() : null\n // Render lag only: the turn has ended, so wait for the transcript to stop changing before judging it.\n await settleText(() => this.read(page, prompt).then((r) => `${r.transcriptChars}:${r.failureNodes.length}:${r.retryButtons}`))\n const last = await this.read(page, prompt)\n t.evidenceScope = last.anchored ? 'after-prompt' : 'whole-transcript'\n evidence.observe(last)\n const finalText = this.config.chat.assistant ? await this.replyText(page) : ''\n t.replyChars = this.config.chat.assistant ? Math.max(0, finalText.length - baselineChars) : Math.max(0, growth)\n Object.assign(t, scoreTurn({ timedOut: !finished, evidence: evidence.added(), replyChars: t.replyChars, stopPressed: t.stopPressedS !== null }))\n const n = this.turns.length\n t.replyFile = join('turns', `${String(n).padStart(2, '0')}-${t.label}.md`)\n const reply = this.config.chat.assistant ? finalText.slice(baselineChars).trim() : '(this app configures no assistant selector; read the reply in the video or the trace)'\n const failures = t.failures.length ? `\\n\\n## Failure evidence\\n\\n${t.failures.map((f) => `- ${f}`).join('\\n')}` : ''\n writeFileSync(join(this.outDir, t.replyFile), `# Turn ${n} (${t.label})\\n\\n## Prompt\\n\\n${prompt}\\n\\n## Reply (${t.outcome})\\n\\n${reply}${failures}\\n`)\n this.mark(\n t.outcome === 'completed'\n ? `Turn complete after ${t.completeS} s (${t.replyChars} chars)`\n : `Turn ${t.outcome.toUpperCase()} after ${t.completeS ?? since()} s${t.error ? `: ${oneLine(t.error, 80)}` : ''}`,\n page,\n )\n return t\n }\n\n private async replyText(page: Page): Promise<string> {\n const sel = this.config.chat.assistant\n if (!sel) return ''\n return settleText(async () => (await page.locator(sel).allInnerTexts()).join('\\n').trim())\n }\n\n /**\n * Close everything, then per context: a captioned full .mp4, a highlights cut\n * (at most 178 s, long waits sped up and labelled), an .srt and a scrubbed\n * trace.zip; plus timings.json and chapters.json. Refuses (throws) when any\n * output file still holds a password or cookie value.\n */\n async finish(opts: { speedup2x?: boolean } = {}): Promise<{ outDir: string; files: string[] }> {\n for (const ctx of this.phones.values()) await ctx.close().catch(() => {})\n const files: string[] = []\n // Stop every recording first, so one context's video does not run on through another's processing.\n const stopped: { r: Recorded; rawTrace: string; webm: string | null; endedAt: number }[] = []\n for (const r of this.recorded) {\n const endedAt = Date.now()\n const rawTrace = join(r.rawDir, 'trace.raw.zip')\n await r.context.tracing.stop({ path: rawTrace }).catch((e) => console.warn(`tracing.stop failed for ${r.label}: ${e}`))\n const video = r.page.video()\n await r.context.close()\n stopped.push({ r, rawTrace, webm: video ? await video.path().catch(() => null) : null, endedAt })\n }\n const needles = secretNeedles(this.config)\n for (const { r, rawTrace, webm, endedAt } of stopped) {\n if (webm) {\n files.push(...postProcessVideo({\n webm, workDir: r.rawDir, videoDir: join(this.outDir, 'video'), label: r.label, t0: r.t0,\n wallSeconds: (endedAt - r.t0) / 1000, chapters: this.chapters.filter((c) => c.label === null || c.label === r.label),\n speedup2x: opts.speedup2x ?? false,\n }))\n }\n try {\n const clean = join(this.outDir, 'video', `${r.label}-trace.zip`)\n const result = scrubTrace(rawTrace, clean, [...needles.hard, ...needles.soft])\n console.log(`trace ${r.label}: ${result.entries} entries, ${result.dropped} sensitive bodies dropped, ${result.rewritten} rewritten`)\n files.push(clean)\n } catch (error) {\n console.warn(`trace ${r.label} not written: ${(error as Error).message}`)\n }\n }\n writeFileSync(join(this.outDir, 'chapters.json'), JSON.stringify(this.chapters.map((c) => ({ ...c, at: new Date(c.at).toISOString(), until: c.until ? new Date(c.until).toISOString() : undefined, offsetS: secs(c.at - this.startedAt) })), null, 2))\n writeFileSync(join(this.outDir, 'timings.json'), JSON.stringify({ journey: this.id, app: this.config.app, base: this.config.baseUrl, startedAt: new Date(this.startedAt).toISOString(), wallS: secs(Date.now() - this.startedAt), steps: this.steps, turns: this.turns }, null, 2))\n await this.browser.close()\n assertNoSecrets(this.outDir, needles)\n console.log(`\\n${this.id}: ${this.steps.length} steps, ${this.turns.length} turns, wall ${secs(Date.now() - this.startedAt)} s`)\n for (const t of this.turns) {\n console.log(` turn[${t.label}] ${t.outcome}: progress ${t.firstProgressS ?? '-'} s, first text ${t.firstTextS ?? '-'} s, end ${t.completeS ?? '-'} s, ${t.replyChars} chars${t.error ? ` | ${oneLine(t.error, 100)}` : ''}`)\n }\n const host = process.env.JOURNEYS_HOST_ALIAS ?? hostname()\n console.log(`output: ${this.outDir}\\ncopy it (run where you will watch it):\\n rsync -a ${host}:${this.outDir}/ \"<dest>/${this.id}/\"`)\n return { outDir: this.outDir, files }\n }\n}\n\nexport function oneLine(text: string, max: number): string {\n const s = text.replace(/\\s+/g, ' ').trim()\n return s.length > max ? `${s.slice(0, max - 1)}…` : s\n}\n\n/** Open a journey. Without `config`, reads `journeys.config.mjs` from the working directory. */\nexport async function startJourney(id: string, opts: { config?: JourneysConfig | ResolvedJourneysConfig; cursor?: boolean; headless?: boolean } = {}): Promise<Journey> {\n if (!/^[a-z0-9][a-z0-9-]{1,60}$/.test(id)) throw new Error('journey id: lowercase letters, digits and dashes')\n const config = opts.config ? resolveJourneysConfig(opts.config) : await loadJourneysConfig()\n let chromium\n try {\n chromium = (await import('playwright')).chromium\n } catch {\n throw new Error('journeys need the optional `playwright` peer: install playwright in the app that runs them')\n }\n const browser = await chromium.launch({ headless: opts.headless ?? true })\n return new Journey(id, config, browser, { cursor: opts.cursor ?? true })\n}\n","/**\n * The one read of a chat page a journey takes every 300 ms, run inside the page\n * by `page.evaluate`, so it must stay self-contained: DOM globals only, no\n * imports and no module-scope names.\n *\n * Failure evidence belongs to the turn whose prompt it follows. On 2026-10-11\n * GTM showed a live Stop as a grey notice, then, when the next message was\n * sent, re-rendered the stopped turn with its red \"You stopped this turn.\" card\n * and a Retry control, above the new message. Read from the whole transcript,\n * that card failed the follow-up, which had answered in 28.5 s. So when the\n * transcript shows the turn's own prompt, only failure marks, Retry controls\n * and lines after it count; when it does not, the whole transcript does.\n */\n\ninterface PageReadArgs {\n readonly transcript: string\n readonly status: string\n readonly failureNodes: string\n readonly retrySource: string\n readonly retryFlags: string\n readonly assistant: string | null\n readonly composer: string\n readonly stopName: string\n /** The turn's prompt as {@link promptHead} gives it; null reads the whole transcript. */\n readonly promptHead: string | null\n}\n\ninterface RawPageReading {\n /** Visible transcript lines (after the turn's prompt when `anchored`). */\n lines: string[]\n failureNodes: string[]\n retryButtons: number\n status: string[]\n /** Characters of assistant text on the page, or -1 with no assistant selector. */\n assistant: number\n transcriptChars: number\n stopVisible: boolean\n /** The turn's prompt was found, so the evidence fields hold only what follows it. */\n anchored: boolean\n}\n\n/** The text a transcript shows for a prompt: its first line, whitespace squashed, at most 48 characters. */\nexport function promptHead(prompt: string): string | null {\n const first = prompt.split('\\n').map((line) => line.replace(/\\s+/g, ' ').trim()).find(Boolean)\n return first ? first.slice(0, 48) : null\n}\n\nexport function readChatPage(c: PageReadArgs): RawPageReading {\n const squash = (s: string) => s.replace(/\\s+/g, ' ').trim()\n const clean = (e: Element) => squash(e.textContent ?? '')\n const region = document.querySelector<HTMLElement>(c.transcript)\n const composer = document.querySelector<HTMLElement>(c.composer)\n const assistantNodes = c.assistant ? Array.from(document.querySelectorAll<HTMLElement>(c.assistant)) : []\n const within = (sel: string) => (region ? Array.from(region.querySelectorAll(sel)) : [])\n\n // The last text node outside the composer and the assistant's own text that holds the prompt.\n let anchor: Node | null = null\n if (region && c.promptHead) {\n const walker = document.createTreeWalker(region, NodeFilter.SHOW_TEXT)\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n if (!squash(node.nodeValue ?? '').includes(c.promptHead)) continue\n if (composer?.contains(node) || assistantNodes.some((a) => a.contains(node))) continue\n anchor = node\n }\n }\n const after = (e: Element) => anchor === null || (anchor.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0\n\n const full = region?.innerText ?? ''\n let text = full\n const composerText = composer && region?.contains(composer) ? composer.innerText.trim() : ''\n if (composerText) {\n const at = text.lastIndexOf(composerText)\n if (at >= 0) text = text.slice(0, at) + text.slice(at + composerText.length)\n }\n let lines = text.split('\\n').map((l) => l.trim()).filter(Boolean)\n if (anchor && c.promptHead) {\n // The same rule for lines: the last one holding the prompt that is not the assistant's.\n const replyLines = new Set(assistantNodes.flatMap((a) => a.innerText.split('\\n').map(squash)))\n let last = -1\n for (let i = 0; i < lines.length; i += 1) {\n const line = squash(lines[i]!)\n if (line.includes(c.promptHead) && !replyLines.has(line)) last = i\n }\n lines = lines.slice(last + 1)\n }\n\n const status = within(c.status).map(clean).filter(Boolean)\n // textContent, not innerText: a failure's collapsed details (the code) count too.\n const failureNodes = within(c.failureNodes).filter(after).map(clean).filter(Boolean)\n const retry = new RegExp(c.retrySource, c.retryFlags)\n const retryButtons = within('button').filter((b) => after(b) && retry.test((b.getAttribute('aria-label') ?? b.textContent ?? '').trim())).length\n const assistant = c.assistant ? assistantNodes.map((e) => e.innerText).join('\\n').trim().length : -1\n const stopVisible = composer !== null && Array.from(composer.querySelectorAll('button')).some((b) =>\n (b.getAttribute('aria-label') ?? b.textContent ?? '').trim() === c.stopName && b.getClientRects().length > 0)\n return { lines, failureNodes, retryButtons, status, assistant, transcriptChars: full.trim().length, stopVisible, anchored: anchor !== null }\n}\n","/**\n * Pressing Send like a person, exactly as often as it takes and never once more.\n *\n * A new-chat composer can drop a press while its model selection is still\n * resolving, and its Send control is not disabled while that gate is shut, so\n * one press can be a silent no-op and a retry is necessary. A retry is also\n * dangerous: the press creates a thread, so a press after the page has already\n * submitted asks for a second one. Pure, so the rule is a unit test.\n */\n\n/** Paths a submission from `routePath` lands on: the route itself and its single-fetch `.data` form. */\nexport function routeSubmitPaths(routePath: string): string[] {\n const singleFetch = routePath.endsWith('/') ? `${routePath}_.data` : `${routePath}.data`\n return [routePath, singleFetch]\n}\n\nexport interface SubmissionTracker {\n /** Whether one request is a submission from the tracked page. */\n matches(method: string, url: string): boolean\n observe(method: string, url: string): void\n /** Submissions seen so far. Above zero means the turn is on its way. */\n readonly count: number\n}\n\n/**\n * Counts submissions from the page at `routeUrl`: a POST to that route (or its\n * `.data` form), or to one of `sendPaths`, on the same origin. A POST to the\n * same path on another origin is not this composer's.\n */\nexport function createSubmissionTracker(routeUrl: string, sendPaths: readonly RegExp[]): SubmissionTracker {\n if (!/^https?:\\/\\//i.test(routeUrl)) throw new Error(`createSubmissionTracker needs the page's full URL, got \"${routeUrl}\"`)\n const route = new URL(routeUrl)\n const exact = new Set(routeSubmitPaths(route.pathname))\n let count = 0\n const matches = (method: string, url: string): boolean => {\n if (method !== 'POST') return false\n let parsed: URL\n try {\n parsed = new URL(url, route.origin)\n } catch {\n return false\n }\n if (parsed.origin !== route.origin) return false\n return exact.has(parsed.pathname) || sendPaths.some((p) => p.test(parsed.pathname))\n }\n return {\n matches,\n observe(method, url) {\n if (matches(method, url)) count += 1\n },\n get count() {\n return count\n },\n }\n}\n\nexport interface SendDriveOps {\n /** True once a submission, or the navigation it causes, has been observed. */\n landed: () => boolean\n /** Wait until Send can take a press, without pressing it. */\n ready: () => Promise<void>\n click: () => Promise<void>\n /** Pause between presses, spent watching for the submission. */\n wait: () => Promise<void>\n attempts: number\n}\n\n/**\n * Press until the page submits. Each attempt waits for the control first and\n * takes its last look at `landed()` after that wait, so the press itself is the\n * only unguarded moment. A click failure is tolerated only once something has\n * landed: an accepted send tears the composer down mid-press.\n */\nexport async function clickUntilSubmitted(ops: SendDriveOps): Promise<void> {\n for (let attempt = 0; attempt < ops.attempts; attempt += 1) {\n if (ops.landed()) return\n try {\n await ops.ready()\n if (ops.landed()) return\n await ops.click()\n } catch (cause) {\n if (!ops.landed()) throw cause\n }\n if (ops.landed()) return\n await ops.wait()\n }\n if (ops.landed()) return\n throw new Error(`Send never submitted: the composer refused ${ops.attempts} presses`)\n}\n\n/**\n * Read until the value stops changing: six identical reads 500 ms apart. Every\n * caller has already seen the turn finish, so this covers render lag only.\n */\nexport async function settleText(\n read: () => Promise<string>,\n wait: (ms: number) => Promise<void> = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),\n timeoutMs = 20_000,\n): Promise<string> {\n const deadline = Date.now() + timeoutMs\n let previous: string | null = null\n let stable = 0\n for (;;) {\n const current = await read().catch(() => null)\n if (current === null) {\n stable = 0\n } else {\n stable = current === previous ? stable + 1 : 1\n previous = current\n if (stable >= 6) return current\n }\n if (Date.now() >= deadline) return previous ?? ''\n await wait(500)\n }\n}\n\n/**\n * The text a composer holds. A `<textarea>` or `<input>` (agent-app's own\n * ChatComposer) keeps typed text in `.value` and leaves `innerText` empty; a\n * contenteditable composer keeps it in `innerText`. Reading only `innerText`\n * failed every first chat turn on the default composer (Casework C1/C5,\n * 2026-10-12).\n */\nexport async function composerText(box: { evaluate<R>(fn: (el: Element) => R): Promise<R> }): Promise<string> {\n return box.evaluate((el) => {\n const field = el as Element & { value?: unknown; innerText?: string }\n return typeof field.value === 'string' ? field.value : (field.innerText ?? el.textContent ?? '')\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,WAAW,qBAAqB;AACzC,SAAS,gBAAgB;AACzB,SAAS,YAAY;;;ACsBd,SAAS,WAAW,QAA+B;AACxD,QAAM,QAAQ,OAAO,MAAM,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,QAAQ,QAAQ,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,OAAO;AAC7F,SAAO,QAAQ,MAAM,MAAM,GAAG,EAAE,IAAI;AACtC;AAEO,SAAS,aAAa,GAAiC;AAC5D,QAAM,SAAS,CAAC,MAAc,EAAE,QAAQ,QAAQ,GAAG,EAAE,KAAK;AAC1D,QAAM,QAAQ,CAAC,MAAe,OAAO,EAAE,eAAe,EAAE;AACxD,QAAM,SAAS,SAAS,cAA2B,EAAE,UAAU;AAC/D,QAAM,WAAW,SAAS,cAA2B,EAAE,QAAQ;AAC/D,QAAM,iBAAiB,EAAE,YAAY,MAAM,KAAK,SAAS,iBAA8B,EAAE,SAAS,CAAC,IAAI,CAAC;AACxG,QAAM,SAAS,CAAC,QAAiB,SAAS,MAAM,KAAK,OAAO,iBAAiB,GAAG,CAAC,IAAI,CAAC;AAGtF,MAAI,SAAsB;AAC1B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wD,IAAI,IAAI,KAAK,MAAM,aAAa,KAAK,EAAE,IAAI;AACrI,WAAO,EAAE,QAAQ,KAAK,QAAQ,MAAM;AAAA,EACtC;AACF;AAEO,SAAS,QAAQ,MAAc,KAAqB;AACzD,QAAM,IAAI,KAAK,QAAQ,QAAQ,GAAG,EAAE,KAAK;AACzC,SAAO,EAAE,SAAS,MAAM,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,WAAM;AACtD;AAGA,eAAsB,aAAa,IAAY,OAAmG,CAAC,GAAqB;AACtK,MAAI,CAAC,4BAA4B,KAAK,EAAE,EAAG,OAAM,IAAI,MAAM,kDAAkD;AAC7G,QAAM,SAAS,KAAK,SAAS,sBAAsB,KAAK,MAAM,IAAI,MAAM,mBAAmB;AAC3F,MAAI;AACJ,MAAI;AACF,gBAAY,MAAM,OAAO,YAAY,GAAG;AAAA,EAC1C,QAAQ;AACN,UAAM,IAAI,MAAM,4FAA4F;AAAA,EAC9G;AACA,QAAM,UAAU,MAAM,SAAS,OAAO,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC;AACzE,SAAO,IAAI,QAAQ,IAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,UAAU,KAAK,CAAC;AACzE;","names":["composerText"]}
1
+ {"version":3,"sources":["../../src/journeys/journey.ts","../../src/journeys/artifacts.ts","../../src/journeys/page-reading.ts","../../src/journeys/send.ts"],"sourcesContent":["/**\n * One recorded journey through a running agent app: signed-in recorded\n * contexts, chapters, a person's pacing, desktop and phone screenshots,\n * measured chat turns, and a `finish()` that turns the recording into files\n * that are safe to copy off the host.\n *\n * const j = await startJourney('core-path') // reads journeys.config.mjs\n * const page = await j.open('founder', 'member') // recorded, already signed in\n * await j.step('Founder opens the workspace', () => page.goto('/app'), page)\n * await j.shot('home', page) // home-desktop.png + home-phone.png\n * const turn = await j.sendNew(page, 'Research …', { from: `/app/${ws}/chat/new` })\n * await j.finish() // mp4s, srt, highlights, scrubbed trace, timings\n *\n * Output, all safe to copy (finish() refuses otherwise):\n * <outDir>/<id>/video/<label>-full.mp4 <label>-highlights.mp4 <label>.srt <label>-trace.zip\n * <outDir>/<id>/<name>-desktop.png <name>-phone.png timings.json chapters.json turns/*.md\n * Raw webm and unscrubbed traces stay in <stateDir>/raw on the host.\n */\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { hostname } from 'node:os'\nimport { join } from 'node:path'\nimport type { Browser, BrowserContext, Locator, Page } from 'playwright'\nimport { pruneJourneyArtifacts } from './artifacts.js'\nimport { loadJourneysConfig, resolveJourneysConfig, threadRouteIn, type JourneysConfig, type ResolvedJourneysConfig, type ThreadRoute } from './config.js'\nimport { promptHead, readChatPage } from './page-reading.js'\nimport { scoreTurn, turnLooksActive, TurnEvidence, type TranscriptSnapshot, type TurnOutcome } from './score.js'\nimport { assertNoSecrets, scrubTrace } from './scrub.js'\nimport { clickUntilSubmitted, composerText, createSubmissionTracker, settleText } from './send.js'\nimport { secretNeedles, storageStateFor } from './session.js'\nimport { postProcessVideo, type Chapter } from './video.js'\n\nexport const DESKTOP = { width: 1440, height: 900 }\nexport const PHONE = { width: 390, height: 844 }\nconst sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))\nconst secs = (ms: number) => Math.round(ms / 100) / 10\n\n/** A visible pointer so a viewer can follow clicks in a headless recording. Hidden for screenshots. */\nconst CURSOR_SCRIPT = `(() => {\n const install = () => {\n if (document.getElementById('__journey_cursor') || !document.body) return\n const dot = document.createElement('div')\n dot.id = '__journey_cursor'\n dot.setAttribute('aria-hidden', 'true')\n Object.assign(dot.style, { position: 'fixed', zIndex: '2147483647', width: '24px', height: '24px',\n margin: '-12px 0 0 -12px', borderRadius: '50%', background: 'rgba(255,72,48,.28)',\n border: '2px solid rgba(255,72,48,.95)', pointerEvents: 'none', left: (window.__jx ?? -100) + 'px',\n top: (window.__jy ?? -100) + 'px', transition: 'transform .12s ease-out' })\n document.body.appendChild(dot)\n }\n addEventListener('mousemove', (e) => { window.__jx = e.clientX; window.__jy = e.clientY\n const d = document.getElementById('__journey_cursor'); if (d) { d.style.left = e.clientX + 'px'; d.style.top = e.clientY + 'px' } }, true)\n addEventListener('mousedown', () => { const d = document.getElementById('__journey_cursor'); if (d) d.style.transform = 'scale(.55)' }, true)\n addEventListener('mouseup', () => { const d = document.getElementById('__journey_cursor'); if (d) d.style.transform = 'scale(1)' }, true)\n // After hydration, so the framework never meets a node it did not render.\n addEventListener('load', () => setTimeout(install, 1500))\n setInterval(install, 2000)\n})()`\n\ninterface Recorded {\n label: string\n identity: string\n context: BrowserContext\n page: Page\n t0: number\n rawDir: string\n}\n\nexport interface TurnRecord {\n label: string\n prompt: string\n threadId: string | null\n sentAt: string\n /** Seconds from the Send press. */\n firstProgressS: number | null\n firstProgressText: string | null\n firstTextS: number | null\n /** Seconds from Send to the first failure evidence on the page, if any appeared. */\n firstFailureS: number | null\n completeS: number | null\n outcome: TurnOutcome\n /** Plain words for what went wrong, or null for a completed turn. */\n error: string | null\n /** Every piece of failure evidence the turn added. */\n failures: string[]\n /** Where evidence was read: after the turn's own prompt, or the whole transcript when the page did not show the prompt. */\n evidenceScope: 'after-prompt' | 'whole-transcript' | null\n replyChars: number\n /** Distinct status lines the transcript showed, with when they appeared. */\n stages: { s: number; text: string }[]\n /** Seconds from Send at which the journey pressed Stop, if it did. */\n stopPressedS: number | null\n replyFile: string | null\n}\n\nexport interface StepRecord {\n caption: string\n label: string | null\n startS: number\n durationS: number\n ok: boolean\n error?: string\n}\n\nexport interface SendOptions {\n caption?: string\n timeoutMs?: number\n /** Keystroke delay for the prompt. */\n delay?: number\n /** Press Stop at first text, or this many seconds after Send. */\n stopAfter?: 'first-text' | number\n}\n\n/** What the page shows right now, read in one evaluate. */\ninterface PageReading extends TranscriptSnapshot {\n status: string[]\n assistantChars: number\n transcriptChars: number\n stopVisible: boolean\n}\n\nexport class Journey {\n readonly outDir: string\n readonly rawDir: string\n readonly chapters: Chapter[] = []\n readonly steps: StepRecord[] = []\n readonly turns: TurnRecord[] = []\n private recorded: Recorded[] = []\n private phones = new Map<string, BrowserContext>()\n private screenshots = new Set<string>()\n private readonly startedAt = Date.now()\n\n constructor(readonly id: string, readonly config: ResolvedJourneysConfig, readonly browser: Browser, private readonly opts: { cursor: boolean }) {\n this.outDir = join(config.outDir, id)\n this.rawDir = join(config.stateDir, 'raw', `${id}-${new Date().toISOString().replace(/[:.]/g, '-')}`)\n mkdirSync(join(this.outDir, 'video'), { recursive: true })\n mkdirSync(join(this.outDir, 'turns'), { recursive: true })\n mkdirSync(this.rawDir, { recursive: true, mode: 0o700 })\n }\n\n /**\n * A recorded, traced 1440x900 context. A config identity starts signed in\n * from the cached session (no login form is ever recorded); `'anon'` starts\n * signed out, for public pages. Open at most two per journey.\n */\n async open(label: string, identity: string, opts: { fresh?: boolean } = {}): Promise<Page> {\n if (this.recorded.some((r) => r.label === label)) throw new Error(`a context labelled ${label} is already open`)\n if (!/^[a-z0-9][a-z0-9-]{0,30}$/.test(label)) throw new Error('context label: lowercase letters, digits and dashes')\n const storageState = identity === 'anon' ? undefined : (await storageStateFor(this.config, identity, opts)).path\n const rawDir = join(this.rawDir, label)\n const context = await this.browser.newContext({\n baseURL: this.config.baseUrl,\n storageState,\n viewport: DESKTOP,\n recordVideo: { dir: rawDir, size: DESKTOP },\n locale: 'en-US',\n timezoneId: 'America/Denver',\n })\n context.setDefaultTimeout(20_000)\n context.setDefaultNavigationTimeout(60_000)\n if (this.opts.cursor) await context.addInitScript(CURSOR_SCRIPT)\n if (process.env.JOURNEY_DEBUG_CLOCK === '1') {\n // Wall-clock seconds since recording start on every frame, for calibrating captions.\n await context.addInitScript((t0: number) => {\n setInterval(() => {\n let d = document.getElementById('__journey_clock')\n if (!d && document.body) {\n d = document.createElement('div')\n d.id = '__journey_clock'\n Object.assign(d.style, { position: 'fixed', left: '50%', top: '0', zIndex: '2147483647', font: 'bold 20px monospace', background: '#ff0', color: '#000', padding: '2px 6px', pointerEvents: 'none' })\n document.body.appendChild(d)\n }\n if (d) d.textContent = ((Date.now() - t0) / 1000).toFixed(1)\n }, 100)\n }, Date.now())\n }\n await context.tracing.start({ screenshots: true, snapshots: true, title: `${this.id} ${label}` })\n const page = await context.newPage()\n this.recorded.push({ label, identity, context, page, t0: Date.now(), rawDir })\n return page\n }\n\n private recordedFor(page?: Page): Recorded {\n const r = page ? this.recorded.find((x) => x.page === page) : this.recorded[0]\n if (!r) throw new Error('no recorded context for that page; call open() first')\n return r\n }\n\n /** A chapter at this instant: one plain line, shown in the caption bar and the .srt. */\n mark(caption: string, page?: Page): void {\n const label = page ? this.recordedFor(page).label : null\n this.chapters.push({ at: Date.now(), caption, label, kind: 'step' })\n console.log(`[${secs(Date.now() - this.startedAt).toFixed(1)}s] ${label ? `${label}: ` : ''}${caption}`)\n }\n\n /** A timed step with its own chapter. A failure is recorded, captioned, then rethrown. */\n async step<T>(caption: string, work: () => Promise<T>, page?: Page): Promise<T> {\n this.mark(caption, page)\n const start = Date.now()\n const entry: StepRecord = { caption, label: page ? this.recordedFor(page).label : null, startS: secs(start - this.startedAt), durationS: 0, ok: true }\n this.steps.push(entry)\n try {\n return await work()\n } catch (error) {\n entry.ok = false\n entry.error = String((error as Error)?.message ?? error).slice(0, 400)\n this.mark(`Step failed: ${caption}`, page)\n throw error\n } finally {\n entry.durationS = secs(Date.now() - start)\n }\n }\n\n /** A waiting span: real speed in the full video, sped up and labelled in the highlights. */\n async wait<T>(caption: string, work: () => Promise<T>, page?: Page): Promise<T> {\n const label = page ? this.recordedFor(page).label : null\n const chapter: Chapter = { at: Date.now(), caption, label, kind: 'wait', until: Date.now() }\n this.chapters.push(chapter)\n console.log(`[${secs(Date.now() - this.startedAt).toFixed(1)}s] ${label ? `${label}: ` : ''}(wait) ${caption}`)\n try {\n return await work()\n } finally {\n chapter.until = Date.now()\n }\n }\n\n pause(ms = 700): Promise<void> {\n return sleep(ms)\n }\n\n /** Move the visible pointer there, pause, click, pause. */\n async click(target: Locator, opts: { pauseAfter?: number } = {}): Promise<void> {\n await target.scrollIntoViewIfNeeded()\n const box = await target.boundingBox()\n if (box) await target.page().mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 14 })\n await sleep(250)\n await target.click()\n await sleep(opts.pauseAfter ?? 600)\n }\n\n /** Type at a readable pace into an input or textarea. */\n async type(target: Locator, text: string, opts: { delay?: number } = {}): Promise<void> {\n await this.click(target, { pauseAfter: 200 })\n const delay = opts.delay ?? 28\n await target.pressSequentially(text, { delay, timeout: 30_000 + text.length * (delay + 60) })\n await sleep(400)\n }\n\n /** The composer's message input. */\n composerInput(page: Page): Locator {\n return page.locator(this.config.chat.composer).getByRole('textbox', { name: this.config.chat.inputName })\n }\n\n private composerButton(page: Page, name: string): Locator {\n return page.locator(this.config.chat.composer).getByRole('button', { name, exact: true })\n }\n\n /**\n * Type into the chat composer at a readable pace. A line break is typed as\n * Shift+Enter, because Enter sends. Retries fast when hydration dropped\n * keystrokes. Never `fill()` a rich-text composer.\n */\n async typePrompt(page: Page, prompt: string, opts: { delay?: number } = {}): Promise<void> {\n const box = this.composerInput(page)\n await box.waitFor({ state: 'visible', timeout: 30_000 })\n await sleep(1_200)\n const delay = opts.delay ?? (prompt.length > 400 ? 8 : 22)\n const want = prompt.replace(/\\s+/g, ' ').trim().slice(0, 80)\n for (let attempt = 0; attempt < 4; attempt += 1) {\n await this.click(box, { pauseAfter: 150 })\n await box.press('ControlOrMeta+a')\n await box.press('Backspace')\n const lines = prompt.split('\\n')\n for (let i = 0; i < lines.length; i += 1) {\n if (i > 0) await box.press('Shift+Enter')\n // Sized by length: a loaded host types slower than the context's 20 s default allows.\n const line = lines[i]!\n if (line) await box.pressSequentially(line, { delay: attempt === 0 ? delay : 0, timeout: 30_000 + line.length * (delay + 60) })\n }\n const text = (await composerText(box).catch(() => '')).replace(/\\s+/g, ' ').trim()\n if (text.includes(want)) return\n await sleep(1_000)\n }\n throw new Error('the composer never held the prompt')\n }\n\n /**\n * Which parts of the chat contract this page shows, without sending\n * anything. Run it on a second app before trusting turn timings there.\n */\n async checkChatContract(page: Page): Promise<Record<'transcript' | 'composer' | 'input' | 'send', boolean>> {\n const visible = (l: Locator) => l.first().isVisible().catch(() => false)\n return {\n transcript: await visible(page.locator(this.config.chat.transcript)),\n composer: await visible(page.locator(this.config.chat.composer)),\n input: await visible(this.composerInput(page)),\n send: await visible(this.composerButton(page, this.config.chat.sendName)),\n }\n }\n\n /**\n * Desktop screenshot of the recorded page, then the same URL in a phone\n * context (390x844, same identity). Look at both before judging the screen.\n */\n async shot(name: string, page?: Page, opts: { phone?: boolean; fullPage?: boolean; phoneUrl?: string } = {}): Promise<{ desktop: string; phone?: string }> {\n const r = this.recordedFor(page)\n const slug = name.replace(/[^a-z0-9-]+/gi, '-').toLowerCase()\n const desktop = join(this.outDir, `${slug}-desktop.png`)\n const cursor = (display: string) => r.page.evaluate((d) => { const c = document.getElementById('__journey_cursor'); if (c) c.style.display = d }, display).catch(() => {})\n await cursor('none')\n await r.page.screenshot({ path: desktop, fullPage: opts.fullPage ?? false })\n this.screenshots.add(desktop)\n await cursor('')\n if (opts.phone === false) return { desktop }\n const phonePath = join(this.outDir, `${slug}-phone.png`)\n let ctx = this.phones.get(r.identity)\n if (!ctx) {\n const storageState = r.identity === 'anon' ? undefined : (await storageStateFor(this.config, r.identity)).path\n ctx = await this.browser.newContext({ baseURL: this.config.baseUrl, storageState, viewport: PHONE, deviceScaleFactor: 2, isMobile: true, hasTouch: true, locale: 'en-US', timezoneId: 'America/Denver' })\n this.phones.set(r.identity, ctx)\n }\n const phone = await ctx.newPage()\n try {\n await phone.goto(opts.phoneUrl ?? r.page.url(), { waitUntil: 'load' })\n await phone.waitForLoadState('networkidle', { timeout: 8_000 }).catch(() => {})\n await sleep(1_500)\n await phone.screenshot({ path: phonePath, fullPage: opts.fullPage ?? false })\n this.screenshots.add(phonePath)\n } finally {\n await phone.close()\n }\n return { desktop, phone: phonePath }\n }\n\n private budgetTurn(): void {\n if (this.turns.length >= this.config.maxTurns) {\n throw new Error(`this journey already sent ${this.turns.length} chat turns, its budget (maxTurns ${this.config.maxTurns})`)\n }\n }\n\n /**\n * Start a new thread: open `from` when given, type the prompt, press Send\n * like a person (again only while the page has not submitted; never deletes\n * a duplicate), wait for the thread, then measure the turn.\n */\n async sendNew(page: Page, prompt: string, opts: SendOptions & { from?: string } = {}): Promise<TurnRecord> {\n this.budgetTurn()\n if (opts.from && !page.url().startsWith(new URL(opts.from, this.config.baseUrl).href)) await page.goto(opts.from)\n await this.typePrompt(page, prompt, { delay: opts.delay })\n const send = this.composerButton(page, this.config.chat.sendName)\n await send.waitFor({ state: 'visible' })\n const box = await send.boundingBox()\n if (box) await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2, { steps: 14 })\n await sleep(400)\n const before = await this.read(page, prompt)\n const evidence = new TurnEvidence(this.patterns(), prompt)\n evidence.begin(before)\n const tracker = createSubmissionTracker(page.url(), this.config.chat.sendPaths)\n const count = (request: { method(): string; url(): string }) => tracker.observe(request.method(), request.url())\n page.on('request', count)\n this.mark(opts.caption ?? `Sends: \"${oneLine(prompt, 90)}\"`, page)\n const sentAt = Date.now()\n const onThread = () => threadRouteIn(page.url(), this.config) !== null\n try {\n await clickUntilSubmitted({\n landed: () => tracker.count > 0 || onThread(),\n ready: () => send.click({ trial: true, timeout: 5_000 }),\n click: () => send.click({ timeout: 5_000 }),\n wait: () => page.waitForRequest((r) => tracker.matches(r.method(), r.url()), { timeout: 1_000 }).then(() => undefined).catch(() => undefined),\n attempts: 15,\n })\n if (this.config.chat.threadPath) await page.waitForURL((url) => threadRouteIn(url.href, this.config) !== null, { timeout: 45_000 })\n } catch (error) {\n return this.notSent(page, prompt, sentAt, String((error as Error).message).slice(0, 300))\n } finally {\n page.off('request', count)\n }\n if (tracker.count > 1) console.warn(`the composer submitted ${tracker.count} times; a duplicate thread may exist (left in place)`)\n return this.measureTurn(page, prompt, sentAt, evidence, before, 0, opts)\n }\n\n /** A follow-up in the open thread: type, one Send press, measure. */\n async sendInThread(page: Page, prompt: string, opts: SendOptions = {}): Promise<TurnRecord> {\n this.budgetTurn()\n await this.typePrompt(page, prompt, { delay: opts.delay })\n const send = this.composerButton(page, this.config.chat.sendName)\n const before = await this.read(page, prompt)\n const evidence = new TurnEvidence(this.patterns(), prompt)\n evidence.begin(before)\n const tracker = createSubmissionTracker(page.url(), this.config.chat.sendPaths)\n const posted = page.waitForRequest((r) => tracker.matches(r.method(), r.url()), { timeout: 30_000 })\n this.mark(opts.caption ?? `Follows up: \"${oneLine(prompt, 90)}\"`, page)\n const sentAt = Date.now()\n await this.click(send, { pauseAfter: 0 })\n const sent = await posted.then(() => true).catch(() => false)\n if (!sent) return this.notSent(page, prompt, sentAt, 'no chat request within 30 s of pressing Send')\n return this.measureTurn(page, prompt, sentAt, evidence, before, Math.max(0, before.assistantChars), opts)\n }\n\n private patterns() {\n return { failure: this.config.chat.failureText, stopped: this.config.chat.stoppedText }\n }\n\n private blankTurn(page: Page, prompt: string, sentAt: number): TurnRecord {\n return {\n label: this.recordedFor(page).label, prompt, threadId: threadRouteIn(page.url(), this.config)?.threadId ?? null,\n sentAt: new Date(sentAt).toISOString(), firstProgressS: null, firstProgressText: null, firstTextS: null, firstFailureS: null, completeS: null,\n outcome: 'timeout', error: null, failures: [], evidenceScope: null, replyChars: 0, stages: [], stopPressedS: null, replyFile: null,\n }\n }\n\n private notSent(page: Page, prompt: string, sentAt: number, why: string): TurnRecord {\n const t = { ...this.blankTurn(page, prompt, sentAt), ...scoreTurn({ notSent: why, timedOut: false, evidence: { failures: [], stopped: [], retryAppeared: false }, replyChars: 0, stopPressed: false }) }\n this.turns.push(t)\n this.mark(`Turn not sent: ${oneLine(why, 90)}`, page)\n return t\n }\n\n /** One read of the transcript, composer and failure marks; with a prompt, the evidence that follows it. */\n private async read(page: Page, prompt: string | null = null): Promise<PageReading> {\n const c = this.config.chat\n const { assistant, ...reading } = await page.evaluate(readChatPage, {\n transcript: c.transcript, status: c.status, failureNodes: c.failureNodes, retrySource: c.retryName.source, retryFlags: c.retryName.flags,\n assistant: c.assistant, composer: c.composer, stopName: c.stopName, promptHead: prompt === null ? null : promptHead(prompt),\n })\n return { ...reading, assistantChars: assistant }\n }\n\n private async runningTurns(page: Page, route: ThreadRoute | null): Promise<string[] | null> {\n if (!route || !this.config.chat.runningTurns) return null\n const res = await page.request.get(this.config.chat.runningTurns(route))\n if (!res.ok()) throw new Error(`running turns answered ${res.status()}`)\n const body = (await res.json()) as { running?: unknown }\n if (!Array.isArray(body.running)) throw new Error('running turns returned no `running` array')\n return body.running.map(String)\n }\n\n /**\n * Time to first visible progress (a new status line or reply text), first\n * reply text, and the turn's end, polled every 300 ms. Failure evidence is\n * read after the turn's own prompt when the page shows it. The turn has ended\n * when, for two reads in a row, {@link turnLooksActive} is false and, where\n * the app lists running turns, the server lists none. Status lines already\n * on the page before Send are not progress. The outcome comes from\n * {@link scoreTurn}.\n */\n private async measureTurn(page: Page, prompt: string, sentAt: number, evidence: TurnEvidence, before: PageReading, baselineChars: number, opts: SendOptions): Promise<TurnRecord> {\n const t = this.blankTurn(page, prompt, sentAt)\n this.turns.push(t)\n const route = threadRouteIn(page.url(), this.config)\n t.threadId = route?.threadId ?? null\n const timeoutMs = opts.timeoutMs ?? 15 * 60_000\n const since = () => secs(Date.now() - sentAt)\n const standingStatus = new Set(before.status)\n // Without an assistant selector, reply text is transcript growth from the\n // first read after Send (the person's own message is on the page by then).\n let growthBase: number | null = null\n let growth = 0\n let sawActive = false\n let quiet = 0\n let lastServerCheck = 0\n let serverRunning: string[] | null = null\n let lastStage = ''\n let lastStatus = ''\n let statusChangedAt = Date.now()\n let finished = false\n await this.wait('Waiting for the agent', async () => {\n while (Date.now() - sentAt < timeoutMs) {\n const s = await this.read(page, prompt).catch(() => null)\n if (s) {\n t.evidenceScope = s.anchored ? 'after-prompt' : 'whole-transcript'\n const shown = evidence.observe(s)\n if (shown.length) {\n t.firstFailureS ??= since()\n this.mark(`Failure shown after ${since()} s: ${oneLine(shown[0]!, 90)}`, page)\n }\n const status = s.status.filter((line) => !standingStatus.has(line))\n growthBase ??= s.transcriptChars\n const chars = s.assistantChars >= 0 ? s.assistantChars - baselineChars : s.transcriptChars - growthBase - status.join(' ').length\n growth = Math.max(growth, chars)\n const stage = status.join(' | ').replace(/\\b\\d+(\\.\\d+)?\\s?s\\b/g, '').trim()\n if (stage && stage !== lastStage) {\n t.stages.push({ s: since(), text: status.join(' | ').slice(0, 160) })\n lastStage = stage\n }\n // Raw text, timers included: a ticking \"Preparing your workspace… 31s\" is changing.\n if (status.join(' | ') !== lastStatus) {\n lastStatus = status.join(' | ')\n statusChangedAt = Date.now()\n }\n if (t.firstProgressS === null && (status.length || chars > 0)) {\n t.firstProgressS = since()\n t.firstProgressText = status[0] ?? 'reply text'\n this.mark(`First visible progress after ${t.firstProgressS} s: ${oneLine(t.firstProgressText, 70)}`, page)\n }\n if (t.firstTextS === null && chars > 0) {\n t.firstTextS = since()\n this.mark(`First text after ${t.firstTextS} s`, page)\n }\n const stopDue = opts.stopAfter === 'first-text' ? t.firstTextS !== null : typeof opts.stopAfter === 'number' && since() >= opts.stopAfter\n if (t.stopPressedS === null && stopDue && s.stopVisible) {\n t.stopPressedS = since()\n this.mark(`Presses Stop after ${t.stopPressedS} s`, page)\n await this.click(this.composerButton(page, this.config.chat.stopName), { pauseAfter: 200 }).catch((e) => console.warn(`Stop press failed: ${e}`))\n }\n if (status.length > 0) sawActive = true\n const active = turnLooksActive({ stopVisible: s.stopVisible, statusLines: status.length, msSinceStatusChanged: Date.now() - statusChangedAt })\n quiet = active ? 0 : quiet + 1\n }\n if (route && this.config.chat.runningTurns && Date.now() - lastServerCheck > 2_000) {\n lastServerCheck = Date.now()\n // A failed read never implies the turn ended.\n serverRunning = await this.runningTurns(page, route).catch(() => serverRunning)\n if (serverRunning?.length) sawActive = true\n }\n const started = sawActive || t.firstTextS !== null || Date.now() - sentAt > 45_000\n const serverDone = !this.config.chat.runningTurns || !route || serverRunning?.length === 0\n if (started && quiet >= 2 && serverDone) {\n finished = true\n return\n }\n await sleep(300)\n }\n }, page)\n t.completeS = finished ? since() : null\n // Render lag only: the turn has ended, so wait for the transcript to stop changing before judging it.\n await settleText(() => this.read(page, prompt).then((r) => `${r.transcriptChars}:${r.failureNodes.length}:${r.retryButtons}`))\n const last = await this.read(page, prompt)\n t.evidenceScope = last.anchored ? 'after-prompt' : 'whole-transcript'\n evidence.observe(last)\n const finalText = this.config.chat.assistant ? await this.replyText(page) : ''\n t.replyChars = this.config.chat.assistant ? Math.max(0, finalText.length - baselineChars) : Math.max(0, growth)\n Object.assign(t, scoreTurn({ timedOut: !finished, evidence: evidence.added(), replyChars: t.replyChars, stopPressed: t.stopPressedS !== null }))\n const n = this.turns.length\n t.replyFile = join('turns', `${String(n).padStart(2, '0')}-${t.label}.md`)\n const reply = this.config.chat.assistant ? finalText.slice(baselineChars).trim() : '(this app configures no assistant selector; read the reply in the video or the trace)'\n const failures = t.failures.length ? `\\n\\n## Failure evidence\\n\\n${t.failures.map((f) => `- ${f}`).join('\\n')}` : ''\n writeFileSync(join(this.outDir, t.replyFile), `# Turn ${n} (${t.label})\\n\\n## Prompt\\n\\n${prompt}\\n\\n## Reply (${t.outcome})\\n\\n${reply}${failures}\\n`)\n this.mark(\n t.outcome === 'completed'\n ? `Turn complete after ${t.completeS} s (${t.replyChars} chars)`\n : `Turn ${t.outcome.toUpperCase()} after ${t.completeS ?? since()} s${t.error ? `: ${oneLine(t.error, 80)}` : ''}`,\n page,\n )\n return t\n }\n\n private async replyText(page: Page): Promise<string> {\n const sel = this.config.chat.assistant\n if (!sel) return ''\n return settleText(async () => (await page.locator(sel).allInnerTexts()).join('\\n').trim())\n }\n\n /**\n * Close everything, then per context: a captioned full .mp4, a highlights cut\n * (at most 178 s, long waits sped up and labelled), an .srt and a scrubbed\n * trace.zip; plus timings.json and chapters.json. Refuses (throws) when any\n * output file still holds a password or cookie value.\n */\n async finish(opts: { speedup2x?: boolean } = {}): Promise<{ outDir: string; files: string[] }> {\n for (const ctx of this.phones.values()) await ctx.close().catch(() => {})\n const files: string[] = []\n // Stop every recording first, so one context's video does not run on through another's processing.\n const stopped: { r: Recorded; rawTrace: string; webm: string | null; endedAt: number }[] = []\n for (const r of this.recorded) {\n const endedAt = Date.now()\n const rawTrace = join(r.rawDir, 'trace.raw.zip')\n await r.context.tracing.stop({ path: rawTrace }).catch((e) => console.warn(`tracing.stop failed for ${r.label}: ${e}`))\n const video = r.page.video()\n await r.context.close()\n stopped.push({ r, rawTrace, webm: video ? await video.path().catch(() => null) : null, endedAt })\n }\n const needles = secretNeedles(this.config)\n for (const { r, rawTrace, webm, endedAt } of stopped) {\n if (webm) {\n files.push(...postProcessVideo({\n webm, workDir: r.rawDir, videoDir: join(this.outDir, 'video'), label: r.label, t0: r.t0,\n wallSeconds: (endedAt - r.t0) / 1000, chapters: this.chapters.filter((c) => c.label === null || c.label === r.label),\n speedup2x: opts.speedup2x ?? false,\n }))\n }\n try {\n const clean = join(this.outDir, 'video', `${r.label}-trace.zip`)\n const result = scrubTrace(rawTrace, clean, [...needles.hard, ...needles.soft])\n console.log(`trace ${r.label}: ${result.entries} entries, ${result.dropped} sensitive bodies dropped, ${result.rewritten} rewritten`)\n files.push(clean)\n } catch (error) {\n console.warn(`trace ${r.label} not written: ${(error as Error).message}`)\n }\n }\n writeFileSync(join(this.outDir, 'chapters.json'), JSON.stringify(this.chapters.map((c) => ({ ...c, at: new Date(c.at).toISOString(), until: c.until ? new Date(c.until).toISOString() : undefined, offsetS: secs(c.at - this.startedAt) })), null, 2))\n writeFileSync(join(this.outDir, 'timings.json'), JSON.stringify({ journey: this.id, app: this.config.app, base: this.config.baseUrl, startedAt: new Date(this.startedAt).toISOString(), wallS: secs(Date.now() - this.startedAt), steps: this.steps, turns: this.turns }, null, 2))\n await this.browser.close()\n assertNoSecrets(this.outDir, needles)\n pruneJourneyArtifacts(this.outDir, new Set([\n ...files,\n ...this.screenshots,\n ...this.turns.flatMap((turn) => turn.replyFile ? [join(this.outDir, turn.replyFile)] : []),\n ]))\n console.log(`\\n${this.id}: ${this.steps.length} steps, ${this.turns.length} turns, wall ${secs(Date.now() - this.startedAt)} s`)\n for (const t of this.turns) {\n console.log(` turn[${t.label}] ${t.outcome}: progress ${t.firstProgressS ?? '-'} s, first text ${t.firstTextS ?? '-'} s, end ${t.completeS ?? '-'} s, ${t.replyChars} chars${t.error ? ` | ${oneLine(t.error, 100)}` : ''}`)\n }\n const host = process.env.JOURNEYS_HOST_ALIAS ?? hostname()\n console.log(`output: ${this.outDir}\\ncopy it (run where you will watch it):\\n rsync -a ${host}:${this.outDir}/ \"<dest>/${this.id}/\"`)\n return { outDir: this.outDir, files }\n }\n}\n\nexport function oneLine(text: string, max: number): string {\n const s = text.replace(/\\s+/g, ' ').trim()\n return s.length > max ? `${s.slice(0, max - 1)}…` : s\n}\n\n/** Open a journey. Without `config`, reads `journeys.config.mjs` from the working directory. */\nexport async function startJourney(id: string, opts: { config?: JourneysConfig | ResolvedJourneysConfig; cursor?: boolean; headless?: boolean } = {}): Promise<Journey> {\n if (!/^[a-z0-9][a-z0-9-]{1,60}$/.test(id)) throw new Error('journey id: lowercase letters, digits and dashes')\n const config = opts.config ? resolveJourneysConfig(opts.config) : await loadJourneysConfig()\n let chromium\n try {\n chromium = (await import('playwright')).chromium\n } catch {\n throw new Error('journeys need the optional `playwright` peer: install playwright in the app that runs them')\n }\n const browser = await chromium.launch({ headless: opts.headless ?? true })\n return new Journey(id, config, browser, { cursor: opts.cursor ?? true })\n}\n","import { readdirSync, rmSync } from 'node:fs'\nimport { join, resolve } from 'node:path'\n\nconst groups = [\n {\n directory: '',\n owns: (name: string) => name.endsWith('-desktop.png') || name.endsWith('-phone.png'),\n },\n {\n directory: 'video',\n owns: (name: string) => name.endsWith('.mp4') || name.endsWith('.srt') || name.endsWith('-trace.zip'),\n },\n {\n directory: 'turns',\n owns: (name: string) => name.endsWith('.md'),\n },\n] as const\n\nexport function pruneJourneyArtifacts(outDir: string, retained: ReadonlySet<string>): void {\n const keep = new Set([...retained].map((file) => resolve(file)))\n for (const group of groups) {\n const directory = join(resolve(outDir), group.directory)\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n if ((!entry.isFile() && !entry.isSymbolicLink()) || !group.owns(entry.name)) continue\n const file = join(directory, entry.name)\n if (!keep.has(file)) rmSync(file)\n }\n }\n}\n","/**\n * The one read of a chat page a journey takes every 300 ms, run inside the page\n * by `page.evaluate`, so it must stay self-contained: DOM globals only, no\n * imports and no module-scope names.\n *\n * Failure evidence belongs to the turn whose prompt it follows. On 2026-10-11\n * GTM showed a live Stop as a grey notice, then, when the next message was\n * sent, re-rendered the stopped turn with its red \"You stopped this turn.\" card\n * and a Retry control, above the new message. Read from the whole transcript,\n * that card failed the follow-up, which had answered in 28.5 s. So when the\n * transcript shows the turn's own prompt, only failure marks, Retry controls\n * and lines after it count; when it does not, the whole transcript does.\n */\n\ninterface PageReadArgs {\n readonly transcript: string\n readonly status: string\n readonly failureNodes: string\n readonly retrySource: string\n readonly retryFlags: string\n readonly assistant: string | null\n readonly composer: string\n readonly stopName: string\n /** The turn's prompt as {@link promptHead} gives it; null reads the whole transcript. */\n readonly promptHead: string | null\n}\n\ninterface RawPageReading {\n /** Visible transcript lines (after the turn's prompt when `anchored`). */\n lines: string[]\n failureNodes: string[]\n retryButtons: number\n status: string[]\n /** Characters of assistant text on the page, or -1 with no assistant selector. */\n assistant: number\n transcriptChars: number\n stopVisible: boolean\n /** The turn's prompt was found, so the evidence fields hold only what follows it. */\n anchored: boolean\n}\n\n/** The text a transcript shows for a prompt: its first line, whitespace squashed, at most 48 characters. */\nexport function promptHead(prompt: string): string | null {\n const first = prompt.split('\\n').map((line) => line.replace(/\\s+/g, ' ').trim()).find(Boolean)\n return first ? first.slice(0, 48) : null\n}\n\nexport function readChatPage(c: PageReadArgs): RawPageReading {\n const squash = (s: string) => s.replace(/\\s+/g, ' ').trim()\n const clean = (e: Element) => squash(e.textContent ?? '')\n const region = document.querySelector<HTMLElement>(c.transcript)\n const composer = document.querySelector<HTMLElement>(c.composer)\n const assistantNodes = c.assistant ? Array.from(document.querySelectorAll<HTMLElement>(c.assistant)) : []\n const within = (sel: string) => (region ? Array.from(region.querySelectorAll(sel)) : [])\n\n // The last text node outside the composer and the assistant's own text that holds the prompt.\n let anchor: Node | null = null\n if (region && c.promptHead) {\n const walker = document.createTreeWalker(region, NodeFilter.SHOW_TEXT)\n for (let node = walker.nextNode(); node; node = walker.nextNode()) {\n if (!squash(node.nodeValue ?? '').includes(c.promptHead)) continue\n if (composer?.contains(node) || assistantNodes.some((a) => a.contains(node))) continue\n anchor = node\n }\n }\n const after = (e: Element) => anchor === null || (anchor.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0\n\n const full = region?.innerText ?? ''\n let text = full\n const composerText = composer && region?.contains(composer) ? composer.innerText.trim() : ''\n if (composerText) {\n const at = text.lastIndexOf(composerText)\n if (at >= 0) text = text.slice(0, at) + text.slice(at + composerText.length)\n }\n let lines = text.split('\\n').map((l) => l.trim()).filter(Boolean)\n if (anchor && c.promptHead) {\n // The same rule for lines: the last one holding the prompt that is not the assistant's.\n const replyLines = new Set(assistantNodes.flatMap((a) => a.innerText.split('\\n').map(squash)))\n let last = -1\n for (let i = 0; i < lines.length; i += 1) {\n const line = squash(lines[i]!)\n if (line.includes(c.promptHead) && !replyLines.has(line)) last = i\n }\n lines = lines.slice(last + 1)\n }\n\n const status = within(c.status).map(clean).filter(Boolean)\n // textContent, not innerText: a failure's collapsed details (the code) count too.\n const failureNodes = within(c.failureNodes).filter(after).map(clean).filter(Boolean)\n const retry = new RegExp(c.retrySource, c.retryFlags)\n const retryButtons = within('button').filter((b) => after(b) && retry.test((b.getAttribute('aria-label') ?? b.textContent ?? '').trim())).length\n const assistant = c.assistant ? assistantNodes.map((e) => e.innerText).join('\\n').trim().length : -1\n const stopVisible = composer !== null && Array.from(composer.querySelectorAll('button')).some((b) =>\n (b.getAttribute('aria-label') ?? b.textContent ?? '').trim() === c.stopName && b.getClientRects().length > 0)\n return { lines, failureNodes, retryButtons, status, assistant, transcriptChars: full.trim().length, stopVisible, anchored: anchor !== null }\n}\n","/**\n * Pressing Send like a person, exactly as often as it takes and never once more.\n *\n * A new-chat composer can drop a press while its model selection is still\n * resolving, and its Send control is not disabled while that gate is shut, so\n * one press can be a silent no-op and a retry is necessary. A retry is also\n * dangerous: the press creates a thread, so a press after the page has already\n * submitted asks for a second one. Pure, so the rule is a unit test.\n */\n\n/** Paths a submission from `routePath` lands on: the route itself and its single-fetch `.data` form. */\nexport function routeSubmitPaths(routePath: string): string[] {\n const singleFetch = routePath.endsWith('/') ? `${routePath}_.data` : `${routePath}.data`\n return [routePath, singleFetch]\n}\n\nexport interface SubmissionTracker {\n /** Whether one request is a submission from the tracked page. */\n matches(method: string, url: string): boolean\n observe(method: string, url: string): void\n /** Submissions seen so far. Above zero means the turn is on its way. */\n readonly count: number\n}\n\n/**\n * Counts submissions from the page at `routeUrl`: a POST to that route (or its\n * `.data` form), or to one of `sendPaths`, on the same origin. A POST to the\n * same path on another origin is not this composer's.\n */\nexport function createSubmissionTracker(routeUrl: string, sendPaths: readonly RegExp[]): SubmissionTracker {\n if (!/^https?:\\/\\//i.test(routeUrl)) throw new Error(`createSubmissionTracker needs the page's full URL, got \"${routeUrl}\"`)\n const route = new URL(routeUrl)\n const exact = new Set(routeSubmitPaths(route.pathname))\n let count = 0\n const matches = (method: string, url: string): boolean => {\n if (method !== 'POST') return false\n let parsed: URL\n try {\n parsed = new URL(url, route.origin)\n } catch {\n return false\n }\n if (parsed.origin !== route.origin) return false\n return exact.has(parsed.pathname) || sendPaths.some((p) => p.test(parsed.pathname))\n }\n return {\n matches,\n observe(method, url) {\n if (matches(method, url)) count += 1\n },\n get count() {\n return count\n },\n }\n}\n\nexport interface SendDriveOps {\n /** True once a submission, or the navigation it causes, has been observed. */\n landed: () => boolean\n /** Wait until Send can take a press, without pressing it. */\n ready: () => Promise<void>\n click: () => Promise<void>\n /** Pause between presses, spent watching for the submission. */\n wait: () => Promise<void>\n attempts: number\n}\n\n/**\n * Press until the page submits. Each attempt waits for the control first and\n * takes its last look at `landed()` after that wait, so the press itself is the\n * only unguarded moment. A click failure is tolerated only once something has\n * landed: an accepted send tears the composer down mid-press.\n */\nexport async function clickUntilSubmitted(ops: SendDriveOps): Promise<void> {\n for (let attempt = 0; attempt < ops.attempts; attempt += 1) {\n if (ops.landed()) return\n try {\n await ops.ready()\n if (ops.landed()) return\n await ops.click()\n } catch (cause) {\n if (!ops.landed()) throw cause\n }\n if (ops.landed()) return\n await ops.wait()\n }\n if (ops.landed()) return\n throw new Error(`Send never submitted: the composer refused ${ops.attempts} presses`)\n}\n\n/**\n * Read until the value stops changing: six identical reads 500 ms apart. Every\n * caller has already seen the turn finish, so this covers render lag only.\n */\nexport async function settleText(\n read: () => Promise<string>,\n wait: (ms: number) => Promise<void> = (ms) => new Promise((resolve) => setTimeout(resolve, ms)),\n timeoutMs = 20_000,\n): Promise<string> {\n const deadline = Date.now() + timeoutMs\n let previous: string | null = null\n let stable = 0\n for (;;) {\n const current = await read().catch(() => null)\n if (current === null) {\n stable = 0\n } else {\n stable = current === previous ? stable + 1 : 1\n previous = current\n if (stable >= 6) return current\n }\n if (Date.now() >= deadline) return previous ?? ''\n await wait(500)\n }\n}\n\n/**\n * The text a composer holds. A `<textarea>` or `<input>` (agent-app's own\n * ChatComposer) keeps typed text in `.value` and leaves `innerText` empty; a\n * contenteditable composer keeps it in `innerText`. Reading only `innerText`\n * failed every first chat turn on the default composer (Casework C1/C5,\n * 2026-10-12).\n */\nexport async function composerText(box: { evaluate<R>(fn: (el: Element) => R): Promise<R> }): Promise<string> {\n return box.evaluate((el) => {\n const field = el as Element & { value?: unknown; innerText?: string }\n return typeof field.value === 'string' ? field.value : (field.innerText ?? el.textContent ?? '')\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,WAAW,qBAAqB;AACzC,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YAAY,GAAG;AAAA,EAC1C,QAAQ;AACN,UAAM,IAAI,MAAM,4FAA4F;AAAA,EAC9G;AACA,QAAM,UAAU,MAAM,SAAS,OAAO,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC;AACzE,SAAO,IAAI,QAAQ,IAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,UAAU,KAAK,CAAC;AACzE;","names":["join","composerText","resolve","resolve","join"]}
@@ -67,6 +67,7 @@ export declare class Journey {
67
67
  readonly turns: TurnRecord[];
68
68
  private recorded;
69
69
  private phones;
70
+ private screenshots;
70
71
  private readonly startedAt;
71
72
  constructor(id: string, config: ResolvedJourneysConfig, browser: Browser, opts: {
72
73
  cursor: boolean;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createChatTurnRoutes,
3
3
  streamChatRouteAsSandboxEvents
4
- } from "../chunk-PVEB4UJI.js";
4
+ } from "../chunk-6GX3UHQW.js";
5
5
  import "../chunk-KH4QSBNI.js";
6
6
  import "../chunk-CQGEGPY7.js";
7
7
  import "../chunk-RN4WPTBH.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.63.16",
3
+ "version": "0.63.18",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [