@wenathlan/extension 1.1.39 → 1.1.41

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/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../memory.ts", "../policy.ts", "../version.ts", "../types.ts", "../protocol.ts"],
4
- "sourcesContent": ["import type { a11ycapture, agentplan, agentsession, artifactinventoryentry, artifactrecord, auditevent, authrecord, bannerreport, capabilityreport, captchahandoff, capturecounter, clipboardconsentrecord, cleanuprule, cleanuprun, clipentry, clickablemap, closedtab, controltabstate, curatedlist, dataset, derivedselector, detectionrecord, diagnosticreport, dialogdecision, dialogpolicy, downloadrecord, endpointconfig, errorreport, exportedartifact, extractsession, focusevent, formprofile, keyholdstate, mimefilter, mutationevent, navcontrol, navintentrecord, navqueues, navrecord, netlogrecord, observationrecord, pagesignals, planprogress, provenancerecord, quarantineentry, ratelimitstate, readercapture, recenttab, resolutionsummary, retryoutcome, runsettings, safetyverdict, scanhookconfig, sessionsnapshot, sheetendpoint, snapshotdiff, stepoutcome, streamstate, submitticket, tabbadge, tabgrouprecord, tablayout, tabmeta, tabwatchevent, taskrules, templateprofile, trailentry, typeaheadpick, waitprofilerecord, watchregistration, wizardstate } from \"./types.js\";\n\n/** Provides a small storage seam that works in browser, tests and future adapters. */\nexport interface memoryadapter {\n get<T>(key: string): Promise<T | undefined>;\n set<T>(key: string, value: T): Promise<void>;\n}\n\n/**\n * Local memory for sessions, plans, audit evidence and interaction state.\n * Correlated rules for every stored record live in this one seam; each accessor is a one line storage delegation so future backends replace the adapter only.\n */\nexport class sessionmemory {\n constructor(private readonly adapter: memoryadapter) {}\n\n async getconfig(): Promise<endpointconfig | undefined> { return this.adapter.get<endpointconfig>(\"config\"); }\n async setconfig(value: endpointconfig): Promise<void> { return this.adapter.set(\"config\", value); }\n async getsession(): Promise<agentsession | undefined> { return this.adapter.get<agentsession>(\"session\"); }\n async setsession(value: agentsession): Promise<void> { return this.adapter.set(\"session\", value); }\n async getplan(): Promise<agentplan | undefined> { return this.adapter.get<agentplan>(\"plan\"); }\n async setplan(value: agentplan): Promise<void> { return this.adapter.set(\"plan\", value); }\n async getdiagnostic(): Promise<diagnosticreport | undefined> { return this.adapter.get<diagnosticreport>(\"diagnostic\"); }\n async setdiagnostic(value: diagnosticreport): Promise<void> { return this.adapter.set(\"diagnostic\", value); }\n async getprogress(): Promise<planprogress | undefined> { return this.adapter.get<planprogress>(\"progress\"); }\n async setprogress(value: planprogress): Promise<void> { return this.adapter.set(\"progress\", value); }\n async getcapabilities(): Promise<capabilityreport | undefined> { return this.adapter.get<capabilityreport>(\"capabilities\"); }\n async setcapabilities(value: capabilityreport): Promise<void> { return this.adapter.set(\"capabilities\", value); }\n async getsettings(): Promise<runsettings | undefined> { return this.adapter.get<runsettings>(\"settings\"); }\n async setsettings(value: runsettings): Promise<void> { return this.adapter.set(\"settings\", value); }\n async getaudit(): Promise<auditevent[]> { return (await this.adapter.get<auditevent[]>(\"audit\")) ?? []; }\n async getoutcomes(): Promise<stepoutcome[]> { return (await this.adapter.get<stepoutcome[]>(\"outcomes\")) ?? []; }\n\n /** Records one audit event; retention is a user setting and an absent setting keeps every event. */\n async addaudi(event: auditevent): Promise<void> {\n const records = await this.getaudit();\n const combined = [event, ...records];\n const retention = (await this.getsettings())?.auditretention;\n await this.adapter.set(\"audit\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Records one step outcome; retention is a user setting and an absent setting keeps every outcome. */\n async addoutcome(outcome: stepoutcome): Promise<void> {\n const records = await this.getoutcomes();\n const combined = [outcome, ...records];\n const retention = (await this.getsettings())?.outcomeretention;\n await this.adapter.set(\"outcomes\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Stores one clickable map under its observation version so every captured map stays available. */\n async setmap(map: clickablemap): Promise<void> { return this.adapter.set(`map${map.version}`, map); }\n\n /** Returns one stored clickable map by its observation version. */\n async getmap(version: number): Promise<clickablemap | undefined> { return this.adapter.get<clickablemap>(`map${version}`); }\n\n /** Advances and persists the observation version counter used to stamp clickable maps. */\n async nextobservationversion(): Promise<number> {\n const current = (await this.adapter.get<number>(\"observationversion\")) ?? 0;\n const next = current + 1;\n await this.adapter.set(\"observationversion\", next);\n return next;\n }\n\n /** Returns the latest observation version used to stamp a clickable map. */\n async getobservationversion(): Promise<number | undefined> { return this.adapter.get<number>(\"observationversion\"); }\n\n /** Returns the key hold registry, persisted so holds survive service worker restarts. */\n async getholds(): Promise<keyholdstate[]> { return (await this.adapter.get<keyholdstate[]>(\"holds\")) ?? []; }\n\n /** Replaces the key hold registry after one press or release transition. */\n async setholds(holds: keyholdstate[]): Promise<void> { return this.adapter.set(\"holds\", holds); }\n\n /** Returns every dialog decision recorded for the audit trail. */\n async getdialogs(): Promise<dialogdecision[]> { return (await this.adapter.get<dialogdecision[]>(\"dialogs\")) ?? []; }\n\n /** Records one dialog decision with the reviewed answer and the observed dialog text. */\n async adddialog(decision: dialogdecision): Promise<void> {\n const records = await this.getdialogs();\n await this.adapter.set(\"dialogs\", [decision, ...records]);\n }\n\n /** Returns every retry outcome recorded with attempts and movement deltas. */\n async getretries(): Promise<retryoutcome[]> { return (await this.adapter.get<retryoutcome[]>(\"retries\")) ?? []; }\n\n /** Records one retry outcome with the attempts made and the movement delta observed. */\n async addretry(outcome: retryoutcome): Promise<void> {\n const records = await this.getretries();\n await this.adapter.set(\"retries\", [outcome, ...records]);\n }\n\n /** Returns every resolution summary stored per target mode. */\n async getresolutions(): Promise<resolutionsummary[]> { return (await this.adapter.get<resolutionsummary[]>(\"resolutions\")) ?? []; }\n\n /** Records one resolution summary for later selector derivation. */\n async addresolution(summary: resolutionsummary): Promise<void> {\n const records = await this.getresolutions();\n await this.adapter.set(\"resolutions\", [summary, ...records]);\n }\n\n /** Returns the reviewed default dialog policy kept for the session auto handler. */\n async getdialogpolicy(): Promise<dialogpolicy | undefined> { return this.adapter.get<dialogpolicy>(\"dialogpolicy\"); }\n\n /** Stores the reviewed default dialog policy of the latest approved plan. */\n async setdialogpolicy(policy: dialogpolicy): Promise<void> { return this.adapter.set(\"dialogpolicy\", policy); }\n\n /** Stores one observation capture under its version so every observation version stays available. */\n async setobservation(record: observationrecord): Promise<void> { return this.adapter.set(`observation${record.version}`, record); }\n\n /** Returns one stored observation version. */\n async getobservation(version: number): Promise<observationrecord | undefined> { return this.adapter.get<observationrecord>(`observation${version}`); }\n\n /** Returns the observation retention window; an absent setting keeps every capture. */\n private async observationretention(): Promise<number | undefined> { return (await this.getsettings())?.observationretention; }\n\n /** Stores one accessibility tree capture; retention is a user setting and an absent setting keeps every tree. */\n async adda11ytree(capture: a11ycapture): Promise<void> {\n const records = await this.geta11ytrees();\n const combined = [capture, ...records];\n const retention = await this.observationretention();\n await this.adapter.set(\"a11ytrees\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns every stored accessibility tree capture, newest first. */\n async geta11ytrees(): Promise<a11ycapture[]> { return (await this.adapter.get<a11ycapture[]>(\"a11ytrees\")) ?? []; }\n\n /** Stores one reader article capture; retention is a user setting and an absent setting keeps every article. */\n async addreaderarticle(capture: readercapture): Promise<void> {\n const records = await this.getreaderarticles();\n const combined = [capture, ...records];\n const retention = await this.observationretention();\n await this.adapter.set(\"readerarticles\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns every stored reader article capture, newest first. */\n async getreaderarticles(): Promise<readercapture[]> { return (await this.adapter.get<readercapture[]>(\"readerarticles\")) ?? []; }\n\n /** Records one dom mutation observed inside a reviewed watch. */\n async addmutationevent(event: mutationevent): Promise<void> {\n const records = await this.getmutationevents();\n await this.adapter.set(\"mutationevents\", [event, ...records]);\n }\n\n /** Returns the mutation event stream of every reviewed watch. */\n async getmutationevents(): Promise<mutationevent[]> { return (await this.adapter.get<mutationevent[]>(\"mutationevents\")) ?? []; }\n\n /** Records one focus change observed inside a reviewed watch. */\n async addfocusevent(event: focusevent): Promise<void> {\n const records = await this.getfocusevents();\n await this.adapter.set(\"focusevents\", [event, ...records]);\n }\n\n /** Returns the focus event stream of every reviewed watch. */\n async getfocusevents(): Promise<focusevent[]> { return (await this.adapter.get<focusevent[]>(\"focusevents\")) ?? []; }\n\n /** Records one consent banner observed by a reviewed banner watch. */\n async addbanner(event: bannerreport): Promise<void> {\n const records = await this.getbanners();\n await this.adapter.set(\"banners\", [event, ...records]);\n }\n\n /** Returns every consent banner report observed so far. */\n async getbanners(): Promise<bannerreport[]> { return (await this.adapter.get<bannerreport[]>(\"banners\")) ?? []; }\n\n /** Records one snapshot diff between two observation versions. */\n async adddiff(diff: snapshotdiff): Promise<void> {\n const records = await this.getdiffs();\n await this.adapter.set(\"diffs\", [diff, ...records]);\n }\n\n /** Returns every stored snapshot diff, newest first. */\n async getdiffs(): Promise<snapshotdiff[]> { return (await this.adapter.get<snapshotdiff[]>(\"diffs\")) ?? []; }\n\n /** Records one derived selector with its stability score for reuse. */\n async addselector(selector: derivedselector): Promise<void> {\n const records = await this.getselectors();\n await this.adapter.set(\"selectors\", [selector, ...records]);\n }\n\n /** Returns every stored derived selector with its stability score, newest first. */\n async getselectors(): Promise<derivedselector[]> { return (await this.adapter.get<derivedselector[]>(\"selectors\")) ?? []; }\n\n /** Records one detected template class or section fingerprint for its origin. */\n async addtemplate(profile: templateprofile): Promise<void> {\n const records = await this.gettemplates();\n await this.adapter.set(\"templates\", [profile, ...records]);\n }\n\n /** Returns every stored template class and section fingerprint, newest first. */\n async gettemplates(): Promise<templateprofile[]> { return (await this.adapter.get<templateprofile[]>(\"templates\")) ?? []; }\n\n /** Records one watch registration so it survives service worker restarts. */\n async addwatch(watch: watchregistration): Promise<void> {\n const records = await this.getwatches();\n await this.adapter.set(\"watches\", [watch, ...records]);\n }\n\n /** Returns every watch registration, newest first, including closed windows. */\n async getwatches(): Promise<watchregistration[]> { return (await this.adapter.get<watchregistration[]>(\"watches\")) ?? []; }\n\n /** Closes one watch registration by watch id once its reviewed lifetime window ends. */\n async closewatch(watchid: string, closedat: number): Promise<void> {\n const records = await this.getwatches();\n await this.adapter.set(\"watches\", records.map(watch => watch.watchid === watchid && watch.closedat === undefined ? { ...watch, closedat } : watch));\n }\n\n /** Returns the live page signals of language, template, scroll lock and banner state. */\n async getsignals(): Promise<pagesignals | undefined> { return this.adapter.get<pagesignals>(\"signals\"); }\n\n /** Replaces the live page signals after an observation step refreshes them. */\n async setsignals(signals: pagesignals): Promise<void> { return this.adapter.set(\"signals\", signals); }\n\n /** Appends one navigation trail entry of a session with its url, title, step ref and timestamp. */\n async addtrailentry(sessionid: string, entry: trailentry): Promise<void> {\n const records = await this.gettrail(sessionid);\n await this.adapter.set(`trail${sessionid}`, [...records, entry]);\n }\n\n /** Returns the navigation trail of a session, oldest first. */\n async gettrail(sessionid: string): Promise<trailentry[]> { return (await this.adapter.get<trailentry[]>(`trail${sessionid}`)) ?? []; }\n\n /** Stores one wait profile for an origin with user configured values, replacing the previous profile of that origin. */\n async setwaitprofile(record: waitprofilerecord): Promise<void> {\n const records = (await this.getwaitprofiles()).filter(item => item.origin !== record.origin);\n await this.adapter.set(\"waitprofiles\", [...records, record]);\n }\n\n /** Returns every stored wait profile with its origin and user configured values, newest first. */\n async getwaitprofiles(): Promise<waitprofilerecord[]> { return (await this.adapter.get<waitprofilerecord[]>(\"waitprofiles\")) ?? []; }\n\n /** Records one navigation step with its redirect chain and final url. */\n async addnavrecord(record: navrecord): Promise<void> {\n const records = await this.getnavrecords();\n await this.adapter.set(\"navrecords\", [record, ...records]);\n }\n\n /** Returns every stored navigation record with redirect chains and final urls, newest first. */\n async getnavrecords(): Promise<navrecord[]> { return (await this.adapter.get<navrecord[]>(\"navrecords\")) ?? []; }\n\n /** Records one navigation intent detected from a plan for audit review. */\n async addnavintent(record: navintentrecord): Promise<void> {\n const records = await this.getnavintents();\n await this.adapter.set(\"navintents\", [record, ...records]);\n }\n\n /** Returns every stored navigation intent record, newest first. */\n async getnavintents(): Promise<navintentrecord[]> { return (await this.adapter.get<navintentrecord[]>(\"navintents\")) ?? []; }\n\n /** Replaces the rate limit window state of one domain. */\n async setratestate(state: ratelimitstate): Promise<void> {\n const records = (await this.getratestates()).filter(item => item.domain !== state.domain);\n await this.adapter.set(\"ratestates\", [...records, state]);\n }\n\n /** Returns every rate limit window state per domain. */\n async getratestates(): Promise<ratelimitstate[]> { return (await this.adapter.get<ratelimitstate[]>(\"ratestates\")) ?? []; }\n\n /** Records one curated link list with its review state before batch opening. */\n async addcurated(list: curatedlist): Promise<void> {\n const records = await this.getcurateds();\n await this.adapter.set(\"curated\", [list, ...records]);\n }\n\n /** Returns every stored curated link list, newest first. */\n async getcurateds(): Promise<curatedlist[]> { return (await this.adapter.get<curatedlist[]>(\"curated\")) ?? []; }\n\n /** Stores reviewed basic auth credentials for one origin, replacing the previous record of that origin. */\n async setauth(record: authrecord): Promise<void> {\n const records = (await this.getauths()).filter(item => item.origin !== record.origin);\n await this.adapter.set(\"auths\", [...records, record]);\n }\n\n /** Returns every stored reviewed basic auth record per origin. */\n async getauths(): Promise<authrecord[]> { return (await this.adapter.get<authrecord[]>(\"auths\")) ?? []; }\n\n /** Records one task artifact routed into the artifact store. */\n async addartifact(record: artifactrecord): Promise<void> {\n const records = await this.getartifacts();\n await this.adapter.set(\"artifacts\", [record, ...records]);\n }\n\n /** Returns every stored task artifact, newest first. */\n async getartifacts(): Promise<artifactrecord[]> { return (await this.adapter.get<artifactrecord[]>(\"artifacts\")) ?? []; }\n\n /** Returns the navigation control state of paused navigation. */\n async getnavcontrol(): Promise<navcontrol | undefined> { return this.adapter.get<navcontrol>(\"navcontrol\"); }\n\n /** Replaces the navigation control state after a pause or resume transition. */\n async setnavcontrol(control: navcontrol): Promise<void> { return this.adapter.set(\"navcontrol\", control); }\n\n /** Records one url safety verdict produced by a checksafe verification. */\n async addsafety(verdict: safetyverdict): Promise<void> {\n const records = await this.getsafeties();\n await this.adapter.set(\"safeties\", [verdict, ...records]);\n }\n\n /** Returns every stored url safety verdict, newest first. */\n async getsafeties(): Promise<safetyverdict[]> { return (await this.adapter.get<safetyverdict[]>(\"safeties\")) ?? []; }\n\n /** Records one recently closed tab so a reopentab step can restore it. */\n async addrecenttab(tab: recenttab): Promise<void> {\n const records = await this.getrecenttabs();\n await this.adapter.set(\"recenttabs\", [tab, ...records]);\n }\n\n /** Returns every recently closed tab, newest first. */\n async getrecenttabs(): Promise<recenttab[]> { return (await this.adapter.get<recenttab[]>(\"recenttabs\")) ?? []; }\n\n /** Returns the queued prefetch and batch open target counts shown in the popup badge. */\n async getnavqueues(): Promise<navqueues | undefined> { return this.adapter.get<navqueues>(\"navqueues\"); }\n\n /** Replaces the queued prefetch and batch open target counts. */\n async setnavqueues(queues: navqueues): Promise<void> { return this.adapter.set(\"navqueues\", queues); }\n\n /** Returns the last known navigation state of a tab, kept across service worker restarts. */\n async getnavstate(tabid: number): Promise<navrecord | undefined> { return this.adapter.get<navrecord>(`navstate${tabid}`); }\n\n /** Replaces the last known navigation state of a tab. */\n async setnavstate(tabid: number, state: navrecord): Promise<void> { return this.adapter.set(`navstate${tabid}`, state); }\n\n /** Stores one named tab layout with its window bounds and group states, replacing the previous layout of that name. */\n async setlayout(layout: tablayout): Promise<void> {\n const records = (await this.getlayouts()).filter(item => item.name !== layout.name);\n await this.adapter.set(\"layouts\", [layout, ...records]);\n }\n\n /** Returns one saved tab layout by name with its timestamp. */\n async getlayout(name: string): Promise<tablayout | undefined> { return (await this.getlayouts()).find(item => item.name === name); }\n\n /** Returns every saved tab layout with its window bounds and group states. */\n async getlayouts(): Promise<tablayout[]> { return (await this.adapter.get<tablayout[]>(\"layouts\")) ?? []; }\n\n /** Stores one tab group definition with its color choice and member tabs, replacing the previous definition of that name. */\n async settabgroup(group: tabgrouprecord): Promise<void> {\n const records = (await this.gettabgroups()).filter(item => item.name !== group.name);\n await this.adapter.set(\"tabgroups\", [...records, group]);\n }\n\n /** Returns every stored tab group definition with its color choice, newest first. */\n async gettabgroups(): Promise<tabgrouprecord[]> { return (await this.adapter.get<tabgrouprecord[]>(\"tabgroups\")) ?? []; }\n\n /** Records one tabmeta record with task provenance, replacing the previous metadata of that tab. */\n async settabmeta(meta: tabmeta): Promise<void> {\n const records = (await this.gettabmetas()).filter(item => item.tabid !== meta.tabid);\n await this.adapter.set(\"tabmetas\", [...records, meta]);\n }\n\n /** Returns every stored tabmeta record with task provenance. */\n async gettabmetas(): Promise<tabmeta[]> { return (await this.adapter.get<tabmeta[]>(\"tabmetas\")) ?? []; }\n\n /** Records one session snapshot of tabs and windows for later restore. */\n async addsnapshot(snapshot: sessionsnapshot): Promise<void> {\n const records = await this.getsnapshots();\n await this.adapter.set(\"snapshots\", [snapshot, ...records]);\n }\n\n /** Returns every stored session snapshot, newest first. */\n async getsnapshots(): Promise<sessionsnapshot[]> { return (await this.adapter.get<sessionsnapshot[]>(\"snapshots\")) ?? []; }\n\n /** Records one closed tab in the history kept for restoretab and reopenrun. */\n async addclosedtab(tab: closedtab): Promise<void> {\n const records = await this.getclosedtabs();\n await this.adapter.set(\"closedtabs\", [tab, ...records]);\n }\n\n /** Returns the closed tab history, newest first. */\n async getclosedtabs(): Promise<closedtab[]> { return (await this.adapter.get<closedtab[]>(\"closedtabs\")) ?? []; }\n\n /** Stores one badge state per task, replacing the previous badge of that task. */\n async setbadge(badge: tabbadge): Promise<void> {\n const records = (await this.getbadges()).filter(item => item.taskid !== badge.taskid);\n await this.adapter.set(\"badges\", [...records, badge]);\n }\n\n /** Returns every stored badge state per task. */\n async getbadges(): Promise<tabbadge[]> { return (await this.adapter.get<tabbadge[]>(\"badges\")) ?? []; }\n\n /** Records one tab event observed inside a reviewed watchtab registration. */\n async addtabwatchevent(event: tabwatchevent): Promise<void> {\n const records = await this.gettabwatchevents();\n await this.adapter.set(\"tabwatchevents\", [event, ...records]);\n }\n\n /** Returns the tab event stream of every reviewed watchtab registration, newest first. */\n async gettabwatchevents(): Promise<tabwatchevent[]> { return (await this.adapter.get<tabwatchevent[]>(\"tabwatchevents\")) ?? []; }\n\n /** Returns the ids of the scratch windows opened for split work. */\n async getscratchwindows(): Promise<number[]> { return (await this.adapter.get<number[]>(\"scratchwindows\")) ?? []; }\n\n /** Replaces the scratch window id list after one scratch window opens or closes. */\n async setscratchwindows(ids: number[]): Promise<void> { return this.adapter.set(\"scratchwindows\", ids); }\n\n /** Returns the pinned control tab state with the live task feed. */\n async getcontroltab(): Promise<controltabstate | undefined> { return this.adapter.get<controltabstate>(\"controltab\"); }\n\n /** Replaces the pinned control tab state. */\n async setcontroltab(state: controltabstate): Promise<void> { return this.adapter.set(\"controltab\", state); }\n\n /** Stores one saved form profile under its reviewed name, replacing the previous profile of that name. */\n async setprofile(profile: formprofile): Promise<void> {\n const records = (await this.getprofiles()).filter(item => item.name !== profile.name);\n await this.adapter.set(\"formprofiles\", [profile, ...records]);\n }\n\n /** Returns one saved form profile by its reviewed name. */\n async getprofile(name: string): Promise<formprofile | undefined> { return (await this.getprofiles()).find(item => item.name === name); }\n\n /** Returns every saved form profile with its origin grants, newest first. */\n async getprofiles(): Promise<formprofile[]> { return (await this.adapter.get<formprofile[]>(\"formprofiles\")) ?? []; }\n\n /** Removes one saved form profile by its reviewed name. */\n async removeprofile(name: string): Promise<void> {\n const records = (await this.getprofiles()).filter(item => item.name !== name);\n await this.adapter.set(\"formprofiles\", records);\n }\n\n /** Records one wizard state with its step history. */\n async addwizard(state: wizardstate): Promise<void> {\n const records = await this.getwizards();\n await this.adapter.set(\"wizards\", [state, ...records]);\n }\n\n /** Returns every stored wizard state with its step history, newest first. */\n async getwizards(): Promise<wizardstate[]> { return (await this.adapter.get<wizardstate[]>(\"wizards\")) ?? []; }\n\n /** Stores one submission ticket with its values hash, replacing the previous ticket of that id. */\n async setticket(ticket: submitticket): Promise<void> {\n const records = (await this.gettickets()).filter(item => item.id !== ticket.id);\n await this.adapter.set(\"submittickets\", [ticket, ...records]);\n }\n\n /** Returns every stored submission ticket with its values hash, newest first. */\n async gettickets(): Promise<submitticket[]> { return (await this.adapter.get<submitticket[]>(\"submittickets\")) ?? []; }\n\n /** Records one collected error report for correction loops. */\n async adderrorreport(report: errorreport): Promise<void> {\n const records = await this.geterrorreports();\n await this.adapter.set(\"errorreports\", [report, ...records]);\n }\n\n /** Returns every stored error report, newest first. */\n async geterrorreports(): Promise<errorreport[]> { return (await this.adapter.get<errorreport[]>(\"errorreports\")) ?? []; }\n\n /** Records one typeahead pick observed when a reviewed suggestion entry was chosen. */\n async addpick(pick: typeaheadpick): Promise<void> {\n const records = await this.getpicks();\n await this.adapter.set(\"typeaheadpicks\", [pick, ...records]);\n }\n\n /** Returns every recorded typeahead pick, newest first. */\n async getpicks(): Promise<typeaheadpick[]> { return (await this.adapter.get<typeaheadpick[]>(\"typeaheadpicks\")) ?? []; }\n\n /** Records one captcha handoff while the plan waits for the user. */\n async addcaptcha(handoff: captchahandoff): Promise<void> {\n const records = await this.getcaptchas();\n await this.adapter.set(\"captchas\", [handoff, ...records]);\n }\n\n /** Returns every captcha handoff record with its resolution state, newest first. */\n async getcaptchas(): Promise<captchahandoff[]> { return (await this.adapter.get<captchahandoff[]>(\"captchas\")) ?? []; }\n\n /** Resolves one captcha handoff by id once the user finished it. */\n async resolvecaptcha(id: string, resolvedat: number): Promise<void> {\n const records = await this.getcaptchas();\n await this.adapter.set(\"captchas\", records.map(handoff => handoff.id === id && !handoff.resolved ? { ...handoff, resolved: true, resolvedat } : handoff));\n }\n\n /** Records one login or template detection for its origin. */\n async adddetection(record: detectionrecord): Promise<void> {\n const records = await this.getdetections();\n await this.adapter.set(\"detections\", [record, ...records]);\n }\n\n /** Returns every stored login and template detection per origin, newest first. */\n async getdetections(): Promise<detectionrecord[]> { return (await this.adapter.get<detectionrecord[]>(\"detections\")) ?? []; }\n\n /** Stores the reviewed one time code behind the consent gate of an active session. */\n async setcodevalue(value: string): Promise<void> { return this.adapter.set(\"codevalue\", value); }\n\n /** Returns the reviewed one time code, if the user stored one behind the consent gate. */\n async getcodevalue(): Promise<string | undefined> { return this.adapter.get<string>(\"codevalue\"); }\n\n /** Stores one dataset with its column specs and rows, replacing the previous record of that id. */\n async setdataset(value: dataset): Promise<void> {\n await this.adapter.set(`dataset${value.id}`, value);\n const ids = ((await this.adapter.get<string[]>(\"datasets\")) ?? []).filter(id => id !== value.id);\n await this.adapter.set(\"datasets\", [value.id, ...ids]);\n }\n\n /** Returns one stored dataset by its id with its column specs and row count. */\n async getdataset(id: string): Promise<dataset | undefined> { return this.adapter.get<dataset>(`dataset${id}`); }\n\n /** Returns every stored dataset id, newest first. */\n async getdatasets(): Promise<dataset[]> {\n const ids = (await this.adapter.get<string[]>(\"datasets\")) ?? [];\n const records: dataset[] = [];\n for (const id of ids) {\n const record = await this.adapter.get<dataset>(`dataset${id}`);\n if (record) records.push(record);\n }\n return records;\n }\n\n /** Stores one imported csv dataset for fill loops beside the dataset store. */\n async addimport(value: dataset): Promise<void> {\n await this.setdataset(value);\n const ids = ((await this.adapter.get<string[]>(\"imports\")) ?? []).filter(id => id !== value.id);\n await this.adapter.set(\"imports\", [value.id, ...ids]);\n }\n\n /** Returns every imported csv dataset for fill loops, newest first. */\n async getimports(): Promise<dataset[]> {\n const ids = (await this.adapter.get<string[]>(\"imports\")) ?? [];\n const records: dataset[] = [];\n for (const id of ids) {\n const record = await this.adapter.get<dataset>(`dataset${id}`);\n if (record) records.push(record);\n }\n return records;\n }\n\n /** Stores one extraction session with its cursor and page history, replacing the previous session of that id. */\n async setextractsession(value: extractsession): Promise<void> {\n await this.adapter.set(`extract${value.id}`, value);\n const ids = ((await this.adapter.get<string[]>(\"extracts\")) ?? []).filter(id => id !== value.id);\n await this.adapter.set(\"extracts\", [value.id, ...ids]);\n }\n\n /** Returns every extraction session with its cursor and page history, newest first. */\n async getextractsessions(): Promise<extractsession[]> {\n const ids = (await this.adapter.get<string[]>(\"extracts\")) ?? [];\n const records: extractsession[] = [];\n for (const id of ids) {\n const record = await this.adapter.get<extractsession>(`extract${id}`);\n if (record) records.push(record);\n }\n return records;\n }\n\n /** Records one provenance record of an exported artifact. */\n async addprovenance(record: provenancerecord): Promise<void> {\n const records = await this.getprovenances();\n await this.adapter.set(\"provenances\", [record, ...records]);\n }\n\n /** Returns every provenance record per exported artifact, newest first. */\n async getprovenances(): Promise<provenancerecord[]> { return (await this.adapter.get<provenancerecord[]>(\"provenances\")) ?? []; }\n\n /** Stores the transform rules and dedupe keys of one task, replacing the previous record of that task. */\n async settaskrules(value: taskrules): Promise<void> {\n const records = ((await this.adapter.get<taskrules[]>(\"taskrules\")) ?? []).filter(item => item.taskid !== value.taskid);\n await this.adapter.set(\"taskrules\", [value, ...records]);\n }\n\n /** Returns the transform rules and dedupe keys per task, newest first. */\n async gettaskrules(): Promise<taskrules[]> { return (await this.adapter.get<taskrules[]>(\"taskrules\")) ?? []; }\n\n /** Stores one stream chunk state for resume, replacing the previous state of that dataset. */\n async setstream(state: streamstate): Promise<void> {\n const records = ((await this.adapter.get<streamstate[]>(\"streams\")) ?? []).filter(item => item.datasetid !== state.datasetid);\n await this.adapter.set(\"streams\", [state, ...records]);\n }\n\n /** Returns every stream chunk state persisted for resume, newest first. */\n async getstreams(): Promise<streamstate[]> { return (await this.adapter.get<streamstate[]>(\"streams\")) ?? []; }\n\n /** Stores one reviewed sheet endpoint config behind its origin grant, replacing the previous config of that origin. */\n async setsheetendpoint(config: sheetendpoint): Promise<void> {\n const records = ((await this.adapter.get<sheetendpoint[]>(\"sheetendpoints\")) ?? []).filter(item => item.origin !== config.origin);\n await this.adapter.set(\"sheetendpoints\", [config, ...records]);\n }\n\n /** Returns every reviewed sheet endpoint config, newest first. */\n async getsheetendpoints(): Promise<sheetendpoint[]> { return (await this.adapter.get<sheetendpoint[]>(\"sheetendpoints\")) ?? []; }\n\n /** Records one exported data artifact; artifact retention is a user setting and an absent setting keeps every artifact. */\n async addexport(artifact: exportedartifact): Promise<void> {\n const records = await this.getexports();\n const combined = [artifact, ...records.filter(item => item.id !== artifact.id)];\n const retention = (await this.getsettings())?.artifactretention;\n await this.adapter.set(\"exports\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns every exported data artifact with its content and checksum, newest first. */\n async getexports(): Promise<exportedartifact[]> { return (await this.adapter.get<exportedartifact[]>(\"exports\")) ?? []; }\n\n /** Removes one exported data artifact by id and reports whether it existed. */\n async removeexport(id: string): Promise<boolean> {\n const records = await this.getexports();\n const remaining = records.filter(item => item.id !== id);\n await this.adapter.set(\"exports\", remaining);\n return remaining.length !== records.length;\n }\n\n /** Removes one run store artifact by id and reports whether it existed. */\n async removeartifact(id: string): Promise<boolean> {\n const records = await this.getartifacts();\n const remaining = records.filter(item => item.id !== id);\n await this.adapter.set(\"artifacts\", remaining);\n return remaining.length !== records.length;\n }\n\n /** Stores one batch download file record with its state, path and checksum, replacing the previous record of that id. */\n async setdownload(record: downloadrecord): Promise<void> {\n const records = ((await this.adapter.get<downloadrecord[]>(\"downloads\")) ?? []).filter(item => item.id !== record.id);\n await this.adapter.set(\"downloads\", [record, ...records]);\n }\n\n /** Returns every batch download file record with its state, path and checksum, newest first. */\n async getdownloads(): Promise<downloadrecord[]> { return (await this.adapter.get<downloadrecord[]>(\"downloads\")) ?? []; }\n\n /** Records one captured network log record; netlog retention is a user setting and an absent value keeps every record. */\n async addnetlog(record: netlogrecord): Promise<void> {\n const records = await this.getnetlog();\n const combined = [record, ...records];\n const retention = (await this.getsettings())?.netlogretention;\n await this.adapter.set(\"netlog\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns the captured network log of the run with its step correlation, newest first. */\n async getnetlog(): Promise<netlogrecord[]> { return (await this.adapter.get<netlogrecord[]>(\"netlog\")) ?? []; }\n\n /** Stores one clipboard consent record with its prompt and origin, replacing the previous record of that id. */\n async setclipconsent(record: clipboardconsentrecord): Promise<void> {\n const records = ((await this.adapter.get<clipboardconsentrecord[]>(\"clipconsents\")) ?? []).filter(item => item.id !== record.id);\n await this.adapter.set(\"clipconsents\", [record, ...records]);\n }\n\n /** Returns every clipboard consent record with its prompt and origin, newest first. */\n async getclipconsents(): Promise<clipboardconsentrecord[]> { return (await this.adapter.get<clipboardconsentrecord[]>(\"clipconsents\")) ?? []; }\n\n /** Records one clipboard entry hash with its origin provenance; the payload text itself never persists. */\n async addclip(entry: clipentry): Promise<void> {\n const records = await this.getclips();\n await this.adapter.set(\"clips\", [entry, ...records]);\n }\n\n /** Returns every clipboard entry hash with its kind and origin provenance, newest first. */\n async getclips(): Promise<clipentry[]> { return (await this.adapter.get<clipentry[]>(\"clips\")) ?? []; }\n\n /** Stores one quarantine entry with its scan verdict, replacing the previous entry of that id. */\n async setquarantine(entry: quarantineentry): Promise<void> {\n const records = ((await this.adapter.get<quarantineentry[]>(\"quarantines\")) ?? []).filter(item => item.id !== entry.id);\n await this.adapter.set(\"quarantines\", [entry, ...records]);\n }\n\n /** Returns every quarantine entry with its scan verdict and release ref, newest first. */\n async getquarantines(): Promise<quarantineentry[]> { return (await this.adapter.get<quarantineentry[]>(\"quarantines\")) ?? []; }\n\n /** Stores the reviewed cleanup rule set of the run, replacing the previous set. */\n async setcleanuprules(rules: cleanuprule[]): Promise<void> { return this.adapter.set(\"cleanuprules\", rules); }\n\n /** Returns the reviewed cleanup rule set of the run. */\n async getcleanuprules(): Promise<cleanuprule[]> { return (await this.adapter.get<cleanuprule[]>(\"cleanuprules\")) ?? []; }\n\n /** Records one cleanup run in the run history. */\n async addcleanuprun(run: cleanuprun): Promise<void> {\n const records = await this.getcleanupruns();\n await this.adapter.set(\"cleanupruns\", [run, ...records]);\n }\n\n /** Returns every cleanup run history record with removed and kept counts, newest first. */\n async getcleanupruns(): Promise<cleanuprun[]> { return (await this.adapter.get<cleanuprun[]>(\"cleanupruns\")) ?? []; }\n\n /** Stores the capture naming counters of one task, replacing the previous counters of that task. */\n async setcapturecounter(counter: capturecounter): Promise<void> {\n const records = ((await this.adapter.get<capturecounter[]>(\"capturecounters\")) ?? []).filter(item => item.taskid !== counter.taskid);\n await this.adapter.set(\"capturecounters\", [counter, ...records]);\n }\n\n /** Returns every stored capture naming counter per task, newest first. */\n async getcapturecounters(): Promise<capturecounter[]> { return (await this.adapter.get<capturecounter[]>(\"capturecounters\")) ?? []; }\n\n /** Replaces the artifact inventory the cleanup sweeper plans against. */\n async setinventory(entries: artifactinventoryentry[]): Promise<void> { return this.adapter.set(\"inventory\", entries); }\n\n /** Returns the artifact inventory with sizes and ages for the cleanup sweeper. */\n async getinventory(): Promise<artifactinventoryentry[]> { return (await this.adapter.get<artifactinventoryentry[]>(\"inventory\")) ?? []; }\n\n /** Stores one user configured virus scanning hook, replacing the previous hook of that scanner name. */\n async setscanhook(config: scanhookconfig): Promise<void> {\n const records = ((await this.adapter.get<scanhookconfig[]>(\"scanhooks\")) ?? []).filter(item => item.scanner !== config.scanner);\n await this.adapter.set(\"scanhooks\", [config, ...records]);\n }\n\n /** Returns every configured virus scanning hook, newest first. */\n async getscanhooks(): Promise<scanhookconfig[]> { return (await this.adapter.get<scanhookconfig[]>(\"scanhooks\")) ?? []; }\n\n /** Stores the armed mime interception filters of the run, newest first. */\n async setmimefilters(filters: mimefilter[]): Promise<void> { return this.adapter.set(\"mimefilters\", filters); }\n\n /** Returns the armed mime interception filters of the run, newest first. */\n async getmimefilters(): Promise<mimefilter[]> { return (await this.adapter.get<mimefilter[]>(\"mimefilters\")) ?? []; }\n}\n\n/** Creates identifiers locally without a network dependency. */\nexport function randomid(): string {\n return crypto.randomUUID();\n}\n", "import type { actionkind, agentplan, agentsession, cleanuprule, downloadspec, endpointconfig, fieldkind, formprofile, mimefilter, observationmode, policyevaluation, quarantineentry, runsettings, safetyverdict, toolstep, transformrule } from \"./types.js\";\n\nconst sensitiveactions = new Set<actionkind>([\"click\", \"type\", \"navigate\", \"select\", \"presskey\", \"drag\", \"drop\", \"upload\", \"clear\", \"check\", \"uncheck\", \"toggle\", \"submit\", \"reload\", \"back\", \"forward\", \"writestorage\", \"setattribute\", \"removeattribute\", \"evaluate\", \"tabcreate\", \"tabactivate\", \"tabclose\", \"tabreload\", \"windowcreate\", \"windowclose\", \"windowresize\", \"downloadfile\", \"clickpoint\", \"shiftclick\", \"dismissdialog\", \"enterframe\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"keyhold\", \"keyrelease\", \"submitsearch\", \"selectmulti\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"openlink\", \"openprivate\", \"reloadcache\", \"stopnav\", \"followlink\", \"spanav\", \"rewritequery\", \"setfragment\", \"navlist\", \"navprofile\", \"handleauth\", \"printpdf\", \"prefetch\", \"preconnect\", \"deeplink\", \"reopentab\", \"pausenav\", \"navrate\", \"openclipboard\", \"batchopen\", \"duplicatetab\", \"closepattern\", \"pintab\", \"mutetab\", \"movetab\", \"movetabwindow\", \"grouptabs\", \"colorgroup\", \"collapsegroup\", \"discardtab\", \"reloadtabs\", \"zoomin\", \"zoomout\", \"switchtab\", \"maximizewindow\", \"minimizewindow\", \"restorewindow\", \"focuswindow\", \"scratchwindow\", \"incognitowindow\", \"restoretab\", \"restorelayout\", \"reopenrun\", \"badgetab\", \"fillform\", \"filllabel\", \"fillplaceholder\", \"submitform\", \"retryform\", \"runwizard\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"fillcard\", \"fillcode\", \"consentpassword\", \"exportcsv\", \"exportjson\", \"exportexcel\", \"copytable\", \"pushsheets\", \"streamdisk\", \"paginateextract\", \"resumeextract\", \"batchdownload\", \"pausedownload\", \"resumedownload\", \"interceptmime\", \"readclipboard\", \"writeclipboard\", \"copyscreen\", \"quarantinedownload\", \"scanvirus\", \"cleanupartifacts\"]);\nconst interactionactions = new Set<actionkind>([\"focus\", \"scroll\", \"hover\", \"clickdeep\", \"rightclick\", \"doubleclick\", \"scrollpage\", \"scrollby\", \"scrollend\", \"scrolltop\", \"fullscreen\", \"zoomset\", \"movepointer\", \"clicktext\", \"clickaria\", \"clickname\", \"expanddetails\", \"pierceshadow\", \"retryaction\"]);\nconst readactions = new Set<actionkind>([\"observe\", \"inspect\", \"extract\", \"wait\", \"waitfor\", \"waittext\", \"readattribute\", \"readstyle\", \"readgeometry\", \"readvalue\", \"readtext\", \"readhtml\", \"countelements\", \"readtable\", \"readlinks\", \"readimages\", \"readmeta\", \"readforms\", \"readstorage\", \"highlight\", \"tablist\", \"windowlist\", \"tabsnapshot\", \"mapclicks\", \"verifyvisible\", \"verifyenabled\", \"resolvexpath\", \"a11ytree\", \"readvisible\", \"readertree\", \"detectlists\", \"detecttables\", \"readjson\", \"watchmutate\", \"waitquiet\", \"watchbanner\", \"detectinfinitescroll\", \"detectvirtual\", \"detectlazy\", \"readscrollpos\", \"readlang\", \"readoutline\", \"countpages\", \"listshadow\", \"listframes\", \"classifypage\", \"fingerprintsection\", \"diffsnapshots\", \"readselection\", \"watchfocus\", \"detectsticky\", \"detectscrolllock\", \"readopengraph\", \"detectlanguage\", \"deriveselector\", \"waitload\", \"waiturl\", \"spawait\", \"detecthttp\", \"readredirects\", \"readfinalurl\", \"trailaudit\", \"navintent\", \"checksafe\", \"querytabs\", \"watchtab\", \"findclones\", \"searchtabs\", \"listaudio\", \"snapshotsession\", \"savelayout\", \"attachmeta\", \"detectfields\", \"generatevalues\", \"saveprofiles\", \"asksubmit\", \"readerrors\", \"skiphoneypot\", \"detectlogin\", \"detecttemplate\", \"handoffcaptcha\", \"scrapetable\", \"importcsv\", \"looprows\", \"transformvalues\", \"deduperows\", \"mergepages\", \"stamplerows\", \"previewgrid\", \"logprovenance\", \"verifydownload\", \"exportnetlog\", \"namecaptures\"]);\nconst allowedactions = new Set<actionkind>([...sensitiveactions, ...interactionactions, ...readactions]);\nconst watchactions = new Set<actionkind>([\"watchmutate\", \"watchbanner\", \"watchfocus\", \"watchtab\"]);\nconst targetactions = new Set<actionkind>([\"inspect\", \"focus\", \"click\", \"type\", \"scroll\", \"select\", \"hover\", \"clickdeep\", \"rightclick\", \"doubleclick\", \"drag\", \"drop\", \"upload\", \"clear\", \"check\", \"uncheck\", \"toggle\", \"submit\", \"readattribute\", \"readstyle\", \"readgeometry\", \"readvalue\", \"readtext\", \"readhtml\", \"countelements\", \"readtable\", \"highlight\", \"setattribute\", \"removeattribute\", \"waitfor\", \"shiftclick\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"submitsearch\", \"selectmulti\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"expanddetails\", \"verifyvisible\", \"verifyenabled\", \"pierceshadow\", \"deriveselector\", \"fingerprintsection\", \"submitform\", \"retryform\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"fillcode\", \"consentpassword\", \"scrapetable\", \"paginateextract\"]);\nconst valueactions = new Set<actionkind>([\"presskey\", \"drag\", \"drop\", \"upload\", \"readattribute\", \"removeattribute\", \"waittext\", \"evaluate\", \"zoomset\", \"tabactivate\", \"tabclose\", \"tabreload\", \"windowclose\", \"windowresize\", \"tabcreate\", \"windowcreate\", \"downloadfile\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"keyhold\", \"keyrelease\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"followlink\", \"setfragment\", \"handleauth\", \"navintent\", \"openclipboard\", \"checksafe\", \"reopentab\", \"spanav\", \"duplicatetab\", \"pintab\", \"mutetab\", \"movetab\", \"movetabwindow\", \"searchtabs\", \"badgetab\", \"attachmeta\", \"focuswindow\", \"maximizewindow\", \"minimizewindow\", \"restorewindow\", \"incognitowindow\", \"asksubmit\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"fillcode\", \"consentpassword\", \"pausedownload\", \"resumedownload\", \"verifydownload\", \"writeclipboard\", \"quarantinedownload\", \"scanvirus\"]);\nconst tabscommandactions = new Set<actionkind>([\"querytabs\", \"duplicatetab\", \"closepattern\", \"pintab\", \"mutetab\", \"movetab\", \"movetabwindow\", \"grouptabs\", \"colorgroup\", \"collapsegroup\", \"discardtab\", \"reloadtabs\", \"zoomin\", \"zoomout\", \"watchtab\", \"switchtab\", \"maximizewindow\", \"minimizewindow\", \"restorewindow\", \"focuswindow\", \"scratchwindow\", \"incognitowindow\", \"restoretab\", \"savelayout\", \"restorelayout\", \"findclones\", \"searchtabs\", \"badgetab\", \"attachmeta\", \"listaudio\", \"reopenrun\", \"snapshotsession\"]);\nconst formactions = new Set<actionkind>([\"fillform\", \"filllabel\", \"fillplaceholder\", \"detectfields\", \"generatevalues\", \"saveprofiles\", \"asksubmit\", \"submitform\", \"readerrors\", \"retryform\", \"runwizard\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"handoffcaptcha\", \"fillcard\", \"fillcode\", \"consentpassword\", \"skiphoneypot\", \"detectlogin\", \"detecttemplate\"]);\n/** Extraction, transform, export and provenance kinds of the forms and data part two family. */\nconst datasetactions = new Set<actionkind>([\"scrapetable\", \"exportcsv\", \"exportjson\", \"exportexcel\", \"copytable\", \"pushsheets\", \"importcsv\", \"looprows\", \"transformvalues\", \"deduperows\", \"paginateextract\", \"mergepages\", \"stamplerows\", \"previewgrid\", \"streamdisk\", \"resumeextract\", \"logprovenance\"]);\n/** Export kinds that move extracted data out of local memory to disk, the clipboard or a reviewed sheet endpoint. */\nconst exportactions = new Set<actionkind>([\"exportcsv\", \"exportjson\", \"exportexcel\", \"copytable\", \"pushsheets\", \"streamdisk\"]);\n/** Files, clipboard and downloads kinds of the batch queue, interception, clipboard, quarantine, naming and cleanup family. */\nconst filesactions = new Set<actionkind>([\"batchdownload\", \"pausedownload\", \"resumedownload\", \"verifydownload\", \"interceptmime\", \"exportnetlog\", \"readclipboard\", \"writeclipboard\", \"copyscreen\", \"quarantinedownload\", \"scanvirus\", \"namecaptures\", \"cleanupartifacts\"]);\n/** Field kinds the form grammar accepts inside records, profiles and value rules. */\nconst fieldkinds: fieldkind[] = [\"text\", \"email\", \"phone\", \"date\", \"number\", \"select\", \"check\", \"radio\", \"file\", \"password\", \"card\", \"code\"];\nconst layoutmutationactions = new Set<actionkind>([\"grouptabs\", \"colorgroup\", \"collapsegroup\", \"savelayout\", \"restorelayout\"]);\n/** Chromium tab group colors accepted as reviewed group color choices. */\nconst groupcolors = [\"grey\", \"blue\", \"red\", \"yellow\", \"green\", \"pink\", \"purple\", \"cyan\", \"orange\"];\n\n/** Normalizes a user supplied HTTPS endpoint without preserving a provider lock-in. */\nexport function normalizeendpoint(value: string): endpointconfig {\n const endpoint = new URL(value.trim());\n if (endpoint.protocol !== \"https:\") throw new Error(\"Devthink accepts HTTPS endpoints only.\");\n if (endpoint.username || endpoint.password) throw new Error(\"Endpoint credentials are not allowed in the URL.\");\n return { endpoint: endpoint.toString(), origin: endpoint.origin, configuredat: Date.now() };\n}\n\n/** Creates the exact optional host pattern requested from Chromium. */\nexport function hostpattern(origin: string): string {\n const parsed = new URL(origin);\n if (parsed.protocol !== \"https:\") throw new Error(\"Only HTTPS origins can be granted.\");\n return `${parsed.origin}/*`;\n}\n\n/** True when the action kind observes the page over a reviewed lifetime window. */\nexport function iswatchkind(kind: actionkind): boolean {\n return watchactions.has(kind);\n}\n\n/** Grades the observation mode of a kind: passive capture, watched lifetimes or diffing passes. */\nexport function observationmodeof(kind: actionkind): observationmode {\n if (watchactions.has(kind) || kind === \"waitquiet\") return \"watching\";\n if (kind === \"diffsnapshots\") return \"diffing\";\n return \"passive\";\n}\n\n/** Defines action risk from the fixed local allowlist. */\nexport function actionrisk(kind: actionkind): \"read\" | \"interaction\" | \"sensitive\" {\n if (!allowedactions.has(kind)) throw new Error(\"Unsupported browser action.\");\n if (sensitiveactions.has(kind)) return \"sensitive\";\n return interactionactions.has(kind) ? \"interaction\" : \"read\";\n}\n\n/** True when the action kind accepts a css selector target or a reviewed targetref. */\nexport function needstarget(kind: actionkind): boolean {\n return targetactions.has(kind);\n}\n\n/** Parses the reviewed JSON options of a step; malformed payloads are rejected early. */\nexport function parseoptions(step: toolstep): Record<string, unknown> {\n if (step.options === undefined) return {};\n let parsed: unknown;\n try { parsed = JSON.parse(step.options); } catch { throw new Error(\"Step options must be a JSON object.\"); }\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) throw new Error(\"Step options must be a JSON object.\");\n return parsed as Record<string, unknown>;\n}\n\n/** Maps an action kind to the optional browser permission it requires, if any. */\nexport function requiredcapability(kind: actionkind): string | undefined {\n if (kind === \"tablist\") return \"tabs\";\n if (kind === \"downloadfile\") return \"downloads\";\n if (kind === \"openclipboard\") return \"clipboardRead\";\n if (kind === \"copytable\") return \"clipboardWrite\";\n if (kind === \"batchdownload\" || kind === \"pausedownload\" || kind === \"resumedownload\" || kind === \"verifydownload\" || kind === \"interceptmime\" || kind === \"quarantinedownload\" || kind === \"scanvirus\") return \"downloads\";\n if (kind === \"readclipboard\") return \"clipboardRead\";\n if (kind === \"writeclipboard\" || kind === \"copyscreen\") return \"clipboardWrite\";\n if (kind === \"openlink\" || kind === \"openprivate\" || kind === \"navlist\" || kind === \"batchopen\" || kind === \"reopentab\" || kind === \"deeplink\") return \"tabs\";\n if (tabscommandactions.has(kind)) return \"tabs\";\n return undefined;\n}\n\n/** True when the kind commands tabs or windows beyond the active tab and needs the optional tabs capability. */\nexport function istabscommandkind(kind: actionkind): boolean {\n return tabscommandactions.has(kind);\n}\n\n/** True when the kind mutates tab groups or layouts and therefore stays inside the active session. */\nexport function islayoutkind(kind: actionkind): boolean {\n return layoutmutationactions.has(kind);\n}\n\n/** True when the kind belongs to the forms and data family. */\nexport function isformkind(kind: actionkind): boolean {\n return formactions.has(kind);\n}\n\n/** True when the kind belongs to the extraction, transform, export and provenance family. */\nexport function isdatasetkind(kind: actionkind): boolean {\n return datasetactions.has(kind);\n}\n\n/** True when the kind exports extracted data out of local memory to disk, the clipboard or a reviewed sheet endpoint. */\nexport function isexportkind(kind: actionkind): boolean {\n return exportactions.has(kind);\n}\n\n/** True when the kind belongs to the files, clipboard and downloads family. */\nexport function isfileskind(kind: actionkind): boolean {\n return filesactions.has(kind);\n}\n\n/** Refuses any export that would leave local memory while the session origin grants do not cover the active origin. */\nexport function exportgranted(session: agentsession | undefined, origin: string): policyevaluation {\n if (!origingranted(session, origin)) return { allowed: false, reason: `The export of extracted data from ${origin} needs the session origin grants before it leaves local memory.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed fieldmatch grammar of one form field entry. */\nexport function validatefieldmatch(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed field match is required in options.\" };\n const match = value as Record<string, unknown>;\n if (match.mode !== \"label\" && match.mode !== \"placeholder\" && match.mode !== \"arialabel\" && match.mode !== \"name\") return { allowed: false, reason: \"The reviewed field match mode must be label, placeholder, arialabel or name.\" };\n const key = match.mode === \"label\" ? \"label\" : match.mode === \"placeholder\" ? \"placeholder\" : match.mode === \"arialabel\" ? \"arialabel\" : \"name\";\n if (!isnonempty(match[key])) return { allowed: false, reason: `The reviewed ${match.mode} field match needs a non-empty ${key}.` };\n return { allowed: true };\n}\n\n/** Validates a reviewed structured form record; password entries are refused because passwords need the explicit consentpassword consent. */\nexport function validateformrecord(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed form record with entries is required in options.\" };\n const record = value as Record<string, unknown>;\n if (record.form !== undefined && !isnonempty(record.form)) return { allowed: false, reason: \"The reviewed form record form selector must be a non-empty string.\" };\n if (!Array.isArray(record.entries) || record.entries.length === 0) return { allowed: false, reason: \"The reviewed form record needs a non-empty list of entries.\" };\n for (const item of record.entries) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return { allowed: false, reason: \"Every reviewed form record entry must be an object.\" };\n const entry = item as Record<string, unknown>;\n const matchcheck = validatefieldmatch(entry.match);\n if (!matchcheck.allowed) return matchcheck;\n if (typeof entry.kind !== \"string\" || !fieldkinds.includes(entry.kind as fieldkind)) return { allowed: false, reason: \"Every reviewed form record entry needs a known field kind.\" };\n if (typeof entry.value !== \"string\") return { allowed: false, reason: \"Every reviewed form record entry needs a string value.\" };\n if (entry.kind === \"password\") return { allowed: false, reason: \"Password entries are refused inside form records; use consentpassword with a reviewed consent ref.\" };\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed valuegen grammar of a generatevalues step. */\nexport function validatevaluegen(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed valuegen rule with a field kind is required in options.\" };\n const rule = value as Record<string, unknown>;\n if (typeof rule.kind !== \"string\" || !fieldkinds.includes(rule.kind as fieldkind)) return { allowed: false, reason: \"The reviewed valuegen kind must be a known field kind.\" };\n if (rule.locale !== undefined && !isnonempty(rule.locale)) return { allowed: false, reason: \"The reviewed valuegen locale must be a non-empty string.\" };\n if (rule.seed !== undefined && (typeof rule.seed !== \"number\" || !Number.isFinite(rule.seed))) return { allowed: false, reason: \"The reviewed valuegen seed must be a finite number.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed list of label or placeholder value pairs for filllabel and fillplaceholder steps. */\nfunction validatefieldpairs(options: Record<string, unknown>, mode: \"label\" | \"placeholder\"): policyevaluation {\n const pairs = options.fields;\n if (!Array.isArray(pairs) || pairs.length === 0) return { allowed: false, reason: \"A reviewed non-empty list of field pairs is required in options.\" };\n for (const item of pairs) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return { allowed: false, reason: \"Every reviewed field pair must be an object.\" };\n const pair = item as Record<string, unknown>;\n if (!isnonempty(pair[mode])) return { allowed: false, reason: `Every reviewed field pair needs a non-empty ${mode}.` };\n if (typeof pair.value !== \"string\" || !pair.value.trim()) return { allowed: false, reason: \"Every reviewed field pair needs a non-empty value.\" };\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed card segment grammar of a fillcard step. */\nfunction validatecardsegments(value: unknown): policyevaluation {\n if (!Array.isArray(value) || value.length === 0) return { allowed: false, reason: \"A reviewed non-empty list of card segments is required in options.\" };\n for (const item of value) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return { allowed: false, reason: \"Every reviewed card segment must be an object.\" };\n const segment = item as Record<string, unknown>;\n const matchcheck = validatefieldmatch(segment.match);\n if (!matchcheck.allowed) return matchcheck;\n if (typeof segment.value !== \"string\" || !segment.value.trim()) return { allowed: false, reason: \"Every reviewed card segment needs a non-empty value.\" };\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed forms and data parameter grammar of the form family. */\nfunction validateformgrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"fillform\" || (kind === \"saveprofiles\" && options.formrecord !== undefined)) {\n const recordcheck = validateformrecord(options.formrecord);\n if (!recordcheck.allowed) return recordcheck;\n }\n if (kind === \"filllabel\" || kind === \"fillplaceholder\") {\n const paircheck = validatefieldpairs(options, kind === \"filllabel\" ? \"label\" : \"placeholder\");\n if (!paircheck.allowed) return paircheck;\n }\n if (kind === \"generatevalues\" && options.valuegen !== undefined) {\n const rulecheck = validatevaluegen(options.valuegen);\n if (!rulecheck.allowed) return rulecheck;\n }\n if (kind === \"saveprofiles\" && !isnonempty(options.name)) return { allowed: false, reason: \"A reviewed profile name is required in options.\" };\n if (kind === \"submitform\" && !isnonempty(options.consentref)) return { allowed: false, reason: \"A reviewed consent ref of an approved asksubmit ticket is required in options.\" };\n if (kind === \"retryform\") {\n const backoff = options.backoff;\n if (!backoff || typeof backoff !== \"object\" || Array.isArray(backoff)) return { allowed: false, reason: \"A reviewed backoff rule with wait and factor is required in options.\" };\n const rule = backoff as Record<string, unknown>;\n if (typeof rule.wait !== \"number\" || !Number.isFinite(rule.wait) || rule.wait <= 0) return { allowed: false, reason: \"The reviewed retry backoff wait must be a positive number of milliseconds with no code ceiling.\" };\n if (typeof rule.factor !== \"number\" || !Number.isFinite(rule.factor) || rule.factor < 1) return { allowed: false, reason: \"The reviewed retry backoff factor must be one or greater with no code ceiling.\" };\n if (options.attempts !== undefined && (typeof options.attempts !== \"number\" || !Number.isInteger(options.attempts) || options.attempts < 1)) return { allowed: false, reason: \"The reviewed retry attempts must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"runwizard\" && options.steps !== undefined && (typeof options.steps !== \"number\" || !Number.isInteger(options.steps) || options.steps < 1)) return { allowed: false, reason: \"The reviewed wizard step count must be a positive integer with no code ceiling.\" };\n if (kind === \"selectchain\") {\n if (!isnonempty(options.child)) return { allowed: false, reason: \"A reviewed child selector of the dependent control is required in options.\" };\n if (!nonnegativeoption(options, \"wait\")) return { allowed: false, reason: \"The reviewed dependent wait must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"picktypeahead\") {\n if (!isnonempty(options.pick)) return { allowed: false, reason: \"A reviewed suggestion entry to pick is required in options.\" };\n if (!nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The reviewed typeahead timeout must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"pickdate\" && !/^\\d{4}-\\d{2}-\\d{2}$/.test(step.value ?? \"\")) return { allowed: false, reason: \"The reviewed date must use the yyyy-mm-dd form.\" };\n if (kind === \"fillcard\") {\n const segmentcheck = validatecardsegments(options.segments);\n if (!segmentcheck.allowed) return segmentcheck;\n if (!nonnegativeoption(options, \"pause\")) return { allowed: false, reason: \"The reviewed card typing pause must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"fillcode\" && !isnonempty(options.source)) return { allowed: false, reason: \"A reviewed one time code source is required in options.\" };\n if (kind === \"consentpassword\" && !isnonempty(options.consentref)) return { allowed: false, reason: \"A reviewed consent ref is required in options before any password is filled.\" };\n return { allowed: true };\n}\n\n/** Validates one reviewed transform rule: a supported expression, source columns and a target column. */\nexport function validatetransformrule(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed transform rule with an expression, sources and a target is required in options.\" };\n const rule = value as Record<string, unknown>;\n const expression = rule.expression;\n if (typeof expression !== \"string\" || !/^(trim|upper|lower|number|prefix|suffix|replace)(?::.+)?$/.test(expression)) return { allowed: false, reason: \"The reviewed transform expression must be trim, upper, lower, number, prefix, suffix or replace with an optional argument.\" };\n if (expression.startsWith(\"replace\") && !expression.slice(\"replace\".length).includes(\"=>\")) return { allowed: false, reason: \"The reviewed replace expression needs the from=>to separator.\" };\n if (expression.startsWith(\"replace\") && expression.slice(\"replace:\".length).split(\"=>\")[0] === \"\") return { allowed: false, reason: \"The reviewed replace expression needs a non-empty from part.\" };\n if (!Array.isArray(rule.sources) || rule.sources.length === 0 || !rule.sources.every(source => isnonempty(source))) return { allowed: false, reason: \"Every reviewed transform rule needs a non-empty list of source columns.\" };\n if (!isnonempty(rule.target)) return { allowed: false, reason: \"Every reviewed transform rule needs a non-empty target column.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed dataset id list in options. */\nfunction validatedatasetids(options: Record<string, unknown>, key: string): policyevaluation {\n const ids = options[key];\n if (!Array.isArray(ids) || ids.length === 0 || !ids.every(id => isnonempty(id))) return { allowed: false, reason: `A reviewed non-empty list of dataset ids is required in options as ${key}.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed extraction, transform, export and provenance parameter grammar of the data family. */\nfunction validatedatagrammar(step: toolstep, options: Record<string, unknown>, origin: string): policyevaluation {\n const kind = step.kind;\n if (kind === \"scrapetable\") {\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed dataset name must be a non-empty string.\" };\n if (options.rowlimit !== undefined && (typeof options.rowlimit !== \"number\" || !Number.isInteger(options.rowlimit) || options.rowlimit < 1)) return { allowed: false, reason: \"The reviewed row limit must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"paginateextract\") {\n if (!isnonempty(options.next)) return { allowed: false, reason: \"A reviewed next control selector is required in options.\" };\n if (options.pages !== undefined && (typeof options.pages !== \"number\" || !Number.isInteger(options.pages) || options.pages < 1)) return { allowed: false, reason: \"The reviewed page count must be a positive integer with no code ceiling.\" };\n if (!nonnegativeoption(options, \"wait\")) return { allowed: false, reason: \"The reviewed row freshness wait must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"exportcsv\" || kind === \"exportjson\" || kind === \"exportexcel\" || kind === \"copytable\" || kind === \"streamdisk\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed artifact name must be a non-empty string.\" };\n }\n if (kind === \"exportcsv\" && options.delimiter !== undefined && (typeof options.delimiter !== \"string\" || options.delimiter.length !== 1)) return { allowed: false, reason: \"The reviewed csv delimiter must be a single character.\" };\n if (kind === \"streamdisk\" && (typeof options.chunk !== \"number\" || !Number.isInteger(options.chunk) || options.chunk < 1)) return { allowed: false, reason: \"The reviewed streaming chunk size must be a positive integer with no code ceiling.\" };\n if (kind === \"pushsheets\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (!isnonempty(options.sheet)) return { allowed: false, reason: \"A reviewed sheet endpoint url is required in options.\" };\n if (!ishttpsurl(options.sheet)) return { allowed: false, reason: \"The reviewed sheet endpoint url must use HTTPS.\" };\n if (options.reviewed !== true) return { allowed: false, reason: \"The sheet push needs the explicit reviewed flag before any data leaves local memory.\" };\n }\n if (kind === \"importcsv\") {\n if (typeof options.csv !== \"string\" || !options.csv.trim()) return { allowed: false, reason: \"Reviewed csv content is required in options.\" };\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed dataset name must be a non-empty string.\" };\n if (options.mapping !== undefined) {\n const mapping = options.mapping;\n if (!mapping || typeof mapping !== \"object\" || Array.isArray(mapping) || !Object.values(mapping).every(item => typeof item === \"string\")) return { allowed: false, reason: \"The reviewed csv column mapping must be an object of string values.\" };\n }\n }\n if (kind === \"looprows\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.variable !== undefined && !isnonempty(options.variable)) return { allowed: false, reason: \"The reviewed row variable name must be a non-empty string.\" };\n const inner = validateinnerstep(options, origin);\n if (!inner.allowed) return inner;\n }\n if (kind === \"transformvalues\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n const rules = options.rules;\n if (!Array.isArray(rules) || rules.length === 0) return { allowed: false, reason: \"A reviewed non-empty list of transform rules is required in options.\" };\n for (const item of rules) {\n const rulecheck = validatetransformrule(item);\n if (!rulecheck.allowed) return rulecheck;\n }\n }\n if (kind === \"deduperows\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n const keys = options.keys;\n if (!Array.isArray(keys) || keys.length === 0 || !keys.every(key => isnonempty(key))) return { allowed: false, reason: \"A reviewed non-empty list of dedupe column keys is required in options.\" };\n }\n if (kind === \"mergepages\") {\n const listcheck = validatedatasetids(options, \"datasets\");\n if (!listcheck.allowed) return listcheck;\n }\n if (kind === \"stamplerows\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.url !== undefined && !ishttpsurl(options.url)) return { allowed: false, reason: \"The reviewed source url must use HTTPS.\" };\n }\n if (kind === \"previewgrid\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.sample !== undefined && (typeof options.sample !== \"number\" || !Number.isInteger(options.sample) || options.sample < 1)) return { allowed: false, reason: \"The reviewed sample row count must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"resumeextract\" && !isnonempty(options.session)) return { allowed: false, reason: \"A reviewed extract session id is required in options.\" };\n if (kind === \"logprovenance\" && !isnonempty(options.artifact)) return { allowed: false, reason: \"A reviewed artifact id or name is required in options.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed batch download specification: a non-empty HTTPS url list, an optional filename rule and an optional completion criterion. */\nexport function validatedownloadspec(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed downloadspec with a url list is required in options.\" };\n const spec = value as Record<string, unknown>;\n if (!Array.isArray(spec.urls) || spec.urls.length === 0 || !spec.urls.every(url => ishttpsurl(url))) return { allowed: false, reason: \"The reviewed downloadspec needs a non-empty list of HTTPS urls.\" };\n if (spec.filename !== undefined && !isnonempty(spec.filename)) return { allowed: false, reason: \"The reviewed downloadspec filename rule must be a non-empty string.\" };\n if (spec.complete !== undefined && spec.complete !== \"size\" && spec.complete !== \"checksum\") return { allowed: false, reason: \"The reviewed downloadspec completion criterion must be size or checksum.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed mime interception filter: include and exclude patterns plus the deny default for unlisted mime types. */\nexport function validatemimefilter(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed mimefilter with include and exclude patterns is required in options.\" };\n const filter = value as Record<string, unknown>;\n if (!Array.isArray(filter.include) || filter.include.length === 0 || !filter.include.every(pattern => isnonempty(pattern))) return { allowed: false, reason: \"The reviewed mimefilter needs a non-empty list of include patterns.\" };\n if (filter.exclude !== undefined && (!Array.isArray(filter.exclude) || !filter.exclude.every(pattern => isnonempty(pattern)))) return { allowed: false, reason: \"The reviewed mimefilter exclude patterns must be a list of non-empty strings.\" };\n if (filter.default !== \"deny\" && filter.default !== \"allow\") return { allowed: false, reason: \"The reviewed mimefilter needs the deny or allow default for unlisted mime types.\" };\n return { allowed: true };\n}\n\n/** Validates one reviewed cleanup rule: a positive age window with no code ceiling, an artifact kind and a keep policy. */\nexport function validatecleanuprule(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed cleanuprule with an age, a kind and a keep policy is required.\" };\n const rule = value as Record<string, unknown>;\n if (typeof rule.age !== \"number\" || !Number.isFinite(rule.age) || rule.age <= 0) return { allowed: false, reason: \"The reviewed cleanup age window must be a positive number of milliseconds with no code ceiling.\" };\n if (!isnonempty(rule.kind)) return { allowed: false, reason: \"The reviewed cleanup rule needs a non-empty artifact kind, or any to match every kind.\" };\n if (rule.keep !== \"none\" && rule.keep !== \"latest\" && rule.keep !== \"all\") return { allowed: false, reason: \"The reviewed cleanup keep policy must be none, latest or all.\" };\n return { allowed: true };\n}\n\n/** Validates the reviewed files, clipboard and downloads parameter grammar; batch sizes, concurrent windows and cleanup ages stay user configured with no code ceilings. */\nfunction validatefilesgrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"batchdownload\") {\n const speccheck = validatedownloadspec(options.downloadspec);\n if (!speccheck.allowed) return speccheck;\n if (options.concurrent !== undefined && (typeof options.concurrent !== \"number\" || !Number.isInteger(options.concurrent) || options.concurrent < 1)) return { allowed: false, reason: \"The reviewed concurrent download window must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"pausedownload\" || kind === \"resumedownload\" || kind === \"verifydownload\" || kind === \"quarantinedownload\" || kind === \"scanvirus\") {\n if (!isnonempty(step.value)) return { allowed: false, reason: \"A reviewed download or quarantine reference is required.\" };\n if (kind === \"verifydownload\") {\n if (options.checksum !== undefined && !isnonempty(options.checksum)) return { allowed: false, reason: \"The reviewed expected checksum must be a non-empty string.\" };\n if (options.bytes !== undefined && (typeof options.bytes !== \"number\" || !Number.isFinite(options.bytes) || options.bytes < 0)) return { allowed: false, reason: \"The reviewed expected size must be zero or a positive number of bytes.\" };\n }\n if (kind === \"scanvirus\" && options.scanner !== undefined && !isnonempty(options.scanner)) return { allowed: false, reason: \"The reviewed scanner name must be a non-empty string.\" };\n if (kind === \"quarantinedownload\" && options.reason !== undefined && !isnonempty(options.reason)) return { allowed: false, reason: \"The reviewed quarantine reason must be a non-empty string.\" };\n }\n if (kind === \"interceptmime\") {\n const filtercheck = validatemimefilter(options.mimefilter);\n if (!filtercheck.allowed) return filtercheck;\n }\n if (kind === \"readclipboard\") {\n if (!isnonempty(options.consentref)) return { allowed: false, reason: \"A clipboard read requires a reviewed consent ref of an approved consent prompt in options.\" };\n if (options.prompt !== undefined && !isnonempty(options.prompt)) return { allowed: false, reason: \"The reviewed clipboard consent prompt must be a non-empty string.\" };\n }\n if (kind === \"exportnetlog\" && options.stepid !== undefined && !isnonempty(options.stepid)) return { allowed: false, reason: \"The reviewed netlog step filter must be a non-empty step id.\" };\n if (kind === \"namecaptures\") {\n if (!isnonempty(options.task)) return { allowed: false, reason: \"A reviewed task id is required in options for capture naming.\" };\n if (options.steps !== undefined && (!Array.isArray(options.steps) || options.steps.length === 0 || !options.steps.every(item => isnonempty(item)))) return { allowed: false, reason: \"The reviewed capture steps must be a non-empty list of step ids when present.\" };\n if (options.extension !== undefined && !isnonempty(options.extension)) return { allowed: false, reason: \"The reviewed capture extension must be a non-empty string.\" };\n }\n if (kind === \"cleanupartifacts\" && options.rules !== undefined) {\n const rules = options.rules;\n if (!Array.isArray(rules) || rules.length === 0) return { allowed: false, reason: \"The reviewed cleanup rules must be a non-empty list when present.\" };\n for (const item of rules) {\n const rulecheck = validatecleanuprule(item);\n if (!rulecheck.allowed) return rulecheck;\n }\n }\n return { allowed: true };\n}\n\n/** Requires an approved consent prompt before any clipboard read; every read consumes its own prompt. */\nexport function clipboardconsentgranted(step: toolstep): policyevaluation {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(step); } catch { options = {}; }\n const consentref = options.consentref;\n if (typeof consentref !== \"string\" || !consentref.trim()) return { allowed: false, reason: \"A clipboard read requires a reviewed consent ref in options.\" };\n return { allowed: true };\n}\n\n/** Refuses to release any quarantined file before a clean scan verdict exists. */\nexport function quarantinereleasegranted(entry: quarantineentry): policyevaluation {\n if (entry.scan !== \"clean\") return { allowed: false, reason: `The quarantined file ${entry.path} cannot leave quarantine with the ${entry.scan} scan verdict; only a clean verdict releases it.` };\n return { allowed: true };\n}\n\n/** Refuses downloads and download interception that fall outside the session origin grants. */\nexport function downloadgranted(session: agentsession | undefined, url: string): policyevaluation {\n let origin = \"\";\n try { origin = new URL(url).origin; } catch { return { allowed: false, reason: \"The reviewed download URL is invalid.\" }; }\n if (!origingranted(session, origin)) return { allowed: false, reason: `The download from ${origin} leaves the session origin grants and needs a session grant first.` };\n return { allowed: true };\n}\n\n/** Masks a clipboard payload for every log line; the full text never persists anywhere. */\nexport function maskclipboard(payload: string): string {\n return `[clipboard payload of ${payload.length} character${payload.length === 1 ? \"\" : \"s\"}]`;\n}\n\n/** Requires an asksubmit review step before every form submission step. */\nexport function submitreviewgranted(steps: toolstep[], submitid: string): policyevaluation {\n const position = steps.findIndex(candidate => candidate.id === submitid);\n const asked = steps.some((candidate, index) => candidate.kind === \"asksubmit\" && (position === -1 || index < position));\n return asked ? { allowed: true } : { allowed: false, reason: \"Form submission requires an asksubmit review step before it.\" };\n}\n\n/** Requires a reviewed consent ref before any password field is filled. */\nexport function passwordconsentgranted(step: toolstep): policyevaluation {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(step); } catch { options = {}; }\n const consentref = options.consentref;\n if (typeof consentref !== \"string\" || !consentref.trim()) return { allowed: false, reason: \"A password fill requires a reviewed consent ref in options.\" };\n return { allowed: true };\n}\n\n/** True when a numeric value passes the Luhn checksum used by card networks. */\nfunction luhnvalid(digits: string): boolean {\n let sum = 0;\n let double = false;\n for (let index = digits.length - 1; index >= 0; index -= 1) {\n let value = Number.parseInt(digits[index] ?? \"\", 10);\n if (!Number.isFinite(value)) return false;\n if (double) { value *= 2; if (value > 9) value -= 9; }\n sum += value;\n double = !double;\n }\n return sum % 10 === 0;\n}\n\n/** Refuses generated values that look like real card numbers or personal identifiers; test prefixed card values stay allowed. */\nexport function generatedvalueallowed(value: string): policyevaluation {\n const compact = value.replace(/[\\s-]/g, \"\");\n if (/^\\d{13,19}$/.test(compact) && luhnvalid(compact) && !compact.startsWith(\"4111\")) return { allowed: false, reason: \"The generated value looks like a real card number and is refused; generated card values use the 4111 test prefix.\" };\n if (/^\\d{3}-\\d{2}-\\d{4}$/.test(value.trim())) return { allowed: false, reason: \"The generated value looks like a personal identifier and is refused.\" };\n return { allowed: true };\n}\n\n/** Requires the origin grants of a saved profile to cover the origin before its values fill a page. */\nexport function profilegrantgranted(profile: formprofile, origin: string): policyevaluation {\n if (!profile.grants.includes(origin)) return { allowed: false, reason: `The saved profile ${profile.name} is not granted to ${origin}; add the origin to the profile grants first.` };\n return { allowed: true };\n}\n\n/** Restricts group and layout mutations to the active session: they refuse without a live session. */\nexport function layoutmutationgranted(session: agentsession | undefined, now: number): policyevaluation {\n if (!session || session.stoppedat || session.expiresat <= now) return { allowed: false, reason: \"Group and layout mutations stay inside the active session.\" };\n return { allowed: true };\n}\n\n/** Requires explicit review before closing a window that holds more than one task tab. */\nexport function windowclosegate(tasktabcount: number, reviewed: boolean): policyevaluation {\n if (tasktabcount > 1 && !reviewed) return { allowed: false, reason: `The window holds ${tasktabcount} task tabs and needs explicit review before it closes.` };\n return { allowed: true };\n}\n\n/** Reads the user configured concurrent task tab ceiling; an absent value never refuses a tab. */\nexport function tasktabceiling(settings: runsettings | undefined): number | undefined {\n const ceiling = settings?.tasktabceiling;\n return typeof ceiling === \"number\" && Number.isFinite(ceiling) && ceiling >= 0 ? ceiling : undefined;\n}\n\n/** Parses the reviewed wait duration of a wait step with no upper bound. */\nexport function waitduration(step: toolstep): number {\n const requested = step.value ? Number.parseInt(step.value, 10) : 250;\n if (!Number.isFinite(requested) || requested < 0) throw new Error(\"Wait duration must be zero or a positive number of milliseconds.\");\n return requested;\n}\n\nfunction isnumericid(value: unknown): value is string {\n return typeof value === \"string\" && /^\\d+$/.test(value);\n}\n\nfunction numericoption(options: Record<string, unknown>, key: string): boolean {\n return options[key] === undefined || (typeof options[key] === \"number\" && Number.isFinite(options[key] as number));\n}\n\n/** True when an optional numeric option is absent or a finite number of zero or more. */\nfunction nonnegativeoption(options: Record<string, unknown>, key: string): boolean {\n return numericoption(options, key) && !(typeof options[key] === \"number\" && (options[key] as number) < 0);\n}\n\nfunction isnonempty(value: unknown): value is string {\n return typeof value === \"string\" && value.trim().length > 0;\n}\n\nfunction ispoint(value: unknown): boolean {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n const point = value as Record<string, unknown>;\n return typeof point.x === \"number\" && Number.isFinite(point.x) && typeof point.y === \"number\" && Number.isFinite(point.y);\n}\n\n/** Grades a resolution match count: zero is absent, one is resolved and more than one is refused as ambiguous. */\nexport function resolutionverdict(count: number): \"absent\" | \"resolved\" | \"ambiguous\" {\n if (!Number.isFinite(count) || count <= 0) return \"absent\";\n return count === 1 ? \"resolved\" : \"ambiguous\";\n}\n\n/** Validates the reviewed targetref grammar of every resolution mode and rejects empty references. */\nexport function validatetargetref(reference: unknown): policyevaluation {\n if (!reference || typeof reference !== \"object\" || Array.isArray(reference)) return { allowed: false, reason: \"The reviewed target reference must be an object.\" };\n const ref = reference as Record<string, unknown>;\n if (ref.mode === \"selector\") return isnonempty(ref.selector) ? { allowed: true } : { allowed: false, reason: \"The selector target reference needs a non-empty selector.\" };\n if (ref.mode === \"text\") return isnonempty(ref.text) ? { allowed: true } : { allowed: false, reason: \"The text target reference needs non-empty text.\" };\n if (ref.mode === \"aria\") {\n if (!isnonempty(ref.role)) return { allowed: false, reason: \"The aria target reference needs a non-empty role.\" };\n return isnonempty(ref.name) ? { allowed: true } : { allowed: false, reason: \"The aria target reference needs a non-empty name.\" };\n }\n if (ref.mode === \"name\") return isnonempty(ref.name) ? { allowed: true } : { allowed: false, reason: \"The name target reference needs a non-empty name.\" };\n if (ref.mode === \"xpath\") return isnonempty(ref.xpath) ? { allowed: true } : { allowed: false, reason: \"The xpath target reference needs a non-empty expression.\" };\n if (ref.mode === \"index\") {\n const index = ref.index;\n return typeof index === \"number\" && Number.isInteger(index) && index >= 1 ? { allowed: true } : { allowed: false, reason: \"The index target reference needs a positive integer map number.\" };\n }\n if (ref.mode === \"point\") {\n const pointok = typeof ref.x === \"number\" && Number.isFinite(ref.x) && typeof ref.y === \"number\" && Number.isFinite(ref.y);\n return pointok ? { allowed: true } : { allowed: false, reason: \"The point target reference needs numeric x and y coordinates.\" };\n }\n return { allowed: false, reason: \"The target reference mode must be selector, text, aria, name, xpath, index or point.\" };\n}\n\n/** True when the session origin grants cover the given origin; a session without grants only allows its own origin. */\nexport function origingranted(session: agentsession | undefined, origin: string): boolean {\n if (!session) return false;\n const grants = session.grants ?? [session.origin];\n return grants.includes(origin);\n}\n\n/** Decides whether an unreviewed origin may open: the session grants cover it or a safe checksafe verdict vouches for it. */\nexport function originverified(url: string, grants: string[], verdicts: safetyverdict[]): policyevaluation {\n let origin = \"\";\n try { origin = new URL(url).origin; } catch { return { allowed: false, reason: \"The reviewed navigation URL is invalid.\" }; }\n if (grants.includes(origin)) return { allowed: true };\n const covered = verdicts.find(verdict => verdict.safe && (verdict.url === url || (safeorigin(verdict.url) === origin)));\n if (covered) return { allowed: true };\n return { allowed: false, reason: `The origin ${origin} is outside the session grants and has no safe checksafe verdict; run checksafe and review it first.` };\n}\n\nfunction safeorigin(url: string): string {\n try { return new URL(url).origin; } catch { return \"\"; }\n}\n\n/** Refuses navigation that would move a granted task tab outside the session origin grants until the user consents. */\nexport function navigationgranted(session: agentsession | undefined, url: string): policyevaluation {\n let origin = \"\";\n try { origin = new URL(url).origin; } catch { return { allowed: false, reason: \"The reviewed navigation URL is invalid.\" }; }\n if (origingranted(session, origin)) return { allowed: true };\n return { allowed: false, reason: `Navigation to ${origin} leaves the task tab origins and needs the user consent of a session grant first.` };\n}\n\n/** Validates the reviewed inner step of a retry or frame wrapper against the same rules as a top-level step. */\nfunction validateinnerstep(options: Record<string, unknown>, origin: string): policyevaluation {\n const stepid = options.stepid;\n const kind = options.kind;\n if (isnonempty(stepid)) {\n if (kind !== undefined) return { allowed: false, reason: \"The reviewed wrapper must reference a step id or an inline step, not both.\" };\n return { allowed: true };\n }\n if (typeof kind !== \"string\" || !kind.trim()) return { allowed: false, reason: \"A reviewed step id or inline step kind is required in options.\" };\n if (kind === \"retryaction\" || kind === \"enterframe\" || kind === \"looprows\") return { allowed: false, reason: \"The reviewed inner step cannot be another wrapper kind.\" };\n if (!allowedactions.has(kind as actionkind)) return { allowed: false, reason: \"The reviewed inner step kind is unsupported.\" };\n const inneroptions = options.options;\n if (inneroptions !== undefined && (!inneroptions || typeof inneroptions !== \"object\" || Array.isArray(inneroptions))) return { allowed: false, reason: \"The reviewed inner step options must be an object.\" };\n const inner: toolstep = {\n id: \"inner\",\n kind: kind as actionkind,\n summary: \"Reviewed inner step.\",\n risk: actionrisk(kind as actionkind),\n ...(isnonempty(options.target) ? { target: options.target } : {}),\n ...(isnonempty(options.value) ? { value: options.value } : {}),\n ...(inneroptions !== undefined ? { options: JSON.stringify(inneroptions) } : {}),\n };\n return validatestep(inner, origin);\n}\n\n/** True when a reviewed https url parses. */\nfunction ishttpsurl(value: unknown): value is string {\n if (typeof value !== \"string\" || !value.trim()) return false;\n try { return new URL(value).protocol === \"https:\"; } catch { return false; }\n}\n\n/** Validates the reviewed navtarget grammar of a navigation step. */\nfunction validatenavtarget(value: unknown, kind: string): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed navtarget with a url is required in options.\" };\n const target = value as Record<string, unknown>;\n if (!ishttpsurl(target.url)) return { allowed: false, reason: \"The reviewed navtarget url must use HTTPS.\" };\n const container = target.container ?? \"tab\";\n if (container !== \"current\" && container !== \"tab\" && container !== \"window\" && container !== \"private\") return { allowed: false, reason: \"The reviewed navtarget container must be current, tab, window or private.\" };\n if (target.position !== undefined && target.position !== \"adjacent\" && target.position !== \"end\") return { allowed: false, reason: \"The reviewed navtarget position must be adjacent or end.\" };\n if (kind === \"openprivate\" && container !== \"private\") return { allowed: false, reason: \"The openprivate step requires the private container.\" };\n if (kind === \"openlink\" && container === \"private\") return { allowed: false, reason: \"The openlink step cannot open the private container; use openprivate.\" };\n return { allowed: true };\n}\n\n/** Validates the reviewed waitprofile grammar with its load signals, thresholds and per origin overrides. */\nfunction validatewaitprofile(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed waitprofile with load signals is required in options.\" };\n const profile = value as Record<string, unknown>;\n if (!Array.isArray(profile.signals) || profile.signals.length === 0 || !profile.signals.every(signal => isnonempty(signal))) return { allowed: false, reason: \"The reviewed waitprofile needs a non-empty list of load signals.\" };\n if (!nonnegativeoption(profile, \"idle\")) return { allowed: false, reason: \"The reviewed waitprofile idle threshold must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(profile, \"timeout\")) return { allowed: false, reason: \"The reviewed waitprofile timeout must be zero or a positive number of milliseconds.\" };\n if (profile.overrides !== undefined) {\n if (!Array.isArray(profile.overrides) || profile.overrides.length === 0) return { allowed: false, reason: \"The reviewed waitprofile overrides must be a non-empty list when present.\" };\n for (const entry of profile.overrides) {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) return { allowed: false, reason: \"Every reviewed waitprofile override must be an object with an origin.\" };\n const override = entry as Record<string, unknown>;\n if (!ishttpsurl(override.origin)) return { allowed: false, reason: \"Every reviewed waitprofile override origin must use HTTPS.\" };\n if (override.signals !== undefined && (!Array.isArray(override.signals) || !override.signals.every(signal => isnonempty(signal)))) return { allowed: false, reason: \"The reviewed waitprofile override signals must be a list of non-empty strings.\" };\n if (!nonnegativeoption(override, \"idle\") || !nonnegativeoption(override, \"timeout\")) return { allowed: false, reason: \"The reviewed waitprofile override thresholds must be zero or positive numbers.\" };\n }\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed urlpattern grammar with its match mode plus query and fragment parts. */\nexport function validateurlpattern(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed urlpattern is required in options.\" };\n const pattern = value as Record<string, unknown>;\n if (pattern.mode !== \"exact\" && pattern.mode !== \"prefix\" && pattern.mode !== \"host\" && pattern.mode !== \"pattern\") return { allowed: false, reason: \"The reviewed urlpattern mode must be exact, prefix, host or pattern.\" };\n if (!ishttpsurl(pattern.url)) return { allowed: false, reason: \"The reviewed urlpattern url must use HTTPS.\" };\n if (pattern.query !== undefined) {\n if (!pattern.query || typeof pattern.query !== \"object\" || Array.isArray(pattern.query)) return { allowed: false, reason: \"The reviewed urlpattern query part must be an object of parameter names and values.\" };\n for (const item of Object.values(pattern.query)) if (typeof item !== \"string\") return { allowed: false, reason: \"The reviewed urlpattern query values must be strings.\" };\n }\n if (pattern.fragment !== undefined && !isnonempty(pattern.fragment)) return { allowed: false, reason: \"The reviewed urlpattern fragment must be a non-empty string.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed non-empty list of HTTPS urls in options. */\nfunction validateurllist(options: Record<string, unknown>, key: string): policyevaluation {\n const urls = options[key];\n if (!Array.isArray(urls) || urls.length === 0 || !urls.every(url => ishttpsurl(url))) return { allowed: false, reason: `A reviewed non-empty list of HTTPS urls is required in options as ${key}.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed ratelimit grammar of a navrate step; the window and ceiling stay user configured with no hardcoded cap. */\nfunction validateratelimit(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed ratelimit with a window and a ceiling is required in options.\" };\n const limit = value as Record<string, unknown>;\n if (limit.domain !== undefined && !isnonempty(limit.domain)) return { allowed: false, reason: \"The reviewed ratelimit domain must be a non-empty string.\" };\n if (typeof limit.window !== \"number\" || !Number.isFinite(limit.window) || limit.window <= 0) return { allowed: false, reason: \"The reviewed ratelimit window must be a positive number of milliseconds with no code ceiling.\" };\n if (typeof limit.ceiling !== \"number\" || !Number.isInteger(limit.ceiling) || limit.ceiling < 1) return { allowed: false, reason: \"The reviewed ratelimit ceiling must be a positive integer with no code ceiling.\" };\n return { allowed: true };\n}\n\n/** Validates the reviewed tabquery grammar with url, title, id and pattern matchers; at least one matcher is required. */\nexport function validatetabquery(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed tabquery with at least one matcher is required in options.\" };\n const query = value as Record<string, unknown>;\n const hasmatcher = query.url !== undefined || query.title !== undefined || query.id !== undefined || query.pattern !== undefined;\n if (!hasmatcher) return { allowed: false, reason: \"The reviewed tabquery needs a url, title, id or pattern matcher.\" };\n if (query.url !== undefined && !isnonempty(query.url)) return { allowed: false, reason: \"The reviewed tabquery url matcher must be a non-empty string.\" };\n if (query.title !== undefined && !isnonempty(query.title)) return { allowed: false, reason: \"The reviewed tabquery title matcher must be a non-empty string.\" };\n if (query.pattern !== undefined && !isnonempty(query.pattern)) return { allowed: false, reason: \"The reviewed tabquery pattern matcher must be a non-empty string.\" };\n if (query.id !== undefined && (typeof query.id !== \"number\" || !Number.isInteger(query.id) || query.id < 0)) return { allowed: false, reason: \"The reviewed tabquery id matcher must be a non-negative integer tab id.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed group color choice against the Chromium tab group palette. */\nfunction validategroupcolor(value: unknown): boolean {\n return typeof value === \"string\" && (groupcolors as string[]).includes(value);\n}\n\n/** Validates a reviewed list of numeric browser ids in options. */\nfunction validateidlist(options: Record<string, unknown>, key: string): boolean {\n const ids = options[key];\n return Array.isArray(ids) && ids.length > 0 && ids.every(id => typeof id === \"number\" && Number.isInteger(id) && id >= 0);\n}\n\n/** Validates the reviewed tab and window parameter grammar of the tabs and windows command family. */\nfunction validatetabsgrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"querytabs\" || kind === \"closepattern\") {\n const querycheck = validatetabquery(options.tabquery);\n if (!querycheck.allowed) return querycheck;\n if (kind === \"closepattern\" && options.reviewed !== true) return { allowed: false, reason: \"The close pattern needs the explicit reviewed flag before any tab closes.\" };\n }\n if (kind === \"duplicatetab\" || kind === \"pintab\" || kind === \"mutetab\" || kind === \"movetab\" || kind === \"movetabwindow\" || kind === \"badgetab\" || kind === \"attachmeta\") {\n if (!isnumericid(step.value)) return { allowed: false, reason: \"A numeric browser tab id is required.\" };\n }\n if (kind === \"focuswindow\" || kind === \"maximizewindow\" || kind === \"minimizewindow\" || kind === \"restorewindow\") {\n if (!isnumericid(step.value)) return { allowed: false, reason: \"A numeric browser window id is required.\" };\n }\n if (kind === \"pintab\" && typeof options.pinned !== \"boolean\") return { allowed: false, reason: \"A reviewed pinned flag is required in options.\" };\n if (kind === \"mutetab\" && typeof options.muted !== \"boolean\") return { allowed: false, reason: \"A reviewed muted flag is required in options.\" };\n if (kind === \"movetab\") {\n if (typeof options.index !== \"number\" || !Number.isInteger(options.index) || options.index < 0) return { allowed: false, reason: \"A reviewed non-negative target index is required in options.\" };\n }\n if (kind === \"movetabwindow\") {\n if (typeof options.windowid !== \"number\" || !Number.isInteger(options.windowid) || options.windowid < 0) return { allowed: false, reason: \"A reviewed target window id is required in options.\" };\n }\n if (kind === \"grouptabs\") {\n const group = options.group;\n if (!group || typeof group !== \"object\" || Array.isArray(group)) return { allowed: false, reason: \"A reviewed group with a name is required in options.\" };\n const spec = group as Record<string, unknown>;\n if (!isnonempty(spec.name)) return { allowed: false, reason: \"The reviewed group needs a non-empty name.\" };\n if (!validategroupcolor(spec.color)) return { allowed: false, reason: \"The reviewed group color must be a Chromium tab group color.\" };\n if (!validateidlist(spec, \"tabids\")) return { allowed: false, reason: \"The reviewed group needs a non-empty list of member tab ids.\" };\n }\n if (kind === \"colorgroup\") {\n if (!isnonempty(options.name)) return { allowed: false, reason: \"A reviewed group name is required in options.\" };\n if (!validategroupcolor(options.color)) return { allowed: false, reason: \"The reviewed group color must be a Chromium tab group color.\" };\n }\n if (kind === \"collapsegroup\") {\n if (!isnonempty(options.name)) return { allowed: false, reason: \"A reviewed group name is required in options.\" };\n if (typeof options.collapsed !== \"boolean\") return { allowed: false, reason: \"A reviewed collapsed flag is required in options.\" };\n }\n if (kind === \"discardtab\" || kind === \"reloadtabs\") {\n if (!isnumericid(step.value) && !validateidlist(options, \"tabs\")) return { allowed: false, reason: \"A numeric tab id or a reviewed list of tab ids is required.\" };\n }\n if (kind === \"zoomin\" || kind === \"zoomout\") {\n if (options.step !== undefined && (typeof options.step !== \"number\" || !Number.isFinite(options.step) || options.step <= 0)) return { allowed: false, reason: \"The reviewed zoom step must be a positive number with no code ceiling.\" };\n if (step.value !== undefined && step.value !== \"\" && !isnumericid(step.value)) return { allowed: false, reason: \"The reviewed zoom target must be a numeric tab id.\" };\n }\n if (kind === \"switchtab\") {\n if (options.direction !== \"next\" && options.direction !== \"previous\") return { allowed: false, reason: \"A reviewed switch direction of next or previous is required in options.\" };\n }\n if (kind === \"restorewindow\") {\n const bounds = options.bounds;\n if (bounds !== undefined) {\n if (!bounds || typeof bounds !== \"object\" || Array.isArray(bounds)) return { allowed: false, reason: \"The reviewed window bounds must be an object.\" };\n const shape = bounds as Record<string, unknown>;\n for (const field of [\"left\", \"top\", \"width\", \"height\"]) {\n if (typeof shape[field] !== \"number\" || !Number.isFinite(shape[field])) return { allowed: false, reason: \"The reviewed window bounds need numeric left, top, width and height.\" };\n }\n }\n }\n if (kind === \"scratchwindow\") {\n if (step.value !== undefined && step.value !== \"\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"The reviewed scratch window url must use HTTPS.\" };\n }\n if (kind === \"incognitowindow\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"A reviewed HTTPS url is required to open an incognito window.\" };\n if (kind === \"restoretab\" && step.value !== undefined && step.value !== \"\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"The reviewed restore url must use HTTPS.\" };\n if (kind === \"savelayout\" || kind === \"restorelayout\") {\n if (!isnonempty(options.name)) return { allowed: false, reason: \"A reviewed layout name is required in options.\" };\n }\n if (kind === \"badgetab\") {\n if (!isnonempty(options.label)) return { allowed: false, reason: \"A reviewed badge label is required in options.\" };\n if (options.taskid !== undefined && !isnonempty(options.taskid)) return { allowed: false, reason: \"The reviewed badge task id must be a non-empty string.\" };\n }\n if (kind === \"attachmeta\") {\n const labels = options.labels;\n const taskrefs = options.taskrefs;\n const haslabels = Array.isArray(labels) && labels.length > 0 && labels.every(label => isnonempty(label));\n const hastaskrefs = Array.isArray(taskrefs) && taskrefs.length > 0 && taskrefs.every(ref => isnonempty(ref));\n if (!haslabels && !hastaskrefs) return { allowed: false, reason: \"Reviewed labels or task refs are required in options to attach metadata.\" };\n if (options.provenance !== undefined && !isnonempty(options.provenance)) return { allowed: false, reason: \"The reviewed provenance must be a non-empty string.\" };\n }\n if (kind === \"reopenrun\" && !isnonempty(options.run)) return { allowed: false, reason: \"A reviewed run id is required in options to reopen its tabs.\" };\n return { allowed: true };\n}\n\n/** Validates a single proposal against the active tab origin and local policy. */\nexport function validatestep(step: toolstep, origin: string): policyevaluation {\n if (!allowedactions.has(step.kind)) return { allowed: false, reason: \"Unsupported action kind.\" };\n if (!step.summary.trim()) return { allowed: false, reason: \"A human-readable action summary is required.\" };\n let options: Record<string, unknown>;\n try { options = parseoptions(step); } catch { return { allowed: false, reason: \"Step options must be a JSON object.\" }; }\n const hastargetref = options.targetref !== undefined;\n if (targetactions.has(step.kind) && !step.target?.trim() && !hastargetref) return { allowed: false, reason: \"A page target is required.\" };\n if (valueactions.has(step.kind) && !step.value?.trim()) return { allowed: false, reason: \"A reviewed value is required.\" };\n if (step.kind === \"select\" && !step.value?.trim()) return { allowed: false, reason: \"A reviewed option value is required.\" };\n if (step.kind === \"navigate\" && !step.value) return { allowed: false, reason: \"A navigation URL is required.\" };\n if (hastargetref) {\n const reference = validatetargetref(options.targetref);\n if (!reference.allowed) return reference;\n }\n if (step.kind === \"wait\") {\n try { waitduration(step); } catch { return { allowed: false, reason: \"Wait duration must be zero or a positive number of milliseconds.\" }; }\n }\n if (step.kind === \"navigate\") {\n try {\n if (new URL(step.value ?? \"\").origin !== origin) return { allowed: false, reason: \"Navigation must remain within the approved origin.\" };\n } catch {\n return { allowed: false, reason: \"Navigation URL is invalid.\" };\n }\n }\n if (step.kind === \"tabcreate\" || step.kind === \"windowcreate\" || step.kind === \"downloadfile\") {\n try {\n const url = new URL(step.value ?? \"\");\n if (url.protocol !== \"https:\") return { allowed: false, reason: \"The reviewed URL must use HTTPS.\" };\n } catch {\n return { allowed: false, reason: \"The reviewed URL is invalid.\" };\n }\n }\n if (step.kind === \"tabactivate\" || step.kind === \"tabclose\" || step.kind === \"tabreload\" || step.kind === \"windowclose\" || step.kind === \"windowresize\") {\n if (!isnumericid(step.value)) return { allowed: false, reason: \"A numeric browser id is required.\" };\n }\n if (step.kind === \"zoomset\") {\n const zoom = Number(step.value);\n if (!Number.isFinite(zoom) || zoom <= 0) return { allowed: false, reason: \"The reviewed zoom must be a positive number.\" };\n }\n if (step.kind === \"setattribute\" || step.kind === \"writestorage\") {\n const keyname = step.kind === \"setattribute\" ? \"name\" : \"key\";\n if (typeof options[keyname] !== \"string\" || !(options[keyname] as string).trim()) return { allowed: false, reason: `A reviewed ${keyname} is required in options.` };\n if (typeof options.value !== \"string\") return { allowed: false, reason: \"A reviewed value is required in options.\" };\n }\n if (step.kind === \"windowresize\") {\n if (typeof options.width !== \"number\" || typeof options.height !== \"number\" || !Number.isFinite(options.width) || !Number.isFinite(options.height)) return { allowed: false, reason: \"Reviewed width and height numbers are required in options.\" };\n }\n if ((step.kind === \"scrollpage\" || step.kind === \"scrollby\") && (!numericoption(options, \"x\") || !numericoption(options, \"y\"))) return { allowed: false, reason: \"Scroll amounts must be numbers in options.\" };\n if (step.kind === \"waitfor\" && options.timeout !== undefined && (typeof options.timeout !== \"number\" || options.timeout < 0)) return { allowed: false, reason: \"The waitfor timeout must be zero or a positive number of milliseconds.\" };\n if (step.kind === \"movepointer\") {\n const path = options.pointpath;\n if (!path || typeof path !== \"object\" || Array.isArray(path)) return { allowed: false, reason: \"A reviewed pointpath with start and end points is required in options.\" };\n const points = path as Record<string, unknown>;\n if (!ispoint(points.start) || !ispoint(points.end)) return { allowed: false, reason: \"The reviewed pointpath needs numeric start and end points.\" };\n if (points.waypoints !== undefined && (!Array.isArray(points.waypoints) || !points.waypoints.every(waypoint => ispoint(waypoint)))) return { allowed: false, reason: \"The reviewed pointpath waypoints must be numeric points.\" };\n if (!nonnegativeoption(points, \"duration\")) return { allowed: false, reason: \"The reviewed pointpath duration must be zero or a positive number of milliseconds.\" };\n const speed = options.speedprofile;\n if (speed !== undefined) {\n if (!speed || typeof speed !== \"object\" || Array.isArray(speed)) return { allowed: false, reason: \"The reviewed speed profile must be an object.\" };\n const profile = speed as Record<string, unknown>;\n if (profile.easing !== undefined && profile.easing !== \"linear\" && profile.easing !== \"easeinout\") return { allowed: false, reason: \"The reviewed easing must be linear or easeinout.\" };\n if (!nonnegativeoption(profile, \"peak\")) return { allowed: false, reason: \"The reviewed peak velocity must be zero or a positive number.\" };\n if (!nonnegativeoption(profile, \"jitter\")) return { allowed: false, reason: \"The reviewed jitter window must be zero or a positive number of milliseconds.\" };\n }\n }\n if (step.kind === \"clickpoint\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"point\")) return { allowed: false, reason: \"A reviewed point target reference is required in options.\" };\n if (step.kind === \"clicktext\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"text\")) return { allowed: false, reason: \"A reviewed text target reference is required in options.\" };\n if (step.kind === \"clickaria\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"aria\")) return { allowed: false, reason: \"A reviewed aria target reference is required in options.\" };\n if (step.kind === \"clickname\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"name\")) return { allowed: false, reason: \"A reviewed name target reference is required in options.\" };\n if (step.kind === \"resolvexpath\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"xpath\")) return { allowed: false, reason: \"A reviewed xpath target reference is required in options.\" };\n if (step.kind === \"typetime\" && options.delay !== undefined && (typeof options.delay !== \"number\" || !Number.isFinite(options.delay) || options.delay < 0)) return { allowed: false, reason: \"The reviewed per keystroke delay must be zero or a positive number of milliseconds.\" };\n if (step.kind === \"submitsearch\") {\n if (!isnonempty(options.results)) return { allowed: false, reason: \"A reviewed results region selector is required in options.\" };\n if (options.timeout !== undefined && (typeof options.timeout !== \"number\" || !Number.isFinite(options.timeout) || options.timeout < 0)) return { allowed: false, reason: \"The submitsearch timeout must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"selectmulti\") {\n const values = options.values;\n if (!Array.isArray(values) || values.length === 0 || !values.every(value => isnonempty(value))) return { allowed: false, reason: \"A reviewed list of option values is required in options.\" };\n }\n if (step.kind === \"setslider\") {\n const slider = Number(step.value);\n if (!Number.isFinite(slider)) return { allowed: false, reason: \"The reviewed slider value must be a number.\" };\n }\n if (step.kind === \"setdate\" && !/^\\d{4}-\\d{2}-\\d{2}$/.test(step.value ?? \"\")) return { allowed: false, reason: \"The reviewed date must use the yyyy-mm-dd form.\" };\n if (step.kind === \"setcolor\" && !/^#[0-9a-fA-F]{6}$/.test(step.value ?? \"\")) return { allowed: false, reason: \"The reviewed color must use the #rrggbb form.\" };\n if (step.kind === \"keyhold\" && options.holdid !== undefined && !isnonempty(options.holdid)) return { allowed: false, reason: \"The reviewed hold id must be a non-empty string.\" };\n if (step.kind === \"dismissdialog\") {\n const accept = options.accept;\n const answer = options.answer;\n if (accept === undefined && !isnonempty(answer)) return { allowed: false, reason: \"A reviewed accept flag or prompt answer is required in options.\" };\n if (accept !== undefined && typeof accept !== \"boolean\") return { allowed: false, reason: \"The reviewed dialog accept flag must be a boolean.\" };\n if (answer !== undefined && !isnonempty(answer)) return { allowed: false, reason: \"The reviewed prompt answer must be a non-empty string.\" };\n }\n if (step.kind === \"pierceshadow\" && options.shadow !== undefined) {\n if (!Array.isArray(options.shadow) || !options.shadow.every(item => isnonempty(item))) return { allowed: false, reason: \"The reviewed shadow path must be a list of non-empty selectors.\" };\n }\n if (step.kind === \"enterframe\") {\n const path = options.framepath;\n if (!Array.isArray(path) || path.length === 0 || !path.every(item => typeof item === \"number\" && Number.isInteger(item) && item >= 0)) return { allowed: false, reason: \"A reviewed frame path of frame indexes is required in options.\" };\n return validateinnerstep(options, origin);\n }\n if (step.kind === \"retryaction\") {\n const inner = validateinnerstep(options, origin);\n if (!inner.allowed) return inner;\n const rule = options.retryrule;\n if (!rule || typeof rule !== \"object\" || Array.isArray(rule)) return { allowed: false, reason: \"A reviewed retry rule with attempts is required in options.\" };\n const retry = rule as Record<string, unknown>;\n if (typeof retry.attempts !== \"number\" || !Number.isInteger(retry.attempts) || retry.attempts < 1) return { allowed: false, reason: \"The reviewed retry attempts must be a positive integer with no code ceiling.\" };\n if (!nonnegativeoption(retry, \"settle\")) return { allowed: false, reason: \"The reviewed retry settle window must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(retry, \"tolerance\")) return { allowed: false, reason: \"The reviewed retry movement tolerance must be zero or a positive number of pixels.\" };\n }\n if (watchactions.has(step.kind)) {\n if (typeof options.lifetime !== \"number\" || !Number.isFinite(options.lifetime) || options.lifetime <= 0) return { allowed: false, reason: \"A reviewed watch lifetime window in milliseconds is required in options.\" };\n if (options.scopes !== undefined && (!Array.isArray(options.scopes) || !options.scopes.every(scope => isnonempty(scope)))) return { allowed: false, reason: \"The reviewed watch scopes must be a list of non-empty selectors.\" };\n if (options.events !== undefined && (!Array.isArray(options.events) || !options.events.every(event => isnonempty(event)))) return { allowed: false, reason: \"The reviewed watch event kinds must be a list of non-empty strings.\" };\n if (!nonnegativeoption(options, \"poll\")) return { allowed: false, reason: \"The reviewed watch poll interval must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"waitquiet\") {\n const rule = options.quietrule;\n if (!rule || typeof rule !== \"object\" || Array.isArray(rule)) return { allowed: false, reason: \"A reviewed quietrule with an idle threshold is required in options.\" };\n const quiet = rule as Record<string, unknown>;\n if (typeof quiet.idle !== \"number\" || !Number.isFinite(quiet.idle) || quiet.idle <= 0) return { allowed: false, reason: \"The reviewed quiet idle threshold must be a positive number of milliseconds with no code ceiling.\" };\n if (!nonnegativeoption(quiet, \"poll\")) return { allowed: false, reason: \"The reviewed quiet poll interval must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(quiet, \"timeout\")) return { allowed: false, reason: \"The reviewed quiet timeout must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"diffsnapshots\") {\n const versions = options.versions;\n if (!Array.isArray(versions) || versions.length !== 2 || !versions.every(version => typeof version === \"number\" && Number.isInteger(version) && version >= 1)) return { allowed: false, reason: \"Two reviewed observation version numbers are required in options.\" };\n }\n if (step.kind === \"openlink\" || step.kind === \"openprivate\" || step.kind === \"deeplink\") {\n const targetcheck = validatenavtarget(options.navtarget, step.kind);\n if (!targetcheck.allowed) return targetcheck;\n if (step.kind === \"deeplink\") {\n const app = options.app;\n if (!isnonempty(app)) return { allowed: false, reason: \"A reviewed deep link app pattern is required in options.\" };\n const params = options.params;\n if (params !== undefined && (!params || typeof params !== \"object\" || Array.isArray(params) || !Object.values(params).every(item => typeof item === \"string\"))) return { allowed: false, reason: \"The reviewed deep link params must be an object of string values.\" };\n }\n }\n if (step.kind === \"waitload\" && !nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The waitload timeout must be zero or a positive number of milliseconds.\" };\n if (step.kind === \"waiturl\" || step.kind === \"spawait\") {\n if (step.kind === \"waiturl\") {\n const patterncheck = validateurlpattern(options.urlpattern);\n if (!patterncheck.allowed) return patterncheck;\n }\n if (!nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The wait timeout must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(options, \"poll\")) return { allowed: false, reason: \"The wait poll interval must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"followlink\") {\n if (options.fragment !== undefined && typeof options.fragment !== \"boolean\") return { allowed: false, reason: \"The reviewed followlink fragment flag must be a boolean.\" };\n }\n if (step.kind === \"spanav\") {\n if (options.routepattern !== undefined) {\n const routecheck = validateurlpattern(options.routepattern);\n if (!routecheck.allowed) return routecheck;\n }\n if (!nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The spanav route timeout must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"rewritequery\") {\n const set = options.set;\n const remove = options.remove;\n if (set === undefined && remove === undefined) return { allowed: false, reason: \"Reviewed query parameters to set or remove are required in options.\" };\n if (set !== undefined && (!set || typeof set !== \"object\" || Array.isArray(set) || !Object.values(set).every(item => typeof item === \"string\"))) return { allowed: false, reason: \"The reviewed query parameters to set must be an object of string values.\" };\n if (remove !== undefined && (!Array.isArray(remove) || !remove.every(item => isnonempty(item)))) return { allowed: false, reason: \"The reviewed query parameters to remove must be a list of non-empty names.\" };\n }\n if (step.kind === \"navlist\") {\n const listcheck = validateurllist(options, \"urls\");\n if (!listcheck.allowed) return listcheck;\n }\n if (step.kind === \"navprofile\") {\n const profilecheck = validatewaitprofile(options.waitprofile);\n if (!profilecheck.allowed) return profilecheck;\n }\n if (step.kind === \"handleauth\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"A reviewed HTTPS origin or url is required as the auth target.\" };\n if (step.kind === \"printpdf\" && options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed artifact name must be a non-empty string.\" };\n if (step.kind === \"prefetch\") {\n const listcheck = validateurllist(options, \"urls\");\n if (!listcheck.allowed) return listcheck;\n }\n if (step.kind === \"preconnect\") {\n const origins = options.origins;\n if (!Array.isArray(origins) || origins.length === 0 || !origins.every(originurl => ishttpsurl(originurl))) return { allowed: false, reason: \"A reviewed non-empty list of HTTPS origins is required in options.\" };\n }\n if (step.kind === \"reopentab\" && step.value !== undefined && !ishttpsurl(step.value)) return { allowed: false, reason: \"The reviewed reopen url must use HTTPS.\" };\n if (step.kind === \"navrate\") {\n const limitcheck = validateratelimit(options.ratelimit);\n if (!limitcheck.allowed) return limitcheck;\n }\n if (step.kind === \"checksafe\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"A reviewed HTTPS url is required for the safety check.\" };\n if (step.kind === \"batchopen\") {\n const listcheck = validateurllist(options, \"urls\");\n if (!listcheck.allowed) return listcheck;\n }\n if (istabscommandkind(step.kind)) {\n const tabscheck = validatetabsgrammar(step, options);\n if (!tabscheck.allowed) return tabscheck;\n }\n if (isformkind(step.kind)) {\n const formcheck = validateformgrammar(step, options);\n if (!formcheck.allowed) return formcheck;\n }\n if (isdatasetkind(step.kind)) {\n const datacheck = validatedatagrammar(step, options, origin);\n if (!datacheck.allowed) return datacheck;\n }\n if (isfileskind(step.kind)) {\n const filescheck = validatefilesgrammar(step, options);\n if (!filescheck.allowed) return filescheck;\n }\n if (step.kind === \"tabcreate\") {\n if (options.background !== undefined && typeof options.background !== \"boolean\") return { allowed: false, reason: \"The reviewed background flag must be a boolean.\" };\n if (options.window !== undefined && (typeof options.window !== \"number\" || !Number.isInteger(options.window) || options.window < 0)) return { allowed: false, reason: \"The reviewed target window id must be a non-negative integer.\" };\n }\n if (step.kind === \"windowcreate\") {\n for (const field of [\"left\", \"top\", \"width\", \"height\"]) {\n if (options[field] !== undefined && (typeof options[field] !== \"number\" || !Number.isFinite(options[field]))) return { allowed: false, reason: `The reviewed window ${field} must be a number.` };\n }\n if (options.state !== undefined && ![\"normal\", \"maximized\", \"minimized\", \"fullscreen\"].includes(options.state as string)) return { allowed: false, reason: \"The reviewed window state must be normal, maximized, minimized or fullscreen.\" };\n }\n return { allowed: true };\n}\n\n/** Shared session gate: a live, unpaused session that still matches the active tab. */\nfunction sessiongate(input: { session: agentsession | undefined; tabid: number; origin: string; now: number; action: string }): policyevaluation {\n if (!input.session || input.session.stoppedat) return { allowed: false, reason: \"No active browser session exists.\" };\n if (input.session.expiresat <= input.now) return { allowed: false, reason: \"The browser session has expired.\" };\n if (input.session.pausedat) return { allowed: false, reason: `The browser session is paused and cannot ${input.action}.` };\n if (input.session.tabid !== input.tabid || input.session.origin !== input.origin) return { allowed: false, reason: `The ${input.action} is outside the approved tab or origin.` };\n return { allowed: true };\n}\n\n/** Applies the consent gate immediately before an action reaches the page bridge. */\nexport function canexecute(input: { session: agentsession | undefined; plan: agentplan | undefined; step: toolstep; tabid: number; origin: string; now?: number; verdicts?: safetyverdict[] }): policyevaluation {\n const now = input.now ?? Date.now();\n const gate = sessiongate({ session: input.session, tabid: input.tabid, origin: input.origin, now, action: \"execute an action\" });\n if (!gate.allowed) return gate;\n if (!input.plan || input.plan.state !== \"approved\") return { allowed: false, reason: \"The plan has not received explicit approval.\" };\n if (input.plan.expiresat <= now) return { allowed: false, reason: \"The approved plan has expired.\" };\n if ((input.step.kind === \"pierceshadow\" || input.step.kind === \"enterframe\") && !origingranted(input.session, input.origin)) return { allowed: false, reason: \"The shadow or frame step is outside the session origin grants.\" };\n if (input.step.kind === \"readjson\" && !origingranted(input.session, input.origin)) return { allowed: false, reason: \"The json state read is outside the session origin grants.\" };\n if (isexportkind(input.step.kind)) {\n const exportgate = exportgranted(input.session, input.origin);\n if (!exportgate.allowed) return exportgate;\n }\n if (input.step.kind === \"navlist\") {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(input.step); } catch { options = {}; }\n for (const url of Array.isArray(options.urls) ? options.urls : []) {\n if (typeof url !== \"string\") continue;\n const navigation = navigationgranted(input.session, url);\n if (!navigation.allowed) return navigation;\n }\n }\n if (islayoutkind(input.step.kind) && !layoutmutationgranted(input.session, now).allowed) return { allowed: false, reason: \"Group and layout mutations stay inside the active session.\" };\n if (input.step.kind === \"submitform\" || input.step.kind === \"retryform\") {\n if (!input.plan) return { allowed: false, reason: \"Form submission requires an asksubmit review step before it.\" };\n const reviewgate = submitreviewgranted(input.plan.steps, input.step.id);\n if (!reviewgate.allowed) return reviewgate;\n }\n if (input.step.kind === \"consentpassword\") {\n const consentgate = passwordconsentgranted(input.step);\n if (!consentgate.allowed) return consentgate;\n }\n if (input.step.kind === \"readclipboard\") {\n const clipgate = clipboardconsentgranted(input.step);\n if (!clipgate.allowed) return clipgate;\n }\n if (input.step.kind === \"interceptmime\" && !origingranted(input.session, input.origin)) return { allowed: false, reason: \"The download interception is outside the session origin grants.\" };\n if (input.step.kind === \"openlink\" || input.step.kind === \"openprivate\" || input.step.kind === \"batchopen\" || input.step.kind === \"prefetch\" || input.step.kind === \"deeplink\" || input.step.kind === \"reopentab\") {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(input.step); } catch { options = {}; }\n const grammar = validatestep(input.step, input.origin);\n if (!grammar.allowed) return grammar;\n const grants = input.session?.grants ?? [input.session?.origin ?? input.origin];\n const targets: unknown[] = input.step.kind === \"batchopen\" || input.step.kind === \"prefetch\" ? (Array.isArray(options.urls) ? options.urls : []) : input.step.kind === \"reopentab\" ? [input.step.value] : [(options.navtarget as Record<string, unknown> | undefined)?.url];\n for (const target of targets) {\n if (typeof target !== \"string\" || !target) continue;\n const verified = originverified(target, grants, input.verdicts ?? []);\n if (!verified.allowed) return verified;\n }\n }\n return validatestep(input.step, input.origin);\n}\n\n/** Allows a non-mutating, temporary target preview during plan review. */\nexport function canpreview(input: { session: agentsession | undefined; plan: agentplan | undefined; step: toolstep; tabid: number; origin: string; now?: number }): policyevaluation {\n const now = input.now ?? Date.now();\n const gate = sessiongate({ session: input.session, tabid: input.tabid, origin: input.origin, now, action: \"preview a target\" });\n if (!gate.allowed) return gate;\n if (!input.plan || ![\"pending\", \"approved\"].includes(input.plan.state)) return { allowed: false, reason: \"Only a reviewed pending or approved plan can be previewed.\" };\n if (input.plan.expiresat <= now) return { allowed: false, reason: \"The reviewed plan has expired.\" };\n let options: Record<string, unknown> = {};\n try { options = parseoptions(input.step); } catch { options = {}; }\n if (!targetactions.has(input.step.kind) && options.targetref === undefined) return { allowed: false, reason: \"Only a target-based action can be previewed.\" };\n return validatestep(input.step, input.origin);\n}\n", "/** Canonical package version synchronized from package.json. */\nexport const packageversion = \"1.1.39\" as const;\n", "/** Shared contracts for every Devthink target. */\nimport { packageversion } from \"./version.js\";\n\nexport const protocolversion = packageversion;\n\n/** Every reviewed action kind. Read kinds observe, interaction kinds move focus, sensitive kinds change page or browser state. */\nexport type actionkind =\n | \"observe\" | \"inspect\" | \"extract\" | \"wait\" | \"waitfor\" | \"waittext\"\n | \"readattribute\" | \"readstyle\" | \"readgeometry\" | \"readvalue\" | \"readtext\" | \"readhtml\"\n | \"countelements\" | \"readtable\" | \"readlinks\" | \"readimages\" | \"readmeta\" | \"readforms\"\n | \"readstorage\" | \"highlight\" | \"tablist\" | \"windowlist\" | \"tabsnapshot\"\n | \"focus\" | \"scroll\" | \"hover\" | \"clickdeep\" | \"rightclick\" | \"doubleclick\"\n | \"scrollpage\" | \"scrollby\" | \"scrollend\" | \"scrolltop\" | \"fullscreen\" | \"zoomset\"\n | \"click\" | \"type\" | \"navigate\" | \"select\" | \"presskey\" | \"drag\" | \"drop\" | \"upload\"\n | \"clear\" | \"check\" | \"uncheck\" | \"toggle\" | \"submit\" | \"reload\" | \"back\" | \"forward\"\n | \"writestorage\" | \"setattribute\" | \"removeattribute\" | \"evaluate\"\n | \"tabcreate\" | \"tabactivate\" | \"tabclose\" | \"tabreload\"\n | \"windowcreate\" | \"windowclose\" | \"windowresize\" | \"downloadfile\"\n | \"movepointer\" | \"clickpoint\" | \"shiftclick\" | \"clicktext\" | \"clickaria\" | \"clickname\"\n | \"resolvexpath\" | \"typetime\" | \"appendtext\" | \"setvalue\" | \"typeedit\"\n | \"keyhold\" | \"keyrelease\" | \"submitsearch\" | \"selectmulti\" | \"chooseradio\"\n | \"setslider\" | \"setdate\" | \"setcolor\" | \"expanddetails\" | \"dismissdialog\"\n | \"pierceshadow\" | \"enterframe\" | \"retryaction\"\n | \"mapclicks\" | \"verifyvisible\" | \"verifyenabled\"\n | \"a11ytree\" | \"readvisible\" | \"readertree\" | \"detectlists\" | \"detecttables\"\n | \"readjson\" | \"watchmutate\" | \"waitquiet\" | \"watchbanner\" | \"detectinfinitescroll\"\n | \"detectvirtual\" | \"detectlazy\" | \"readscrollpos\" | \"readlang\" | \"readoutline\"\n | \"countpages\" | \"listshadow\" | \"listframes\" | \"classifypage\" | \"fingerprintsection\"\n | \"diffsnapshots\" | \"readselection\" | \"watchfocus\" | \"detectsticky\" | \"detectscrolllock\"\n | \"readopengraph\" | \"detectlanguage\" | \"deriveselector\"\n | \"openlink\" | \"openprivate\" | \"reloadcache\" | \"stopnav\" | \"waitload\" | \"waiturl\"\n | \"followlink\" | \"spanav\" | \"spawait\" | \"rewritequery\" | \"setfragment\" | \"navlist\"\n | \"navprofile\" | \"detecthttp\" | \"readredirects\" | \"readfinalurl\" | \"handleauth\" | \"printpdf\"\n | \"prefetch\" | \"preconnect\" | \"deeplink\" | \"reopentab\" | \"trailaudit\" | \"pausenav\"\n | \"navintent\" | \"navrate\" | \"openclipboard\" | \"checksafe\" | \"batchopen\"\n | \"querytabs\" | \"duplicatetab\" | \"closepattern\" | \"pintab\" | \"mutetab\" | \"movetab\"\n | \"movetabwindow\" | \"grouptabs\" | \"colorgroup\" | \"collapsegroup\" | \"discardtab\"\n | \"reloadtabs\" | \"zoomin\" | \"zoomout\" | \"watchtab\" | \"switchtab\" | \"maximizewindow\"\n | \"minimizewindow\" | \"restorewindow\" | \"focuswindow\" | \"scratchwindow\" | \"incognitowindow\"\n | \"restoretab\" | \"savelayout\" | \"restorelayout\" | \"findclones\" | \"searchtabs\"\n | \"badgetab\" | \"attachmeta\" | \"listaudio\" | \"reopenrun\" | \"snapshotsession\"\n | \"fillform\" | \"filllabel\" | \"fillplaceholder\" | \"detectfields\" | \"generatevalues\"\n | \"saveprofiles\" | \"asksubmit\" | \"submitform\" | \"readerrors\" | \"retryform\"\n | \"runwizard\" | \"selectchain\" | \"picktypeahead\" | \"pickdate\" | \"attachfile\"\n | \"handoffcaptcha\" | \"fillcard\" | \"fillcode\" | \"consentpassword\" | \"skiphoneypot\"\n | \"detectlogin\" | \"detecttemplate\"\n | \"scrapetable\" | \"exportcsv\" | \"exportjson\" | \"exportexcel\" | \"copytable\"\n | \"pushsheets\" | \"importcsv\" | \"looprows\" | \"transformvalues\" | \"deduperows\"\n | \"paginateextract\" | \"mergepages\" | \"stamplerows\" | \"previewgrid\"\n | \"streamdisk\" | \"resumeextract\" | \"logprovenance\"\n | \"batchdownload\" | \"pausedownload\" | \"resumedownload\" | \"verifydownload\" | \"interceptmime\"\n | \"exportnetlog\" | \"readclipboard\" | \"writeclipboard\" | \"copyscreen\" | \"quarantinedownload\"\n | \"scanvirus\" | \"namecaptures\" | \"cleanupartifacts\";\n\nexport type actionrisk = \"read\" | \"interaction\" | \"sensitive\";\nexport type planstate = \"draft\" | \"pending\" | \"approved\" | \"rejected\" | \"expired\" | \"completed\" | \"cancelled\";\nexport type auditkind = \"configure\" | \"session\" | \"observe\" | \"proposal\" | \"approval\" | \"action\" | \"error\" | \"stop\" | \"pause\" | \"resume\" | \"complete\" | \"capability\" | \"tab\" | \"window\" | \"download\" | \"pointer\" | \"dialog\" | \"hold\" | \"retry\" | \"observation\" | \"watch\" | \"diff\" | \"navigation\" | \"redirect\" | \"auth\" | \"prefetch\" | \"rate\" | \"group\" | \"layout\" | \"discard\" | \"badge\" | \"fill\" | \"submit\" | \"consent\" | \"handoff\" | \"scrape\" | \"export\" | \"stream\" | \"provenance\" | \"resume\" | \"intercept\" | \"clipboard\" | \"quarantine\" | \"cleanup\";\n\n/** Observation mode classes: passive capture, watched lifetimes and diffing passes. */\nexport type observationmode = \"passive\" | \"watching\" | \"diffing\";\n\nexport interface toolstep {\n id: string;\n kind: actionkind;\n target?: string;\n value?: string;\n /** Reviewed JSON parameters such as modifiers, amounts or coordinates. */\n options?: string;\n summary: string;\n risk: actionrisk;\n}\n\nexport interface agentplan {\n id: string;\n objective: string;\n origin: string;\n steps: toolstep[];\n createdat: number;\n expiresat: number;\n state: planstate;\n approvedat?: number;\n completedat?: number;\n}\n\nexport interface agentsession {\n id: string;\n tabid: number;\n origin: string;\n startedat: number;\n expiresat: number;\n stoppedat?: number;\n pausedat?: number;\n /** Origins granted to this session; prepared for multi origin work. */\n grants?: string[];\n}\n\nexport interface endpointconfig {\n endpoint: string;\n origin: string;\n configuredat: number;\n}\n\nexport interface observation {\n /** Observation schema version for forward compatibility. */\n schemaversion: number;\n url: string;\n title: string;\n textpreview: string;\n textlength: number;\n forms: Array<{ label: string; type: string; name: string; options?: string[] }>;\n interactive: Array<{ selector: string; role: string; label: string }>;\n capturedat: number;\n /** Observation mode of this capture: passive, watching or diffing. */\n mode?: observationmode;\n /** Accessibility tree section captured by the page walker. */\n a11y?: a11ynode;\n /** Reader view article section extracted by the text density heuristic. */\n reader?: readerarticle;\n /** Repeated list patterns detected on the page. */\n listpattern?: listpattern[];\n /** Data table shapes detected on the page. */\n tableshape?: tableshape[];\n /** Snapshot diff section attached when two observation versions are compared. */\n diff?: snapshotdiff;\n}\n\nexport interface auditevent {\n id: string;\n kind: auditkind;\n at: number;\n summary: string;\n sessionid?: string;\n planid?: string;\n stepid?: string;\n}\n\nexport interface diagnosticreport {\n id: string;\n sessionid: string;\n origin: string;\n capturedat: number;\n tabid: number;\n title: string;\n textlength: number;\n interactivecount: number;\n formcount: number;\n bridgeavailable: boolean;\n}\n\n/** Live report of the optional browser capabilities the user has granted. */\nexport interface capabilityreport {\n tabs: boolean;\n downloads: boolean;\n clipboardread: boolean;\n clipboardwrite: boolean;\n reportedat: number;\n}\n\n/** Structured result of one executed step, kept with configurable retention. */\nexport interface stepoutcome {\n stepid: string;\n ok: boolean;\n summary: string;\n details?: Record<string, unknown>;\n at: number;\n}\n\n/** User chosen retention windows; an absent value keeps everything forever. */\nexport interface runsettings {\n auditretention?: number;\n outcomeretention?: number;\n /** Retention window for stored observation captures such as a11y trees and reader articles. */\n observationretention?: number;\n /** User configured ceiling on concurrent task tabs; an absent value never refuses a tab. */\n tasktabceiling?: number;\n /** Retention window for exported data artifacts; an absent value keeps every artifact. */\n artifactretention?: number;\n /** Retention window for captured network log records; an absent value keeps every record. */\n netlogretention?: number;\n /** True when the pinned control tab with the live task feed stays open. */\n controltab?: boolean;\n}\n\nexport interface proposalrequest {\n objective: string;\n session: agentsession;\n observation: observation;\n capabilities: capabilityreport;\n}\n\nexport interface planproposal {\n version: typeof protocolversion;\n plan: agentplan;\n}\n\nexport interface policyevaluation {\n allowed: boolean;\n reason?: string;\n}\n\n/** Tracks which reviewed steps of one plan have already executed locally. */\nexport interface planprogress {\n planid: string;\n completedsteps: string[];\n outcomes?: stepoutcome[];\n /** Tabs assigned to the running task so progress tracks work across its tabs. */\n tasktabs?: number[];\n /** Prior progress snapshots preserved when a new plan replaces the tracked one. */\n prior?: planprogress[];\n updatedat: number;\n}\n\n/** Modes that address one element during target resolution. */\nexport type targetmode = \"selector\" | \"text\" | \"aria\" | \"name\" | \"xpath\" | \"index\" | \"point\";\n\n/** Reviewed element reference resolved by the page bridge at preview and execution time. */\nexport interface targetref {\n mode: targetmode;\n selector?: string;\n text?: string;\n role?: string;\n name?: string;\n xpath?: string;\n index?: number;\n x?: number;\n y?: number;\n}\n\n/** One point on a reviewed pointer path. */\nexport interface pointref {\n x: number;\n y: number;\n}\n\n/** Reviewed pointer path between two points through optional waypoints. */\nexport interface pointpath {\n start: pointref;\n end: pointref;\n waypoints?: pointref[];\n duration?: number;\n}\n\n/** Reviewed pointer speed shape with an easing curve, peak velocity and a jitter window. */\nexport interface speedprofile {\n easing?: \"linear\" | \"easeinout\";\n peak?: number;\n jitter?: number;\n}\n\n/** One key held down across steps under a hold id, with tab and step provenance. */\nexport interface keyholdstate {\n holdid: string;\n key: string;\n modifiers?: string[];\n tabid?: number;\n stepid?: string;\n pressedat: number;\n releasedat?: number;\n}\n\n/** Reviewed answers for confirm, alert and prompt dialogs; prompts need a reviewed answer. */\nexport interface dialogpolicy {\n accept: boolean;\n answer?: string;\n}\n\n/** Ordered frame indexes that address targets inside same origin iframes. */\nexport type framepath = number[];\n\n/** Ordered host selectors that address targets across open shadow roots. */\nexport type shadowpath = string[];\n\n/** Reviewed retry bounds with an attempt count that carries no hardcoded ceiling. */\nexport interface retryrule {\n attempts: number;\n settle?: number;\n tolerance?: number;\n}\n\n/** One numbered clickable element of a clickablemap. */\nexport interface mapentry {\n number: number;\n selector: string;\n role: string;\n label: string;\n mode: targetmode;\n}\n\n/** Numbered map of every clickable element captured inside one observation version. */\nexport interface clickablemap {\n version: number;\n entries: mapentry[];\n builtat: number;\n}\n\n/** Matched element summary attached to step results and review envelopes. */\nexport interface resolvedtarget {\n mode: targetmode;\n selector: string;\n tag: string;\n label: string;\n geometry: { x: number; y: number; width: number; height: number };\n candidates?: string[];\n}\n\n/** One dialog answered by the reviewed dialog policy, kept for the audit trail. */\nexport interface dialogdecision {\n id: string;\n dialog: string;\n text: string;\n accept: boolean;\n answer?: string;\n sessionid?: string;\n at: number;\n}\n\n/** One retry execution record with the attempts made and the movement delta observed between them. */\nexport interface retryoutcome {\n stepid: string;\n attempts: number;\n movement: number;\n ok: boolean;\n at: number;\n}\n\n/** Resolution summary stored per target mode for later selector derivation. */\nexport interface resolutionsummary {\n stepid: string;\n mode: targetmode;\n selector: string;\n label: string;\n at: number;\n}\n\n/** One accessibility tree node with role, accessible name, states, value and child refs. */\nexport interface a11ynode {\n role: string;\n name: string;\n states: string[];\n value?: string;\n childcount: number;\n children: a11ynode[];\n}\n\n/** One reader view article with title, byline, blocks and text statistics. */\nexport interface readerarticle {\n title: string;\n byline: string;\n blocks: Array<{ kind: string; text: string; words: number }>;\n words: number;\n characters: number;\n}\n\n/** One detected repeated list with its shared item selector, repeat count and samples. */\nexport interface listpattern {\n container: string;\n itemselector: string;\n repeat: number;\n samples: string[];\n}\n\n/** One detected data table shape with header row, column specs and caption. */\nexport interface tableshape {\n selector: string;\n headers: string[];\n columns: Array<{ label: string; cells: number }>;\n rows: number;\n caption: string;\n}\n\n/** One embedded json state payload extracted from an inline script. */\nexport interface jsonstate {\n scripturl: string;\n rootpath: string;\n payload: unknown;\n}\n\n/** Reviewed watch registration with selector scopes, event kinds and a lifetime window. */\nexport interface mutationwatch {\n watchid?: string;\n scopes?: string[];\n events?: string[];\n lifetime: number;\n}\n\n/** Reviewed network quiet rule with an idle threshold, poll interval and timeout. */\nexport interface quietrule {\n idle: number;\n poll?: number;\n timeout?: number;\n}\n\n/** One dom mutation observed inside a reviewed watch, with a timestamp and target path. */\nexport interface mutationevent {\n watchid: string;\n event: string;\n targetpath: string;\n sessionid?: string;\n at: number;\n}\n\n/** One focus change observed inside a reviewed focus watch, with a timestamp and target path. */\nexport interface focusevent {\n watchid: string;\n kind: \"focus\" | \"blur\";\n targetpath: string;\n sessionid?: string;\n at: number;\n}\n\n/** One consent banner observed by a reviewed banner watch, with its controls. */\nexport interface bannerreport {\n kind: string;\n selector: string;\n text: string;\n controls: string[];\n sessionid?: string;\n at: number;\n}\n\n/** One node change inside a snapshot diff. */\nexport interface diffentry {\n kind: \"added\" | \"removed\" | \"changed\";\n selector: string;\n summary: string;\n}\n\n/** One snapshot diff between two stored observation versions. */\nexport interface snapshotdiff {\n baseversion: number;\n targetversion: number;\n added: diffentry[];\n removed: diffentry[];\n changed: diffentry[];\n at: number;\n}\n\n/** One derived selector candidate with its strategy and stability score. */\nexport interface selectorcandidate {\n selector: string;\n strategy: string;\n score: number;\n}\n\n/** One derived selector stored with its stability score for reuse. */\nexport interface derivedselector {\n stepid: string;\n selector: string;\n strategy: string;\n score: number;\n at: number;\n}\n\n/** One watch registration persisted so watches survive service worker restarts. */\nexport interface watchregistration {\n watchid: string;\n kind: actionkind;\n stepid: string;\n sessionid: string;\n origin: string;\n scopes: string[];\n events: string[];\n startedat: number;\n lifetime: number;\n closedat?: number;\n}\n\n/** One stored observation capture under its version. */\nexport interface observationrecord {\n version: number;\n observation: observation;\n}\n\n/** One stored accessibility tree capture. */\nexport interface a11ycapture {\n version: number;\n tree: a11ynode;\n capturedat: number;\n}\n\n/** One stored reader article capture. */\nexport interface readercapture {\n version: number;\n article: readerarticle;\n capturedat: number;\n}\n\n/** Live page signals refreshed after observation steps: language, template, scroll lock and banner state. */\nexport interface pagesignals {\n language?: string;\n template?: string;\n scrolllocked?: boolean;\n banner?: string;\n refreshedat: number;\n}\n\n/** One detected template class or section fingerprint stored per origin. */\nexport interface templateprofile {\n origin: string;\n template: string;\n fingerprint: string;\n section?: string;\n at: number;\n}\n\n/** Reviewed navigation target with its url, container, position and private flag. */\nexport interface navtarget {\n url: string;\n container: \"current\" | \"tab\" | \"window\" | \"private\";\n position?: \"adjacent\" | \"end\";\n private: boolean;\n}\n\n/** Reviewed per origin override of one wait profile. */\nexport interface waitoverride {\n origin: string;\n signals?: string[];\n idle?: number;\n timeout?: number;\n}\n\n/** Reviewed wait profile with load signals, thresholds and per origin overrides. */\nexport interface waitprofile {\n signals: string[];\n idle?: number;\n timeout?: number;\n overrides?: waitoverride[];\n}\n\n/** Reviewed url pattern with a match mode plus required query and fragment parts. */\nexport interface urlpattern {\n mode: \"exact\" | \"prefix\" | \"host\" | \"pattern\";\n url: string;\n query?: Record<string, string>;\n fragment?: string;\n}\n\n/** One redirect hop of a redirect chain with its url, status and timestamp. */\nexport interface redirecthop {\n url: string;\n status: number;\n at: number;\n}\n\n/** One observed redirect chain with hops, statuses and timing. */\nexport interface redirectchain {\n hops: redirecthop[];\n startedat: number;\n endedat: number;\n}\n\n/** One navigation trail entry with url, title, step ref and timestamp. */\nexport interface trailentry {\n url: string;\n title: string;\n stepid?: string;\n at: number;\n}\n\n/** Reviewed per domain navigation rate limit with a window and a user configured ceiling. */\nexport interface ratelimit {\n domain: string;\n window: number;\n ceiling: number;\n}\n\n/** Live navigation state of a tab: load phase, final url and redirect chain. */\nexport interface navstate {\n phase: \"idle\" | \"loading\" | \"interactive\" | \"complete\";\n finalurl?: string;\n redirects?: redirectchain;\n}\n\n/** One stored wait profile applied per origin with user configured values. */\nexport interface waitprofilerecord {\n origin: string;\n profile: waitprofile;\n at: number;\n}\n\n/** One stored navigation record with the redirect chain and final url of one navigation step. */\nexport interface navrecord {\n stepid: string;\n sessionid?: string;\n origin: string;\n finalurl: string;\n chain: redirectchain;\n at: number;\n}\n\n/** One recorded navigation intent detected from a plan, kept for audit review. */\nexport interface navintentrecord {\n id: string;\n intent: string;\n origin: string;\n sessionid?: string;\n stepid?: string;\n at: number;\n}\n\n/** One rate limit window state per domain with the reviewed limit and the hit count. */\nexport interface ratelimitstate {\n domain: string;\n limit: ratelimit;\n openedat: number;\n count: number;\n}\n\n/** One curated link of a batch open list with its safety verdict and review state. */\nexport interface curatedlink {\n url: string;\n verdict: \"safe\" | \"unsafe\" | \"unknown\";\n reasons: string[];\n}\n\n/** One curated link list stored with its review state before batch opening. */\nexport interface curatedlist {\n id: string;\n links: curatedlink[];\n reviewedat?: number;\n at: number;\n}\n\n/** Reviewed basic auth credentials for one origin, stored only after explicit review. */\nexport interface authrecord {\n origin: string;\n username: string;\n password: string;\n reviewedat: number;\n}\n\n/** One url safety verdict produced by a checksafe verification. */\nexport interface safetyverdict {\n url: string;\n safe: boolean;\n reasons: string[];\n at: number;\n}\n\n/** One task artifact routed into the artifact store by a printpdf step. */\nexport interface artifactrecord {\n id: string;\n kind: string;\n name: string;\n stepid: string;\n at: number;\n}\n\n/** Navigation control state: paused navigation while a consent prompt is open. */\nexport interface navcontrol {\n pausedat?: number;\n reason?: string;\n updatedat: number;\n}\n\n/** One recently closed tab remembered so a reopentab step can restore it. */\nexport interface recenttab {\n url: string;\n tabid: number;\n closedat: number;\n}\n\n/** Queued navigation targets of prefetch and batch open steps, shown in the popup badge. */\nexport interface navqueues {\n prefetch: number;\n batchopen: number;\n updatedat: number;\n}\n\n/** Reviewed tab query with url, title, id and pattern matchers resolved against the live tab set. */\nexport interface tabquery {\n url?: string;\n title?: string;\n id?: number;\n pattern?: string;\n}\n\n/** Reviewed tab group definition with name, color, member tabs and collapse state. */\nexport interface tabgroupspec {\n name: string;\n color: string;\n tabids: number[];\n collapsed: boolean;\n}\n\n/** One stored tab group definition with its color choice and member tabs. */\nexport interface tabgrouprecord {\n groupid: string;\n name: string;\n color: string;\n tabids: number[];\n collapsed: boolean;\n savedat: number;\n}\n\n/** Window bounds of one window state or saved layout. */\nexport interface windowbounds {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/** Live or saved window state with bounds, maximize state and profile kind. */\nexport interface windowstate {\n bounds: windowbounds;\n maximized: boolean;\n profile: \"normal\" | \"incognito\" | \"scratch\";\n}\n\n/** One tab position inside a saved layout, carrying its window and pin state. */\nexport interface layouttab {\n url: string;\n title: string;\n pinned: boolean;\n index: number;\n windowid: number;\n}\n\n/** One saved tab layout with name, tabs, groups, positions and window bounds. */\nexport interface tablayout {\n name: string;\n tabs: layouttab[];\n groups: tabgroupspec[];\n windows: Array<{ windowid: number; state: windowstate }>;\n savedat: number;\n}\n\n/** Per tab task metadata with task refs, provenance and free text labels. */\nexport interface tabmeta {\n tabid: number;\n taskrefs: string[];\n provenance: string;\n labels: string[];\n at: number;\n}\n\n/** One per tab task status badge set by a badgetab step or refreshed from live progress. */\nexport interface tabbadge {\n tabid: number;\n taskid: string;\n label: string;\n setat: number;\n}\n\n/** One tab report entry carrying audio state and metadata per tab. */\nexport interface tabreportentry {\n tabid: number;\n url: string;\n title: string;\n index: number;\n windowid: number;\n active: boolean;\n pinned: boolean;\n audible: boolean;\n muted: boolean;\n discarded: boolean;\n meta?: tabmeta;\n}\n\n/** Tab report payload with matched tabs, groups and badges. */\nexport interface tabreport {\n matches: tabreportentry[];\n groups: tabgroupspec[];\n badges: tabbadge[];\n}\n\n/** One session snapshot of tabs and windows captured for later restore. */\nexport interface sessionsnapshot {\n id: string;\n sessionid?: string;\n layout: tablayout;\n capturedat: number;\n}\n\n/** One closed tab history entry kept for restoretab and reopenrun. */\nexport interface closedtab {\n url: string;\n title: string;\n tabid: number;\n windowid: number;\n closedat: number;\n}\n\n/** One tab event observed inside a reviewed watchtab registration. */\nexport interface tabwatchevent {\n watchid: string;\n event: \"title\" | \"activated\" | \"closed\";\n tabid: number;\n detail?: string;\n at: number;\n}\n\n/** Pinned control tab state carrying the live task feed. */\nexport interface controltabstate {\n tabid: number;\n enabled: boolean;\n updatedat: number;\n}\n\n/** Field kinds the form family recognizes across inputs, selects, checks and specialized payment fields. */\nexport type fieldkind = \"text\" | \"email\" | \"phone\" | \"date\" | \"number\" | \"select\" | \"check\" | \"radio\" | \"file\" | \"password\" | \"card\" | \"code\";\n\n/** Reviewed field match addressing one control by label, placeholder, aria label or name. */\nexport interface fieldmatch {\n mode: \"label\" | \"placeholder\" | \"arialabel\" | \"name\";\n label?: string;\n placeholder?: string;\n arialabel?: string;\n name?: string;\n}\n\n/** One reviewed form field entry pairing a field match with its kind and value. */\nexport interface formentry {\n match: fieldmatch;\n kind: fieldkind;\n value: string;\n}\n\n/** A reviewed structured form record with field entries, kinds and values. */\nexport interface formrecord {\n form?: string;\n entries: formentry[];\n}\n\n/** Reviewed value generation rules for one field kind with locale and seed choices. */\nexport interface valuegen {\n kind: fieldkind;\n locale?: string;\n seed?: number;\n}\n\n/** One saved form profile with a reviewed name, field entries and the origin grants it is bound to. */\nexport interface formprofile {\n name: string;\n fields: formentry[];\n grants: string[];\n savedat: number;\n}\n\n/** Live wizard state with the step index, the total steps and the per step completion flags. */\nexport interface wizardstate {\n index: number;\n steps: number;\n completed: boolean[];\n at: number;\n}\n\n/** One submission ticket with the form ref, the values hash and the consent ref of its asksubmit approval. */\nexport interface submitticket {\n id: string;\n form: string;\n valueshash: string;\n consentref: string;\n approved?: boolean;\n at: number;\n}\n\n/** One validation error message associated with a field ref. */\nexport interface fielderror {\n field: string;\n message: string;\n}\n\n/** One collected error report of a form, kept for correction loops. */\nexport interface errorreport {\n form: string;\n errors: fielderror[];\n at: number;\n}\n\n/** One captcha handoff record with its resolution state while the plan waits for the user. */\nexport interface captchahandoff {\n id: string;\n origin: string;\n resolved: boolean;\n openedat: number;\n resolvedat?: number;\n}\n\n/** One login or template detection stored per origin with the matched markers. */\nexport interface detectionrecord {\n origin: string;\n kind: \"login\" | \"signup\" | \"checkout\";\n markers: string[];\n at: number;\n}\n\n/** One typeahead pick recorded when a reviewed suggestion entry was chosen. */\nexport interface typeaheadpick {\n field: string;\n query: string;\n pick: string;\n at: number;\n}\n\n/** Form report payload with the detected fields, their kinds and the matched controls. */\nexport interface formreport {\n form: string;\n fields: Array<{ selector: string; label: string; kind: fieldkind; matched: boolean }>;\n}\n\n/** One scraped or imported dataset column with a stable key, its label, its value kind and the normalized name. */\nexport interface columnspec {\n key: string;\n label: string;\n kind: \"text\" | \"number\";\n normalized: string;\n}\n\n/** One dataset row keyed by column keys. */\nexport type datasetrow = Record<string, string>;\n\n/** One source reference attaching a row index to its url, timestamp and step ref. */\nexport interface sourceref {\n row: number;\n url: string;\n at: number;\n stepid?: string;\n}\n\n/** One structured dataset with column specs, rows and source refs; row counts stay user configured with no code ceiling. */\nexport interface dataset {\n id: string;\n name: string;\n columns: columnspec[];\n rows: datasetrow[];\n sources: sourceref[];\n at: number;\n}\n\n/** One reviewed transform rule applying an expression to source columns and writing the target column. */\nexport interface transformrule {\n expression: string;\n sources: string[];\n target: string;\n}\n\n/** One extraction session tracking visited pages, collected rows and the resume cursor. */\nexport interface extractsession {\n id: string;\n datasetid: string;\n name: string;\n target: string;\n next: string;\n planned: number;\n pages: string[];\n rows: number;\n cursor: number;\n done?: boolean;\n startedat: number;\n updatedat: number;\n}\n\n/** One provenance record of an exported artifact with its url, timestamp, step ref, row range and checksum. */\nexport interface provenancerecord {\n artifact: string;\n name: string;\n url: string;\n stepid: string;\n rowstart: number;\n rowend: number;\n checksum: string;\n at: number;\n}\n\n/** One exported data artifact kept in the task artifact store with its content and checksum. */\nexport interface exportedartifact {\n id: string;\n kind: \"csv\" | \"json\" | \"excel\";\n name: string;\n stepid: string;\n rowcount: number;\n content: string;\n checksum: string;\n at: number;\n}\n\n/** One streaming export state with chunk and written row counters persisted for resume. */\nexport interface streamstate {\n datasetid: string;\n name: string;\n chunk: number;\n chunks: number;\n written: number;\n done?: boolean;\n at: number;\n}\n\n/** One reviewed sheet endpoint configuration stored behind its origin grant. */\nexport interface sheetendpoint {\n endpoint: string;\n origin: string;\n configuredat: number;\n}\n\n/** Transform rules and dedupe keys remembered per task between extraction and export. */\nexport interface taskrules {\n taskid: string;\n transforms: transformrule[];\n dedupekeys: string[];\n at: number;\n}\n\n/** One reviewed batch download specification with its url list, filename rule and completion criteria. */\nexport interface downloadspec {\n urls: string[];\n filename?: string;\n complete?: \"size\" | \"checksum\";\n}\n\n/** Per file states of the batch download queue. */\nexport type downloadstate = \"queued\" | \"running\" | \"paused\" | \"complete\" | \"failed\";\n\n/** One batch download file record with its state, resolved path and checksum; concurrent windows stay user configured with no code ceiling. */\nexport interface downloadrecord {\n id: string;\n url: string;\n filename: string;\n state: downloadstate;\n downloadid?: number;\n path?: string;\n bytes?: number;\n checksum?: string;\n at: number;\n updatedat: number;\n}\n\n/** Reviewed mime interception filter with include and exclude patterns and a deny default for unlisted mime types. */\nexport interface mimefilter {\n include: string[];\n exclude: string[];\n default: \"deny\" | \"allow\";\n}\n\n/** One captured network log record with url, method, status, timing and step correlation through its request id. */\nexport interface netlogrecord {\n url: string;\n method: string;\n status: number;\n timing: number;\n requestid?: string;\n stepid: string;\n at: number;\n /** Captured header names; exported netlogs always carry their values redacted. */\n headers?: Record<string, string>;\n}\n\n/** One clipboard entry with its kind, payload hash and origin provenance; the payload text never persists. */\nexport interface clipentry {\n kind: \"read\" | \"write\" | \"screen\";\n hash: string;\n length: number;\n origin: string;\n stepid: string;\n at: number;\n}\n\n/** Verdicts of the configured virus scanning hooks. */\nexport type scanverdict = \"pending\" | \"clean\" | \"flagged\" | \"error\";\n\n/** One quarantined download kept outside the downloads folder with its reason, scan state and release ref. */\nexport interface quarantineentry {\n id: string;\n path: string;\n reason: string;\n scan: scanverdict;\n release?: string;\n at: number;\n updatedat: number;\n}\n\n/** One consistent capture filename stamped from task, step and sequence parts. */\nexport interface capturename {\n task: string;\n step: string;\n sequence: number;\n}\n\n/** One reviewed artifact cleanup rule with an age window, an artifact kind and a keep policy. */\nexport interface cleanuprule {\n age: number;\n kind: string;\n keep: \"none\" | \"latest\" | \"all\";\n}\n\n/** One clipboard consent record with its prompt, origin and single use approval state; every clipboard read needs its own approved prompt. */\nexport interface clipboardconsentrecord {\n id: string;\n prompt: string;\n origin: string;\n stepid: string;\n approved?: boolean;\n usedat?: number;\n at: number;\n}\n\n/** One user configured virus scanning hook endpoint stored behind its origin grant. */\nexport interface scanhookconfig {\n scanner: string;\n endpoint: string;\n origin: string;\n configuredat: number;\n}\n\n/** One stored capture naming counter per task and step base. */\nexport interface capturecounter {\n taskid: string;\n counters: Record<string, number>;\n at: number;\n}\n\n/** One artifact inventory entry for the cleanup sweeper with its size and capture time. */\nexport interface artifactinventoryentry {\n id: string;\n kind: string;\n name: string;\n size: number;\n at: number;\n}\n\n/** One cleanup run history record with the applied rule count and the removed and kept artifact counts. */\nexport interface cleanuprun {\n id: string;\n rules: number;\n removed: number;\n kept: number;\n at: number;\n}\n", "import { actionrisk, parseoptions, submitreviewgranted, validatestep } from \"./policy.js\";\nimport { protocolversion, type agentplan, type bannerreport, type clickablemap, type dataset, type downloadrecord, type errorreport, type extractsession, type focusevent, type formreport, type keyholdstate, type mutationevent, type navstate, type netlogrecord, type observation, type pagesignals, type planproposal, type proposalrequest, type provenancerecord, type quarantineentry, type resolvedtarget, type safetyverdict, type selectorcandidate, type snapshotdiff, type stepoutcome, type tablayout, type tabreport, type toolstep, type trailentry, type transformrule, type typeaheadpick, type wizardstate } from \"./types.js\";\n\nfunction record(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"Protocol message must be an object.\");\n return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, field: string): string {\n if (typeof value !== \"string\" || !value.trim()) throw new Error(`${field} must be a non-empty string.`);\n return value.trim();\n}\n\n/**\n * Reviewed options grammar shared by every step kind.\n *\n * A step may carry a JSON `options` object with the following reviewed fields:\n * - `targetref`: element addressing without a css selector, with `mode` one of `selector`, `text`, `aria`, `name`, `xpath`, `index` or `point`; the text mode carries `text`, the aria mode carries `role` plus `name`, the name mode carries `name`, the xpath mode carries `xpath`, the index mode carries a one based clickable map `index`, and the point mode carries viewport `x` and `y` coordinates.\n * - `pointpath`: pointer travel between two points, with `start` and `end` points, optional `waypoints` and a `duration` in milliseconds.\n * - `speedprofile`: pointer speed shape with `easing` (`linear` or `easeinout`), a `peak` velocity in pixels per second and a `jitter` window in milliseconds.\n * - `framepath`: ordered frame indexes routing a step inside same origin iframes.\n * - `shadow`: ordered host selectors addressing a target across open shadow roots.\n * - `retryrule`: retry bounds with `attempts`, a `settle` window in milliseconds and a movement `tolerance` in pixels; attempts carry no code ceiling.\n * - `dialogpolicy`: dialog answers with an `accept` flag and a reviewed prompt `answer` string.\n * - wrapper steps (`retryaction`, `enterframe`) reference an inner step by `stepid` or inline with `kind`, `target`, `value` and an `options` object.\n * - control kinds add reviewed `delay`, `values`, `results`, `timeout`, `holdid` and `modifiers` fields.\n * - watch kinds (`watchmutate`, `watchbanner`, `watchfocus`) carry a reviewed `lifetime` window in milliseconds, optional selector `scopes`, optional event kind filters `events` and an optional `poll` interval; the lifetime window carries no code ceiling.\n * - `waitquiet` carries a reviewed `quietrule` with a positive `idle` threshold in milliseconds, an optional `poll` interval and an optional `timeout`; every value carries no code ceiling.\n * - `diffsnapshots` carries exactly two reviewed observation `versions` to compare.\n * - navigation kinds carry the navigation parameter grammar: `navtarget` with a `url`, a `container` (`current`, `tab`, `window` or `private`), a `position` (`adjacent` or `end`) and a `private` flag; `waitprofile` with non-empty load `signals`, optional `idle` and `timeout` thresholds and per origin `overrides`; and `urlpattern` with a `mode` (`exact`, `prefix`, `host` or `pattern`), a `url`, optional `query` parameter expectations and an optional `fragment`.\n * - `waiturl` and `spawait` carry a reviewed `urlpattern`, `timeout` and `poll`; `spanav` carries an optional `routepattern`, `followlink` an optional `fragment` flag, `rewritequery` reviewed `set` and `remove` query edits, `navlist`/`prefetch`/`batchopen` reviewed `urls` lists, `preconnect` reviewed `origins`, `navrate` a reviewed `ratelimit` with `domain`, `window` and `ceiling` (never capped in code), and `deeplink` a reviewed `app` pattern with `params`.\n * - observation kinds attach structured evidence to step details: a11y trees, reader articles, list patterns, table shapes, pagination estimates, watch event records, quiet probe samples, snapshot diffs and derived selector candidates with stability scores.\n * - navigation steps attach structured evidence to step details: load phases and ready states, final urls after redirects, redirect chains with statuses and timing, http error, offline and certificate interstitial states, safety verdicts and navlist entry completions.\n * - the tabs and windows command family adds its parameter grammar: `tabquery` with url, title, id and pattern matchers (at least one matcher required, patterns use `*` and `**` wildcards); `group` with a `name`, a Chromium tab group `color`, member `tabids` and a `collapsed` flag; `layout` names for `savelayout` and `restorelayout`; reviewed `pinned`, `muted`, `index`, `windowid`, `direction`, `step`, `bounds`, `label`, `labels`, `taskrefs`, `provenance` and `run` fields; `tabcreate` gains reviewed `background` and `window` options and `windowcreate` gains reviewed `left`, `top`, `width`, `height` and `state` options; `closepattern` requires the explicit `reviewed` flag before any tab closes.\n * - tab command steps attach structured evidence to step details: tab reports with matched tabs carrying audio state and metadata, group registries, badge states, layout snapshots, clone warnings, discard candidates and watchtab event records.\n * - the forms and data family adds its parameter grammar: `formrecord` with an optional `form` selector and non-empty `entries` of `{ match, kind, value }` where `match` is a `fieldmatch` with `mode` one of `label`, `placeholder`, `arialabel` or `name`; `valuegen` with a field `kind`, an optional `locale` and an optional numeric `seed`; `fields` lists of label or placeholder value pairs for filllabel and fillplaceholder; a reviewed `name` plus `formrecord` for saveprofiles; a reviewed `consentref` for submitform and consentpassword; a reviewed `backoff` rule with `wait` and `factor` plus an optional `attempts` for retryform with no code ceiling; a reviewed `child` selector, `pick` entry, `pause` and `timeout` for chains, typeaheads and card typing; reviewed card `segments`; and a reviewed `source` for fillcode; password entries inside form records are refused because passwords need the explicit consentpassword consent.\n * - form steps attach structured evidence to step details: form reports with detected fields, kinds and matched controls, error reports with field refs and messages, wizard states with step history, typeahead picks, honeypot flags, login detections with session link markers and signup or checkout template detections.\n * - the forms and data part two family adds its parameter grammar: `scrapetable` and `paginateextract` carry an optional dataset `name`, an optional positive integer `rowlimit` (never capped in code), a reviewed `next` control selector, an optional positive integer `pages` count (never capped in code) and an optional `wait` row freshness window; the export kinds (`exportcsv`, `exportjson`, `exportexcel`, `copytable`, `streamdisk`, `pushsheets`) carry a reviewed `dataset` id, an optional artifact `name`, an optional single character csv `delimiter`, a reviewed positive integer streaming `chunk` size (never capped in code) and, for sheet pushes, a reviewed HTTPS `sheet` endpoint plus the explicit `reviewed` flag; `importcsv` carries reviewed `csv` text with an optional `name` and a `mapping` object of csv headers to target keys; `looprows` carries a reviewed `dataset` id, an optional row `variable` name and a wrapped inner step by `stepid` or inline; `transformvalues` carries reviewed `rules` of `{ expression, sources, target }` where the expression is `trim`, `upper`, `lower`, `number`, `prefix:x`, `suffix:x` or `replace:from=>to`; `deduperows` carries reviewed dedupe `keys`; `mergepages` carries a reviewed `datasets` id list; `stamplerows` carries a reviewed `dataset` id with an optional `url`; `previewgrid` carries a reviewed `dataset` id with an optional `sample` row count (never capped in code); `resumeextract` carries a reviewed `session` id; and `logprovenance` carries a reviewed `artifact` id or name.\n * - data steps attach structured evidence to step details: scraped grids with normalized column specs, span filled rows and nested child datasets, pagination page counts with remaining next controls, dataset previews with sampled rows, dedupe removed counts, transform error lists, stream chunk states and provenance records with checksums and row ranges.\n * - the files, clipboard and downloads family adds its parameter grammar: `batchdownload` carries a reviewed `downloadspec` with a non-empty `urls` list, an optional `filename` rule and an optional `complete` criterion (`size` or `checksum`) plus an optional positive integer `concurrent` window (never capped in code); `pausedownload`, `resumedownload`, `verifydownload`, `quarantinedownload` and `scanvirus` carry a reviewed download or quarantine reference with optional `checksum`, `bytes`, `scanner` and `reason` fields; `interceptmime` carries a reviewed `mimefilter` with non-empty `include` patterns, optional `exclude` patterns and the `deny` or `allow` default for unlisted mime types; `readclipboard` carries a reviewed `consentref` plus an optional `prompt`; `exportnetlog` carries an optional `stepid` filter; `namecaptures` carries a reviewed `task` with optional `steps` and `extension`; and `cleanupartifacts` carries reviewed `rules` of `{ age, kind, keep }` where the age window carries no code ceiling and the keep policy is `none`, `latest` or `all`.\n * - files steps attach structured evidence to step details: batch download reports with per file states, resolved paths and checksums, verification match results, netlog records correlated with steps through request ids, clipboard entries with payload hashes and origin provenance (the payload text never appears), quarantine entries with scan verdicts and release refs, capture names stamped from task, step and sequence parts, and cleanup run outcomes with removed and kept counts.\n *\n * Ambiguous text, aria or name resolutions are refused at execution time with the candidate list so the user can choose.\n */\n\n/** Validates agent output before it becomes a locally reviewable plan. Plans may carry any number of steps. */\nexport function parseproposal(value: unknown, origin: string): planproposal {\n const root = record(value);\n if (root.version !== protocolversion) throw new Error(\"Unsupported protocol version.\");\n const planinput = record(root.plan);\n const stepsinput = planinput.steps;\n if (!Array.isArray(stepsinput) || stepsinput.length === 0) throw new Error(\"A plan needs at least one step.\");\n const steps: toolstep[] = stepsinput.map((input, index) => {\n const candidate = record(input);\n const kind = text(candidate.kind, `step ${index + 1} kind`) as toolstep[\"kind\"];\n const step: toolstep = {\n id: typeof candidate.id === \"string\" ? candidate.id : crypto.randomUUID(),\n kind,\n summary: text(candidate.summary, `step ${index + 1} summary`),\n risk: actionrisk(kind),\n ...(typeof candidate.target === \"string\" ? { target: candidate.target } : {}),\n ...(typeof candidate.value === \"string\" ? { value: candidate.value } : {}),\n ...(typeof candidate.options === \"string\" ? { options: candidate.options } : {}),\n };\n const evaluation = validatestep(step, origin);\n if (!evaluation.allowed) throw new Error(evaluation.reason);\n return step;\n });\n for (const step of steps) {\n if (step.kind !== \"retryaction\" && step.kind !== \"enterframe\" && step.kind !== \"looprows\") continue;\n const options = parseoptions(step);\n if (typeof options.stepid === \"string\" && !steps.some(candidate => candidate.id === options.stepid)) throw new Error(\"A retry, frame or loop wrapper references an unknown step id.\");\n }\n for (const step of steps) {\n if (step.kind !== \"submitform\" && step.kind !== \"retryform\") continue;\n const review = submitreviewgranted(steps, step.id);\n if (!review.allowed) throw new Error(review.reason);\n }\n const createdat = Date.now();\n const expiresat = typeof planinput.expiresat === \"number\" ? planinput.expiresat : createdat + 10 * 60 * 1000;\n const plan: agentplan = {\n id: typeof planinput.id === \"string\" ? planinput.id : crypto.randomUUID(),\n objective: text(planinput.objective, \"objective\"),\n origin,\n steps,\n createdat,\n expiresat,\n state: \"pending\",\n };\n if (plan.expiresat <= createdat) throw new Error(\"Plan expiry must be in the future.\");\n return { version: protocolversion, plan };\n}\n\n/** Shapes the only data that may be sent to a user-configured agent endpoint. */\nexport function requestbody(input: proposalrequest): string {\n return JSON.stringify({ version: protocolversion, objective: input.objective, session: input.session, observation: input.observation, capabilities: input.capabilities });\n}\n\n/** Wraps one executed step outcome in the versioned response envelope for callers, attaching the matched element summary for review. */\nexport function outcomeresponse(input: { outcome: stepoutcome; plan: agentplan; resolvedtarget?: resolvedtarget }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, outcome: input.outcome, ...(input.resolvedtarget ? { resolvedtarget: input.resolvedtarget } : {}) });\n}\n\n/** Wraps a clickable map payload with numbered entries in the versioned response envelope. */\nexport function mapresponse(input: { map: clickablemap; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, map: input.map });\n}\n\n/** Reports the keys currently held on one tab for the live context envelope, refreshed per step. */\nexport function heldkeysreport(input: { tabid: number; holds: keyholdstate[] }): { version: typeof protocolversion; tabid: number; heldkeys: keyholdstate[] } {\n return { version: protocolversion, tabid: input.tabid, heldkeys: input.holds };\n}\n\n/** Wraps one observation capture with its a11y, reader, listpattern, tableshape and diff sections in the versioned response envelope. */\nexport function observationresponse(input: { observation: observation; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, observation: input.observation });\n}\n\n/** Wraps mutation, focus and banner event records with their timestamps and target paths in the versioned response envelope. */\nexport function eventresponse(input: { events: Array<mutationevent | focusevent | bannerreport>; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, events: input.events });\n}\n\n/** Wraps one snapshot diff with its added, removed and changed nodes and its two observation versions in the versioned response envelope. */\nexport function diffresponse(input: { diff: snapshotdiff; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, diff: input.diff });\n}\n\n/** Reports the detected page language, template class, scroll lock and banner state in the live context envelope. */\nexport function signalsreport(input: { signals?: pagesignals }): { version: typeof protocolversion; language?: string; template?: string; scrolllocked?: boolean; banner?: string } {\n const signals = input.signals;\n return {\n version: protocolversion,\n ...(signals && signals.language !== undefined ? { language: signals.language } : {}),\n ...(signals && signals.template !== undefined ? { template: signals.template } : {}),\n ...(signals && signals.scrolllocked !== undefined ? { scrolllocked: signals.scrolllocked } : {}),\n ...(signals && signals.banner !== undefined ? { banner: signals.banner } : {}),\n };\n}\n\n/** Wraps derived selector candidates with their stability scores in the versioned response envelope. */\nexport function selectorresponse(input: { candidates: selectorcandidate[]; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, candidates: input.candidates });\n}\n\n/** Wraps the live navigation state with its load phase, final url and redirect chain in the versioned response envelope. */\nexport function navstateresponse(input: { navstate: navstate; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, navstate: input.navstate });\n}\n\n/** Carries the navigation trail of a session with its visited urls, titles and step refs in the session context envelope. */\nexport function trailreport(input: { sessionid?: string; trail: trailentry[] }): { version: typeof protocolversion; sessionid?: string; trail: trailentry[] } {\n return { version: protocolversion, ...(input.sessionid ? { sessionid: input.sessionid } : {}), trail: input.trail };\n}\n\n/** Wraps url safety verdicts with their reasons in the versioned response envelope for external link review. */\nexport function safetyresponse(input: { verdicts: safetyverdict[]; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, verdicts: input.verdicts });\n}\n\n/** Wraps one tab report with its matched tabs, groups and badges in the versioned response envelope. */\nexport function tabreportresponse(input: { report: tabreport; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, report: input.report });\n}\n\n/** Carries the saved tab layouts with their window bounds and group states in the session context envelope. */\nexport function layoutreport(input: { layouts: tablayout[] }): { version: typeof protocolversion; layouts: tablayout[] } {\n return { version: protocolversion, layouts: input.layouts };\n}\n\n/** Wraps one form report with the detected fields, their kinds and the matched controls in the versioned response envelope. */\nexport function formreportresponse(input: { report: formreport; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, report: input.report });\n}\n\n/** Wraps one collected error report with its field refs and messages in the versioned response envelope for correction loops. */\nexport function errorreportresponse(input: { report: errorreport; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, report: input.report });\n}\n\n/** Carries the wizard states with their step history and the recorded typeahead picks in the session context envelope. */\nexport function wizardreport(input: { sessionid?: string; wizards: wizardstate[]; picks: typeaheadpick[] }): { version: typeof protocolversion; sessionid?: string; wizards: wizardstate[]; picks: typeaheadpick[] } {\n return { version: protocolversion, ...(input.sessionid ? { sessionid: input.sessionid } : {}), wizards: input.wizards, picks: input.picks };\n}\n\n/** Wraps one dataset payload with its column specs and a sampled row list in the versioned response envelope. */\nexport function datasetresponse(input: { dataset: dataset; plan: agentplan; sample?: number }): string {\n const sample = Math.max(0, Math.floor(input.sample ?? 10));\n const payload = { ...input.dataset, rows: input.dataset.rows.slice(0, sample), totalrows: input.dataset.rows.length };\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, dataset: payload });\n}\n\n/** Carries the extraction progress with visited page counts, collected row counts and resume cursors in the session context envelope. */\nexport function extractionreport(input: { sessions: extractsession[] }): { version: typeof protocolversion; sessions: extractsession[] } {\n return { version: protocolversion, sessions: input.sessions };\n}\n\n/** Reports the provenance records of every exported artifact with its source url, step ref, row range and checksum in the session context envelope. */\nexport function provenancereport(input: { records: provenancerecord[] }): { version: typeof protocolversion; records: provenancerecord[] } {\n return { version: protocolversion, records: input.records };\n}\n\n/** Documents the reviewed transform rule grammar shared by transformvalues steps and the task rules store. */\nexport function transformgrammar(rules: transformrule[]): string {\n return JSON.stringify({ rules: rules.map(rule => ({ expression: rule.expression, sources: rule.sources, target: rule.target })) });\n}\n\n/** Wraps the batch download queue with per file states, resolved paths and checksums in the versioned response envelope. */\nexport function downloadreport(input: { downloads: downloadrecord[]; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, downloads: input.downloads });\n}\n\n/** Carries the captured network log records with their step correlation through request ids in the session context envelope. */\nexport function netlogreport(input: { records: netlogrecord[] }): { version: typeof protocolversion; records: netlogrecord[] } {\n return { version: protocolversion, records: input.records };\n}\n\n/** Carries the quarantine entries with their scan verdicts and release refs in the session context envelope. */\nexport function quarantinereport(input: { ent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,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,MAAM,GAAG,MAAM,GAAG,WAAW,MAAM,QAAQ,KAAK,OAAO;AACpH,SAAO,KAAK,UAAU,EAAE,SAAS,iBAAiB,QAAQ,MAAM,KAAK,IAAI,WAAW,MAAM,KAAK,OAAO,SAAS,QAAQ,CAAC;AAC1H;AAGO,SAAS,iBAAiB,OAAwG;AACvI,SAAO,EAAE,SAAS,iBAAiB,UAAU,MAAM,SAAS;AAC9D;AAGO,SAAS,iBAAiB,OAA0G;AACzI,SAAO,EAAE,SAAS,iBAAiB,SAAS,MAAM,QAAQ;AAC5D;AAGO,SAAS,iBAAiB,OAAgC;AAC/D,SAAO,KAAK,UAAU,EAAE,OAAO,MAAM,IAAI,WAAS,EAAE,YAAY,KAAK,YAAY,SAAS,KAAK,SAAS,QAAQ,KAAK,OAAO,EAAE,EAAE,CAAC;AACnI;AAGO,SAAS,eAAe,OAAiE;AAC9F,SAAO,KAAK,UAAU,EAAE,SAAS,iBAAiB,QAAQ,MAAM,KAAK,IAAI,WAAW,MAAM,KAAK,OAAO,WAAW,MAAM,UAAU,CAAC;AACpI;AAGO,SAAS,aAAa,OAAkG;AAC7H,SAAO,EAAE,SAAS,iBAAiB,SAAS,MAAM,QAAQ;AAC5D;AAGO,SAAS,iBAAiB,OAAwG;AACvI,SAAO,EAAE,SAAS,iBAAiB,SAAS,MAAM,QAAQ;AAC5D;",
6
- "names": ["record", "record"]
3
+ "sources": ["../capture.ts", "../media.ts", "../memory.ts", "../policy.ts", "../version.ts", "../types.ts", "../protocol.ts"],
4
+ "sourcesContent": ["import type { captureexport, captureformat, capturenaming, captureoptions, regionrect, sheetlayout, shotpair, shotrecord, stitchplan } from \"./types.js\";\n\n/**\n * Media capture logics for the 1.1.40 family.\n * Every correlated rule for the capture options defaults, the stitch tiling and seam blending, the fixed header skip, the pixel ratio scaling, the element crop and viewport fallback, the region container steps, the contact sheet grid, the annotation plan, the capture naming rule and the before and after state pairing lives in this file.\n */\n\n/** Formats every capture kind may produce; the policy grammar refuses anything outside this set. */\nexport const captureformats: captureformat[] = [\"png\", \"jpeg\", \"webp\"];\n\n/** Export targets a reviewed capture may route to; disk writes stay inside the reviewed download flow. */\nexport const capturetargets: captureexport[] = [\"memory\", \"download\", \"clipboard\"];\n\n/** The capture kinds of the 1.1.40 family, listed among the available capabilities of every proposal request. */\nexport const capturekinds: string[] = [\"shotview\", \"shotfullpage\", \"shotelement\", \"shotregion\", \"contactsheet\"];\n\n/** Normalizes reviewed capture options with png, pixel ratio one and the memory export target as defaults. */\nexport function captureoptionsof(value: unknown): captureoptions {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const options = value as Record<string, unknown>;\n const normalized: captureoptions = {};\n if (options.format === \"png\" || options.format === \"jpeg\" || options.format === \"webp\") normalized.format = options.format;\n if (typeof options.quality === \"number\" && Number.isFinite(options.quality)) normalized.quality = options.quality;\n if (typeof options.pixelratio === \"number\" && Number.isFinite(options.pixelratio)) normalized.pixelratio = options.pixelratio;\n if (typeof options.annotate === \"boolean\") normalized.annotate = options.annotate;\n if (options.exporttarget === \"memory\" || options.exporttarget === \"download\" || options.exporttarget === \"clipboard\") normalized.exporttarget = options.exporttarget;\n return normalized;\n}\n\n/** Builds one shotrecord for a visible viewport capture with the reviewed geometry and byte size. */\nexport function capturevisible(input: { runid: string; stepid: string; options: captureoptions; viewport: { width: number; height: number }; dataurl: string; at: number; id: string; name?: string; target?: string }): shotrecord {\n const ratio = input.options.pixelratio ?? 1;\n return {\n id: input.id,\n runid: input.runid,\n stepid: input.stepid,\n kind: \"shotview\",\n format: input.options.format ?? \"png\",\n width: Math.round(input.viewport.width * ratio),\n height: Math.round(input.viewport.height * ratio),\n capturedat: input.at,\n bytes: input.dataurl,\n ...(input.name !== undefined ? { name: input.name } : {}),\n ...(input.options.annotate === true ? { annotated: true } : {}),\n ...(input.options.exporttarget !== undefined ? { exporttarget: input.options.exporttarget } : {}),\n ...(input.target !== undefined ? { target: input.target } : {}),\n };\n}\n\n/** Builds one shotrecord for a stitched full page capture from the tile plan geometry. */\nexport function capturestitched(input: { runid: string; stepid: string; options: captureoptions; plan: stitchplan; dataurl: string; at: number; id: string; name?: string }): shotrecord {\n const ratio = input.options.pixelratio ?? 1;\n return {\n id: input.id,\n runid: input.runid,\n stepid: input.stepid,\n kind: \"shotfullpage\",\n format: input.options.format ?? \"png\",\n width: Math.round(input.plan.scrollwidth * ratio),\n height: Math.round(input.plan.scrollheight * ratio),\n capturedat: input.at,\n bytes: input.dataurl,\n ...(input.name !== undefined ? { name: input.name } : {}),\n ...(input.options.annotate === true ? { annotated: true } : {}),\n ...(input.options.exporttarget !== undefined ? { exporttarget: input.options.exporttarget } : {}),\n };\n}\n\n/** Builds one shotrecord for an element capture cropped to the pixel ratio scaled element bounds. */\nexport function captureelement(input: { runid: string; stepid: string; options: captureoptions; rect: regionrect; dataurl: string; at: number; id: string; name?: string; target?: string }): shotrecord {\n const ratio = input.options.pixelratio ?? 1;\n const scaled = scaledrect(input.rect, ratio);\n return {\n id: input.id,\n runid: input.runid,\n stepid: input.stepid,\n kind: \"shotelement\",\n format: input.options.format ?? \"png\",\n width: scaled.width,\n height: scaled.height,\n capturedat: input.at,\n bytes: input.dataurl,\n ...(input.name !== undefined ? { name: input.name } : {}),\n ...(input.options.annotate === true ? { annotated: true } : {}),\n ...(input.options.exporttarget !== undefined ? { exporttarget: input.options.exporttarget } : {}),\n ...(input.target !== undefined ? { target: input.target } : {}),\n };\n}\n\n/** Builds one shotrecord for a region capture of one reviewed rectangle or scrollable container. */\nexport function captureregion(input: { runid: string; stepid: string; options: captureoptions; rect: regionrect; dataurl: string; at: number; id: string; name?: string; target?: string }): shotrecord {\n const ratio = input.options.pixelratio ?? 1;\n const scaled = scaledrect(input.rect, ratio);\n return {\n id: input.id,\n runid: input.runid,\n stepid: input.stepid,\n kind: \"shotregion\",\n format: input.options.format ?? \"png\",\n width: scaled.width,\n height: scaled.height,\n capturedat: input.at,\n bytes: input.dataurl,\n ...(input.name !== undefined ? { name: input.name } : {}),\n ...(input.options.annotate === true ? { annotated: true } : {}),\n ...(input.options.exporttarget !== undefined ? { exporttarget: input.options.exporttarget } : {}),\n ...(input.target !== undefined ? { target: input.target } : {}),\n };\n}\n\n/** Links a before and an after shot into one shotpair with the action context and the dom snapshot id of the same moment; a missing after shot skips the pair. */\nexport function pairstates(before: shotrecord | undefined, after: shotrecord | undefined, action: { kind: string; target?: string; domsnapshotid?: string }, at: number, id: string): { pair?: shotpair; skipped?: \"before\" | \"after\"; reason: string } {\n if (!before) return { skipped: \"before\", reason: \"The before shot was not captured, so no state pair exists.\" };\n if (!after) return { skipped: \"after\", reason: `The action of kind ${action.kind} failed before the after shot, so the state pair is skipped.` };\n return {\n pair: {\n id,\n beforeid: before.id,\n afterid: after.id,\n actionkind: action.kind,\n ...(action.target !== undefined ? { target: action.target } : {}),\n ...(action.domsnapshotid !== undefined ? { domsnapshotid: action.domsnapshotid } : {}),\n at,\n },\n reason: `Paired the before shot ${before.id} with the after shot ${after.id} around the ${action.kind} action.`,\n };\n}\n\n/** Applies the capture policy around one action: beforeafter pairs wrap the action, every other mode leaves the pair to the manual capture kinds. */\nexport function capturestates(input: { policy: string; before?: shotrecord | undefined; after?: shotrecord | undefined; actionkind: string; target?: string | undefined; domsnapshotid?: string | undefined; at: number; id: string }): { pair?: shotpair; skipped?: \"before\" | \"after\"; reason: string } {\n if (input.policy !== \"beforeafter\") return { reason: `The ${input.policy} capture policy takes no state pair around the ${input.actionkind} action.` };\n return pairstates(input.before, input.after, { kind: input.actionkind, ...(input.target !== undefined ? { target: input.target } : {}), ...(input.domsnapshotid !== undefined ? { domsnapshotid: input.domsnapshotid } : {}) }, input.at, input.id);\n}\n\n/** Builds the viewport tiling of one full page capture: a tile grid of scroll offsets with overlap rows; the last tile clamps to the page end. */\nexport function buildstitchplan(input: { scrollwidth: number; scrollheight: number; viewportwidth: number; viewportheight: number; overlap?: number }): stitchplan {\n const overlap = Math.max(0, Math.round(input.overlap ?? 0));\n const stepy = Math.max(1, input.viewportheight - overlap);\n const columns = Math.max(1, Math.ceil(input.scrollwidth / input.viewportwidth));\n const rows = input.scrollheight <= input.viewportheight ? 1 : Math.max(1, Math.ceil((input.scrollheight - overlap) / stepy));\n const tiles: Array<{ x: number; y: number }> = [];\n for (let column = 0; column < columns; column += 1) {\n for (let row = 0; row < rows; row += 1) {\n const x = Math.min(column * input.viewportwidth, Math.max(0, input.scrollwidth - input.viewportwidth));\n const y = rows === 1 ? 0 : Math.min(row * stepy, Math.max(0, input.scrollheight - input.viewportheight));\n tiles.push({ x: Math.round(x), y: Math.round(y) });\n }\n }\n return { columns, rows, tiles, overlap, scrollwidth: Math.round(input.scrollwidth), scrollheight: Math.round(input.scrollheight), viewportwidth: Math.round(input.viewportwidth), viewportheight: Math.round(input.viewportheight) };\n}\n\n/** Linear cross fade weights across one overlap band: the first row keeps the existing content, the last row adopts the new tile. */\nexport function seamweights(overlap: number): number[] {\n if (overlap <= 0) return [];\n const weights: number[] = [];\n for (let index = 0; index < overlap; index += 1) weights.push((index + 1) / (overlap + 1));\n return weights;\n}\n\n/** Blends one overlap band of equal length row arrays with the linear seam weights so tile seams never hard cut. */\nexport function blendrows(upper: number[], lower: number[]): number[] {\n const weights = seamweights(upper.length);\n return upper.map((value, index) => {\n const weight = weights[index] ?? 1;\n return value * (1 - weight) + (lower[index] ?? value) * weight;\n });\n}\n\n/** True when a tile band repeats the first tile band, so the stitcher skips it and fixed headers never repeat across tiles. */\nexport function fixedheadermatch(band: number[], firstband: number[]): boolean {\n if (band.length === 0 || band.length !== firstband.length) return false;\n return band.every((value, index) => value === firstband[index]);\n}\n\n/** Scales one css pixel rectangle by the reviewed pixel ratio; ratios of one, two and three scale every edge. */\nexport function scaledrect(rect: regionrect, pixelratio: number): regionrect {\n const ratio = pixelratio >= 1 ? pixelratio : 1;\n return { x: Math.round(rect.x * ratio), y: Math.round(rect.y * ratio), width: Math.round(rect.width * ratio), height: Math.round(rect.height * ratio) };\n}\n\n/** Clamps one rectangle to the visible part of the viewport, never returning negative geometry. */\nexport function croprect(rect: regionrect, viewport: { width: number; height: number }): regionrect {\n const x = Math.max(0, rect.x);\n const y = Math.max(0, rect.y);\n return { x: Math.round(x), y: Math.round(y), width: Math.round(Math.max(0, Math.min(rect.width, viewport.width - x))), height: Math.round(Math.max(0, Math.min(rect.height, viewport.height - y))) };\n}\n\n/** True when an element rectangle crosses any viewport edge and the capture falls back to tiled capture. */\nexport function crossesviewport(rect: regionrect, viewport: { width: number; height: number }): boolean {\n return rect.x < 0 || rect.y < 0 || rect.x + rect.width > viewport.width || rect.y + rect.height > viewport.height;\n}\n\n/** Scroll tops that walk a scrollable container in reviewed steps; every step clamps so the last window ends at the container end. */\nexport function regionsteps(containerheight: number, viewportstep: number): number[] {\n if (containerheight <= 0 || viewportstep <= 0) return [0];\n const steps: number[] = [];\n for (let top = 0; top < containerheight; top += viewportstep) {\n const clamped = Math.min(top, Math.max(0, containerheight - viewportstep));\n if (!steps.includes(clamped)) steps.push(clamped);\n }\n return steps;\n}\n\n/** One placed cell of a contact sheet grid with its caption stamped from the reviewed label style. */\nexport interface sheetcell {\n index: number;\n column: number;\n row: number;\n selector: string;\n label: string;\n caption: string;\n}\n\n/** Places the element captures of a contact sheet on a labeled grid; the cell count stays a user choice with no code ceiling. */\nexport function buildsheet(cells: Array<{ selector: string; label?: string }>, layout: sheetlayout): { columns: number; rows: number; cells: sheetcell[] } {\n const columns = Math.max(1, Math.round(layout.columns));\n const rows = Math.max(1, Math.ceil(cells.length / columns));\n const placed: sheetcell[] = cells.map((cell, index) => {\n const column = index % columns;\n const row = Math.floor(index / columns);\n const label = cell.label ?? \"\";\n const caption = layout.label === \"none\" ? \"\" : layout.label === \"index\" ? `${index + 1}` : layout.label === \"selector\" ? cell.selector : label ? `${index + 1} \u00B7 ${cell.selector} \u00B7 ${label}` : `${index + 1} \u00B7 ${cell.selector}`;\n return { index, column, row, selector: cell.selector, label, caption };\n });\n return { columns, rows, cells: placed };\n}\n\n/** Slugifies one capture name part into a filename safe lowercase form. */\nfunction capturepart(value: string): string {\n return value.replace(/[^a-z0-9-]+/gi, \"-\").replace(/^-+|-+$/g, \"\").toLowerCase() || \"capture\";\n}\n\n/** Builds one capture filename from the reviewed naming rule segments; the sequence counter keeps every name unique inside a run. */\nexport function buildname(rule: capturenaming, parts: { run: string; step: string; sequence: number; kind: string }, extension: string): string {\n const segments: string[] = [];\n if (rule.run) segments.push(capturepart(parts.run));\n if (rule.step) segments.push(capturepart(parts.step));\n if (rule.sequence) segments.push(String(Math.max(0, Math.round(parts.sequence))));\n if (rule.kind) segments.push(capturepart(parts.kind));\n const safeextension = extension.replace(/^\\.+/, \"\").toLowerCase() || \"png\";\n return `${(segments.length > 0 ? segments : [\"capture\"]).join(\"-\")}.${safeextension}`;\n}\n\n/** One annotation plan for a captured image: the step number marker, the optional target outline and the footer with capture time and page url. */\nexport interface annotationplan {\n marker: { x: number; y: number; number: number };\n outline?: regionrect;\n footer: string;\n}\n\n/** Plans the annotations of one capture: the step number marker position, the expanded target rect outline and the footer text with capture time and url. */\nexport function annotationplanof(input: { step: number; width: number; height: number; rect?: regionrect; url: string; at: number }): annotationplan {\n const inset = Math.min(24, Math.max(8, Math.round(Math.min(input.width, input.height) / 12)));\n const plan: annotationplan = {\n marker: { x: inset, y: inset, number: Math.max(1, Math.round(input.step)) },\n footer: `${new Date(input.at).toISOString()} \u00B7 ${input.url}`,\n };\n if (input.rect !== undefined) {\n const expansion = 2;\n plan.outline = { x: Math.round(input.rect.x - expansion), y: Math.round(input.rect.y - expansion), width: Math.round(input.rect.width + expansion * 2), height: Math.round(input.rect.height + expansion * 2) };\n }\n return plan;\n}\n", "import type { assetrecord, captureformat, capturenaming, convertdirective, imagefilter, imagedescriptor, mediadatum, pdfoptions, recordingoptions, recordingrecord, streamrecord, thumbdirective } from \"./types.js\";\nimport { buildname } from \"./capture.js\";\n\n/**\n * Media capture part two logics for the 1.1.41 family.\n * Every correlated rule for the derived pdf composition with reviewed paper sizes, margins and pagination break points, the recording records with their frame intervals and clean stops, the image filter matching with url deduplication and counter names, the lapse frame ordering, the conversion and thumbnail geometry and the raw media, asset and stream normalization lives in this file.\n */\n\n/** The media capture part two kinds, listed among the available capabilities of every proposal request. */\nexport const mediakinds: string[] = [\"capturepdf\", \"recordscreen\", \"captureaudio\", \"captureframe\", \"downloadimages\", \"shotcanvas\", \"probestream\", \"readmedia\", \"readassets\", \"timelapse\", \"convertimage\", \"makethumbs\"];\n\n/** Default paper size in inches when the reviewed options leave it open: us letter portrait. */\nconst defaultpaperwidth = 8.5;\nconst defaultpaperheight = 11;\n\n/** Default page margins in inches when the reviewed options leave them open. */\nconst defaultmargins = { top: 0.4, right: 0.4, bottom: 0.4, left: 0.4 };\n\n/** Points per paper inch of the pdf coordinate space. */\nconst pdfpointsperinch = 72;\n\n/** Base body font size in points that the reviewed scale multiplies. */\nconst basefontsize = 11;\n\n/** Normalizes reviewed pdf options with paper defaults; unknown fields stay ignored. */\nexport function pdfoptionsof(value: unknown): pdfoptions {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const options = value as Record<string, unknown>;\n const normalized: pdfoptions = {};\n if (typeof options.paperwidth === \"number\" && Number.isFinite(options.paperwidth)) normalized.paperwidth = options.paperwidth;\n if (typeof options.paperheight === \"number\" && Number.isFinite(options.paperheight)) normalized.paperheight = options.paperheight;\n if (options.margins && typeof options.margins === \"object\" && !Array.isArray(options.margins)) {\n const margins = options.margins as Record<string, unknown>;\n const top = typeof margins.top === \"number\" ? margins.top : defaultmargins.top;\n const right = typeof margins.right === \"number\" ? margins.right : defaultmargins.right;\n const bottom = typeof margins.bottom === \"number\" ? margins.bottom : defaultmargins.bottom;\n const left = typeof margins.left === \"number\" ? margins.left : defaultmargins.left;\n normalized.margins = { top, right, bottom, left };\n }\n if (typeof options.scale === \"number\" && Number.isFinite(options.scale)) normalized.scale = options.scale;\n if (typeof options.landscape === \"boolean\") normalized.landscape = options.landscape;\n if (typeof options.paginate === \"boolean\") normalized.paginate = options.paginate;\n return normalized;\n}\n\n/** Resolves the pdf page size in points after the landscape swap. */\nexport function pdfpagesize(options: pdfoptions): { width: number; height: number } {\n const width = (options.paperwidth ?? defaultpaperwidth) * pdfpointsperinch;\n const height = (options.paperheight ?? defaultpaperheight) * pdfpointsperinch;\n return options.landscape === true ? { width: height, height: width } : { width, height };\n}\n\n/** Resolves the reviewed margins in points. */\nfunction pdfmargins(options: pdfoptions): { top: number; right: number; bottom: number; left: number } {\n const margins = options.margins ?? defaultmargins;\n return { top: margins.top * pdfpointsperinch, right: margins.right * pdfpointsperinch, bottom: margins.bottom * pdfpointsperinch, left: margins.left * pdfpointsperinch };\n}\n\n/** Resolves the body font size in points from the reviewed scale with no code ceiling on the scale itself. */\nfunction pdffontsize(options: pdfoptions): number {\n return basefontsize * (options.scale ?? 1);\n}\n\n/** Wraps one text block into page lines for the reviewed geometry: word wrap at the average glyph width of the Helvetica body font. */\nexport function pdftextlayout(text: string, options: pdfoptions): string[] {\n const size = pdfpagesize(options);\n const margins = pdfmargins(options);\n const fontsize = pdffontsize(options);\n const leading = fontsize * 1.35;\n const linesperpage = Math.max(1, Math.floor((size.height - margins.top - margins.bottom) / leading));\n const columns = Math.max(1, Math.floor((size.width - margins.left - margins.right) / (fontsize * 0.5)));\n const wrapped: string[] = [];\n for (const paragraph of text.split(/\\r?\\n/)) {\n let line = \"\";\n for (const word of paragraph.split(/\\s+/).filter(Boolean)) {\n const candidate = line ? `${line} ${word}` : word;\n if (candidate.length <= columns) { line = candidate; continue; }\n if (line) wrapped.push(line);\n if (word.length <= columns) { line = word; continue; }\n for (let index = 0; index < word.length; index += columns) wrapped.push(word.slice(index, index + columns));\n line = \"\";\n }\n wrapped.push(line);\n if (wrapped.length >= linesperpage) break;\n }\n return wrapped.slice(0, linesperpage);\n}\n\n/** Splits the scroll height into report page segments at reviewed break point offsets; absent break points walk the height in viewport steps. */\nexport function pdfsegments(scrollheight: number, viewportheight: number, breaks: number[]): Array<{ top: number; height: number }> {\n if (scrollheight <= 0) return [];\n const step = viewportheight > 0 ? viewportheight : scrollheight;\n const cuts = [0, ...breaks.filter(top => Number.isFinite(top) && top > 0 && top < scrollheight).map(top => Math.round(top))].filter((top, index, list) => list.indexOf(top) === index).sort((left, right) => left - right);\n const segments: Array<{ top: number; height: number }> = [];\n let index = 0;\n let cursor = 0;\n while (cursor < scrollheight) {\n while (index < cuts.length && (cuts[index] ?? 0) <= cursor) index += 1;\n const nextcut = index < cuts.length ? cuts[index] : undefined;\n const next = nextcut !== undefined ? Math.min(nextcut, scrollheight) : Math.min(cursor + step, scrollheight);\n if (next <= cursor) break;\n segments.push({ top: cursor, height: next - cursor });\n cursor = next;\n }\n return segments.length > 0 ? segments : [{ top: 0, height: scrollheight }];\n}\n\n/** Escapes one pdf text string: parentheses and backslashes escape and characters outside latin one become honest question marks. */\nfunction pdfescape(text: string): string {\n let escaped = \"\";\n for (const character of text) {\n const code = character.charCodeAt(0);\n if (character === \"(\" || character === \")\" || character === \"\\\\\") escaped += `\\\\${character}`;\n else if (code >= 32 && code <= 255) escaped += character;\n else escaped += \"?\";\n }\n return escaped;\n}\n\n/** Composes one derived pdf document from the page text blocks with the reviewed paper size, margins, scale and landscape orientation; the byte size is the latin one document length. */\nexport function buildpdf(pages: string[], options: pdfoptions): { document: string; bytes: number; pages: number; pagewidth: number; pageheight: number } {\n const size = pdfpagesize(options);\n const margins = pdfmargins(options);\n const fontsize = pdffontsize(options);\n const leading = fontsize * 1.35;\n const laidout = (pages.length > 0 ? pages : [\"\"]).map(text => pdftextlayout(text, options));\n const objects: string[] = [];\n const kids = laidout.map((_, index) => `${4 + index * 2} 0 R`).join(\" \");\n objects.push(`<< /Type /Catalog /Pages 2 0 R >>`);\n objects.push(`<< /Type /Pages /Kids [${kids}] /Count ${laidout.length} >>`);\n objects.push(`<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>`);\n for (let pageindex = 0; pageindex < laidout.length; pageindex += 1) {\n const lines = laidout[pageindex] ?? [];\n const operators: string[] = [\"BT\", `/F1 ${fontsize} Tf`, `${leading.toFixed(2)} TL`, `${margins.left.toFixed(2)} ${(size.height - margins.top - fontsize).toFixed(2)} Td`];\n for (let lineindex = 0; lineindex < lines.length; lineindex += 1) {\n if (lineindex > 0) operators.push(\"T*\");\n operators.push(`(${pdfescape(lines[lineindex] ?? \"\")}) Tj`);\n }\n operators.push(\"ET\");\n const content = operators.join(\"\\n\");\n objects.push(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${size.width.toFixed(2)} ${size.height.toFixed(2)}] /Resources << /Font << /F1 3 0 R >> >> /Contents ${5 + pageindex * 2} 0 R >>`);\n objects.push(`<< /Length ${content.length} >>\\nstream\\n${content}\\nendstream`);\n }\n let document = \"%PDF-1.4\\n\";\n const offsets: number[] = [];\n for (let index = 0; index < objects.length; index += 1) {\n offsets.push(document.length);\n document += `${index + 1} 0 obj\\n${objects[index]}\\nendobj\\n`;\n }\n const xrefstart = document.length;\n document += `xref\\n0 ${objects.length + 1}\\n0000000000 65535 f \\n`;\n for (const offset of offsets) document += `${String(offset).padStart(10, \"0\")} 00000 n \\n`;\n document += `trailer\\n<< /Size ${objects.length + 1} /Root 1 0 R >>\\nstartxref\\n${xrefstart}\\n%%EOF\\n`;\n return { document, bytes: document.length, pages: laidout.length, pagewidth: Math.round(size.width), pageheight: Math.round(size.height) };\n}\n\n/** Normalizes reviewed recording options with the tab scope as the default. */\nexport function recordingoptionsof(value: unknown): recordingoptions {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const options = value as Record<string, unknown>;\n const normalized: recordingoptions = {};\n if (options.scope === \"tab\" || options.scope === \"run\") normalized.scope = options.scope;\n if (typeof options.fps === \"number\" && Number.isFinite(options.fps)) normalized.fps = options.fps;\n if (typeof options.bitrate === \"number\" && Number.isFinite(options.bitrate)) normalized.bitrate = options.bitrate;\n if (typeof options.audio === \"boolean\") normalized.audio = options.audio;\n return normalized;\n}\n\n/** Opens one recording record of user activity with the reviewed options applied. */\nexport function newrecording(input: { id: string; runid: string; stepid: string; tabid: number; kind: \"screen\" | \"audio\"; options: recordingoptions; at: number }): recordingrecord {\n return {\n id: input.id,\n runid: input.runid,\n stepid: input.stepid,\n tabid: input.tabid,\n kind: input.kind,\n scope: input.options.scope ?? \"tab\",\n format: input.kind === \"audio\" ? \"evidence\" : \"frames\",\n startedat: input.at,\n at: input.at,\n ...(input.options.fps !== undefined ? { fps: input.options.fps } : {}),\n ...(input.options.bitrate !== undefined ? { bitrate: input.options.bitrate } : {}),\n ...(input.options.audio !== undefined ? { audio: input.options.audio } : {}),\n frames: [],\n };\n}\n\n/** Closes one recording cleanly at the given time and stamps the duration. */\nexport function finishrecording(record: recordingrecord, endat: number): recordingrecord {\n return { ...record, endedat: endat, duration: Math.max(0, endat - record.startedat) };\n}\n\n/** Frame shoot interval in milliseconds of the reviewed fps; the fps itself carries no code ceiling. */\nexport function frameinterval(fps: number): number {\n if (!Number.isFinite(fps) || fps <= 0) return 1000;\n return Math.max(1, Math.round(1000 / fps));\n}\n\n/** Normalizes a reviewed image filter; unknown fields stay ignored. */\nexport function imagefilterof(value: unknown): imagefilter {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n const options = value as Record<string, unknown>;\n const normalized: imagefilter = {};\n if (typeof options.selector === \"string\" && options.selector.trim()) normalized.selector = options.selector.trim();\n if (typeof options.minwidth === \"number\" && Number.isFinite(options.minwidth)) normalized.minwidth = options.minwidth;\n if (typeof options.minheight === \"number\" && Number.isFinite(options.minheight)) normalized.minheight = options.minheight;\n if (Array.isArray(options.formats) && options.formats.every(item => typeof item === \"string\" && item.trim())) normalized.formats = options.formats as string[];\n return normalized;\n}\n\n/** True when one observed image passes the reviewed filter: minimum dimensions and the format list; absent bounds never refuse. */\nexport function imagematches(image: imagedescriptor, filter: imagefilter): boolean {\n if (filter.minwidth !== undefined && image.width < filter.minwidth) return false;\n if (filter.minheight !== undefined && image.height < filter.minheight) return false;\n if (filter.formats !== undefined && filter.formats.length > 0) {\n const mime = image.mime.toLowerCase();\n const matches = filter.formats.some(format => {\n const wanted = format.toLowerCase().trim();\n return mime === wanted || mime === `image/${wanted}` || mime.endsWith(`/${wanted}`);\n });\n if (!matches) return false;\n }\n return true;\n}\n\n/** Deduplicates observed images by url before any download starts; the first observation of a url wins. */\nexport function dedupeimages(images: imagedescriptor[]): imagedescriptor[] {\n const seen = new Set<string>();\n const unique: imagedescriptor[] = [];\n for (const image of images) {\n if (seen.has(image.url)) continue;\n seen.add(image.url);\n unique.push(image);\n }\n return unique;\n}\n\n/** Stamps consistent image batch filenames from the reviewed naming rule with a per batch image counter. */\nexport function imagenames(rule: capturenaming, run: string, step: string, count: number, extension: string): string[] {\n const names: string[] = [];\n for (let index = 1; index <= Math.max(0, Math.round(count)); index += 1) names.push(buildname(rule, { run, step, sequence: index, kind: \"image\" }, extension));\n return names;\n}\n\n/** Normalizes a reviewed lapse plan; an absent format keeps png. */\nexport function lapseplanof(value: unknown): { interval: number; duration: number; format: captureformat } | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const options = value as Record<string, unknown>;\n if (typeof options.interval !== \"number\" || !Number.isFinite(options.interval)) return undefined;\n if (typeof options.duration !== \"number\" || !Number.isFinite(options.duration)) return undefined;\n const format = options.format === \"jpeg\" || options.format === \"webp\" ? options.format : \"png\";\n return { interval: options.interval, duration: options.duration, format };\n}\n\n/** Ordered lapse frame timestamps starting at zero and stepping the reviewed interval inside the reviewed duration. */\nexport function lapseframes(plan: { interval: number; duration: number }): number[] {\n if (!(plan.interval > 0) || !(plan.duration > 0)) return [];\n const frames: number[] = [];\n for (let time = 0; time < plan.duration; time += plan.interval) frames.push(Math.round(time));\n return frames;\n}\n\n/** Normalizes a reviewed conversion directive; an absent payload leaves the step without a directive. */\nexport function convertdirectiveof(value: unknown): convertdirective | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const options = value as Record<string, unknown>;\n if (options.target !== \"png\" && options.target !== \"jpeg\" && options.target !== \"webp\") return undefined;\n const normalized: convertdirective = { target: options.target };\n if (options.source === \"png\" || options.source === \"jpeg\" || options.source === \"webp\") normalized.source = options.source;\n if (typeof options.quality === \"number\" && Number.isFinite(options.quality)) normalized.quality = options.quality;\n return normalized;\n}\n\n/** Normalizes a reviewed thumbnail directive; an absent payload leaves the step without a directive. */\nexport function thumbdirectiveof(value: unknown): thumbdirective | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const options = value as Record<string, unknown>;\n if (typeof options.size !== \"number\" || !Number.isFinite(options.size) || options.size <= 0) return undefined;\n if (options.fit !== \"cover\" && options.fit !== \"contain\") return undefined;\n if (typeof options.suffix !== \"string\" || !options.suffix.trim()) return undefined;\n return { size: options.size, fit: options.fit, suffix: options.suffix.trim() };\n}\n\n/** Nine argument draw geometry of one thumbnail: cover crops to the square and fits inside, contain letterboxes the whole source. */\nexport function thumbgeometry(source: { width: number; height: number }, directive: thumbdirective): { sx: number; sy: number; sw: number; sh: number; dx: number; dy: number; dw: number; dh: number; width: number; height: number } {\n const size = Math.max(1, Math.round(directive.size));\n if (directive.fit === \"contain\") {\n const scale = Math.min(size / Math.max(1, source.width), size / Math.max(1, source.height));\n const dw = Math.max(1, Math.round(source.width * scale));\n const dh = Math.max(1, Math.round(source.height * scale));\n return { sx: 0, sy: 0, sw: source.width, sh: source.height, dx: Math.floor((size - dw) / 2), dy: Math.floor((size - dh) / 2), dw, dh, width: size, height: size };\n }\n const scale = Math.max(size / Math.max(1, source.width), size / Math.max(1, source.height));\n const sw = Math.min(source.width, Math.round(size / scale));\n const sh = Math.min(source.height, Math.round(size / scale));\n return { sx: Math.floor((source.width - sw) / 2), sy: Math.floor((source.height - sh) / 2), sw, sh, dx: 0, dy: 0, dw: size, dh: size, width: size, height: size };\n}\n\n/** Normalizes raw embedded media element entries into mediadatum records with duration, dimensions, codecs and track lists. */\nexport function mediaentries(raw: Array<Record<string, unknown>>): mediadatum[] {\n return raw.map(entry => ({\n url: typeof entry.url === \"string\" ? entry.url : \"\",\n mime: typeof entry.mime === \"string\" ? entry.mime : \"\",\n duration: typeof entry.duration === \"number\" && Number.isFinite(entry.duration) ? entry.duration : 0,\n width: typeof entry.width === \"number\" && Number.isFinite(entry.width) ? Math.round(entry.width) : 0,\n height: typeof entry.height === \"number\" && Number.isFinite(entry.height) ? Math.round(entry.height) : 0,\n codecs: typeof entry.codecs === \"string\" ? entry.codecs : \"\",\n tracks: Array.isArray(entry.tracks) ? entry.tracks.filter(item => typeof item === \"string\") : [],\n }));\n}\n\n/** Normalizes raw page asset entries into favicon or logo asset shapes with their byte sizes and declared sizes. */\nexport function assetentries(raw: Array<Record<string, unknown>>): Array<{ kind: assetrecord[\"kind\"]; url: string; bytes: number; sizes?: string }> {\n return raw.map(entry => ({\n kind: entry.kind === \"logo\" ? \"logo\" : \"favicon\",\n url: typeof entry.url === \"string\" ? entry.url : \"\",\n bytes: typeof entry.bytes === \"number\" && Number.isFinite(entry.bytes) ? entry.bytes : 0,\n ...(typeof entry.sizes === \"string\" && entry.sizes.trim() ? { sizes: entry.sizes.trim() } : {}),\n }));\n}\n\n/** Normalizes raw stream probe entries into stream summaries with track counts, labels, live states and track details. */\nexport function streamsummaries(raw: Array<Record<string, unknown>>): Array<Omit<streamrecord, \"id\" | \"runid\" | \"stepid\" | \"at\">> {\n return raw.map(entry => {\n const tracks = Array.isArray(entry.tracks) ? entry.tracks : [];\n return {\n kind: typeof entry.kind === \"string\" ? entry.kind : \"stream\",\n tracks: tracks.length,\n label: typeof entry.label === \"string\" ? entry.label : \"\",\n live: entry.live === true,\n detail: tracks.map(track => {\n const item = track as Record<string, unknown>;\n return {\n kind: typeof item.kind === \"string\" ? item.kind : \"\",\n label: typeof item.label === \"string\" ? item.label : \"\",\n ...(typeof item.width === \"number\" && Number.isFinite(item.width) ? { width: Math.round(item.width) } : {}),\n ...(typeof item.height === \"number\" && Number.isFinite(item.height) ? { height: Math.round(item.height) } : {}),\n ...(typeof item.framerate === \"number\" && Number.isFinite(item.framerate) ? { framerate: item.framerate } : {}),\n state: typeof item.state === \"string\" ? item.state : \"\",\n };\n }),\n };\n });\n}\n", "import type { a11ycapture, agentplan, agentsession, artifactinventoryentry, artifactrecord, assetrecord, auditevent, authrecord, bannerreport, capabilityreport, canvasrecord, captchahandoff, capturecounter, clipboardconsentrecord, cleanuprule, cleanuprun, clipentry, clickablemap, closedtab, controltabstate, curatedlist, dataset, derivedselector, detectionrecord, diagnosticreport, dialogdecision, dialogpolicy, downloadrecord, endpointconfig, errorreport, exportedartifact, extractsession, focusevent, formprofile, framerecord, imagebatch, keyholdstate, mediarecord, pdfrecord, mimefilter, mutationevent, navcontrol, navintentrecord, navqueues, navrecord, netlogrecord, observationrecord, pagesignals, planprogress, provenancerecord, quarantineentry, ratelimitstate, readercapture, recenttab, recordingconsentrecord, recordingrecord, resolutionsummary, retryoutcome, runsettings, safetyverdict, scanhookconfig, sessionsnapshot, sheetendpoint, shotpair, shotrecord, snapshotdiff, stepoutcome, streamstate, submitticket, tabbadge, tabgrouprecord, tablayout, tabmeta, tabwatchevent, taskrules, templateprofile, trailentry, typeaheadpick, waitprofilerecord, watchregistration, wizardstate } from \"./types.js\";\n\n/** Provides a small storage seam that works in browser, tests and future adapters. */\nexport interface memoryadapter {\n get<T>(key: string): Promise<T | undefined>;\n set<T>(key: string, value: T): Promise<void>;\n}\n\n/**\n * Local memory for sessions, plans, audit evidence and interaction state.\n * Correlated rules for every stored record live in this one seam; each accessor is a one line storage delegation so future backends replace the adapter only.\n */\nexport class sessionmemory {\n constructor(private readonly adapter: memoryadapter) {}\n\n async getconfig(): Promise<endpointconfig | undefined> { return this.adapter.get<endpointconfig>(\"config\"); }\n async setconfig(value: endpointconfig): Promise<void> { return this.adapter.set(\"config\", value); }\n async getsession(): Promise<agentsession | undefined> { return this.adapter.get<agentsession>(\"session\"); }\n async setsession(value: agentsession): Promise<void> { return this.adapter.set(\"session\", value); }\n async getplan(): Promise<agentplan | undefined> { return this.adapter.get<agentplan>(\"plan\"); }\n async setplan(value: agentplan): Promise<void> { return this.adapter.set(\"plan\", value); }\n async getdiagnostic(): Promise<diagnosticreport | undefined> { return this.adapter.get<diagnosticreport>(\"diagnostic\"); }\n async setdiagnostic(value: diagnosticreport): Promise<void> { return this.adapter.set(\"diagnostic\", value); }\n async getprogress(): Promise<planprogress | undefined> { return this.adapter.get<planprogress>(\"progress\"); }\n async setprogress(value: planprogress): Promise<void> { return this.adapter.set(\"progress\", value); }\n async getcapabilities(): Promise<capabilityreport | undefined> { return this.adapter.get<capabilityreport>(\"capabilities\"); }\n async setcapabilities(value: capabilityreport): Promise<void> { return this.adapter.set(\"capabilities\", value); }\n async getsettings(): Promise<runsettings | undefined> { return this.adapter.get<runsettings>(\"settings\"); }\n async setsettings(value: runsettings): Promise<void> { return this.adapter.set(\"settings\", value); }\n async getaudit(): Promise<auditevent[]> { return (await this.adapter.get<auditevent[]>(\"audit\")) ?? []; }\n async getoutcomes(): Promise<stepoutcome[]> { return (await this.adapter.get<stepoutcome[]>(\"outcomes\")) ?? []; }\n\n /** Records one audit event; retention is a user setting and an absent setting keeps every event. */\n async addaudi(event: auditevent): Promise<void> {\n const records = await this.getaudit();\n const combined = [event, ...records];\n const retention = (await this.getsettings())?.auditretention;\n await this.adapter.set(\"audit\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Records one step outcome; retention is a user setting and an absent setting keeps every outcome. */\n async addoutcome(outcome: stepoutcome): Promise<void> {\n const records = await this.getoutcomes();\n const combined = [outcome, ...records];\n const retention = (await this.getsettings())?.outcomeretention;\n await this.adapter.set(\"outcomes\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Stores one clickable map under its observation version so every captured map stays available. */\n async setmap(map: clickablemap): Promise<void> { return this.adapter.set(`map${map.version}`, map); }\n\n /** Returns one stored clickable map by its observation version. */\n async getmap(version: number): Promise<clickablemap | undefined> { return this.adapter.get<clickablemap>(`map${version}`); }\n\n /** Advances and persists the observation version counter used to stamp clickable maps. */\n async nextobservationversion(): Promise<number> {\n const current = (await this.adapter.get<number>(\"observationversion\")) ?? 0;\n const next = current + 1;\n await this.adapter.set(\"observationversion\", next);\n return next;\n }\n\n /** Returns the latest observation version used to stamp a clickable map. */\n async getobservationversion(): Promise<number | undefined> { return this.adapter.get<number>(\"observationversion\"); }\n\n /** Returns the key hold registry, persisted so holds survive service worker restarts. */\n async getholds(): Promise<keyholdstate[]> { return (await this.adapter.get<keyholdstate[]>(\"holds\")) ?? []; }\n\n /** Replaces the key hold registry after one press or release transition. */\n async setholds(holds: keyholdstate[]): Promise<void> { return this.adapter.set(\"holds\", holds); }\n\n /** Returns every dialog decision recorded for the audit trail. */\n async getdialogs(): Promise<dialogdecision[]> { return (await this.adapter.get<dialogdecision[]>(\"dialogs\")) ?? []; }\n\n /** Records one dialog decision with the reviewed answer and the observed dialog text. */\n async adddialog(decision: dialogdecision): Promise<void> {\n const records = await this.getdialogs();\n await this.adapter.set(\"dialogs\", [decision, ...records]);\n }\n\n /** Returns every retry outcome recorded with attempts and movement deltas. */\n async getretries(): Promise<retryoutcome[]> { return (await this.adapter.get<retryoutcome[]>(\"retries\")) ?? []; }\n\n /** Records one retry outcome with the attempts made and the movement delta observed. */\n async addretry(outcome: retryoutcome): Promise<void> {\n const records = await this.getretries();\n await this.adapter.set(\"retries\", [outcome, ...records]);\n }\n\n /** Returns every resolution summary stored per target mode. */\n async getresolutions(): Promise<resolutionsummary[]> { return (await this.adapter.get<resolutionsummary[]>(\"resolutions\")) ?? []; }\n\n /** Records one resolution summary for later selector derivation. */\n async addresolution(summary: resolutionsummary): Promise<void> {\n const records = await this.getresolutions();\n await this.adapter.set(\"resolutions\", [summary, ...records]);\n }\n\n /** Returns the reviewed default dialog policy kept for the session auto handler. */\n async getdialogpolicy(): Promise<dialogpolicy | undefined> { return this.adapter.get<dialogpolicy>(\"dialogpolicy\"); }\n\n /** Stores the reviewed default dialog policy of the latest approved plan. */\n async setdialogpolicy(policy: dialogpolicy): Promise<void> { return this.adapter.set(\"dialogpolicy\", policy); }\n\n /** Stores one observation capture under its version so every observation version stays available. */\n async setobservation(record: observationrecord): Promise<void> { return this.adapter.set(`observation${record.version}`, record); }\n\n /** Returns one stored observation version. */\n async getobservation(version: number): Promise<observationrecord | undefined> { return this.adapter.get<observationrecord>(`observation${version}`); }\n\n /** Returns the observation retention window; an absent setting keeps every capture. */\n private async observationretention(): Promise<number | undefined> { return (await this.getsettings())?.observationretention; }\n\n /** Stores one accessibility tree capture; retention is a user setting and an absent setting keeps every tree. */\n async adda11ytree(capture: a11ycapture): Promise<void> {\n const records = await this.geta11ytrees();\n const combined = [capture, ...records];\n const retention = await this.observationretention();\n await this.adapter.set(\"a11ytrees\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns every stored accessibility tree capture, newest first. */\n async geta11ytrees(): Promise<a11ycapture[]> { return (await this.adapter.get<a11ycapture[]>(\"a11ytrees\")) ?? []; }\n\n /** Stores one reader article capture; retention is a user setting and an absent setting keeps every article. */\n async addreaderarticle(capture: readercapture): Promise<void> {\n const records = await this.getreaderarticles();\n const combined = [capture, ...records];\n const retention = await this.observationretention();\n await this.adapter.set(\"readerarticles\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns every stored reader article capture, newest first. */\n async getreaderarticles(): Promise<readercapture[]> { return (await this.adapter.get<readercapture[]>(\"readerarticles\")) ?? []; }\n\n /** Records one dom mutation observed inside a reviewed watch. */\n async addmutationevent(event: mutationevent): Promise<void> {\n const records = await this.getmutationevents();\n await this.adapter.set(\"mutationevents\", [event, ...records]);\n }\n\n /** Returns the mutation event stream of every reviewed watch. */\n async getmutationevents(): Promise<mutationevent[]> { return (await this.adapter.get<mutationevent[]>(\"mutationevents\")) ?? []; }\n\n /** Records one focus change observed inside a reviewed watch. */\n async addfocusevent(event: focusevent): Promise<void> {\n const records = await this.getfocusevents();\n await this.adapter.set(\"focusevents\", [event, ...records]);\n }\n\n /** Returns the focus event stream of every reviewed watch. */\n async getfocusevents(): Promise<focusevent[]> { return (await this.adapter.get<focusevent[]>(\"focusevents\")) ?? []; }\n\n /** Records one consent banner observed by a reviewed banner watch. */\n async addbanner(event: bannerreport): Promise<void> {\n const records = await this.getbanners();\n await this.adapter.set(\"banners\", [event, ...records]);\n }\n\n /** Returns every consent banner report observed so far. */\n async getbanners(): Promise<bannerreport[]> { return (await this.adapter.get<bannerreport[]>(\"banners\")) ?? []; }\n\n /** Records one snapshot diff between two observation versions. */\n async adddiff(diff: snapshotdiff): Promise<void> {\n const records = await this.getdiffs();\n await this.adapter.set(\"diffs\", [diff, ...records]);\n }\n\n /** Returns every stored snapshot diff, newest first. */\n async getdiffs(): Promise<snapshotdiff[]> { return (await this.adapter.get<snapshotdiff[]>(\"diffs\")) ?? []; }\n\n /** Records one derived selector with its stability score for reuse. */\n async addselector(selector: derivedselector): Promise<void> {\n const records = await this.getselectors();\n await this.adapter.set(\"selectors\", [selector, ...records]);\n }\n\n /** Returns every stored derived selector with its stability score, newest first. */\n async getselectors(): Promise<derivedselector[]> { return (await this.adapter.get<derivedselector[]>(\"selectors\")) ?? []; }\n\n /** Records one detected template class or section fingerprint for its origin. */\n async addtemplate(profile: templateprofile): Promise<void> {\n const records = await this.gettemplates();\n await this.adapter.set(\"templates\", [profile, ...records]);\n }\n\n /** Returns every stored template class and section fingerprint, newest first. */\n async gettemplates(): Promise<templateprofile[]> { return (await this.adapter.get<templateprofile[]>(\"templates\")) ?? []; }\n\n /** Records one watch registration so it survives service worker restarts. */\n async addwatch(watch: watchregistration): Promise<void> {\n const records = await this.getwatches();\n await this.adapter.set(\"watches\", [watch, ...records]);\n }\n\n /** Returns every watch registration, newest first, including closed windows. */\n async getwatches(): Promise<watchregistration[]> { return (await this.adapter.get<watchregistration[]>(\"watches\")) ?? []; }\n\n /** Closes one watch registration by watch id once its reviewed lifetime window ends. */\n async closewatch(watchid: string, closedat: number): Promise<void> {\n const records = await this.getwatches();\n await this.adapter.set(\"watches\", records.map(watch => watch.watchid === watchid && watch.closedat === undefined ? { ...watch, closedat } : watch));\n }\n\n /** Returns the live page signals of language, template, scroll lock and banner state. */\n async getsignals(): Promise<pagesignals | undefined> { return this.adapter.get<pagesignals>(\"signals\"); }\n\n /** Replaces the live page signals after an observation step refreshes them. */\n async setsignals(signals: pagesignals): Promise<void> { return this.adapter.set(\"signals\", signals); }\n\n /** Appends one navigation trail entry of a session with its url, title, step ref and timestamp. */\n async addtrailentry(sessionid: string, entry: trailentry): Promise<void> {\n const records = await this.gettrail(sessionid);\n await this.adapter.set(`trail${sessionid}`, [...records, entry]);\n }\n\n /** Returns the navigation trail of a session, oldest first. */\n async gettrail(sessionid: string): Promise<trailentry[]> { return (await this.adapter.get<trailentry[]>(`trail${sessionid}`)) ?? []; }\n\n /** Stores one wait profile for an origin with user configured values, replacing the previous profile of that origin. */\n async setwaitprofile(record: waitprofilerecord): Promise<void> {\n const records = (await this.getwaitprofiles()).filter(item => item.origin !== record.origin);\n await this.adapter.set(\"waitprofiles\", [...records, record]);\n }\n\n /** Returns every stored wait profile with its origin and user configured values, newest first. */\n async getwaitprofiles(): Promise<waitprofilerecord[]> { return (await this.adapter.get<waitprofilerecord[]>(\"waitprofiles\")) ?? []; }\n\n /** Records one navigation step with its redirect chain and final url. */\n async addnavrecord(record: navrecord): Promise<void> {\n const records = await this.getnavrecords();\n await this.adapter.set(\"navrecords\", [record, ...records]);\n }\n\n /** Returns every stored navigation record with redirect chains and final urls, newest first. */\n async getnavrecords(): Promise<navrecord[]> { return (await this.adapter.get<navrecord[]>(\"navrecords\")) ?? []; }\n\n /** Records one navigation intent detected from a plan for audit review. */\n async addnavintent(record: navintentrecord): Promise<void> {\n const records = await this.getnavintents();\n await this.adapter.set(\"navintents\", [record, ...records]);\n }\n\n /** Returns every stored navigation intent record, newest first. */\n async getnavintents(): Promise<navintentrecord[]> { return (await this.adapter.get<navintentrecord[]>(\"navintents\")) ?? []; }\n\n /** Replaces the rate limit window state of one domain. */\n async setratestate(state: ratelimitstate): Promise<void> {\n const records = (await this.getratestates()).filter(item => item.domain !== state.domain);\n await this.adapter.set(\"ratestates\", [...records, state]);\n }\n\n /** Returns every rate limit window state per domain. */\n async getratestates(): Promise<ratelimitstate[]> { return (await this.adapter.get<ratelimitstate[]>(\"ratestates\")) ?? []; }\n\n /** Records one curated link list with its review state before batch opening. */\n async addcurated(list: curatedlist): Promise<void> {\n const records = await this.getcurateds();\n await this.adapter.set(\"curated\", [list, ...records]);\n }\n\n /** Returns every stored curated link list, newest first. */\n async getcurateds(): Promise<curatedlist[]> { return (await this.adapter.get<curatedlist[]>(\"curated\")) ?? []; }\n\n /** Stores reviewed basic auth credentials for one origin, replacing the previous record of that origin. */\n async setauth(record: authrecord): Promise<void> {\n const records = (await this.getauths()).filter(item => item.origin !== record.origin);\n await this.adapter.set(\"auths\", [...records, record]);\n }\n\n /** Returns every stored reviewed basic auth record per origin. */\n async getauths(): Promise<authrecord[]> { return (await this.adapter.get<authrecord[]>(\"auths\")) ?? []; }\n\n /** Records one task artifact routed into the artifact store. */\n async addartifact(record: artifactrecord): Promise<void> {\n const records = await this.getartifacts();\n await this.adapter.set(\"artifacts\", [record, ...records]);\n }\n\n /** Returns every stored task artifact, newest first. */\n async getartifacts(): Promise<artifactrecord[]> { return (await this.adapter.get<artifactrecord[]>(\"artifacts\")) ?? []; }\n\n /** Returns the navigation control state of paused navigation. */\n async getnavcontrol(): Promise<navcontrol | undefined> { return this.adapter.get<navcontrol>(\"navcontrol\"); }\n\n /** Replaces the navigation control state after a pause or resume transition. */\n async setnavcontrol(control: navcontrol): Promise<void> { return this.adapter.set(\"navcontrol\", control); }\n\n /** Records one url safety verdict produced by a checksafe verification. */\n async addsafety(verdict: safetyverdict): Promise<void> {\n const records = await this.getsafeties();\n await this.adapter.set(\"safeties\", [verdict, ...records]);\n }\n\n /** Returns every stored url safety verdict, newest first. */\n async getsafeties(): Promise<safetyverdict[]> { return (await this.adapter.get<safetyverdict[]>(\"safeties\")) ?? []; }\n\n /** Records one recently closed tab so a reopentab step can restore it. */\n async addrecenttab(tab: recenttab): Promise<void> {\n const records = await this.getrecenttabs();\n await this.adapter.set(\"recenttabs\", [tab, ...records]);\n }\n\n /** Returns every recently closed tab, newest first. */\n async getrecenttabs(): Promise<recenttab[]> { return (await this.adapter.get<recenttab[]>(\"recenttabs\")) ?? []; }\n\n /** Returns the queued prefetch and batch open target counts shown in the popup badge. */\n async getnavqueues(): Promise<navqueues | undefined> { return this.adapter.get<navqueues>(\"navqueues\"); }\n\n /** Replaces the queued prefetch and batch open target counts. */\n async setnavqueues(queues: navqueues): Promise<void> { return this.adapter.set(\"navqueues\", queues); }\n\n /** Returns the last known navigation state of a tab, kept across service worker restarts. */\n async getnavstate(tabid: number): Promise<navrecord | undefined> { return this.adapter.get<navrecord>(`navstate${tabid}`); }\n\n /** Replaces the last known navigation state of a tab. */\n async setnavstate(tabid: number, state: navrecord): Promise<void> { return this.adapter.set(`navstate${tabid}`, state); }\n\n /** Stores one named tab layout with its window bounds and group states, replacing the previous layout of that name. */\n async setlayout(layout: tablayout): Promise<void> {\n const records = (await this.getlayouts()).filter(item => item.name !== layout.name);\n await this.adapter.set(\"layouts\", [layout, ...records]);\n }\n\n /** Returns one saved tab layout by name with its timestamp. */\n async getlayout(name: string): Promise<tablayout | undefined> { return (await this.getlayouts()).find(item => item.name === name); }\n\n /** Returns every saved tab layout with its window bounds and group states. */\n async getlayouts(): Promise<tablayout[]> { return (await this.adapter.get<tablayout[]>(\"layouts\")) ?? []; }\n\n /** Stores one tab group definition with its color choice and member tabs, replacing the previous definition of that name. */\n async settabgroup(group: tabgrouprecord): Promise<void> {\n const records = (await this.gettabgroups()).filter(item => item.name !== group.name);\n await this.adapter.set(\"tabgroups\", [...records, group]);\n }\n\n /** Returns every stored tab group definition with its color choice, newest first. */\n async gettabgroups(): Promise<tabgrouprecord[]> { return (await this.adapter.get<tabgrouprecord[]>(\"tabgroups\")) ?? []; }\n\n /** Records one tabmeta record with task provenance, replacing the previous metadata of that tab. */\n async settabmeta(meta: tabmeta): Promise<void> {\n const records = (await this.gettabmetas()).filter(item => item.tabid !== meta.tabid);\n await this.adapter.set(\"tabmetas\", [...records, meta]);\n }\n\n /** Returns every stored tabmeta record with task provenance. */\n async gettabmetas(): Promise<tabmeta[]> { return (await this.adapter.get<tabmeta[]>(\"tabmetas\")) ?? []; }\n\n /** Records one session snapshot of tabs and windows for later restore. */\n async addsnapshot(snapshot: sessionsnapshot): Promise<void> {\n const records = await this.getsnapshots();\n await this.adapter.set(\"snapshots\", [snapshot, ...records]);\n }\n\n /** Returns every stored session snapshot, newest first. */\n async getsnapshots(): Promise<sessionsnapshot[]> { return (await this.adapter.get<sessionsnapshot[]>(\"snapshots\")) ?? []; }\n\n /** Records one closed tab in the history kept for restoretab and reopenrun. */\n async addclosedtab(tab: closedtab): Promise<void> {\n const records = await this.getclosedtabs();\n await this.adapter.set(\"closedtabs\", [tab, ...records]);\n }\n\n /** Returns the closed tab history, newest first. */\n async getclosedtabs(): Promise<closedtab[]> { return (await this.adapter.get<closedtab[]>(\"closedtabs\")) ?? []; }\n\n /** Stores one badge state per task, replacing the previous badge of that task. */\n async setbadge(badge: tabbadge): Promise<void> {\n const records = (await this.getbadges()).filter(item => item.taskid !== badge.taskid);\n await this.adapter.set(\"badges\", [...records, badge]);\n }\n\n /** Returns every stored badge state per task. */\n async getbadges(): Promise<tabbadge[]> { return (await this.adapter.get<tabbadge[]>(\"badges\")) ?? []; }\n\n /** Records one tab event observed inside a reviewed watchtab registration. */\n async addtabwatchevent(event: tabwatchevent): Promise<void> {\n const records = await this.gettabwatchevents();\n await this.adapter.set(\"tabwatchevents\", [event, ...records]);\n }\n\n /** Returns the tab event stream of every reviewed watchtab registration, newest first. */\n async gettabwatchevents(): Promise<tabwatchevent[]> { return (await this.adapter.get<tabwatchevent[]>(\"tabwatchevents\")) ?? []; }\n\n /** Returns the ids of the scratch windows opened for split work. */\n async getscratchwindows(): Promise<number[]> { return (await this.adapter.get<number[]>(\"scratchwindows\")) ?? []; }\n\n /** Replaces the scratch window id list after one scratch window opens or closes. */\n async setscratchwindows(ids: number[]): Promise<void> { return this.adapter.set(\"scratchwindows\", ids); }\n\n /** Returns the pinned control tab state with the live task feed. */\n async getcontroltab(): Promise<controltabstate | undefined> { return this.adapter.get<controltabstate>(\"controltab\"); }\n\n /** Replaces the pinned control tab state. */\n async setcontroltab(state: controltabstate): Promise<void> { return this.adapter.set(\"controltab\", state); }\n\n /** Stores one saved form profile under its reviewed name, replacing the previous profile of that name. */\n async setprofile(profile: formprofile): Promise<void> {\n const records = (await this.getprofiles()).filter(item => item.name !== profile.name);\n await this.adapter.set(\"formprofiles\", [profile, ...records]);\n }\n\n /** Returns one saved form profile by its reviewed name. */\n async getprofile(name: string): Promise<formprofile | undefined> { return (await this.getprofiles()).find(item => item.name === name); }\n\n /** Returns every saved form profile with its origin grants, newest first. */\n async getprofiles(): Promise<formprofile[]> { return (await this.adapter.get<formprofile[]>(\"formprofiles\")) ?? []; }\n\n /** Removes one saved form profile by its reviewed name. */\n async removeprofile(name: string): Promise<void> {\n const records = (await this.getprofiles()).filter(item => item.name !== name);\n await this.adapter.set(\"formprofiles\", records);\n }\n\n /** Records one wizard state with its step history. */\n async addwizard(state: wizardstate): Promise<void> {\n const records = await this.getwizards();\n await this.adapter.set(\"wizards\", [state, ...records]);\n }\n\n /** Returns every stored wizard state with its step history, newest first. */\n async getwizards(): Promise<wizardstate[]> { return (await this.adapter.get<wizardstate[]>(\"wizards\")) ?? []; }\n\n /** Stores one submission ticket with its values hash, replacing the previous ticket of that id. */\n async setticket(ticket: submitticket): Promise<void> {\n const records = (await this.gettickets()).filter(item => item.id !== ticket.id);\n await this.adapter.set(\"submittickets\", [ticket, ...records]);\n }\n\n /** Returns every stored submission ticket with its values hash, newest first. */\n async gettickets(): Promise<submitticket[]> { return (await this.adapter.get<submitticket[]>(\"submittickets\")) ?? []; }\n\n /** Records one collected error report for correction loops. */\n async adderrorreport(report: errorreport): Promise<void> {\n const records = await this.geterrorreports();\n await this.adapter.set(\"errorreports\", [report, ...records]);\n }\n\n /** Returns every stored error report, newest first. */\n async geterrorreports(): Promise<errorreport[]> { return (await this.adapter.get<errorreport[]>(\"errorreports\")) ?? []; }\n\n /** Records one typeahead pick observed when a reviewed suggestion entry was chosen. */\n async addpick(pick: typeaheadpick): Promise<void> {\n const records = await this.getpicks();\n await this.adapter.set(\"typeaheadpicks\", [pick, ...records]);\n }\n\n /** Returns every recorded typeahead pick, newest first. */\n async getpicks(): Promise<typeaheadpick[]> { return (await this.adapter.get<typeaheadpick[]>(\"typeaheadpicks\")) ?? []; }\n\n /** Records one captcha handoff while the plan waits for the user. */\n async addcaptcha(handoff: captchahandoff): Promise<void> {\n const records = await this.getcaptchas();\n await this.adapter.set(\"captchas\", [handoff, ...records]);\n }\n\n /** Returns every captcha handoff record with its resolution state, newest first. */\n async getcaptchas(): Promise<captchahandoff[]> { return (await this.adapter.get<captchahandoff[]>(\"captchas\")) ?? []; }\n\n /** Resolves one captcha handoff by id once the user finished it. */\n async resolvecaptcha(id: string, resolvedat: number): Promise<void> {\n const records = await this.getcaptchas();\n await this.adapter.set(\"captchas\", records.map(handoff => handoff.id === id && !handoff.resolved ? { ...handoff, resolved: true, resolvedat } : handoff));\n }\n\n /** Records one login or template detection for its origin. */\n async adddetection(record: detectionrecord): Promise<void> {\n const records = await this.getdetections();\n await this.adapter.set(\"detections\", [record, ...records]);\n }\n\n /** Returns every stored login and template detection per origin, newest first. */\n async getdetections(): Promise<detectionrecord[]> { return (await this.adapter.get<detectionrecord[]>(\"detections\")) ?? []; }\n\n /** Stores the reviewed one time code behind the consent gate of an active session. */\n async setcodevalue(value: string): Promise<void> { return this.adapter.set(\"codevalue\", value); }\n\n /** Returns the reviewed one time code, if the user stored one behind the consent gate. */\n async getcodevalue(): Promise<string | undefined> { return this.adapter.get<string>(\"codevalue\"); }\n\n /** Stores one dataset with its column specs and rows, replacing the previous record of that id. */\n async setdataset(value: dataset): Promise<void> {\n await this.adapter.set(`dataset${value.id}`, value);\n const ids = ((await this.adapter.get<string[]>(\"datasets\")) ?? []).filter(id => id !== value.id);\n await this.adapter.set(\"datasets\", [value.id, ...ids]);\n }\n\n /** Returns one stored dataset by its id with its column specs and row count. */\n async getdataset(id: string): Promise<dataset | undefined> { return this.adapter.get<dataset>(`dataset${id}`); }\n\n /** Returns every stored dataset id, newest first. */\n async getdatasets(): Promise<dataset[]> {\n const ids = (await this.adapter.get<string[]>(\"datasets\")) ?? [];\n const records: dataset[] = [];\n for (const id of ids) {\n const record = await this.adapter.get<dataset>(`dataset${id}`);\n if (record) records.push(record);\n }\n return records;\n }\n\n /** Stores one imported csv dataset for fill loops beside the dataset store. */\n async addimport(value: dataset): Promise<void> {\n await this.setdataset(value);\n const ids = ((await this.adapter.get<string[]>(\"imports\")) ?? []).filter(id => id !== value.id);\n await this.adapter.set(\"imports\", [value.id, ...ids]);\n }\n\n /** Returns every imported csv dataset for fill loops, newest first. */\n async getimports(): Promise<dataset[]> {\n const ids = (await this.adapter.get<string[]>(\"imports\")) ?? [];\n const records: dataset[] = [];\n for (const id of ids) {\n const record = await this.adapter.get<dataset>(`dataset${id}`);\n if (record) records.push(record);\n }\n return records;\n }\n\n /** Stores one extraction session with its cursor and page history, replacing the previous session of that id. */\n async setextractsession(value: extractsession): Promise<void> {\n await this.adapter.set(`extract${value.id}`, value);\n const ids = ((await this.adapter.get<string[]>(\"extracts\")) ?? []).filter(id => id !== value.id);\n await this.adapter.set(\"extracts\", [value.id, ...ids]);\n }\n\n /** Returns every extraction session with its cursor and page history, newest first. */\n async getextractsessions(): Promise<extractsession[]> {\n const ids = (await this.adapter.get<string[]>(\"extracts\")) ?? [];\n const records: extractsession[] = [];\n for (const id of ids) {\n const record = await this.adapter.get<extractsession>(`extract${id}`);\n if (record) records.push(record);\n }\n return records;\n }\n\n /** Records one provenance record of an exported artifact. */\n async addprovenance(record: provenancerecord): Promise<void> {\n const records = await this.getprovenances();\n await this.adapter.set(\"provenances\", [record, ...records]);\n }\n\n /** Returns every provenance record per exported artifact, newest first. */\n async getprovenances(): Promise<provenancerecord[]> { return (await this.adapter.get<provenancerecord[]>(\"provenances\")) ?? []; }\n\n /** Stores the transform rules and dedupe keys of one task, replacing the previous record of that task. */\n async settaskrules(value: taskrules): Promise<void> {\n const records = ((await this.adapter.get<taskrules[]>(\"taskrules\")) ?? []).filter(item => item.taskid !== value.taskid);\n await this.adapter.set(\"taskrules\", [value, ...records]);\n }\n\n /** Returns the transform rules and dedupe keys per task, newest first. */\n async gettaskrules(): Promise<taskrules[]> { return (await this.adapter.get<taskrules[]>(\"taskrules\")) ?? []; }\n\n /** Stores one stream chunk state for resume, replacing the previous state of that dataset. */\n async setstream(state: streamstate): Promise<void> {\n const records = ((await this.adapter.get<streamstate[]>(\"streams\")) ?? []).filter(item => item.datasetid !== state.datasetid);\n await this.adapter.set(\"streams\", [state, ...records]);\n }\n\n /** Returns every stream chunk state persisted for resume, newest first. */\n async getstreams(): Promise<streamstate[]> { return (await this.adapter.get<streamstate[]>(\"streams\")) ?? []; }\n\n /** Stores one reviewed sheet endpoint config behind its origin grant, replacing the previous config of that origin. */\n async setsheetendpoint(config: sheetendpoint): Promise<void> {\n const records = ((await this.adapter.get<sheetendpoint[]>(\"sheetendpoints\")) ?? []).filter(item => item.origin !== config.origin);\n await this.adapter.set(\"sheetendpoints\", [config, ...records]);\n }\n\n /** Returns every reviewed sheet endpoint config, newest first. */\n async getsheetendpoints(): Promise<sheetendpoint[]> { return (await this.adapter.get<sheetendpoint[]>(\"sheetendpoints\")) ?? []; }\n\n /** Records one exported data artifact; artifact retention is a user setting and an absent setting keeps every artifact. */\n async addexport(artifact: exportedartifact): Promise<void> {\n const records = await this.getexports();\n const combined = [artifact, ...records.filter(item => item.id !== artifact.id)];\n const retention = (await this.getsettings())?.artifactretention;\n await this.adapter.set(\"exports\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns every exported data artifact with its content and checksum, newest first. */\n async getexports(): Promise<exportedartifact[]> { return (await this.adapter.get<exportedartifact[]>(\"exports\")) ?? []; }\n\n /** Removes one exported data artifact by id and reports whether it existed. */\n async removeexport(id: string): Promise<boolean> {\n const records = await this.getexports();\n const remaining = records.filter(item => item.id !== id);\n await this.adapter.set(\"exports\", remaining);\n return remaining.length !== records.length;\n }\n\n /** Removes one run store artifact by id and reports whether it existed. */\n async removeartifact(id: string): Promise<boolean> {\n const records = await this.getartifacts();\n const remaining = records.filter(item => item.id !== id);\n await this.adapter.set(\"artifacts\", remaining);\n return remaining.length !== records.length;\n }\n\n /** Stores one batch download file record with its state, path and checksum, replacing the previous record of that id. */\n async setdownload(record: downloadrecord): Promise<void> {\n const records = ((await this.adapter.get<downloadrecord[]>(\"downloads\")) ?? []).filter(item => item.id !== record.id);\n await this.adapter.set(\"downloads\", [record, ...records]);\n }\n\n /** Returns every batch download file record with its state, path and checksum, newest first. */\n async getdownloads(): Promise<downloadrecord[]> { return (await this.adapter.get<downloadrecord[]>(\"downloads\")) ?? []; }\n\n /** Records one captured network log record; netlog retention is a user setting and an absent value keeps every record. */\n async addnetlog(record: netlogrecord): Promise<void> {\n const records = await this.getnetlog();\n const combined = [record, ...records];\n const retention = (await this.getsettings())?.netlogretention;\n await this.adapter.set(\"netlog\", retention === undefined ? combined : combined.slice(0, retention));\n }\n\n /** Returns the captured network log of the run with its step correlation, newest first. */\n async getnetlog(): Promise<netlogrecord[]> { return (await this.adapter.get<netlogrecord[]>(\"netlog\")) ?? []; }\n\n /** Stores one clipboard consent record with its prompt and origin, replacing the previous record of that id. */\n async setclipconsent(record: clipboardconsentrecord): Promise<void> {\n const records = ((await this.adapter.get<clipboardconsentrecord[]>(\"clipconsents\")) ?? []).filter(item => item.id !== record.id);\n await this.adapter.set(\"clipconsents\", [record, ...records]);\n }\n\n /** Returns every clipboard consent record with its prompt and origin, newest first. */\n async getclipconsents(): Promise<clipboardconsentrecord[]> { return (await this.adapter.get<clipboardconsentrecord[]>(\"clipconsents\")) ?? []; }\n\n /** Records one clipboard entry hash with its origin provenance; the payload text itself never persists. */\n async addclip(entry: clipentry): Promise<void> {\n const records = await this.getclips();\n await this.adapter.set(\"clips\", [entry, ...records]);\n }\n\n /** Returns every clipboard entry hash with its kind and origin provenance, newest first. */\n async getclips(): Promise<clipentry[]> { return (await this.adapter.get<clipentry[]>(\"clips\")) ?? []; }\n\n /** Stores one quarantine entry with its scan verdict, replacing the previous entry of that id. */\n async setquarantine(entry: quarantineentry): Promise<void> {\n const records = ((await this.adapter.get<quarantineentry[]>(\"quarantines\")) ?? []).filter(item => item.id !== entry.id);\n await this.adapter.set(\"quarantines\", [entry, ...records]);\n }\n\n /** Returns every quarantine entry with its scan verdict and release ref, newest first. */\n async getquarantines(): Promise<quarantineentry[]> { return (await this.adapter.get<quarantineentry[]>(\"quarantines\")) ?? []; }\n\n /** Stores the reviewed cleanup rule set of the run, replacing the previous set. */\n async setcleanuprules(rules: cleanuprule[]): Promise<void> { return this.adapter.set(\"cleanuprules\", rules); }\n\n /** Returns the reviewed cleanup rule set of the run. */\n async getcleanuprules(): Promise<cleanuprule[]> { return (await this.adapter.get<cleanuprule[]>(\"cleanuprules\")) ?? []; }\n\n /** Records one cleanup run in the run history. */\n async addcleanuprun(run: cleanuprun): Promise<void> {\n const records = await this.getcleanupruns();\n await this.adapter.set(\"cleanupruns\", [run, ...records]);\n }\n\n /** Returns every cleanup run history record with removed and kept counts, newest first. */\n async getcleanupruns(): Promise<cleanuprun[]> { return (await this.adapter.get<cleanuprun[]>(\"cleanupruns\")) ?? []; }\n\n /** Stores the capture naming counters of one task, replacing the previous counters of that task. */\n async setcapturecounter(counter: capturecounter): Promise<void> {\n const records = ((await this.adapter.get<capturecounter[]>(\"capturecounters\")) ?? []).filter(item => item.taskid !== counter.taskid);\n await this.adapter.set(\"capturecounters\", [counter, ...records]);\n }\n\n /** Returns every stored capture naming counter per task, newest first. */\n async getcapturecounters(): Promise<capturecounter[]> { return (await this.adapter.get<capturecounter[]>(\"capturecounters\")) ?? []; }\n\n /** Replaces the artifact inventory the cleanup sweeper plans against. */\n async setinventory(entries: artifactinventoryentry[]): Promise<void> { return this.adapter.set(\"inventory\", entries); }\n\n /** Returns the artifact inventory with sizes and ages for the cleanup sweeper. */\n async getinventory(): Promise<artifactinventoryentry[]> { return (await this.adapter.get<artifactinventoryentry[]>(\"inventory\")) ?? []; }\n\n /** Stores one user configured virus scanning hook, replacing the previous hook of that scanner name. */\n async setscanhook(config: scanhookconfig): Promise<void> {\n const records = ((await this.adapter.get<scanhookconfig[]>(\"scanhooks\")) ?? []).filter(item => item.scanner !== config.scanner);\n await this.adapter.set(\"scanhooks\", [config, ...records]);\n }\n\n /** Returns every configured virus scanning hook, newest first. */\n async getscanhooks(): Promise<scanhookconfig[]> { return (await this.adapter.get<scanhookconfig[]>(\"scanhooks\")) ?? []; }\n\n /** Stores the armed mime interception filters of the run, newest first. */\n async setmimefilters(filters: mimefilter[]): Promise<void> { return this.adapter.set(\"mimefilters\", filters); }\n\n /** Returns the armed mime interception filters of the run, newest first. */\n async getmimefilters(): Promise<mimefilter[]> { return (await this.adapter.get<mimefilter[]>(\"mimefilters\")) ?? []; }\n\n /** Stores one capture record with its bytes and step linkage, replacing the previous record of that id; the user configured capture retention window expires the oldest bytes while the metadata always survives for the audit trail. */\n async addcapture(record: shotrecord): Promise<void> {\n const records = await this.getcaptures();\n const retention = (await this.getsettings())?.captureretention;\n const combined = [record, ...records.filter(item => item.id !== record.id)];\n const stored = retention === undefined ? combined : combined.map((item, index) => index < retention ? item : expirecapturebytes(item));\n await this.adapter.set(\"captures\", stored);\n }\n\n /** Returns every stored capture record with its metadata, newest first. */\n async getcaptures(): Promise<shotrecord[]> { return (await this.adapter.get<shotrecord[]>(\"captures\")) ?? []; }\n\n /** Returns one capture record with its bytes by its id. */\n async getcapture(id: string): Promise<shotrecord | undefined> { return (await this.getcaptures()).find(item => item.id === id); }\n\n /** Returns the capture records filtered by run, step and kind. */\n async listcaptures(filter: { runid?: string; stepid?: string; kind?: string }): Promise<shotrecord[]> {\n const records = await this.getcaptures();\n return records.filter(item => (filter.runid === undefined || item.runid === filter.runid) && (filter.stepid === undefined || item.stepid === filter.stepid) && (filter.kind === undefined || item.kind === filter.kind));\n }\n\n /** Records one before and after shotpair of the run with its action context. */\n async addpair(pair: shotpair): Promise<void> {\n const records = await this.getpairs();\n await this.adapter.set(\"capturepairs\", [pair, ...records.filter(item => item.id !== pair.id)]);\n }\n\n /** Returns the shotpairs of one run resolved through their before records, newest first; an absent run returns every pair. */\n async getpairs(runid?: string): Promise<shotpair[]> {\n const records = (await this.adapter.get<shotpair[]>(\"capturepairs\")) ?? [];\n if (runid === undefined) return records;\n const runs = new Map<string, string>();\n for (const capture of await this.getcaptures()) runs.set(capture.id, capture.runid);\n return records.filter(item => runs.get(item.beforeid) === runid);\n }\n\n /** Stores one media record of the 1.1.41 family with its bytes and step linkage, replacing the previous record of that id; the user configured media retention window expires the oldest bytes while the metadata and the recording index always survive. */\n async addmedia(record: mediarecord): Promise<void> {\n const records = await this.getmediarecords();\n const retention = (await this.getsettings())?.mediaretention;\n const combined = [record, ...records.filter(item => item.id !== record.id)];\n const stored = retention === undefined ? combined : combined.map((item, index) => index < retention ? item : expiremediabytes(item));\n await this.adapter.set(\"media\", stored);\n }\n\n /** Returns every stored media record, newest first. */\n async getmediarecords(): Promise<mediarecord[]> { return (await this.adapter.get<mediarecord[]>(\"media\")) ?? []; }\n\n /** Returns the media records filtered by run and kind; an absent filter returns every record. */\n async listmedia(filter: { runid?: string; kind?: string }): Promise<mediarecord[]> {\n const records = await this.getmediarecords();\n return records.filter(item => (filter.runid === undefined || item.runid === filter.runid) && (filter.kind === undefined || mediakindof(item) === filter.kind));\n }\n\n /** Returns one media record by its id. */\n async getmediarecord(id: string): Promise<mediarecord | undefined> { return (await this.getmediarecords()).find(item => item.id === id); }\n\n /** Returns one recording with its file reference and frame index by its id. */\n async getrecording(id: string): Promise<recordingrecord | undefined> {\n const found = await this.getmediarecord(id);\n return found !== undefined && \"startedat\" in found ? found : undefined;\n }\n\n /** Removes one media record by its id; the audit trail keeps its outcome evidence. */\n async removemedia(id: string): Promise<void> {\n await this.adapter.set(\"media\", (await this.getmediarecords()).filter(item => item.id !== id));\n }\n\n /** Stores one observed image batch of a downloadimages step, replacing the previous batch of that id. */\n async addimagebatch(batch: imagebatch): Promise<void> {\n const records = (await this.adapter.get<imagebatch[]>(\"imagebatches\")) ?? [];\n await this.adapter.set(\"imagebatches\", [batch, ...records.filter(item => item.id !== batch.id)]);\n }\n\n /** Returns every observed image batch with its filter match counts, newest first. */\n async getimagebatches(): Promise<imagebatch[]> { return (await this.adapter.get<imagebatch[]>(\"imagebatches\")) ?? []; }\n\n /** Stores one recording consent decision of an origin, replacing the previous record of that id. */\n async setrecordingconsent(record: recordingconsentrecord): Promise<void> {\n const records = ((await this.adapter.get<recordingconsentrecord[]>(\"recordingconsents\")) ?? []).filter(item => item.id !== record.id);\n await this.adapter.set(\"recordingconsents\", [record, ...records]);\n }\n\n /** Returns every recording consent decision with its prompt and origin, newest first. */\n async getrecordingconsents(): Promise<recordingconsentrecord[]> { return (await this.adapter.get<recordingconsentrecord[]>(\"recordingconsents\")) ?? []; }\n}\n\n/** Resolves the media family discriminator of one stored media record. */\nfunction mediakindof(record: mediarecord): string {\n if (\"pages\" in record) return \"pdf\";\n if (\"startedat\" in record) return \"recording\";\n if (\"timestamp\" in record) return \"frame\";\n if (\"context\" in record) return \"canvas\";\n if (\"tracks\" in record) return \"stream\";\n return \"asset\";\n}\n\n/** Expires the bytes of one media record while keeping the metadata and the recording frame index for the audit trail. */\nfunction expiremediabytes(record: mediarecord): mediarecord {\n if (\"dataurl\" in record) {\n const source = record as pdfrecord | canvasrecord | framerecord;\n const copy = { ...source } as { dataurl?: string };\n delete copy.dataurl;\n return { ...copy, bytesexpired: true } as mediarecord;\n }\n if (\"startedat\" in record) {\n const source = record as recordingrecord;\n const copy = { ...source };\n delete copy.bytes;\n return { ...copy, bytesexpired: true };\n }\n return record;\n}\n\n/** Expires the bytes of one capture record while keeping the metadata for the audit trail. */\nfunction expirecapturebytes(record: shotrecord): shotrecord {\n const { bytes, ...metadata } = record;\n void bytes;\n return { ...metadata, bytesexpired: true };\n}\n\n/** Creates identifiers locally without a network dependency. */\nexport function randomid(): string {\n return crypto.randomUUID();\n}\n", "import type { actionkind, agentplan, agentsession, captureexport, captureformat, capturenaming, captureoptions, cleanuprule, downloadspec, endpointconfig, fieldkind, formprofile, mimefilter, observationmode, policyevaluation, quarantineentry, regionrect, runsettings, safetyverdict, toolstep, transformrule } from \"./types.js\";\n\nconst sensitiveactions = new Set<actionkind>([\"click\", \"type\", \"navigate\", \"select\", \"presskey\", \"drag\", \"drop\", \"upload\", \"clear\", \"check\", \"uncheck\", \"toggle\", \"submit\", \"reload\", \"back\", \"forward\", \"writestorage\", \"setattribute\", \"removeattribute\", \"evaluate\", \"tabcreate\", \"tabactivate\", \"tabclose\", \"tabreload\", \"windowcreate\", \"windowclose\", \"windowresize\", \"downloadfile\", \"clickpoint\", \"shiftclick\", \"dismissdialog\", \"enterframe\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"keyhold\", \"keyrelease\", \"submitsearch\", \"selectmulti\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"openlink\", \"openprivate\", \"reloadcache\", \"stopnav\", \"followlink\", \"spanav\", \"rewritequery\", \"setfragment\", \"navlist\", \"navprofile\", \"handleauth\", \"printpdf\", \"prefetch\", \"preconnect\", \"deeplink\", \"reopentab\", \"pausenav\", \"navrate\", \"openclipboard\", \"batchopen\", \"duplicatetab\", \"closepattern\", \"pintab\", \"mutetab\", \"movetab\", \"movetabwindow\", \"grouptabs\", \"colorgroup\", \"collapsegroup\", \"discardtab\", \"reloadtabs\", \"zoomin\", \"zoomout\", \"switchtab\", \"maximizewindow\", \"minimizewindow\", \"restorewindow\", \"focuswindow\", \"scratchwindow\", \"incognitowindow\", \"restoretab\", \"restorelayout\", \"reopenrun\", \"badgetab\", \"fillform\", \"filllabel\", \"fillplaceholder\", \"submitform\", \"retryform\", \"runwizard\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"fillcard\", \"fillcode\", \"consentpassword\", \"exportcsv\", \"exportjson\", \"exportexcel\", \"copytable\", \"pushsheets\", \"streamdisk\", \"paginateextract\", \"resumeextract\", \"batchdownload\", \"pausedownload\", \"resumedownload\", \"interceptmime\", \"readclipboard\", \"writeclipboard\", \"copyscreen\", \"quarantinedownload\", \"scanvirus\", \"cleanupartifacts\", \"recordscreen\", \"captureaudio\", \"downloadimages\"]);\nconst interactionactions = new Set<actionkind>([\"focus\", \"scroll\", \"hover\", \"clickdeep\", \"rightclick\", \"doubleclick\", \"scrollpage\", \"scrollby\", \"scrollend\", \"scrolltop\", \"fullscreen\", \"zoomset\", \"movepointer\", \"clicktext\", \"clickaria\", \"clickname\", \"expanddetails\", \"pierceshadow\", \"retryaction\"]);\nconst readactions = new Set<actionkind>([\"observe\", \"inspect\", \"extract\", \"wait\", \"waitfor\", \"waittext\", \"readattribute\", \"readstyle\", \"readgeometry\", \"readvalue\", \"readtext\", \"readhtml\", \"countelements\", \"readtable\", \"readlinks\", \"readimages\", \"readmeta\", \"readforms\", \"readstorage\", \"highlight\", \"tablist\", \"windowlist\", \"tabsnapshot\", \"mapclicks\", \"verifyvisible\", \"verifyenabled\", \"resolvexpath\", \"a11ytree\", \"readvisible\", \"readertree\", \"detectlists\", \"detecttables\", \"readjson\", \"watchmutate\", \"waitquiet\", \"watchbanner\", \"detectinfinitescroll\", \"detectvirtual\", \"detectlazy\", \"readscrollpos\", \"readlang\", \"readoutline\", \"countpages\", \"listshadow\", \"listframes\", \"classifypage\", \"fingerprintsection\", \"diffsnapshots\", \"readselection\", \"watchfocus\", \"detectsticky\", \"detectscrolllock\", \"readopengraph\", \"detectlanguage\", \"deriveselector\", \"waitload\", \"waiturl\", \"spawait\", \"detecthttp\", \"readredirects\", \"readfinalurl\", \"trailaudit\", \"navintent\", \"checksafe\", \"querytabs\", \"watchtab\", \"findclones\", \"searchtabs\", \"listaudio\", \"snapshotsession\", \"savelayout\", \"attachmeta\", \"detectfields\", \"generatevalues\", \"saveprofiles\", \"asksubmit\", \"readerrors\", \"skiphoneypot\", \"detectlogin\", \"detecttemplate\", \"handoffcaptcha\", \"scrapetable\", \"importcsv\", \"looprows\", \"transformvalues\", \"deduperows\", \"mergepages\", \"stamplerows\", \"previewgrid\", \"logprovenance\", \"verifydownload\", \"exportnetlog\", \"namecaptures\", \"shotview\", \"shotfullpage\", \"shotelement\", \"shotregion\", \"contactsheet\", \"capturepdf\", \"captureframe\", \"readmedia\", \"readassets\", \"probestream\", \"timelapse\", \"shotcanvas\", \"convertimage\", \"makethumbs\"]);\nconst allowedactions = new Set<actionkind>([...sensitiveactions, ...interactionactions, ...readactions]);\nconst watchactions = new Set<actionkind>([\"watchmutate\", \"watchbanner\", \"watchfocus\", \"watchtab\"]);\nconst targetactions = new Set<actionkind>([\"inspect\", \"focus\", \"click\", \"type\", \"scroll\", \"select\", \"hover\", \"clickdeep\", \"rightclick\", \"doubleclick\", \"drag\", \"drop\", \"upload\", \"clear\", \"check\", \"uncheck\", \"toggle\", \"submit\", \"readattribute\", \"readstyle\", \"readgeometry\", \"readvalue\", \"readtext\", \"readhtml\", \"countelements\", \"readtable\", \"highlight\", \"setattribute\", \"removeattribute\", \"waitfor\", \"shiftclick\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"submitsearch\", \"selectmulti\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"expanddetails\", \"verifyvisible\", \"verifyenabled\", \"pierceshadow\", \"deriveselector\", \"fingerprintsection\", \"submitform\", \"retryform\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"fillcode\", \"consentpassword\", \"scrapetable\", \"paginateextract\", \"shotelement\", \"captureframe\", \"shotcanvas\"]);\nconst valueactions = new Set<actionkind>([\"presskey\", \"drag\", \"drop\", \"upload\", \"readattribute\", \"removeattribute\", \"waittext\", \"evaluate\", \"zoomset\", \"tabactivate\", \"tabclose\", \"tabreload\", \"windowclose\", \"windowresize\", \"tabcreate\", \"windowcreate\", \"downloadfile\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"keyhold\", \"keyrelease\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"followlink\", \"setfragment\", \"handleauth\", \"navintent\", \"openclipboard\", \"checksafe\", \"reopentab\", \"spanav\", \"duplicatetab\", \"pintab\", \"mutetab\", \"movetab\", \"movetabwindow\", \"searchtabs\", \"badgetab\", \"attachmeta\", \"focuswindow\", \"maximizewindow\", \"minimizewindow\", \"restorewindow\", \"incognitowindow\", \"asksubmit\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"fillcode\", \"consentpassword\", \"pausedownload\", \"resumedownload\", \"verifydownload\", \"writeclipboard\", \"quarantinedownload\", \"scanvirus\"]);\nconst tabscommandactions = new Set<actionkind>([\"querytabs\", \"duplicatetab\", \"closepattern\", \"pintab\", \"mutetab\", \"movetab\", \"movetabwindow\", \"grouptabs\", \"colorgroup\", \"collapsegroup\", \"discardtab\", \"reloadtabs\", \"zoomin\", \"zoomout\", \"watchtab\", \"switchtab\", \"maximizewindow\", \"minimizewindow\", \"restorewindow\", \"focuswindow\", \"scratchwindow\", \"incognitowindow\", \"restoretab\", \"savelayout\", \"restorelayout\", \"findclones\", \"searchtabs\", \"badgetab\", \"attachmeta\", \"listaudio\", \"reopenrun\", \"snapshotsession\"]);\nconst formactions = new Set<actionkind>([\"fillform\", \"filllabel\", \"fillplaceholder\", \"detectfields\", \"generatevalues\", \"saveprofiles\", \"asksubmit\", \"submitform\", \"readerrors\", \"retryform\", \"runwizard\", \"selectchain\", \"picktypeahead\", \"pickdate\", \"attachfile\", \"handoffcaptcha\", \"fillcard\", \"fillcode\", \"consentpassword\", \"skiphoneypot\", \"detectlogin\", \"detecttemplate\"]);\n/** Extraction, transform, export and provenance kinds of the forms and data part two family. */\nconst datasetactions = new Set<actionkind>([\"scrapetable\", \"exportcsv\", \"exportjson\", \"exportexcel\", \"copytable\", \"pushsheets\", \"importcsv\", \"looprows\", \"transformvalues\", \"deduperows\", \"paginateextract\", \"mergepages\", \"stamplerows\", \"previewgrid\", \"streamdisk\", \"resumeextract\", \"logprovenance\"]);\n/** Export kinds that move extracted data out of local memory to disk, the clipboard or a reviewed sheet endpoint. */\nconst exportactions = new Set<actionkind>([\"exportcsv\", \"exportjson\", \"exportexcel\", \"copytable\", \"pushsheets\", \"streamdisk\"]);\n/** Files, clipboard and downloads kinds of the batch queue, interception, clipboard, quarantine, naming and cleanup family. */\nconst filesactions = new Set<actionkind>([\"batchdownload\", \"pausedownload\", \"resumedownload\", \"verifydownload\", \"interceptmime\", \"exportnetlog\", \"readclipboard\", \"writeclipboard\", \"copyscreen\", \"quarantinedownload\", \"scanvirus\", \"namecaptures\", \"cleanupartifacts\"]);\nconst captureactions = new Set<actionkind>([\"shotview\", \"shotfullpage\", \"shotelement\", \"shotregion\", \"contactsheet\"]);\n/** Media capture part two kinds of the pdf, recording, image, canvas, stream, asset, lapse, conversion and thumbnail family. */\nconst mediaactions = new Set<actionkind>([\"capturepdf\", \"recordscreen\", \"captureaudio\", \"captureframe\", \"downloadimages\", \"shotcanvas\", \"probestream\", \"readmedia\", \"readassets\", \"timelapse\", \"convertimage\", \"makethumbs\"]);\n/** Field kinds the form grammar accepts inside records, profiles and value rules. */\nconst fieldkinds: fieldkind[] = [\"text\", \"email\", \"phone\", \"date\", \"number\", \"select\", \"check\", \"radio\", \"file\", \"password\", \"card\", \"code\"];\nconst layoutmutationactions = new Set<actionkind>([\"grouptabs\", \"colorgroup\", \"collapsegroup\", \"savelayout\", \"restorelayout\"]);\n/** Chromium tab group colors accepted as reviewed group color choices. */\nconst groupcolors = [\"grey\", \"blue\", \"red\", \"yellow\", \"green\", \"pink\", \"purple\", \"cyan\", \"orange\"];\n\n/** Normalizes a user supplied HTTPS endpoint without preserving a provider lock-in. */\nexport function normalizeendpoint(value: string): endpointconfig {\n const endpoint = new URL(value.trim());\n if (endpoint.protocol !== \"https:\") throw new Error(\"Devthink accepts HTTPS endpoints only.\");\n if (endpoint.username || endpoint.password) throw new Error(\"Endpoint credentials are not allowed in the URL.\");\n return { endpoint: endpoint.toString(), origin: endpoint.origin, configuredat: Date.now() };\n}\n\n/** Creates the exact optional host pattern requested from Chromium. */\nexport function hostpattern(origin: string): string {\n const parsed = new URL(origin);\n if (parsed.protocol !== \"https:\") throw new Error(\"Only HTTPS origins can be granted.\");\n return `${parsed.origin}/*`;\n}\n\n/** True when the action kind observes the page over a reviewed lifetime window. */\nexport function iswatchkind(kind: actionkind): boolean {\n return watchactions.has(kind);\n}\n\n/** Grades the observation mode of a kind: passive capture, watched lifetimes or diffing passes. */\nexport function observationmodeof(kind: actionkind): observationmode {\n if (watchactions.has(kind) || kind === \"waitquiet\") return \"watching\";\n if (kind === \"diffsnapshots\") return \"diffing\";\n return \"passive\";\n}\n\n/** Defines action risk from the fixed local allowlist. */\nexport function actionrisk(kind: actionkind): \"read\" | \"interaction\" | \"sensitive\" {\n if (!allowedactions.has(kind)) throw new Error(\"Unsupported browser action.\");\n if (sensitiveactions.has(kind)) return \"sensitive\";\n return interactionactions.has(kind) ? \"interaction\" : \"read\";\n}\n\n/** True when the action kind accepts a css selector target or a reviewed targetref. */\nexport function needstarget(kind: actionkind): boolean {\n return targetactions.has(kind);\n}\n\n/** Parses the reviewed JSON options of a step; malformed payloads are rejected early. */\nexport function parseoptions(step: toolstep): Record<string, unknown> {\n if (step.options === undefined) return {};\n let parsed: unknown;\n try { parsed = JSON.parse(step.options); } catch { throw new Error(\"Step options must be a JSON object.\"); }\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) throw new Error(\"Step options must be a JSON object.\");\n return parsed as Record<string, unknown>;\n}\n\n/** Maps an action kind to the optional browser permission it requires, if any. */\nexport function requiredcapability(kind: actionkind): string | undefined {\n if (kind === \"tablist\") return \"tabs\";\n if (kind === \"downloadfile\") return \"downloads\";\n if (kind === \"openclipboard\") return \"clipboardRead\";\n if (kind === \"copytable\") return \"clipboardWrite\";\n if (kind === \"batchdownload\" || kind === \"pausedownload\" || kind === \"resumedownload\" || kind === \"verifydownload\" || kind === \"interceptmime\" || kind === \"quarantinedownload\" || kind === \"scanvirus\") return \"downloads\";\n if (kind === \"readclipboard\") return \"clipboardRead\";\n if (kind === \"writeclipboard\" || kind === \"copyscreen\") return \"clipboardWrite\";\n if (kind === \"downloadimages\") return \"downloads\";\n if (kind === \"openlink\" || kind === \"openprivate\" || kind === \"navlist\" || kind === \"batchopen\" || kind === \"reopentab\" || kind === \"deeplink\") return \"tabs\";\n if (tabscommandactions.has(kind)) return \"tabs\";\n return undefined;\n}\n\n/** True when the kind commands tabs or windows beyond the active tab and needs the optional tabs capability. */\nexport function istabscommandkind(kind: actionkind): boolean {\n return tabscommandactions.has(kind);\n}\n\n/** True when the kind mutates tab groups or layouts and therefore stays inside the active session. */\nexport function islayoutkind(kind: actionkind): boolean {\n return layoutmutationactions.has(kind);\n}\n\n/** True when the kind belongs to the forms and data family. */\nexport function isformkind(kind: actionkind): boolean {\n return formactions.has(kind);\n}\n\n/** True when the kind belongs to the extraction, transform, export and provenance family. */\nexport function isdatasetkind(kind: actionkind): boolean {\n return datasetactions.has(kind);\n}\n\n/** True when the kind exports extracted data out of local memory to disk, the clipboard or a reviewed sheet endpoint. */\nexport function isexportkind(kind: actionkind): boolean {\n return exportactions.has(kind);\n}\n\n/** True when the kind belongs to the files, clipboard and downloads family. */\nexport function isfileskind(kind: actionkind): boolean {\n return filesactions.has(kind);\n}\n\n/** True when the kind belongs to the media capture family of viewport, full page, element, region and contact sheet shots. */\nexport function iscapturekind(kind: actionkind): boolean {\n return captureactions.has(kind);\n}\n\n/** Requires the active tab grant of the live session before any capture kind runs: the session tab and origin must match and the origin grant must cover the active origin. */\nexport function capturegate(session: agentsession | undefined, tabid: number, origin: string, now: number): policyevaluation {\n if (!session || session.stoppedat) return { allowed: false, reason: \"No active browser session exists for the capture.\" };\n if (session.expiresat <= now) return { allowed: false, reason: \"The browser session has expired and cannot capture.\" };\n if (session.pausedat) return { allowed: false, reason: \"The browser session is paused and cannot capture.\" };\n if (session.tabid !== tabid) return { allowed: false, reason: `The capture needs the active tab grant of session tab ${session.tabid} and refuses tab ${tabid}.` };\n if (!origingranted(session, origin)) return { allowed: false, reason: `The capture of ${origin} needs the session origin grants first.` };\n return { allowed: true };\n}\n\n/** Validates one reviewed capture options payload: format inside the png, jpeg and webp set, quality bounded only by the format range, pixel ratio from one up with no code ceiling, and a known export target. */\nexport function validatecaptureoptions(value: unknown): policyevaluation {\n if (value === undefined) return { allowed: true };\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"The reviewed capture options must be an object in options.capture.\" };\n const options = value as Record<string, unknown>;\n if (options.format !== undefined && options.format !== \"png\" && options.format !== \"jpeg\" && options.format !== \"webp\") return { allowed: false, reason: \"The reviewed capture format must be png, jpeg or webp.\" };\n if (options.quality !== undefined && (typeof options.quality !== \"number\" || !Number.isFinite(options.quality) || options.quality < 0 || options.quality > 100)) return { allowed: false, reason: \"The reviewed capture quality must stay between zero and one hundred; any value in that range is the user choice with no code cap.\" };\n if (options.pixelratio !== undefined && (typeof options.pixelratio !== \"number\" || !Number.isFinite(options.pixelratio) || options.pixelratio < 1)) return { allowed: false, reason: \"The reviewed pixel ratio starts at one and climbs to any user configured ceiling with no code ceiling.\" };\n if (options.annotate !== undefined && typeof options.annotate !== \"boolean\") return { allowed: false, reason: \"The reviewed capture annotation flag must be a boolean.\" };\n if (options.exporttarget !== undefined && options.exporttarget !== \"memory\" && options.exporttarget !== \"download\" && options.exporttarget !== \"clipboard\") return { allowed: false, reason: \"The reviewed capture export target must be memory, download or clipboard.\" };\n return { allowed: true };\n}\n\n/** Validates one reviewed region rectangle in css pixels; negative coordinates and non positive sizes are refused. */\nexport function validateregionrect(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed regionrect with x, y, width and height in css pixels is required in options.\" };\n const rect = value as Record<string, unknown>;\n for (const field of [\"x\", \"y\", \"width\", \"height\"]) {\n if (typeof rect[field] !== \"number\" || !Number.isFinite(rect[field] as number)) return { allowed: false, reason: `The reviewed regionrect needs a numeric ${field} in css pixels.` };\n }\n if ((rect.x as number) < 0 || (rect.y as number) < 0) return { allowed: false, reason: \"The reviewed regionrect refuses negative coordinates.\" };\n if ((rect.width as number) <= 0 || (rect.height as number) <= 0) return { allowed: false, reason: \"The reviewed regionrect needs positive width and height values.\" };\n return { allowed: true };\n}\n\n/** Validates one reviewed capture naming rule against the allowed segment set: run, step, sequence and kind flags only. */\nexport function validatecapturenaming(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed capturenaming rule with run, step, sequence and kind flags is required.\" };\n const rule = value as Record<string, unknown>;\n const segments = [\"run\", \"step\", \"sequence\", \"kind\"];\n for (const key of Object.keys(rule)) {\n if (!segments.includes(key)) return { allowed: false, reason: `The reviewed capturenaming rule refuses the unknown ${key} segment; only run, step, sequence and kind participate.` };\n }\n for (const segment of segments) {\n if (rule[segment] !== undefined && typeof rule[segment] !== \"boolean\") return { allowed: false, reason: `The reviewed capturenaming ${segment} flag must be a boolean.` };\n }\n if (!segments.some(segment => rule[segment] === true)) return { allowed: false, reason: \"The reviewed capturenaming rule needs at least one enabled segment of run, step, sequence and kind.\" };\n return { allowed: true };\n}\n\n/** Routes the capture export target: memory stays local, clipboard needs the clipboardwrite grant and disk writes only run through the reviewed download flow. */\nexport function captureexportgranted(target: captureexport | undefined): policyevaluation {\n if (target === undefined || target === \"memory\") return { allowed: true };\n if (target === \"clipboard\") return { allowed: true, reason: \"The clipboard capture export runs behind the optional clipboardwrite capability, negotiated through the permissions api before the copy.\" };\n if (target === \"download\") return { allowed: true, reason: \"The download capture export runs only through the reviewed download flow behind the optional downloads capability.\" };\n return { allowed: false, reason: \"The capture export target must be memory, download or clipboard; no other disk route exists.\" };\n}\n\n/** Keeps the stitching scroll budget inside the reviewed wait window: the settle windows of every tile must fit the reviewed wait window with no code ceiling on either side. */\nexport function stitchbudgetallowed(tiles: number, settle: number, wait: number): policyevaluation {\n if (tiles <= 0) return { allowed: false, reason: \"The stitch budget needs at least one tile.\" };\n if (settle < 0 || wait < 0) return { allowed: false, reason: \"The reviewed settle and wait windows must be zero or positive milliseconds.\" };\n if (tiles * settle > wait) return { allowed: false, reason: `The stitching scroll budget of ${tiles} tiles at ${settle} milliseconds exceeds the reviewed wait window of ${wait} milliseconds; review a wider window or a smaller settle.` };\n return { allowed: true };\n}\n\n/** Allows beforeafter state capture to wrap any existing action kind except the capture kinds themselves; pixel evidence around sensitive actions grades as reviewable evidence. */\nexport function beforeafterwrapallowed(kind: actionkind): boolean {\n return allowedactions.has(kind) && !captureactions.has(kind);\n}\n\n/** Exposes the capture retention window as a user configured choice; an absent value keeps every capture byte forever with no code ceiling. */\nexport function captureretentionwindow(settings: runsettings | undefined): number | undefined {\n return settings?.captureretention;\n}\n\n/** Validates the reviewed media capture parameter grammar; pixel ratios, quality values, cell counts and retention windows stay user choices with no code ceilings. */\nfunction validatecapturegrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n const optioncheck = validatecaptureoptions(options.capture);\n if (!optioncheck.allowed) return optioncheck;\n if (options.settle !== undefined && (typeof options.settle !== \"number\" || !Number.isFinite(options.settle) || options.settle < 0)) return { allowed: false, reason: \"The reviewed capture settle window must be zero or a positive number of milliseconds.\" };\n if (options.overlap !== undefined && (typeof options.overlap !== \"number\" || !Number.isInteger(options.overlap) || options.overlap < 0)) return { allowed: false, reason: \"The reviewed stitch overlap must be zero or a positive number of rows.\" };\n if (options.wait !== undefined && (typeof options.wait !== \"number\" || !Number.isFinite(options.wait) || options.wait < 0)) return { allowed: false, reason: \"The reviewed capture wait window must be zero or a positive number of milliseconds.\" };\n if (options.naming !== undefined) {\n const namingcheck = validatecapturenaming(options.naming);\n if (!namingcheck.allowed) return namingcheck;\n }\n if (kind === \"shotregion\") {\n const rectcheck = validateregionrect(options.regionrect);\n if (!rectcheck.allowed) return rectcheck;\n if (options.reviewed !== true) return { allowed: false, reason: \"Every reviewed regionrect needs the explicit reviewed flag before shotregion runs.\" };\n if (options.container !== undefined && !isnonempty(options.container)) return { allowed: false, reason: \"The reviewed scrollable container selector must be a non-empty string.\" };\n if (options.steps !== undefined && (typeof options.steps !== \"number\" || !Number.isInteger(options.steps) || options.steps < 1)) return { allowed: false, reason: \"The reviewed container scroll steps must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"contactsheet\") {\n const elements = options.elements;\n if (!Array.isArray(elements) || elements.length === 0 || !elements.every(item => isnonempty(item))) return { allowed: false, reason: \"A reviewed non-empty list of element selectors is required in options for the contact sheet; the cell count stays the user choice.\" };\n const layout = options.sheet;\n if (layout !== undefined) {\n if (!layout || typeof layout !== \"object\" || Array.isArray(layout)) return { allowed: false, reason: \"The reviewed sheetlayout must be an object with cellsize, columns and label.\" };\n const sheet = layout as Record<string, unknown>;\n if (typeof sheet.cellsize !== \"number\" || !Number.isFinite(sheet.cellsize) || sheet.cellsize <= 0) return { allowed: false, reason: \"The reviewed contact sheet cell size must be a positive number of pixels.\" };\n if (typeof sheet.columns !== \"number\" || !Number.isInteger(sheet.columns) || sheet.columns < 1) return { allowed: false, reason: \"The reviewed contact sheet column count must be a positive integer with no code ceiling.\" };\n if (sheet.label !== undefined && sheet.label !== \"none\" && sheet.label !== \"index\" && sheet.label !== \"selector\" && sheet.label !== \"both\") return { allowed: false, reason: \"The reviewed contact sheet label style must be none, index, selector or both.\" };\n }\n }\n return { allowed: true };\n}\n\n/** Refuses any export that would leave local memory while the session origin grants do not cover the active origin. */\nexport function exportgranted(session: agentsession | undefined, origin: string): policyevaluation {\n if (!origingranted(session, origin)) return { allowed: false, reason: `The export of extracted data from ${origin} needs the session origin grants before it leaves local memory.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed fieldmatch grammar of one form field entry. */\nexport function validatefieldmatch(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed field match is required in options.\" };\n const match = value as Record<string, unknown>;\n if (match.mode !== \"label\" && match.mode !== \"placeholder\" && match.mode !== \"arialabel\" && match.mode !== \"name\") return { allowed: false, reason: \"The reviewed field match mode must be label, placeholder, arialabel or name.\" };\n const key = match.mode === \"label\" ? \"label\" : match.mode === \"placeholder\" ? \"placeholder\" : match.mode === \"arialabel\" ? \"arialabel\" : \"name\";\n if (!isnonempty(match[key])) return { allowed: false, reason: `The reviewed ${match.mode} field match needs a non-empty ${key}.` };\n return { allowed: true };\n}\n\n/** Validates a reviewed structured form record; password entries are refused because passwords need the explicit consentpassword consent. */\nexport function validateformrecord(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed form record with entries is required in options.\" };\n const record = value as Record<string, unknown>;\n if (record.form !== undefined && !isnonempty(record.form)) return { allowed: false, reason: \"The reviewed form record form selector must be a non-empty string.\" };\n if (!Array.isArray(record.entries) || record.entries.length === 0) return { allowed: false, reason: \"The reviewed form record needs a non-empty list of entries.\" };\n for (const item of record.entries) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return { allowed: false, reason: \"Every reviewed form record entry must be an object.\" };\n const entry = item as Record<string, unknown>;\n const matchcheck = validatefieldmatch(entry.match);\n if (!matchcheck.allowed) return matchcheck;\n if (typeof entry.kind !== \"string\" || !fieldkinds.includes(entry.kind as fieldkind)) return { allowed: false, reason: \"Every reviewed form record entry needs a known field kind.\" };\n if (typeof entry.value !== \"string\") return { allowed: false, reason: \"Every reviewed form record entry needs a string value.\" };\n if (entry.kind === \"password\") return { allowed: false, reason: \"Password entries are refused inside form records; use consentpassword with a reviewed consent ref.\" };\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed valuegen grammar of a generatevalues step. */\nexport function validatevaluegen(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed valuegen rule with a field kind is required in options.\" };\n const rule = value as Record<string, unknown>;\n if (typeof rule.kind !== \"string\" || !fieldkinds.includes(rule.kind as fieldkind)) return { allowed: false, reason: \"The reviewed valuegen kind must be a known field kind.\" };\n if (rule.locale !== undefined && !isnonempty(rule.locale)) return { allowed: false, reason: \"The reviewed valuegen locale must be a non-empty string.\" };\n if (rule.seed !== undefined && (typeof rule.seed !== \"number\" || !Number.isFinite(rule.seed))) return { allowed: false, reason: \"The reviewed valuegen seed must be a finite number.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed list of label or placeholder value pairs for filllabel and fillplaceholder steps. */\nfunction validatefieldpairs(options: Record<string, unknown>, mode: \"label\" | \"placeholder\"): policyevaluation {\n const pairs = options.fields;\n if (!Array.isArray(pairs) || pairs.length === 0) return { allowed: false, reason: \"A reviewed non-empty list of field pairs is required in options.\" };\n for (const item of pairs) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return { allowed: false, reason: \"Every reviewed field pair must be an object.\" };\n const pair = item as Record<string, unknown>;\n if (!isnonempty(pair[mode])) return { allowed: false, reason: `Every reviewed field pair needs a non-empty ${mode}.` };\n if (typeof pair.value !== \"string\" || !pair.value.trim()) return { allowed: false, reason: \"Every reviewed field pair needs a non-empty value.\" };\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed card segment grammar of a fillcard step. */\nfunction validatecardsegments(value: unknown): policyevaluation {\n if (!Array.isArray(value) || value.length === 0) return { allowed: false, reason: \"A reviewed non-empty list of card segments is required in options.\" };\n for (const item of value) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) return { allowed: false, reason: \"Every reviewed card segment must be an object.\" };\n const segment = item as Record<string, unknown>;\n const matchcheck = validatefieldmatch(segment.match);\n if (!matchcheck.allowed) return matchcheck;\n if (typeof segment.value !== \"string\" || !segment.value.trim()) return { allowed: false, reason: \"Every reviewed card segment needs a non-empty value.\" };\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed forms and data parameter grammar of the form family. */\nfunction validateformgrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"fillform\" || (kind === \"saveprofiles\" && options.formrecord !== undefined)) {\n const recordcheck = validateformrecord(options.formrecord);\n if (!recordcheck.allowed) return recordcheck;\n }\n if (kind === \"filllabel\" || kind === \"fillplaceholder\") {\n const paircheck = validatefieldpairs(options, kind === \"filllabel\" ? \"label\" : \"placeholder\");\n if (!paircheck.allowed) return paircheck;\n }\n if (kind === \"generatevalues\" && options.valuegen !== undefined) {\n const rulecheck = validatevaluegen(options.valuegen);\n if (!rulecheck.allowed) return rulecheck;\n }\n if (kind === \"saveprofiles\" && !isnonempty(options.name)) return { allowed: false, reason: \"A reviewed profile name is required in options.\" };\n if (kind === \"submitform\" && !isnonempty(options.consentref)) return { allowed: false, reason: \"A reviewed consent ref of an approved asksubmit ticket is required in options.\" };\n if (kind === \"retryform\") {\n const backoff = options.backoff;\n if (!backoff || typeof backoff !== \"object\" || Array.isArray(backoff)) return { allowed: false, reason: \"A reviewed backoff rule with wait and factor is required in options.\" };\n const rule = backoff as Record<string, unknown>;\n if (typeof rule.wait !== \"number\" || !Number.isFinite(rule.wait) || rule.wait <= 0) return { allowed: false, reason: \"The reviewed retry backoff wait must be a positive number of milliseconds with no code ceiling.\" };\n if (typeof rule.factor !== \"number\" || !Number.isFinite(rule.factor) || rule.factor < 1) return { allowed: false, reason: \"The reviewed retry backoff factor must be one or greater with no code ceiling.\" };\n if (options.attempts !== undefined && (typeof options.attempts !== \"number\" || !Number.isInteger(options.attempts) || options.attempts < 1)) return { allowed: false, reason: \"The reviewed retry attempts must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"runwizard\" && options.steps !== undefined && (typeof options.steps !== \"number\" || !Number.isInteger(options.steps) || options.steps < 1)) return { allowed: false, reason: \"The reviewed wizard step count must be a positive integer with no code ceiling.\" };\n if (kind === \"selectchain\") {\n if (!isnonempty(options.child)) return { allowed: false, reason: \"A reviewed child selector of the dependent control is required in options.\" };\n if (!nonnegativeoption(options, \"wait\")) return { allowed: false, reason: \"The reviewed dependent wait must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"picktypeahead\") {\n if (!isnonempty(options.pick)) return { allowed: false, reason: \"A reviewed suggestion entry to pick is required in options.\" };\n if (!nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The reviewed typeahead timeout must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"pickdate\" && !/^\\d{4}-\\d{2}-\\d{2}$/.test(step.value ?? \"\")) return { allowed: false, reason: \"The reviewed date must use the yyyy-mm-dd form.\" };\n if (kind === \"fillcard\") {\n const segmentcheck = validatecardsegments(options.segments);\n if (!segmentcheck.allowed) return segmentcheck;\n if (!nonnegativeoption(options, \"pause\")) return { allowed: false, reason: \"The reviewed card typing pause must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"fillcode\" && !isnonempty(options.source)) return { allowed: false, reason: \"A reviewed one time code source is required in options.\" };\n if (kind === \"consentpassword\" && !isnonempty(options.consentref)) return { allowed: false, reason: \"A reviewed consent ref is required in options before any password is filled.\" };\n return { allowed: true };\n}\n\n/** Validates one reviewed transform rule: a supported expression, source columns and a target column. */\nexport function validatetransformrule(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed transform rule with an expression, sources and a target is required in options.\" };\n const rule = value as Record<string, unknown>;\n const expression = rule.expression;\n if (typeof expression !== \"string\" || !/^(trim|upper|lower|number|prefix|suffix|replace)(?::.+)?$/.test(expression)) return { allowed: false, reason: \"The reviewed transform expression must be trim, upper, lower, number, prefix, suffix or replace with an optional argument.\" };\n if (expression.startsWith(\"replace\") && !expression.slice(\"replace\".length).includes(\"=>\")) return { allowed: false, reason: \"The reviewed replace expression needs the from=>to separator.\" };\n if (expression.startsWith(\"replace\") && expression.slice(\"replace:\".length).split(\"=>\")[0] === \"\") return { allowed: false, reason: \"The reviewed replace expression needs a non-empty from part.\" };\n if (!Array.isArray(rule.sources) || rule.sources.length === 0 || !rule.sources.every(source => isnonempty(source))) return { allowed: false, reason: \"Every reviewed transform rule needs a non-empty list of source columns.\" };\n if (!isnonempty(rule.target)) return { allowed: false, reason: \"Every reviewed transform rule needs a non-empty target column.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed dataset id list in options. */\nfunction validatedatasetids(options: Record<string, unknown>, key: string): policyevaluation {\n const ids = options[key];\n if (!Array.isArray(ids) || ids.length === 0 || !ids.every(id => isnonempty(id))) return { allowed: false, reason: `A reviewed non-empty list of dataset ids is required in options as ${key}.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed extraction, transform, export and provenance parameter grammar of the data family. */\nfunction validatedatagrammar(step: toolstep, options: Record<string, unknown>, origin: string): policyevaluation {\n const kind = step.kind;\n if (kind === \"scrapetable\") {\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed dataset name must be a non-empty string.\" };\n if (options.rowlimit !== undefined && (typeof options.rowlimit !== \"number\" || !Number.isInteger(options.rowlimit) || options.rowlimit < 1)) return { allowed: false, reason: \"The reviewed row limit must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"paginateextract\") {\n if (!isnonempty(options.next)) return { allowed: false, reason: \"A reviewed next control selector is required in options.\" };\n if (options.pages !== undefined && (typeof options.pages !== \"number\" || !Number.isInteger(options.pages) || options.pages < 1)) return { allowed: false, reason: \"The reviewed page count must be a positive integer with no code ceiling.\" };\n if (!nonnegativeoption(options, \"wait\")) return { allowed: false, reason: \"The reviewed row freshness wait must be zero or a positive number of milliseconds.\" };\n }\n if (kind === \"exportcsv\" || kind === \"exportjson\" || kind === \"exportexcel\" || kind === \"copytable\" || kind === \"streamdisk\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed artifact name must be a non-empty string.\" };\n }\n if (kind === \"exportcsv\" && options.delimiter !== undefined && (typeof options.delimiter !== \"string\" || options.delimiter.length !== 1)) return { allowed: false, reason: \"The reviewed csv delimiter must be a single character.\" };\n if (kind === \"streamdisk\" && (typeof options.chunk !== \"number\" || !Number.isInteger(options.chunk) || options.chunk < 1)) return { allowed: false, reason: \"The reviewed streaming chunk size must be a positive integer with no code ceiling.\" };\n if (kind === \"pushsheets\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (!isnonempty(options.sheet)) return { allowed: false, reason: \"A reviewed sheet endpoint url is required in options.\" };\n if (!ishttpsurl(options.sheet)) return { allowed: false, reason: \"The reviewed sheet endpoint url must use HTTPS.\" };\n if (options.reviewed !== true) return { allowed: false, reason: \"The sheet push needs the explicit reviewed flag before any data leaves local memory.\" };\n }\n if (kind === \"importcsv\") {\n if (typeof options.csv !== \"string\" || !options.csv.trim()) return { allowed: false, reason: \"Reviewed csv content is required in options.\" };\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed dataset name must be a non-empty string.\" };\n if (options.mapping !== undefined) {\n const mapping = options.mapping;\n if (!mapping || typeof mapping !== \"object\" || Array.isArray(mapping) || !Object.values(mapping).every(item => typeof item === \"string\")) return { allowed: false, reason: \"The reviewed csv column mapping must be an object of string values.\" };\n }\n }\n if (kind === \"looprows\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.variable !== undefined && !isnonempty(options.variable)) return { allowed: false, reason: \"The reviewed row variable name must be a non-empty string.\" };\n const inner = validateinnerstep(options, origin);\n if (!inner.allowed) return inner;\n }\n if (kind === \"transformvalues\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n const rules = options.rules;\n if (!Array.isArray(rules) || rules.length === 0) return { allowed: false, reason: \"A reviewed non-empty list of transform rules is required in options.\" };\n for (const item of rules) {\n const rulecheck = validatetransformrule(item);\n if (!rulecheck.allowed) return rulecheck;\n }\n }\n if (kind === \"deduperows\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n const keys = options.keys;\n if (!Array.isArray(keys) || keys.length === 0 || !keys.every(key => isnonempty(key))) return { allowed: false, reason: \"A reviewed non-empty list of dedupe column keys is required in options.\" };\n }\n if (kind === \"mergepages\") {\n const listcheck = validatedatasetids(options, \"datasets\");\n if (!listcheck.allowed) return listcheck;\n }\n if (kind === \"stamplerows\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.url !== undefined && !ishttpsurl(options.url)) return { allowed: false, reason: \"The reviewed source url must use HTTPS.\" };\n }\n if (kind === \"previewgrid\") {\n if (!isnonempty(options.dataset)) return { allowed: false, reason: \"A reviewed dataset id is required in options.\" };\n if (options.sample !== undefined && (typeof options.sample !== \"number\" || !Number.isInteger(options.sample) || options.sample < 1)) return { allowed: false, reason: \"The reviewed sample row count must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"resumeextract\" && !isnonempty(options.session)) return { allowed: false, reason: \"A reviewed extract session id is required in options.\" };\n if (kind === \"logprovenance\" && !isnonempty(options.artifact)) return { allowed: false, reason: \"A reviewed artifact id or name is required in options.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed batch download specification: a non-empty HTTPS url list, an optional filename rule and an optional completion criterion. */\nexport function validatedownloadspec(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed downloadspec with a url list is required in options.\" };\n const spec = value as Record<string, unknown>;\n if (!Array.isArray(spec.urls) || spec.urls.length === 0 || !spec.urls.every(url => ishttpsurl(url))) return { allowed: false, reason: \"The reviewed downloadspec needs a non-empty list of HTTPS urls.\" };\n if (spec.filename !== undefined && !isnonempty(spec.filename)) return { allowed: false, reason: \"The reviewed downloadspec filename rule must be a non-empty string.\" };\n if (spec.complete !== undefined && spec.complete !== \"size\" && spec.complete !== \"checksum\") return { allowed: false, reason: \"The reviewed downloadspec completion criterion must be size or checksum.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed mime interception filter: include and exclude patterns plus the deny default for unlisted mime types. */\nexport function validatemimefilter(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed mimefilter with include and exclude patterns is required in options.\" };\n const filter = value as Record<string, unknown>;\n if (!Array.isArray(filter.include) || filter.include.length === 0 || !filter.include.every(pattern => isnonempty(pattern))) return { allowed: false, reason: \"The reviewed mimefilter needs a non-empty list of include patterns.\" };\n if (filter.exclude !== undefined && (!Array.isArray(filter.exclude) || !filter.exclude.every(pattern => isnonempty(pattern)))) return { allowed: false, reason: \"The reviewed mimefilter exclude patterns must be a list of non-empty strings.\" };\n if (filter.default !== \"deny\" && filter.default !== \"allow\") return { allowed: false, reason: \"The reviewed mimefilter needs the deny or allow default for unlisted mime types.\" };\n return { allowed: true };\n}\n\n/** Validates one reviewed cleanup rule: a positive age window with no code ceiling, an artifact kind and a keep policy. */\nexport function validatecleanuprule(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed cleanuprule with an age, a kind and a keep policy is required.\" };\n const rule = value as Record<string, unknown>;\n if (typeof rule.age !== \"number\" || !Number.isFinite(rule.age) || rule.age <= 0) return { allowed: false, reason: \"The reviewed cleanup age window must be a positive number of milliseconds with no code ceiling.\" };\n if (!isnonempty(rule.kind)) return { allowed: false, reason: \"The reviewed cleanup rule needs a non-empty artifact kind, or any to match every kind.\" };\n if (rule.keep !== \"none\" && rule.keep !== \"latest\" && rule.keep !== \"all\") return { allowed: false, reason: \"The reviewed cleanup keep policy must be none, latest or all.\" };\n return { allowed: true };\n}\n\n/** Validates the reviewed files, clipboard and downloads parameter grammar; batch sizes, concurrent windows and cleanup ages stay user configured with no code ceilings. */\nfunction validatefilesgrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"batchdownload\") {\n const speccheck = validatedownloadspec(options.downloadspec);\n if (!speccheck.allowed) return speccheck;\n if (options.concurrent !== undefined && (typeof options.concurrent !== \"number\" || !Number.isInteger(options.concurrent) || options.concurrent < 1)) return { allowed: false, reason: \"The reviewed concurrent download window must be a positive integer with no code ceiling.\" };\n }\n if (kind === \"pausedownload\" || kind === \"resumedownload\" || kind === \"verifydownload\" || kind === \"quarantinedownload\" || kind === \"scanvirus\") {\n if (!isnonempty(step.value)) return { allowed: false, reason: \"A reviewed download or quarantine reference is required.\" };\n if (kind === \"verifydownload\") {\n if (options.checksum !== undefined && !isnonempty(options.checksum)) return { allowed: false, reason: \"The reviewed expected checksum must be a non-empty string.\" };\n if (options.bytes !== undefined && (typeof options.bytes !== \"number\" || !Number.isFinite(options.bytes) || options.bytes < 0)) return { allowed: false, reason: \"The reviewed expected size must be zero or a positive number of bytes.\" };\n }\n if (kind === \"scanvirus\" && options.scanner !== undefined && !isnonempty(options.scanner)) return { allowed: false, reason: \"The reviewed scanner name must be a non-empty string.\" };\n if (kind === \"quarantinedownload\" && options.reason !== undefined && !isnonempty(options.reason)) return { allowed: false, reason: \"The reviewed quarantine reason must be a non-empty string.\" };\n }\n if (kind === \"interceptmime\") {\n const filtercheck = validatemimefilter(options.mimefilter);\n if (!filtercheck.allowed) return filtercheck;\n }\n if (kind === \"readclipboard\") {\n if (!isnonempty(options.consentref)) return { allowed: false, reason: \"A clipboard read requires a reviewed consent ref of an approved consent prompt in options.\" };\n if (options.prompt !== undefined && !isnonempty(options.prompt)) return { allowed: false, reason: \"The reviewed clipboard consent prompt must be a non-empty string.\" };\n }\n if (kind === \"exportnetlog\" && options.stepid !== undefined && !isnonempty(options.stepid)) return { allowed: false, reason: \"The reviewed netlog step filter must be a non-empty step id.\" };\n if (kind === \"namecaptures\") {\n if (!isnonempty(options.task)) return { allowed: false, reason: \"A reviewed task id is required in options for capture naming.\" };\n if (options.steps !== undefined && (!Array.isArray(options.steps) || options.steps.length === 0 || !options.steps.every(item => isnonempty(item)))) return { allowed: false, reason: \"The reviewed capture steps must be a non-empty list of step ids when present.\" };\n if (options.extension !== undefined && !isnonempty(options.extension)) return { allowed: false, reason: \"The reviewed capture extension must be a non-empty string.\" };\n }\n if (kind === \"cleanupartifacts\" && options.rules !== undefined) {\n const rules = options.rules;\n if (!Array.isArray(rules) || rules.length === 0) return { allowed: false, reason: \"The reviewed cleanup rules must be a non-empty list when present.\" };\n for (const item of rules) {\n const rulecheck = validatecleanuprule(item);\n if (!rulecheck.allowed) return rulecheck;\n }\n }\n return { allowed: true };\n}\n\n/** Requires an approved consent prompt before any clipboard read; every read consumes its own prompt. */\nexport function clipboardconsentgranted(step: toolstep): policyevaluation {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(step); } catch { options = {}; }\n const consentref = options.consentref;\n if (typeof consentref !== \"string\" || !consentref.trim()) return { allowed: false, reason: \"A clipboard read requires a reviewed consent ref in options.\" };\n return { allowed: true };\n}\n\n/** Refuses to release any quarantined file before a clean scan verdict exists. */\nexport function quarantinereleasegranted(entry: quarantineentry): policyevaluation {\n if (entry.scan !== \"clean\") return { allowed: false, reason: `The quarantined file ${entry.path} cannot leave quarantine with the ${entry.scan} scan verdict; only a clean verdict releases it.` };\n return { allowed: true };\n}\n\n/** Refuses downloads and download interception that fall outside the session origin grants. */\nexport function downloadgranted(session: agentsession | undefined, url: string): policyevaluation {\n let origin = \"\";\n try { origin = new URL(url).origin; } catch { return { allowed: false, reason: \"The reviewed download URL is invalid.\" }; }\n if (!origingranted(session, origin)) return { allowed: false, reason: `The download from ${origin} leaves the session origin grants and needs a session grant first.` };\n return { allowed: true };\n}\n\n/** Masks a clipboard payload for every log line; the full text never persists anywhere. */\nexport function maskclipboard(payload: string): string {\n return `[clipboard payload of ${payload.length} character${payload.length === 1 ? \"\" : \"s\"}]`;\n}\n\n/** Requires an asksubmit review step before every form submission step. */\nexport function submitreviewgranted(steps: toolstep[], submitid: string): policyevaluation {\n const position = steps.findIndex(candidate => candidate.id === submitid);\n const asked = steps.some((candidate, index) => candidate.kind === \"asksubmit\" && (position === -1 || index < position));\n return asked ? { allowed: true } : { allowed: false, reason: \"Form submission requires an asksubmit review step before it.\" };\n}\n\n/** Requires a reviewed consent ref before any password field is filled. */\nexport function passwordconsentgranted(step: toolstep): policyevaluation {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(step); } catch { options = {}; }\n const consentref = options.consentref;\n if (typeof consentref !== \"string\" || !consentref.trim()) return { allowed: false, reason: \"A password fill requires a reviewed consent ref in options.\" };\n return { allowed: true };\n}\n\n/** True when a numeric value passes the Luhn checksum used by card networks. */\nfunction luhnvalid(digits: string): boolean {\n let sum = 0;\n let double = false;\n for (let index = digits.length - 1; index >= 0; index -= 1) {\n let value = Number.parseInt(digits[index] ?? \"\", 10);\n if (!Number.isFinite(value)) return false;\n if (double) { value *= 2; if (value > 9) value -= 9; }\n sum += value;\n double = !double;\n }\n return sum % 10 === 0;\n}\n\n/** Refuses generated values that look like real card numbers or personal identifiers; test prefixed card values stay allowed. */\nexport function generatedvalueallowed(value: string): policyevaluation {\n const compact = value.replace(/[\\s-]/g, \"\");\n if (/^\\d{13,19}$/.test(compact) && luhnvalid(compact) && !compact.startsWith(\"4111\")) return { allowed: false, reason: \"The generated value looks like a real card number and is refused; generated card values use the 4111 test prefix.\" };\n if (/^\\d{3}-\\d{2}-\\d{4}$/.test(value.trim())) return { allowed: false, reason: \"The generated value looks like a personal identifier and is refused.\" };\n return { allowed: true };\n}\n\n/** Requires the origin grants of a saved profile to cover the origin before its values fill a page. */\nexport function profilegrantgranted(profile: formprofile, origin: string): policyevaluation {\n if (!profile.grants.includes(origin)) return { allowed: false, reason: `The saved profile ${profile.name} is not granted to ${origin}; add the origin to the profile grants first.` };\n return { allowed: true };\n}\n\n/** Restricts group and layout mutations to the active session: they refuse without a live session. */\nexport function layoutmutationgranted(session: agentsession | undefined, now: number): policyevaluation {\n if (!session || session.stoppedat || session.expiresat <= now) return { allowed: false, reason: \"Group and layout mutations stay inside the active session.\" };\n return { allowed: true };\n}\n\n/** Requires explicit review before closing a window that holds more than one task tab. */\nexport function windowclosegate(tasktabcount: number, reviewed: boolean): policyevaluation {\n if (tasktabcount > 1 && !reviewed) return { allowed: false, reason: `The window holds ${tasktabcount} task tabs and needs explicit review before it closes.` };\n return { allowed: true };\n}\n\n/** Reads the user configured concurrent task tab ceiling; an absent value never refuses a tab. */\nexport function tasktabceiling(settings: runsettings | undefined): number | undefined {\n const ceiling = settings?.tasktabceiling;\n return typeof ceiling === \"number\" && Number.isFinite(ceiling) && ceiling >= 0 ? ceiling : undefined;\n}\n\n/** Parses the reviewed wait duration of a wait step with no upper bound. */\nexport function waitduration(step: toolstep): number {\n const requested = step.value ? Number.parseInt(step.value, 10) : 250;\n if (!Number.isFinite(requested) || requested < 0) throw new Error(\"Wait duration must be zero or a positive number of milliseconds.\");\n return requested;\n}\n\nfunction isnumericid(value: unknown): value is string {\n return typeof value === \"string\" && /^\\d+$/.test(value);\n}\n\nfunction numericoption(options: Record<string, unknown>, key: string): boolean {\n return options[key] === undefined || (typeof options[key] === \"number\" && Number.isFinite(options[key] as number));\n}\n\n/** True when an optional numeric option is absent or a finite number of zero or more. */\nfunction nonnegativeoption(options: Record<string, unknown>, key: string): boolean {\n return numericoption(options, key) && !(typeof options[key] === \"number\" && (options[key] as number) < 0);\n}\n\nfunction isnonempty(value: unknown): value is string {\n return typeof value === \"string\" && value.trim().length > 0;\n}\n\nfunction ispoint(value: unknown): boolean {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n const point = value as Record<string, unknown>;\n return typeof point.x === \"number\" && Number.isFinite(point.x) && typeof point.y === \"number\" && Number.isFinite(point.y);\n}\n\n/** Grades a resolution match count: zero is absent, one is resolved and more than one is refused as ambiguous. */\nexport function resolutionverdict(count: number): \"absent\" | \"resolved\" | \"ambiguous\" {\n if (!Number.isFinite(count) || count <= 0) return \"absent\";\n return count === 1 ? \"resolved\" : \"ambiguous\";\n}\n\n/** Validates the reviewed targetref grammar of every resolution mode and rejects empty references. */\nexport function validatetargetref(reference: unknown): policyevaluation {\n if (!reference || typeof reference !== \"object\" || Array.isArray(reference)) return { allowed: false, reason: \"The reviewed target reference must be an object.\" };\n const ref = reference as Record<string, unknown>;\n if (ref.mode === \"selector\") return isnonempty(ref.selector) ? { allowed: true } : { allowed: false, reason: \"The selector target reference needs a non-empty selector.\" };\n if (ref.mode === \"text\") return isnonempty(ref.text) ? { allowed: true } : { allowed: false, reason: \"The text target reference needs non-empty text.\" };\n if (ref.mode === \"aria\") {\n if (!isnonempty(ref.role)) return { allowed: false, reason: \"The aria target reference needs a non-empty role.\" };\n return isnonempty(ref.name) ? { allowed: true } : { allowed: false, reason: \"The aria target reference needs a non-empty name.\" };\n }\n if (ref.mode === \"name\") return isnonempty(ref.name) ? { allowed: true } : { allowed: false, reason: \"The name target reference needs a non-empty name.\" };\n if (ref.mode === \"xpath\") return isnonempty(ref.xpath) ? { allowed: true } : { allowed: false, reason: \"The xpath target reference needs a non-empty expression.\" };\n if (ref.mode === \"index\") {\n const index = ref.index;\n return typeof index === \"number\" && Number.isInteger(index) && index >= 1 ? { allowed: true } : { allowed: false, reason: \"The index target reference needs a positive integer map number.\" };\n }\n if (ref.mode === \"point\") {\n const pointok = typeof ref.x === \"number\" && Number.isFinite(ref.x) && typeof ref.y === \"number\" && Number.isFinite(ref.y);\n return pointok ? { allowed: true } : { allowed: false, reason: \"The point target reference needs numeric x and y coordinates.\" };\n }\n return { allowed: false, reason: \"The target reference mode must be selector, text, aria, name, xpath, index or point.\" };\n}\n\n/** True when the session origin grants cover the given origin; a session without grants only allows its own origin. */\nexport function origingranted(session: agentsession | undefined, origin: string): boolean {\n if (!session) return false;\n const grants = session.grants ?? [session.origin];\n return grants.includes(origin);\n}\n\n/** Decides whether an unreviewed origin may open: the session grants cover it or a safe checksafe verdict vouches for it. */\nexport function originverified(url: string, grants: string[], verdicts: safetyverdict[]): policyevaluation {\n let origin = \"\";\n try { origin = new URL(url).origin; } catch { return { allowed: false, reason: \"The reviewed navigation URL is invalid.\" }; }\n if (grants.includes(origin)) return { allowed: true };\n const covered = verdicts.find(verdict => verdict.safe && (verdict.url === url || (safeorigin(verdict.url) === origin)));\n if (covered) return { allowed: true };\n return { allowed: false, reason: `The origin ${origin} is outside the session grants and has no safe checksafe verdict; run checksafe and review it first.` };\n}\n\nfunction safeorigin(url: string): string {\n try { return new URL(url).origin; } catch { return \"\"; }\n}\n\n/** Refuses navigation that would move a granted task tab outside the session origin grants until the user consents. */\nexport function navigationgranted(session: agentsession | undefined, url: string): policyevaluation {\n let origin = \"\";\n try { origin = new URL(url).origin; } catch { return { allowed: false, reason: \"The reviewed navigation URL is invalid.\" }; }\n if (origingranted(session, origin)) return { allowed: true };\n return { allowed: false, reason: `Navigation to ${origin} leaves the task tab origins and needs the user consent of a session grant first.` };\n}\n\n/** Validates the reviewed inner step of a retry or frame wrapper against the same rules as a top-level step. */\nfunction validateinnerstep(options: Record<string, unknown>, origin: string): policyevaluation {\n const stepid = options.stepid;\n const kind = options.kind;\n if (isnonempty(stepid)) {\n if (kind !== undefined) return { allowed: false, reason: \"The reviewed wrapper must reference a step id or an inline step, not both.\" };\n return { allowed: true };\n }\n if (typeof kind !== \"string\" || !kind.trim()) return { allowed: false, reason: \"A reviewed step id or inline step kind is required in options.\" };\n if (kind === \"retryaction\" || kind === \"enterframe\" || kind === \"looprows\") return { allowed: false, reason: \"The reviewed inner step cannot be another wrapper kind.\" };\n if (!allowedactions.has(kind as actionkind)) return { allowed: false, reason: \"The reviewed inner step kind is unsupported.\" };\n const inneroptions = options.options;\n if (inneroptions !== undefined && (!inneroptions || typeof inneroptions !== \"object\" || Array.isArray(inneroptions))) return { allowed: false, reason: \"The reviewed inner step options must be an object.\" };\n const inner: toolstep = {\n id: \"inner\",\n kind: kind as actionkind,\n summary: \"Reviewed inner step.\",\n risk: actionrisk(kind as actionkind),\n ...(isnonempty(options.target) ? { target: options.target } : {}),\n ...(isnonempty(options.value) ? { value: options.value } : {}),\n ...(inneroptions !== undefined ? { options: JSON.stringify(inneroptions) } : {}),\n };\n return validatestep(inner, origin);\n}\n\n/** True when a reviewed https url parses. */\nfunction ishttpsurl(value: unknown): value is string {\n if (typeof value !== \"string\" || !value.trim()) return false;\n try { return new URL(value).protocol === \"https:\"; } catch { return false; }\n}\n\n/** Validates the reviewed navtarget grammar of a navigation step. */\nfunction validatenavtarget(value: unknown, kind: string): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed navtarget with a url is required in options.\" };\n const target = value as Record<string, unknown>;\n if (!ishttpsurl(target.url)) return { allowed: false, reason: \"The reviewed navtarget url must use HTTPS.\" };\n const container = target.container ?? \"tab\";\n if (container !== \"current\" && container !== \"tab\" && container !== \"window\" && container !== \"private\") return { allowed: false, reason: \"The reviewed navtarget container must be current, tab, window or private.\" };\n if (target.position !== undefined && target.position !== \"adjacent\" && target.position !== \"end\") return { allowed: false, reason: \"The reviewed navtarget position must be adjacent or end.\" };\n if (kind === \"openprivate\" && container !== \"private\") return { allowed: false, reason: \"The openprivate step requires the private container.\" };\n if (kind === \"openlink\" && container === \"private\") return { allowed: false, reason: \"The openlink step cannot open the private container; use openprivate.\" };\n return { allowed: true };\n}\n\n/** Validates the reviewed waitprofile grammar with its load signals, thresholds and per origin overrides. */\nfunction validatewaitprofile(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed waitprofile with load signals is required in options.\" };\n const profile = value as Record<string, unknown>;\n if (!Array.isArray(profile.signals) || profile.signals.length === 0 || !profile.signals.every(signal => isnonempty(signal))) return { allowed: false, reason: \"The reviewed waitprofile needs a non-empty list of load signals.\" };\n if (!nonnegativeoption(profile, \"idle\")) return { allowed: false, reason: \"The reviewed waitprofile idle threshold must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(profile, \"timeout\")) return { allowed: false, reason: \"The reviewed waitprofile timeout must be zero or a positive number of milliseconds.\" };\n if (profile.overrides !== undefined) {\n if (!Array.isArray(profile.overrides) || profile.overrides.length === 0) return { allowed: false, reason: \"The reviewed waitprofile overrides must be a non-empty list when present.\" };\n for (const entry of profile.overrides) {\n if (!entry || typeof entry !== \"object\" || Array.isArray(entry)) return { allowed: false, reason: \"Every reviewed waitprofile override must be an object with an origin.\" };\n const override = entry as Record<string, unknown>;\n if (!ishttpsurl(override.origin)) return { allowed: false, reason: \"Every reviewed waitprofile override origin must use HTTPS.\" };\n if (override.signals !== undefined && (!Array.isArray(override.signals) || !override.signals.every(signal => isnonempty(signal)))) return { allowed: false, reason: \"The reviewed waitprofile override signals must be a list of non-empty strings.\" };\n if (!nonnegativeoption(override, \"idle\") || !nonnegativeoption(override, \"timeout\")) return { allowed: false, reason: \"The reviewed waitprofile override thresholds must be zero or positive numbers.\" };\n }\n }\n return { allowed: true };\n}\n\n/** Validates the reviewed urlpattern grammar with its match mode plus query and fragment parts. */\nexport function validateurlpattern(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed urlpattern is required in options.\" };\n const pattern = value as Record<string, unknown>;\n if (pattern.mode !== \"exact\" && pattern.mode !== \"prefix\" && pattern.mode !== \"host\" && pattern.mode !== \"pattern\") return { allowed: false, reason: \"The reviewed urlpattern mode must be exact, prefix, host or pattern.\" };\n if (!ishttpsurl(pattern.url)) return { allowed: false, reason: \"The reviewed urlpattern url must use HTTPS.\" };\n if (pattern.query !== undefined) {\n if (!pattern.query || typeof pattern.query !== \"object\" || Array.isArray(pattern.query)) return { allowed: false, reason: \"The reviewed urlpattern query part must be an object of parameter names and values.\" };\n for (const item of Object.values(pattern.query)) if (typeof item !== \"string\") return { allowed: false, reason: \"The reviewed urlpattern query values must be strings.\" };\n }\n if (pattern.fragment !== undefined && !isnonempty(pattern.fragment)) return { allowed: false, reason: \"The reviewed urlpattern fragment must be a non-empty string.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed non-empty list of HTTPS urls in options. */\nfunction validateurllist(options: Record<string, unknown>, key: string): policyevaluation {\n const urls = options[key];\n if (!Array.isArray(urls) || urls.length === 0 || !urls.every(url => ishttpsurl(url))) return { allowed: false, reason: `A reviewed non-empty list of HTTPS urls is required in options as ${key}.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed ratelimit grammar of a navrate step; the window and ceiling stay user configured with no hardcoded cap. */\nfunction validateratelimit(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed ratelimit with a window and a ceiling is required in options.\" };\n const limit = value as Record<string, unknown>;\n if (limit.domain !== undefined && !isnonempty(limit.domain)) return { allowed: false, reason: \"The reviewed ratelimit domain must be a non-empty string.\" };\n if (typeof limit.window !== \"number\" || !Number.isFinite(limit.window) || limit.window <= 0) return { allowed: false, reason: \"The reviewed ratelimit window must be a positive number of milliseconds with no code ceiling.\" };\n if (typeof limit.ceiling !== \"number\" || !Number.isInteger(limit.ceiling) || limit.ceiling < 1) return { allowed: false, reason: \"The reviewed ratelimit ceiling must be a positive integer with no code ceiling.\" };\n return { allowed: true };\n}\n\n/** Validates the reviewed tabquery grammar with url, title, id and pattern matchers; at least one matcher is required. */\nexport function validatetabquery(value: unknown): policyevaluation {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return { allowed: false, reason: \"A reviewed tabquery with at least one matcher is required in options.\" };\n const query = value as Record<string, unknown>;\n const hasmatcher = query.url !== undefined || query.title !== undefined || query.id !== undefined || query.pattern !== undefined;\n if (!hasmatcher) return { allowed: false, reason: \"The reviewed tabquery needs a url, title, id or pattern matcher.\" };\n if (query.url !== undefined && !isnonempty(query.url)) return { allowed: false, reason: \"The reviewed tabquery url matcher must be a non-empty string.\" };\n if (query.title !== undefined && !isnonempty(query.title)) return { allowed: false, reason: \"The reviewed tabquery title matcher must be a non-empty string.\" };\n if (query.pattern !== undefined && !isnonempty(query.pattern)) return { allowed: false, reason: \"The reviewed tabquery pattern matcher must be a non-empty string.\" };\n if (query.id !== undefined && (typeof query.id !== \"number\" || !Number.isInteger(query.id) || query.id < 0)) return { allowed: false, reason: \"The reviewed tabquery id matcher must be a non-negative integer tab id.\" };\n return { allowed: true };\n}\n\n/** Validates a reviewed group color choice against the Chromium tab group palette. */\nfunction validategroupcolor(value: unknown): boolean {\n return typeof value === \"string\" && (groupcolors as string[]).includes(value);\n}\n\n/** Validates a reviewed list of numeric browser ids in options. */\nfunction validateidlist(options: Record<string, unknown>, key: string): boolean {\n const ids = options[key];\n return Array.isArray(ids) && ids.length > 0 && ids.every(id => typeof id === \"number\" && Number.isInteger(id) && id >= 0);\n}\n\n/** Validates the reviewed tab and window parameter grammar of the tabs and windows command family. */\nfunction validatetabsgrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"querytabs\" || kind === \"closepattern\") {\n const querycheck = validatetabquery(options.tabquery);\n if (!querycheck.allowed) return querycheck;\n if (kind === \"closepattern\" && options.reviewed !== true) return { allowed: false, reason: \"The close pattern needs the explicit reviewed flag before any tab closes.\" };\n }\n if (kind === \"duplicatetab\" || kind === \"pintab\" || kind === \"mutetab\" || kind === \"movetab\" || kind === \"movetabwindow\" || kind === \"badgetab\" || kind === \"attachmeta\") {\n if (!isnumericid(step.value)) return { allowed: false, reason: \"A numeric browser tab id is required.\" };\n }\n if (kind === \"focuswindow\" || kind === \"maximizewindow\" || kind === \"minimizewindow\" || kind === \"restorewindow\") {\n if (!isnumericid(step.value)) return { allowed: false, reason: \"A numeric browser window id is required.\" };\n }\n if (kind === \"pintab\" && typeof options.pinned !== \"boolean\") return { allowed: false, reason: \"A reviewed pinned flag is required in options.\" };\n if (kind === \"mutetab\" && typeof options.muted !== \"boolean\") return { allowed: false, reason: \"A reviewed muted flag is required in options.\" };\n if (kind === \"movetab\") {\n if (typeof options.index !== \"number\" || !Number.isInteger(options.index) || options.index < 0) return { allowed: false, reason: \"A reviewed non-negative target index is required in options.\" };\n }\n if (kind === \"movetabwindow\") {\n if (typeof options.windowid !== \"number\" || !Number.isInteger(options.windowid) || options.windowid < 0) return { allowed: false, reason: \"A reviewed target window id is required in options.\" };\n }\n if (kind === \"grouptabs\") {\n const group = options.group;\n if (!group || typeof group !== \"object\" || Array.isArray(group)) return { allowed: false, reason: \"A reviewed group with a name is required in options.\" };\n const spec = group as Record<string, unknown>;\n if (!isnonempty(spec.name)) return { allowed: false, reason: \"The reviewed group needs a non-empty name.\" };\n if (!validategroupcolor(spec.color)) return { allowed: false, reason: \"The reviewed group color must be a Chromium tab group color.\" };\n if (!validateidlist(spec, \"tabids\")) return { allowed: false, reason: \"The reviewed group needs a non-empty list of member tab ids.\" };\n }\n if (kind === \"colorgroup\") {\n if (!isnonempty(options.name)) return { allowed: false, reason: \"A reviewed group name is required in options.\" };\n if (!validategroupcolor(options.color)) return { allowed: false, reason: \"The reviewed group color must be a Chromium tab group color.\" };\n }\n if (kind === \"collapsegroup\") {\n if (!isnonempty(options.name)) return { allowed: false, reason: \"A reviewed group name is required in options.\" };\n if (typeof options.collapsed !== \"boolean\") return { allowed: false, reason: \"A reviewed collapsed flag is required in options.\" };\n }\n if (kind === \"discardtab\" || kind === \"reloadtabs\") {\n if (!isnumericid(step.value) && !validateidlist(options, \"tabs\")) return { allowed: false, reason: \"A numeric tab id or a reviewed list of tab ids is required.\" };\n }\n if (kind === \"zoomin\" || kind === \"zoomout\") {\n if (options.step !== undefined && (typeof options.step !== \"number\" || !Number.isFinite(options.step) || options.step <= 0)) return { allowed: false, reason: \"The reviewed zoom step must be a positive number with no code ceiling.\" };\n if (step.value !== undefined && step.value !== \"\" && !isnumericid(step.value)) return { allowed: false, reason: \"The reviewed zoom target must be a numeric tab id.\" };\n }\n if (kind === \"switchtab\") {\n if (options.direction !== \"next\" && options.direction !== \"previous\") return { allowed: false, reason: \"A reviewed switch direction of next or previous is required in options.\" };\n }\n if (kind === \"restorewindow\") {\n const bounds = options.bounds;\n if (bounds !== undefined) {\n if (!bounds || typeof bounds !== \"object\" || Array.isArray(bounds)) return { allowed: false, reason: \"The reviewed window bounds must be an object.\" };\n const shape = bounds as Record<string, unknown>;\n for (const field of [\"left\", \"top\", \"width\", \"height\"]) {\n if (typeof shape[field] !== \"number\" || !Number.isFinite(shape[field])) return { allowed: false, reason: \"The reviewed window bounds need numeric left, top, width and height.\" };\n }\n }\n }\n if (kind === \"scratchwindow\") {\n if (step.value !== undefined && step.value !== \"\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"The reviewed scratch window url must use HTTPS.\" };\n }\n if (kind === \"incognitowindow\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"A reviewed HTTPS url is required to open an incognito window.\" };\n if (kind === \"restoretab\" && step.value !== undefined && step.value !== \"\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"The reviewed restore url must use HTTPS.\" };\n if (kind === \"savelayout\" || kind === \"restorelayout\") {\n if (!isnonempty(options.name)) return { allowed: false, reason: \"A reviewed layout name is required in options.\" };\n }\n if (kind === \"badgetab\") {\n if (!isnonempty(options.label)) return { allowed: false, reason: \"A reviewed badge label is required in options.\" };\n if (options.taskid !== undefined && !isnonempty(options.taskid)) return { allowed: false, reason: \"The reviewed badge task id must be a non-empty string.\" };\n }\n if (kind === \"attachmeta\") {\n const labels = options.labels;\n const taskrefs = options.taskrefs;\n const haslabels = Array.isArray(labels) && labels.length > 0 && labels.every(label => isnonempty(label));\n const hastaskrefs = Array.isArray(taskrefs) && taskrefs.length > 0 && taskrefs.every(ref => isnonempty(ref));\n if (!haslabels && !hastaskrefs) return { allowed: false, reason: \"Reviewed labels or task refs are required in options to attach metadata.\" };\n if (options.provenance !== undefined && !isnonempty(options.provenance)) return { allowed: false, reason: \"The reviewed provenance must be a non-empty string.\" };\n }\n if (kind === \"reopenrun\" && !isnonempty(options.run)) return { allowed: false, reason: \"A reviewed run id is required in options to reopen its tabs.\" };\n return { allowed: true };\n}\n\n/** True when the kind belongs to the media capture family of pdf documents, recordings, images, canvases, streams, assets, lapses, conversions and thumbnails. */\nexport function ismediakind(kind: actionkind): boolean {\n return mediaactions.has(kind);\n}\n\n/** True when the kind records user activity and needs the reviewed recording consent before it starts. */\nexport function isrecordingkind(kind: actionkind): boolean {\n return kind === \"recordscreen\" || kind === \"captureaudio\";\n}\n\n/** Requires the active tab grant of the live session for every media kind: the session tab and origin must match and the origin grant must cover the active origin. */\nexport function mediagate(session: agentsession | undefined, tabid: number, origin: string, now: number): policyevaluation {\n if (!session || session.stoppedat) return { allowed: false, reason: \"No active browser session exists for the media capture.\" };\n if (session.expiresat <= now) return { allowed: false, reason: \"The browser session has expired and cannot capture media.\" };\n if (session.pausedat) return { allowed: false, reason: \"The browser session is paused and cannot capture media.\" };\n if (session.tabid !== tabid) return { allowed: false, reason: `The media capture needs the active tab grant of session tab ${session.tabid} and refuses tab ${tabid}.` };\n if (!origingranted(session, origin)) return { allowed: false, reason: `The media capture of ${origin} needs the session origin grants first.` };\n return { allowed: true };\n}\n\n/** Requires an approved recording consent prompt before any recording of user activity starts; every start consumes its own prompt. */\nexport function recordingconsentgranted(step: toolstep): policyevaluation {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(step); } catch { options = {}; }\n const consentref = options.consentref;\n if (typeof consentref !== \"string\" || !consentref.trim()) return { allowed: false, reason: \"A recording of user activity requires a reviewed consent ref in options before it starts.\" };\n return { allowed: true };\n}\n\n/** Exposes the recording duration window as a user configured choice in milliseconds; an absent window leaves the duration to the reviewed step options with no code ceiling. */\nexport function recordingwindow(settings: runsettings | undefined): number | undefined {\n const window = settings?.recordingwindow;\n return typeof window === \"number\" && Number.isFinite(window) && window > 0 ? window : undefined;\n}\n\n/** Keeps the reviewed lapse plan inside the reviewed wait budget: the whole lapse duration must fit the wait window with no code ceiling on either side. */\nexport function lapsebudgetallowed(interval: number, duration: number, wait: number | undefined): policyevaluation {\n if (!(interval > 0)) return { allowed: false, reason: \"The reviewed lapse interval must be a positive number of milliseconds.\" };\n if (!(duration > 0)) return { allowed: false, reason: \"The reviewed lapse duration must be a positive number of milliseconds.\" };\n if (wait !== undefined && !(wait >= 0)) return { allowed: false, reason: \"The reviewed wait budget must be zero or a positive number of milliseconds.\" };\n if (wait !== undefined && duration > wait) return { allowed: false, reason: `The lapse duration of ${duration} milliseconds exceeds the reviewed wait budget of ${wait} milliseconds; review a wider budget or a shorter duration.` };\n return { allowed: true };\n}\n\n/** Validates the reviewed media capture parameter grammar of the 1.1.41 family: pdf paper sizes, recording scopes and windows, image filters, lapse plans, conversion targets and thumbnail directives stay user choices with no code ceilings. */\nfunction validatemediagrammar(step: toolstep, options: Record<string, unknown>): policyevaluation {\n const kind = step.kind;\n if (kind === \"capturepdf\") {\n const pdf = options.pdf;\n if (pdf !== undefined) {\n if (!pdf || typeof pdf !== \"object\" || Array.isArray(pdf)) return { allowed: false, reason: \"The reviewed pdf options must be an object in options.pdf.\" };\n const pdfoptions = pdf as Record<string, unknown>;\n if (pdfoptions.paperwidth !== undefined && (typeof pdfoptions.paperwidth !== \"number\" || !Number.isFinite(pdfoptions.paperwidth) || pdfoptions.paperwidth <= 0)) return { allowed: false, reason: \"The reviewed pdf paper width must be a positive number of inches with no code cap.\" };\n if (pdfoptions.paperheight !== undefined && (typeof pdfoptions.paperheight !== \"number\" || !Number.isFinite(pdfoptions.paperheight) || pdfoptions.paperheight <= 0)) return { allowed: false, reason: \"The reviewed pdf paper height must be a positive number of inches with no code cap.\" };\n if (pdfoptions.margins !== undefined) {\n const margins = pdfoptions.margins;\n if (!margins || typeof margins !== \"object\" || Array.isArray(margins)) return { allowed: false, reason: \"The reviewed pdf margins must be an object with top, right, bottom and left inches.\" };\n for (const side of [\"top\", \"right\", \"bottom\", \"left\"]) {\n const value = (margins as Record<string, unknown>)[side];\n if (value === undefined) continue;\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) return { allowed: false, reason: `The reviewed pdf ${side} margin must be zero or a positive number of inches; negative margins are refused.` };\n }\n }\n if (pdfoptions.scale !== undefined && (typeof pdfoptions.scale !== \"number\" || !Number.isFinite(pdfoptions.scale) || pdfoptions.scale <= 0)) return { allowed: false, reason: \"The reviewed pdf scale must be a positive number with no code cap.\" };\n if (pdfoptions.landscape !== undefined && typeof pdfoptions.landscape !== \"boolean\") return { allowed: false, reason: \"The reviewed pdf landscape flag must be a boolean.\" };\n if (pdfoptions.paginate !== undefined && typeof pdfoptions.paginate !== \"boolean\") return { allowed: false, reason: \"The reviewed pdf paginate flag must be a boolean.\" };\n }\n if (options.breakpoints !== undefined && (!Array.isArray(options.breakpoints) || options.breakpoints.length === 0 || !options.breakpoints.every(item => isnonempty(item)))) return { allowed: false, reason: \"The reviewed pdf break points must be a non-empty list of selectors when present.\" };\n if (options.exporttarget !== undefined && options.exporttarget !== \"memory\" && options.exporttarget !== \"download\") return { allowed: false, reason: \"The reviewed pdf export target must be memory or download; pdf documents do not route to the clipboard.\" };\n if (options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed pdf artifact name must be a non-empty string.\" };\n }\n if (kind === \"recordscreen\" || kind === \"captureaudio\") {\n const recording = options.recording;\n if (recording !== undefined) {\n if (!recording || typeof recording !== \"object\" || Array.isArray(recording)) return { allowed: false, reason: \"The reviewed recording options must be an object in options.recording.\" };\n const recordoptions = recording as Record<string, unknown>;\n if (recordoptions.scope !== undefined && recordoptions.scope !== \"tab\" && recordoptions.scope !== \"run\") return { allowed: false, reason: \"The reviewed recording scope must be tab or run.\" };\n if (recordoptions.fps !== undefined && (typeof recordoptions.fps !== \"number\" || !Number.isFinite(recordoptions.fps) || recordoptions.fps <= 0)) return { allowed: false, reason: \"The reviewed recording fps must be a positive number with no code ceiling.\" };\n if (recordoptions.bitrate !== undefined && (typeof recordoptions.bitrate !== \"number\" || !Number.isFinite(recordoptions.bitrate) || recordoptions.bitrate <= 0)) return { allowed: false, reason: \"The reviewed recording bitrate must be a positive number with no code ceiling.\" };\n if (recordoptions.audio !== undefined && typeof recordoptions.audio !== \"boolean\") return { allowed: false, reason: \"The reviewed recording audio flag must be a boolean.\" };\n }\n if (options.duration !== undefined && (typeof options.duration !== \"number\" || !Number.isFinite(options.duration) || options.duration <= 0)) return { allowed: false, reason: \"The reviewed recording duration must be a positive number of milliseconds with no code ceiling.\" };\n const consent = recordingconsentgranted(step);\n if (!consent.allowed) return consent;\n }\n if (kind === \"captureframe\") {\n if (options.timestamp !== undefined && (typeof options.timestamp !== \"number\" || !Number.isFinite(options.timestamp) || options.timestamp < 0)) return { allowed: false, reason: \"The reviewed frame timestamp must be zero or a positive number of seconds.\" };\n if (options.poster !== undefined && typeof options.poster !== \"boolean\") return { allowed: false, reason: \"The reviewed poster flag must be a boolean.\" };\n const capturecheck = validatecaptureoptions(options.capture);\n if (!capturecheck.allowed) return capturecheck;\n }\n if (kind === \"downloadimages\") {\n const filter = options.imagefilter;\n if (!filter || typeof filter !== \"object\" || Array.isArray(filter)) return { allowed: false, reason: \"A reviewed imagefilter is required in options before any image downloads.\" };\n const imagefilter = filter as Record<string, unknown>;\n if (imagefilter.selector !== undefined && !isnonempty(imagefilter.selector)) return { allowed: false, reason: \"The reviewed imagefilter selector must be a non-empty selector from the reviewed selector grammar.\" };\n if (imagefilter.minwidth !== undefined && (typeof imagefilter.minwidth !== \"number\" || !Number.isFinite(imagefilter.minwidth) || imagefilter.minwidth < 0)) return { allowed: false, reason: \"The reviewed imagefilter minimum width must be zero or a positive number of pixels.\" };\n if (imagefilter.minheight !== undefined && (typeof imagefilter.minheight !== \"number\" || !Number.isFinite(imagefilter.minheight) || imagefilter.minheight < 0)) return { allowed: false, reason: \"The reviewed imagefilter minimum height must be zero or a positive number of pixels.\" };\n if (imagefilter.formats !== undefined && (!Array.isArray(imagefilter.formats) || imagefilter.formats.length === 0 || !imagefilter.formats.every(item => isnonempty(item)))) return { allowed: false, reason: \"The reviewed imagefilter format list must be a non-empty list of mime or extension patterns when present.\" };\n if (options.naming !== undefined) {\n const namingcheck = validatecapturenaming(options.naming);\n if (!namingcheck.allowed) return namingcheck;\n }\n }\n if (kind === \"shotcanvas\") {\n const capturecheck = validatecaptureoptions(options.capture);\n if (!capturecheck.allowed) return capturecheck;\n }\n if (kind === \"probestream\" && options.selector !== undefined && !isnonempty(options.selector)) return { allowed: false, reason: \"The reviewed stream probe scope selector must be a non-empty string.\" };\n if (kind === \"timelapse\") {\n const lapse = options.lapse;\n if (!lapse || typeof lapse !== \"object\" || Array.isArray(lapse)) return { allowed: false, reason: \"A reviewed lapse plan with interval, duration and format is required in options.\" };\n const plan = lapse as Record<string, unknown>;\n if (typeof plan.interval !== \"number\" || !Number.isFinite(plan.interval) || plan.interval <= 0) return { allowed: false, reason: \"The reviewed lapse interval must be a positive number of milliseconds with no code ceiling.\" };\n if (typeof plan.duration !== \"number\" || !Number.isFinite(plan.duration) || plan.duration <= 0) return { allowed: false, reason: \"The reviewed lapse duration must be a positive number of milliseconds with no code ceiling.\" };\n if (plan.format !== undefined && plan.format !== \"png\" && plan.format !== \"jpeg\" && plan.format !== \"webp\") return { allowed: false, reason: \"The reviewed lapse format must be png, jpeg or webp.\" };\n const budget = lapsebudgetallowed(plan.interval as number, plan.duration as number, typeof options.wait === \"number\" ? options.wait : undefined);\n if (!budget.allowed) return budget;\n const capturecheck = validatecaptureoptions(options.capture);\n if (!capturecheck.allowed) return capturecheck;\n }\n if (kind === \"convertimage\" || kind === \"makethumbs\") {\n const single = options.capture;\n const list = options.captures;\n const hasone = isnonempty(single);\n const haslist = Array.isArray(list) && list.length > 0 && list.every(item => isnonempty(item));\n if (!hasone && !haslist) return { allowed: false, reason: \"A reviewed capture id or a reviewed non-empty capture id list is required in options.\" };\n if (hasone && haslist) return { allowed: false, reason: \"The reviewed step needs one capture id or a capture id list, not both.\" };\n }\n if (kind === \"convertimage\") {\n const convert = options.convert;\n if (!convert || typeof convert !== \"object\" || Array.isArray(convert)) return { allowed: false, reason: \"A reviewed convert directive with a target format is required in options.\" };\n const directive = convert as Record<string, unknown>;\n if (directive.target !== \"png\" && directive.target !== \"jpeg\" && directive.target !== \"webp\") return { allowed: false, reason: \"The reviewed conversion target must be png, jpeg or webp.\" };\n if (directive.source !== undefined && directive.source !== \"png\" && directive.source !== \"jpeg\" && directive.source !== \"webp\") return { allowed: false, reason: \"The reviewed conversion source must be png, jpeg or webp.\" };\n if (directive.quality !== undefined && (typeof directive.quality !== \"number\" || !Number.isFinite(directive.quality) || directive.quality < 0 || directive.quality > 100)) return { allowed: false, reason: \"The reviewed conversion quality must stay between zero and one hundred with no code cap inside that range.\" };\n }\n if (kind === \"makethumbs\") {\n const thumb = options.thumb;\n if (!thumb || typeof thumb !== \"object\" || Array.isArray(thumb)) return { allowed: false, reason: \"A reviewed thumb directive with size, fit and suffix is required in options.\" };\n const directive = thumb as Record<string, unknown>;\n if (typeof directive.size !== \"number\" || !Number.isFinite(directive.size) || directive.size <= 0) return { allowed: false, reason: \"The reviewed thumbnail size must be a positive number of pixels with no fixed set.\" };\n if (directive.fit !== \"cover\" && directive.fit !== \"contain\") return { allowed: false, reason: \"The reviewed thumbnail fit must be cover or contain.\" };\n if (!isnonempty(directive.suffix)) return { allowed: false, reason: \"The reviewed thumbnail naming suffix must be a non-empty string.\" };\n }\n return { allowed: true };\n}\n\n/** Validates a single proposal against the active tab origin and local policy. */\nexport function validatestep(step: toolstep, origin: string): policyevaluation {\n if (!allowedactions.has(step.kind)) return { allowed: false, reason: \"Unsupported action kind.\" };\n if (!step.summary.trim()) return { allowed: false, reason: \"A human-readable action summary is required.\" };\n let options: Record<string, unknown>;\n try { options = parseoptions(step); } catch { return { allowed: false, reason: \"Step options must be a JSON object.\" }; }\n const hastargetref = options.targetref !== undefined;\n if (targetactions.has(step.kind) && !step.target?.trim() && !hastargetref) return { allowed: false, reason: \"A page target is required.\" };\n if (valueactions.has(step.kind) && !step.value?.trim()) return { allowed: false, reason: \"A reviewed value is required.\" };\n if (step.kind === \"select\" && !step.value?.trim()) return { allowed: false, reason: \"A reviewed option value is required.\" };\n if (step.kind === \"navigate\" && !step.value) return { allowed: false, reason: \"A navigation URL is required.\" };\n if (hastargetref) {\n const reference = validatetargetref(options.targetref);\n if (!reference.allowed) return reference;\n }\n if (step.kind === \"wait\") {\n try { waitduration(step); } catch { return { allowed: false, reason: \"Wait duration must be zero or a positive number of milliseconds.\" }; }\n }\n if (step.kind === \"navigate\") {\n try {\n if (new URL(step.value ?? \"\").origin !== origin) return { allowed: false, reason: \"Navigation must remain within the approved origin.\" };\n } catch {\n return { allowed: false, reason: \"Navigation URL is invalid.\" };\n }\n }\n if (step.kind === \"tabcreate\" || step.kind === \"windowcreate\" || step.kind === \"downloadfile\") {\n try {\n const url = new URL(step.value ?? \"\");\n if (url.protocol !== \"https:\") return { allowed: false, reason: \"The reviewed URL must use HTTPS.\" };\n } catch {\n return { allowed: false, reason: \"The reviewed URL is invalid.\" };\n }\n }\n if (step.kind === \"tabactivate\" || step.kind === \"tabclose\" || step.kind === \"tabreload\" || step.kind === \"windowclose\" || step.kind === \"windowresize\") {\n if (!isnumericid(step.value)) return { allowed: false, reason: \"A numeric browser id is required.\" };\n }\n if (step.kind === \"zoomset\") {\n const zoom = Number(step.value);\n if (!Number.isFinite(zoom) || zoom <= 0) return { allowed: false, reason: \"The reviewed zoom must be a positive number.\" };\n }\n if (step.kind === \"setattribute\" || step.kind === \"writestorage\") {\n const keyname = step.kind === \"setattribute\" ? \"name\" : \"key\";\n if (typeof options[keyname] !== \"string\" || !(options[keyname] as string).trim()) return { allowed: false, reason: `A reviewed ${keyname} is required in options.` };\n if (typeof options.value !== \"string\") return { allowed: false, reason: \"A reviewed value is required in options.\" };\n }\n if (step.kind === \"windowresize\") {\n if (typeof options.width !== \"number\" || typeof options.height !== \"number\" || !Number.isFinite(options.width) || !Number.isFinite(options.height)) return { allowed: false, reason: \"Reviewed width and height numbers are required in options.\" };\n }\n if ((step.kind === \"scrollpage\" || step.kind === \"scrollby\") && (!numericoption(options, \"x\") || !numericoption(options, \"y\"))) return { allowed: false, reason: \"Scroll amounts must be numbers in options.\" };\n if (step.kind === \"waitfor\" && options.timeout !== undefined && (typeof options.timeout !== \"number\" || options.timeout < 0)) return { allowed: false, reason: \"The waitfor timeout must be zero or a positive number of milliseconds.\" };\n if (step.kind === \"movepointer\") {\n const path = options.pointpath;\n if (!path || typeof path !== \"object\" || Array.isArray(path)) return { allowed: false, reason: \"A reviewed pointpath with start and end points is required in options.\" };\n const points = path as Record<string, unknown>;\n if (!ispoint(points.start) || !ispoint(points.end)) return { allowed: false, reason: \"The reviewed pointpath needs numeric start and end points.\" };\n if (points.waypoints !== undefined && (!Array.isArray(points.waypoints) || !points.waypoints.every(waypoint => ispoint(waypoint)))) return { allowed: false, reason: \"The reviewed pointpath waypoints must be numeric points.\" };\n if (!nonnegativeoption(points, \"duration\")) return { allowed: false, reason: \"The reviewed pointpath duration must be zero or a positive number of milliseconds.\" };\n const speed = options.speedprofile;\n if (speed !== undefined) {\n if (!speed || typeof speed !== \"object\" || Array.isArray(speed)) return { allowed: false, reason: \"The reviewed speed profile must be an object.\" };\n const profile = speed as Record<string, unknown>;\n if (profile.easing !== undefined && profile.easing !== \"linear\" && profile.easing !== \"easeinout\") return { allowed: false, reason: \"The reviewed easing must be linear or easeinout.\" };\n if (!nonnegativeoption(profile, \"peak\")) return { allowed: false, reason: \"The reviewed peak velocity must be zero or a positive number.\" };\n if (!nonnegativeoption(profile, \"jitter\")) return { allowed: false, reason: \"The reviewed jitter window must be zero or a positive number of milliseconds.\" };\n }\n }\n if (step.kind === \"clickpoint\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"point\")) return { allowed: false, reason: \"A reviewed point target reference is required in options.\" };\n if (step.kind === \"clicktext\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"text\")) return { allowed: false, reason: \"A reviewed text target reference is required in options.\" };\n if (step.kind === \"clickaria\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"aria\")) return { allowed: false, reason: \"A reviewed aria target reference is required in options.\" };\n if (step.kind === \"clickname\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"name\")) return { allowed: false, reason: \"A reviewed name target reference is required in options.\" };\n if (step.kind === \"resolvexpath\" && (!hastargetref || (options.targetref as Record<string, unknown>).mode !== \"xpath\")) return { allowed: false, reason: \"A reviewed xpath target reference is required in options.\" };\n if (step.kind === \"typetime\" && options.delay !== undefined && (typeof options.delay !== \"number\" || !Number.isFinite(options.delay) || options.delay < 0)) return { allowed: false, reason: \"The reviewed per keystroke delay must be zero or a positive number of milliseconds.\" };\n if (step.kind === \"submitsearch\") {\n if (!isnonempty(options.results)) return { allowed: false, reason: \"A reviewed results region selector is required in options.\" };\n if (options.timeout !== undefined && (typeof options.timeout !== \"number\" || !Number.isFinite(options.timeout) || options.timeout < 0)) return { allowed: false, reason: \"The submitsearch timeout must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"selectmulti\") {\n const values = options.values;\n if (!Array.isArray(values) || values.length === 0 || !values.every(value => isnonempty(value))) return { allowed: false, reason: \"A reviewed list of option values is required in options.\" };\n }\n if (step.kind === \"setslider\") {\n const slider = Number(step.value);\n if (!Number.isFinite(slider)) return { allowed: false, reason: \"The reviewed slider value must be a number.\" };\n }\n if (step.kind === \"setdate\" && !/^\\d{4}-\\d{2}-\\d{2}$/.test(step.value ?? \"\")) return { allowed: false, reason: \"The reviewed date must use the yyyy-mm-dd form.\" };\n if (step.kind === \"setcolor\" && !/^#[0-9a-fA-F]{6}$/.test(step.value ?? \"\")) return { allowed: false, reason: \"The reviewed color must use the #rrggbb form.\" };\n if (step.kind === \"keyhold\" && options.holdid !== undefined && !isnonempty(options.holdid)) return { allowed: false, reason: \"The reviewed hold id must be a non-empty string.\" };\n if (step.kind === \"dismissdialog\") {\n const accept = options.accept;\n const answer = options.answer;\n if (accept === undefined && !isnonempty(answer)) return { allowed: false, reason: \"A reviewed accept flag or prompt answer is required in options.\" };\n if (accept !== undefined && typeof accept !== \"boolean\") return { allowed: false, reason: \"The reviewed dialog accept flag must be a boolean.\" };\n if (answer !== undefined && !isnonempty(answer)) return { allowed: false, reason: \"The reviewed prompt answer must be a non-empty string.\" };\n }\n if (step.kind === \"pierceshadow\" && options.shadow !== undefined) {\n if (!Array.isArray(options.shadow) || !options.shadow.every(item => isnonempty(item))) return { allowed: false, reason: \"The reviewed shadow path must be a list of non-empty selectors.\" };\n }\n if (step.kind === \"enterframe\") {\n const path = options.framepath;\n if (!Array.isArray(path) || path.length === 0 || !path.every(item => typeof item === \"number\" && Number.isInteger(item) && item >= 0)) return { allowed: false, reason: \"A reviewed frame path of frame indexes is required in options.\" };\n return validateinnerstep(options, origin);\n }\n if (step.kind === \"retryaction\") {\n const inner = validateinnerstep(options, origin);\n if (!inner.allowed) return inner;\n const rule = options.retryrule;\n if (!rule || typeof rule !== \"object\" || Array.isArray(rule)) return { allowed: false, reason: \"A reviewed retry rule with attempts is required in options.\" };\n const retry = rule as Record<string, unknown>;\n if (typeof retry.attempts !== \"number\" || !Number.isInteger(retry.attempts) || retry.attempts < 1) return { allowed: false, reason: \"The reviewed retry attempts must be a positive integer with no code ceiling.\" };\n if (!nonnegativeoption(retry, \"settle\")) return { allowed: false, reason: \"The reviewed retry settle window must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(retry, \"tolerance\")) return { allowed: false, reason: \"The reviewed retry movement tolerance must be zero or a positive number of pixels.\" };\n }\n if (watchactions.has(step.kind)) {\n if (typeof options.lifetime !== \"number\" || !Number.isFinite(options.lifetime) || options.lifetime <= 0) return { allowed: false, reason: \"A reviewed watch lifetime window in milliseconds is required in options.\" };\n if (options.scopes !== undefined && (!Array.isArray(options.scopes) || !options.scopes.every(scope => isnonempty(scope)))) return { allowed: false, reason: \"The reviewed watch scopes must be a list of non-empty selectors.\" };\n if (options.events !== undefined && (!Array.isArray(options.events) || !options.events.every(event => isnonempty(event)))) return { allowed: false, reason: \"The reviewed watch event kinds must be a list of non-empty strings.\" };\n if (!nonnegativeoption(options, \"poll\")) return { allowed: false, reason: \"The reviewed watch poll interval must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"waitquiet\") {\n const rule = options.quietrule;\n if (!rule || typeof rule !== \"object\" || Array.isArray(rule)) return { allowed: false, reason: \"A reviewed quietrule with an idle threshold is required in options.\" };\n const quiet = rule as Record<string, unknown>;\n if (typeof quiet.idle !== \"number\" || !Number.isFinite(quiet.idle) || quiet.idle <= 0) return { allowed: false, reason: \"The reviewed quiet idle threshold must be a positive number of milliseconds with no code ceiling.\" };\n if (!nonnegativeoption(quiet, \"poll\")) return { allowed: false, reason: \"The reviewed quiet poll interval must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(quiet, \"timeout\")) return { allowed: false, reason: \"The reviewed quiet timeout must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"diffsnapshots\") {\n const versions = options.versions;\n if (!Array.isArray(versions) || versions.length !== 2 || !versions.every(version => typeof version === \"number\" && Number.isInteger(version) && version >= 1)) return { allowed: false, reason: \"Two reviewed observation version numbers are required in options.\" };\n }\n if (step.kind === \"openlink\" || step.kind === \"openprivate\" || step.kind === \"deeplink\") {\n const targetcheck = validatenavtarget(options.navtarget, step.kind);\n if (!targetcheck.allowed) return targetcheck;\n if (step.kind === \"deeplink\") {\n const app = options.app;\n if (!isnonempty(app)) return { allowed: false, reason: \"A reviewed deep link app pattern is required in options.\" };\n const params = options.params;\n if (params !== undefined && (!params || typeof params !== \"object\" || Array.isArray(params) || !Object.values(params).every(item => typeof item === \"string\"))) return { allowed: false, reason: \"The reviewed deep link params must be an object of string values.\" };\n }\n }\n if (step.kind === \"waitload\" && !nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The waitload timeout must be zero or a positive number of milliseconds.\" };\n if (step.kind === \"waiturl\" || step.kind === \"spawait\") {\n if (step.kind === \"waiturl\") {\n const patterncheck = validateurlpattern(options.urlpattern);\n if (!patterncheck.allowed) return patterncheck;\n }\n if (!nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The wait timeout must be zero or a positive number of milliseconds.\" };\n if (!nonnegativeoption(options, \"poll\")) return { allowed: false, reason: \"The wait poll interval must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"followlink\") {\n if (options.fragment !== undefined && typeof options.fragment !== \"boolean\") return { allowed: false, reason: \"The reviewed followlink fragment flag must be a boolean.\" };\n }\n if (step.kind === \"spanav\") {\n if (options.routepattern !== undefined) {\n const routecheck = validateurlpattern(options.routepattern);\n if (!routecheck.allowed) return routecheck;\n }\n if (!nonnegativeoption(options, \"timeout\")) return { allowed: false, reason: \"The spanav route timeout must be zero or a positive number of milliseconds.\" };\n }\n if (step.kind === \"rewritequery\") {\n const set = options.set;\n const remove = options.remove;\n if (set === undefined && remove === undefined) return { allowed: false, reason: \"Reviewed query parameters to set or remove are required in options.\" };\n if (set !== undefined && (!set || typeof set !== \"object\" || Array.isArray(set) || !Object.values(set).every(item => typeof item === \"string\"))) return { allowed: false, reason: \"The reviewed query parameters to set must be an object of string values.\" };\n if (remove !== undefined && (!Array.isArray(remove) || !remove.every(item => isnonempty(item)))) return { allowed: false, reason: \"The reviewed query parameters to remove must be a list of non-empty names.\" };\n }\n if (step.kind === \"navlist\") {\n const listcheck = validateurllist(options, \"urls\");\n if (!listcheck.allowed) return listcheck;\n }\n if (step.kind === \"navprofile\") {\n const profilecheck = validatewaitprofile(options.waitprofile);\n if (!profilecheck.allowed) return profilecheck;\n }\n if (step.kind === \"handleauth\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"A reviewed HTTPS origin or url is required as the auth target.\" };\n if (step.kind === \"printpdf\" && options.name !== undefined && !isnonempty(options.name)) return { allowed: false, reason: \"The reviewed artifact name must be a non-empty string.\" };\n if (step.kind === \"prefetch\") {\n const listcheck = validateurllist(options, \"urls\");\n if (!listcheck.allowed) return listcheck;\n }\n if (step.kind === \"preconnect\") {\n const origins = options.origins;\n if (!Array.isArray(origins) || origins.length === 0 || !origins.every(originurl => ishttpsurl(originurl))) return { allowed: false, reason: \"A reviewed non-empty list of HTTPS origins is required in options.\" };\n }\n if (step.kind === \"reopentab\" && step.value !== undefined && !ishttpsurl(step.value)) return { allowed: false, reason: \"The reviewed reopen url must use HTTPS.\" };\n if (step.kind === \"navrate\") {\n const limitcheck = validateratelimit(options.ratelimit);\n if (!limitcheck.allowed) return limitcheck;\n }\n if (step.kind === \"checksafe\" && !ishttpsurl(step.value)) return { allowed: false, reason: \"A reviewed HTTPS url is required for the safety check.\" };\n if (step.kind === \"batchopen\") {\n const listcheck = validateurllist(options, \"urls\");\n if (!listcheck.allowed) return listcheck;\n }\n if (istabscommandkind(step.kind)) {\n const tabscheck = validatetabsgrammar(step, options);\n if (!tabscheck.allowed) return tabscheck;\n }\n if (isformkind(step.kind)) {\n const formcheck = validateformgrammar(step, options);\n if (!formcheck.allowed) return formcheck;\n }\n if (isdatasetkind(step.kind)) {\n const datacheck = validatedatagrammar(step, options, origin);\n if (!datacheck.allowed) return datacheck;\n }\n if (isfileskind(step.kind)) {\n const filescheck = validatefilesgrammar(step, options);\n if (!filescheck.allowed) return filescheck;\n }\n if (iscapturekind(step.kind)) {\n const capturecheck = validatecapturegrammar(step, options);\n if (!capturecheck.allowed) return capturecheck;\n }\n if (ismediakind(step.kind)) {\n const mediacheck = validatemediagrammar(step, options);\n if (!mediacheck.allowed) return mediacheck;\n }\n if (step.kind === \"tabcreate\") {\n if (options.background !== undefined && typeof options.background !== \"boolean\") return { allowed: false, reason: \"The reviewed background flag must be a boolean.\" };\n if (options.window !== undefined && (typeof options.window !== \"number\" || !Number.isInteger(options.window) || options.window < 0)) return { allowed: false, reason: \"The reviewed target window id must be a non-negative integer.\" };\n }\n if (step.kind === \"windowcreate\") {\n for (const field of [\"left\", \"top\", \"width\", \"height\"]) {\n if (options[field] !== undefined && (typeof options[field] !== \"number\" || !Number.isFinite(options[field]))) return { allowed: false, reason: `The reviewed window ${field} must be a number.` };\n }\n if (options.state !== undefined && ![\"normal\", \"maximized\", \"minimized\", \"fullscreen\"].includes(options.state as string)) return { allowed: false, reason: \"The reviewed window state must be normal, maximized, minimized or fullscreen.\" };\n }\n return { allowed: true };\n}\n\n/** Shared session gate: a live, unpaused session that still matches the active tab. */\nfunction sessiongate(input: { session: agentsession | undefined; tabid: number; origin: string; now: number; action: string }): policyevaluation {\n if (!input.session || input.session.stoppedat) return { allowed: false, reason: \"No active browser session exists.\" };\n if (input.session.expiresat <= input.now) return { allowed: false, reason: \"The browser session has expired.\" };\n if (input.session.pausedat) return { allowed: false, reason: `The browser session is paused and cannot ${input.action}.` };\n if (input.session.tabid !== input.tabid || input.session.origin !== input.origin) return { allowed: false, reason: `The ${input.action} is outside the approved tab or origin.` };\n return { allowed: true };\n}\n\n/** Applies the consent gate immediately before an action reaches the page bridge. */\nexport function canexecute(input: { session: agentsession | undefined; plan: agentplan | undefined; step: toolstep; tabid: number; origin: string; now?: number; verdicts?: safetyverdict[] }): policyevaluation {\n const now = input.now ?? Date.now();\n const gate = sessiongate({ session: input.session, tabid: input.tabid, origin: input.origin, now, action: \"execute an action\" });\n if (!gate.allowed) return gate;\n if (!input.plan || input.plan.state !== \"approved\") return { allowed: false, reason: \"The plan has not received explicit approval.\" };\n if (input.plan.expiresat <= now) return { allowed: false, reason: \"The approved plan has expired.\" };\n if ((input.step.kind === \"pierceshadow\" || input.step.kind === \"enterframe\") && !origingranted(input.session, input.origin)) return { allowed: false, reason: \"The shadow or frame step is outside the session origin grants.\" };\n if (input.step.kind === \"readjson\" && !origingranted(input.session, input.origin)) return { allowed: false, reason: \"The json state read is outside the session origin grants.\" };\n if (isexportkind(input.step.kind)) {\n const exportgate = exportgranted(input.session, input.origin);\n if (!exportgate.allowed) return exportgate;\n }\n if (input.step.kind === \"navlist\") {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(input.step); } catch { options = {}; }\n for (const url of Array.isArray(options.urls) ? options.urls : []) {\n if (typeof url !== \"string\") continue;\n const navigation = navigationgranted(input.session, url);\n if (!navigation.allowed) return navigation;\n }\n }\n if (islayoutkind(input.step.kind) && !layoutmutationgranted(input.session, now).allowed) return { allowed: false, reason: \"Group and layout mutations stay inside the active session.\" };\n if (input.step.kind === \"submitform\" || input.step.kind === \"retryform\") {\n if (!input.plan) return { allowed: false, reason: \"Form submission requires an asksubmit review step before it.\" };\n const reviewgate = submitreviewgranted(input.plan.steps, input.step.id);\n if (!reviewgate.allowed) return reviewgate;\n }\n if (input.step.kind === \"consentpassword\") {\n const consentgate = passwordconsentgranted(input.step);\n if (!consentgate.allowed) return consentgate;\n }\n if (input.step.kind === \"readclipboard\") {\n const clipgate = clipboardconsentgranted(input.step);\n if (!clipgate.allowed) return clipgate;\n }\n if (input.step.kind === \"interceptmime\" && !origingranted(input.session, input.origin)) return { allowed: false, reason: \"The download interception is outside the session origin grants.\" };\n if (iscapturekind(input.step.kind)) {\n const capturegatecheck = capturegate(input.session, input.tabid, input.origin, now);\n if (!capturegatecheck.allowed) return capturegatecheck;\n let captureoptions: Record<string, unknown> = {};\n try { captureoptions = parseoptions(input.step); } catch { captureoptions = {}; }\n const target = (captureoptions.capture as Record<string, unknown> | undefined)?.exporttarget;\n if (target !== undefined && target !== \"memory\" && target !== \"download\" && target !== \"clipboard\") return { allowed: false, reason: \"The capture export target must be memory, download or clipboard.\" };\n }\n if (ismediakind(input.step.kind)) {\n const mediagatecheck = mediagate(input.session, input.tabid, input.origin, now);\n if (!mediagatecheck.allowed) return mediagatecheck;\n }\n if (isrecordingkind(input.step.kind)) {\n const recordinggate = recordingconsentgranted(input.step);\n if (!recordinggate.allowed) return recordinggate;\n }\n if (input.step.kind === \"openlink\" || input.step.kind === \"openprivate\" || input.step.kind === \"batchopen\" || input.step.kind === \"prefetch\" || input.step.kind === \"deeplink\" || input.step.kind === \"reopentab\") {\n let options: Record<string, unknown> = {};\n try { options = parseoptions(input.step); } catch { options = {}; }\n const grammar = validatestep(input.step, input.origin);\n if (!grammar.allowed) return grammar;\n const grants = input.session?.grants ?? [input.session?.origin ?? input.origin];\n const targets: unknown[] = input.step.kind === \"batchopen\" || input.step.kind === \"prefetch\" ? (Array.isArray(options.urls) ? options.urls : []) : input.step.kind === \"reopentab\" ? [input.step.value] : [(options.navtarget as Record<string, unknown> | undefined)?.url];\n for (const target of targets) {\n if (typeof target !== \"string\" || !target) continue;\n const verified = originverified(target, grants, input.verdicts ?? []);\n if (!verified.allowed) return verified;\n }\n }\n return validatestep(input.step, input.origin);\n}\n\n/** Allows a non-mutating, temporary target preview during plan review. */\nexport function canpreview(input: { session: agentsession | undefined; plan: agentplan | undefined; step: toolstep; tabid: number; origin: string; now?: number }): policyevaluation {\n const now = input.now ?? Date.now();\n const gate = sessiongate({ session: input.session, tabid: input.tabid, origin: input.origin, now, action: \"preview a target\" });\n if (!gate.allowed) return gate;\n if (!input.plan || ![\"pending\", \"approved\"].includes(input.plan.state)) return { allowed: false, reason: \"Only a reviewed pending or approved plan can be previewed.\" };\n if (input.plan.expiresat <= now) return { allowed: false, reason: \"The reviewed plan has expired.\" };\n let options: Record<string, unknown> = {};\n try { options = parseoptions(input.step); } catch { options = {}; }\n if (!targetactions.has(input.step.kind) && options.targetref === undefined) return { allowed: false, reason: \"Only a target-based action can be previewed.\" };\n return validatestep(input.step, input.origin);\n}\n", "/** Canonical package version synchronized from package.json. */\nexport const packageversion = \"1.1.41\" as const;\n", "/** Shared contracts for every Devthink target. */\nimport { packageversion } from \"./version.js\";\n\nexport const protocolversion = packageversion;\n\n/** Every reviewed action kind. Read kinds observe, interaction kinds move focus, sensitive kinds change page or browser state. */\nexport type actionkind =\n | \"observe\" | \"inspect\" | \"extract\" | \"wait\" | \"waitfor\" | \"waittext\"\n | \"readattribute\" | \"readstyle\" | \"readgeometry\" | \"readvalue\" | \"readtext\" | \"readhtml\"\n | \"countelements\" | \"readtable\" | \"readlinks\" | \"readimages\" | \"readmeta\" | \"readforms\"\n | \"readstorage\" | \"highlight\" | \"tablist\" | \"windowlist\" | \"tabsnapshot\"\n | \"focus\" | \"scroll\" | \"hover\" | \"clickdeep\" | \"rightclick\" | \"doubleclick\"\n | \"scrollpage\" | \"scrollby\" | \"scrollend\" | \"scrolltop\" | \"fullscreen\" | \"zoomset\"\n | \"click\" | \"type\" | \"navigate\" | \"select\" | \"presskey\" | \"drag\" | \"drop\" | \"upload\"\n | \"clear\" | \"check\" | \"uncheck\" | \"toggle\" | \"submit\" | \"reload\" | \"back\" | \"forward\"\n | \"writestorage\" | \"setattribute\" | \"removeattribute\" | \"evaluate\"\n | \"tabcreate\" | \"tabactivate\" | \"tabclose\" | \"tabreload\"\n | \"windowcreate\" | \"windowclose\" | \"windowresize\" | \"downloadfile\"\n | \"movepointer\" | \"clickpoint\" | \"shiftclick\" | \"clicktext\" | \"clickaria\" | \"clickname\"\n | \"resolvexpath\" | \"typetime\" | \"appendtext\" | \"setvalue\" | \"typeedit\"\n | \"keyhold\" | \"keyrelease\" | \"submitsearch\" | \"selectmulti\" | \"chooseradio\"\n | \"setslider\" | \"setdate\" | \"setcolor\" | \"expanddetails\" | \"dismissdialog\"\n | \"pierceshadow\" | \"enterframe\" | \"retryaction\"\n | \"mapclicks\" | \"verifyvisible\" | \"verifyenabled\"\n | \"a11ytree\" | \"readvisible\" | \"readertree\" | \"detectlists\" | \"detecttables\"\n | \"readjson\" | \"watchmutate\" | \"waitquiet\" | \"watchbanner\" | \"detectinfinitescroll\"\n | \"detectvirtual\" | \"detectlazy\" | \"readscrollpos\" | \"readlang\" | \"readoutline\"\n | \"countpages\" | \"listshadow\" | \"listframes\" | \"classifypage\" | \"fingerprintsection\"\n | \"diffsnapshots\" | \"readselection\" | \"watchfocus\" | \"detectsticky\" | \"detectscrolllock\"\n | \"readopengraph\" | \"detectlanguage\" | \"deriveselector\"\n | \"openlink\" | \"openprivate\" | \"reloadcache\" | \"stopnav\" | \"waitload\" | \"waiturl\"\n | \"followlink\" | \"spanav\" | \"spawait\" | \"rewritequery\" | \"setfragment\" | \"navlist\"\n | \"navprofile\" | \"detecthttp\" | \"readredirects\" | \"readfinalurl\" | \"handleauth\" | \"printpdf\"\n | \"prefetch\" | \"preconnect\" | \"deeplink\" | \"reopentab\" | \"trailaudit\" | \"pausenav\"\n | \"navintent\" | \"navrate\" | \"openclipboard\" | \"checksafe\" | \"batchopen\"\n | \"querytabs\" | \"duplicatetab\" | \"closepattern\" | \"pintab\" | \"mutetab\" | \"movetab\"\n | \"movetabwindow\" | \"grouptabs\" | \"colorgroup\" | \"collapsegroup\" | \"discardtab\"\n | \"reloadtabs\" | \"zoomin\" | \"zoomout\" | \"watchtab\" | \"switchtab\" | \"maximizewindow\"\n | \"minimizewindow\" | \"restorewindow\" | \"focuswindow\" | \"scratchwindow\" | \"incognitowindow\"\n | \"restoretab\" | \"savelayout\" | \"restorelayout\" | \"findclones\" | \"searchtabs\"\n | \"badgetab\" | \"attachmeta\" | \"listaudio\" | \"reopenrun\" | \"snapshotsession\"\n | \"fillform\" | \"filllabel\" | \"fillplaceholder\" | \"detectfields\" | \"generatevalues\"\n | \"saveprofiles\" | \"asksubmit\" | \"submitform\" | \"readerrors\" | \"retryform\"\n | \"runwizard\" | \"selectchain\" | \"picktypeahead\" | \"pickdate\" | \"attachfile\"\n | \"handoffcaptcha\" | \"fillcard\" | \"fillcode\" | \"consentpassword\" | \"skiphoneypot\"\n | \"detectlogin\" | \"detecttemplate\"\n | \"scrapetable\" | \"exportcsv\" | \"exportjson\" | \"exportexcel\" | \"copytable\"\n | \"pushsheets\" | \"importcsv\" | \"looprows\" | \"transformvalues\" | \"deduperows\"\n | \"paginateextract\" | \"mergepages\" | \"stamplerows\" | \"previewgrid\"\n | \"streamdisk\" | \"resumeextract\" | \"logprovenance\"\n | \"batchdownload\" | \"pausedownload\" | \"resumedownload\" | \"verifydownload\" | \"interceptmime\"\n | \"exportnetlog\" | \"readclipboard\" | \"writeclipboard\" | \"copyscreen\" | \"quarantinedownload\"\n | \"scanvirus\" | \"namecaptures\" | \"cleanupartifacts\"\n | \"shotview\" | \"shotfullpage\" | \"shotelement\" | \"shotregion\" | \"contactsheet\"\n | \"capturepdf\" | \"recordscreen\" | \"captureaudio\" | \"captureframe\" | \"downloadimages\"\n | \"shotcanvas\" | \"probestream\" | \"readmedia\" | \"readassets\" | \"timelapse\" | \"convertimage\" | \"makethumbs\";\n\nexport type actionrisk = \"read\" | \"interaction\" | \"sensitive\";\nexport type planstate = \"draft\" | \"pending\" | \"approved\" | \"rejected\" | \"expired\" | \"completed\" | \"cancelled\";\nexport type auditkind = \"configure\" | \"session\" | \"observe\" | \"proposal\" | \"approval\" | \"action\" | \"error\" | \"stop\" | \"pause\" | \"resume\" | \"complete\" | \"capability\" | \"tab\" | \"window\" | \"download\" | \"pointer\" | \"dialog\" | \"hold\" | \"retry\" | \"observation\" | \"watch\" | \"diff\" | \"navigation\" | \"redirect\" | \"auth\" | \"prefetch\" | \"rate\" | \"group\" | \"layout\" | \"discard\" | \"badge\" | \"fill\" | \"submit\" | \"consent\" | \"handoff\" | \"scrape\" | \"export\" | \"stream\" | \"provenance\" | \"resume\" | \"intercept\" | \"clipboard\" | \"quarantine\" | \"cleanup\" | \"capture\" | \"media\";\n\n/** Observation mode classes: passive capture, watched lifetimes and diffing passes. */\nexport type observationmode = \"passive\" | \"watching\" | \"diffing\";\n\nexport interface toolstep {\n id: string;\n kind: actionkind;\n target?: string;\n value?: string;\n /** Reviewed JSON parameters such as modifiers, amounts or coordinates. */\n options?: string;\n summary: string;\n risk: actionrisk;\n}\n\nexport interface agentplan {\n id: string;\n objective: string;\n origin: string;\n steps: toolstep[];\n createdat: number;\n expiresat: number;\n state: planstate;\n approvedat?: number;\n completedat?: number;\n}\n\nexport interface agentsession {\n id: string;\n tabid: number;\n origin: string;\n startedat: number;\n expiresat: number;\n stoppedat?: number;\n pausedat?: number;\n /** Origins granted to this session; prepared for multi origin work. */\n grants?: string[];\n}\n\nexport interface endpointconfig {\n endpoint: string;\n origin: string;\n configuredat: number;\n}\n\nexport interface observation {\n /** Observation schema version for forward compatibility. */\n schemaversion: number;\n url: string;\n title: string;\n textpreview: string;\n textlength: number;\n forms: Array<{ label: string; type: string; name: string; options?: string[] }>;\n interactive: Array<{ selector: string; role: string; label: string }>;\n capturedat: number;\n /** Observation mode of this capture: passive, watching or diffing. */\n mode?: observationmode;\n /** Accessibility tree section captured by the page walker. */\n a11y?: a11ynode;\n /** Reader view article section extracted by the text density heuristic. */\n reader?: readerarticle;\n /** Repeated list patterns detected on the page. */\n listpattern?: listpattern[];\n /** Data table shapes detected on the page. */\n tableshape?: tableshape[];\n /** Snapshot diff section attached when two observation versions are compared. */\n diff?: snapshotdiff;\n}\n\nexport interface auditevent {\n id: string;\n kind: auditkind;\n at: number;\n summary: string;\n sessionid?: string;\n planid?: string;\n stepid?: string;\n}\n\nexport interface diagnosticreport {\n id: string;\n sessionid: string;\n origin: string;\n capturedat: number;\n tabid: number;\n title: string;\n textlength: number;\n interactivecount: number;\n formcount: number;\n bridgeavailable: boolean;\n}\n\n/** Live report of the optional browser capabilities the user has granted, with the capture kinds the active tab grant already covers. */\nexport interface capabilityreport {\n tabs: boolean;\n downloads: boolean;\n clipboardread: boolean;\n clipboardwrite: boolean;\n /** Capture kinds listed among the available capabilities because they need no optional permission beyond the active tab. */\n captures?: string[];\n /** Media capture part two kinds listed among the available capabilities. */\n media?: string[];\n reportedat: number;\n}\n\n/** Structured result of one executed step, kept with configurable retention. */\nexport interface stepoutcome {\n stepid: string;\n ok: boolean;\n summary: string;\n details?: Record<string, unknown>;\n at: number;\n}\n\n/** User chosen retention windows; an absent value keeps everything forever. */\nexport interface runsettings {\n auditretention?: number;\n outcomeretention?: number;\n /** Retention window for stored observation captures such as a11y trees and reader articles. */\n observationretention?: number;\n /** User configured ceiling on concurrent task tabs; an absent value never refuses a tab. */\n tasktabceiling?: number;\n /** Retention window for exported data artifacts; an absent value keeps every artifact. */\n artifactretention?: number;\n /** Retention window for captured network log records; an absent value keeps every record. */\n netlogretention?: number;\n /** Retention window for stored capture bytes; an absent value keeps every byte and the metadata always survives. */\n captureretention?: number;\n /** Retention window for stored media bytes such as pdf documents, frames, canvases and recordings; an absent value keeps every byte. */\n mediaretention?: number;\n /** Recording duration window in milliseconds for recordscreen and captureaudio; an absent window leaves the duration to the reviewed step options. */\n recordingwindow?: number;\n /** Capture policy of the run: off, manual, annotated or beforeafter state pairs around actions. */\n capturepolicy?: capturepolicy;\n /** True when the pinned control tab with the live task feed stays open. */\n controltab?: boolean;\n}\n\nexport interface proposalrequest {\n objective: string;\n session: agentsession;\n observation: observation;\n capabilities: capabilityreport;\n}\n\nexport interface planproposal {\n version: typeof protocolversion;\n plan: agentplan;\n}\n\nexport interface policyevaluation {\n allowed: boolean;\n reason?: string;\n}\n\n/** Tracks which reviewed steps of one plan have already executed locally. */\nexport interface planprogress {\n planid: string;\n completedsteps: string[];\n outcomes?: stepoutcome[];\n /** Tabs assigned to the running task so progress tracks work across its tabs. */\n tasktabs?: number[];\n /** Prior progress snapshots preserved when a new plan replaces the tracked one. */\n prior?: planprogress[];\n updatedat: number;\n}\n\n/** Modes that address one element during target resolution. */\nexport type targetmode = \"selector\" | \"text\" | \"aria\" | \"name\" | \"xpath\" | \"index\" | \"point\";\n\n/** Reviewed element reference resolved by the page bridge at preview and execution time. */\nexport interface targetref {\n mode: targetmode;\n selector?: string;\n text?: string;\n role?: string;\n name?: string;\n xpath?: string;\n index?: number;\n x?: number;\n y?: number;\n}\n\n/** One point on a reviewed pointer path. */\nexport interface pointref {\n x: number;\n y: number;\n}\n\n/** Reviewed pointer path between two points through optional waypoints. */\nexport interface pointpath {\n start: pointref;\n end: pointref;\n waypoints?: pointref[];\n duration?: number;\n}\n\n/** Reviewed pointer speed shape with an easing curve, peak velocity and a jitter window. */\nexport interface speedprofile {\n easing?: \"linear\" | \"easeinout\";\n peak?: number;\n jitter?: number;\n}\n\n/** One key held down across steps under a hold id, with tab and step provenance. */\nexport interface keyholdstate {\n holdid: string;\n key: string;\n modifiers?: string[];\n tabid?: number;\n stepid?: string;\n pressedat: number;\n releasedat?: number;\n}\n\n/** Reviewed answers for confirm, alert and prompt dialogs; prompts need a reviewed answer. */\nexport interface dialogpolicy {\n accept: boolean;\n answer?: string;\n}\n\n/** Ordered frame indexes that address targets inside same origin iframes. */\nexport type framepath = number[];\n\n/** Ordered host selectors that address targets across open shadow roots. */\nexport type shadowpath = string[];\n\n/** Reviewed retry bounds with an attempt count that carries no hardcoded ceiling. */\nexport interface retryrule {\n attempts: number;\n settle?: number;\n tolerance?: number;\n}\n\n/** One numbered clickable element of a clickablemap. */\nexport interface mapentry {\n number: number;\n selector: string;\n role: string;\n label: string;\n mode: targetmode;\n}\n\n/** Numbered map of every clickable element captured inside one observation version. */\nexport interface clickablemap {\n version: number;\n entries: mapentry[];\n builtat: number;\n}\n\n/** Matched element summary attached to step results and review envelopes. */\nexport interface resolvedtarget {\n mode: targetmode;\n selector: string;\n tag: string;\n label: string;\n geometry: { x: number; y: number; width: number; height: number };\n candidates?: string[];\n}\n\n/** One dialog answered by the reviewed dialog policy, kept for the audit trail. */\nexport interface dialogdecision {\n id: string;\n dialog: string;\n text: string;\n accept: boolean;\n answer?: string;\n sessionid?: string;\n at: number;\n}\n\n/** One retry execution record with the attempts made and the movement delta observed between them. */\nexport interface retryoutcome {\n stepid: string;\n attempts: number;\n movement: number;\n ok: boolean;\n at: number;\n}\n\n/** Resolution summary stored per target mode for later selector derivation. */\nexport interface resolutionsummary {\n stepid: string;\n mode: targetmode;\n selector: string;\n label: string;\n at: number;\n}\n\n/** One accessibility tree node with role, accessible name, states, value and child refs. */\nexport interface a11ynode {\n role: string;\n name: string;\n states: string[];\n value?: string;\n childcount: number;\n children: a11ynode[];\n}\n\n/** One reader view article with title, byline, blocks and text statistics. */\nexport interface readerarticle {\n title: string;\n byline: string;\n blocks: Array<{ kind: string; text: string; words: number }>;\n words: number;\n characters: number;\n}\n\n/** One detected repeated list with its shared item selector, repeat count and samples. */\nexport interface listpattern {\n container: string;\n itemselector: string;\n repeat: number;\n samples: string[];\n}\n\n/** One detected data table shape with header row, column specs and caption. */\nexport interface tableshape {\n selector: string;\n headers: string[];\n columns: Array<{ label: string; cells: number }>;\n rows: number;\n caption: string;\n}\n\n/** One embedded json state payload extracted from an inline script. */\nexport interface jsonstate {\n scripturl: string;\n rootpath: string;\n payload: unknown;\n}\n\n/** Reviewed watch registration with selector scopes, event kinds and a lifetime window. */\nexport interface mutationwatch {\n watchid?: string;\n scopes?: string[];\n events?: string[];\n lifetime: number;\n}\n\n/** Reviewed network quiet rule with an idle threshold, poll interval and timeout. */\nexport interface quietrule {\n idle: number;\n poll?: number;\n timeout?: number;\n}\n\n/** One dom mutation observed inside a reviewed watch, with a timestamp and target path. */\nexport interface mutationevent {\n watchid: string;\n event: string;\n targetpath: string;\n sessionid?: string;\n at: number;\n}\n\n/** One focus change observed inside a reviewed focus watch, with a timestamp and target path. */\nexport interface focusevent {\n watchid: string;\n kind: \"focus\" | \"blur\";\n targetpath: string;\n sessionid?: string;\n at: number;\n}\n\n/** One consent banner observed by a reviewed banner watch, with its controls. */\nexport interface bannerreport {\n kind: string;\n selector: string;\n text: string;\n controls: string[];\n sessionid?: string;\n at: number;\n}\n\n/** One node change inside a snapshot diff. */\nexport interface diffentry {\n kind: \"added\" | \"removed\" | \"changed\";\n selector: string;\n summary: string;\n}\n\n/** One snapshot diff between two stored observation versions. */\nexport interface snapshotdiff {\n baseversion: number;\n targetversion: number;\n added: diffentry[];\n removed: diffentry[];\n changed: diffentry[];\n at: number;\n}\n\n/** One derived selector candidate with its strategy and stability score. */\nexport interface selectorcandidate {\n selector: string;\n strategy: string;\n score: number;\n}\n\n/** One derived selector stored with its stability score for reuse. */\nexport interface derivedselector {\n stepid: string;\n selector: string;\n strategy: string;\n score: number;\n at: number;\n}\n\n/** One watch registration persisted so watches survive service worker restarts. */\nexport interface watchregistration {\n watchid: string;\n kind: actionkind;\n stepid: string;\n sessionid: string;\n origin: string;\n scopes: string[];\n events: string[];\n startedat: number;\n lifetime: number;\n closedat?: number;\n}\n\n/** One stored observation capture under its version. */\nexport interface observationrecord {\n version: number;\n observation: observation;\n}\n\n/** One stored accessibility tree capture. */\nexport interface a11ycapture {\n version: number;\n tree: a11ynode;\n capturedat: number;\n}\n\n/** One stored reader article capture. */\nexport interface readercapture {\n version: number;\n article: readerarticle;\n capturedat: number;\n}\n\n/** Live page signals refreshed after observation steps: language, template, scroll lock and banner state. */\nexport interface pagesignals {\n language?: string;\n template?: string;\n scrolllocked?: boolean;\n banner?: string;\n refreshedat: number;\n}\n\n/** One detected template class or section fingerprint stored per origin. */\nexport interface templateprofile {\n origin: string;\n template: string;\n fingerprint: string;\n section?: string;\n at: number;\n}\n\n/** Reviewed navigation target with its url, container, position and private flag. */\nexport interface navtarget {\n url: string;\n container: \"current\" | \"tab\" | \"window\" | \"private\";\n position?: \"adjacent\" | \"end\";\n private: boolean;\n}\n\n/** Reviewed per origin override of one wait profile. */\nexport interface waitoverride {\n origin: string;\n signals?: string[];\n idle?: number;\n timeout?: number;\n}\n\n/** Reviewed wait profile with load signals, thresholds and per origin overrides. */\nexport interface waitprofile {\n signals: string[];\n idle?: number;\n timeout?: number;\n overrides?: waitoverride[];\n}\n\n/** Reviewed url pattern with a match mode plus required query and fragment parts. */\nexport interface urlpattern {\n mode: \"exact\" | \"prefix\" | \"host\" | \"pattern\";\n url: string;\n query?: Record<string, string>;\n fragment?: string;\n}\n\n/** One redirect hop of a redirect chain with its url, status and timestamp. */\nexport interface redirecthop {\n url: string;\n status: number;\n at: number;\n}\n\n/** One observed redirect chain with hops, statuses and timing. */\nexport interface redirectchain {\n hops: redirecthop[];\n startedat: number;\n endedat: number;\n}\n\n/** One navigation trail entry with url, title, step ref and timestamp. */\nexport interface trailentry {\n url: string;\n title: string;\n stepid?: string;\n at: number;\n}\n\n/** Reviewed per domain navigation rate limit with a window and a user configured ceiling. */\nexport interface ratelimit {\n domain: string;\n window: number;\n ceiling: number;\n}\n\n/** Live navigation state of a tab: load phase, final url and redirect chain. */\nexport interface navstate {\n phase: \"idle\" | \"loading\" | \"interactive\" | \"complete\";\n finalurl?: string;\n redirects?: redirectchain;\n}\n\n/** One stored wait profile applied per origin with user configured values. */\nexport interface waitprofilerecord {\n origin: string;\n profile: waitprofile;\n at: number;\n}\n\n/** One stored navigation record with the redirect chain and final url of one navigation step. */\nexport interface navrecord {\n stepid: string;\n sessionid?: string;\n origin: string;\n finalurl: string;\n chain: redirectchain;\n at: number;\n}\n\n/** One recorded navigation intent detected from a plan, kept for audit review. */\nexport interface navintentrecord {\n id: string;\n intent: string;\n origin: string;\n sessionid?: string;\n stepid?: string;\n at: number;\n}\n\n/** One rate limit window state per domain with the reviewed limit and the hit count. */\nexport interface ratelimitstate {\n domain: string;\n limit: ratelimit;\n openedat: number;\n count: number;\n}\n\n/** One curated link of a batch open list with its safety verdict and review state. */\nexport interface curatedlink {\n url: string;\n verdict: \"safe\" | \"unsafe\" | \"unknown\";\n reasons: string[];\n}\n\n/** One curated link list stored with its review state before batch opening. */\nexport interface curatedlist {\n id: string;\n links: curatedlink[];\n reviewedat?: number;\n at: number;\n}\n\n/** Reviewed basic auth credentials for one origin, stored only after explicit review. */\nexport interface authrecord {\n origin: string;\n username: string;\n password: string;\n reviewedat: number;\n}\n\n/** One url safety verdict produced by a checksafe verification. */\nexport interface safetyverdict {\n url: string;\n safe: boolean;\n reasons: string[];\n at: number;\n}\n\n/** One task artifact routed into the artifact store by a printpdf step. */\nexport interface artifactrecord {\n id: string;\n kind: string;\n name: string;\n stepid: string;\n at: number;\n}\n\n/** Navigation control state: paused navigation while a consent prompt is open. */\nexport interface navcontrol {\n pausedat?: number;\n reason?: string;\n updatedat: number;\n}\n\n/** One recently closed tab remembered so a reopentab step can restore it. */\nexport interface recenttab {\n url: string;\n tabid: number;\n closedat: number;\n}\n\n/** Queued navigation targets of prefetch and batch open steps, shown in the popup badge. */\nexport interface navqueues {\n prefetch: number;\n batchopen: number;\n updatedat: number;\n}\n\n/** Reviewed tab query with url, title, id and pattern matchers resolved against the live tab set. */\nexport interface tabquery {\n url?: string;\n title?: string;\n id?: number;\n pattern?: string;\n}\n\n/** Reviewed tab group definition with name, color, member tabs and collapse state. */\nexport interface tabgroupspec {\n name: string;\n color: string;\n tabids: number[];\n collapsed: boolean;\n}\n\n/** One stored tab group definition with its color choice and member tabs. */\nexport interface tabgrouprecord {\n groupid: string;\n name: string;\n color: string;\n tabids: number[];\n collapsed: boolean;\n savedat: number;\n}\n\n/** Window bounds of one window state or saved layout. */\nexport interface windowbounds {\n left: number;\n top: number;\n width: number;\n height: number;\n}\n\n/** Live or saved window state with bounds, maximize state and profile kind. */\nexport interface windowstate {\n bounds: windowbounds;\n maximized: boolean;\n profile: \"normal\" | \"incognito\" | \"scratch\";\n}\n\n/** One tab position inside a saved layout, carrying its window and pin state. */\nexport interface layouttab {\n url: string;\n title: string;\n pinned: boolean;\n index: number;\n windowid: number;\n}\n\n/** One saved tab layout with name, tabs, groups, positions and window bounds. */\nexport interface tablayout {\n name: string;\n tabs: layouttab[];\n groups: tabgroupspec[];\n windows: Array<{ windowid: number; state: windowstate }>;\n savedat: number;\n}\n\n/** Per tab task metadata with task refs, provenance and free text labels. */\nexport interface tabmeta {\n tabid: number;\n taskrefs: string[];\n provenance: string;\n labels: string[];\n at: number;\n}\n\n/** One per tab task status badge set by a badgetab step or refreshed from live progress. */\nexport interface tabbadge {\n tabid: number;\n taskid: string;\n label: string;\n setat: number;\n}\n\n/** One tab report entry carrying audio state and metadata per tab. */\nexport interface tabreportentry {\n tabid: number;\n url: string;\n title: string;\n index: number;\n windowid: number;\n active: boolean;\n pinned: boolean;\n audible: boolean;\n muted: boolean;\n discarded: boolean;\n meta?: tabmeta;\n}\n\n/** Tab report payload with matched tabs, groups and badges. */\nexport interface tabreport {\n matches: tabreportentry[];\n groups: tabgroupspec[];\n badges: tabbadge[];\n}\n\n/** One session snapshot of tabs and windows captured for later restore. */\nexport interface sessionsnapshot {\n id: string;\n sessionid?: string;\n layout: tablayout;\n capturedat: number;\n}\n\n/** One closed tab history entry kept for restoretab and reopenrun. */\nexport interface closedtab {\n url: string;\n title: string;\n tabid: number;\n windowid: number;\n closedat: number;\n}\n\n/** One tab event observed inside a reviewed watchtab registration. */\nexport interface tabwatchevent {\n watchid: string;\n event: \"title\" | \"activated\" | \"closed\";\n tabid: number;\n detail?: string;\n at: number;\n}\n\n/** Pinned control tab state carrying the live task feed. */\nexport interface controltabstate {\n tabid: number;\n enabled: boolean;\n updatedat: number;\n}\n\n/** Field kinds the form family recognizes across inputs, selects, checks and specialized payment fields. */\nexport type fieldkind = \"text\" | \"email\" | \"phone\" | \"date\" | \"number\" | \"select\" | \"check\" | \"radio\" | \"file\" | \"password\" | \"card\" | \"code\";\n\n/** Reviewed field match addressing one control by label, placeholder, aria label or name. */\nexport interface fieldmatch {\n mode: \"label\" | \"placeholder\" | \"arialabel\" | \"name\";\n label?: string;\n placeholder?: string;\n arialabel?: string;\n name?: string;\n}\n\n/** One reviewed form field entry pairing a field match with its kind and value. */\nexport interface formentry {\n match: fieldmatch;\n kind: fieldkind;\n value: string;\n}\n\n/** A reviewed structured form record with field entries, kinds and values. */\nexport interface formrecord {\n form?: string;\n entries: formentry[];\n}\n\n/** Reviewed value generation rules for one field kind with locale and seed choices. */\nexport interface valuegen {\n kind: fieldkind;\n locale?: string;\n seed?: number;\n}\n\n/** One saved form profile with a reviewed name, field entries and the origin grants it is bound to. */\nexport interface formprofile {\n name: string;\n fields: formentry[];\n grants: string[];\n savedat: number;\n}\n\n/** Live wizard state with the step index, the total steps and the per step completion flags. */\nexport interface wizardstate {\n index: number;\n steps: number;\n completed: boolean[];\n at: number;\n}\n\n/** One submission ticket with the form ref, the values hash and the consent ref of its asksubmit approval. */\nexport interface submitticket {\n id: string;\n form: string;\n valueshash: string;\n consentref: string;\n approved?: boolean;\n at: number;\n}\n\n/** One validation error message associated with a field ref. */\nexport interface fielderror {\n field: string;\n message: string;\n}\n\n/** One collected error report of a form, kept for correction loops. */\nexport interface errorreport {\n form: string;\n errors: fielderror[];\n at: number;\n}\n\n/** One captcha handoff record with its resolution state while the plan waits for the user. */\nexport interface captchahandoff {\n id: string;\n origin: string;\n resolved: boolean;\n openedat: number;\n resolvedat?: number;\n}\n\n/** One login or template detection stored per origin with the matched markers. */\nexport interface detectionrecord {\n origin: string;\n kind: \"login\" | \"signup\" | \"checkout\";\n markers: string[];\n at: number;\n}\n\n/** One typeahead pick recorded when a reviewed suggestion entry was chosen. */\nexport interface typeaheadpick {\n field: string;\n query: string;\n pick: string;\n at: number;\n}\n\n/** Form report payload with the detected fields, their kinds and the matched controls. */\nexport interface formreport {\n form: string;\n fields: Array<{ selector: string; label: string; kind: fieldkind; matched: boolean }>;\n}\n\n/** One scraped or imported dataset column with a stable key, its label, its value kind and the normalized name. */\nexport interface columnspec {\n key: string;\n label: string;\n kind: \"text\" | \"number\";\n normalized: string;\n}\n\n/** One dataset row keyed by column keys. */\nexport type datasetrow = Record<string, string>;\n\n/** One source reference attaching a row index to its url, timestamp and step ref. */\nexport interface sourceref {\n row: number;\n url: string;\n at: number;\n stepid?: string;\n}\n\n/** One structured dataset with column specs, rows and source refs; row counts stay user configured with no code ceiling. */\nexport interface dataset {\n id: string;\n name: string;\n columns: columnspec[];\n rows: datasetrow[];\n sources: sourceref[];\n at: number;\n}\n\n/** One reviewed transform rule applying an expression to source columns and writing the target column. */\nexport interface transformrule {\n expression: string;\n sources: string[];\n target: string;\n}\n\n/** One extraction session tracking visited pages, collected rows and the resume cursor. */\nexport interface extractsession {\n id: string;\n datasetid: string;\n name: string;\n target: string;\n next: string;\n planned: number;\n pages: string[];\n rows: number;\n cursor: number;\n done?: boolean;\n startedat: number;\n updatedat: number;\n}\n\n/** One provenance record of an exported artifact with its url, timestamp, step ref, row range and checksum. */\nexport interface provenancerecord {\n artifact: string;\n name: string;\n url: string;\n stepid: string;\n rowstart: number;\n rowend: number;\n checksum: string;\n at: number;\n}\n\n/** One exported data artifact kept in the task artifact store with its content and checksum. */\nexport interface exportedartifact {\n id: string;\n kind: \"csv\" | \"json\" | \"excel\";\n name: string;\n stepid: string;\n rowcount: number;\n content: string;\n checksum: string;\n at: number;\n}\n\n/** One streaming export state with chunk and written row counters persisted for resume. */\nexport interface streamstate {\n datasetid: string;\n name: string;\n chunk: number;\n chunks: number;\n written: number;\n done?: boolean;\n at: number;\n}\n\n/** One reviewed sheet endpoint configuration stored behind its origin grant. */\nexport interface sheetendpoint {\n endpoint: string;\n origin: string;\n configuredat: number;\n}\n\n/** Transform rules and dedupe keys remembered per task between extraction and export. */\nexport interface taskrules {\n taskid: string;\n transforms: transformrule[];\n dedupekeys: string[];\n at: number;\n}\n\n/** One reviewed batch download specification with its url list, filename rule and completion criteria. */\nexport interface downloadspec {\n urls: string[];\n filename?: string;\n complete?: \"size\" | \"checksum\";\n}\n\n/** Per file states of the batch download queue. */\nexport type downloadstate = \"queued\" | \"running\" | \"paused\" | \"complete\" | \"failed\";\n\n/** One batch download file record with its state, resolved path and checksum; concurrent windows stay user configured with no code ceiling. */\nexport interface downloadrecord {\n id: string;\n url: string;\n filename: string;\n state: downloadstate;\n downloadid?: number;\n path?: string;\n bytes?: number;\n checksum?: string;\n at: number;\n updatedat: number;\n}\n\n/** Reviewed mime interception filter with include and exclude patterns and a deny default for unlisted mime types. */\nexport interface mimefilter {\n include: string[];\n exclude: string[];\n default: \"deny\" | \"allow\";\n}\n\n/** One captured network log record with url, method, status, timing and step correlation through its request id. */\nexport interface netlogrecord {\n url: string;\n method: string;\n status: number;\n timing: number;\n requestid?: string;\n stepid: string;\n at: number;\n /** Captured header names; exported netlogs always carry their values redacted. */\n headers?: Record<string, string>;\n}\n\n/** One clipboard entry with its kind, payload hash and origin provenance; the payload text never persists. */\nexport interface clipentry {\n kind: \"read\" | \"write\" | \"screen\";\n hash: string;\n length: number;\n origin: string;\n stepid: string;\n at: number;\n}\n\n/** Verdicts of the configured virus scanning hooks. */\nexport type scanverdict = \"pending\" | \"clean\" | \"flagged\" | \"error\";\n\n/** One quarantined download kept outside the downloads folder with its reason, scan state and release ref. */\nexport interface quarantineentry {\n id: string;\n path: string;\n reason: string;\n scan: scanverdict;\n release?: string;\n at: number;\n updatedat: number;\n}\n\n/** One consistent capture filename stamped from task, step and sequence parts. */\nexport interface capturename {\n task: string;\n step: string;\n sequence: number;\n}\n\n/** One reviewed artifact cleanup rule with an age window, an artifact kind and a keep policy. */\nexport interface cleanuprule {\n age: number;\n kind: string;\n keep: \"none\" | \"latest\" | \"all\";\n}\n\n/** One clipboard consent record with its prompt, origin and single use approval state; every clipboard read needs its own approved prompt. */\nexport interface clipboardconsentrecord {\n id: string;\n prompt: string;\n origin: string;\n stepid: string;\n approved?: boolean;\n usedat?: number;\n at: number;\n}\n\n/** One user configured virus scanning hook endpoint stored behind its origin grant. */\nexport interface scanhookconfig {\n scanner: string;\n endpoint: string;\n origin: string;\n configuredat: number;\n}\n\n/** One stored capture naming counter per task and step base. */\nexport interface capturecounter {\n taskid: string;\n counters: Record<string, number>;\n at: number;\n}\n\n/** One artifact inventory entry for the cleanup sweeper with its size and capture time. */\nexport interface artifactinventoryentry {\n id: string;\n kind: string;\n name: string;\n size: number;\n at: number;\n}\n\n/** One cleanup run history record with the applied rule count and the removed and kept artifact counts. */\nexport interface cleanuprun {\n id: string;\n rules: number;\n removed: number;\n kept: number;\n at: number;\n}\n\n/** Formats a reviewed capture may produce; anything outside this set is refused. */\nexport type captureformat = \"png\" | \"jpeg\" | \"webp\";\n\n/** Export targets a reviewed capture may route to: session memory, the reviewed download flow or the clipboard. */\nexport type captureexport = \"memory\" | \"download\" | \"clipboard\";\n\n/** Capture policy modes: captures off, manual shots only, annotated evidence or before and after state pairs around actions. */\nexport type capturepolicy = \"off\" | \"manual\" | \"annotated\" | \"beforeafter\";\n\n/** Reviewed capture options: format, quality, pixel ratio, annotation flag and export target; every bound stays a user choice. */\nexport interface captureoptions {\n format?: captureformat;\n /** Jpeg and webp quality between zero and one hundred; any value in the format range is a user choice with no code cap. */\n quality?: number;\n /** Output scale from one up to any user configured ceiling with no code ceiling. */\n pixelratio?: number;\n annotate?: boolean;\n exporttarget?: captureexport;\n}\n\n/** One reviewed rectangle of the page in css pixels. */\nexport interface regionrect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** One planned viewport tiling of a full page capture: tile grid, scroll offsets and overlap rows. */\nexport interface stitchplan {\n columns: number;\n rows: number;\n tiles: Array<{ x: number; y: number }>;\n overlap: number;\n scrollwidth: number;\n scrollheight: number;\n viewportwidth: number;\n viewportheight: number;\n}\n\n/** Reviewed contact sheet layout: cell size, column count and label style; cell counts stay user choice only. */\nexport interface sheetlayout {\n cellsize: number;\n columns: number;\n label: \"none\" | \"index\" | \"selector\" | \"both\";\n}\n\n/** Reviewed capture naming rule choosing which filename segments participate. */\nexport interface capturenaming {\n run: boolean;\n step: boolean;\n sequence: boolean;\n kind: boolean;\n}\n\n/** One stored screen capture record with its run, step, kind, format, geometry and capture time. */\nexport interface shotrecord {\n id: string;\n runid: string;\n stepid: string;\n kind: string;\n format: captureformat;\n width: number;\n height: number;\n capturedat: number;\n /** Stored image bytes as a data url while the retention window still covers the record. */\n bytes?: string;\n name?: string;\n annotated?: boolean;\n exporttarget?: captureexport;\n target?: string;\n /** True once the retention window expired the bytes; the metadata stays for the audit trail. */\n bytesexpired?: boolean;\n}\n\n/** One before and after state pair linked to the action it wraps, with the dom snapshot id of the same moment. */\nexport interface shotpair {\n id: string;\n beforeid: string;\n afterid: string;\n actionkind: string;\n target?: string;\n domsnapshotid?: string;\n at: number;\n}\n\n/** One stored pdf document record of a capturepdf step with its page count, reviewed page size, margins and byte size. */\nexport interface pdfrecord {\n id: string;\n runid: string;\n stepid: string;\n pages: number;\n /** Paper size in pdf points after the landscape swap. */\n pagewidth: number;\n pageheight: number;\n margins: { top: number; right: number; bottom: number; left: number };\n landscape: boolean;\n scale: number;\n bytes: number;\n at: number;\n /** Stored pdf bytes as a data url while the retention window still covers the record. */\n dataurl?: string;\n name?: string;\n /** True once the retention window expired the bytes; the metadata stays for the audit trail. */\n bytesexpired?: boolean;\n}\n\n/** Reviewed pdf print options: paper width and height in inches, margins in inches, scale, landscape and the paginate flag; every bound stays a user choice with no code cap. */\nexport interface pdfoptions {\n paperwidth?: number;\n paperheight?: number;\n margins?: { top: number; right: number; bottom: number; left: number };\n scale?: number;\n landscape?: boolean;\n paginate?: boolean;\n}\n\n/** One stored recording of user activity with its tab, start and end times, format and duration; the frame index survives the byte expiry. */\nexport interface recordingrecord {\n id: string;\n runid: string;\n stepid: string;\n tabid: number;\n kind: \"screen\" | \"audio\";\n scope: \"tab\" | \"run\";\n format: string;\n startedat: number;\n endedat?: number;\n duration?: number;\n fps?: number;\n bitrate?: number;\n audio?: boolean;\n /** Ordered frame capture ids of a derived frame sequence recording. */\n frames?: string[];\n /** File reference of the finished artifact routed through the reviewed download flow. */\n file?: string;\n at: number;\n /** Byte size of the derived artifact manifest while the retention window still covers the record. */\n bytes?: number;\n bytesexpired?: boolean;\n}\n\n/** Reviewed recording options: scope tab or run, fps, bitrate and the audio flag; fps and bitrate stay user choices with no code ceiling. */\nexport interface recordingoptions {\n scope?: \"tab\" | \"run\";\n fps?: number;\n bitrate?: number;\n audio?: boolean;\n}\n\n/** One still frame grabbed from a video element with its source element, reviewed timestamp and poster flag. */\nexport interface framerecord {\n id: string;\n runid: string;\n stepid: string;\n source: string;\n timestamp: number;\n poster: boolean;\n format: captureformat;\n width: number;\n height: number;\n at: number;\n dataurl?: string;\n name?: string;\n bytesexpired?: boolean;\n}\n\n/** One image observed on the page with its url, alt text, dimensions, byte size and mime type. */\nexport interface imagedescriptor {\n url: string;\n alt: string;\n width: number;\n height: number;\n bytes: number;\n mime: string;\n}\n\n/** Reviewed image filter: selector scope, minimum dimensions and a format list; batch sizes and thresholds stay user choices with no code ceilings. */\nexport interface imagefilter {\n selector?: string;\n minwidth?: number;\n minheight?: number;\n formats?: string[];\n}\n\n/** One captured canvas content record with its element, context kind and data url. */\nexport interface canvasrecord {\n id: string;\n runid: string;\n stepid: string;\n element: string;\n context: \"2d\" | \"webgl\";\n width: number;\n height: number;\n format: captureformat;\n at: number;\n dataurl?: string;\n name?: string;\n bytesexpired?: boolean;\n}\n\n/** One webrtc media stream probe record with its kind, track count, label and live flag. */\nexport interface streamrecord {\n id: string;\n runid: string;\n stepid: string;\n kind: string;\n tracks: number;\n label: string;\n live: boolean;\n at: number;\n /** Track details of the probe: kind, label, settings and ready state. */\n detail?: Array<{ kind: string; label: string; width?: number; height?: number; framerate?: number; state: string }>;\n}\n\n/** One embedded media source datum with its source url, mime type, duration, dimensions and codecs. */\nexport interface mediadatum {\n url: string;\n mime: string;\n duration: number;\n width: number;\n height: number;\n codecs: string;\n tracks: string[];\n}\n\n/** One collected page asset of kind favicon or logo with its url and byte size. */\nexport interface assetrecord {\n id: string;\n runid: string;\n stepid: string;\n kind: \"favicon\" | \"logo\";\n url: string;\n bytes: number;\n /** Declared icon sizes of the asset, for example 32x32 or any. */\n sizes?: string;\n at: number;\n}\n\n/** Reviewed time lapse plan: interval, duration and output format; both windows stay user choices with no code ceilings. */\nexport interface lapseplan {\n interval: number;\n duration: number;\n format: captureformat;\n}\n\n/** Reviewed image conversion directive: source format, target format and quality. */\nexport interface convertdirective {\n source?: captureformat;\n target: captureformat;\n quality?: number;\n}\n\n/** Reviewed thumbnail directive: size, fit and naming suffix; sizes stay user choices with no fixed set. */\nexport interface thumbdirective {\n size: number;\n fit: \"cover\" | \"contain\";\n suffix: string;\n}\n\n/** One image batch observed by downloadimages with its filter match counts and the observed image descriptors. */\nexport interface imagebatch {\n id: string;\n runid: string;\n stepid: string;\n images: imagedescriptor[];\n matched: number;\n downloaded: number;\n at: number;\n}\n\n/** One recording consent decision persisted per origin; every recordscreen and captureaudio start needs its own approved prompt. */\nexport interface recordingconsentrecord {\n id: string;\n prompt: string;\n origin: string;\n stepid: string;\n approved?: boolean;\n usedat?: number;\n at: number;\n}\n\n/** The union of media records stored per run: pdf documents, recordings, video frames, canvas contents, stream probes and page assets. */\nexport type mediarecord = pdfrecord | recordingrecord | framerecord | canvasrecord | streamrecord | assetrecord;\n", "import { actionrisk, parseoptions, submitreviewgranted, validatestep } from \"./policy.js\";\nimport { protocolversion, type agentplan, type bannerreport, type clickablemap, type dataset, type downloadrecord, type errorreport, type extractsession, type focusevent, type formreport, type imagebatch, type keyholdstate, type mediarecord, type mutationevent, type navstate, type netlogrecord, type observation, type pagesignals, type planproposal, type proposalrequest, type provenancerecord, type quarantineentry, type resolvedtarget, type safetyverdict, type selectorcandidate, type shotpair, type shotrecord, type snapshotdiff, type stepoutcome, type tablayout, type tabreport, type toolstep, type trailentry, type transformrule, type typeaheadpick, type wizardstate } from \"./types.js\";\n\nfunction record(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"Protocol message must be an object.\");\n return value as Record<string, unknown>;\n}\n\nfunction text(value: unknown, field: string): string {\n if (typeof value !== \"string\" || !value.trim()) throw new Error(`${field} must be a non-empty string.`);\n return value.trim();\n}\n\n/**\n * Reviewed options grammar shared by every step kind.\n *\n * A step may carry a JSON `options` object with the following reviewed fields:\n * - `targetref`: element addressing without a css selector, with `mode` one of `selector`, `text`, `aria`, `name`, `xpath`, `index` or `point`; the text mode carries `text`, the aria mode carries `role` plus `name`, the name mode carries `name`, the xpath mode carries `xpath`, the index mode carries a one based clickable map `index`, and the point mode carries viewport `x` and `y` coordinates.\n * - `pointpath`: pointer travel between two points, with `start` and `end` points, optional `waypoints` and a `duration` in milliseconds.\n * - `speedprofile`: pointer speed shape with `easing` (`linear` or `easeinout`), a `peak` velocity in pixels per second and a `jitter` window in milliseconds.\n * - `framepath`: ordered frame indexes routing a step inside same origin iframes.\n * - `shadow`: ordered host selectors addressing a target across open shadow roots.\n * - `retryrule`: retry bounds with `attempts`, a `settle` window in milliseconds and a movement `tolerance` in pixels; attempts carry no code ceiling.\n * - `dialogpolicy`: dialog answers with an `accept` flag and a reviewed prompt `answer` string.\n * - wrapper steps (`retryaction`, `enterframe`) reference an inner step by `stepid` or inline with `kind`, `target`, `value` and an `options` object.\n * - control kinds add reviewed `delay`, `values`, `results`, `timeout`, `holdid` and `modifiers` fields.\n * - watch kinds (`watchmutate`, `watchbanner`, `watchfocus`) carry a reviewed `lifetime` window in milliseconds, optional selector `scopes`, optional event kind filters `events` and an optional `poll` interval; the lifetime window carries no code ceiling.\n * - `waitquiet` carries a reviewed `quietrule` with a positive `idle` threshold in milliseconds, an optional `poll` interval and an optional `timeout`; every value carries no code ceiling.\n * - `diffsnapshots` carries exactly two reviewed observation `versions` to compare.\n * - navigation kinds carry the navigation parameter grammar: `navtarget` with a `url`, a `container` (`current`, `tab`, `window` or `private`), a `position` (`adjacent` or `end`) and a `private` flag; `waitprofile` with non-empty load `signals`, optional `idle` and `timeout` thresholds and per origin `overrides`; and `urlpattern` with a `mode` (`exact`, `prefix`, `host` or `pattern`), a `url`, optional `query` parameter expectations and an optional `fragment`.\n * - `waiturl` and `spawait` carry a reviewed `urlpattern`, `timeout` and `poll`; `spanav` carries an optional `routepattern`, `followlink` an optional `fragment` flag, `rewritequery` reviewed `set` and `remove` query edits, `navlist`/`prefetch`/`batchopen` reviewed `urls` lists, `preconnect` reviewed `origins`, `navrate` a reviewed `ratelimit` with `domain`, `window` and `ceiling` (never capped in code), and `deeplink` a reviewed `app` pattern with `params`.\n * - observation kinds attach structured evidence to step details: a11y trees, reader articles, list patterns, table shapes, pagination estimates, watch event records, quiet probe samples, snapshot diffs and derived selector candidates with stability scores.\n * - navigation steps attach structured evidence to step details: load phases and ready states, final urls after redirects, redirect chains with statuses and timing, http error, offline and certificate interstitial states, safety verdicts and navlist entry completions.\n * - the tabs and windows command family adds its parameter grammar: `tabquery` with url, title, id and pattern matchers (at least one matcher required, patterns use `*` and `**` wildcards); `group` with a `name`, a Chromium tab group `color`, member `tabids` and a `collapsed` flag; `layout` names for `savelayout` and `restorelayout`; reviewed `pinned`, `muted`, `index`, `windowid`, `direction`, `step`, `bounds`, `label`, `labels`, `taskrefs`, `provenance` and `run` fields; `tabcreate` gains reviewed `background` and `window` options and `windowcreate` gains reviewed `left`, `top`, `width`, `height` and `state` options; `closepattern` requires the explicit `reviewed` flag before any tab closes.\n * - tab command steps attach structured evidence to step details: tab reports with matched tabs carrying audio state and metadata, group registries, badge states, layout snapshots, clone warnings, discard candidates and watchtab event records.\n * - the forms and data family adds its parameter grammar: `formrecord` with an optional `form` selector and non-empty `entries` of `{ match, kind, value }` where `match` is a `fieldmatch` with `mode` one of `label`, `placeholder`, `arialabel` or `name`; `valuegen` with a field `kind`, an optional `locale` and an optional numeric `seed`; `fields` lists of label or placeholder value pairs for filllabel and fillplaceholder; a reviewed `name` plus `formrecord` for saveprofiles; a reviewed `consentref` for submitform and consentpassword; a reviewed `backoff` rule with `wait` and `factor` plus an optional `attempts` for retryform with no code ceiling; a reviewed `child` selector, `pick` entry, `pause` and `timeout` for chains, typeaheads and card typing; reviewed card `segments`; and a reviewed `source` for fillcode; password entries inside form records are refused because passwords need the explicit consentpassword consent.\n * - form steps attach structured evidence to step details: form reports with detected fields, kinds and matched controls, error reports with field refs and messages, wizard states with step history, typeahead picks, honeypot flags, login detections with session link markers and signup or checkout template detections.\n * - the forms and data part two family adds its parameter grammar: `scrapetable` and `paginateextract` carry an optional dataset `name`, an optional positive integer `rowlimit` (never capped in code), a reviewed `next` control selector, an optional positive integer `pages` count (never capped in code) and an optional `wait` row freshness window; the export kinds (`exportcsv`, `exportjson`, `exportexcel`, `copytable`, `streamdisk`, `pushsheets`) carry a reviewed `dataset` id, an optional artifact `name`, an optional single character csv `delimiter`, a reviewed positive integer streaming `chunk` size (never capped in code) and, for sheet pushes, a reviewed HTTPS `sheet` endpoint plus the explicit `reviewed` flag; `importcsv` carries reviewed `csv` text with an optional `name` and a `mapping` object of csv headers to target keys; `looprows` carries a reviewed `dataset` id, an optional row `variable` name and a wrapped inner step by `stepid` or inline; `transformvalues` carries reviewed `rules` of `{ expression, sources, target }` where the expression is `trim`, `upper`, `lower`, `number`, `prefix:x`, `suffix:x` or `replace:from=>to`; `deduperows` carries reviewed dedupe `keys`; `mergepages` carries a reviewed `datasets` id list; `stamplerows` carries a reviewed `dataset` id with an optional `url`; `previewgrid` carries a reviewed `dataset` id with an optional `sample` row count (never capped in code); `resumeextract` carries a reviewed `session` id; and `logprovenance` carries a reviewed `artifact` id or name.\n * - data steps attach structured evidence to step details: scraped grids with normalized column specs, span filled rows and nested child datasets, pagination page counts with remaining next controls, dataset previews with sampled rows, dedupe removed counts, transform error lists, stream chunk states and provenance records with checksums and row ranges.\n * - the files, clipboard and downloads family adds its parameter grammar: `batchdownload` carries a reviewed `downloadspec` with a non-empty `urls` list, an optional `filename` rule and an optional `complete` criterion (`size` or `checksum`) plus an optional positive integer `concurrent` window (never capped in code); `pausedownload`, `resumedownload`, `verifydownload`, `quarantinedownload` and `scanvirus` carry a reviewed download or quarantine reference with optional `checksum`, `bytes`, `scanner` and `reason` fields; `interceptmime` carries a reviewed `mimefilter` with non-empty `include` patterns, optional `exclude` patterns and the `deny` or `allow` default for unlisted mime types; `readclipboard` carries a reviewed `consentref` plus an optional `prompt`; `exportnetlog` carries an optional `stepid` filter; `namecaptures` carries a reviewed `task` with optional `steps` and `extension`; and `cleanupartifacts` carries reviewed `rules` of `{ age, kind, keep }` where the age window carries no code ceiling and the keep policy is `none`, `latest` or `all`.\n * - files steps attach structured evidence to step details: batch download reports with per file states, resolved paths and checksums, verification match results, netlog records correlated with steps through request ids, clipboard entries with payload hashes and origin provenance (the payload text never appears), quarantine entries with scan verdicts and release refs, capture names stamped from task, step and sequence parts, and cleanup run outcomes with removed and kept counts.\n * - the media capture family adds its parameter grammar: every capture kind (`shotview`, `shotfullpage`, `shotelement`, `shotregion`, `contactsheet`) carries a reviewed `capture` options object with `format` (`png`, `jpeg` or `webp`), `quality` between zero and one hundred, `pixelratio` from one up with no code ceiling, an `annotate` flag and an `exporttarget` of `memory`, `download` or `clipboard`; `shotfullpage` adds reviewed `settle`, `overlap` and `wait` windows that keep the stitching scroll budget inside the reviewed wait window; `shotelement` addresses its element through the step target; `shotregion` requires a reviewed `regionrect` of `x`, `y`, `width` and `height` in css pixels plus the explicit `reviewed` flag, with an optional scrollable `container` selector and `steps` count; `contactsheet` carries reviewed `elements` selectors with an optional `sheet` layout of `cellsize`, `columns` and `label` (`none`, `index`, `selector` or `both`); and a reviewed `naming` rule of `run`, `step`, `sequence` and `kind` segment flags extends the 1.1.39 capture naming rule with the capture kind segment.\n * - capture steps attach structured evidence to step details: shotrecords with record id, run, step, kind, format, geometry and byte size, the stitch tile count of full page captures, shotpair ids of before and after state captures with their action kind, target selector and dom snapshot id, and contact sheet cells with selector labels; the response envelope gains a capture block with the record id, format and byte size, and the capture report carries every stored record and pair.\n * - the media capture part two family adds its parameter grammar: `capturepdf` carries reviewed `pdf` options of `paperwidth` and `paperheight` inches (positive, never capped in code), `margins` of `top`, `right`, `bottom` and `left` inches (negative margins are refused), a positive `scale`, `landscape` and `paginate` flags, optional reviewed break point `selectors` and an `exporttarget` of memory or download; `recordscreen` and `captureaudio` carry reviewed `recording` options of `scope` (`tab` or `run`), positive `fps` and `bitrate` values with no code ceilings, an `audio` flag, a positive `duration` window and a reviewed `consentref` of an approved recording consent prompt; `captureframe` addresses a video element through the step target with an optional `timestamp` in seconds and a `poster` flag; `downloadimages` carries a reviewed `imagefilter` of `selector` scope, `minwidth` and `minheight` thresholds and a `formats` list plus an optional `naming` rule; `shotcanvas` addresses a canvas element through the step target with reviewed capture options; `probestream` carries an optional scope `selector`; `readmedia` and `readassets` carry no parameters; `timelapse` carries a reviewed `lapse` plan of positive `interval` and `duration` windows with a `format` and the lapse duration kept inside the reviewed `wait` budget; `convertimage` carries reviewed `capture` or `captures` ids plus a `convert` directive of `source`, `target` (png, jpeg or webp) and `quality`; and `makethumbs` carries the same capture ids plus a `thumb` directive of positive `size`, `fit` (cover or contain) and `suffix`.\n * - media steps attach structured evidence to step details: pdf records with page count, paper size, margins and byte size, recording records with ids, durations, frame counts and file refs, image batches with filter match counts and deduplicated url lists, frame records with source, timestamp and poster flag, canvas records with context kind, stream probe results with track details, asset lists and ordered lapse frame ids; the response envelope gains a media block with the record id, kind and byte size, and the media report carries every stored media record and image batch.\n *\n * Ambiguous text, aria or name resolutions are refused at execution time with the candidate list so the user can choose.\n */\n\n/** Validates agent output before it becomes a locally reviewable plan. Plans may carry any number of steps. */\nexport function parseproposal(value: unknown, origin: string): planproposal {\n const root = record(value);\n if (root.version !== protocolversion) throw new Error(\"Unsupported protocol version.\");\n const planinput = record(root.plan);\n const stepsinput = planinput.steps;\n if (!Array.isArray(stepsinput) || stepsinput.length === 0) throw new Error(\"A plan needs at least one step.\");\n const steps: toolstep[] = stepsinput.map((input, index) => {\n const candidate = record(input);\n const kind = text(candidate.kind, `step ${index + 1} kind`) as toolstep[\"kind\"];\n const step: toolstep = {\n id: typeof candidate.id === \"string\" ? candidate.id : crypto.randomUUID(),\n kind,\n summary: text(candidate.summary, `step ${index + 1} summary`),\n risk: actionrisk(kind),\n ...(typeof candidate.target === \"string\" ? { target: candidate.target } : {}),\n ...(typeof candidate.value === \"string\" ? { value: candidate.value } : {}),\n ...(typeof candidate.options === \"string\" ? { options: candidate.options } : {}),\n };\n const evaluation = validatestep(step, origin);\n if (!evaluation.allowed) throw new Error(evaluation.reason);\n return step;\n });\n for (const step of steps) {\n if (step.kind !== \"retryaction\" && step.kind !== \"enterframe\" && step.kind !== \"looprows\") continue;\n const options = parseoptions(step);\n if (typeof options.stepid === \"string\" && !steps.some(candidate => candidate.id === options.stepid)) throw new Error(\"A retry, frame or loop wrapper references an unknown step id.\");\n }\n for (const step of steps) {\n if (step.kind !== \"submitform\" && step.kind !== \"retryform\") continue;\n const review = submitreviewgranted(steps, step.id);\n if (!review.allowed) throw new Error(review.reason);\n }\n const createdat = Date.now();\n const expiresat = typeof planinput.expiresat === \"number\" ? planinput.expiresat : createdat + 10 * 60 * 1000;\n const plan: agentplan = {\n id: typeof planinput.id === \"string\" ? planinput.id : crypto.randomUUID(),\n objective: text(planinput.objective, \"objective\"),\n origin,\n steps,\n createdat,\n expiresat,\n state: \"pending\",\n };\n if (plan.expiresat <= createdat) throw new Error(\"Plan expiry must be in the future.\");\n return { version: protocolversion, plan };\n}\n\n/** Shapes the only data that may be sent to a user-configured agent endpoint. */\nexport function requestbody(input: proposalrequest): string {\n return JSON.stringify({ version: protocolversion, objective: input.objective, session: input.session, observation: input.observation, capabilities: input.capabilities });\n}\n\n/** Wraps one executed step outcome in the versioned response envelope for callers, attaching the matched element summary, the capture block of capture steps and the media block of media steps for review. */\nexport function outcomeresponse(input: { outcome: stepoutcome; plan: agentplan; resolvedtarget?: resolvedtarget; capture?: { id: string; format: string; bytes: number }; media?: { id: string; kind: string; bytes: number } }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, outcome: input.outcome, ...(input.resolvedtarget ? { resolvedtarget: input.resolvedtarget } : {}), ...(input.capture ? { capture: input.capture } : {}), ...(input.media ? { media: input.media } : {}) });\n}\n\n/** Wraps a clickable map payload with numbered entries in the versioned response envelope. */\nexport function mapresponse(input: { map: clickablemap; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, map: input.map });\n}\n\n/** Reports the keys currently held on one tab for the live context envelope, refreshed per step. */\nexport function heldkeysreport(input: { tabid: number; holds: keyholdstate[] }): { version: typeof protocolversion; tabid: number; heldkeys: keyholdstate[] } {\n return { version: protocolversion, tabid: input.tabid, heldkeys: input.holds };\n}\n\n/** Wraps one observation capture with its a11y, reader, listpattern, tableshape and diff sections in the versioned response envelope. */\nexport function observationresponse(input: { observation: observation; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, observation: input.observation });\n}\n\n/** Wraps mutation, focus and banner event records with their timestamps and target paths in the versioned response envelope. */\nexport function eventresponse(input: { events: Array<mutationevent | focusevent | bannerreport>; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, events: input.events });\n}\n\n/** Wraps one snapshot diff with its added, removed and changed nodes and its two observation versions in the versioned response envelope. */\nexport function diffresponse(input: { diff: snapshotdiff; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, diff: input.diff });\n}\n\n/** Reports the detected page language, template class, scroll lock and banner state in the live context envelope. */\nexport function signalsreport(input: { signals?: pagesignals }): { version: typeof protocolversion; language?: string; template?: string; scrolllocked?: boolean; banner?: string } {\n const signals = input.signals;\n return {\n version: protocolversion,\n ...(signals && signals.language !== undefined ? { language: signals.language } : {}),\n ...(signals && signals.template !== undefined ? { template: signals.template } : {}),\n ...(signals && signals.scrolllocked !== undefined ? { scrolllocked: signals.scrolllocked } : {}),\n ...(signals && signals.banner !== undefined ? { banner: signals.banner } : {}),\n };\n}\n\n/** Wraps derived selector candidates with their stability scores in the versioned response envelope. */\nexport function selectorresponse(input: { candidates: selectorcandidate[]; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, candidates: input.candidates });\n}\n\n/** Wraps the live navigation state with its load phase, final url and redirect chain in the versioned response envelope. */\nexport function navstateresponse(input: { navstate: navstate; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, navstate: input.navstate });\n}\n\n/** Carries the navigation trail of a session with its visited urls, titles and step refs in the session context envelope. */\nexport function trailreport(input: { sessionid?: string; trail: trailentry[] }): { version: typeof protocolversion; sessionid?: string; trail: trailentry[] } {\n return { version: protocolversion, ...(input.sessionid ? { sessionid: input.sessionid } : {}), trail: input.trail };\n}\n\n/** Wraps url safety verdicts with their reasons in the versioned response envelope for external link review. */\nexport function safetyresponse(input: { verdicts: safetyverdict[]; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, verdicts: input.verdicts });\n}\n\n/** Wraps one tab report with its matched tabs, groups and badges in the versioned response envelope. */\nexport function tabreportresponse(input: { report: tabreport; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, report: input.report });\n}\n\n/** Carries the saved tab layouts with their window bounds and group states in the session context envelope. */\nexport function layoutreport(input: { layouts: tablayout[] }): { version: typeof protocolversion; layouts: tablayout[] } {\n return { version: protocolversion, layouts: input.layouts };\n}\n\n/** Wraps one form report with the detected fields, their kinds and the matched controls in the versioned response envelope. */\nexport function formreportresponse(input: { report: formreport; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, report: input.report });\n}\n\n/** Wraps one collected error report with its field refs and messages in the versioned response envelope for correction loops. */\nexport function errorreportresponse(input: { report: errorreport; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, report: input.report });\n}\n\n/** Carries the wizard states with their step history and the recorded typeahead picks in the session context envelope. */\nexport function wizardreport(input: { sessionid?: string; wizards: wizardstate[]; picks: typeaheadpick[] }): { version: typeof protocolversion; sessionid?: string; wizards: wizardstate[]; picks: typeaheadpick[] } {\n return { version: protocolversion, ...(input.sessionid ? { sessionid: input.sessionid } : {}), wizards: input.wizards, picks: input.picks };\n}\n\n/** Wraps one dataset payload with its column specs and a sampled row list in the versioned response envelope. */\nexport function datasetresponse(input: { dataset: dataset; plan: agentplan; sample?: number }): string {\n const sample = Math.max(0, Math.floor(input.sample ?? 10));\n const payload = { ...input.dataset, rows: input.dataset.rows.slice(0, sample), totalrows: input.dataset.rows.length };\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, dataset: payload });\n}\n\n/** Carries the extraction progress with visited page counts, collected row counts and resume cursors in the session context envelope. */\nexport function extractionreport(input: { sessions: extractsession[] }): { version: typeof protocolversion; sessions: extractsession[] } {\n return { version: protocolversion, sessions: input.sessions };\n}\n\n/** Reports the provenance records of every exported artifact with its source url, step ref, row range and checksum in the session context envelope. */\nexport function provenancereport(input: { records: provenancerecord[] }): { version: typeof protocolversion; records: provenancerecord[] } {\n return { version: protocolversion, records: input.records };\n}\n\n/** Documents the reviewed transform rule grammar shared by transformvalues steps and the task rules store. */\nexport function transformgrammar(rules: transformrule[]): string {\n return JSON.stringify({ rules: rules.map(rule => ({ expression: rule.expression, sources: rule.sources, target: rule.target })) });\n}\n\n/** Wraps the batch download queue with per file states, resolved paths and checksums in the versioned response envelope. */\nexport function downloadreport(input: { downloads: downloadrecord[]; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, downloads: input.downloads });\n}\n\n/** Carries the captured network log records with their step correlation through request ids in the session context envelope. */\nexport function netlogreport(input: { records: netlogrecord[] }): { version: typeof protocolversion; records: netlogrecord[] } {\n return { version: protocolversion, records: input.records };\n}\n\n/** Carries the quarantine entries with their scan verdicts and release refs in the session context envelope. */\nexport function quarantinereport(input: { entries: quarantineentry[] }): { version: typeof protocolversion; entries: quarantineentry[] } {\n return { version: protocolversion, entries: input.entries };\n}\n\n/** Carries every stored capture record with its metadata and the before and after shotpairs of the run in the session context envelope. */\nexport function capturereport(input: { records: shotrecord[]; pairs: shotpair[] }): { version: typeof protocolversion; records: shotrecord[]; pairs: shotpair[] } {\n return { version: protocolversion, records: input.records, pairs: input.pairs };\n}\n\n/** Carries every stored media record of pdf documents, recordings, frames, canvases, stream probes and assets beside the observed image batches in the session context envelope. */\nexport function mediareport(input: { records: mediarecord[]; images: imagebatch[] }): { version: typeof protocolversion; records: mediarecord[]; images: imagebatch[] } {\n return { version: protocolversion, records: input.records, images: input.images };\n}\n"],
5
+ "mappings": ";AAQO,IAAM,iBAAkC,CAAC,OAAO,QAAQ,MAAM;AAG9D,IAAM,iBAAkC,CAAC,UAAU,YAAY,WAAW;AAG1E,IAAM,eAAyB,CAAC,YAAY,gBAAgB,eAAe,cAAc,cAAc;AAGvG,SAAS,iBAAiB,OAAgC;AAC/D,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACzE,QAAM,UAAU;AAChB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