@michael-joseph-miller/ant-bot 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to ant-bot are recorded here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
5
|
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.1.5] — 2026-08-23
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Input is now dispatched in order.** The screencast socket handles each frame without awaiting
|
|
12
|
+
the last, so events raced: a mouse down and up could invert and a burst of typing arrived
|
|
13
|
+
shuffled. Slow human typing mostly survived it, which is why this looked like "some keys work"
|
|
14
|
+
rather than like a bug. Input is serialised per screen, and the takeover check runs again at
|
|
15
|
+
dispatch so a queued event cannot land after control is handed back. Backlogged pointer moves
|
|
16
|
+
are dropped rather than queued without bound; clicks, keys and text never are.
|
|
17
|
+
|
|
7
18
|
## [0.1.4] — 2026-08-23
|
|
8
19
|
|
|
9
20
|
### Added
|
package/README.md
CHANGED
|
@@ -276,10 +276,10 @@ Current totals, as run against this checkout:
|
|
|
276
276
|
| Package | Test files | Tests |
|
|
277
277
|
|---|---|---|
|
|
278
278
|
| `@antbot/contract` | 1 | 22 |
|
|
279
|
-
| `@antbot/daemon` | 20 |
|
|
279
|
+
| `@antbot/daemon` | 20 | 471 |
|
|
280
280
|
| `@antbot/ui` | 8 | 63 |
|
|
281
281
|
| `@antbot/cli` | 7 | 116 |
|
|
282
|
-
| **Total** | **36** | **
|
|
282
|
+
| **Total** | **36** | **672** |
|
|
283
283
|
|
|
284
284
|
## Status / not built
|
|
285
285
|
|
|
@@ -134,6 +134,7 @@ function errMsg(err) {
|
|
|
134
134
|
return err instanceof Error ? err.message : String(err);
|
|
135
135
|
}
|
|
136
136
|
var MAX_SELECTION_CHARS = 1e5;
|
|
137
|
+
var MAX_QUEUED_INPUT = 32;
|
|
137
138
|
var BrowserService = class {
|
|
138
139
|
constructor(deps) {
|
|
139
140
|
this.deps = deps;
|
|
@@ -160,6 +161,9 @@ var BrowserService = class {
|
|
|
160
161
|
* likely to be rescuing (a login form sitting still, waiting for input).
|
|
161
162
|
*/
|
|
162
163
|
lastFrameSize = /* @__PURE__ */ new Map();
|
|
164
|
+
/** Per-bot serialisation chain for human input — see forwardInput. */
|
|
165
|
+
inputQueue = /* @__PURE__ */ new Map();
|
|
166
|
+
inputDepth = /* @__PURE__ */ new Map();
|
|
163
167
|
get isHeadless() {
|
|
164
168
|
return this.headlessMode;
|
|
165
169
|
}
|
|
@@ -511,6 +515,8 @@ ${this.orientLine(o)}`;
|
|
|
511
515
|
}
|
|
512
516
|
returnControl(botId) {
|
|
513
517
|
this.takenOver.delete(botId);
|
|
518
|
+
this.inputQueue.delete(botId);
|
|
519
|
+
this.inputDepth.delete(botId);
|
|
514
520
|
}
|
|
515
521
|
/**
|
|
516
522
|
* The remote page's current text selection, for copying out of a taken-over screen.
|
|
@@ -580,11 +586,12 @@ ${this.orientLine(o)}`;
|
|
|
580
586
|
/**
|
|
581
587
|
* Dispatches human input into a taken-over page.
|
|
582
588
|
*
|
|
583
|
-
* The takeover check is the whole security model here
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
* what *bots* do; this is the human
|
|
589
|
+
* The takeover check is the whole security model here. It is applied twice on purpose: on entry,
|
|
590
|
+
* so a caller is refused immediately, and again at dispatch, because events *are* queued for
|
|
591
|
+
* ordering and control can be returned while some are still pending. Without the second check a
|
|
592
|
+
* stale click would land after handback, into a page the bot has since navigated. Input does not
|
|
593
|
+
* pass the Permission Gateway, because the gateway governs what *bots* do; this is the human
|
|
594
|
+
* acting as themselves on their own computer.
|
|
588
595
|
*
|
|
589
596
|
* Dispatch goes through Playwright's `page.mouse` / `page.keyboard` rather than raw CDP so the
|
|
590
597
|
* key-code mapping is the SDK's problem, matching how `click()` and `type()` above work.
|
|
@@ -595,6 +602,25 @@ ${this.orientLine(o)}`;
|
|
|
595
602
|
"Input was sent for a screen that is not taken over. Take over the screen first."
|
|
596
603
|
);
|
|
597
604
|
}
|
|
605
|
+
const depth = (this.inputDepth.get(botId) ?? 0) + 1;
|
|
606
|
+
this.inputDepth.set(botId, depth);
|
|
607
|
+
if (ev.kind === "mouse" && ev.action === "move" && depth > MAX_QUEUED_INPUT) {
|
|
608
|
+
this.inputDepth.set(botId, depth - 1);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const run = async () => {
|
|
612
|
+
try {
|
|
613
|
+
if (this.takenOver.has(botId)) await this.dispatchInput(botId, ev);
|
|
614
|
+
} finally {
|
|
615
|
+
this.inputDepth.set(botId, Math.max(0, (this.inputDepth.get(botId) ?? 1) - 1));
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
const chained = (this.inputQueue.get(botId) ?? Promise.resolve()).then(run, run);
|
|
619
|
+
this.inputQueue.set(botId, chained.catch(() => {
|
|
620
|
+
}));
|
|
621
|
+
return chained;
|
|
622
|
+
}
|
|
623
|
+
async dispatchInput(botId, ev) {
|
|
598
624
|
const page = await this.getPage(botId);
|
|
599
625
|
if (ev.kind === "text") {
|
|
600
626
|
await page.keyboard.insertText(ev.text);
|
|
@@ -677,4 +703,4 @@ export {
|
|
|
677
703
|
detectBlockFromSignals,
|
|
678
704
|
normalizeUrl
|
|
679
705
|
};
|
|
680
|
-
//# sourceMappingURL=browser-
|
|
706
|
+
//# sourceMappingURL=browser-NOWM4S6C.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../daemon/src/computer/browser.ts", "../../daemon/src/computer/input.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { chromium } from 'playwright';\nimport type { BrowserContext, CDPSession, Page } from 'playwright';\nimport type { EventBus } from '../util/bus.js';\nimport { toPageCoords, isForwardableKey, clampWheel, type FrameSize } from './input.js';\nimport type { ScreencastInput } from '@antbot/contract';\nimport { logger } from '../util/log.js';\n\nconst log = logger('browser');\n\n/* ------------------------------------------------------------------------------------------- *\n * Errors\n * ------------------------------------------------------------------------------------------- */\n\n/** Thrown when the browser cannot be launched (e.g. Chromium isn't installed). */\nexport class BrowserUnavailableError extends Error {\n constructor(public readonly reason: string) {\n super(`Browser is unavailable: ${reason}. Try: npx playwright install chromium`);\n this.name = 'BrowserUnavailableError';\n }\n}\n\n/** Thrown by ScreenLock when a bot's screen already has a computer-use task in flight. */\nexport class ScreenBusyError extends Error {\n constructor(public readonly botId: string) {\n super(`That bot's screen is already busy with another computer-use task. Wait for it to finish before starting another.`);\n this.name = 'ScreenBusyError';\n }\n}\n\n/** Thrown by normalizeUrl for disallowed / malformed URLs. */\nexport class InvalidUrlError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidUrlError';\n }\n}\n\n/** Thrown when an action targets a bot screen the human currently has taken over. */\nexport class ScreenNotTakenOverError extends Error {\n constructor(message = 'This screen is not taken over.') {\n super(message);\n this.name = 'ScreenNotTakenOverError';\n }\n}\n\nexport class ScreenTakenOverError extends Error {\n constructor() {\n super('The human has taken control of this screen; wait until they return it.');\n this.name = 'ScreenTakenOverError';\n }\n}\n\n/* ------------------------------------------------------------------------------------------- *\n * Pure helpers (no browser required) \u2014 exported for unit testing.\n * ------------------------------------------------------------------------------------------- */\n\n/**\n * Adds `https://` to bare domains/paths, rejects `javascript:` and `file:` URLs outright, and\n * otherwise passes the input through unchanged. Deliberately permissive about other schemes\n * (e.g. `data:`, `about:`) \u2014 computer-use tasks legitimately need to load those in tests and\n * sandboxes; the block list is specifically the two schemes that are dangerous or meaningless\n * for a screen-driving agent.\n */\nexport function normalizeUrl(input: string): string {\n const trimmed = (input ?? '').trim();\n if (!trimmed) throw new InvalidUrlError('URL is empty.');\n const schemeMatch = trimmed.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);\n if (!schemeMatch) return `https://${trimmed}`;\n const scheme = schemeMatch[1]!.toLowerCase();\n if (scheme === 'javascript') throw new InvalidUrlError('javascript: URLs are not allowed.');\n if (scheme === 'file') throw new InvalidUrlError('file: URLs are not allowed.');\n return trimmed;\n}\n\nexport interface BlockSignals {\n hasPasswordInput: boolean;\n iframeSrcs: string[];\n bodyText: string;\n}\n\nexport interface BlockDetection {\n kind: 'login' | 'captcha' | '2fa';\n message: string;\n}\n\n/**\n * Heuristic login-wall / CAPTCHA / 2FA detector over already-extracted page signals. Kept pure\n * (no Page dependency) so it can run without a browser in unit tests; `BrowserService.detectBlock`\n * gathers the signals from a live Page and delegates here.\n */\nexport function detectBlockFromSignals(signals: BlockSignals): BlockDetection | null {\n const iframeBlob = (signals.iframeSrcs ?? []).join(' ').toLowerCase();\n const body = signals.bodyText ?? '';\n\n if (/recaptcha/i.test(iframeBlob) || /hcaptcha/i.test(iframeBlob)) {\n return { kind: 'captcha', message: 'A CAPTCHA challenge (reCAPTCHA/hCaptcha) is present on this page.' };\n }\n if (/challenges\\.cloudflare\\.com|cf-challenge|turnstile/i.test(iframeBlob) || /checking your browser|cloudflare/i.test(body)) {\n return { kind: 'captcha', message: 'A Cloudflare browser challenge is present on this page.' };\n }\n if (/verify (your \\w+|it'?s you)|two-factor|one-time code/i.test(body)) {\n return { kind: '2fa', message: \"This page is asking for two-factor / one-time-code verification.\" };\n }\n if (signals.hasPasswordInput) {\n return { kind: 'login', message: 'This page has a password field \u2014 it looks like a login wall.' };\n }\n return null;\n}\n\n/**\n * Per-key mutex: `run` executes `fn` immediately if the key is free, otherwise rejects with\n * `ScreenBusyError` rather than queueing \u2014 mirrors \"one computer-use task per Bot screen at a\n * time\" (outline \u00A713): a second concurrent call is a caller bug, not something to serialize.\n */\nexport class ScreenLock {\n private busy = new Set<string>();\n\n isBusy(key: string): boolean {\n return this.busy.has(key);\n }\n\n async run<T>(key: string, fn: () => Promise<T>): Promise<T> {\n if (this.busy.has(key)) throw new ScreenBusyError(key);\n this.busy.add(key);\n try {\n return await fn();\n } finally {\n this.busy.delete(key);\n }\n }\n}\n\n/**\n * Frame-rate limiter for the screencast. `shouldEmit()` returns true at most once per\n * `1000/fps` ms according to the injected clock (defaults to `Date.now`), so tests can drive it\n * deterministically without real timers.\n */\nexport class FrameThrottle {\n private lastEmit = -Infinity;\n\n constructor(\n private readonly fps: number,\n private readonly clock: () => number = () => Date.now(),\n ) {}\n\n get intervalMs(): number {\n return 1000 / this.fps;\n }\n\n shouldEmit(): boolean {\n const now = this.clock();\n if (now - this.lastEmit >= this.intervalMs) {\n this.lastEmit = now;\n return true;\n }\n return false;\n }\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/* ------------------------------------------------------------------------------------------- *\n * BrowserService\n * ------------------------------------------------------------------------------------------- */\n\nexport interface BrowserServiceDeps {\n profileDir: string;\n bus: EventBus;\n headless?: boolean;\n}\n\nexport interface ComputerPageStatus {\n botId: string;\n url: string;\n title: string;\n}\n\nexport interface BrowserStatus {\n available: boolean;\n reason?: string;\n mode: 'host';\n headless: boolean;\n pages: ComputerPageStatus[];\n}\n\nexport interface TakeOverResult {\n ok: boolean;\n mode: 'screencast-only' | 'window';\n message: string;\n}\n\ntype FrameListener = (jpegBase64: string, w: number, h: number) => void;\n\n/** A selection can be a whole document; this socket is otherwise carrying video. */\nconst MAX_SELECTION_CHARS = 100_000;\n\n/** Queued input events per screen before pointer moves start being dropped. */\nconst MAX_QUEUED_INPUT = 32;\n\n/**\n * One Playwright persistent browser context shared by every Bot (\"the computer\"), with a\n * dedicated Page (\"screen\") per botId. Because all pages share one persistent context, cookies\n * and logins are shared across bots by design (outline \u00A75: \"one computer, shared by all your\n * Bots\") \u2014 this is intentional, not a bug.\n */\nexport class BrowserService {\n private context: BrowserContext | null = null;\n private launchPromise: Promise<BrowserContext> | null = null;\n private unavailableReason: string | undefined;\n\n private readonly headlessMode: boolean;\n private readonly pages = new Map<string, Page>();\n private readonly titleCache = new Map<string, string>();\n private readonly takenOver = new Set<string>();\n private readonly lock = new ScreenLock();\n\n private readonly screencastSessions = new Map<string, CDPSession>();\n private readonly screencastListeners = new Map<string, Set<FrameListener>>();\n private readonly screencastThrottles = new Map<string, FrameThrottle>();\n private readonly viewerCounts = new Map<string, number>();\n /**\n * Last known viewport, per bot. Seeded from the page and refreshed by screencast frames.\n * Input coordinates scale against this, NOT against frame arrival: Chromium only emits\n * screencast frames on visual change, so a static page delivers none at all and a\n * frame-dependent geometry would drop every click on exactly the pages a human is most\n * likely to be rescuing (a login form sitting still, waiting for input).\n */\n private readonly lastFrameSize = new Map<string, FrameSize>();\n /** Per-bot serialisation chain for human input \u2014 see forwardInput. */\n private readonly inputQueue = new Map<string, Promise<void>>();\n private readonly inputDepth = new Map<string, number>();\n\n constructor(private readonly deps: BrowserServiceDeps) {\n this.headlessMode = deps.headless ?? true;\n }\n\n get isHeadless(): boolean {\n return this.headlessMode;\n }\n\n /** Lazily launches the shared persistent context. Concurrent callers share one launch. */\n private async ensureContext(): Promise<BrowserContext> {\n if (this.context) return this.context;\n if (this.launchPromise) return this.launchPromise;\n\n this.launchPromise = (async () => {\n try {\n fs.mkdirSync(this.deps.profileDir, { recursive: true });\n const ctx = await chromium.launchPersistentContext(this.deps.profileDir, {\n headless: this.headlessMode,\n viewport: { width: 1280, height: 800 },\n });\n this.context = ctx;\n ctx.on('close', () => {\n this.context = null;\n this.launchPromise = null;\n this.pages.clear();\n });\n return ctx;\n } catch (err) {\n this.unavailableReason = errMsg(err);\n this.launchPromise = null;\n throw new BrowserUnavailableError(this.unavailableReason);\n }\n })();\n return this.launchPromise;\n }\n\n /** Returns this bot's dedicated page, creating it lazily. Pages persist across turns. */\n async getPage(botId: string): Promise<Page> {\n const existing = this.pages.get(botId);\n if (existing && !existing.isClosed()) return existing;\n const ctx = await this.ensureContext();\n const page = await ctx.newPage();\n this.pages.set(botId, page);\n page.on('close', () => {\n if (this.pages.get(botId) === page) this.pages.delete(botId);\n });\n return page;\n }\n\n async closePage(botId: string): Promise<void> {\n const page = this.pages.get(botId);\n if (page) {\n await page.close().catch(() => {});\n this.pages.delete(botId);\n }\n this.titleCache.delete(botId);\n this.takenOver.delete(botId);\n }\n\n /** Serializes computer-use tasks per bot screen; a concurrent second call is rejected. */\n async withScreen<T>(botId: string, fn: (page: Page) => Promise<T>): Promise<T> {\n return this.lock.run(botId, async () => {\n if (this.takenOver.has(botId)) throw new ScreenTakenOverError();\n const page = await this.getPage(botId);\n return fn(page);\n });\n }\n\n private async orient(botId: string, page: Page): Promise<{ url: string; title: string }> {\n const url = page.url();\n let title = this.titleCache.get(botId) ?? '';\n try {\n title = await page.title();\n this.titleCache.set(botId, title);\n } catch {\n // page may be mid-navigation or closed; fall back to the cached title.\n }\n return { url, title };\n }\n\n private orientLine(o: { url: string; title: string }): string {\n return `URL: ${o.url}\\nTitle: ${o.title}`;\n }\n\n /** Gathers page signals and runs them through the pure detector. Never throws. */\n async detectBlock(page: Page): Promise<BlockDetection | null> {\n try {\n const hasPasswordInput = (await page.$$('input[type=\"password\"]').catch(() => [])).length > 0;\n const iframeSrcs = await page\n .$$eval('iframe', (els) => els.map((e) => e.getAttribute('src') ?? ''))\n .catch(() => [] as string[]);\n const bodyText = await page\n .evaluate(() => document.body?.innerText ?? '')\n .catch(() => '');\n return detectBlockFromSignals({ hasPasswordInput, iframeSrcs, bodyText: bodyText.slice(0, 4000) });\n } catch {\n return null;\n }\n }\n\n /** If a block is detected, publishes a warn notification and returns the STOP text to prepend. */\n private async checkBlock(botId: string, page: Page): Promise<string | null> {\n const block = await this.detectBlock(page);\n if (!block) return null;\n this.deps.bus.publish({\n type: 'notify',\n botId,\n threadId: null,\n level: 'warn',\n title: 'Browser needs a human',\n body: block.message,\n });\n return (\n `${block.message} STOP: do not attempt to solve or bypass this yourself \u2014 ` +\n `ask the human to take over the computer and wait for them to return control.`\n );\n }\n\n /* ---------------------------------------------------------------------------------------- *\n * Actions \u2014 each returns a short result string including the resulting URL + title, and is\n * safe to call even if the page has navigated away, closed, or errored mid-action.\n * ---------------------------------------------------------------------------------------- */\n\n async navigate(botId: string, url: string): Promise<string> {\n const target = normalizeUrl(url);\n return this.withScreen(botId, async (page) => {\n try {\n await page.goto(target, { waitUntil: 'domcontentloaded', timeout: 30000 });\n } catch (err) {\n return `Navigation to ${target} failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Navigated.\\n${this.orientLine(o)}`;\n });\n }\n\n async click(botId: string, selector: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.click(selector, { timeout: 10000 });\n } catch (err) {\n return `Click on \"${selector}\" failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Clicked \"${selector}\".\\n${this.orientLine(o)}`;\n });\n }\n\n async type(botId: string, selector: string, text: string, opts?: { submit?: boolean }): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n const isPassword = await page\n .$eval(selector, (el) => (el as HTMLInputElement).type === 'password')\n .catch(() => false);\n if (isPassword) {\n return (\n `Refused: \"${selector}\" looks like a password field. Never type credentials into the browser \u2014 ` +\n `ask the human to take over the computer instead.\\n${this.orientLine(await this.orient(botId, page))}`\n );\n }\n await page.fill(selector, text, { timeout: 10000 });\n if (opts?.submit) await page.press(selector, 'Enter');\n } catch (err) {\n return `Type into \"${selector}\" failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Typed into \"${selector}\".\\n${this.orientLine(o)}`;\n });\n }\n\n async pressKey(botId: string, key: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.keyboard.press(key);\n } catch (err) {\n return `Key press \"${key}\" failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Pressed \"${key}\".\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n /** Returns visible text (page body, or a selector's text), capped at ~8000 characters. */\n async readText(botId: string, selector?: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n let text: string;\n try {\n text = selector\n ? ((await page.$eval(selector, (el) => (el as HTMLElement).innerText ?? '')) ?? '')\n : await page.evaluate(() => document.body?.innerText ?? '');\n } catch (err) {\n return `Read${selector ? ` of \"${selector}\"` : ''} failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const capped = text.length > 8000 ? `${text.slice(0, 8000)}\\n\u2026(truncated)` : text;\n return `${this.orientLine(await this.orient(botId, page))}\\n---\\n${capped}`;\n });\n }\n\n async readLinks(botId: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n let links: Array<{ text: string; href: string }>;\n try {\n links = await page.$$eval('a[href]', (els) =>\n els\n .slice(0, 200)\n .map((e) => ({ text: (e as HTMLElement).innerText.trim().slice(0, 120), href: (e as HTMLAnchorElement).href })),\n );\n } catch (err) {\n return `Reading links failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const body = links.map((l) => `- ${l.text || '(no text)'} -> ${l.href}`).join('\\n') || '(no links found)';\n return `${this.orientLine(await this.orient(botId, page))}\\n---\\n${body}`;\n });\n }\n\n /** Saves a PNG screenshot (to `filePath`, or a temp file if omitted) and returns its path. */\n async screenshot(botId: string, filePath?: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n const target = filePath ?? path.join(os.tmpdir(), `antbot-screenshot-${botId}-${Date.now()}.png`);\n try {\n fs.mkdirSync(path.dirname(target), { recursive: true });\n await page.screenshot({ path: target });\n } catch (err) {\n return `Screenshot failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Screenshot saved to ${target}\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n async currentUrl(botId: string): Promise<string> {\n return this.withScreen(botId, async (page) => this.orientLine(await this.orient(botId, page)));\n }\n\n async waitFor(botId: string, selector: string, timeoutMs: number): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.waitForSelector(selector, { timeout: timeoutMs });\n } catch (err) {\n return `Waiting for \"${selector}\" timed out: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Found \"${selector}\".\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n async scroll(botId: string, dy: number): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.mouse.wheel(0, dy);\n } catch (err) {\n return `Scroll failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Scrolled by ${dy}px.\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n async goBack(botId: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.goBack({ waitUntil: 'domcontentloaded', timeout: 15000 });\n } catch (err) {\n return `Go back failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Went back.\\n${this.orientLine(o)}`;\n });\n }\n\n /* ---------------------------------------------------------------------------------------- *\n * Screencast \u2014 CDP-driven JPEG frames, throttled to ~4fps, reference-counted per bot so it\n * auto-stops once the last viewer detaches.\n * ---------------------------------------------------------------------------------------- */\n\n async startScreencast(botId: string, onFrame: FrameListener): Promise<() => void> {\n const page = await this.getPage(botId);\n\n let listeners = this.screencastListeners.get(botId);\n if (!listeners) {\n listeners = new Set();\n this.screencastListeners.set(botId, listeners);\n }\n listeners.add(onFrame);\n this.viewerCounts.set(botId, (this.viewerCounts.get(botId) ?? 0) + 1);\n\n if (!this.screencastSessions.has(botId)) {\n const ctx = await this.ensureContext();\n const session = await ctx.newCDPSession(page);\n const throttle = new FrameThrottle(4);\n this.screencastSessions.set(botId, session);\n this.screencastThrottles.set(botId, throttle);\n\n session.on('Page.screencastFrame', (evt) => {\n void session.send('Page.screencastFrameAck', { sessionId: evt.sessionId }).catch(() => {});\n const w = evt.metadata?.deviceWidth ?? 0;\n const h = evt.metadata?.deviceHeight ?? 0;\n // Recorded on every frame, before the throttle: input must scale against the page's\n // current geometry, which changes on resize and navigation regardless of what the\n // viewer happens to be shown.\n if (w > 0 && h > 0) this.lastFrameSize.set(botId, { width: w, height: h });\n if (!throttle.shouldEmit()) return;\n for (const l of listeners!) {\n try {\n l(evt.data, w, h);\n } catch (err) {\n log.warn('screencast frame listener threw', err);\n }\n }\n });\n\n await session.send('Page.startScreencast', { format: 'jpeg', quality: 60, maxWidth: 1280, everyNthFrame: 2 });\n\n // Chromium emits screencast frames only when something repaints, so a page sitting still\n // \u2014 a login form, a 2FA prompt, exactly what a human takes over to deal with \u2014 delivers\n // nothing and the viewer stays blank forever. Seed it with one screenshot so there is\n // always something on screen; live frames take over from there.\n void this.seedFirstFrame(botId, page).catch((err) => log.warn('screencast seed frame failed', err));\n }\n\n let stopped = false;\n return () => {\n if (stopped) return;\n stopped = true;\n listeners!.delete(onFrame);\n const remaining = Math.max(0, (this.viewerCounts.get(botId) ?? 1) - 1);\n this.viewerCounts.set(botId, remaining);\n if (remaining > 0) return;\n\n const session = this.screencastSessions.get(botId);\n this.screencastSessions.delete(botId);\n this.screencastThrottles.delete(botId);\n this.screencastListeners.delete(botId);\n this.lastFrameSize.delete(botId);\n if (session) {\n void session\n .send('Page.stopScreencast')\n .catch(() => {})\n .then(() => session.detach().catch(() => {}));\n }\n };\n }\n\n /* ---------------------------------------------------------------------------------------- *\n * Takeover \u2014 pauses agent-driven actions on a bot's screen for the human.\n * ---------------------------------------------------------------------------------------- */\n\n isTakenOver(botId: string): boolean {\n return this.takenOver.has(botId);\n }\n\n /**\n * Marks the screen as human-controlled. When headless, there is no window to bring forward\n * (and launching a second headed context on the same profile dir isn't possible \u2014 Chromium\n * locks the profile), so the human acts through the screencast view instead; interactive input\n * forwarding through that view is out of scope here. When headed, brings the real window to\n * the front for the human to drive directly.\n */\n async takeOver(botId: string): Promise<TakeOverResult> {\n this.takenOver.add(botId);\n if (this.headlessMode) {\n return {\n ok: true,\n mode: 'screencast-only',\n message:\n 'This computer is running headless, so there is no window to bring to the front. ' +\n 'Act through the screencast view for the blocked step (password, 2FA, CAPTCHA), then return control. ' +\n 'Never paste secrets into chat.',\n };\n }\n try {\n const page = await this.getPage(botId);\n await page.bringToFront();\n } catch (err) {\n log.warn('failed to bring page to front for takeover', err);\n }\n return {\n ok: true,\n mode: 'window',\n message: 'The browser window for this bot has been brought to the front. Complete the blocked step, then return control.',\n };\n }\n\n returnControl(botId: string): void {\n this.takenOver.delete(botId);\n this.inputQueue.delete(botId);\n this.inputDepth.delete(botId);\n }\n\n /**\n * The remote page's current text selection, for copying out of a taken-over screen.\n *\n * Gated the same way as input: while a bot is working the screencast is a window, not a\n * console. Reading a selection is milder than clicking, but the rule \"this channel does\n * nothing unless the human holds control\" is worth more than the exception.\n *\n * Capped, because a selection can be an entire document and this crosses a socket that is\n * otherwise carrying video.\n */\n async readSelection(botId: string): Promise<string> {\n if (!this.takenOver.has(botId)) {\n throw new ScreenNotTakenOverError(\n 'A selection was requested for a screen that is not taken over. Take over the screen first.',\n );\n }\n const page = await this.getPage(botId);\n const text = await page.evaluate(() => {\n // Text selected inside a form field is not reliably part of the document selection, so\n // check the focused control first \u2014 copying out of a login field is a likely reason to be\n // here in the first place.\n const el = document.activeElement as HTMLInputElement | HTMLTextAreaElement | null;\n if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA')) {\n const { selectionStart: a, selectionEnd: b, value } = el;\n if (typeof a === 'number' && typeof b === 'number' && b > a) return value.slice(a, b);\n }\n return window.getSelection()?.toString() ?? '';\n });\n return text.slice(0, MAX_SELECTION_CHARS);\n }\n\n /** One immediate JPEG so a static page is not a blank pane. See startScreencast. */\n private async seedFirstFrame(botId: string, page: Page): Promise<void> {\n const listeners = this.screencastListeners.get(botId);\n if (!listeners?.size) return;\n const buf = await page.screenshot({ type: 'jpeg', quality: 60 });\n const vp = page.viewportSize() ?? { width: 0, height: 0 };\n if (vp.width > 0 && vp.height > 0) this.lastFrameSize.set(botId, vp);\n for (const l of listeners) {\n try {\n l(buf.toString('base64'), vp.width, vp.height);\n } catch (err) {\n log.warn('screencast seed listener threw', err);\n }\n }\n }\n\n /**\n * The page's CSS viewport, which is what input coordinates are in.\n *\n * `viewportSize()` is synchronous and correct whenever the context sets one; a persistent\n * context launched without an explicit viewport returns null, so fall back to asking the page.\n * The cached value is only a last resort for a page that has since closed.\n */\n private async viewportOf(botId: string, page: Page): Promise<FrameSize | undefined> {\n const vp = page.viewportSize();\n if (vp && vp.width > 0 && vp.height > 0) {\n this.lastFrameSize.set(botId, { width: vp.width, height: vp.height });\n return vp;\n }\n try {\n const inner = await page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight }));\n if (inner.width > 0 && inner.height > 0) {\n this.lastFrameSize.set(botId, inner);\n return inner;\n }\n } catch { /* page closed or navigating */ }\n return this.lastFrameSize.get(botId);\n }\n\n /**\n * Dispatches human input into a taken-over page.\n *\n * The takeover check is the whole security model here. It is applied twice on purpose: on entry,\n * so a caller is refused immediately, and again at dispatch, because events *are* queued for\n * ordering and control can be returned while some are still pending. Without the second check a\n * stale click would land after handback, into a page the bot has since navigated. Input does not\n * pass the Permission Gateway, because the gateway governs what *bots* do; this is the human\n * acting as themselves on their own computer.\n *\n * Dispatch goes through Playwright's `page.mouse` / `page.keyboard` rather than raw CDP so the\n * key-code mapping is the SDK's problem, matching how `click()` and `type()` above work.\n */\n async forwardInput(botId: string, ev: ScreencastInput): Promise<void> {\n if (!this.takenOver.has(botId)) {\n throw new ScreenNotTakenOverError(\n 'Input was sent for a screen that is not taken over. Take over the screen first.',\n );\n }\n\n // Input is strictly ordered per screen. The websocket handler dispatches each frame without\n // awaiting the last, so without this chain a mouse-down and mouse-up race each other and a\n // burst of typing arrives shuffled \u2014 which reads as \"some keys work\" rather than as a bug.\n const depth = (this.inputDepth.get(botId) ?? 0) + 1;\n this.inputDepth.set(botId, depth);\n\n // A pointer streams moves faster than they can be dispatched. Dropping stale moves under\n // backlog keeps the queue from growing without bound; the next move supersedes them anyway.\n // Never dropped: clicks, keys and text, where every event is meaningful.\n if (ev.kind === 'mouse' && ev.action === 'move' && depth > MAX_QUEUED_INPUT) {\n this.inputDepth.set(botId, depth - 1);\n return;\n }\n\n const run = async (): Promise<void> => {\n try {\n // Re-checked here, not just on entry: control can be returned while events are queued,\n // and a click that lands afterwards would hit a page the bot has already moved on.\n if (this.takenOver.has(botId)) await this.dispatchInput(botId, ev);\n } finally {\n this.inputDepth.set(botId, Math.max(0, (this.inputDepth.get(botId) ?? 1) - 1));\n }\n };\n\n const chained = (this.inputQueue.get(botId) ?? Promise.resolve()).then(run, run);\n // Stored swallowing rejections so one failed event cannot poison every later one.\n this.inputQueue.set(botId, chained.catch(() => {}));\n return chained;\n }\n\n private async dispatchInput(botId: string, ev: ScreencastInput): Promise<void> {\n const page = await this.getPage(botId);\n\n if (ev.kind === 'text') {\n await page.keyboard.insertText(ev.text);\n return;\n }\n\n if (ev.kind === 'key') {\n if (!isForwardableKey(ev.key)) return;\n if (ev.action === 'down') await page.keyboard.down(ev.key);\n else await page.keyboard.up(ev.key);\n return;\n }\n\n const pt = toPageCoords({ x: ev.x, y: ev.y }, await this.viewportOf(botId, page));\n // Geometry genuinely unknown \u2014 a guessed coordinate is a click the human did not aim.\n if (!pt) return;\n\n switch (ev.action) {\n case 'move':\n await page.mouse.move(pt.x, pt.y);\n break;\n case 'down':\n await page.mouse.move(pt.x, pt.y);\n await page.mouse.down({ button: ev.button, clickCount: Math.max(1, ev.clickCount) });\n break;\n case 'up':\n await page.mouse.up({ button: ev.button, clickCount: Math.max(1, ev.clickCount) });\n break;\n case 'wheel':\n await page.mouse.move(pt.x, pt.y);\n await page.mouse.wheel(clampWheel(ev.deltaX), clampWheel(ev.deltaY));\n break;\n }\n }\n\n /* ---------------------------------------------------------------------------------------- */\n\n /** Never launches the browser. Reports optimistically until a launch attempt has failed. */\n status(): BrowserStatus {\n if (this.unavailableReason) {\n return { available: false, reason: this.unavailableReason, mode: 'host', headless: this.headlessMode, pages: [] };\n }\n const pages: ComputerPageStatus[] = [];\n if (this.context) {\n for (const [botId, page] of this.pages) {\n if (page.isClosed()) continue;\n pages.push({ botId, url: page.url(), title: this.titleCache.get(botId) ?? '' });\n }\n }\n return { available: true, mode: 'host', headless: this.headlessMode, pages };\n }\n\n async shutdown(): Promise<void> {\n for (const session of this.screencastSessions.values()) {\n await session\n .send('Page.stopScreencast')\n .catch(() => {})\n .then(() => session.detach().catch(() => {}));\n }\n this.screencastSessions.clear();\n this.screencastListeners.clear();\n this.screencastThrottles.clear();\n this.viewerCounts.clear();\n\n for (const page of this.pages.values()) {\n await page.close().catch(() => {});\n }\n this.pages.clear();\n this.titleCache.clear();\n this.takenOver.clear();\n\n if (this.context) {\n await this.context.close().catch(() => {});\n this.context = null;\n }\n this.launchPromise = null;\n }\n}\n", "// Turning normalised screencast input into page coordinates.\n//\n// The client sends fractions of the frame, not pixels, because neither side knows the other's\n// geometry: the screencast is captured at up to 1280px wide (Chromium picks the scale), and the\n// browser then fits that image into whatever the pane happens to be. Pixels sent from the client\n// would be in a third coordinate space belonging to neither.\n//\n// Pure, so every rounding and clamping case below is testable without a browser.\n\n/** Viewport size reported by the most recent screencast frame, in CSS pixels. */\nexport interface FrameSize {\n width: number;\n height: number;\n}\n\n/**\n * Converts a normalised point to page CSS pixels, or null when the conversion cannot be trusted.\n *\n * Null rather than a clamped guess when the frame size is unknown or degenerate: dispatching a\n * click at (0, 0) because no frame has arrived yet would hit whatever is in the top-left corner,\n * which is exactly the kind of silent wrong action this codebase avoids.\n */\nexport function toPageCoords(\n norm: { x: number; y: number },\n frame: FrameSize | undefined,\n): { x: number; y: number } | null {\n if (!frame) return null;\n if (!Number.isFinite(frame.width) || !Number.isFinite(frame.height)) return null;\n if (frame.width <= 0 || frame.height <= 0) return null;\n if (!Number.isFinite(norm.x) || !Number.isFinite(norm.y)) return null;\n\n const clamp01 = (n: number): number => (n < 0 ? 0 : n > 1 ? 1 : n);\n // Clamped to the last addressable pixel: x = 1.0 would otherwise land one pixel outside the\n // viewport, which Chromium ignores rather than treating as an edge click.\n return {\n x: Math.min(Math.round(clamp01(norm.x) * frame.width), frame.width - 1),\n y: Math.min(Math.round(clamp01(norm.y) * frame.height), frame.height - 1),\n };\n}\n\n/**\n * Keys that must not be forwarded to the page, whatever the client sends.\n *\n * These either close or navigate away from the page the human was asked to unblock \u2014 losing the\n * session they took over to rescue \u2014 or they open browser-level UI the screencast cannot show,\n * leaving the view frozen on a page that is no longer in front. The human still has every normal\n * key, including Tab, Enter and Escape.\n */\nconst BLOCKED_KEYS = new Set(['F5', 'F11', 'F12', 'BrowserRefresh', 'BrowserBack', 'BrowserForward']);\n\n/** Whether a key event is safe to dispatch into a taken-over page. */\nexport function isForwardableKey(key: string): boolean {\n return key.length > 0 && !BLOCKED_KEYS.has(key);\n}\n\n/**\n * Wheel deltas, bounded. An unbounded delta from a malformed client would scroll a page by\n * millions of pixels in one event; clamping keeps a bad frame from being disorienting.\n */\nexport function clampWheel(delta: number): number {\n if (!Number.isFinite(delta)) return 0;\n const MAX = 1000;\n return Math.max(-MAX, Math.min(MAX, Math.round(delta)));\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;;;ACmBlB,SAAS,aACd,MACA,OACiC;AACjC,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,CAAC,OAAO,SAAS,MAAM,KAAK,KAAK,CAAC,OAAO,SAAS,MAAM,MAAM,EAAG,QAAO;AAC5E,MAAI,MAAM,S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AAM;AAErB,QAAI,KAAK,SAAS;AAChB,YAAM,KAAK,QAAQ,MAAM,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AACzC,WAAK,UAAU;AAAA,IACjB;AACA,SAAK,gBAAgB;AAAA,EACvB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -2286,7 +2286,7 @@ async function wireSkills(app) {
|
|
|
2286
2286
|
}
|
|
2287
2287
|
async function wireBrowser(app) {
|
|
2288
2288
|
try {
|
|
2289
|
-
const mod = await optionalImport("browser", () => import("./browser-
|
|
2289
|
+
const mod = await optionalImport("browser", () => import("./browser-NOWM4S6C.js"));
|
|
2290
2290
|
const Ctor = mod?.BrowserService ?? mod?.default;
|
|
2291
2291
|
if (!Ctor) return void log8.warn("browser subsystem unavailable: no BrowserService export");
|
|
2292
2292
|
const svc = new Ctor({ profileDir: app.cfg.paths.browserProfile, bus: app.bus, headless: true });
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../daemon/src/computer/browser.ts", "../../daemon/src/computer/input.ts"],
|
|
4
|
-
"sourcesContent": ["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { chromium } from 'playwright';\nimport type { BrowserContext, CDPSession, Page } from 'playwright';\nimport type { EventBus } from '../util/bus.js';\nimport { toPageCoords, isForwardableKey, clampWheel, type FrameSize } from './input.js';\nimport type { ScreencastInput } from '@antbot/contract';\nimport { logger } from '../util/log.js';\n\nconst log = logger('browser');\n\n/* ------------------------------------------------------------------------------------------- *\n * Errors\n * ------------------------------------------------------------------------------------------- */\n\n/** Thrown when the browser cannot be launched (e.g. Chromium isn't installed). */\nexport class BrowserUnavailableError extends Error {\n constructor(public readonly reason: string) {\n super(`Browser is unavailable: ${reason}. Try: npx playwright install chromium`);\n this.name = 'BrowserUnavailableError';\n }\n}\n\n/** Thrown by ScreenLock when a bot's screen already has a computer-use task in flight. */\nexport class ScreenBusyError extends Error {\n constructor(public readonly botId: string) {\n super(`That bot's screen is already busy with another computer-use task. Wait for it to finish before starting another.`);\n this.name = 'ScreenBusyError';\n }\n}\n\n/** Thrown by normalizeUrl for disallowed / malformed URLs. */\nexport class InvalidUrlError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidUrlError';\n }\n}\n\n/** Thrown when an action targets a bot screen the human currently has taken over. */\nexport class ScreenNotTakenOverError extends Error {\n constructor(message = 'This screen is not taken over.') {\n super(message);\n this.name = 'ScreenNotTakenOverError';\n }\n}\n\nexport class ScreenTakenOverError extends Error {\n constructor() {\n super('The human has taken control of this screen; wait until they return it.');\n this.name = 'ScreenTakenOverError';\n }\n}\n\n/* ------------------------------------------------------------------------------------------- *\n * Pure helpers (no browser required) \u2014 exported for unit testing.\n * ------------------------------------------------------------------------------------------- */\n\n/**\n * Adds `https://` to bare domains/paths, rejects `javascript:` and `file:` URLs outright, and\n * otherwise passes the input through unchanged. Deliberately permissive about other schemes\n * (e.g. `data:`, `about:`) \u2014 computer-use tasks legitimately need to load those in tests and\n * sandboxes; the block list is specifically the two schemes that are dangerous or meaningless\n * for a screen-driving agent.\n */\nexport function normalizeUrl(input: string): string {\n const trimmed = (input ?? '').trim();\n if (!trimmed) throw new InvalidUrlError('URL is empty.');\n const schemeMatch = trimmed.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);\n if (!schemeMatch) return `https://${trimmed}`;\n const scheme = schemeMatch[1]!.toLowerCase();\n if (scheme === 'javascript') throw new InvalidUrlError('javascript: URLs are not allowed.');\n if (scheme === 'file') throw new InvalidUrlError('file: URLs are not allowed.');\n return trimmed;\n}\n\nexport interface BlockSignals {\n hasPasswordInput: boolean;\n iframeSrcs: string[];\n bodyText: string;\n}\n\nexport interface BlockDetection {\n kind: 'login' | 'captcha' | '2fa';\n message: string;\n}\n\n/**\n * Heuristic login-wall / CAPTCHA / 2FA detector over already-extracted page signals. Kept pure\n * (no Page dependency) so it can run without a browser in unit tests; `BrowserService.detectBlock`\n * gathers the signals from a live Page and delegates here.\n */\nexport function detectBlockFromSignals(signals: BlockSignals): BlockDetection | null {\n const iframeBlob = (signals.iframeSrcs ?? []).join(' ').toLowerCase();\n const body = signals.bodyText ?? '';\n\n if (/recaptcha/i.test(iframeBlob) || /hcaptcha/i.test(iframeBlob)) {\n return { kind: 'captcha', message: 'A CAPTCHA challenge (reCAPTCHA/hCaptcha) is present on this page.' };\n }\n if (/challenges\\.cloudflare\\.com|cf-challenge|turnstile/i.test(iframeBlob) || /checking your browser|cloudflare/i.test(body)) {\n return { kind: 'captcha', message: 'A Cloudflare browser challenge is present on this page.' };\n }\n if (/verify (your \\w+|it'?s you)|two-factor|one-time code/i.test(body)) {\n return { kind: '2fa', message: \"This page is asking for two-factor / one-time-code verification.\" };\n }\n if (signals.hasPasswordInput) {\n return { kind: 'login', message: 'This page has a password field \u2014 it looks like a login wall.' };\n }\n return null;\n}\n\n/**\n * Per-key mutex: `run` executes `fn` immediately if the key is free, otherwise rejects with\n * `ScreenBusyError` rather than queueing \u2014 mirrors \"one computer-use task per Bot screen at a\n * time\" (outline \u00A713): a second concurrent call is a caller bug, not something to serialize.\n */\nexport class ScreenLock {\n private busy = new Set<string>();\n\n isBusy(key: string): boolean {\n return this.busy.has(key);\n }\n\n async run<T>(key: string, fn: () => Promise<T>): Promise<T> {\n if (this.busy.has(key)) throw new ScreenBusyError(key);\n this.busy.add(key);\n try {\n return await fn();\n } finally {\n this.busy.delete(key);\n }\n }\n}\n\n/**\n * Frame-rate limiter for the screencast. `shouldEmit()` returns true at most once per\n * `1000/fps` ms according to the injected clock (defaults to `Date.now`), so tests can drive it\n * deterministically without real timers.\n */\nexport class FrameThrottle {\n private lastEmit = -Infinity;\n\n constructor(\n private readonly fps: number,\n private readonly clock: () => number = () => Date.now(),\n ) {}\n\n get intervalMs(): number {\n return 1000 / this.fps;\n }\n\n shouldEmit(): boolean {\n const now = this.clock();\n if (now - this.lastEmit >= this.intervalMs) {\n this.lastEmit = now;\n return true;\n }\n return false;\n }\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/* ------------------------------------------------------------------------------------------- *\n * BrowserService\n * ------------------------------------------------------------------------------------------- */\n\nexport interface BrowserServiceDeps {\n profileDir: string;\n bus: EventBus;\n headless?: boolean;\n}\n\nexport interface ComputerPageStatus {\n botId: string;\n url: string;\n title: string;\n}\n\nexport interface BrowserStatus {\n available: boolean;\n reason?: string;\n mode: 'host';\n headless: boolean;\n pages: ComputerPageStatus[];\n}\n\nexport interface TakeOverResult {\n ok: boolean;\n mode: 'screencast-only' | 'window';\n message: string;\n}\n\ntype FrameListener = (jpegBase64: string, w: number, h: number) => void;\n\n/** A selection can be a whole document; this socket is otherwise carrying video. */\nconst MAX_SELECTION_CHARS = 100_000;\n\n/**\n * One Playwright persistent browser context shared by every Bot (\"the computer\"), with a\n * dedicated Page (\"screen\") per botId. Because all pages share one persistent context, cookies\n * and logins are shared across bots by design (outline \u00A75: \"one computer, shared by all your\n * Bots\") \u2014 this is intentional, not a bug.\n */\nexport class BrowserService {\n private context: BrowserContext | null = null;\n private launchPromise: Promise<BrowserContext> | null = null;\n private unavailableReason: string | undefined;\n\n private readonly headlessMode: boolean;\n private readonly pages = new Map<string, Page>();\n private readonly titleCache = new Map<string, string>();\n private readonly takenOver = new Set<string>();\n private readonly lock = new ScreenLock();\n\n private readonly screencastSessions = new Map<string, CDPSession>();\n private readonly screencastListeners = new Map<string, Set<FrameListener>>();\n private readonly screencastThrottles = new Map<string, FrameThrottle>();\n private readonly viewerCounts = new Map<string, number>();\n /**\n * Last known viewport, per bot. Seeded from the page and refreshed by screencast frames.\n * Input coordinates scale against this, NOT against frame arrival: Chromium only emits\n * screencast frames on visual change, so a static page delivers none at all and a\n * frame-dependent geometry would drop every click on exactly the pages a human is most\n * likely to be rescuing (a login form sitting still, waiting for input).\n */\n private readonly lastFrameSize = new Map<string, FrameSize>();\n\n constructor(private readonly deps: BrowserServiceDeps) {\n this.headlessMode = deps.headless ?? true;\n }\n\n get isHeadless(): boolean {\n return this.headlessMode;\n }\n\n /** Lazily launches the shared persistent context. Concurrent callers share one launch. */\n private async ensureContext(): Promise<BrowserContext> {\n if (this.context) return this.context;\n if (this.launchPromise) return this.launchPromise;\n\n this.launchPromise = (async () => {\n try {\n fs.mkdirSync(this.deps.profileDir, { recursive: true });\n const ctx = await chromium.launchPersistentContext(this.deps.profileDir, {\n headless: this.headlessMode,\n viewport: { width: 1280, height: 800 },\n });\n this.context = ctx;\n ctx.on('close', () => {\n this.context = null;\n this.launchPromise = null;\n this.pages.clear();\n });\n return ctx;\n } catch (err) {\n this.unavailableReason = errMsg(err);\n this.launchPromise = null;\n throw new BrowserUnavailableError(this.unavailableReason);\n }\n })();\n return this.launchPromise;\n }\n\n /** Returns this bot's dedicated page, creating it lazily. Pages persist across turns. */\n async getPage(botId: string): Promise<Page> {\n const existing = this.pages.get(botId);\n if (existing && !existing.isClosed()) return existing;\n const ctx = await this.ensureContext();\n const page = await ctx.newPage();\n this.pages.set(botId, page);\n page.on('close', () => {\n if (this.pages.get(botId) === page) this.pages.delete(botId);\n });\n return page;\n }\n\n async closePage(botId: string): Promise<void> {\n const page = this.pages.get(botId);\n if (page) {\n await page.close().catch(() => {});\n this.pages.delete(botId);\n }\n this.titleCache.delete(botId);\n this.takenOver.delete(botId);\n }\n\n /** Serializes computer-use tasks per bot screen; a concurrent second call is rejected. */\n async withScreen<T>(botId: string, fn: (page: Page) => Promise<T>): Promise<T> {\n return this.lock.run(botId, async () => {\n if (this.takenOver.has(botId)) throw new ScreenTakenOverError();\n const page = await this.getPage(botId);\n return fn(page);\n });\n }\n\n private async orient(botId: string, page: Page): Promise<{ url: string; title: string }> {\n const url = page.url();\n let title = this.titleCache.get(botId) ?? '';\n try {\n title = await page.title();\n this.titleCache.set(botId, title);\n } catch {\n // page may be mid-navigation or closed; fall back to the cached title.\n }\n return { url, title };\n }\n\n private orientLine(o: { url: string; title: string }): string {\n return `URL: ${o.url}\\nTitle: ${o.title}`;\n }\n\n /** Gathers page signals and runs them through the pure detector. Never throws. */\n async detectBlock(page: Page): Promise<BlockDetection | null> {\n try {\n const hasPasswordInput = (await page.$$('input[type=\"password\"]').catch(() => [])).length > 0;\n const iframeSrcs = await page\n .$$eval('iframe', (els) => els.map((e) => e.getAttribute('src') ?? ''))\n .catch(() => [] as string[]);\n const bodyText = await page\n .evaluate(() => document.body?.innerText ?? '')\n .catch(() => '');\n return detectBlockFromSignals({ hasPasswordInput, iframeSrcs, bodyText: bodyText.slice(0, 4000) });\n } catch {\n return null;\n }\n }\n\n /** If a block is detected, publishes a warn notification and returns the STOP text to prepend. */\n private async checkBlock(botId: string, page: Page): Promise<string | null> {\n const block = await this.detectBlock(page);\n if (!block) return null;\n this.deps.bus.publish({\n type: 'notify',\n botId,\n threadId: null,\n level: 'warn',\n title: 'Browser needs a human',\n body: block.message,\n });\n return (\n `${block.message} STOP: do not attempt to solve or bypass this yourself \u2014 ` +\n `ask the human to take over the computer and wait for them to return control.`\n );\n }\n\n /* ---------------------------------------------------------------------------------------- *\n * Actions \u2014 each returns a short result string including the resulting URL + title, and is\n * safe to call even if the page has navigated away, closed, or errored mid-action.\n * ---------------------------------------------------------------------------------------- */\n\n async navigate(botId: string, url: string): Promise<string> {\n const target = normalizeUrl(url);\n return this.withScreen(botId, async (page) => {\n try {\n await page.goto(target, { waitUntil: 'domcontentloaded', timeout: 30000 });\n } catch (err) {\n return `Navigation to ${target} failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Navigated.\\n${this.orientLine(o)}`;\n });\n }\n\n async click(botId: string, selector: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.click(selector, { timeout: 10000 });\n } catch (err) {\n return `Click on \"${selector}\" failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Clicked \"${selector}\".\\n${this.orientLine(o)}`;\n });\n }\n\n async type(botId: string, selector: string, text: string, opts?: { submit?: boolean }): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n const isPassword = await page\n .$eval(selector, (el) => (el as HTMLInputElement).type === 'password')\n .catch(() => false);\n if (isPassword) {\n return (\n `Refused: \"${selector}\" looks like a password field. Never type credentials into the browser \u2014 ` +\n `ask the human to take over the computer instead.\\n${this.orientLine(await this.orient(botId, page))}`\n );\n }\n await page.fill(selector, text, { timeout: 10000 });\n if (opts?.submit) await page.press(selector, 'Enter');\n } catch (err) {\n return `Type into \"${selector}\" failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Typed into \"${selector}\".\\n${this.orientLine(o)}`;\n });\n }\n\n async pressKey(botId: string, key: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.keyboard.press(key);\n } catch (err) {\n return `Key press \"${key}\" failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Pressed \"${key}\".\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n /** Returns visible text (page body, or a selector's text), capped at ~8000 characters. */\n async readText(botId: string, selector?: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n let text: string;\n try {\n text = selector\n ? ((await page.$eval(selector, (el) => (el as HTMLElement).innerText ?? '')) ?? '')\n : await page.evaluate(() => document.body?.innerText ?? '');\n } catch (err) {\n return `Read${selector ? ` of \"${selector}\"` : ''} failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const capped = text.length > 8000 ? `${text.slice(0, 8000)}\\n\u2026(truncated)` : text;\n return `${this.orientLine(await this.orient(botId, page))}\\n---\\n${capped}`;\n });\n }\n\n async readLinks(botId: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n let links: Array<{ text: string; href: string }>;\n try {\n links = await page.$$eval('a[href]', (els) =>\n els\n .slice(0, 200)\n .map((e) => ({ text: (e as HTMLElement).innerText.trim().slice(0, 120), href: (e as HTMLAnchorElement).href })),\n );\n } catch (err) {\n return `Reading links failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const body = links.map((l) => `- ${l.text || '(no text)'} -> ${l.href}`).join('\\n') || '(no links found)';\n return `${this.orientLine(await this.orient(botId, page))}\\n---\\n${body}`;\n });\n }\n\n /** Saves a PNG screenshot (to `filePath`, or a temp file if omitted) and returns its path. */\n async screenshot(botId: string, filePath?: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n const target = filePath ?? path.join(os.tmpdir(), `antbot-screenshot-${botId}-${Date.now()}.png`);\n try {\n fs.mkdirSync(path.dirname(target), { recursive: true });\n await page.screenshot({ path: target });\n } catch (err) {\n return `Screenshot failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Screenshot saved to ${target}\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n async currentUrl(botId: string): Promise<string> {\n return this.withScreen(botId, async (page) => this.orientLine(await this.orient(botId, page)));\n }\n\n async waitFor(botId: string, selector: string, timeoutMs: number): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.waitForSelector(selector, { timeout: timeoutMs });\n } catch (err) {\n return `Waiting for \"${selector}\" timed out: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Found \"${selector}\".\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n async scroll(botId: string, dy: number): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.mouse.wheel(0, dy);\n } catch (err) {\n return `Scroll failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n return `Scrolled by ${dy}px.\\n${this.orientLine(await this.orient(botId, page))}`;\n });\n }\n\n async goBack(botId: string): Promise<string> {\n return this.withScreen(botId, async (page) => {\n try {\n await page.goBack({ waitUntil: 'domcontentloaded', timeout: 15000 });\n } catch (err) {\n return `Go back failed: ${errMsg(err)}\\n${this.orientLine(await this.orient(botId, page))}`;\n }\n const block = await this.checkBlock(botId, page);\n const o = await this.orient(botId, page);\n return block ? `${block}\\n${this.orientLine(o)}` : `Went back.\\n${this.orientLine(o)}`;\n });\n }\n\n /* ---------------------------------------------------------------------------------------- *\n * Screencast \u2014 CDP-driven JPEG frames, throttled to ~4fps, reference-counted per bot so it\n * auto-stops once the last viewer detaches.\n * ---------------------------------------------------------------------------------------- */\n\n async startScreencast(botId: string, onFrame: FrameListener): Promise<() => void> {\n const page = await this.getPage(botId);\n\n let listeners = this.screencastListeners.get(botId);\n if (!listeners) {\n listeners = new Set();\n this.screencastListeners.set(botId, listeners);\n }\n listeners.add(onFrame);\n this.viewerCounts.set(botId, (this.viewerCounts.get(botId) ?? 0) + 1);\n\n if (!this.screencastSessions.has(botId)) {\n const ctx = await this.ensureContext();\n const session = await ctx.newCDPSession(page);\n const throttle = new FrameThrottle(4);\n this.screencastSessions.set(botId, session);\n this.screencastThrottles.set(botId, throttle);\n\n session.on('Page.screencastFrame', (evt) => {\n void session.send('Page.screencastFrameAck', { sessionId: evt.sessionId }).catch(() => {});\n const w = evt.metadata?.deviceWidth ?? 0;\n const h = evt.metadata?.deviceHeight ?? 0;\n // Recorded on every frame, before the throttle: input must scale against the page's\n // current geometry, which changes on resize and navigation regardless of what the\n // viewer happens to be shown.\n if (w > 0 && h > 0) this.lastFrameSize.set(botId, { width: w, height: h });\n if (!throttle.shouldEmit()) return;\n for (const l of listeners!) {\n try {\n l(evt.data, w, h);\n } catch (err) {\n log.warn('screencast frame listener threw', err);\n }\n }\n });\n\n await session.send('Page.startScreencast', { format: 'jpeg', quality: 60, maxWidth: 1280, everyNthFrame: 2 });\n\n // Chromium emits screencast frames only when something repaints, so a page sitting still\n // \u2014 a login form, a 2FA prompt, exactly what a human takes over to deal with \u2014 delivers\n // nothing and the viewer stays blank forever. Seed it with one screenshot so there is\n // always something on screen; live frames take over from there.\n void this.seedFirstFrame(botId, page).catch((err) => log.warn('screencast seed frame failed', err));\n }\n\n let stopped = false;\n return () => {\n if (stopped) return;\n stopped = true;\n listeners!.delete(onFrame);\n const remaining = Math.max(0, (this.viewerCounts.get(botId) ?? 1) - 1);\n this.viewerCounts.set(botId, remaining);\n if (remaining > 0) return;\n\n const session = this.screencastSessions.get(botId);\n this.screencastSessions.delete(botId);\n this.screencastThrottles.delete(botId);\n this.screencastListeners.delete(botId);\n this.lastFrameSize.delete(botId);\n if (session) {\n void session\n .send('Page.stopScreencast')\n .catch(() => {})\n .then(() => session.detach().catch(() => {}));\n }\n };\n }\n\n /* ---------------------------------------------------------------------------------------- *\n * Takeover \u2014 pauses agent-driven actions on a bot's screen for the human.\n * ---------------------------------------------------------------------------------------- */\n\n isTakenOver(botId: string): boolean {\n return this.takenOver.has(botId);\n }\n\n /**\n * Marks the screen as human-controlled. When headless, there is no window to bring forward\n * (and launching a second headed context on the same profile dir isn't possible \u2014 Chromium\n * locks the profile), so the human acts through the screencast view instead; interactive input\n * forwarding through that view is out of scope here. When headed, brings the real window to\n * the front for the human to drive directly.\n */\n async takeOver(botId: string): Promise<TakeOverResult> {\n this.takenOver.add(botId);\n if (this.headlessMode) {\n return {\n ok: true,\n mode: 'screencast-only',\n message:\n 'This computer is running headless, so there is no window to bring to the front. ' +\n 'Act through the screencast view for the blocked step (password, 2FA, CAPTCHA), then return control. ' +\n 'Never paste secrets into chat.',\n };\n }\n try {\n const page = await this.getPage(botId);\n await page.bringToFront();\n } catch (err) {\n log.warn('failed to bring page to front for takeover', err);\n }\n return {\n ok: true,\n mode: 'window',\n message: 'The browser window for this bot has been brought to the front. Complete the blocked step, then return control.',\n };\n }\n\n returnControl(botId: string): void {\n this.takenOver.delete(botId);\n }\n\n /**\n * The remote page's current text selection, for copying out of a taken-over screen.\n *\n * Gated the same way as input: while a bot is working the screencast is a window, not a\n * console. Reading a selection is milder than clicking, but the rule \"this channel does\n * nothing unless the human holds control\" is worth more than the exception.\n *\n * Capped, because a selection can be an entire document and this crosses a socket that is\n * otherwise carrying video.\n */\n async readSelection(botId: string): Promise<string> {\n if (!this.takenOver.has(botId)) {\n throw new ScreenNotTakenOverError(\n 'A selection was requested for a screen that is not taken over. Take over the screen first.',\n );\n }\n const page = await this.getPage(botId);\n const text = await page.evaluate(() => {\n // Text selected inside a form field is not reliably part of the document selection, so\n // check the focused control first \u2014 copying out of a login field is a likely reason to be\n // here in the first place.\n const el = document.activeElement as HTMLInputElement | HTMLTextAreaElement | null;\n if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA')) {\n const { selectionStart: a, selectionEnd: b, value } = el;\n if (typeof a === 'number' && typeof b === 'number' && b > a) return value.slice(a, b);\n }\n return window.getSelection()?.toString() ?? '';\n });\n return text.slice(0, MAX_SELECTION_CHARS);\n }\n\n /** One immediate JPEG so a static page is not a blank pane. See startScreencast. */\n private async seedFirstFrame(botId: string, page: Page): Promise<void> {\n const listeners = this.screencastListeners.get(botId);\n if (!listeners?.size) return;\n const buf = await page.screenshot({ type: 'jpeg', quality: 60 });\n const vp = page.viewportSize() ?? { width: 0, height: 0 };\n if (vp.width > 0 && vp.height > 0) this.lastFrameSize.set(botId, vp);\n for (const l of listeners) {\n try {\n l(buf.toString('base64'), vp.width, vp.height);\n } catch (err) {\n log.warn('screencast seed listener threw', err);\n }\n }\n }\n\n /**\n * The page's CSS viewport, which is what input coordinates are in.\n *\n * `viewportSize()` is synchronous and correct whenever the context sets one; a persistent\n * context launched without an explicit viewport returns null, so fall back to asking the page.\n * The cached value is only a last resort for a page that has since closed.\n */\n private async viewportOf(botId: string, page: Page): Promise<FrameSize | undefined> {\n const vp = page.viewportSize();\n if (vp && vp.width > 0 && vp.height > 0) {\n this.lastFrameSize.set(botId, { width: vp.width, height: vp.height });\n return vp;\n }\n try {\n const inner = await page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight }));\n if (inner.width > 0 && inner.height > 0) {\n this.lastFrameSize.set(botId, inner);\n return inner;\n }\n } catch { /* page closed or navigating */ }\n return this.lastFrameSize.get(botId);\n }\n\n /**\n * Dispatches human input into a taken-over page.\n *\n * The takeover check is the whole security model here, and it is deliberately a hard refusal\n * rather than a queue: input is only ever legitimate while the bot is blocked, and silently\n * buffering it would let a stale click land after control was returned \u2014 into a page the bot\n * has since navigated. Input does not pass the Permission Gateway, because the gateway governs\n * what *bots* do; this is the human acting as themselves on their own computer.\n *\n * Dispatch goes through Playwright's `page.mouse` / `page.keyboard` rather than raw CDP so the\n * key-code mapping is the SDK's problem, matching how `click()` and `type()` above work.\n */\n async forwardInput(botId: string, ev: ScreencastInput): Promise<void> {\n if (!this.takenOver.has(botId)) {\n throw new ScreenNotTakenOverError(\n 'Input was sent for a screen that is not taken over. Take over the screen first.',\n );\n }\n const page = await this.getPage(botId);\n\n if (ev.kind === 'text') {\n await page.keyboard.insertText(ev.text);\n return;\n }\n\n if (ev.kind === 'key') {\n if (!isForwardableKey(ev.key)) return;\n if (ev.action === 'down') await page.keyboard.down(ev.key);\n else await page.keyboard.up(ev.key);\n return;\n }\n\n const pt = toPageCoords({ x: ev.x, y: ev.y }, await this.viewportOf(botId, page));\n // Geometry genuinely unknown \u2014 a guessed coordinate is a click the human did not aim.\n if (!pt) return;\n\n switch (ev.action) {\n case 'move':\n await page.mouse.move(pt.x, pt.y);\n break;\n case 'down':\n await page.mouse.move(pt.x, pt.y);\n await page.mouse.down({ button: ev.button, clickCount: Math.max(1, ev.clickCount) });\n break;\n case 'up':\n await page.mouse.up({ button: ev.button, clickCount: Math.max(1, ev.clickCount) });\n break;\n case 'wheel':\n await page.mouse.move(pt.x, pt.y);\n await page.mouse.wheel(clampWheel(ev.deltaX), clampWheel(ev.deltaY));\n break;\n }\n }\n\n /* ---------------------------------------------------------------------------------------- */\n\n /** Never launches the browser. Reports optimistically until a launch attempt has failed. */\n status(): BrowserStatus {\n if (this.unavailableReason) {\n return { available: false, reason: this.unavailableReason, mode: 'host', headless: this.headlessMode, pages: [] };\n }\n const pages: ComputerPageStatus[] = [];\n if (this.context) {\n for (const [botId, page] of this.pages) {\n if (page.isClosed()) continue;\n pages.push({ botId, url: page.url(), title: this.titleCache.get(botId) ?? '' });\n }\n }\n return { available: true, mode: 'host', headless: this.headlessMode, pages };\n }\n\n async shutdown(): Promise<void> {\n for (const session of this.screencastSessions.values()) {\n await session\n .send('Page.stopScreencast')\n .catch(() => {})\n .then(() => session.detach().catch(() => {}));\n }\n this.screencastSessions.clear();\n this.screencastListeners.clear();\n this.screencastThrottles.clear();\n this.viewerCounts.clear();\n\n for (const page of this.pages.values()) {\n await page.close().catch(() => {});\n }\n this.pages.clear();\n this.titleCache.clear();\n this.takenOver.clear();\n\n if (this.context) {\n await this.context.close().catch(() => {});\n this.context = null;\n }\n this.launchPromise = null;\n }\n}\n", "// Turning normalised screencast input into page coordinates.\n//\n// The client sends fractions of the frame, not pixels, because neither side knows the other's\n// geometry: the screencast is captured at up to 1280px wide (Chromium picks the scale), and the\n// browser then fits that image into whatever the pane happens to be. Pixels sent from the client\n// would be in a third coordinate space belonging to neither.\n//\n// Pure, so every rounding and clamping case below is testable without a browser.\n\n/** Viewport size reported by the most recent screencast frame, in CSS pixels. */\nexport interface FrameSize {\n width: number;\n height: number;\n}\n\n/**\n * Converts a normalised point to page CSS pixels, or null when the conversion cannot be trusted.\n *\n * Null rather than a clamped guess when the frame size is unknown or degenerate: dispatching a\n * click at (0, 0) because no frame has arrived yet would hit whatever is in the top-left corner,\n * which is exactly the kind of silent wrong action this codebase avoids.\n */\nexport function toPageCoords(\n norm: { x: number; y: number },\n frame: FrameSize | undefined,\n): { x: number; y: number } | null {\n if (!frame) return null;\n if (!Number.isFinite(frame.width) || !Number.isFinite(frame.height)) return null;\n if (frame.width <= 0 || frame.height <= 0) return null;\n if (!Number.isFinite(norm.x) || !Number.isFinite(norm.y)) return null;\n\n const clamp01 = (n: number): number => (n < 0 ? 0 : n > 1 ? 1 : n);\n // Clamped to the last addressable pixel: x = 1.0 would otherwise land one pixel outside the\n // viewport, which Chromium ignores rather than treating as an edge click.\n return {\n x: Math.min(Math.round(clamp01(norm.x) * frame.width), frame.width - 1),\n y: Math.min(Math.round(clamp01(norm.y) * frame.height), frame.height - 1),\n };\n}\n\n/**\n * Keys that must not be forwarded to the page, whatever the client sends.\n *\n * These either close or navigate away from the page the human was asked to unblock \u2014 losing the\n * session they took over to rescue \u2014 or they open browser-level UI the screencast cannot show,\n * leaving the view frozen on a page that is no longer in front. The human still has every normal\n * key, including Tab, Enter and Escape.\n */\nconst BLOCKED_KEYS = new Set(['F5', 'F11', 'F12', 'BrowserRefresh', 'BrowserBack', 'BrowserForward']);\n\n/** Whether a key event is safe to dispatch into a taken-over page. */\nexport function isForwardableKey(key: string): boolean {\n return key.length > 0 && !BLOCKED_KEYS.has(key);\n}\n\n/**\n * Wheel deltas, bounded. An unbounded delta from a malformed client would scroll a page by\n * millions of pixels in one event; clamping keeps a bad frame from being disorienting.\n */\nexport function clampWheel(delta: number): number {\n if (!Number.isFinite(delta)) return 0;\n const MAX = 1000;\n return Math.max(-MAX, Math.min(MAX, Math.round(delta)));\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,gBAAgB;;;ACmBlB,SAAS,aACd,MACA,OACiC;AACjC,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI,CAAC,OAAO,SAAS,MAAM,KAAK,KAAK,CAAC,OAAO,SAAS,MAAM,MAAM,EAAG,QAAO;AAC5E,MAAI,MAAM,SAAS,KAAK,MAAM,UAAU,EAAG,QAAO;AAClD,MAAI,CAAC,OAAO,SAAS,KAAK,CAAC,KAAK,CAAC,OAAO,SAAS,KAAK,CAAC,EAAG,QAAO;AAE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