omowright 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bsk/dom-reads.d.ts +31 -0
- package/dist/bsk/first-navigate.d.ts +14 -0
- package/dist/bsk/protocol/params.generated.d.ts +1511 -0
- package/dist/bsk/screenshot.d.ts +6 -8
- package/dist/bsk/session.d.ts +47 -28
- package/dist/bsk/shared-tab.d.ts +22 -0
- package/dist/bsk/snapshot.d.ts +3 -4
- package/dist/bsk/targets.d.ts +8 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +221 -123
- package/package.json +2 -2
- package/skills/omowright/references/browserskill.md +63 -14
package/dist/index.js
CHANGED
|
@@ -35703,7 +35703,7 @@ async function snapshotWithFrames(page, opts = {}) {
|
|
|
35703
35703
|
// package.json
|
|
35704
35704
|
var package_default = {
|
|
35705
35705
|
name: "omowright",
|
|
35706
|
-
version: "0.3.
|
|
35706
|
+
version: "0.3.4",
|
|
35707
35707
|
description: "OmOWright browser automation for standard Chromium CDP endpoints.",
|
|
35708
35708
|
keywords: [
|
|
35709
35709
|
"accessibility-snapshot",
|
|
@@ -35754,7 +35754,7 @@ var package_default = {
|
|
|
35754
35754
|
"test:cloak-profile": "bun test test/cloak-profile.test.ts test/cloak-profile.integration.test.ts",
|
|
35755
35755
|
typecheck: "bun check --no-script --no-pretty -p tsconfig.json",
|
|
35756
35756
|
"typecheck:control": "bun scripts/typecheck-control.ts",
|
|
35757
|
-
check: "bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
|
|
35757
|
+
check: "bun scripts/bsk-protocol.ts --check && bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
|
|
35758
35758
|
lint: "oxlint --deny-warnings src bin bridge test scripts && bun scripts/lint-ratchet.ts",
|
|
35759
35759
|
"lint:ratchet:update": "bun scripts/lint-ratchet.ts --update",
|
|
35760
35760
|
"lint:fix": "oxlint --fix src bin bridge test scripts",
|
|
@@ -37192,7 +37192,7 @@ function decodeResponse(line, rpcId, method) {
|
|
|
37192
37192
|
}
|
|
37193
37193
|
// src/bsk/targets.ts
|
|
37194
37194
|
var REF_SHAPE = /^@?e\d+$/;
|
|
37195
|
-
function
|
|
37195
|
+
function elementTarget(target) {
|
|
37196
37196
|
if (typeof target === "string") {
|
|
37197
37197
|
return REF_SHAPE.test(target) ? { ref: target } : { selector: target };
|
|
37198
37198
|
}
|
|
@@ -37202,14 +37202,31 @@ function resolveTarget(target) {
|
|
|
37202
37202
|
return { ref: spec.ref };
|
|
37203
37203
|
if (typeof spec.selector === "string")
|
|
37204
37204
|
return { selector: spec.selector };
|
|
37205
|
+
}
|
|
37206
|
+
return;
|
|
37207
|
+
}
|
|
37208
|
+
function resolveTarget(target) {
|
|
37209
|
+
const element = elementTarget(target);
|
|
37210
|
+
if (element)
|
|
37211
|
+
return element;
|
|
37212
|
+
if (target && typeof target === "object") {
|
|
37213
|
+
const spec = target;
|
|
37205
37214
|
if (typeof spec.captureId === "string") {
|
|
37215
|
+
if (typeof spec.x !== "number" || typeof spec.y !== "number")
|
|
37216
|
+
throw new TypeError("a {captureId, x, y} target needs numeric x and y image coordinates");
|
|
37206
37217
|
return { capture_id: spec.captureId, image_x: spec.x, image_y: spec.y };
|
|
37207
37218
|
}
|
|
37208
37219
|
}
|
|
37209
37220
|
throw new TypeError("target must be a ref ('e3' / '@e3'), a CSS selector, or {captureId, x, y}");
|
|
37210
37221
|
}
|
|
37211
|
-
function
|
|
37212
|
-
|
|
37222
|
+
function resolveElementTarget(target) {
|
|
37223
|
+
const element = elementTarget(target);
|
|
37224
|
+
if (element)
|
|
37225
|
+
return element;
|
|
37226
|
+
throw new TypeError("target must be a ref ('e3' / '@e3') or a CSS selector");
|
|
37227
|
+
}
|
|
37228
|
+
function optionalElementTarget(target) {
|
|
37229
|
+
return target === undefined ? {} : resolveElementTarget(target);
|
|
37213
37230
|
}
|
|
37214
37231
|
function compact(params) {
|
|
37215
37232
|
const out = {};
|
|
@@ -37219,13 +37236,22 @@ function compact(params) {
|
|
|
37219
37236
|
return out;
|
|
37220
37237
|
}
|
|
37221
37238
|
|
|
37239
|
+
// src/bsk/shared-tab.ts
|
|
37240
|
+
function sharedTab({ context, observation, expect, dependsOn, ...unknown }) {
|
|
37241
|
+
const extra = Object.keys(unknown);
|
|
37242
|
+
if (extra.length > 0) {
|
|
37243
|
+
throw new TypeError(`unknown option ${extra.map((key) => JSON.stringify(key)).join(", ")}: a shared-tab action takes { context, observation, expect, dependsOn } besides its own options`);
|
|
37244
|
+
}
|
|
37245
|
+
return { context_id: context, observation_id: observation, expect, depends_on: dependsOn };
|
|
37246
|
+
}
|
|
37247
|
+
|
|
37222
37248
|
// src/bsk/screenshot.ts
|
|
37223
37249
|
function fromBase64(value, field) {
|
|
37224
37250
|
if (typeof value !== "string")
|
|
37225
37251
|
throw new TypeError(`${field} is not base64 text`);
|
|
37226
37252
|
return Buffer.from(value, "base64");
|
|
37227
37253
|
}
|
|
37228
|
-
async function captureScreenshot(session, { ref, tabId, fullPage = false, scope, timeoutMs,
|
|
37254
|
+
async function captureScreenshot(session, { ref, tabId, fullPage = false, scope, timeoutMs, ...shared } = {}) {
|
|
37229
37255
|
if (!fullPage) {
|
|
37230
37256
|
const result = await session.tool("screenshot", { ref, tab_id: tabId });
|
|
37231
37257
|
return {
|
|
@@ -37243,16 +37269,18 @@ async function captureScreenshot(session, { ref, tabId, fullPage = false, scope,
|
|
|
37243
37269
|
scope,
|
|
37244
37270
|
tab_id: tabId,
|
|
37245
37271
|
timeout_ms: timeoutMs,
|
|
37246
|
-
|
|
37247
|
-
depends_on: dependsOn
|
|
37272
|
+
...sharedTab(shared)
|
|
37248
37273
|
});
|
|
37249
|
-
const
|
|
37274
|
+
const captureId = readProperty(started, "capture_id");
|
|
37275
|
+
if (typeof captureId !== "string")
|
|
37276
|
+
throw new TypeError("screenshot_full_page returned no capture_id");
|
|
37277
|
+
const buffer = await readCapture(session, captureId, readProperty(started, "byte_size"));
|
|
37250
37278
|
return {
|
|
37251
37279
|
buffer,
|
|
37252
37280
|
width: readProperty(started, "width"),
|
|
37253
37281
|
height: readProperty(started, "height"),
|
|
37254
37282
|
format: readProperty(started, "format"),
|
|
37255
|
-
captureId
|
|
37283
|
+
captureId,
|
|
37256
37284
|
scope: readProperty(started, "scope") ?? scope ?? null,
|
|
37257
37285
|
tabId: readProperty(started, "tab_id"),
|
|
37258
37286
|
dialogs: readProperty(started, "dialogs") ?? []
|
|
@@ -37283,19 +37311,85 @@ async function readCapture(session, captureId, byteSize) {
|
|
|
37283
37311
|
return buffer;
|
|
37284
37312
|
}
|
|
37285
37313
|
|
|
37314
|
+
// src/bsk/first-navigate.ts
|
|
37315
|
+
var BOOTSTRAP_REFUSAL = "The initial task tab changed; synchronize before acting";
|
|
37316
|
+
var BOOTSTRAP_SETTLE_TIMEOUT_MS = 1e4;
|
|
37317
|
+
var INITIAL_BLANK_URLS = new Set(["", "about:blank"]);
|
|
37318
|
+
function isBootstrapRefusal(error) {
|
|
37319
|
+
return error instanceof BskRpcError && error.code === "permission_denied" && error.message === BOOTSTRAP_REFUSAL && optionalProperty(error.data, "reason") === "cooperation_sync_required" && optionalProperty(error.data, "effect_state") === "none";
|
|
37320
|
+
}
|
|
37321
|
+
function taskTab(tabs, tabId) {
|
|
37322
|
+
const list = listOrEmpty(readProperty(tabs, "tabs"), "tab_list tabs");
|
|
37323
|
+
return tabId === undefined ? list.find((tab) => optionalProperty(tab, "active") === true) : list.find((tab) => optionalProperty(tab, "tab_id") === tabId);
|
|
37324
|
+
}
|
|
37325
|
+
async function settleInitialTab(session, refusal, tabId) {
|
|
37326
|
+
const waited = await session.waitForNavigation({
|
|
37327
|
+
...tabId === undefined ? {} : { tabId },
|
|
37328
|
+
waitUntil: "load",
|
|
37329
|
+
timeoutMs: BOOTSTRAP_SETTLE_TIMEOUT_MS
|
|
37330
|
+
});
|
|
37331
|
+
const reached = optionalProperty(waited, "reached");
|
|
37332
|
+
const tab = taskTab(await session.tabList({ scope: "agent" }), tabId);
|
|
37333
|
+
const url = optionalProperty(tab, "url");
|
|
37334
|
+
if (reached === "load" && INITIAL_BLANK_URLS.has(url))
|
|
37335
|
+
return;
|
|
37336
|
+
const where = tab === undefined ? "no task tab is listed" : `tab ${String(optionalProperty(tab, "tab_id"))} is at ${url === "" ? "(no URL yet)" : String(url)}`;
|
|
37337
|
+
throw new BskRpcError(refusal.code, `${refusal.message}: the first navigate was refused before the task tab settled, and it was not sent again because wait_for_navigation reached ${JSON.stringify(reached)} and ${where}`, refusal.data);
|
|
37338
|
+
}
|
|
37339
|
+
|
|
37340
|
+
// src/bsk/dom-reads.ts
|
|
37341
|
+
function readNodes(session, target, { fields, maxNodes, maxBytes, tabId, timeoutMs, context } = {}) {
|
|
37342
|
+
return session.tool("read", {
|
|
37343
|
+
...optionalElementTarget(target),
|
|
37344
|
+
fields,
|
|
37345
|
+
max_nodes: maxNodes,
|
|
37346
|
+
max_bytes: maxBytes,
|
|
37347
|
+
tab_id: tabId,
|
|
37348
|
+
timeout_ms: timeoutMs,
|
|
37349
|
+
context_id: context
|
|
37350
|
+
});
|
|
37351
|
+
}
|
|
37352
|
+
function extractItems(session, action, { target, itemSelector, fields, maxRows, maxColumns, maxBytes, targetId, tabId, timeoutMs } = {}) {
|
|
37353
|
+
return session.tool("extract", {
|
|
37354
|
+
action,
|
|
37355
|
+
...optionalElementTarget(target),
|
|
37356
|
+
item_selector: itemSelector,
|
|
37357
|
+
fields,
|
|
37358
|
+
max_rows: maxRows,
|
|
37359
|
+
max_columns: maxColumns,
|
|
37360
|
+
max_bytes: maxBytes,
|
|
37361
|
+
target_id: targetId,
|
|
37362
|
+
tab_id: tabId,
|
|
37363
|
+
timeout_ms: timeoutMs
|
|
37364
|
+
});
|
|
37365
|
+
}
|
|
37366
|
+
function waitForElement(session, target, { state, pollMs, tabId, timeoutMs }) {
|
|
37367
|
+
return session.tool("wait_for_element", {
|
|
37368
|
+
...resolveElementTarget(target),
|
|
37369
|
+
state,
|
|
37370
|
+
poll_ms: pollMs,
|
|
37371
|
+
tab_id: tabId,
|
|
37372
|
+
timeout_ms: timeoutMs
|
|
37373
|
+
});
|
|
37374
|
+
}
|
|
37375
|
+
|
|
37286
37376
|
// src/bsk/session.ts
|
|
37287
37377
|
var SESSION_STOP_TIMEOUT_MS = 3600000;
|
|
37288
|
-
|
|
37289
|
-
|
|
37290
|
-
|
|
37291
|
-
|
|
37292
|
-
|
|
37293
|
-
|
|
37378
|
+
var text = (value) => typeof value === "string" ? value : undefined;
|
|
37379
|
+
function cooperateReply(reply) {
|
|
37380
|
+
const fields = typeof reply === "object" && reply !== null ? reply : {};
|
|
37381
|
+
const nested = optionalProperty(optionalProperty(reply, "observation"), "observation_id");
|
|
37382
|
+
return {
|
|
37383
|
+
...fields,
|
|
37384
|
+
context_id: text(optionalProperty(reply, "context_id")),
|
|
37385
|
+
observation_id: text(optionalProperty(reply, "observation_id")) ?? text(nested)
|
|
37386
|
+
};
|
|
37294
37387
|
}
|
|
37295
37388
|
|
|
37296
37389
|
class BskSession {
|
|
37297
37390
|
#client;
|
|
37298
37391
|
#stopped = false;
|
|
37392
|
+
#acted = false;
|
|
37299
37393
|
constructor(client, { sessionId, browserInstanceId = null, agentWindowId = null, interaction = null } = {}) {
|
|
37300
37394
|
if (typeof sessionId !== "string" || sessionId.length === 0)
|
|
37301
37395
|
throw new TypeError("BskSession requires a sessionId");
|
|
@@ -37311,6 +37405,14 @@ class BskSession {
|
|
|
37311
37405
|
get stopped() {
|
|
37312
37406
|
return this.#stopped;
|
|
37313
37407
|
}
|
|
37408
|
+
#call(name, params) {
|
|
37409
|
+
return this.tool(name, params);
|
|
37410
|
+
}
|
|
37411
|
+
#act(name, params, shared) {
|
|
37412
|
+
const wire = { ...params, ...sharedTab(shared) };
|
|
37413
|
+
this.#acted = true;
|
|
37414
|
+
return this.tool(name, wire);
|
|
37415
|
+
}
|
|
37314
37416
|
tool(name, params = {}) {
|
|
37315
37417
|
if (this.#stopped)
|
|
37316
37418
|
return Promise.reject(new Error(`BrowserSkill session ${this.sessionId} is stopped`));
|
|
@@ -37318,37 +37420,41 @@ class BskSession {
|
|
|
37318
37420
|
idPrefix: name.replace(/_/g, "-")
|
|
37319
37421
|
});
|
|
37320
37422
|
}
|
|
37321
|
-
cooperate(action, {
|
|
37322
|
-
|
|
37423
|
+
cooperate(action, {
|
|
37424
|
+
tabId,
|
|
37425
|
+
timeoutMs,
|
|
37426
|
+
maxTokens,
|
|
37427
|
+
controlPolicy
|
|
37428
|
+
} = {}) {
|
|
37429
|
+
return this.#call("cooperate", {
|
|
37430
|
+
action,
|
|
37431
|
+
tab_id: tabId,
|
|
37432
|
+
timeout_ms: timeoutMs,
|
|
37433
|
+
max_tokens: maxTokens,
|
|
37434
|
+
control_policy: controlPolicy
|
|
37435
|
+
}).then(cooperateReply, (error) => {
|
|
37323
37436
|
if (error instanceof BskRpcError && error.code === "unknown_method")
|
|
37324
|
-
return { context_id: undefined, supported: false, ready: true };
|
|
37437
|
+
return { context_id: undefined, observation_id: undefined, supported: false, ready: true };
|
|
37325
37438
|
throw error;
|
|
37326
37439
|
});
|
|
37327
37440
|
}
|
|
37328
|
-
navigate(url, { tabId, waitUntil, timeoutMs, ...shared } = {}) {
|
|
37329
|
-
|
|
37330
|
-
|
|
37331
|
-
|
|
37332
|
-
|
|
37333
|
-
|
|
37334
|
-
|
|
37335
|
-
|
|
37441
|
+
async navigate(url, { tabId, waitUntil, timeoutMs, ...shared } = {}) {
|
|
37442
|
+
const send = () => this.#act("navigate", { url, tab_id: tabId, wait_until: waitUntil, timeout_ms: timeoutMs }, shared);
|
|
37443
|
+
const first = !this.#acted && shared.context === undefined;
|
|
37444
|
+
try {
|
|
37445
|
+
return await send();
|
|
37446
|
+
} catch (error) {
|
|
37447
|
+
if (!first || !isBootstrapRefusal(error))
|
|
37448
|
+
throw error;
|
|
37449
|
+
await settleInitialTab(this, error, tabId);
|
|
37450
|
+
return send();
|
|
37451
|
+
}
|
|
37336
37452
|
}
|
|
37337
37453
|
back({ tabId, waitUntil, timeoutMs, ...shared } = {}) {
|
|
37338
|
-
return this
|
|
37339
|
-
tab_id: tabId,
|
|
37340
|
-
wait_until: waitUntil,
|
|
37341
|
-
timeout_ms: timeoutMs,
|
|
37342
|
-
...sharedTab(shared)
|
|
37343
|
-
});
|
|
37454
|
+
return this.#act("navigate_back", { tab_id: tabId, wait_until: waitUntil, timeout_ms: timeoutMs }, shared);
|
|
37344
37455
|
}
|
|
37345
37456
|
forward({ tabId, waitUntil, timeoutMs, ...shared } = {}) {
|
|
37346
|
-
return this
|
|
37347
|
-
tab_id: tabId,
|
|
37348
|
-
wait_until: waitUntil,
|
|
37349
|
-
timeout_ms: timeoutMs,
|
|
37350
|
-
...sharedTab(shared)
|
|
37351
|
-
});
|
|
37457
|
+
return this.#act("navigate_forward", { tab_id: tabId, wait_until: waitUntil, timeout_ms: timeoutMs }, shared);
|
|
37352
37458
|
}
|
|
37353
37459
|
reload({
|
|
37354
37460
|
tabId,
|
|
@@ -37357,13 +37463,7 @@ class BskSession {
|
|
|
37357
37463
|
hard,
|
|
37358
37464
|
...shared
|
|
37359
37465
|
} = {}) {
|
|
37360
|
-
return this
|
|
37361
|
-
tab_id: tabId,
|
|
37362
|
-
wait_until: waitUntil,
|
|
37363
|
-
timeout_ms: timeoutMs,
|
|
37364
|
-
hard,
|
|
37365
|
-
...sharedTab(shared)
|
|
37366
|
-
});
|
|
37466
|
+
return this.#act("reload", { tab_id: tabId, wait_until: waitUntil, timeout_ms: timeoutMs, hard }, shared);
|
|
37367
37467
|
}
|
|
37368
37468
|
observe({
|
|
37369
37469
|
cursor,
|
|
@@ -37374,25 +37474,24 @@ class BskSession {
|
|
|
37374
37474
|
probeHover,
|
|
37375
37475
|
...shared
|
|
37376
37476
|
} = {}) {
|
|
37377
|
-
return this
|
|
37477
|
+
return this.#act("observe", {
|
|
37378
37478
|
cursor,
|
|
37379
37479
|
tab_id: tabId,
|
|
37380
37480
|
max_depth: maxDepth,
|
|
37381
37481
|
max_tokens: maxTokens,
|
|
37382
37482
|
debug_surfaces: debugSurfaces,
|
|
37383
|
-
probe_hover: probeHover
|
|
37384
|
-
|
|
37385
|
-
});
|
|
37483
|
+
probe_hover: probeHover
|
|
37484
|
+
}, shared);
|
|
37386
37485
|
}
|
|
37387
37486
|
snapshot({
|
|
37388
37487
|
tabId,
|
|
37389
37488
|
maxDepth,
|
|
37390
37489
|
maxTokens
|
|
37391
37490
|
} = {}) {
|
|
37392
|
-
return this
|
|
37491
|
+
return this.#call("snapshot", { tab_id: tabId, max_depth: maxDepth, max_tokens: maxTokens });
|
|
37393
37492
|
}
|
|
37394
37493
|
getHtml({ ref, tabId, maxBytes } = {}) {
|
|
37395
|
-
return this
|
|
37494
|
+
return this.#call("get_html", { ref, tab_id: tabId, max_bytes: maxBytes });
|
|
37396
37495
|
}
|
|
37397
37496
|
screenshot(options) {
|
|
37398
37497
|
return captureScreenshot(this, options);
|
|
@@ -37405,15 +37504,7 @@ class BskSession {
|
|
|
37405
37504
|
timeoutMs,
|
|
37406
37505
|
...shared
|
|
37407
37506
|
} = {}) {
|
|
37408
|
-
return this
|
|
37409
|
-
...resolveTarget(target),
|
|
37410
|
-
button,
|
|
37411
|
-
click_count: clickCount,
|
|
37412
|
-
modifiers,
|
|
37413
|
-
tab_id: tabId,
|
|
37414
|
-
timeout_ms: timeoutMs,
|
|
37415
|
-
...sharedTab(shared)
|
|
37416
|
-
});
|
|
37507
|
+
return this.#act("click", { ...resolveTarget(target), button, click_count: clickCount, modifiers, tab_id: tabId, timeout_ms: timeoutMs }, shared);
|
|
37417
37508
|
}
|
|
37418
37509
|
hover(target, {
|
|
37419
37510
|
modifiers,
|
|
@@ -37422,30 +37513,16 @@ class BskSession {
|
|
|
37422
37513
|
timeoutMs,
|
|
37423
37514
|
...shared
|
|
37424
37515
|
} = {}) {
|
|
37425
|
-
return this
|
|
37426
|
-
...resolveTarget(target),
|
|
37427
|
-
modifiers,
|
|
37428
|
-
settle_ms: settleMs,
|
|
37429
|
-
tab_id: tabId,
|
|
37430
|
-
timeout_ms: timeoutMs,
|
|
37431
|
-
...sharedTab(shared)
|
|
37432
|
-
});
|
|
37516
|
+
return this.#act("hover", { ...resolveElementTarget(target), modifiers, settle_ms: settleMs, tab_id: tabId, timeout_ms: timeoutMs }, shared);
|
|
37433
37517
|
}
|
|
37434
37518
|
focus(target, { tabId, timeoutMs, ...shared } = {}) {
|
|
37435
|
-
return this
|
|
37519
|
+
return this.#act("focus", { ...resolveElementTarget(target), tab_id: tabId, timeout_ms: timeoutMs }, shared);
|
|
37436
37520
|
}
|
|
37437
37521
|
blur(target, { tabId, timeoutMs, ...shared } = {}) {
|
|
37438
|
-
return this
|
|
37522
|
+
return this.#act("blur", { ...resolveElementTarget(target), tab_id: tabId, timeout_ms: timeoutMs }, shared);
|
|
37439
37523
|
}
|
|
37440
37524
|
fill(target, value, { clearBefore, tabId, timeoutMs, ...shared } = {}) {
|
|
37441
|
-
return this
|
|
37442
|
-
...resolveTarget(target),
|
|
37443
|
-
value,
|
|
37444
|
-
clear_before: clearBefore,
|
|
37445
|
-
tab_id: tabId,
|
|
37446
|
-
timeout_ms: timeoutMs,
|
|
37447
|
-
...sharedTab(shared)
|
|
37448
|
-
}).catch((error) => {
|
|
37525
|
+
return this.#act("fill", { ...resolveElementTarget(target), value, clear_before: clearBefore, tab_id: tabId, timeout_ms: timeoutMs }, shared).catch((error) => {
|
|
37449
37526
|
throw redactValue(error, value);
|
|
37450
37527
|
});
|
|
37451
37528
|
}
|
|
@@ -37457,32 +37534,18 @@ class BskSession {
|
|
|
37457
37534
|
timeoutMs,
|
|
37458
37535
|
...shared
|
|
37459
37536
|
} = {}) {
|
|
37460
|
-
return this
|
|
37461
|
-
key,
|
|
37462
|
-
...optionalTarget(target),
|
|
37463
|
-
modifiers,
|
|
37464
|
-
hold_ms: holdMs,
|
|
37465
|
-
tab_id: tabId,
|
|
37466
|
-
timeout_ms: timeoutMs,
|
|
37467
|
-
...sharedTab(shared)
|
|
37468
|
-
});
|
|
37537
|
+
return this.#act("press", { key, ...optionalElementTarget(target), modifiers, hold_ms: holdMs, tab_id: tabId, timeout_ms: timeoutMs }, shared);
|
|
37469
37538
|
}
|
|
37470
37539
|
select(target, values, { tabId, timeoutMs, ...shared } = {}) {
|
|
37471
|
-
return this
|
|
37472
|
-
...
|
|
37540
|
+
return this.#act("select", {
|
|
37541
|
+
...resolveElementTarget(target),
|
|
37473
37542
|
values: Array.isArray(values) ? values : [values],
|
|
37474
37543
|
tab_id: tabId,
|
|
37475
|
-
timeout_ms: timeoutMs
|
|
37476
|
-
|
|
37477
|
-
});
|
|
37544
|
+
timeout_ms: timeoutMs
|
|
37545
|
+
}, shared);
|
|
37478
37546
|
}
|
|
37479
37547
|
scrollTo(target, { tabId, timeoutMs, ...shared } = {}) {
|
|
37480
|
-
return this
|
|
37481
|
-
...resolveTarget(target),
|
|
37482
|
-
tab_id: tabId,
|
|
37483
|
-
timeout_ms: timeoutMs,
|
|
37484
|
-
...sharedTab(shared)
|
|
37485
|
-
});
|
|
37548
|
+
return this.#act("scroll_to", { ...resolveElementTarget(target), tab_id: tabId, timeout_ms: timeoutMs }, shared);
|
|
37486
37549
|
}
|
|
37487
37550
|
wheel({
|
|
37488
37551
|
deltaX = 0,
|
|
@@ -37493,50 +37556,83 @@ class BskSession {
|
|
|
37493
37556
|
timeoutMs,
|
|
37494
37557
|
...shared
|
|
37495
37558
|
} = {}) {
|
|
37496
|
-
return this
|
|
37497
|
-
...
|
|
37559
|
+
return this.#act("wheel", {
|
|
37560
|
+
...optionalElementTarget(target),
|
|
37498
37561
|
delta_x: deltaX,
|
|
37499
37562
|
delta_y: deltaY,
|
|
37500
37563
|
modifiers,
|
|
37501
37564
|
tab_id: tabId,
|
|
37502
|
-
timeout_ms: timeoutMs
|
|
37503
|
-
|
|
37504
|
-
});
|
|
37565
|
+
timeout_ms: timeoutMs
|
|
37566
|
+
}, shared);
|
|
37505
37567
|
}
|
|
37506
|
-
evaluate(expression, { tabId, awaitPromise, returnByValue, timeoutMs, ...shared } = {}) {
|
|
37507
|
-
return this
|
|
37568
|
+
evaluate(expression, { tabId, awaitPromise, returnByValue, timeoutMs, unverified, ...shared } = {}) {
|
|
37569
|
+
return this.#act("evaluate", {
|
|
37508
37570
|
expression,
|
|
37509
37571
|
tab_id: tabId,
|
|
37510
37572
|
await_promise: awaitPromise,
|
|
37511
37573
|
return_by_value: returnByValue,
|
|
37512
37574
|
timeout_ms: timeoutMs,
|
|
37513
|
-
|
|
37514
|
-
});
|
|
37575
|
+
unverified
|
|
37576
|
+
}, shared);
|
|
37577
|
+
}
|
|
37578
|
+
read(target, options) {
|
|
37579
|
+
return readNodes(this, target, options);
|
|
37580
|
+
}
|
|
37581
|
+
extract(action, options) {
|
|
37582
|
+
return extractItems(this, action, options);
|
|
37583
|
+
}
|
|
37584
|
+
waitForElement(target, options) {
|
|
37585
|
+
return waitForElement(this, target, options);
|
|
37586
|
+
}
|
|
37587
|
+
drag(source, {
|
|
37588
|
+
target,
|
|
37589
|
+
delta,
|
|
37590
|
+
mode,
|
|
37591
|
+
button,
|
|
37592
|
+
durationMs,
|
|
37593
|
+
holdMs,
|
|
37594
|
+
modifiers,
|
|
37595
|
+
tabId,
|
|
37596
|
+
timeoutMs,
|
|
37597
|
+
...shared
|
|
37598
|
+
} = {}) {
|
|
37599
|
+
return this.#act("drag", {
|
|
37600
|
+
source,
|
|
37601
|
+
target,
|
|
37602
|
+
delta,
|
|
37603
|
+
mode,
|
|
37604
|
+
button,
|
|
37605
|
+
duration_ms: durationMs,
|
|
37606
|
+
hold_ms: holdMs,
|
|
37607
|
+
modifiers,
|
|
37608
|
+
tab_id: tabId,
|
|
37609
|
+
timeout_ms: timeoutMs
|
|
37610
|
+
}, shared);
|
|
37515
37611
|
}
|
|
37516
37612
|
tabList({ scope } = {}) {
|
|
37517
|
-
return this
|
|
37613
|
+
return this.#call("tab_list", { scope });
|
|
37518
37614
|
}
|
|
37519
37615
|
tabCreate({ url, active, index } = {}) {
|
|
37520
|
-
return this
|
|
37616
|
+
return this.#call("tab_create", { url, active, index });
|
|
37521
37617
|
}
|
|
37522
37618
|
tabClose(tabId, shared = {}) {
|
|
37523
|
-
return this
|
|
37619
|
+
return this.#act("tab_close", { tab_id: tabId }, shared);
|
|
37524
37620
|
}
|
|
37525
37621
|
tabSelect(tabId) {
|
|
37526
|
-
return this
|
|
37622
|
+
return this.#call("tab_select", { tab_id: tabId });
|
|
37527
37623
|
}
|
|
37528
37624
|
tabBorrow(tabId, { confirmationTimeoutMs } = {}) {
|
|
37529
|
-
return this
|
|
37625
|
+
return this.#call("tab_borrow", { tab_id: tabId, confirmation_timeout_ms: confirmationTimeoutMs });
|
|
37530
37626
|
}
|
|
37531
37627
|
tabReturn(tabId) {
|
|
37532
|
-
return this
|
|
37628
|
+
return this.#call("tab_return", { tab_id: tabId });
|
|
37533
37629
|
}
|
|
37534
37630
|
waitForNavigation({
|
|
37535
37631
|
tabId,
|
|
37536
37632
|
waitUntil,
|
|
37537
37633
|
timeoutMs
|
|
37538
37634
|
} = {}) {
|
|
37539
|
-
return this
|
|
37635
|
+
return this.#call("wait_for_navigation", { tab_id: tabId, wait_until: waitUntil, timeout_ms: timeoutMs });
|
|
37540
37636
|
}
|
|
37541
37637
|
requestHelp({
|
|
37542
37638
|
prompt,
|
|
@@ -37545,13 +37641,13 @@ class BskSession {
|
|
|
37545
37641
|
completionCriteria,
|
|
37546
37642
|
tabId,
|
|
37547
37643
|
timeoutMs
|
|
37548
|
-
}
|
|
37549
|
-
return this
|
|
37644
|
+
}) {
|
|
37645
|
+
return this.#call("request_help", {
|
|
37550
37646
|
prompt,
|
|
37551
37647
|
title,
|
|
37552
37648
|
tab_id: tabId,
|
|
37553
37649
|
timeout_ms: timeoutMs,
|
|
37554
|
-
targets: targets?.map((t) =>
|
|
37650
|
+
targets: targets?.map((t) => resolveElementTarget(t)),
|
|
37555
37651
|
completion_criteria: completionCriteria
|
|
37556
37652
|
});
|
|
37557
37653
|
}
|
|
@@ -37562,7 +37658,7 @@ class BskSession {
|
|
|
37562
37658
|
maxTextChars,
|
|
37563
37659
|
includeStack
|
|
37564
37660
|
} = {}) {
|
|
37565
|
-
return this
|
|
37661
|
+
return this.#call("console", {
|
|
37566
37662
|
tab_id: tabId,
|
|
37567
37663
|
since,
|
|
37568
37664
|
limit,
|
|
@@ -37576,10 +37672,10 @@ class BskSession {
|
|
|
37576
37672
|
limit,
|
|
37577
37673
|
maxTextChars
|
|
37578
37674
|
} = {}) {
|
|
37579
|
-
return this
|
|
37675
|
+
return this.#call("network", { tab_id: tabId, since, limit, max_text_chars: maxTextChars });
|
|
37580
37676
|
}
|
|
37581
37677
|
resize(width, height, shared = {}) {
|
|
37582
|
-
return this
|
|
37678
|
+
return this.#act("window_resize", { width, height }, shared);
|
|
37583
37679
|
}
|
|
37584
37680
|
emulate({
|
|
37585
37681
|
tabId,
|
|
@@ -37587,7 +37683,7 @@ class BskSession {
|
|
|
37587
37683
|
overrides,
|
|
37588
37684
|
...shared
|
|
37589
37685
|
} = {}) {
|
|
37590
|
-
return this
|
|
37686
|
+
return this.#act("emulate", { tab_id: tabId, off, overrides }, shared);
|
|
37591
37687
|
}
|
|
37592
37688
|
async stop() {
|
|
37593
37689
|
if (this.#stopped)
|
|
@@ -37753,11 +37849,13 @@ function buildSnapshotExpression(options = {}) {
|
|
|
37753
37849
|
return { tree: result.tree, refs: result.refs || {}, css, error: result.error };
|
|
37754
37850
|
})()`;
|
|
37755
37851
|
}
|
|
37756
|
-
async function bskSnapshot(session, { tabId, timeoutMs, context, dependsOn, ...snapshotOptions } = {}) {
|
|
37852
|
+
async function bskSnapshot(session, { tabId, timeoutMs, context, observation, expect, dependsOn, ...snapshotOptions } = {}) {
|
|
37757
37853
|
const reply = await session.evaluate(buildSnapshotExpression(snapshotOptions), {
|
|
37758
37854
|
tabId,
|
|
37759
37855
|
timeoutMs,
|
|
37760
37856
|
context,
|
|
37857
|
+
observation,
|
|
37858
|
+
expect,
|
|
37761
37859
|
dependsOn,
|
|
37762
37860
|
awaitPromise: false,
|
|
37763
37861
|
returnByValue: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omowright",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "OmOWright browser automation for standard Chromium CDP endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility-snapshot",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"test:cloak-profile": "bun test test/cloak-profile.test.ts test/cloak-profile.integration.test.ts",
|
|
52
52
|
"typecheck": "bun check --no-script --no-pretty -p tsconfig.json",
|
|
53
53
|
"typecheck:control": "bun scripts/typecheck-control.ts",
|
|
54
|
-
"check": "bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
|
|
54
|
+
"check": "bun scripts/bsk-protocol.ts --check && bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
|
|
55
55
|
"lint": "oxlint --deny-warnings src bin bridge test scripts && bun scripts/lint-ratchet.ts",
|
|
56
56
|
"lint:ratchet:update": "bun scripts/lint-ratchet.ts --update",
|
|
57
57
|
"lint:fix": "oxlint --fix src bin bridge test scripts",
|