@wenathlan/extension 1.1.32 → 1.1.34
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/README.md +8 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +388 -12
- package/dist/index.js.map +3 -3
- package/dist/memory.d.ts +81 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/policy.d.ts +13 -1
- package/dist/policy.d.ts.map +1 -1
- package/dist/protocol.d.ts +67 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/types.d.ts +288 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/extension/dist/background.js +892 -25
- package/extension/dist/background.js.map +4 -4
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/pagebridge.js +1826 -88
- package/extension/dist/pagebridge.js.map +4 -4
- package/extension/dist/popup.html +1 -1
- package/extension/dist/popup.js +13 -3
- package/extension/dist/popup.js.map +2 -2
- package/extension/dist/sidepanel.html +1 -1
- package/extension/dist/sidepanel.js +322 -25
- package/extension/dist/sidepanel.js.map +2 -2
- package/extension/dist/style.css +2 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../memory.ts", "../policy.ts", "../version.ts", "../types.ts", "../protocol.ts"],
|
|
4
|
-
"sourcesContent": ["import type { agentplan, agentsession, auditevent, capabilityreport, diagnosticreport, endpointconfig, planprogress, runsettings, stepoutcome } 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\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\n/** Creates identifiers locally without a network dependency. */\nexport function randomid(): string {\n return crypto.randomUUID();\n}\n", "import type { actionkind, agentplan, agentsession, endpointconfig, policyevaluation, toolstep } 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\"]);\nconst interactionactions = new Set<actionkind>([\"focus\", \"scroll\", \"hover\", \"clickdeep\", \"rightclick\", \"doubleclick\", \"scrollpage\", \"scrollby\", \"scrollend\", \"scrolltop\", \"fullscreen\", \"zoomset\"]);\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\"]);\nconst allowedactions = new Set<actionkind>([...sensitiveactions, ...interactionactions, ...readactions]);\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\"]);\nconst valueactions = new Set<actionkind>([\"presskey\", \"drag\", \"drop\", \"upload\", \"readattribute\", \"removeattribute\", \"waittext\", \"evaluate\", \"zoomset\", \"tabactivate\", \"tabclose\", \"tabreload\", \"windowclose\", \"windowresize\", \"tabcreate\", \"windowcreate\", \"downloadfile\"]);\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/** 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/** 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 return 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/** 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 if (targetactions.has(step.kind) && !step.target?.trim()) 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 let options: Record<string, unknown>;\n try { options = parseoptions(step); } catch { return { allowed: false, reason: \"Step options must be a JSON object.\" }; }\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 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 }): 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 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 if (!targetactions.has(input.step.kind)) 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.32\" 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\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\";\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}\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}\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 /** Prior progress snapshots preserved when a new plan replaces the tracked one. */\n prior?: planprogress[];\n updatedat: number;\n}\n", "import { actionrisk, parseoptions, validatestep } from \"./policy.js\";\nimport { protocolversion, type agentplan, type planproposal, type proposalrequest, type stepoutcome, type toolstep } 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/** 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 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. */\nexport function outcomeresponse(input: { outcome: stepoutcome; plan: agentplan }): string {\n return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, outcome: input.outcome });\n}\n"],
|
|
5
|
-
"mappings": ";AAQO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,SAAwB;AAAxB;AAAA,EAAyB;AAAA,EAAzB;AAAA,EAE7B,MAAM,YAAiD;AAAE,WAAO,KAAK,QAAQ,IAAoB,QAAQ;AAAA,EAAG;AAAA,EAC5G,MAAM,UAAU,OAAsC;AAAE,WAAO,KAAK,QAAQ,IAAI,UAAU,KAAK;AAAA,EAAG;AAAA,EAClG,MAAM,aAAgD;AAAE,WAAO,KAAK,QAAQ,IAAkB,SAAS;AAAA,EAAG;AAAA,EAC1G,MAAM,WAAW,OAAoC;AAA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AC3E,GAAI,OAAO,UAAU,UAAU,WAAW,EAAE,OAAO,UAAU,MAAM,IAAI,CAAC;AAAA,MACxE,GAAI,OAAO,UAAU,YAAY,WAAW,EAAE,SAAS,UAAU,QAAQ,IAAI,CAAC;AAAA,IAChF;AACA,UAAM,aAAa,aAAa,MAAM,MAAM;AAC5C,QAAI,CAAC,WAAW,QAAS,OAAM,IAAI,MAAM,WAAW,MAAM;AAC1D,WAAO;AAAA,EACT,CAAC;AACD,QAAM,YAAY,KAAK,IAAI;AAC3B,QAAM,YAAY,OAAO,UAAU,cAAc,WAAW,UAAU,YAAY,YAAY,KAAK,KAAK;AACxG,QAAM,OAAkB;AAAA,IACtB,IAAI,OAAO,UAAU,OAAO,WAAW,UAAU,KAAK,OAAO,WAAW;AAAA,IACxE,WAAW,KAAK,UAAU,WAAW,WAAW;AAAA,IAChD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT;AACA,MAAI,KAAK,aAAa,UAAW,OAAM,IAAI,MAAM,oCAAoC;AACrF,SAAO,EAAE,SAAS,iBAAiB,KAAK;AAC1C;AAGO,SAAS,YAAY,OAAgC;AAC1D,SAAO,KAAK,UAAU,EAAE,SAAS,iBAAiB,WAAW,MAAM,WAAW,SAAS,MAAM,SAAS,aAAa,MAAM,aAAa,cAAc,MAAM,aAAa,CAAC;AAC1K;AAGO,SAAS,gBAAgB,OAA0D;AACxF,SAAO,KAAK,UAAU,EAAE,SAAS,iBAAiB,QAAQ,MAAM,KAAK,IAAI,WAAW,MAAM,KAAK,OAAO,SAAS,MAAM,QAAQ,CAAC;AAChI;",
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import type { a11ycapture, agentplan, agentsession, auditevent, bannerreport, capabilityreport, clickablemap, derivedselector, diagnosticreport, dialogdecision, dialogpolicy, endpointconfig, focusevent, keyholdstate, mutationevent, observationrecord, pagesignals, planprogress, readercapture, resolutionsummary, retryoutcome, runsettings, snapshotdiff, stepoutcome, templateprofile, watchregistration } 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\n/** Creates identifiers locally without a network dependency. */\nexport function randomid(): string {\n return crypto.randomUUID();\n}\n", "import type { actionkind, agentplan, agentsession, endpointconfig, observationmode, policyevaluation, toolstep } 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\"]);\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\"]);\nconst allowedactions = new Set<actionkind>([...sensitiveactions, ...interactionactions, ...readactions]);\nconst watchactions = new Set<actionkind>([\"watchmutate\", \"watchbanner\", \"watchfocus\"]);\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\"]);\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\"]);\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 return 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/** 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\") 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/** 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 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 }): 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 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.34\" 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\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\";\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}\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 /** 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", "import { actionrisk, parseoptions, validatestep } from \"./policy.js\";\nimport { protocolversion, type agentplan, type bannerreport, type clickablemap, type focusevent, type keyholdstate, type mutationevent, type observation, type pagesignals, type planproposal, type proposalrequest, type resolvedtarget, type selectorcandidate, type snapshotdiff, type stepoutcome, type toolstep } 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 * - 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 *\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\") continue;\n const options = parseoptions(step);\n if (typeof options.stepid === \"string\" && !steps.some(candidate => candidate.id === options.stepid)) throw new Error(\"A retry or frame wrapper references an unknown step id.\");\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"],
|
|
5
|
+
"mappings": ";AAYO,IAAM,gBAAN,MAAoB;AAAA,EACzB,YAA6B,SAAwB;AAAxB;AAAA,EAAyB;AAAA,EAAzB;AAAA,EAE7B,MAAM,YAAiD;AAAE,WAAO,KAAK,QAAQ,IAAoB,QAAQ;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AAiB,SAAY,EAAE,cAAc,QAAQ,aAAa,IAAI,CAAC;AAAA,IAC9F,GAAI,WAAW,QAAQ,WAAW,SAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;AAAA,EAC9E;AACF;AAGO,SAAS,iBAAiB,OAAqE;AACpG,SAAO,KAAK,UAAU,EAAE,SAAS,iBAAiB,QAAQ,MAAM,KAAK,IAAI,WAAW,MAAM,KAAK,OAAO,YAAY,MAAM,WAAW,CAAC;AACtI;",
|
|
6
|
+
"names": ["record"]
|
|
7
7
|
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { agentplan, agentsession, auditevent, capabilityreport, diagnosticreport, endpointconfig, planprogress, runsettings, stepoutcome } from "./types.js";
|
|
1
|
+
import type { a11ycapture, agentplan, agentsession, auditevent, bannerreport, capabilityreport, clickablemap, derivedselector, diagnosticreport, dialogdecision, dialogpolicy, endpointconfig, focusevent, keyholdstate, mutationevent, observationrecord, pagesignals, planprogress, readercapture, resolutionsummary, retryoutcome, runsettings, snapshotdiff, stepoutcome, templateprofile, watchregistration } from "./types.js";
|
|
2
2
|
/** Provides a small storage seam that works in browser, tests and future adapters. */
|
|
3
3
|
export interface memoryadapter {
|
|
4
4
|
get<T>(key: string): Promise<T | undefined>;
|
|
5
5
|
set<T>(key: string, value: T): Promise<void>;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Local memory for sessions, plans, audit evidence and interaction state.
|
|
9
|
+
* 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.
|
|
10
|
+
*/
|
|
7
11
|
export declare class sessionmemory {
|
|
8
12
|
private readonly adapter;
|
|
9
13
|
constructor(adapter: memoryadapter);
|
|
@@ -27,6 +31,82 @@ export declare class sessionmemory {
|
|
|
27
31
|
addaudi(event: auditevent): Promise<void>;
|
|
28
32
|
/** Records one step outcome; retention is a user setting and an absent setting keeps every outcome. */
|
|
29
33
|
addoutcome(outcome: stepoutcome): Promise<void>;
|
|
34
|
+
/** Stores one clickable map under its observation version so every captured map stays available. */
|
|
35
|
+
setmap(map: clickablemap): Promise<void>;
|
|
36
|
+
/** Returns one stored clickable map by its observation version. */
|
|
37
|
+
getmap(version: number): Promise<clickablemap | undefined>;
|
|
38
|
+
/** Advances and persists the observation version counter used to stamp clickable maps. */
|
|
39
|
+
nextobservationversion(): Promise<number>;
|
|
40
|
+
/** Returns the latest observation version used to stamp a clickable map. */
|
|
41
|
+
getobservationversion(): Promise<number | undefined>;
|
|
42
|
+
/** Returns the key hold registry, persisted so holds survive service worker restarts. */
|
|
43
|
+
getholds(): Promise<keyholdstate[]>;
|
|
44
|
+
/** Replaces the key hold registry after one press or release transition. */
|
|
45
|
+
setholds(holds: keyholdstate[]): Promise<void>;
|
|
46
|
+
/** Returns every dialog decision recorded for the audit trail. */
|
|
47
|
+
getdialogs(): Promise<dialogdecision[]>;
|
|
48
|
+
/** Records one dialog decision with the reviewed answer and the observed dialog text. */
|
|
49
|
+
adddialog(decision: dialogdecision): Promise<void>;
|
|
50
|
+
/** Returns every retry outcome recorded with attempts and movement deltas. */
|
|
51
|
+
getretries(): Promise<retryoutcome[]>;
|
|
52
|
+
/** Records one retry outcome with the attempts made and the movement delta observed. */
|
|
53
|
+
addretry(outcome: retryoutcome): Promise<void>;
|
|
54
|
+
/** Returns every resolution summary stored per target mode. */
|
|
55
|
+
getresolutions(): Promise<resolutionsummary[]>;
|
|
56
|
+
/** Records one resolution summary for later selector derivation. */
|
|
57
|
+
addresolution(summary: resolutionsummary): Promise<void>;
|
|
58
|
+
/** Returns the reviewed default dialog policy kept for the session auto handler. */
|
|
59
|
+
getdialogpolicy(): Promise<dialogpolicy | undefined>;
|
|
60
|
+
/** Stores the reviewed default dialog policy of the latest approved plan. */
|
|
61
|
+
setdialogpolicy(policy: dialogpolicy): Promise<void>;
|
|
62
|
+
/** Stores one observation capture under its version so every observation version stays available. */
|
|
63
|
+
setobservation(record: observationrecord): Promise<void>;
|
|
64
|
+
/** Returns one stored observation version. */
|
|
65
|
+
getobservation(version: number): Promise<observationrecord | undefined>;
|
|
66
|
+
/** Returns the observation retention window; an absent setting keeps every capture. */
|
|
67
|
+
private observationretention;
|
|
68
|
+
/** Stores one accessibility tree capture; retention is a user setting and an absent setting keeps every tree. */
|
|
69
|
+
adda11ytree(capture: a11ycapture): Promise<void>;
|
|
70
|
+
/** Returns every stored accessibility tree capture, newest first. */
|
|
71
|
+
geta11ytrees(): Promise<a11ycapture[]>;
|
|
72
|
+
/** Stores one reader article capture; retention is a user setting and an absent setting keeps every article. */
|
|
73
|
+
addreaderarticle(capture: readercapture): Promise<void>;
|
|
74
|
+
/** Returns every stored reader article capture, newest first. */
|
|
75
|
+
getreaderarticles(): Promise<readercapture[]>;
|
|
76
|
+
/** Records one dom mutation observed inside a reviewed watch. */
|
|
77
|
+
addmutationevent(event: mutationevent): Promise<void>;
|
|
78
|
+
/** Returns the mutation event stream of every reviewed watch. */
|
|
79
|
+
getmutationevents(): Promise<mutationevent[]>;
|
|
80
|
+
/** Records one focus change observed inside a reviewed watch. */
|
|
81
|
+
addfocusevent(event: focusevent): Promise<void>;
|
|
82
|
+
/** Returns the focus event stream of every reviewed watch. */
|
|
83
|
+
getfocusevents(): Promise<focusevent[]>;
|
|
84
|
+
/** Records one consent banner observed by a reviewed banner watch. */
|
|
85
|
+
addbanner(event: bannerreport): Promise<void>;
|
|
86
|
+
/** Returns every consent banner report observed so far. */
|
|
87
|
+
getbanners(): Promise<bannerreport[]>;
|
|
88
|
+
/** Records one snapshot diff between two observation versions. */
|
|
89
|
+
adddiff(diff: snapshotdiff): Promise<void>;
|
|
90
|
+
/** Returns every stored snapshot diff, newest first. */
|
|
91
|
+
getdiffs(): Promise<snapshotdiff[]>;
|
|
92
|
+
/** Records one derived selector with its stability score for reuse. */
|
|
93
|
+
addselector(selector: derivedselector): Promise<void>;
|
|
94
|
+
/** Returns every stored derived selector with its stability score, newest first. */
|
|
95
|
+
getselectors(): Promise<derivedselector[]>;
|
|
96
|
+
/** Records one detected template class or section fingerprint for its origin. */
|
|
97
|
+
addtemplate(profile: templateprofile): Promise<void>;
|
|
98
|
+
/** Returns every stored template class and section fingerprint, newest first. */
|
|
99
|
+
gettemplates(): Promise<templateprofile[]>;
|
|
100
|
+
/** Records one watch registration so it survives service worker restarts. */
|
|
101
|
+
addwatch(watch: watchregistration): Promise<void>;
|
|
102
|
+
/** Returns every watch registration, newest first, including closed windows. */
|
|
103
|
+
getwatches(): Promise<watchregistration[]>;
|
|
104
|
+
/** Closes one watch registration by watch id once its reviewed lifetime window ends. */
|
|
105
|
+
closewatch(watchid: string, closedat: number): Promise<void>;
|
|
106
|
+
/** Returns the live page signals of language, template, scroll lock and banner state. */
|
|
107
|
+
getsignals(): Promise<pagesignals | undefined>;
|
|
108
|
+
/** Replaces the live page signals after an observation step refreshes them. */
|
|
109
|
+
setsignals(signals: pagesignals): Promise<void>;
|
|
30
110
|
}
|
|
31
111
|
/** Creates identifiers locally without a network dependency. */
|
|
32
112
|
export declare function randomid(): string;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,W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ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import type { actionkind, agentplan, agentsession, endpointconfig, policyevaluation, toolstep } from "./types.js";
|
|
1
|
+
import type { actionkind, agentplan, agentsession, endpointconfig, observationmode, policyevaluation, toolstep } from "./types.js";
|
|
2
2
|
/** Normalizes a user supplied HTTPS endpoint without preserving a provider lock-in. */
|
|
3
3
|
export declare function normalizeendpoint(value: string): endpointconfig;
|
|
4
4
|
/** Creates the exact optional host pattern requested from Chromium. */
|
|
5
5
|
export declare function hostpattern(origin: string): string;
|
|
6
|
+
/** True when the action kind observes the page over a reviewed lifetime window. */
|
|
7
|
+
export declare function iswatchkind(kind: actionkind): boolean;
|
|
8
|
+
/** Grades the observation mode of a kind: passive capture, watched lifetimes or diffing passes. */
|
|
9
|
+
export declare function observationmodeof(kind: actionkind): observationmode;
|
|
6
10
|
/** Defines action risk from the fixed local allowlist. */
|
|
7
11
|
export declare function actionrisk(kind: actionkind): "read" | "interaction" | "sensitive";
|
|
12
|
+
/** True when the action kind accepts a css selector target or a reviewed targetref. */
|
|
13
|
+
export declare function needstarget(kind: actionkind): boolean;
|
|
8
14
|
/** Parses the reviewed JSON options of a step; malformed payloads are rejected early. */
|
|
9
15
|
export declare function parseoptions(step: toolstep): Record<string, unknown>;
|
|
10
16
|
/** Maps an action kind to the optional browser permission it requires, if any. */
|
|
11
17
|
export declare function requiredcapability(kind: actionkind): string | undefined;
|
|
12
18
|
/** Parses the reviewed wait duration of a wait step with no upper bound. */
|
|
13
19
|
export declare function waitduration(step: toolstep): number;
|
|
20
|
+
/** Grades a resolution match count: zero is absent, one is resolved and more than one is refused as ambiguous. */
|
|
21
|
+
export declare function resolutionverdict(count: number): "absent" | "resolved" | "ambiguous";
|
|
22
|
+
/** Validates the reviewed targetref grammar of every resolution mode and rejects empty references. */
|
|
23
|
+
export declare function validatetargetref(reference: unknown): policyevaluation;
|
|
24
|
+
/** True when the session origin grants cover the given origin; a session without grants only allows its own origin. */
|
|
25
|
+
export declare function origingranted(session: agentsession | undefined, origin: string): boolean;
|
|
14
26
|
/** Validates a single proposal against the active tab origin and local policy. */
|
|
15
27
|
export declare function validatestep(step: toolstep, origin: string): policyevaluation;
|
|
16
28
|
/** Applies the consent gate immediately before an action reaches the page bridge. */
|
package/dist/policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUnI,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAK/D;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAErD;AAED,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe,CAInE;AAED,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,WAAW,CAIjF;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAErD;AAED,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMpE;AAED,kFAAkF;AAClF,w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equest, type stepoutcome } from "./types.js";
|
|
1
|
+
import { protocolversion, type agentplan, type bannerreport, type clickablemap, type focusevent, type keyholdstate, type mutationevent, type observation, type pagesignals, type planproposal, type proposalrequest, type resolvedtarget, type selectorcandidate, type snapshotdiff, type stepoutcome } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reviewed options grammar shared by every step kind.
|
|
4
|
+
*
|
|
5
|
+
* A step may carry a JSON `options` object with the following reviewed fields:
|
|
6
|
+
* - `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.
|
|
7
|
+
* - `pointpath`: pointer travel between two points, with `start` and `end` points, optional `waypoints` and a `duration` in milliseconds.
|
|
8
|
+
* - `speedprofile`: pointer speed shape with `easing` (`linear` or `easeinout`), a `peak` velocity in pixels per second and a `jitter` window in milliseconds.
|
|
9
|
+
* - `framepath`: ordered frame indexes routing a step inside same origin iframes.
|
|
10
|
+
* - `shadow`: ordered host selectors addressing a target across open shadow roots.
|
|
11
|
+
* - `retryrule`: retry bounds with `attempts`, a `settle` window in milliseconds and a movement `tolerance` in pixels; attempts carry no code ceiling.
|
|
12
|
+
* - `dialogpolicy`: dialog answers with an `accept` flag and a reviewed prompt `answer` string.
|
|
13
|
+
* - wrapper steps (`retryaction`, `enterframe`) reference an inner step by `stepid` or inline with `kind`, `target`, `value` and an `options` object.
|
|
14
|
+
* - control kinds add reviewed `delay`, `values`, `results`, `timeout`, `holdid` and `modifiers` fields.
|
|
15
|
+
* - 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.
|
|
16
|
+
* - `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.
|
|
17
|
+
* - `diffsnapshots` carries exactly two reviewed observation `versions` to compare.
|
|
18
|
+
* - 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.
|
|
19
|
+
*
|
|
20
|
+
* Ambiguous text, aria or name resolutions are refused at execution time with the candidate list so the user can choose.
|
|
21
|
+
*/
|
|
2
22
|
/** Validates agent output before it becomes a locally reviewable plan. Plans may carry any number of steps. */
|
|
3
23
|
export declare function parseproposal(value: unknown, origin: string): planproposal;
|
|
4
24
|
/** Shapes the only data that may be sent to a user-configured agent endpoint. */
|
|
5
25
|
export declare function requestbody(input: proposalrequest): string;
|
|
6
|
-
/** Wraps one executed step outcome in the versioned response envelope for callers. */
|
|
26
|
+
/** Wraps one executed step outcome in the versioned response envelope for callers, attaching the matched element summary for review. */
|
|
7
27
|
export declare function outcomeresponse(input: {
|
|
8
28
|
outcome: stepoutcome;
|
|
9
29
|
plan: agentplan;
|
|
30
|
+
resolvedtarget?: resolvedtarget;
|
|
31
|
+
}): string;
|
|
32
|
+
/** Wraps a clickable map payload with numbered entries in the versioned response envelope. */
|
|
33
|
+
export declare function mapresponse(input: {
|
|
34
|
+
map: clickablemap;
|
|
35
|
+
plan: agentplan;
|
|
36
|
+
}): string;
|
|
37
|
+
/** Reports the keys currently held on one tab for the live context envelope, refreshed per step. */
|
|
38
|
+
export declare function heldkeysreport(input: {
|
|
39
|
+
tabid: number;
|
|
40
|
+
holds: keyholdstate[];
|
|
41
|
+
}): {
|
|
42
|
+
version: typeof protocolversion;
|
|
43
|
+
tabid: number;
|
|
44
|
+
heldkeys: keyholdstate[];
|
|
45
|
+
};
|
|
46
|
+
/** Wraps one observation capture with its a11y, reader, listpattern, tableshape and diff sections in the versioned response envelope. */
|
|
47
|
+
export declare function observationresponse(input: {
|
|
48
|
+
observation: observation;
|
|
49
|
+
plan: agentplan;
|
|
50
|
+
}): string;
|
|
51
|
+
/** Wraps mutation, focus and banner event records with their timestamps and target paths in the versioned response envelope. */
|
|
52
|
+
export declare function eventresponse(input: {
|
|
53
|
+
events: Array<mutationevent | focusevent | bannerreport>;
|
|
54
|
+
plan: agentplan;
|
|
55
|
+
}): string;
|
|
56
|
+
/** Wraps one snapshot diff with its added, removed and changed nodes and its two observation versions in the versioned response envelope. */
|
|
57
|
+
export declare function diffresponse(input: {
|
|
58
|
+
diff: snapshotdiff;
|
|
59
|
+
plan: agentplan;
|
|
60
|
+
}): string;
|
|
61
|
+
/** Reports the detected page language, template class, scroll lock and banner state in the live context envelope. */
|
|
62
|
+
export declare function signalsreport(input: {
|
|
63
|
+
signals?: pagesignals;
|
|
64
|
+
}): {
|
|
65
|
+
version: typeof protocolversion;
|
|
66
|
+
language?: string;
|
|
67
|
+
template?: string;
|
|
68
|
+
scrolllocked?: boolean;
|
|
69
|
+
banner?: string;
|
|
70
|
+
};
|
|
71
|
+
/** Wraps derived selector candidates with their stability scores in the versioned response envelope. */
|
|
72
|
+
export declare function selectorresponse(input: {
|
|
73
|
+
candidates: selectorcandidate[];
|
|
74
|
+
plan: agentplan;
|
|
10
75
|
}): string;
|
|
11
76
|
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../protocol.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,KAAK,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