@wudao-org/browser 0.0.0-stage → 0.4.21
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/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/download.d.ts +61 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +217 -0
- package/dist/download.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/port.d.ts +141 -0
- package/dist/port.d.ts.map +1 -0
- package/dist/port.js +145 -0
- package/dist/port.js.map +1 -0
- package/dist/runtime.d.ts +92 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +188 -0
- package/dist/runtime.js.map +1 -0
- package/dist/snapshot.d.ts +58 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +121 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/tools.d.ts +29 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +678 -0
- package/dist/tools.js.map +1 -0
- package/package.json +33 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { SnapshotRefEntry } from "./runtime.js";
|
|
2
|
+
/** Hard output budget for the model-facing snapshot (maxResultSizeChars
|
|
3
|
+
* spirit: bounded context, honest truncation note over silent loss). */
|
|
4
|
+
export declare const MAX_SNAPSHOT_CHARS = 12000;
|
|
5
|
+
/** ω99-136 — an element's viewport rect in CSS PIXELS (getBoundingClientRect).
|
|
6
|
+
* Screenshot bytes (port.ts) are DEVICE pixels (CSS × devicePixelRatio): this
|
|
7
|
+
* arc reports both spaces honestly and does NOT convert — the single
|
|
8
|
+
* canonical coordinate layer is the next arc. */
|
|
9
|
+
export interface ElementBbox {
|
|
10
|
+
readonly x: number;
|
|
11
|
+
readonly y: number;
|
|
12
|
+
readonly width: number;
|
|
13
|
+
readonly height: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CollectedElement {
|
|
16
|
+
readonly ref: string;
|
|
17
|
+
readonly tag: string;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly href?: string;
|
|
20
|
+
readonly value?: string;
|
|
21
|
+
readonly placeholder?: string;
|
|
22
|
+
readonly type?: string;
|
|
23
|
+
readonly checked?: boolean;
|
|
24
|
+
readonly disabled?: boolean;
|
|
25
|
+
/** ω99-136: optional so OLD collected payloads (pre-vision snapshots) stay
|
|
26
|
+
* shape-compatible — absence means "geometry not collected", never 0,0. */
|
|
27
|
+
readonly bbox?: ElementBbox;
|
|
28
|
+
}
|
|
29
|
+
export interface CollectedPage {
|
|
30
|
+
readonly url: string;
|
|
31
|
+
readonly title: string;
|
|
32
|
+
readonly text: string;
|
|
33
|
+
readonly elements: readonly CollectedElement[];
|
|
34
|
+
}
|
|
35
|
+
/** The snapshot collector — a plain-ES EXPRESSION (an IIFE) the default port
|
|
36
|
+
* hands to page.evaluate. Deterministic, no external state: previous refs
|
|
37
|
+
* are wiped, visibility is geometry+style, the list caps at 200 elements. */
|
|
38
|
+
export declare const COLLECT_SCRIPT = "(() => {\n const clean = (s, n) => { const t = String(s == null ? \"\" : s).replace(/\\s+/g, \" \").trim(); return t.length > n ? t.slice(0, n) + \"\u2026\" : t; };\n document.querySelectorAll(\"[data-wudao-ref]\").forEach((el) => el.removeAttribute(\"data-wudao-ref\"));\n const visible = (el) => {\n const r = el.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0) return false;\n const s = getComputedStyle(el);\n return s.visibility !== \"hidden\" && s.display !== \"none\";\n };\n const sel = 'a, button, input, select, textarea, summary, [role=\"button\"], [role=\"link\"], [role=\"tab\"], [role=\"checkbox\"], [onclick]';\n const els = Array.from(document.querySelectorAll(sel)).filter(visible).slice(0, 200);\n const elements = els.map((el, i) => {\n const ref = \"e\" + (i + 1);\n el.setAttribute(\"data-wudao-ref\", ref);\n const out = { ref: ref, tag: el.tagName.toLowerCase(), text: clean(el.getAttribute(\"aria-label\") || el.textContent || el.value || \"\", 80) };\n // \u03C999-136: CSS-pixel viewport rect for the vision lane (see ElementBbox);\n // raw doubles, no rounding \u2014 coordinate-space decisions belong to the next arc.\n const r = el.getBoundingClientRect();\n out.bbox = { x: r.x, y: r.y, width: r.width, height: r.height };\n const href = el.getAttribute(\"href\");\n if (el.tagName === \"A\" && href) out.href = clean(href, 100);\n if (el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\" || el.tagName === \"SELECT\") {\n if (el.getAttribute(\"type\")) out.type = el.getAttribute(\"type\");\n if (el.getAttribute(\"placeholder\")) out.placeholder = clean(el.getAttribute(\"placeholder\"), 60);\n if (el.value !== undefined && el.value !== \"\") out.value = clean(el.value, 60);\n if (el.type === \"checkbox\" || el.type === \"radio\") out.checked = !!el.checked;\n }\n if (el.disabled) out.disabled = true;\n return out;\n });\n const text = document.body ? document.body.innerText : \"\";\n return { url: location.href, title: document.title, text: text.slice(0, 20000), elements: elements };\n})()";
|
|
39
|
+
export declare const refSelector: (ref: string) => string;
|
|
40
|
+
/** Tool-input validation: refs are exactly e<positive-digits>. */
|
|
41
|
+
export declare function validRef(ref: string): boolean;
|
|
42
|
+
/** One element line: `- e1 [a] "Guide" → /guide` (+input/value facets).
|
|
43
|
+
* ω99-136: a collected bbox appends `@[x,y,w,h]` (CSS px) so the vision lane
|
|
44
|
+
* can correlate refs with pixels; the four numbers ride INSIDE the line, so
|
|
45
|
+
* their chars are spent from the same 12k budget — over budget shrinks the
|
|
46
|
+
* element list (fit check #3), never the discipline. */
|
|
47
|
+
export declare function elementLine(e: CollectedElement): string;
|
|
48
|
+
/** Pure: the model-facing snapshot text + the ref→selector map, under the
|
|
49
|
+
* hard budget. Priority when truncating: keep EVERY element line (the refs
|
|
50
|
+
* are the actionable surface) and cut the page text first; if the element
|
|
51
|
+
* list alone still exceeds the budget, cut lines and say so. The refs map
|
|
52
|
+
* only ever contains refs whose line SURVIVED — a ref the model cannot see
|
|
53
|
+
* is a stale promise we refuse to hand out. */
|
|
54
|
+
export declare function formatSnapshot(p: CollectedPage): {
|
|
55
|
+
text: string;
|
|
56
|
+
refs: Map<string, SnapshotRefEntry>;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;yEACyE;AACzE,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC;;;kDAGkD;AAClD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B;gFAC4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAChD;AAED;;8EAE8E;AAC9E,eAAO,MAAM,cAAc,olEAgCtB,CAAC;AAEN,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAAqC,CAAC;AAEhF,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7C;AAID;;;;yDAIyD;AACzD,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAYvD;AAED;;;;;gDAKgD;AAChD,wBAAgB,cAAc,CAAC,CAAC,EAAE,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;CAAE,CAyCtG"}
|
package/dist/snapshot.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/** Hard output budget for the model-facing snapshot (maxResultSizeChars
|
|
2
|
+
* spirit: bounded context, honest truncation note over silent loss). */
|
|
3
|
+
export const MAX_SNAPSHOT_CHARS = 12_000;
|
|
4
|
+
/** The snapshot collector — a plain-ES EXPRESSION (an IIFE) the default port
|
|
5
|
+
* hands to page.evaluate. Deterministic, no external state: previous refs
|
|
6
|
+
* are wiped, visibility is geometry+style, the list caps at 200 elements. */
|
|
7
|
+
export const COLLECT_SCRIPT = `(() => {
|
|
8
|
+
const clean = (s, n) => { const t = String(s == null ? "" : s).replace(/\\s+/g, " ").trim(); return t.length > n ? t.slice(0, n) + "…" : t; };
|
|
9
|
+
document.querySelectorAll("[data-wudao-ref]").forEach((el) => el.removeAttribute("data-wudao-ref"));
|
|
10
|
+
const visible = (el) => {
|
|
11
|
+
const r = el.getBoundingClientRect();
|
|
12
|
+
if (r.width <= 0 || r.height <= 0) return false;
|
|
13
|
+
const s = getComputedStyle(el);
|
|
14
|
+
return s.visibility !== "hidden" && s.display !== "none";
|
|
15
|
+
};
|
|
16
|
+
const sel = 'a, button, input, select, textarea, summary, [role="button"], [role="link"], [role="tab"], [role="checkbox"], [onclick]';
|
|
17
|
+
const els = Array.from(document.querySelectorAll(sel)).filter(visible).slice(0, 200);
|
|
18
|
+
const elements = els.map((el, i) => {
|
|
19
|
+
const ref = "e" + (i + 1);
|
|
20
|
+
el.setAttribute("data-wudao-ref", ref);
|
|
21
|
+
const out = { ref: ref, tag: el.tagName.toLowerCase(), text: clean(el.getAttribute("aria-label") || el.textContent || el.value || "", 80) };
|
|
22
|
+
// ω99-136: CSS-pixel viewport rect for the vision lane (see ElementBbox);
|
|
23
|
+
// raw doubles, no rounding — coordinate-space decisions belong to the next arc.
|
|
24
|
+
const r = el.getBoundingClientRect();
|
|
25
|
+
out.bbox = { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
26
|
+
const href = el.getAttribute("href");
|
|
27
|
+
if (el.tagName === "A" && href) out.href = clean(href, 100);
|
|
28
|
+
if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
|
|
29
|
+
if (el.getAttribute("type")) out.type = el.getAttribute("type");
|
|
30
|
+
if (el.getAttribute("placeholder")) out.placeholder = clean(el.getAttribute("placeholder"), 60);
|
|
31
|
+
if (el.value !== undefined && el.value !== "") out.value = clean(el.value, 60);
|
|
32
|
+
if (el.type === "checkbox" || el.type === "radio") out.checked = !!el.checked;
|
|
33
|
+
}
|
|
34
|
+
if (el.disabled) out.disabled = true;
|
|
35
|
+
return out;
|
|
36
|
+
});
|
|
37
|
+
const text = document.body ? document.body.innerText : "";
|
|
38
|
+
return { url: location.href, title: document.title, text: text.slice(0, 20000), elements: elements };
|
|
39
|
+
})()`;
|
|
40
|
+
export const refSelector = (ref) => `[data-wudao-ref="${ref}"]`;
|
|
41
|
+
/** Tool-input validation: refs are exactly e<positive-digits>. */
|
|
42
|
+
export function validRef(ref) {
|
|
43
|
+
return /^e[1-9][0-9]{0,4}$/.test(ref);
|
|
44
|
+
}
|
|
45
|
+
const TRUNCATION_NOTE = "\n[snapshot truncated at the char budget — run browser_snapshot again after scrolling to see more]";
|
|
46
|
+
/** One element line: `- e1 [a] "Guide" → /guide` (+input/value facets).
|
|
47
|
+
* ω99-136: a collected bbox appends `@[x,y,w,h]` (CSS px) so the vision lane
|
|
48
|
+
* can correlate refs with pixels; the four numbers ride INSIDE the line, so
|
|
49
|
+
* their chars are spent from the same 12k budget — over budget shrinks the
|
|
50
|
+
* element list (fit check #3), never the discipline. */
|
|
51
|
+
export function elementLine(e) {
|
|
52
|
+
const parts = [`- ${e.ref} [${e.tag}`];
|
|
53
|
+
if (e.type !== undefined)
|
|
54
|
+
parts.push(`type=${e.type}`);
|
|
55
|
+
if (e.placeholder !== undefined)
|
|
56
|
+
parts.push(`placeholder="${e.placeholder}"`);
|
|
57
|
+
if (e.checked !== undefined)
|
|
58
|
+
parts.push(e.checked ? "checked" : "unchecked");
|
|
59
|
+
let line = parts.join(" ") + "]";
|
|
60
|
+
if (e.text !== "")
|
|
61
|
+
line += ` "${e.text}"`;
|
|
62
|
+
if (e.value !== undefined)
|
|
63
|
+
line += ` (value: ${e.value})`;
|
|
64
|
+
if (e.href !== undefined)
|
|
65
|
+
line += ` → ${e.href}`;
|
|
66
|
+
if (e.bbox !== undefined)
|
|
67
|
+
line += ` @[${e.bbox.x},${e.bbox.y},${e.bbox.width},${e.bbox.height}]`;
|
|
68
|
+
if (e.disabled === true)
|
|
69
|
+
line += " [disabled]";
|
|
70
|
+
return line;
|
|
71
|
+
}
|
|
72
|
+
/** Pure: the model-facing snapshot text + the ref→selector map, under the
|
|
73
|
+
* hard budget. Priority when truncating: keep EVERY element line (the refs
|
|
74
|
+
* are the actionable surface) and cut the page text first; if the element
|
|
75
|
+
* list alone still exceeds the budget, cut lines and say so. The refs map
|
|
76
|
+
* only ever contains refs whose line SURVIVED — a ref the model cannot see
|
|
77
|
+
* is a stale promise we refuse to hand out. */
|
|
78
|
+
export function formatSnapshot(p) {
|
|
79
|
+
const header = `# ${p.title}\n${p.url}\n`;
|
|
80
|
+
const emptyNote = p.elements.length === 0 ? "no clickable elements on this page\n" : "";
|
|
81
|
+
const elementLines = p.elements.map(elementLine);
|
|
82
|
+
const listHead = "\n# Clickable elements (address by ref from browser_snapshot)\n";
|
|
83
|
+
const refMapFor = (lines, els) => {
|
|
84
|
+
const shown = new Set(lines.map((l) => /^- (e[1-9][0-9]{0,4}) /.exec(l)?.[1]).filter((x) => x !== undefined));
|
|
85
|
+
const m = new Map();
|
|
86
|
+
for (const e of els) {
|
|
87
|
+
if (shown.has(e.ref)) {
|
|
88
|
+
// ω99-114: carry the type facet so tools.ts can refuse typing into
|
|
89
|
+
// password fields (unknown type stays absent — never guessed).
|
|
90
|
+
// ω99-139: carry the bbox too (browser_click_xy's hit-test source;
|
|
91
|
+
// absent stays absent — never guessed).
|
|
92
|
+
m.set(e.ref, { selector: refSelector(e.ref), desc: `${e.tag} "${e.text}"`, ...(e.type !== undefined ? { type: e.type } : {}), ...(e.bbox !== undefined ? { bbox: e.bbox } : {}) });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return m;
|
|
96
|
+
};
|
|
97
|
+
// Fit check #1: everything fits — done.
|
|
98
|
+
const full = `${header}\n# Page outline\n${p.text}\n${listHead}${elementLines.join("\n")}\n${emptyNote}`.replace(/\n{3,}/g, "\n\n");
|
|
99
|
+
if (full.length <= MAX_SNAPSHOT_CHARS) {
|
|
100
|
+
return { text: full, refs: refMapFor(elementLines, p.elements) };
|
|
101
|
+
}
|
|
102
|
+
// Fit check #2: keep all element lines, cut the page text.
|
|
103
|
+
const listBlock = `${listHead}${elementLines.join("\n")}\n`;
|
|
104
|
+
const textBudget = MAX_SNAPSHOT_CHARS - header.length - listBlock.length - TRUNCATION_NOTE.length - 16;
|
|
105
|
+
if (textBudget > 200) {
|
|
106
|
+
const text = `${header}\n# Page outline\n${p.text.slice(0, textBudget)}…\n${listBlock}${TRUNCATION_NOTE}`;
|
|
107
|
+
return { text, refs: refMapFor(elementLines, p.elements) };
|
|
108
|
+
}
|
|
109
|
+
// Fit check #3: the element list alone is over budget — cut lines.
|
|
110
|
+
const kept = [];
|
|
111
|
+
let used = header.length + listHead.length + 24 /* outline remnant */;
|
|
112
|
+
for (const line of elementLines) {
|
|
113
|
+
if (used + line.length + 1 > MAX_SNAPSHOT_CHARS - TRUNCATION_NOTE.length)
|
|
114
|
+
break;
|
|
115
|
+
kept.push(line);
|
|
116
|
+
used += line.length + 1;
|
|
117
|
+
}
|
|
118
|
+
const text = `${header}\n# Page outline\n${p.text.slice(0, Math.max(0, MAX_SNAPSHOT_CHARS - used - listHead.length - TRUNCATION_NOTE.length - 8))}…\n${listHead}${kept.join("\n")}${TRUNCATION_NOTE}`;
|
|
119
|
+
return { text, refs: refMapFor(kept, p.elements) };
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAWA;yEACyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAmCzC;;8EAE8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCzB,CAAC;AAEN,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,oBAAoB,GAAG,IAAI,CAAC;AAEhF,kEAAkE;AAClE,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,OAAO,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,eAAe,GAAG,oGAAoG,CAAC;AAE7H;;;;yDAIyD;AACzD,MAAM,UAAU,WAAW,CAAC,CAAmB;IAC7C,MAAM,KAAK,GAAa,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,G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AAI,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,kBAAkB,GAAG,eAAe,CAAC,MAAM;YAAE,MAAM;QAChF,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,MAAM,qBAAqB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,eAAe,EAAE,CAAC;IACtM,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AACrD,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ImageBlock, Tool } from "@wudao-org/core";
|
|
2
|
+
import type { BrowserRuntime } from "./runtime.js";
|
|
3
|
+
/** What the sink learns about the captured PNG (its IHDR dimensions — the
|
|
4
|
+
* CSS-pixel viewport when browser_see captures at scale:"css"). */
|
|
5
|
+
export interface BrowserImageSinkMeta {
|
|
6
|
+
readonly widthPx: number;
|
|
7
|
+
readonly heightPx: number;
|
|
8
|
+
}
|
|
9
|
+
/** Receives the PNG bytes, returns the durable ImageBlock they became.
|
|
10
|
+
* Returning undefined = honest no-image THIS call (the caller's modality
|
|
11
|
+
* pre-check declined — browser_see degrades to its text table); throwing =
|
|
12
|
+
* an honest error result (a failed screenshot is never silently empty). */
|
|
13
|
+
export type BrowserImageSink = (png: Uint8Array, meta: BrowserImageSinkMeta) => Promise<ImageBlock | undefined>;
|
|
14
|
+
/** The eleven tools, in their FIXED registration order (the CLI inserts them
|
|
15
|
+
* at one fixed position; this order inside the group never changes).
|
|
16
|
+
* ω99-138: `imageSink` is optional — absent (or undefined-returning) keeps
|
|
17
|
+
* browser_see on its honest text-table degradation; the six 112 tools are
|
|
18
|
+
* untouched by it either way.
|
|
19
|
+
* ω99-139: browser_click_xy sits right after browser_click (the click pair),
|
|
20
|
+
* arming "point at pixels → click" for canvas pages browser_see unveiled.
|
|
21
|
+
* ω99-140: browser_type_xy sits right after browser_type (the type pair) —
|
|
22
|
+
* the same pairing logic, isomorphic: "point at pixels → type".
|
|
23
|
+
* ω99-141: browser_scroll_xy sits right after browser_scroll (the scroll
|
|
24
|
+
* pair) — "point at pixels → scroll the container under them".
|
|
25
|
+
* ω99-142: browser_downloads sits right after browser_scroll_xy, before
|
|
26
|
+
* browser_close — the export flow's last mile (see the file the page
|
|
27
|
+
* saved), zero parameters by design. */
|
|
28
|
+
export declare function browserToolsFor(runtime: BrowserRuntime, imageSink?: BrowserImageSink): Tool[];
|
|
29
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAc,MAAM,iBAAiB,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAsC,MAAM,cAAc,CAAC;AAcvF;oEACoE;AACpE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;4EAG4E;AAC5E,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;AAmIhH;;;;;;;;;;;;;yCAayC;AACzC,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,EAAE,CAwgB7F"}
|