@orkestrel/browser 0.0.21 → 0.0.23
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 +7 -4
- package/dist/bin/main.js +12 -3
- package/dist/bin/main.js.map +1 -1
- package/dist/src/browser/index.d.ts +77 -19
- package/dist/src/browser/index.js +361 -21
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +957 -174
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +356 -78
- package/dist/src/core/index.d.ts +356 -78
- package/dist/src/core/index.js +951 -176
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +540 -92
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +127 -18
- package/dist/src/server/index.d.ts +127 -18
- package/dist/src/server/index.js +529 -96
- package/dist/src/server/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -25,8 +25,8 @@ export declare const BASE64_LOOKUP: Readonly<Record<string, number>>;
|
|
|
25
25
|
* units, one fewer when the last would split a surrogate pair (so a limit of 1 before a pair keeps
|
|
26
26
|
* nothing), followed by `\n[characters 0–END of TOTAL; FOOTER]`. The footer has no default, so
|
|
27
27
|
* every caller states what the cut result's reader does next: the toolset passes
|
|
28
|
-
* `BROWSER_TOOL_VIEW_FOOTER` for
|
|
29
|
-
* any other.
|
|
28
|
+
* `BROWSER_TOOL_VIEW_FOOTER` for an action or `dialog` receipt that carries a view and
|
|
29
|
+
* `BROWSER_TOOL_CUT_FOOTER` for any other result, including `look` and `read` results.
|
|
30
30
|
*
|
|
31
31
|
* @param text - The page-authored or composed string
|
|
32
32
|
* @param limit - The most characters kept before the footer, a positive integer
|
|
@@ -68,6 +68,9 @@ export declare const BROWSER_CODEGEN_BINDING_NAME = "__orkestrelBrowserCodegen";
|
|
|
68
68
|
*/
|
|
69
69
|
export declare const BROWSER_CODEGEN_SOURCE = "(() => {\n\tconst binding = '__orkestrelBrowserCodegen'\n\twindow[binding + '__state']?.controller.abort()\n\tconst state = { controller: new AbortController(), nodes: [], indices: new WeakMap() }\n\twindow[binding + '__state'] = state\n\tfor (const event of ['click', 'input', 'change', 'keydown', 'focusout', 'submit', 'contextmenu', 'drop']) {\n\t\tdocument.addEventListener(event, (event) => {\n\t\t\tif (!event.isTrusted || typeof window[binding] !== 'function') return\n\t\t\tif (event.type === 'keydown' && event.key !== 'Enter') return\n\t\t\tconst element = event.composedPath()[0]\n\t\t\tif (!(element instanceof Element)) return\n\t\t\tlet index = state.indices.get(element)\n\t\t\tif (index === undefined) {\n\t\t\t\tindex = state.nodes.push(element) - 1\n\t\t\t\tstate.indices.set(element, index)\n\t\t\t}\n\t\t\tconst control = element.tagName === 'SELECT' ? (element.multiple ? 'multiple' : 'select')\n\t\t\t\t: element.tagName === 'OPTION' ? 'option'\n\t\t\t\t: element.tagName === 'INPUT' && element.type === 'password' ? 'password'\n\t\t\t\t: element.tagName === 'TEXTAREA' || element.isContentEditable ||\n\t\t\t\t\t(element.tagName === 'INPUT' && ['text', 'search', 'url', 'tel', 'email', 'number'].includes(element.type)) ? 'text' : 'other'\n\t\t\tconst payload = { event: event.type, index, top: window === window.top && element.ownerDocument === document, control, form: !!element.form }\n\t\t\tif (event.type === 'click') payload.detail = event.detail\n\t\t\tif (event.type === 'keydown') payload.key = 'Enter'\n\t\t\tif (event.type === 'input' && control === 'password') payload.secret = true\n\t\t\tif (event.type === 'input' && control === 'text') payload.value = element.isContentEditable ? element.textContent || '' : element.value\n\t\t\tif (event.type === 'change' && control === 'select') {\n\t\t\t\tpayload.value = element.value\n\t\t\t\tpayload.roundtrip = Array.from(element.options).find(option => option.value === element.value) === element.selectedOptions[0]\n\t\t\t}\n\t\t\tif (element.getRootNode() !== document) {\n\t\t\t\tpayload.event = 'unsupported'\n\t\t\t\tpayload.gap = 'the element is in a shadow root'\n\t\t\t} else if (event.type === 'contextmenu' || event.type === 'drop' || (event.type === 'click' && (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) && !['select', 'multiple', 'option'].includes(control))) {\n\t\t\t\tpayload.event = 'unsupported'\n\t\t\t\tpayload.gap = 'an unsupported gesture'\n\t\t\t}\n\t\t\twindow[binding](JSON.stringify(payload.event === 'unsupported' ? { event: payload.event, index, top: payload.top, control, form: payload.form, gap: payload.gap } : payload))\n\t\t}, { capture: true, signal: state.controller.signal })\n\t}\n})()";
|
|
70
70
|
|
|
71
|
+
/** Matches protocol errors caused by replacement or closure of an execution context. */
|
|
72
|
+
export declare const BROWSER_CONTEXT_LOSS_PATTERN: RegExp;
|
|
73
|
+
|
|
71
74
|
/**
|
|
72
75
|
* Sets the default timeout for browser connection, requests, and navigation, `30_000`
|
|
73
76
|
* milliseconds.
|
|
@@ -104,7 +107,7 @@ export declare const BROWSER_FRAME_WORLD_NAME = "__orkestrelBrowserFrame";
|
|
|
104
107
|
*/
|
|
105
108
|
export declare const BROWSER_HAR_CREATOR: Readonly<{
|
|
106
109
|
name: "@orkestrel/browser";
|
|
107
|
-
version: "0.0.
|
|
110
|
+
version: "0.0.23";
|
|
108
111
|
}>;
|
|
109
112
|
|
|
110
113
|
/** Names accessibility roles that receive actionable outline references. */
|
|
@@ -249,6 +252,16 @@ export declare const BROWSER_SCHEMES: readonly string[];
|
|
|
249
252
|
/** Names the attribute that tags temporary screenshot styles and masks. */
|
|
250
253
|
export declare const BROWSER_SCREENSHOT_ATTRIBUTE = "data-orkestrel-screenshot";
|
|
251
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Matches one word of an outline search and of a row's role and name: a run of at least 3 letters
|
|
257
|
+
* or digits.
|
|
258
|
+
*
|
|
259
|
+
* @remarks
|
|
260
|
+
* The 3-character floor drops words such as `a`, `to`, and `of`, which would otherwise score a row
|
|
261
|
+
* whose name shares them with the search.
|
|
262
|
+
*/
|
|
263
|
+
export declare const BROWSER_SEARCH_PATTERN: RegExp;
|
|
264
|
+
|
|
252
265
|
/**
|
|
253
266
|
* Sets the default maximum node count accepted from a decoded CDP DOM snapshot, `100_000`.
|
|
254
267
|
*/
|
|
@@ -297,20 +310,21 @@ export declare const BROWSER_TOOL_CHANGED_NOTE = "(The page changed before the v
|
|
|
297
310
|
*
|
|
298
311
|
* @remarks
|
|
299
312
|
* Every tool description is at most 25 words and says what the tool shows or does, and for
|
|
300
|
-
* `look` and `
|
|
313
|
+
* `look`, `read`, and `plain` when to call it; every parameter description is at most 100 characters.
|
|
301
314
|
* Every tool declares at least one required parameter, because the streamed tool-call parser of
|
|
302
|
-
* Ollama 0.34.4 rejects a call to a tool that declares no parameter. `look`
|
|
303
|
-
*
|
|
304
|
-
*
|
|
315
|
+
* Ollama 0.34.4 rejects a call to a tool that declares no parameter. `look`, `read`, and `plain` take
|
|
316
|
+
* `search` and `offset`; an element's own reading is `BrowserElementInterface.read`.
|
|
317
|
+
* `look`, `read`, `plain`, and `journeys` annotate `pure` and
|
|
305
318
|
* `untrusted`, `wait` and `tabs` annotate `pure`, and the rest carry no annotation. `type` takes
|
|
306
319
|
* `secret` beside `ref`, `text`, and `submit`. The journey tools `record`, `save`, `journeys`,
|
|
307
320
|
* `edit`, and `replay` are advertised only by a toolset constructed with `journeys`.
|
|
321
|
+
* `wait` takes `absent` beside `text` and `timeout`.
|
|
308
322
|
*/
|
|
309
323
|
export declare const BROWSER_TOOL_COPY: Readonly<Record<BrowserToolName, ToolDefinition>>;
|
|
310
324
|
|
|
311
325
|
/**
|
|
312
|
-
* Holds the clause that ends the footer of a cut result
|
|
313
|
-
*
|
|
326
|
+
* Holds the clause that ends the footer of a cut result other than an action or `dialog` receipt
|
|
327
|
+
* that carries a view, including `look` and `read` results.
|
|
314
328
|
*/
|
|
315
329
|
export declare const BROWSER_TOOL_CUT_FOOTER = "the rest was cut";
|
|
316
330
|
|
|
@@ -351,7 +365,7 @@ export declare const BROWSER_TOOL_LIMIT = 4000;
|
|
|
351
365
|
export declare const BROWSER_TOOL_NAME_PATTERN: RegExp;
|
|
352
366
|
|
|
353
367
|
/**
|
|
354
|
-
* Names every tool the browser toolset reserves: `look`, `read`, `click`, `type`, `press`,
|
|
368
|
+
* Names every tool the browser toolset reserves: `look`, `read`, `plain`, `click`, `type`, `press`,
|
|
355
369
|
* `navigate`, `wait`, `dialog`, `tabs`, and `switch`.
|
|
356
370
|
*/
|
|
357
371
|
export declare const BROWSER_TOOL_NAMES: readonly BrowserToolName[];
|
|
@@ -374,10 +388,10 @@ export declare const BROWSER_TOOL_TIMEOUT_LIMIT_MS = 30000;
|
|
|
374
388
|
export declare const BROWSER_TOOL_TIMEOUT_MS = 5000;
|
|
375
389
|
|
|
376
390
|
/**
|
|
377
|
-
* Holds the clause that ends the footer of a cut
|
|
378
|
-
*
|
|
391
|
+
* Holds the clause that ends the footer of a cut action or `dialog` receipt that carries a view,
|
|
392
|
+
* and names `look` as the call that finds an element the cut view leaves out.
|
|
379
393
|
*/
|
|
380
|
-
export declare const BROWSER_TOOL_VIEW_FOOTER = "the rest was cut; call
|
|
394
|
+
export declare const BROWSER_TOOL_VIEW_FOOTER = "the rest was cut; call look with words to find";
|
|
381
395
|
|
|
382
396
|
/**
|
|
383
397
|
* Names the accessibility roles the `type` tool writes to: `textbox`, `searchbox`, and
|
|
@@ -392,6 +406,15 @@ export declare const BROWSER_TOOL_VIEW_FOOTER = "the rest was cut; call read for
|
|
|
392
406
|
*/
|
|
393
407
|
export declare const BROWSER_TYPED_ROLES: ReadonlySet<string>;
|
|
394
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Names the finished transitions and animations that wake a parked wait.
|
|
411
|
+
*
|
|
412
|
+
* @remarks
|
|
413
|
+
* Chromium 154.0.4258.53 delivers these events in main and isolated worlds after a
|
|
414
|
+
* visibility or discrete display exit. Opacity alone leaves text in `innerText`.
|
|
415
|
+
*/
|
|
416
|
+
export declare const BROWSER_WAIT_EVENTS: readonly string[];
|
|
417
|
+
|
|
395
418
|
/**
|
|
396
419
|
* Captures Chromium Accessibility-domain snapshots for one page.
|
|
397
420
|
*
|
|
@@ -763,6 +786,8 @@ export declare interface BrowserContextInterface {
|
|
|
763
786
|
* - `emulation` — emulation overrides inherited by every page of the context
|
|
764
787
|
*/
|
|
765
788
|
export declare interface BrowserContextOptions {
|
|
789
|
+
/** Names each element reference the context's pages issue. Default: a counter the context owns. */
|
|
790
|
+
readonly reference?: BrowserReferenceFunction;
|
|
766
791
|
readonly on?: EmitterHooks<BrowserContextEventMap>;
|
|
767
792
|
readonly error?: EmitterErrorHandler;
|
|
768
793
|
readonly proxy?: BrowserProxy;
|
|
@@ -1109,8 +1134,9 @@ export declare interface BrowserElementInterface {
|
|
|
1109
1134
|
/** Moves focus to the element. */
|
|
1110
1135
|
focus(options?: BrowserCallOptions): Promise<void>;
|
|
1111
1136
|
/**
|
|
1112
|
-
* Captures the element's markup with its document's URL and title as a reading whose
|
|
1113
|
-
* tracks later navigations of that document
|
|
1137
|
+
* Captures the element's rendered markup with its document's URL and title as a reading whose
|
|
1138
|
+
* `stale` flag tracks later navigations of that document; {@link BrowserReadingInput} defines
|
|
1139
|
+
* the rendered markup.
|
|
1114
1140
|
*/
|
|
1115
1141
|
read(options?: BrowserCallOptions): Promise<BrowserReadingInterface>;
|
|
1116
1142
|
/**
|
|
@@ -1141,7 +1167,7 @@ export declare class BrowserElementManager implements BrowserElementManagerInter
|
|
|
1141
1167
|
outline(options?: BrowserOutlineOptions): Promise<BrowserOutline>;
|
|
1142
1168
|
/** A CSS query searches the page's main-frame document; use the accessibility outline for in-process child documents. */
|
|
1143
1169
|
find(query: BrowserElementQuery, options?: BrowserCallOptions): Promise<readonly BrowserPageElementInterface[]>;
|
|
1144
|
-
wait(query: BrowserElementQuery, options?:
|
|
1170
|
+
wait(query: BrowserElementQuery, options?: BrowserWaitOptions): Promise<readonly BrowserPageElementInterface[]>;
|
|
1145
1171
|
element(reference: string): BrowserPageElementInterface | undefined;
|
|
1146
1172
|
elements(): readonly BrowserPageElementInterface[];
|
|
1147
1173
|
clear(): void;
|
|
@@ -1163,13 +1189,16 @@ export declare interface BrowserElementManagerInput {
|
|
|
1163
1189
|
readonly world: BrowserElementWorldFunction;
|
|
1164
1190
|
readonly reference: BrowserReferenceFunction;
|
|
1165
1191
|
readonly ready: BrowserReadinessFunction;
|
|
1192
|
+
/** Discards readiness after context loss and waits for the destination document. */
|
|
1193
|
+
readonly recover: BrowserReadinessFunction;
|
|
1166
1194
|
}
|
|
1167
1195
|
|
|
1168
1196
|
/** Captures, queries, and retains references to a view's elements. */
|
|
1169
1197
|
export declare interface BrowserElementManagerInterface<TElement extends BrowserElementInterface = BrowserElementInterface> {
|
|
1170
1198
|
/**
|
|
1171
1199
|
* Captures the view's document as a document-order outline, binding a reference to each
|
|
1172
|
-
* interactive element and bounding the referenced rows by `limit`.
|
|
1200
|
+
* interactive element and bounding the referenced rows by `limit`. The outline also lists the
|
|
1201
|
+
* rows that best match `search` and names the focused referenced row, both past `limit`.
|
|
1173
1202
|
*/
|
|
1174
1203
|
outline(options?: BrowserOutlineOptions): Promise<BrowserOutline>;
|
|
1175
1204
|
/**
|
|
@@ -1178,10 +1207,10 @@ export declare interface BrowserElementManagerInterface<TElement extends Browser
|
|
|
1178
1207
|
*/
|
|
1179
1208
|
find(query: BrowserElementQuery, options?: BrowserCallOptions): Promise<readonly TElement[]>;
|
|
1180
1209
|
/**
|
|
1181
|
-
* Resolves with the elements matching `query` after a mutation produces a match, or after none
|
|
1210
|
+
* Resolves with the elements matching `query` after a mutation or a finished transition or animation produces a match, or after none
|
|
1182
1211
|
* matches when `absent` is set; rejects at the deadline or on abort.
|
|
1183
1212
|
*/
|
|
1184
|
-
wait(query: BrowserElementQuery, options?:
|
|
1213
|
+
wait(query: BrowserElementQuery, options?: BrowserWaitOptions): Promise<readonly TElement[]>;
|
|
1185
1214
|
/**
|
|
1186
1215
|
* Returns the element a reference names, or `undefined` when the reference is unknown or was
|
|
1187
1216
|
* dropped.
|
|
@@ -1235,11 +1264,6 @@ export declare interface BrowserElementSubject {
|
|
|
1235
1264
|
readonly subject: string;
|
|
1236
1265
|
}
|
|
1237
1266
|
|
|
1238
|
-
/** Configures an element wait, including whether absence satisfies it. */
|
|
1239
|
-
export declare interface BrowserElementWaitOptions extends BrowserCallOptions {
|
|
1240
|
-
readonly absent?: boolean;
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
1267
|
/** Resolves the page-owned isolated world for a particular frame and session. */
|
|
1244
1268
|
export declare type BrowserElementWorldFunction = (frame: string, session: string, options?: BrowserCallOptions) => Promise<number>;
|
|
1245
1269
|
|
|
@@ -1412,11 +1436,11 @@ export declare interface BrowserFrameInterface {
|
|
|
1412
1436
|
/** Resolves the frame document title. */
|
|
1413
1437
|
title(options?: BrowserCallOptions): Promise<string>;
|
|
1414
1438
|
/**
|
|
1415
|
-
* Captures the document URL, title, and HTML in one size-guarded evaluation in the frame's
|
|
1439
|
+
* Captures the document URL, title, and rendered HTML in one size-guarded evaluation in the frame's
|
|
1416
1440
|
* isolated world and returns them as a reading whose `stale` flag tracks later navigations.
|
|
1417
1441
|
* A frame constructed without an epoch source (a standalone `BrowserFrame` with no `epoch`
|
|
1418
1442
|
* argument) returns readings whose `stale` stays `false`, because no navigation counter is
|
|
1419
|
-
* available to it.
|
|
1443
|
+
* available to it. {@link BrowserReadingInput} defines the rendered markup.
|
|
1420
1444
|
*/
|
|
1421
1445
|
read(options?: BrowserCallOptions): Promise<BrowserReadingInterface>;
|
|
1422
1446
|
/** Evaluates an expression in the frame execution world under the result-size guard. */
|
|
@@ -2389,13 +2413,24 @@ export declare interface BrowserNodeQuery {
|
|
|
2389
2413
|
*/
|
|
2390
2414
|
export declare type BrowserOperationOptions = BrowserClickOptions & BrowserDragOptions;
|
|
2391
2415
|
|
|
2392
|
-
/**
|
|
2416
|
+
/**
|
|
2417
|
+
* Carries a document-order outline and its included and available element counts.
|
|
2418
|
+
*
|
|
2419
|
+
* @remarks
|
|
2420
|
+
* - `matches` — the rendered rows that best match the options' `search`, in document order and
|
|
2421
|
+
* past `limit` included; empty without a `search` or without a match
|
|
2422
|
+
* - `focus` — the rendered row of the referenced element that has focus, past `limit` included;
|
|
2423
|
+
* the last such row in document order when several do, and `undefined` when focus is on no
|
|
2424
|
+
* referenced element
|
|
2425
|
+
*/
|
|
2393
2426
|
export declare interface BrowserOutline {
|
|
2394
2427
|
readonly url: string;
|
|
2395
2428
|
readonly title: string;
|
|
2396
2429
|
readonly text: string;
|
|
2397
2430
|
readonly count: number;
|
|
2398
2431
|
readonly total: number;
|
|
2432
|
+
readonly matches: readonly string[];
|
|
2433
|
+
readonly focus: string | undefined;
|
|
2399
2434
|
}
|
|
2400
2435
|
|
|
2401
2436
|
/** Associates an outline row with its frame, session, and optional actionable reference. */
|
|
@@ -2405,10 +2440,20 @@ export declare interface BrowserOutlineNode extends BrowserAXNode {
|
|
|
2405
2440
|
readonly tool?: string;
|
|
2406
2441
|
}
|
|
2407
2442
|
|
|
2408
|
-
/**
|
|
2443
|
+
/**
|
|
2444
|
+
* Configures an outline's element limit, optional subtree, and search.
|
|
2445
|
+
*
|
|
2446
|
+
* @remarks
|
|
2447
|
+
* - `search` — the words that select the outline's `matches`: the text is lowercased and split
|
|
2448
|
+
* into whole words of at least 3 letters or digits (`BROWSER_SEARCH_PATTERN`), each referenced
|
|
2449
|
+
* row's role and accessible name are split the same way, and a row scores the number of distinct
|
|
2450
|
+
* search words equal to one of its words; every referenced row with the highest score above 0
|
|
2451
|
+
* matches
|
|
2452
|
+
*/
|
|
2409
2453
|
export declare interface BrowserOutlineOptions extends BrowserCallOptions {
|
|
2410
2454
|
readonly limit?: number;
|
|
2411
2455
|
readonly within?: string;
|
|
2456
|
+
readonly search?: string;
|
|
2412
2457
|
}
|
|
2413
2458
|
|
|
2414
2459
|
/**
|
|
@@ -2452,7 +2497,7 @@ export declare class BrowserPage extends BrowserFrame implements BrowserPageInte
|
|
|
2452
2497
|
get mouse(): BrowserMouseInterface;
|
|
2453
2498
|
get touch(): BrowserTouchInterface;
|
|
2454
2499
|
read(options?: BrowserCallOptions): Promise<BrowserReadingInterface>;
|
|
2455
|
-
wait(text: string, options?:
|
|
2500
|
+
wait(text: string, options?: BrowserWaitOptions): Promise<void>;
|
|
2456
2501
|
get network(): BrowserNetworkManagerInterface;
|
|
2457
2502
|
get registry(): BrowserRegistryInterface;
|
|
2458
2503
|
get navigation(): BrowserNavigationManagerInterface;
|
|
@@ -2586,8 +2631,8 @@ export declare interface BrowserPageInterface extends BrowserFrameInterface, Bro
|
|
|
2586
2631
|
readonly keyboard: BrowserKeyboardInterface;
|
|
2587
2632
|
readonly mouse: BrowserMouseInterface;
|
|
2588
2633
|
readonly touch: BrowserTouchInterface;
|
|
2589
|
-
/** Waits for
|
|
2590
|
-
wait(text: string, options?:
|
|
2634
|
+
/** Waits for text in the main document body’s `innerText`, or its absence with `absent`, rejecting at the deadline or on abort. */
|
|
2635
|
+
wait(text: string, options?: BrowserWaitOptions): Promise<void>;
|
|
2591
2636
|
readonly emitter: EmitterInterface<BrowserPageEventMap>;
|
|
2592
2637
|
readonly registry: BrowserRegistryInterface;
|
|
2593
2638
|
readonly network: BrowserNetworkManagerInterface;
|
|
@@ -2892,7 +2937,7 @@ export declare interface BrowserReadinessWait {
|
|
|
2892
2937
|
* title: 'Example',
|
|
2893
2938
|
* html: '<nav>Menu</nav><main><p>Body</p></main>',
|
|
2894
2939
|
* })
|
|
2895
|
-
* reading.markdown() // { text: 'Body', offset: 0, total: 4 }
|
|
2940
|
+
* reading.markdown({ distill: true }) // { text: 'Body', offset: 0, total: 4 }
|
|
2896
2941
|
* ```
|
|
2897
2942
|
*/
|
|
2898
2943
|
export declare class BrowserReading implements BrowserReadingInterface {
|
|
@@ -2910,13 +2955,45 @@ export declare class BrowserReading implements BrowserReadingInterface {
|
|
|
2910
2955
|
* Describes the captured document a reading is built from.
|
|
2911
2956
|
*
|
|
2912
2957
|
* @remarks
|
|
2913
|
-
* - `url` — the document URL, which
|
|
2958
|
+
* - `url` — the document URL, which each projection resolves relative links against
|
|
2914
2959
|
* - `title` — the document title
|
|
2915
2960
|
* - `html` — the serialized document HTML
|
|
2916
2961
|
* - `epoch` — the navigation epoch recorded when the capture was issued. Default: the value
|
|
2917
2962
|
* `navigation` returns at construction
|
|
2918
2963
|
* - `navigation` — reads the source's navigation epoch at the moment of the call; a reading
|
|
2919
2964
|
* built without it never reports stale
|
|
2965
|
+
*
|
|
2966
|
+
* A view, frame, or element captures rendered markup by importing its root into an HTML
|
|
2967
|
+
* document without a window, so that nothing in the copy loads or runs, and pruning the copy
|
|
2968
|
+
* against the live document's computed styles. The live document is never written.
|
|
2969
|
+
* - A root or flat-tree ancestor in its own document with `display: none` yields empty HTML.
|
|
2970
|
+
* - Descendants with `display: none` are removed.
|
|
2971
|
+
* - Text under `visibility: hidden` or `collapse`, and invisible elements without children,
|
|
2972
|
+
* are removed; visible descendants of invisible elements remain.
|
|
2973
|
+
* - A child node of an element with an open shadow root is removed when no slot takes it or
|
|
2974
|
+
* when its slot sits under an element whose computed `display` is `none`.
|
|
2975
|
+
* - Closed `details` keeps only its first `summary` child. Elements with `content-visibility:
|
|
2976
|
+
* hidden`, and `canvas`, `video`, and `audio` elements, lose their child nodes.
|
|
2977
|
+
* - SVG `switch` keeps the child element with client rects, or its first child element when
|
|
2978
|
+
* none has rects, including definitions referenced by `use`. Other branches are removed.
|
|
2979
|
+
* Forms, rendered dialogs, and buttons become neutral carriers. Text fields and textareas
|
|
2980
|
+
* carry live values; empty text fields and textareas carry visible placeholders. Selects carry the selected
|
|
2981
|
+
* label, or displayed option and group labels in a listbox's client area. Named graphics carry
|
|
2982
|
+
* one explicit alternative; printed button text takes precedence over its accessible name.
|
|
2983
|
+
* Links carry resolved live addresses. Region elements remain available to distillation.
|
|
2984
|
+
* Carriers and block `div`, `summary`, and `details` elements receive `br` separators around their
|
|
2985
|
+
* contents. The `html` handle is this normalized capture, not the original DOM serialization.
|
|
2986
|
+
* Direct element reads apply the same ancestor visibility and child-pruning rules.
|
|
2987
|
+
* Password and hidden inputs are removed entirely, including in the data-only fallback for
|
|
2988
|
+
* detached roots and documents without a window. Active floor elements are dropped.
|
|
2989
|
+
* Checkbox, radio, range, and color values aren't printed text. Native control captions,
|
|
2990
|
+
* localized dates, invalid or intermediate number edits, and MathML are omitted rather than
|
|
2991
|
+
* guessed. A file input carries its sole filename; native multiple-file summaries are omitted.
|
|
2992
|
+
* Valid committed numbers carry their live value.
|
|
2993
|
+
* Opacity, clipping outside listboxes, size, position, and `content-visibility: auto` remove
|
|
2994
|
+
* nothing. Shadow-root text, generated content, text transformations, localized number
|
|
2995
|
+
* formatting, textarea clipping, and significant spaces are outside the capture's fidelity.
|
|
2996
|
+
* Caller-supplied HTML is parsed as given; projection options and their safety floors apply.
|
|
2920
2997
|
*/
|
|
2921
2998
|
export declare interface BrowserReadingInput {
|
|
2922
2999
|
readonly url: string;
|
|
@@ -2933,12 +3010,13 @@ export declare interface BrowserReadingInput {
|
|
|
2933
3010
|
* @remarks
|
|
2934
3011
|
* - `url` — the document URL at capture
|
|
2935
3012
|
* - `title` — the document title at capture
|
|
2936
|
-
* - `html` — the parsed document handle every projection reads
|
|
3013
|
+
* - `html` — the parsed captured and normalized document handle every projection reads;
|
|
3014
|
+
* caller-supplied HTML remains as supplied
|
|
2937
3015
|
* - `stale` — true when the source frame has navigated or detached since the capture; false
|
|
2938
3016
|
* otherwise
|
|
2939
3017
|
*
|
|
2940
|
-
* Each projection runs over
|
|
2941
|
-
* with `distill:
|
|
3018
|
+
* Each projection runs over the whole document by default and over
|
|
3019
|
+
* `html.distill({ base: url })` with `distill: true`. A reading computes each projection one time and cuts every slice from
|
|
2942
3020
|
* it, so successive slices of one reading and mode share one `total`.
|
|
2943
3021
|
*/
|
|
2944
3022
|
export declare interface BrowserReadingInterface {
|
|
@@ -2959,12 +3037,23 @@ export declare interface BrowserReadingInterface {
|
|
|
2959
3037
|
text(options?: BrowserReadOptions): BrowserReadResult;
|
|
2960
3038
|
}
|
|
2961
3039
|
|
|
3040
|
+
/**
|
|
3041
|
+
* Describes a matching line and its character offset in a reading's projection.
|
|
3042
|
+
*
|
|
3043
|
+
* @remarks
|
|
3044
|
+
* Offsets count UTF-16 code units in the original text, including preceding line breaks.
|
|
3045
|
+
*/
|
|
3046
|
+
export declare interface BrowserReadMatch {
|
|
3047
|
+
readonly offset: number;
|
|
3048
|
+
readonly text: string;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
2962
3051
|
/**
|
|
2963
3052
|
* Describes the options for one slice of a reading's Markdown or plain-text projection.
|
|
2964
3053
|
*
|
|
2965
3054
|
* @remarks
|
|
2966
3055
|
* - `distill` — if `true`, projects the distilled document; if `false`, projects the whole
|
|
2967
|
-
* document. Default: `
|
|
3056
|
+
* document. Default: `false`
|
|
2968
3057
|
* - `offset` — the character index the slice starts at, a non-negative integer. Default: `0`
|
|
2969
3058
|
* - `limit` — the most characters the slice holds, a positive integer. Default: unbounded
|
|
2970
3059
|
*
|
|
@@ -3129,7 +3218,7 @@ export declare interface BrowserRegistryInterface {
|
|
|
3129
3218
|
tool(name: string, frame?: string): BrowserTool | undefined;
|
|
3130
3219
|
/** Returns every registered tool, including shadowed frame registrations. */
|
|
3131
3220
|
tools(): readonly BrowserTool[];
|
|
3132
|
-
/** Projects tools as untrusted executable tools, omitting optional-
|
|
3221
|
+
/** Projects tools as untrusted executable tools, omitting optional-purpose schemas. */
|
|
3133
3222
|
adopt(): Promise<readonly ToolInterface[]>;
|
|
3134
3223
|
/** Invokes a tool and awaits its terminal event; rejects on abort, invalidation, or timeout. */
|
|
3135
3224
|
execute(tool: BrowserTool, input: Readonly<Record<string, unknown>>, options?: BrowserCallOptions): Promise<BrowserInvocationResult>;
|
|
@@ -3876,11 +3965,11 @@ export declare interface BrowserRunStoreInterface {
|
|
|
3876
3965
|
}
|
|
3877
3966
|
|
|
3878
3967
|
/**
|
|
3879
|
-
* Names a tool the browser toolset reserves: the
|
|
3968
|
+
* Names a tool the browser toolset reserves: the generic tools, the staged `dialog`, the
|
|
3880
3969
|
* opt-in `tabs` and `switch`, and the journey tools `record`, `save`, `journeys`, `edit`,
|
|
3881
3970
|
* `replay`, and `forget`, which a toolset constructed with `journeys` reserves.
|
|
3882
3971
|
*/
|
|
3883
|
-
export declare type BrowserToolName = 'look' | 'read' | 'click' | 'type' | 'press' | 'navigate' | 'wait' | 'dialog' | 'tabs' | 'switch' | 'record' | 'save' | 'journeys' | 'edit' | 'replay' | 'forget';
|
|
3972
|
+
export declare type BrowserToolName = 'look' | 'read' | 'plain' | 'click' | 'type' | 'press' | 'navigate' | 'wait' | 'dialog' | 'tabs' | 'switch' | 'record' | 'save' | 'journeys' | 'edit' | 'replay' | 'forget';
|
|
3884
3973
|
|
|
3885
3974
|
/** Identifies a removed WebMCP tool by document and name. */
|
|
3886
3975
|
export declare interface BrowserToolRemoval {
|
|
@@ -3893,7 +3982,7 @@ export declare interface BrowserRunStoreInterface {
|
|
|
3893
3982
|
* view's own tools beside them.
|
|
3894
3983
|
*
|
|
3895
3984
|
* @remarks
|
|
3896
|
-
* Every toolset advertises `look`, `read`, `click`, `type`, and `wait`, which need only the
|
|
3985
|
+
* Every toolset advertises `look`, `read`, `plain`, `click`, `type`, and `wait`, which need only the
|
|
3897
3986
|
* `BrowserViewInterface` it is constructed over. With `options.page` it also advertises `press`
|
|
3898
3987
|
* and `navigate`, stages the `dialog` tool while a dialog is open on the current page, follows a
|
|
3899
3988
|
* popup the current page opens and returns to the opener when the popup closes, and adopts
|
|
@@ -3907,11 +3996,18 @@ export declare interface BrowserRunStoreInterface {
|
|
|
3907
3996
|
* refuses every tool but `dialog` while a dialog is open, forwards `ToolContext.signal` into every
|
|
3908
3997
|
* protocol call, refuses a call to a toolset tool that carries a parameter the tool does not
|
|
3909
3998
|
* advertise, and cuts every returned string and every thrown message at `limit` characters plus
|
|
3910
|
-
* a footer; the footer of a cut
|
|
3911
|
-
*
|
|
3912
|
-
* the
|
|
3913
|
-
*
|
|
3914
|
-
* the
|
|
3999
|
+
* a footer; the footer of a cut action or `dialog` receipt that carries a view names `look` as the next
|
|
4000
|
+
* call. `look`, `read`, and `plain` read the page and return pages of at most `limit`
|
|
4001
|
+
* characters and name the offset the next page starts at. A page ends after the last line break
|
|
4002
|
+
* in its window that lies past the page's start, or at the window's end when no such break fits,
|
|
4003
|
+
* without splitting a surrogate pair. The last page ends at the end of the outline or reading. A `look` whose
|
|
4004
|
+
* `search` matches referenced rows lists those rows first, and its pages reach every referenced row.
|
|
4005
|
+
* A `press` receipt names the referenced element that has focus after the key. A page tool's
|
|
4006
|
+
* error message and JSON output reach the toolset already cut at `BROWSER_REGISTRY_OUTPUT_LIMIT`
|
|
4007
|
+
* (4 096) by the registry, so a `limit` over that shows at most 4 096 characters of either; a page
|
|
4008
|
+
* tool's text output reaches the boundary whole.
|
|
4009
|
+
* `wait` with `absent` set to `true` settles when the text is not on the page, and a miss
|
|
4010
|
+
* returns the `timeout` outcome as an appearance miss does.
|
|
3915
4011
|
*
|
|
3916
4012
|
* `click`, `type`, `press`, `navigate`, and `switch` are actions: one runs at a time, in call
|
|
3917
4013
|
* order, and holds the queue until its receipt. A queued action whose signal aborts leaves
|
|
@@ -3942,7 +4038,7 @@ export declare interface BrowserRunStoreInterface {
|
|
|
3942
4038
|
* page placement's `type` with `submit` ends its action with `and submitted the form` when a read
|
|
3943
4039
|
* recorded a submission, or when the navigation the receipt settled names `formSubmissionGet` or
|
|
3944
4040
|
* `formSubmissionPost` as its reason, whatever the read answered, and with `and pressed Enter`
|
|
3945
|
-
* otherwise. A `read`
|
|
4041
|
+
* otherwise. A `read` or `plain`
|
|
3946
4042
|
* at an offset at or past its retained reading's end restarts that reading at 0. A receipt that
|
|
3947
4043
|
* waits for a requested navigation shares one `BROWSER_TOOL_TIMEOUT_MS` deadline between that
|
|
3948
4044
|
* wait and its view capture, of which `BROWSER_TOOL_CAPTURE_MS` is reserved for the capture. The
|
|
@@ -3958,9 +4054,9 @@ export declare interface BrowserRunStoreInterface {
|
|
|
3958
4054
|
* A page tool is skipped, with `skip` emitted, when its name is reserved (`unresolved` included), when the manager holds
|
|
3959
4055
|
* its name under a tool the toolset did not add (checked again immediately before each addition),
|
|
3960
4056
|
* when its name falls outside `BROWSER_TOOL_NAME_PATTERN`, when its parameters or, for a source
|
|
3961
|
-
* that supplies `tools()`, its selected registration declare `
|
|
4057
|
+
* that supplies `tools()`, its selected registration declare `purpose` optional, or when that
|
|
3962
4058
|
* registration is marked `debugging`. The selected registration is the main frame's, then the
|
|
3963
|
-
* earlier one. A page tool whose parameters require nothing advertises a required `
|
|
4059
|
+
* earlier one. A page tool whose parameters require nothing advertises a required `purpose`, which
|
|
3964
4060
|
* is stripped before the tool runs. Every adopted tool is advertised `untrusted`. `destroy()`
|
|
3965
4061
|
* removes only the tools the manager still holds under the instances the toolset added, never
|
|
3966
4062
|
* closes a page, and ends only what `options.release` hands over, calling it one time last.
|
|
@@ -3971,7 +4067,7 @@ export declare interface BrowserRunStoreInterface {
|
|
|
3971
4067
|
*
|
|
3972
4068
|
* const toolset = new BrowserToolset(page, { page })
|
|
3973
4069
|
* await toolset.start()
|
|
3974
|
-
* const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: {
|
|
4070
|
+
* const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: { search: 'cart' } })
|
|
3975
4071
|
* await toolset.destroy()
|
|
3976
4072
|
* ```
|
|
3977
4073
|
*/
|
|
@@ -4029,8 +4125,8 @@ export declare interface BrowserRunStoreInterface {
|
|
|
4029
4125
|
* - `emitter` — emits `adopt`, `skip`, `select`, `action`, `hold`, and `release`
|
|
4030
4126
|
* - `tools` — the manager the toolset fills, with execution through the `perform` boundary
|
|
4031
4127
|
* - `native` — the generic tools alone, which a consumer publishes to a built-in agent: the
|
|
4032
|
-
*
|
|
4033
|
-
* view-backed one
|
|
4128
|
+
* `look`, `read`, `plain`, `click`, `type`, `press`, `navigate`, and `wait` for a page-backed
|
|
4129
|
+
* toolset, and `look`, `read`, `plain`, `click`, `type`, and `wait` for a view-backed one
|
|
4034
4130
|
* - `view` — the view the tools act on
|
|
4035
4131
|
*/
|
|
4036
4132
|
export declare interface BrowserToolsetInterface {
|
|
@@ -4142,7 +4238,7 @@ export declare interface BrowserRunStoreInterface {
|
|
|
4142
4238
|
* - `reserved` — the name is one of the toolset's own tool names
|
|
4143
4239
|
* - `held` — the manager holds the name under a tool the toolset did not add
|
|
4144
4240
|
* - `pattern` — the name falls outside `BROWSER_TOOL_NAME_PATTERN`
|
|
4145
|
-
* - `schema` — the page's input schema declares `
|
|
4241
|
+
* - `schema` — the page's input schema declares `purpose` as optional
|
|
4146
4242
|
* - `debugging` — the page marks the tool for developers
|
|
4147
4243
|
*/
|
|
4148
4244
|
export declare type BrowserToolsetReason = 'reserved' | 'held' | 'pattern' | 'schema' | 'debugging';
|
|
@@ -4359,15 +4455,15 @@ export declare interface BrowserRunStoreInterface {
|
|
|
4359
4455
|
/** Resolves the document title. */
|
|
4360
4456
|
title(options?: BrowserCallOptions): Promise<string>;
|
|
4361
4457
|
/**
|
|
4362
|
-
* Captures the document URL, title, and markup as a reading whose `stale` flag tracks
|
|
4363
|
-
* navigations.
|
|
4458
|
+
* Captures the document URL, title, and rendered markup as a reading whose `stale` flag tracks
|
|
4459
|
+
* later navigations; {@link BrowserReadingInput} defines the rendered markup.
|
|
4364
4460
|
*/
|
|
4365
4461
|
read(options?: BrowserCallOptions): Promise<BrowserReadingInterface>;
|
|
4366
4462
|
/**
|
|
4367
|
-
* Resolves when `
|
|
4463
|
+
* Resolves when the main document body’s `innerText` contains `text`, or lacks it with `absent`; rejects with a `BrowserError` coded
|
|
4368
4464
|
* `BROWSER_WAIT_TIMEOUT` at the deadline, and with `signal.reason` on abort.
|
|
4369
4465
|
*/
|
|
4370
|
-
wait(text: string, options?:
|
|
4466
|
+
wait(text: string, options?: BrowserWaitOptions): Promise<void>;
|
|
4371
4467
|
}
|
|
4372
4468
|
|
|
4373
4469
|
/** Describes the viewport dimensions for a browser page. */
|
|
@@ -4380,6 +4476,18 @@ export declare interface BrowserRunStoreInterface {
|
|
|
4380
4476
|
readonly landscape?: boolean;
|
|
4381
4477
|
}
|
|
4382
4478
|
|
|
4479
|
+
/**
|
|
4480
|
+
* Configures a text or element wait, including whether absence satisfies it.
|
|
4481
|
+
*
|
|
4482
|
+
* @remarks
|
|
4483
|
+
* - `absent` — if `true`, the wait resolves when the body's `innerText` lacks the text or no
|
|
4484
|
+
* element matches; if `false` or omitted, when the text is present or an element matches.
|
|
4485
|
+
* A condition that already holds resolves at the first check
|
|
4486
|
+
*/
|
|
4487
|
+
export declare interface BrowserWaitOptions extends BrowserCallOptions {
|
|
4488
|
+
readonly absent?: boolean;
|
|
4489
|
+
}
|
|
4490
|
+
|
|
4383
4491
|
/** Names the page load condition for navigation — the CDP load event awaited by `navigate()`. */
|
|
4384
4492
|
export declare type BrowserWaitUntil = 'commit' | 'load' | 'domcontentloaded' | 'idle';
|
|
4385
4493
|
|
|
@@ -4762,6 +4870,20 @@ export declare interface BrowserRunStoreInterface {
|
|
|
4762
4870
|
*/
|
|
4763
4871
|
export declare function collectBrowserJourneyTextBindings(steps: readonly BrowserJourneyStepInput[]): readonly string[];
|
|
4764
4872
|
|
|
4873
|
+
/**
|
|
4874
|
+
* Collects distinct lowercase words of at least 3 letters or digits.
|
|
4875
|
+
*
|
|
4876
|
+
* @param text - Text to scan
|
|
4877
|
+
* @returns The searchable whole words
|
|
4878
|
+
*
|
|
4879
|
+
* @example
|
|
4880
|
+
* ```ts
|
|
4881
|
+
* import { collectBrowserWords } from '@orkestrel/browser'
|
|
4882
|
+
* [...collectBrowserWords('The cart, the bag')] // ['the', 'cart', 'bag']
|
|
4883
|
+
* ```
|
|
4884
|
+
*/
|
|
4885
|
+
export declare function collectBrowserWords(text: string): ReadonlySet<string>;
|
|
4886
|
+
|
|
4765
4887
|
/**
|
|
4766
4888
|
* Compiles the element-side actionability pass used before trusted input.
|
|
4767
4889
|
*
|
|
@@ -4894,22 +5016,26 @@ export declare interface BrowserRunStoreInterface {
|
|
|
4894
5016
|
export declare function compileHitFunction(): string;
|
|
4895
5017
|
|
|
4896
5018
|
/**
|
|
4897
|
-
* Compiles a
|
|
5019
|
+
* Compiles a wait woken by mutations and finished transitions and animations, with one deadline and explicit disconnect ownership.
|
|
5020
|
+
* @remarks
|
|
5021
|
+
* `transitionend` and `animationend` inside a shadow root are not composed in Chromium
|
|
5022
|
+
* 154.0.4258.53, so this document listener does not see them. Mutations inside that root are
|
|
5023
|
+
* not observed either.
|
|
4898
5024
|
* @param deadline - Maximum time in milliseconds
|
|
4899
5025
|
* @param key - Isolated-world property owning this observer
|
|
4900
|
-
* @param predicate - Optional expression checked immediately and after
|
|
5026
|
+
* @param predicate - Optional expression checked immediately and on the task after a mutation batch or a `BROWSER_WAIT_EVENTS` event
|
|
4901
5027
|
* @returns Promise expression resolving true on a match or change, false at the deadline
|
|
4902
5028
|
*/
|
|
4903
5029
|
export declare function compileQueryWaitExpression(deadline: number, key: string, predicate?: string): string;
|
|
4904
5030
|
|
|
4905
5031
|
/**
|
|
4906
|
-
* Compiles the in-page function that reads the document's URL, title, and
|
|
5032
|
+
* Compiles the in-page function that reads the document's URL, title, and rendered HTML.
|
|
4907
5033
|
*
|
|
4908
5034
|
* @remarks
|
|
4909
|
-
* The
|
|
4910
|
-
*
|
|
4911
|
-
*
|
|
4912
|
-
*
|
|
5035
|
+
* The optional root defaults to `document.documentElement`. {@link BrowserReadingInput}
|
|
5036
|
+
* defines its inert capture, lowering, redaction, and limits. A missing root yields empty HTML.
|
|
5037
|
+
* Call it inside {@link compileGuardedEvaluateExpression} to bound the final serialized result
|
|
5038
|
+
* under {@link BROWSER_RESULT_LIMIT}.
|
|
4913
5039
|
*
|
|
4914
5040
|
* @returns A function declaration source
|
|
4915
5041
|
*/
|
|
@@ -5008,13 +5134,14 @@ export declare interface BrowserRunStoreInterface {
|
|
|
5008
5134
|
export declare function compileSubmitReadExpression(token: number): string;
|
|
5009
5135
|
|
|
5010
5136
|
/**
|
|
5011
|
-
* Compiles a visible
|
|
5137
|
+
* Compiles a wait for the presence or absence of visible text, coalesced by tasks.
|
|
5012
5138
|
* @param text - Text to find in the main document body
|
|
5013
5139
|
* @param deadline - Maximum time in milliseconds
|
|
5014
5140
|
* @param key - Isolated-world property owning this observer
|
|
5141
|
+
* @param absent - If `true`, resolves when the body's `innerText` lacks `text`; if `false`, when it contains it. Default: `false`
|
|
5015
5142
|
* @returns Mutation-driven promise expression with one deadline
|
|
5016
5143
|
*/
|
|
5017
|
-
export declare function compileTextWaitExpression(text: string, deadline: number, key: string): string;
|
|
5144
|
+
export declare function compileTextWaitExpression(text: string, deadline: number, key: string, absent?: boolean): string;
|
|
5018
5145
|
|
|
5019
5146
|
/**
|
|
5020
5147
|
* Composes a frame-local point with its ancestor frame offsets.
|
|
@@ -5150,7 +5277,7 @@ export declare interface BrowserRunStoreInterface {
|
|
|
5150
5277
|
*
|
|
5151
5278
|
* const toolset = createBrowserToolset(page, { context })
|
|
5152
5279
|
* await toolset.start()
|
|
5153
|
-
* const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: {
|
|
5280
|
+
* const result = await toolset.tools.execute({ id: '1', name: 'look', arguments: { search: 'cart' } })
|
|
5154
5281
|
* ```
|
|
5155
5282
|
*
|
|
5156
5283
|
* @example Drive a page with a small model
|
|
@@ -5164,8 +5291,8 @@ export declare interface BrowserRunStoreInterface {
|
|
|
5164
5291
|
* const system =
|
|
5165
5292
|
* 'You control a web browser with tools and must call a tool before you answer. ' +
|
|
5166
5293
|
* 'The first message shows the page as look returns it; references such as e4 name its elements. ' +
|
|
5167
|
-
* 'To learn a fact, call read with
|
|
5168
|
-
*
|
|
5294
|
+
* 'To learn a fact, call read with search set to words from your question; when its result ends by naming an offset, call read again with that offset. ' +
|
|
5295
|
+
* "To use the site's search box, call type with its reference, the words, and submit true. " +
|
|
5169
5296
|
* 'To press a button or follow a link, call click with its reference from the latest result. Never invent a reference. ' +
|
|
5170
5297
|
* 'If text you expect has not appeared, call wait once. ' +
|
|
5171
5298
|
* 'When the task is done, answer in one short sentence.'
|
|
@@ -5175,11 +5302,11 @@ export declare interface BrowserRunStoreInterface {
|
|
|
5175
5302
|
* const page = await browser.create({ url: 'https://shop.example.test/' })
|
|
5176
5303
|
* const toolset = createBrowserToolset(page, { tools: createToolManager() })
|
|
5177
5304
|
* await toolset.start()
|
|
5178
|
-
* toolset.tools.tools().map((tool) => tool.name) // ['look', 'read', 'click', 'type', 'press', 'navigate', 'wait']
|
|
5305
|
+
* toolset.tools.tools().map((tool) => tool.name) // ['look', 'read', 'plain', 'click', 'type', 'press', 'navigate', 'wait']
|
|
5179
5306
|
* const seeded = await toolset.tools.execute({
|
|
5180
5307
|
* id: 'seed',
|
|
5181
5308
|
* name: 'look',
|
|
5182
|
-
* arguments: {
|
|
5309
|
+
* arguments: { search: '' },
|
|
5183
5310
|
* })
|
|
5184
5311
|
* const view = seeded.success ? String(seeded.value) : seeded.error
|
|
5185
5312
|
* const agent = createAgent(createOllama({ model: 'qwen3.5:2b-q4_K_M' }), {
|
|
@@ -5266,10 +5393,10 @@ export declare interface BrowserRunStoreInterface {
|
|
|
5266
5393
|
export declare function deriveBrowserJourneyTrigger(step: BrowserJourneyStepInput, inputs?: Readonly<Record<string, string>>): string;
|
|
5267
5394
|
|
|
5268
5395
|
/**
|
|
5269
|
-
* Derives the advertised input schema from an authored one, adding a required `
|
|
5396
|
+
* Derives the advertised input schema from an authored one, adding a required `purpose` parameter when the schema requires nothing.
|
|
5270
5397
|
* @param schema - Authored input schema, or undefined for a parameterless tool
|
|
5271
|
-
* @returns An advertised schema, or undefined when the authored `
|
|
5272
|
-
* @remarks The caller strips only a synthetic `
|
|
5398
|
+
* @returns An advertised schema, or undefined when the authored `purpose` parameter is optional
|
|
5399
|
+
* @remarks The caller strips only a synthetic `purpose` parameter before invoking the page tool.
|
|
5273
5400
|
*/
|
|
5274
5401
|
export declare function deriveBrowserToolSchema(schema: Readonly<Record<string, unknown>> | undefined): Readonly<Record<string, unknown>> | undefined;
|
|
5275
5402
|
|
|
@@ -6100,15 +6227,111 @@ export declare interface BrowserRunStoreInterface {
|
|
|
6100
6227
|
*/
|
|
6101
6228
|
export declare function renderBrowserJourneyFault(fault: BrowserStoreFault): string;
|
|
6102
6229
|
|
|
6230
|
+
/**
|
|
6231
|
+
* Renders matching rows in at most half the available reply room.
|
|
6232
|
+
*
|
|
6233
|
+
* @remarks
|
|
6234
|
+
* An oversized first row is cut with an ellipsis without splitting a surrogate pair, reserving
|
|
6235
|
+
* room for the first later row that can fit beside it only when the cut keeps the leading token
|
|
6236
|
+
* through its first space. Otherwise it cuts without reserving. Later rows that do not fit are
|
|
6237
|
+
* skipped. An empty collection or a cut with no character before the ellipsis produces no block.
|
|
6238
|
+
*
|
|
6239
|
+
* @param heading - The match count and search, ending with a colon
|
|
6240
|
+
* @param rows - Matching rows in document order
|
|
6241
|
+
* @param room - Characters available in the reply
|
|
6242
|
+
* @returns The bounded block with a trailing blank line, or an empty string
|
|
6243
|
+
*
|
|
6244
|
+
* @example
|
|
6245
|
+
* ```ts
|
|
6246
|
+
* import { renderBrowserMatches } from '@orkestrel/browser'
|
|
6247
|
+
* renderBrowserMatches('Matches:', ['[5] Cart'], 100) // 'Matches:\n[5] Cart\n\n'
|
|
6248
|
+
* ```
|
|
6249
|
+
*/
|
|
6250
|
+
export declare function renderBrowserMatches(heading: string, rows: readonly string[], room: number): string;
|
|
6251
|
+
|
|
6103
6252
|
/**
|
|
6104
6253
|
* Renders document-order text and referenced elements with a bounded element count.
|
|
6254
|
+
*
|
|
6255
|
+
* @remarks
|
|
6256
|
+
* Each referenced row renders through `renderBrowserOutlineRow`, and the closing
|
|
6257
|
+
* `(COUNT of TOTAL elements)` line counts the rows included and available. `matches` holds the
|
|
6258
|
+
* rows `scanBrowserOutline` returns for `search`, and `focus` the last referenced row whose node
|
|
6259
|
+
* carries a `focused` property of `true`; both reach past `limit`.
|
|
6260
|
+
*
|
|
6105
6261
|
* @param url - Document address
|
|
6106
6262
|
* @param title - Document title
|
|
6107
6263
|
* @param nodes - Ordered accessibility rows
|
|
6108
6264
|
* @param limit - Maximum referenced rows to include
|
|
6109
|
-
* @
|
|
6265
|
+
* @param search - The words whose best-matching rows `matches` lists. Default: none, which lists
|
|
6266
|
+
* none
|
|
6267
|
+
* @returns Outline text, element counts, matching rows, and the focused row
|
|
6268
|
+
*
|
|
6269
|
+
* @example
|
|
6270
|
+
* ```ts
|
|
6271
|
+
* import { renderBrowserOutline } from '@orkestrel/browser'
|
|
6272
|
+
*
|
|
6273
|
+
* const node = {
|
|
6274
|
+
* parent: undefined,
|
|
6275
|
+
* children: [],
|
|
6276
|
+
* backend: undefined,
|
|
6277
|
+
* frame: undefined,
|
|
6278
|
+
* ignored: false,
|
|
6279
|
+
* description: undefined,
|
|
6280
|
+
* value: undefined,
|
|
6281
|
+
* session: 'main',
|
|
6282
|
+
* }
|
|
6283
|
+
* const outline = renderBrowserOutline(
|
|
6284
|
+
* 'https://shop.example/cart',
|
|
6285
|
+
* 'Cart',
|
|
6286
|
+
* [
|
|
6287
|
+
* { ...node, id: '1', role: 'button', name: 'Close', properties: {}, reference: 'e1' },
|
|
6288
|
+
* { ...node, id: '2', role: 'button', name: 'Archive', properties: { focused: true }, reference: 'e2' },
|
|
6289
|
+
* ],
|
|
6290
|
+
* 1,
|
|
6291
|
+
* 'archive button',
|
|
6292
|
+
* )
|
|
6293
|
+
* outline.text // 'page "Cart" https://shop.example/cart\ne1 button "Close"\n(1 of 2 elements)'
|
|
6294
|
+
* outline.matches // ['e2 button "Archive"']
|
|
6295
|
+
* outline.focus // 'e2 button "Archive"'
|
|
6296
|
+
* ```
|
|
6297
|
+
*/
|
|
6298
|
+
export declare function renderBrowserOutline(url: string, title: string, nodes: readonly BrowserOutlineNode[], limit: number, search?: string): BrowserOutline;
|
|
6299
|
+
|
|
6300
|
+
/**
|
|
6301
|
+
* Renders one outline row: the node's reference, its role, its quoted accessible name, and the
|
|
6302
|
+
* states it carries.
|
|
6303
|
+
*
|
|
6304
|
+
* @remarks
|
|
6305
|
+
* After the name the row appends `value="V"` when the node carries a non-empty value,
|
|
6306
|
+
* `pressed=true|false|mixed`, `expanded=true|false`, and `selected=true|false` when present,
|
|
6307
|
+
* `[checked]` when checked, `[disabled]` when disabled, and `[tool=NAME]` for a page tool's form,
|
|
6308
|
+
* in that order. A node without a reference renders without one.
|
|
6309
|
+
*
|
|
6310
|
+
* @param node - The outline node
|
|
6311
|
+
* @returns The rendered row
|
|
6312
|
+
*
|
|
6313
|
+
* @example
|
|
6314
|
+
* ```ts
|
|
6315
|
+
* import { renderBrowserOutlineRow } from '@orkestrel/browser'
|
|
6316
|
+
*
|
|
6317
|
+
* renderBrowserOutlineRow({
|
|
6318
|
+
* id: '4',
|
|
6319
|
+
* parent: undefined,
|
|
6320
|
+
* children: [],
|
|
6321
|
+
* backend: undefined,
|
|
6322
|
+
* frame: undefined,
|
|
6323
|
+
* ignored: false,
|
|
6324
|
+
* role: 'checkbox',
|
|
6325
|
+
* name: ' Gift wrap ',
|
|
6326
|
+
* description: undefined,
|
|
6327
|
+
* value: undefined,
|
|
6328
|
+
* properties: { checked: 'true' },
|
|
6329
|
+
* session: 'main',
|
|
6330
|
+
* reference: 'e4',
|
|
6331
|
+
* }) // 'e4 checkbox "Gift wrap" [checked]'
|
|
6332
|
+
* ```
|
|
6110
6333
|
*/
|
|
6111
|
-
export declare function
|
|
6334
|
+
export declare function renderBrowserOutlineRow(node: BrowserOutlineNode): string;
|
|
6112
6335
|
|
|
6113
6336
|
/**
|
|
6114
6337
|
* Renders a tool receipt: the action and its status on one line, the interrupting dialog, then
|
|
@@ -6194,6 +6417,61 @@ export declare interface BrowserRunStoreInterface {
|
|
|
6194
6417
|
*/
|
|
6195
6418
|
export declare function resolveBrowserJourneyBinding(value: unknown, inputs: Readonly<Record<string, string>>): string;
|
|
6196
6419
|
|
|
6420
|
+
/**
|
|
6421
|
+
* Returns the referenced outline nodes whose role and accessible name share the most words with a
|
|
6422
|
+
* search, in document order.
|
|
6423
|
+
*
|
|
6424
|
+
* @remarks
|
|
6425
|
+
* The search and each node's role and name are lowercased and split into whole words by
|
|
6426
|
+
* `BROWSER_SEARCH_PATTERN`, so a word shorter than 3 letters or digits never counts, and words
|
|
6427
|
+
* compare whole, with no substring or prefix match. A node scores the number of distinct search
|
|
6428
|
+
* words equal to one of its words, and every node with the highest score above 0 matches. Only a
|
|
6429
|
+
* node an outline renders as a referenced row takes part: one that is not ignored, carries a
|
|
6430
|
+
* reference, and whose role is not omitted, a heading, or text.
|
|
6431
|
+
*
|
|
6432
|
+
* @param nodes - Ordered accessibility rows
|
|
6433
|
+
* @param search - The words to match
|
|
6434
|
+
* @returns The best-matching nodes in document order; empty when no node shares a word
|
|
6435
|
+
*
|
|
6436
|
+
* @example
|
|
6437
|
+
* ```ts
|
|
6438
|
+
* import { scanBrowserOutline } from '@orkestrel/browser'
|
|
6439
|
+
*
|
|
6440
|
+
* const node = {
|
|
6441
|
+
* parent: undefined,
|
|
6442
|
+
* children: [],
|
|
6443
|
+
* backend: undefined,
|
|
6444
|
+
* frame: undefined,
|
|
6445
|
+
* ignored: false,
|
|
6446
|
+
* description: undefined,
|
|
6447
|
+
* value: undefined,
|
|
6448
|
+
* properties: {},
|
|
6449
|
+
* session: 'main',
|
|
6450
|
+
* }
|
|
6451
|
+
* const nodes = [
|
|
6452
|
+
* { ...node, id: '1', role: 'button', name: 'Close', reference: 'e1' },
|
|
6453
|
+
* { ...node, id: '2', role: 'button', name: 'Archive', reference: 'e2' },
|
|
6454
|
+
* ]
|
|
6455
|
+
* scanBrowserOutline(nodes, 'archive dialog button').map((match) => match.reference) // ['e2']
|
|
6456
|
+
* ```
|
|
6457
|
+
*/
|
|
6458
|
+
export declare function scanBrowserOutline(nodes: readonly BrowserOutlineNode[], search: string): readonly BrowserOutlineNode[];
|
|
6459
|
+
|
|
6460
|
+
/**
|
|
6461
|
+
* Matches the lines sharing the most distinct search words, in document order.
|
|
6462
|
+
*
|
|
6463
|
+
* @param text - The complete projection
|
|
6464
|
+
* @param search - Words to match, using the outline's word rule
|
|
6465
|
+
* @returns The best-scoring lines and their original UTF-16 offsets; empty without a shared word
|
|
6466
|
+
*
|
|
6467
|
+
* @example
|
|
6468
|
+
* ```ts
|
|
6469
|
+
* import { scanBrowserText } from '@orkestrel/browser'
|
|
6470
|
+
* scanBrowserText('Cart\nBlue kettle', 'kettle') // [{ offset: 5, text: 'Blue kettle' }]
|
|
6471
|
+
* ```
|
|
6472
|
+
*/
|
|
6473
|
+
export declare function scanBrowserText(text: string, search: string): readonly BrowserReadMatch[];
|
|
6474
|
+
|
|
6197
6475
|
/**
|
|
6198
6476
|
* Awaits every teardown step in order and returns the first failure.
|
|
6199
6477
|
*
|
|
@@ -6357,8 +6635,8 @@ export declare interface BrowserRunStoreInterface {
|
|
|
6357
6635
|
* ```ts
|
|
6358
6636
|
* import { BROWSER_TOOL_COPY, validateBrowserToolArguments } from '@orkestrel/browser'
|
|
6359
6637
|
*
|
|
6360
|
-
* validateBrowserToolArguments(BROWSER_TOOL_COPY.look, {
|
|
6361
|
-
* // throws 'The look tool takes no ref parameter; call look with
|
|
6638
|
+
* validateBrowserToolArguments(BROWSER_TOOL_COPY.look, { search: 'cart', ref: 'e1' })
|
|
6639
|
+
* // throws 'The look tool takes no ref parameter; call look with search and offset.'
|
|
6362
6640
|
* ```
|
|
6363
6641
|
*/
|
|
6364
6642
|
export declare function validateBrowserToolArguments(definition: ToolDefinition, args: Readonly<Record<string, unknown>>): void;
|