@wenathlan/extension 1.1.32 → 1.1.33
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 +5 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +221 -12
- package/dist/index.js.map +2 -2
- package/dist/memory.d.ts +33 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/policy.d.ts +8 -0
- package/dist/policy.d.ts.map +1 -1
- package/dist/protocol.d.ts +33 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/types.d.ts +114 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/extension/dist/background.js +565 -23
- package/extension/dist/background.js.map +4 -4
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/pagebridge.js +894 -86
- package/extension/dist/pagebridge.js.map +4 -4
- package/extension/dist/popup.html +1 -1
- package/extension/dist/popup.js +12 -3
- package/extension/dist/popup.js.map +2 -2
- package/extension/dist/sidepanel.html +1 -1
- package/extension/dist/sidepanel.js +134 -25
- package/extension/dist/sidepanel.js.map +2 -2
- package/extension/dist/style.css +1 -1
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Devthink is a **consent-first browser-agent bridge** distributed as a TypeScript library and a Chromium Manifest V3 extension. It turns a user-provided browser objective into a bounded, reviewable plan. The user must start the active-tab session and approve the plan before any page action reaches the browser.
|
|
4
4
|
|
|
5
|
-
Version: **1.1.
|
|
5
|
+
Version: **1.1.33**. License: **GPL-3.0-only**. The repository is `wenathlan/extension`; the npm-compatible scoped package identifier is `@wenathlan/extension`.
|
|
6
6
|
|
|
7
7
|
## What it does
|
|
8
8
|
|
|
9
|
-
| Capability | Behavior in 1.1.
|
|
9
|
+
| Capability | Behavior in 1.1.33 |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| Active-tab session | The user starts a short-lived session for one HTTPS tab and one origin; the session records its origin grants. |
|
|
12
12
|
| Page observation | The extension captures the complete semantic inventory: every interactive element, every form control, every select option and the full page text. |
|
|
13
13
|
| Plan proposal | A local plan can be created immediately; an optional user-configured HTTPS endpoint can return a typed plan proposal of any length. |
|
|
14
14
|
| Review gate | Every remote proposal starts in `pending`; it cannot reach the page bridge before explicit approval. |
|
|
15
|
-
| Browser tools | Reviewed plans cover
|
|
15
|
+
| Browser tools | Reviewed plans cover ninety action kinds: pointer paths and coordinate clicks, text, aria, name, xpath, index and point target resolution, timed typing, key holds, sliders, dates, colors, shadow dom piercing, iframe entry, dialog answering, retry rules, a complete read vocabulary with clickable maps and verification reads, page mutation under review, and browser-level tab, window, zoom, snapshot and download commands. |
|
|
16
|
+
| Target resolution | Steps address elements through reviewed `targetref` modes: css selector, visible text, aria role and name, accessible name, xpath, clickable map index or viewport point; ambiguous matches are refused with candidate lists and every resolution returns a matched element summary for review. |
|
|
16
17
|
| Optional capabilities | `tabs`, `downloads`, `clipboardRead` and `clipboardWrite` are optional permissions; browser kinds check their capability, the review panel can request a grant and every grant is audited. |
|
|
17
18
|
| Unlimited by choice | Wait durations, plan size, plan expiry, audit retention and outcome retention carry no code ceilings; every bound is a user choice. |
|
|
18
19
|
| Structured results | Step results carry structured JSON details, rendered in the side panel beside each reviewed step. |
|
|
@@ -45,7 +46,7 @@ The endpoint field intentionally has no default URL. Enter a URL such as `https:
|
|
|
45
46
|
|
|
46
47
|
```json
|
|
47
48
|
{
|
|
48
|
-
"version": "1.1.
|
|
49
|
+
"version": "1.1.33",
|
|
49
50
|
"objective": "User supplied objective",
|
|
50
51
|
"session": { "id": "uuid", "tabid": 1, "origin": "https://example.com" },
|
|
51
52
|
"observation": { "schemaversion": 2, "url": "https://example.com/path", "interactive": [] },
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./memory.js";
|
|
2
|
-
export { actionrisk as deriveactionrisk, canexecute, hostpattern, normalizeendpoint, validatestep } from "./policy.js";
|
|
2
|
+
export { actionrisk as deriveactionrisk, canexecute, hostpattern, normalizeendpoint, resolutionverdict, validatestep, validatetargetref } from "./policy.js";
|
|
3
3
|
export * from "./protocol.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7J,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -66,18 +66,80 @@ var sessionmemory = class {
|
|
|
66
66
|
const retention = (await this.getsettings())?.outcomeretention;
|
|
67
67
|
await this.adapter.set("outcomes", retention === void 0 ? combined : combined.slice(0, retention));
|
|
68
68
|
}
|
|
69
|
+
/** Stores one clickable map under its observation version so every captured map stays available. */
|
|
70
|
+
async setmap(map) {
|
|
71
|
+
return this.adapter.set(`map${map.version}`, map);
|
|
72
|
+
}
|
|
73
|
+
/** Returns one stored clickable map by its observation version. */
|
|
74
|
+
async getmap(version) {
|
|
75
|
+
return this.adapter.get(`map${version}`);
|
|
76
|
+
}
|
|
77
|
+
/** Advances and persists the observation version counter used to stamp clickable maps. */
|
|
78
|
+
async nextobservationversion() {
|
|
79
|
+
const current = await this.adapter.get("observationversion") ?? 0;
|
|
80
|
+
const next = current + 1;
|
|
81
|
+
await this.adapter.set("observationversion", next);
|
|
82
|
+
return next;
|
|
83
|
+
}
|
|
84
|
+
/** Returns the latest observation version used to stamp a clickable map. */
|
|
85
|
+
async getobservationversion() {
|
|
86
|
+
return this.adapter.get("observationversion");
|
|
87
|
+
}
|
|
88
|
+
/** Returns the key hold registry, persisted so holds survive service worker restarts. */
|
|
89
|
+
async getholds() {
|
|
90
|
+
return await this.adapter.get("holds") ?? [];
|
|
91
|
+
}
|
|
92
|
+
/** Replaces the key hold registry after one press or release transition. */
|
|
93
|
+
async setholds(holds) {
|
|
94
|
+
return this.adapter.set("holds", holds);
|
|
95
|
+
}
|
|
96
|
+
/** Returns every dialog decision recorded for the audit trail. */
|
|
97
|
+
async getdialogs() {
|
|
98
|
+
return await this.adapter.get("dialogs") ?? [];
|
|
99
|
+
}
|
|
100
|
+
/** Records one dialog decision with the reviewed answer and the observed dialog text. */
|
|
101
|
+
async adddialog(decision) {
|
|
102
|
+
const records = await this.getdialogs();
|
|
103
|
+
await this.adapter.set("dialogs", [decision, ...records]);
|
|
104
|
+
}
|
|
105
|
+
/** Returns every retry outcome recorded with attempts and movement deltas. */
|
|
106
|
+
async getretries() {
|
|
107
|
+
return await this.adapter.get("retries") ?? [];
|
|
108
|
+
}
|
|
109
|
+
/** Records one retry outcome with the attempts made and the movement delta observed. */
|
|
110
|
+
async addretry(outcome) {
|
|
111
|
+
const records = await this.getretries();
|
|
112
|
+
await this.adapter.set("retries", [outcome, ...records]);
|
|
113
|
+
}
|
|
114
|
+
/** Returns every resolution summary stored per target mode. */
|
|
115
|
+
async getresolutions() {
|
|
116
|
+
return await this.adapter.get("resolutions") ?? [];
|
|
117
|
+
}
|
|
118
|
+
/** Records one resolution summary for later selector derivation. */
|
|
119
|
+
async addresolution(summary) {
|
|
120
|
+
const records = await this.getresolutions();
|
|
121
|
+
await this.adapter.set("resolutions", [summary, ...records]);
|
|
122
|
+
}
|
|
123
|
+
/** Returns the reviewed default dialog policy kept for the session auto handler. */
|
|
124
|
+
async getdialogpolicy() {
|
|
125
|
+
return this.adapter.get("dialogpolicy");
|
|
126
|
+
}
|
|
127
|
+
/** Stores the reviewed default dialog policy of the latest approved plan. */
|
|
128
|
+
async setdialogpolicy(policy) {
|
|
129
|
+
return this.adapter.set("dialogpolicy", policy);
|
|
130
|
+
}
|
|
69
131
|
};
|
|
70
132
|
function randomid() {
|
|
71
133
|
return crypto.randomUUID();
|
|
72
134
|
}
|
|
73
135
|
|
|
74
136
|
// policy.ts
|
|
75
|
-
var sensitiveactions = /* @__PURE__ */ new Set(["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"]);
|
|
76
|
-
var interactionactions = /* @__PURE__ */ new Set(["focus", "scroll", "hover", "clickdeep", "rightclick", "doubleclick", "scrollpage", "scrollby", "scrollend", "scrolltop", "fullscreen", "zoomset"]);
|
|
77
|
-
var readactions = /* @__PURE__ */ new Set(["observe", "inspect", "extract", "wait", "waitfor", "waittext", "readattribute", "readstyle", "readgeometry", "readvalue", "readtext", "readhtml", "countelements", "readtable", "readlinks", "readimages", "readmeta", "readforms", "readstorage", "highlight", "tablist", "windowlist", "tabsnapshot"]);
|
|
137
|
+
var sensitiveactions = /* @__PURE__ */ new Set(["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"]);
|
|
138
|
+
var interactionactions = /* @__PURE__ */ new Set(["focus", "scroll", "hover", "clickdeep", "rightclick", "doubleclick", "scrollpage", "scrollby", "scrollend", "scrolltop", "fullscreen", "zoomset", "movepointer", "clicktext", "clickaria", "clickname", "expanddetails", "pierceshadow", "retryaction"]);
|
|
139
|
+
var readactions = /* @__PURE__ */ new Set(["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"]);
|
|
78
140
|
var allowedactions = /* @__PURE__ */ new Set([...sensitiveactions, ...interactionactions, ...readactions]);
|
|
79
|
-
var targetactions = /* @__PURE__ */ new Set(["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"]);
|
|
80
|
-
var valueactions = /* @__PURE__ */ new Set(["presskey", "drag", "drop", "upload", "readattribute", "removeattribute", "waittext", "evaluate", "zoomset", "tabactivate", "tabclose", "tabreload", "windowclose", "windowresize", "tabcreate", "windowcreate", "downloadfile"]);
|
|
141
|
+
var targetactions = /* @__PURE__ */ new Set(["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"]);
|
|
142
|
+
var valueactions = /* @__PURE__ */ new Set(["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"]);
|
|
81
143
|
function normalizeendpoint(value) {
|
|
82
144
|
const endpoint = new URL(value.trim());
|
|
83
145
|
if (endpoint.protocol !== "https:") throw new Error("Devthink accepts HTTPS endpoints only.");
|
|
@@ -116,19 +178,88 @@ function isnumericid(value) {
|
|
|
116
178
|
function numericoption(options, key) {
|
|
117
179
|
return options[key] === void 0 || typeof options[key] === "number" && Number.isFinite(options[key]);
|
|
118
180
|
}
|
|
181
|
+
function nonnegativeoption(options, key) {
|
|
182
|
+
return numericoption(options, key) && !(typeof options[key] === "number" && options[key] < 0);
|
|
183
|
+
}
|
|
184
|
+
function isnonempty(value) {
|
|
185
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
186
|
+
}
|
|
187
|
+
function ispoint(value) {
|
|
188
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
189
|
+
const point = value;
|
|
190
|
+
return typeof point.x === "number" && Number.isFinite(point.x) && typeof point.y === "number" && Number.isFinite(point.y);
|
|
191
|
+
}
|
|
192
|
+
function resolutionverdict(count) {
|
|
193
|
+
if (!Number.isFinite(count) || count <= 0) return "absent";
|
|
194
|
+
return count === 1 ? "resolved" : "ambiguous";
|
|
195
|
+
}
|
|
196
|
+
function validatetargetref(reference) {
|
|
197
|
+
if (!reference || typeof reference !== "object" || Array.isArray(reference)) return { allowed: false, reason: "The reviewed target reference must be an object." };
|
|
198
|
+
const ref = reference;
|
|
199
|
+
if (ref.mode === "selector") return isnonempty(ref.selector) ? { allowed: true } : { allowed: false, reason: "The selector target reference needs a non-empty selector." };
|
|
200
|
+
if (ref.mode === "text") return isnonempty(ref.text) ? { allowed: true } : { allowed: false, reason: "The text target reference needs non-empty text." };
|
|
201
|
+
if (ref.mode === "aria") {
|
|
202
|
+
if (!isnonempty(ref.role)) return { allowed: false, reason: "The aria target reference needs a non-empty role." };
|
|
203
|
+
return isnonempty(ref.name) ? { allowed: true } : { allowed: false, reason: "The aria target reference needs a non-empty name." };
|
|
204
|
+
}
|
|
205
|
+
if (ref.mode === "name") return isnonempty(ref.name) ? { allowed: true } : { allowed: false, reason: "The name target reference needs a non-empty name." };
|
|
206
|
+
if (ref.mode === "xpath") return isnonempty(ref.xpath) ? { allowed: true } : { allowed: false, reason: "The xpath target reference needs a non-empty expression." };
|
|
207
|
+
if (ref.mode === "index") {
|
|
208
|
+
const index = ref.index;
|
|
209
|
+
return typeof index === "number" && Number.isInteger(index) && index >= 1 ? { allowed: true } : { allowed: false, reason: "The index target reference needs a positive integer map number." };
|
|
210
|
+
}
|
|
211
|
+
if (ref.mode === "point") {
|
|
212
|
+
const pointok = typeof ref.x === "number" && Number.isFinite(ref.x) && typeof ref.y === "number" && Number.isFinite(ref.y);
|
|
213
|
+
return pointok ? { allowed: true } : { allowed: false, reason: "The point target reference needs numeric x and y coordinates." };
|
|
214
|
+
}
|
|
215
|
+
return { allowed: false, reason: "The target reference mode must be selector, text, aria, name, xpath, index or point." };
|
|
216
|
+
}
|
|
217
|
+
function origingranted(session, origin) {
|
|
218
|
+
if (!session) return false;
|
|
219
|
+
const grants = session.grants ?? [session.origin];
|
|
220
|
+
return grants.includes(origin);
|
|
221
|
+
}
|
|
222
|
+
function validateinnerstep(options, origin) {
|
|
223
|
+
const stepid = options.stepid;
|
|
224
|
+
const kind = options.kind;
|
|
225
|
+
if (isnonempty(stepid)) {
|
|
226
|
+
if (kind !== void 0) return { allowed: false, reason: "The reviewed wrapper must reference a step id or an inline step, not both." };
|
|
227
|
+
return { allowed: true };
|
|
228
|
+
}
|
|
229
|
+
if (typeof kind !== "string" || !kind.trim()) return { allowed: false, reason: "A reviewed step id or inline step kind is required in options." };
|
|
230
|
+
if (kind === "retryaction" || kind === "enterframe") return { allowed: false, reason: "The reviewed inner step cannot be another wrapper kind." };
|
|
231
|
+
if (!allowedactions.has(kind)) return { allowed: false, reason: "The reviewed inner step kind is unsupported." };
|
|
232
|
+
const inneroptions = options.options;
|
|
233
|
+
if (inneroptions !== void 0 && (!inneroptions || typeof inneroptions !== "object" || Array.isArray(inneroptions))) return { allowed: false, reason: "The reviewed inner step options must be an object." };
|
|
234
|
+
const inner = {
|
|
235
|
+
id: "inner",
|
|
236
|
+
kind,
|
|
237
|
+
summary: "Reviewed inner step.",
|
|
238
|
+
risk: actionrisk(kind),
|
|
239
|
+
...isnonempty(options.target) ? { target: options.target } : {},
|
|
240
|
+
...isnonempty(options.value) ? { value: options.value } : {},
|
|
241
|
+
...inneroptions !== void 0 ? { options: JSON.stringify(inneroptions) } : {}
|
|
242
|
+
};
|
|
243
|
+
return validatestep(inner, origin);
|
|
244
|
+
}
|
|
119
245
|
function validatestep(step, origin) {
|
|
120
246
|
if (!allowedactions.has(step.kind)) return { allowed: false, reason: "Unsupported action kind." };
|
|
121
247
|
if (!step.summary.trim()) return { allowed: false, reason: "A human-readable action summary is required." };
|
|
122
|
-
if (targetactions.has(step.kind) && !step.target?.trim()) return { allowed: false, reason: "A page target is required." };
|
|
123
|
-
if (valueactions.has(step.kind) && !step.value?.trim()) return { allowed: false, reason: "A reviewed value is required." };
|
|
124
|
-
if (step.kind === "select" && !step.value?.trim()) return { allowed: false, reason: "A reviewed option value is required." };
|
|
125
|
-
if (step.kind === "navigate" && !step.value) return { allowed: false, reason: "A navigation URL is required." };
|
|
126
248
|
let options;
|
|
127
249
|
try {
|
|
128
250
|
options = parseoptions(step);
|
|
129
251
|
} catch {
|
|
130
252
|
return { allowed: false, reason: "Step options must be a JSON object." };
|
|
131
253
|
}
|
|
254
|
+
const hastargetref = options.targetref !== void 0;
|
|
255
|
+
if (targetactions.has(step.kind) && !step.target?.trim() && !hastargetref) return { allowed: false, reason: "A page target is required." };
|
|
256
|
+
if (valueactions.has(step.kind) && !step.value?.trim()) return { allowed: false, reason: "A reviewed value is required." };
|
|
257
|
+
if (step.kind === "select" && !step.value?.trim()) return { allowed: false, reason: "A reviewed option value is required." };
|
|
258
|
+
if (step.kind === "navigate" && !step.value) return { allowed: false, reason: "A navigation URL is required." };
|
|
259
|
+
if (hastargetref) {
|
|
260
|
+
const reference = validatetargetref(options.targetref);
|
|
261
|
+
if (!reference.allowed) return reference;
|
|
262
|
+
}
|
|
132
263
|
if (step.kind === "wait") {
|
|
133
264
|
try {
|
|
134
265
|
waitduration(step);
|
|
@@ -168,6 +299,68 @@ function validatestep(step, origin) {
|
|
|
168
299
|
}
|
|
169
300
|
if ((step.kind === "scrollpage" || step.kind === "scrollby") && (!numericoption(options, "x") || !numericoption(options, "y"))) return { allowed: false, reason: "Scroll amounts must be numbers in options." };
|
|
170
301
|
if (step.kind === "waitfor" && options.timeout !== void 0 && (typeof options.timeout !== "number" || options.timeout < 0)) return { allowed: false, reason: "The waitfor timeout must be zero or a positive number of milliseconds." };
|
|
302
|
+
if (step.kind === "movepointer") {
|
|
303
|
+
const path = options.pointpath;
|
|
304
|
+
if (!path || typeof path !== "object" || Array.isArray(path)) return { allowed: false, reason: "A reviewed pointpath with start and end points is required in options." };
|
|
305
|
+
const points = path;
|
|
306
|
+
if (!ispoint(points.start) || !ispoint(points.end)) return { allowed: false, reason: "The reviewed pointpath needs numeric start and end points." };
|
|
307
|
+
if (points.waypoints !== void 0 && (!Array.isArray(points.waypoints) || !points.waypoints.every((waypoint) => ispoint(waypoint)))) return { allowed: false, reason: "The reviewed pointpath waypoints must be numeric points." };
|
|
308
|
+
if (!nonnegativeoption(points, "duration")) return { allowed: false, reason: "The reviewed pointpath duration must be zero or a positive number of milliseconds." };
|
|
309
|
+
const speed = options.speedprofile;
|
|
310
|
+
if (speed !== void 0) {
|
|
311
|
+
if (!speed || typeof speed !== "object" || Array.isArray(speed)) return { allowed: false, reason: "The reviewed speed profile must be an object." };
|
|
312
|
+
const profile = speed;
|
|
313
|
+
if (profile.easing !== void 0 && profile.easing !== "linear" && profile.easing !== "easeinout") return { allowed: false, reason: "The reviewed easing must be linear or easeinout." };
|
|
314
|
+
if (!nonnegativeoption(profile, "peak")) return { allowed: false, reason: "The reviewed peak velocity must be zero or a positive number." };
|
|
315
|
+
if (!nonnegativeoption(profile, "jitter")) return { allowed: false, reason: "The reviewed jitter window must be zero or a positive number of milliseconds." };
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (step.kind === "clickpoint" && (!hastargetref || options.targetref.mode !== "point")) return { allowed: false, reason: "A reviewed point target reference is required in options." };
|
|
319
|
+
if (step.kind === "clicktext" && (!hastargetref || options.targetref.mode !== "text")) return { allowed: false, reason: "A reviewed text target reference is required in options." };
|
|
320
|
+
if (step.kind === "clickaria" && (!hastargetref || options.targetref.mode !== "aria")) return { allowed: false, reason: "A reviewed aria target reference is required in options." };
|
|
321
|
+
if (step.kind === "clickname" && (!hastargetref || options.targetref.mode !== "name")) return { allowed: false, reason: "A reviewed name target reference is required in options." };
|
|
322
|
+
if (step.kind === "resolvexpath" && (!hastargetref || options.targetref.mode !== "xpath")) return { allowed: false, reason: "A reviewed xpath target reference is required in options." };
|
|
323
|
+
if (step.kind === "typetime" && options.delay !== void 0 && (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." };
|
|
324
|
+
if (step.kind === "submitsearch") {
|
|
325
|
+
if (!isnonempty(options.results)) return { allowed: false, reason: "A reviewed results region selector is required in options." };
|
|
326
|
+
if (options.timeout !== void 0 && (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." };
|
|
327
|
+
}
|
|
328
|
+
if (step.kind === "selectmulti") {
|
|
329
|
+
const values = options.values;
|
|
330
|
+
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." };
|
|
331
|
+
}
|
|
332
|
+
if (step.kind === "setslider") {
|
|
333
|
+
const slider = Number(step.value);
|
|
334
|
+
if (!Number.isFinite(slider)) return { allowed: false, reason: "The reviewed slider value must be a number." };
|
|
335
|
+
}
|
|
336
|
+
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." };
|
|
337
|
+
if (step.kind === "setcolor" && !/^#[0-9a-fA-F]{6}$/.test(step.value ?? "")) return { allowed: false, reason: "The reviewed color must use the #rrggbb form." };
|
|
338
|
+
if (step.kind === "keyhold" && options.holdid !== void 0 && !isnonempty(options.holdid)) return { allowed: false, reason: "The reviewed hold id must be a non-empty string." };
|
|
339
|
+
if (step.kind === "dismissdialog") {
|
|
340
|
+
const accept = options.accept;
|
|
341
|
+
const answer = options.answer;
|
|
342
|
+
if (accept === void 0 && !isnonempty(answer)) return { allowed: false, reason: "A reviewed accept flag or prompt answer is required in options." };
|
|
343
|
+
if (accept !== void 0 && typeof accept !== "boolean") return { allowed: false, reason: "The reviewed dialog accept flag must be a boolean." };
|
|
344
|
+
if (answer !== void 0 && !isnonempty(answer)) return { allowed: false, reason: "The reviewed prompt answer must be a non-empty string." };
|
|
345
|
+
}
|
|
346
|
+
if (step.kind === "pierceshadow" && options.shadow !== void 0) {
|
|
347
|
+
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." };
|
|
348
|
+
}
|
|
349
|
+
if (step.kind === "enterframe") {
|
|
350
|
+
const path = options.framepath;
|
|
351
|
+
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." };
|
|
352
|
+
return validateinnerstep(options, origin);
|
|
353
|
+
}
|
|
354
|
+
if (step.kind === "retryaction") {
|
|
355
|
+
const inner = validateinnerstep(options, origin);
|
|
356
|
+
if (!inner.allowed) return inner;
|
|
357
|
+
const rule = options.retryrule;
|
|
358
|
+
if (!rule || typeof rule !== "object" || Array.isArray(rule)) return { allowed: false, reason: "A reviewed retry rule with attempts is required in options." };
|
|
359
|
+
const retry = rule;
|
|
360
|
+
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." };
|
|
361
|
+
if (!nonnegativeoption(retry, "settle")) return { allowed: false, reason: "The reviewed retry settle window must be zero or a positive number of milliseconds." };
|
|
362
|
+
if (!nonnegativeoption(retry, "tolerance")) return { allowed: false, reason: "The reviewed retry movement tolerance must be zero or a positive number of pixels." };
|
|
363
|
+
}
|
|
171
364
|
return { allowed: true };
|
|
172
365
|
}
|
|
173
366
|
function sessiongate(input) {
|
|
@@ -183,11 +376,12 @@ function canexecute(input) {
|
|
|
183
376
|
if (!gate.allowed) return gate;
|
|
184
377
|
if (!input.plan || input.plan.state !== "approved") return { allowed: false, reason: "The plan has not received explicit approval." };
|
|
185
378
|
if (input.plan.expiresat <= now) return { allowed: false, reason: "The approved plan has expired." };
|
|
379
|
+
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." };
|
|
186
380
|
return validatestep(input.step, input.origin);
|
|
187
381
|
}
|
|
188
382
|
|
|
189
383
|
// version.ts
|
|
190
|
-
var packageversion = "1.1.
|
|
384
|
+
var packageversion = "1.1.33";
|
|
191
385
|
|
|
192
386
|
// types.ts
|
|
193
387
|
var protocolversion = packageversion;
|
|
@@ -223,6 +417,11 @@ function parseproposal(value, origin) {
|
|
|
223
417
|
if (!evaluation.allowed) throw new Error(evaluation.reason);
|
|
224
418
|
return step;
|
|
225
419
|
});
|
|
420
|
+
for (const step of steps) {
|
|
421
|
+
if (step.kind !== "retryaction" && step.kind !== "enterframe") continue;
|
|
422
|
+
const options = parseoptions(step);
|
|
423
|
+
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.");
|
|
424
|
+
}
|
|
226
425
|
const createdat = Date.now();
|
|
227
426
|
const expiresat = typeof planinput.expiresat === "number" ? planinput.expiresat : createdat + 10 * 60 * 1e3;
|
|
228
427
|
const plan = {
|
|
@@ -241,19 +440,29 @@ function requestbody(input) {
|
|
|
241
440
|
return JSON.stringify({ version: protocolversion, objective: input.objective, session: input.session, observation: input.observation, capabilities: input.capabilities });
|
|
242
441
|
}
|
|
243
442
|
function outcomeresponse(input) {
|
|
244
|
-
return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, outcome: input.outcome });
|
|
443
|
+
return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, outcome: input.outcome, ...input.resolvedtarget ? { resolvedtarget: input.resolvedtarget } : {} });
|
|
444
|
+
}
|
|
445
|
+
function mapresponse(input) {
|
|
446
|
+
return JSON.stringify({ version: protocolversion, planid: input.plan.id, planstate: input.plan.state, map: input.map });
|
|
447
|
+
}
|
|
448
|
+
function heldkeysreport(input) {
|
|
449
|
+
return { version: protocolversion, tabid: input.tabid, heldkeys: input.holds };
|
|
245
450
|
}
|
|
246
451
|
export {
|
|
247
452
|
canexecute,
|
|
248
453
|
actionrisk as deriveactionrisk,
|
|
454
|
+
heldkeysreport,
|
|
249
455
|
hostpattern,
|
|
456
|
+
mapresponse,
|
|
250
457
|
normalizeendpoint,
|
|
251
458
|
outcomeresponse,
|
|
252
459
|
parseproposal,
|
|
253
460
|
protocolversion,
|
|
254
461
|
randomid,
|
|
255
462
|
requestbody,
|
|
463
|
+
resolutionverdict,
|
|
256
464
|
sessionmemory,
|
|
257
|
-
validatestep
|
|
465
|
+
validatestep,
|
|
466
|
+
validatetargetref
|
|
258
467
|
};
|
|
259
468
|
//# sourceMappingURL=index.js.map
|
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: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,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;",
|
|
4
|
+
"sourcesContent": ["import type { agentplan, agentsession, auditevent, capabilityreport, clickablemap, dialogdecision, dialogpolicy, diagnosticreport, endpointconfig, keyholdstate, planprogress, resolutionsummary, retryoutcome, 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\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\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\", \"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\"]);\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\", \"shiftclick\", \"typetime\", \"appendtext\", \"setvalue\", \"typeedit\", \"submitsearch\", \"selectmulti\", \"chooseradio\", \"setslider\", \"setdate\", \"setcolor\", \"expanddetails\", \"verifyvisible\", \"verifyenabled\", \"pierceshadow\"]);\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/** 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 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 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.33\" 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\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\";\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\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", "import { actionrisk, parseoptions, validatestep } from \"./policy.js\";\nimport { protocolversion, type agentplan, type clickablemap, type keyholdstate, type planproposal, type proposalrequest, type resolvedtarget, 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 *\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"],
|
|
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;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;AAAE,WAAO,KAAK,QAAQ,IAAI,WAAW,KAAK;AAAA,EAAG;AAAA,EAClG,MAAM,UAA0C;AAAE,WAAO,KAAK,QAAQ,IAAe,MAAM;AAAA,EAAG;AAAA,EAC9F,MAAM,QAAQ,OAAiC;AAAE,WAAO,KAAK,QAAQ,IAAI,QAAQ,KAAK;AAAA,EAAG;AAAA,EACzF,MAAM,gBAAuD;AAAE,WAAO,KAAK,QAAQ,IAAsB,YAAY;AAAA,EAAG;AAAA,EACxH,MAAM,cAAc,OAAwC;AAAE,WAAO,KAAK,QAAQ,IAAI,cAAc,KAAK;AAAA,EAAG;AAAA,EAC5G,MAAM,cAAiD;AAAE,WAAO,KAAK,QAAQ,IAAkB,UAAU;AAAA,EAAG;AAAA,EAC5G,MAAM,YAAY,OAAoC;AAAE,WAAO,KA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