@jackwener/browsermcp 0.0.39-embedded.0 → 0.0.39
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/CHANGELOG.md +2 -48
- package/README.md +6 -93
- package/dist/docs/api-reference.md +10 -3
- package/dist/docs/api-use.md +15 -3
- package/dist/docs/instructions.md +1 -1
- package/dist/src/api/browser.js +2 -0
- package/dist/src/api/browser.js.map +1 -1
- package/dist/src/api/content-wait.js +48 -0
- package/dist/src/api/content-wait.js.map +1 -0
- package/dist/src/api/tab.js +14 -2
- package/dist/src/api/tab.js.map +1 -1
- package/dist/src/backends/extension-page.js +2 -2
- package/dist/src/backends/extension-page.js.map +1 -1
- package/dist/src/docs/manifest.js +3 -6
- package/dist/src/docs/manifest.js.map +1 -1
- package/dist/src/protocol.js.map +1 -1
- package/dist/src/shared/aria-tree.js +7 -1
- package/dist/src/shared/aria-tree.js.map +1 -1
- package/dist/src/shared/closed-shadow.js +50 -0
- package/dist/src/shared/closed-shadow.js.map +1 -0
- package/dist/src/shared/engine.js +97 -30
- package/dist/src/shared/engine.js.map +1 -1
- package/dist/src/shared/inflight.js +50 -0
- package/dist/src/shared/inflight.js.map +1 -0
- package/dist/src/shared/injected-source.js +2 -2
- package/dist/src/shared/injected-source.js.map +1 -1
- package/docs/api-reference.md +10 -3
- package/docs/api-use.md +15 -3
- package/docs/instructions.md +1 -1
- package/extension/dist/background.js +195 -47
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/page.js +231 -35
- package/package.json +3 -12
- package/dist/src/api/action-input.d.ts +0 -87
- package/dist/src/api/agent.d.ts +0 -10
- package/dist/src/api/api.d.ts +0 -54
- package/dist/src/api/browser.d.ts +0 -93
- package/dist/src/api/commands.d.ts +0 -506
- package/dist/src/api/context.d.ts +0 -7
- package/dist/src/api/diff.d.ts +0 -8
- package/dist/src/api/errors.d.ts +0 -14
- package/dist/src/api/network.d.ts +0 -10
- package/dist/src/api/observation.d.ts +0 -4
- package/dist/src/api/streams.d.ts +0 -13
- package/dist/src/api/tab.d.ts +0 -319
- package/dist/src/api/webmcp.d.ts +0 -19
- package/dist/src/backends/backend.d.ts +0 -14
- package/dist/src/backends/browser-helpers.d.ts +0 -17
- package/dist/src/backends/extension-page.d.ts +0 -5
- package/dist/src/backends/managed-page.d.ts +0 -50
- package/dist/src/backends/page-transport.d.ts +0 -10
- package/dist/src/backends/page-types.d.ts +0 -82
- package/dist/src/docs/embedded.d.ts +0 -2
- package/dist/src/docs/embedded.js +0 -40
- package/dist/src/docs/embedded.js.map +0 -1
- package/dist/src/docs/manifest.d.ts +0 -23
- package/dist/src/docs/surface.d.ts +0 -12
- package/dist/src/electron/backend.d.ts +0 -50
- package/dist/src/electron/backend.js +0 -375
- package/dist/src/electron/backend.js.map +0 -1
- package/dist/src/electron/chrome.d.ts +0 -24
- package/dist/src/electron/chrome.js +0 -133
- package/dist/src/electron/chrome.js.map +0 -1
- package/dist/src/electron/driver.d.ts +0 -66
- package/dist/src/electron/driver.js +0 -294
- package/dist/src/electron/driver.js.map +0 -1
- package/dist/src/electron/event-buffer.d.ts +0 -16
- package/dist/src/electron/event-buffer.js +0 -59
- package/dist/src/electron/event-buffer.js.map +0 -1
- package/dist/src/electron/page.js +0 -834
- package/dist/src/electron/registry.d.ts +0 -104
- package/dist/src/electron/registry.js +0 -316
- package/dist/src/electron/registry.js.map +0 -1
- package/dist/src/electron/streams.d.ts +0 -16
- package/dist/src/electron/streams.js +0 -48
- package/dist/src/electron/streams.js.map +0 -1
- package/dist/src/embedded/index.d.ts +0 -39
- package/dist/src/embedded/index.js +0 -72
- package/dist/src/embedded/index.js.map +0 -1
- package/dist/src/host/bridge.d.ts +0 -50
- package/dist/src/host/doctor.d.ts +0 -34
- package/dist/src/host/extension.d.ts +0 -3
- package/dist/src/host/host.d.ts +0 -3
- package/dist/src/host/ipc.d.ts +0 -14
- package/dist/src/host/jsonc-config.d.ts +0 -1
- package/dist/src/host/launch.d.ts +0 -11
- package/dist/src/host/native-messaging.d.ts +0 -28
- package/dist/src/host/opencode.d.ts +0 -6
- package/dist/src/host/pi.d.ts +0 -6
- package/dist/src/host/registration.d.ts +0 -24
- package/dist/src/host/setup.d.ts +0 -7
- package/dist/src/host/socket.d.ts +0 -25
- package/dist/src/host/state.d.ts +0 -39
- package/dist/src/launcher/stdio.d.ts +0 -3
- package/dist/src/lib/paths.d.ts +0 -1
- package/dist/src/lib/sources.d.ts +0 -5
- package/dist/src/main.d.ts +0 -2
- package/dist/src/mcp/catalog.d.ts +0 -202
- package/dist/src/mcp/js-session.d.ts +0 -64
- package/dist/src/mcp/server.d.ts +0 -15
- package/dist/src/protocol.d.ts +0 -320
- package/dist/src/recon/analyzer.d.ts +0 -43
- package/dist/src/recon/discover.d.ts +0 -48
- package/dist/src/runtime/runtime.d.ts +0 -148
- package/dist/src/shared/api-contract.d.ts +0 -86
- package/dist/src/shared/aria-tree.d.ts +0 -2
- package/dist/src/shared/element-ref.d.ts +0 -4
- package/dist/src/shared/engine.d.ts +0 -50
- package/dist/src/shared/injected-source.d.ts +0 -2
- package/dist/src/shared/page-contract.d.ts +0 -256
- package/dist/src/sites/define.d.ts +0 -28
- package/dist/src/sites/drafts.d.ts +0 -39
- package/dist/src/sites/executor.d.ts +0 -34
- package/dist/src/sites/loader.d.ts +0 -101
- package/dist/src/sites/manifest.d.ts +0 -5
- package/dist/src/sites/schema.d.ts +0 -11
- package/dist/src/version.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,75 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.0.39
|
|
3
|
+
## 0.0.39 — 2026-11-11
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Improve browser Agent Experience: wait for page content after navigation, observe and act inside closed shadow roots, report action outcomes, return named ambiguity candidates, keep waiting for late targets, compact layout tables, hide closed details and transparent text, and expose empty fields and selection state. Includes Chrome extension 0.0.28 and updated release-gate coverage.
|
|
6
6
|
|
|
7
7
|
## 0.0.38 — 2026-11-09
|
|
8
8
|
|
|
9
9
|
Index built-in adapters from a build-generated manifest without importing command modules at startup or during search. Load a command module on execution. Validate manifest metadata and preserve live indexing for writable user adapters. Build, targeted checks, real Electron and installed ASAR verification completed before release.
|
|
10
10
|
|
|
11
|
-
## 0.0.38-embedded.0 — 2026-10-28
|
|
12
|
-
|
|
13
|
-
Includes stable 0.0.37 Agent Experience improvements: compact viewport observations and semantic pagination, navigation readiness via expect, explicit evaluate timeout outcomes, bounded error details, API signatures for recovery, and close receipts. Retains built-in adapter defaults and application-owned custom adapters.
|
|
14
|
-
|
|
15
11
|
## 0.0.37 — 2026-10-28
|
|
16
12
|
|
|
17
13
|
Improve Agent Experience across browser backends: compact viewport observations with explicit scope and semantic pagination; navigation readiness conditions shared with expect; explicit evaluation timeout outcomes and bounded error details; API signatures in unknown-method recovery; clear reading continuation and close receipts.
|
|
18
14
|
|
|
19
|
-
## 0.0.37-embedded.1 — 2026-10-28
|
|
20
|
-
|
|
21
|
-
Embedded adapters load from the packaged defaults and application-owned dataDir. MCP instructions expose loaded sites and the sites_search to site_run workflow. Activated custom adapters are immediately usable; externally edited adapters refresh on demand during command search. Clarify source overrides and packaging requirements.
|
|
22
|
-
|
|
23
|
-
## 0.0.37-embedded.0 — 2026-10-28
|
|
24
|
-
|
|
25
|
-
Load packaged site adapters by default in embedded applications while keeping custom adapters in application-owned dataDir. Surface loaded adapters and direct sites_search to site_run usage at agent initialization. Explicit sources replaces built-ins; sources: [] keeps application adapters only. Activated custom adapters are immediately available to existing sessions.
|
|
26
|
-
|
|
27
15
|
## 0.0.36 — 2026-10-28
|
|
28
16
|
|
|
29
17
|
Make existing site adapters discoverable at agent initialization: show loaded sites and command counts, document direct sites_search to site_run invocation without enabling, and clarify application-owned adapter storage.
|
|
30
18
|
|
|
31
|
-
## 0.0.36-embedded.0 — 2026-10-28
|
|
32
|
-
|
|
33
|
-
Includes stable 0.0.35 shared typed browser commands and helpers. navigate_tab reuses existing pages; close_tab is available through MCP and session.api.helper. Retained page handles stay usable until session closure.
|
|
34
|
-
|
|
35
19
|
## 0.0.35 — 2026-10-28
|
|
36
20
|
|
|
37
21
|
Add shared typed browser commands and session helpers, including navigate_tab and close_tab. Reuse existing tabs and preserve handoff handles. Protocol revision 5 requires extension 0.0.27 and a matching host.
|
|
38
22
|
|
|
39
|
-
## 0.0.35-embedded.0 — 2026-10-22
|
|
40
|
-
|
|
41
|
-
Includes stable 0.0.34 strict evaluation and lossless RPC contracts, shared tab discovery with scope/counts/pagination, and invalid-response detection. Fixes debugger cleanup after WebContents destruction. Verified with 31 tests, real Electron MCP flows and the installed npm package inside app.asar. openTabs now returns an envelope; read items.
|
|
42
|
-
|
|
43
23
|
## 0.0.34 — 2026-10-22
|
|
44
24
|
|
|
45
25
|
Enforce strict evaluate options and lossless REPL call transport. Separate user data from internal RPC references. Return explicit tab discovery scope, counts and pagination using shared backend contracts. Reject malformed backend responses. Protocol revision 4 requires updating host and extension together; read openTabs results from items.
|
|
46
26
|
|
|
47
|
-
## 0.0.34-embedded.3 — 2026-10-22
|
|
48
|
-
|
|
49
|
-
Host-owned logical tabs, lazy page registration, active-tab selection, session lifecycle events, and retention controls. Includes session-bound adapters and automatic npm publishing through GitHub Actions OIDC.
|
|
50
|
-
|
|
51
|
-
## 0.0.34-embedded.2 — 2026-10-22
|
|
52
|
-
|
|
53
|
-
- Preserve logical tab identity, session ownership and retention across WebContents replacement.
|
|
54
|
-
- Define host-owned create/load/close callbacks and explicit attach/detach lifecycle operations.
|
|
55
|
-
- Report structured host failures with recoverable tab state; protect cleanup against invalid keep entries.
|
|
56
|
-
- Add handle-based deliverable/handoff retention and safe local remote-method inspection.
|
|
57
|
-
- Verify background duplicate claims, host failure recovery and installed ASAR execution.
|
|
58
|
-
|
|
59
|
-
## 0.0.34-embedded.1 — 2026-10-21
|
|
60
|
-
|
|
61
|
-
- Model host tabs independently of WebContents, with stable logical IDs, explicit active selection, metadata updates and lazy loading.
|
|
62
|
-
- Expose typed host events and snapshots with public MCP session IDs; reserve ownership during loading and roll back or cancel failed/revoked claims.
|
|
63
|
-
- Unify tab state across MCP and Chrome APIs, and default MCP version to the installed package version.
|
|
64
|
-
- Migration: use registerPage handles and reported tabId values; tabId no longer equals webContents.id. Synchronize host selection with setActivePage(scope, handle).
|
|
65
|
-
- Share runtime isolation, storage injection, package version resolution and release infrastructure with main.
|
|
66
|
-
|
|
67
|
-
## 0.0.34-embedded.0 — 2026-10-21
|
|
68
|
-
|
|
69
|
-
- Add the embedded Electron SDK with host-owned storage, profiles and page lifecycle.
|
|
70
|
-
- Support MCP sessions, adapter creation and updates, Chrome API compatibility and CDP in embedded Chromium.
|
|
71
|
-
- Import @jackwener/browsermcp/embedded without CLI setup or a Chrome extension.
|
|
72
|
-
|
|
73
27
|
## 0.0.33 — 2026-10-20
|
|
74
28
|
|
|
75
29
|
- refactor: standardize BrowserMCP runtime names and simplify configuration
|
package/README.md
CHANGED
|
@@ -143,97 +143,6 @@ Site commands execute directly without additional approval prompts. The read/wri
|
|
|
143
143
|
| [Tab lifecycle](docs/tab-lifecycle.md) | Claiming tabs, grouping, and cleanup |
|
|
144
144
|
| [Errors](docs/errors.md) | Error codes and recovery |
|
|
145
145
|
|
|
146
|
-
## Embedded Electron applications
|
|
147
|
-
|
|
148
|
-
Import `@jackwener/browsermcp/embedded` from Electron's main process. This entry does not run setup, register Native Messaging, discover Chrome, read global CLI configuration, or install an extension. The application supplies its writable directory, profile sessions, and page lifecycle callbacks. Adapters can still be created, verified, activated, updated, and removed through `tools`.
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
import { app, BrowserWindow, session } from 'electron';
|
|
152
|
-
import path from 'node:path';
|
|
153
|
-
import { createEmbeddedBrowser } from '@jackwener/browsermcp/embedded';
|
|
154
|
-
|
|
155
|
-
await app.whenReady();
|
|
156
|
-
const windows = new Map<number, BrowserWindow>();
|
|
157
|
-
const profile = ({ profileId }) => session.fromPartition(`persist:${profileId}`);
|
|
158
|
-
const browser = await createEmbeddedBrowser({
|
|
159
|
-
dataDir: path.join(app.getPath('userData'), 'browsermcp'),
|
|
160
|
-
execution: 'trusted-node',
|
|
161
|
-
browser: {
|
|
162
|
-
profile,
|
|
163
|
-
async createPage(scope) {
|
|
164
|
-
const window = new BrowserWindow({
|
|
165
|
-
webPreferences: {
|
|
166
|
-
session: profile(scope), contextIsolation: true,
|
|
167
|
-
sandbox: true, nodeIntegration: false,
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
const id = window.webContents.id;
|
|
171
|
-
windows.set(id, window);
|
|
172
|
-
window.once('closed', () => windows.delete(id));
|
|
173
|
-
return { contents: window.webContents, close: async () => { window.destroy(); } };
|
|
174
|
-
},
|
|
175
|
-
async activatePage(contents) { windows.get(contents.id)?.show(); },
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// Scope comes from the application, not from agent-provided MCP arguments.
|
|
180
|
-
const connection = browser.createSession({ workspaceId: 'project-a', profileId: 'personal' });
|
|
181
|
-
await connection.server.connect(transport); // Any host-provided MCP SDK transport.
|
|
182
|
-
// On disconnect, cleanup is automatic. Explicit close and application shutdown:
|
|
183
|
-
await connection.close();
|
|
184
|
-
await browser.dispose();
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
The host owns logical tabs; a tab does not need a `WebContents` until it is claimed. Register restored tabs immediately, and synchronize selection from the host UI:
|
|
188
|
-
|
|
189
|
-
```ts
|
|
190
|
-
const scope = { workspaceId: 'workspace', profileId: 'personal' };
|
|
191
|
-
const handle = browser.registerPage({
|
|
192
|
-
scope,
|
|
193
|
-
url: restoredTab.url,
|
|
194
|
-
title: restoredTab.title,
|
|
195
|
-
load: async (signal) => {
|
|
196
|
-
// Resolve only once the restored tab has loaded; honor cancellation.
|
|
197
|
-
return hostTabs.ensureLoaded(restoredTab.id, { signal });
|
|
198
|
-
},
|
|
199
|
-
close: async () => { await hostTabs.close(restoredTab.id); },
|
|
200
|
-
});
|
|
201
|
-
browser.setActivePage(scope, handle); // Call on each host selection change.
|
|
202
|
-
browser.updatePage(handle, { url: restoredTab.url, title: restoredTab.title });
|
|
203
|
-
const unsubscribe = browser.subscribe((event) => {
|
|
204
|
-
// event.sessionId matches createSession().id, with no internal prefix.
|
|
205
|
-
// event.page.sessionId is the current owner; undefined after release.
|
|
206
|
-
hostTabs.setAgentOwner(event.page.handle, event.page.sessionId);
|
|
207
|
-
});
|
|
208
|
-
const snapshot = browser.getPages(scope); // Initialize/reconcile host UI.
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
`registerPage` takes a descriptor with `scope`, `url`, optional `title` / `contents` / `load(signal)`, and a required `close()` callback. For restored tabs, pass metadata and `load(signal)`; enumeration and matching do not trigger loading. A claim reserves exclusive ownership before loading, validates the resolved Electron profile, and returns only after loading succeeds. Failed loads return an unowned tab to the pool. Loading is cancelled on release, unregister, or session cleanup, and is bounded to 30 seconds. A host must honor the signal to prevent its own late side effects; BrowserMCP never attaches a result after access is revoked. WebContents destruction detaches the execution resource; the logical tab, ownership and retention remain intact. Use `attachPage(handle, contents)` to attach a replacement, or let `load(signal)` restore it on demand. `detachPage(handle)` explicitly detaches a resource. `close()` must close the logical host tab, including dormant tabs and tabs whose WebContents was replaced; bind it to the host tab identity, not an obsolete WebContents. Call `unregisterPage(handle)` when the logical host tab is removed.
|
|
212
|
-
|
|
213
|
-
**Identity contract:** the returned handle and the numeric `tabId` in `getPages()` / agent tab lists belong to BrowserMCP. `tabId` is not `webContents.id`. Use the handle to map to your host tab and use the reported `tabId` for Chrome-shaped calls. Both stay stable across loading and WebContents replacement. `webContentsId` identifies only the current execution resource. This changes the implicit `webContents.id` behavior in `0.0.34-embedded.0` and the original vendored branch.
|
|
214
|
-
|
|
215
|
-
`setActivePage(scope, handle | null)` is authoritative; keyboard focus is never used to infer the selected tab. Each workspace/profile has at most one active tab. `openTabs`, `claimTab({ active: true })`, owned-tab lists and `chrome.tabs.query` read the same registry state. `activatePage(contents)` implements agent-requested activation, after which the registry selection is updated. A zero-match claim reports `tab_not_found`; multiple matches report `ambiguous_tab`.
|
|
216
|
-
|
|
217
|
-
Host `subscribe()` emits typed snapshots for registration, metadata/lifecycle changes, activation, acquisition, release, navigation, closure and unregister. Acquisition is idempotent for the same session. Listener exceptions cannot break ownership transitions. Subscribe before taking `getPages(scope)` when initializing UI, and unsubscribe when disposing it. MCP version defaults to the installed BrowserMCP package version; explicit `version` remains available for bundled hosts.
|
|
218
|
-
|
|
219
|
-
The callbacks can manage `WebContentsView` instead of `BrowserWindow`; layout is entirely application-owned. Use `browser.registerPage({ scope, url, contents, close })` to make an existing user page available for claiming. Register only intended browser content, not application settings or privileged UI. `unregisterPage(handle)` revokes access without closing the page. User pages are released during cleanup; unkept agent pages are closed. Profile IDs must map to the intended Electron `Session`, and the backend checks this identity when registering/creating pages.
|
|
220
|
-
|
|
221
|
-
The current evaluator explicitly requires **trusted Node execution**. REPL and adapter modules can access Node capabilities; neither `vm`, a Worker, nor page registration is a sandbox against malicious host code. The REPL runs in a Worker; adapter modules execute in the runtime process. This main-process entry is for applications that trust the connected agent and loaded adapter code. Browser pages should retain `sandbox: true`, `contextIsolation: true`, and `nodeIntegration: false`.
|
|
222
|
-
|
|
223
|
-
Storage is confined by configuration: generated adapters are in `<dataDir>/adapters`, inactive candidates in `<dataDir>/drafts`, and a small standalone adapter SDK in `<dataDir>/node_modules`. No implicit `~/.browsermcp` or `~/.opencli-mcp` source is loaded. Built-in adapters load by default. Set `sources` to replace the read-only sources, or `sources: []` to use only application-owned adapters. Activated adapters in `<dataDir>/adapters` override these sources and become available to existing sessions immediately through `sites_search` and `site_run`. For files copied or edited externally, command searches recheck source file metadata and reload changed adapters on demand; no restart is required. Adapter code is shared within the service, while execution uses the caller's authorized profile and pages. No login credentials are copied between profiles.
|
|
224
|
-
|
|
225
|
-
`browser.chrome.call/describe/watch` remain available. Electron implements `tabs.query/get/create/update/remove/reload` and `cookies.getAll/get/set/remove`, plus session-scoped `tabs.onCreated/onUpdated/onRemoved/onActivated` events. Call `describe` for method availability and differences. Only registered, accessible tabs are returned; `windowId` is `-1` because window organization belongs to the host. Unsupported methods/options return `capability_unavailable`. Page-scoped CDP is available through `tab.cdp.send`; browser-wide `Target.*` and `Browser.*` commands are rejected. This is an explicit compatibility surface, not an emulation of every extension API.
|
|
226
|
-
|
|
227
|
-
Package the generated `dist`, `docs`, `adapters`, and `adapter-sdk` resources with the npm package. When using ASAR, unpack `**/js-*.mjs` so the REPL worker and evaluator remain loadable. Keep Electron as an application dependency; it is only a development dependency here. Call `dispose()` before quitting, await it, and handle cleanup failures; it is safe to retry. The SDK does not install process exit handlers or call `process.exit()`.
|
|
228
|
-
|
|
229
|
-
Validation:
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
npm run build:embedded # SDK and page resources; no extension build required
|
|
233
|
-
npm run smoke:embedded # real Electron + MCP, two profiles, adapter editing, cleanup
|
|
234
|
-
npm run smoke:embedded:package # installed npm package inside app.asar
|
|
235
|
-
```
|
|
236
|
-
|
|
237
146
|
## Development
|
|
238
147
|
|
|
239
148
|
```bash
|
|
@@ -249,10 +158,14 @@ npm run typecheck
|
|
|
249
158
|
npm run build:ext # rebuild the extension
|
|
250
159
|
npm test # core regression tests
|
|
251
160
|
npm run smoke:setup # isolated setup and Native Messaging end-to-end check
|
|
252
|
-
npm run smoke:
|
|
161
|
+
npm run smoke:feedback # real Chromium + extension: what an agent observes, does and verifies
|
|
162
|
+
npm run smoke:observation # real Chromium + extension: frames, shadow DOM, refs, reads, pagination
|
|
163
|
+
npm run smoke:native # real Chromium + extension through MCP, the REPL and the native bridge
|
|
253
164
|
```
|
|
254
165
|
|
|
255
|
-
|
|
166
|
+
The three real-browser checks need Chromium (`BROWSERMCP_TEST_CHROMIUM` to point at it) and run without a display with `BROWSERMCP_TEST_HEADLESS=1`.
|
|
167
|
+
|
|
168
|
+
Keep the automated suite focused on MCP browser flow, REPL persistence and interruption, connection recovery, session isolation, tab cleanup, and adapter execution. Prefer these integration checks over per-adapter mapping tests and implementation-detail assertions. Run the tests relevant to your change. `npm run check` runs typecheck, build, and the full test suite when a broader check is needed. For browser changes, run the three real-browser checks. `docs/api-reference.md` is generated during the build; update its TypeScript source rather than editing the generated file.
|
|
256
169
|
|
|
257
170
|
Maintainers: use the [release workflow](docs/releasing.md) to publish the npm package and GitHub Release.
|
|
258
171
|
|
|
@@ -9,12 +9,12 @@ interface AgentApi {
|
|
|
9
9
|
tabs_list(input: { query?: string | undefined; scope?: "unclaimed" | "all" | "session" | undefined; limit?: number | undefined; cursor?: string | undefined; }): Promise<{ snapshot: string; scope: "unclaimed" | "all" | "session"; excluded: string; nextCursor?: string; items: Array<Row>; total: number; complete: boolean; }>;
|
|
10
10
|
claim_tab(input: { backendId?: number | undefined; active?: true | undefined; url?: string | undefined; title?: string | undefined; expectedUrl?: string | undefined; expectedTitle?: string | undefined; }): Promise<{ tabId: string; }>;
|
|
11
11
|
open_tab(input: { url?: string | undefined; }): Promise<{ tabId: string; }>;
|
|
12
|
-
navigate_tab(input: { tabId: string; url: string; ready?: { target?: { ref?: string | number | undefined; selector?: string | undefined; within?: string | undefined; nth?: number | undefined; role?: string | undefined; name?: string | undefined; label?: string | undefined; text?: string | undefined; testid?: string | undefined; x?: number | undefined; y?: number | undefined; frame?: string | number | Array<string | number> | undefined; } | undefined; text?: string | undefined; notText?: string | undefined; url?: string | undefined; title?: string | undefined; visible?: boolean | undefined; value?: string | undefined; checked?: boolean | undefined; selected?: Array<string> | undefined; enabled?: boolean | undefined; } | undefined; timeoutMs?: number | undefined; waitUntil?: "load" | "none" | undefined; settleMs?: number | undefined; }): Promise<{ url: string | null; title: string | null; tabId: string; }>;
|
|
12
|
+
navigate_tab(input: { tabId: string; url: string; ready?: { target?: { ref?: string | number | undefined; selector?: string | undefined; within?: string | undefined; nth?: number | undefined; role?: string | undefined; name?: string | undefined; label?: string | undefined; text?: string | undefined; testid?: string | undefined; x?: number | undefined; y?: number | undefined; frame?: string | number | Array<string | number> | undefined; } | undefined; text?: string | undefined; notText?: string | undefined; url?: string | undefined; title?: string | undefined; visible?: boolean | undefined; value?: string | undefined; checked?: boolean | undefined; selected?: Array<string> | undefined; enabled?: boolean | undefined; } | undefined; timeoutMs?: number | undefined; waitUntil?: "load" | "none" | undefined; settleMs?: number | undefined; }): Promise<{ url: string | null; title: string | null; content?: "empty" | "placeholder"; tabId: string; }>;
|
|
13
13
|
close_tab(input: { tabId: string; }): Promise<{ tabId: string; closed: boolean; }>;
|
|
14
14
|
tabs_close(input: { tabIds: Array<string>; }): Promise<{ complete: boolean; results: Array<{ tabId: string; closed: boolean; } | { ok: false; error: Record<string, unknown>; tabId: string; closed: boolean; }>; }>;
|
|
15
15
|
release_tab(input: { tabId: string; }): Promise<{ tabId: string; released: boolean; }>;
|
|
16
16
|
tab_observe(input: { tabId: string; options?: { cursor?: string | undefined; mode?: "state" | "screenshot" | "both" | undefined; format?: "aria" | "dom" | undefined; target?: { ref?: string | number | undefined; selector?: string | undefined; within?: string | undefined; nth?: number | undefined; role?: string | undefined; name?: string | undefined; label?: string | undefined; text?: string | undefined; testid?: string | undefined; x?: number | undefined; y?: number | undefined; frame?: string | number | Array<string | number> | undefined; } | undefined; viewport?: boolean | undefined; includeFrames?: boolean | undefined; fullPage?: boolean | undefined; limit?: number | undefined; start?: number | undefined; } | undefined; }): Promise<{ scope?: "target" | "viewport" | "document"; complete?: boolean; webmcp?: PageToolsUpdate; nextCursor?: string; next?: { cursor: string; }; url: string | null; title: string | null; snapshotId?: string; image?: ImageValue; frames?: Array<ObservedFrame>; framesComplete?: boolean; metadataTruncated?: boolean; stateContinued?: boolean; stateContinues?: boolean; state?: string; dom?: DomSnapshot; warnings?: Array<string>; diff?: boolean; changed?: { added: number; removed: number; changed?: number; }; tabId: string; }>;
|
|
17
|
-
tab_act(input: { tabId: string; action: { [x: string]: unknown; }; }): Promise<{ action: ActAction; delivery: "applied" | "received" | "dispatched"; controlState: "verified" | "unverified"; network?: { afterSequence: number; cursor: number; }; matches_n?: number; navigated?: boolean; url?: string; title?: string; timedOut?: boolean; ref?: string; filled?: boolean; verified?: boolean; actual?: string; checked?: boolean; changed?: boolean; selected?: Array<string>; files?: number; openedTabs?: Array<{ tab?: string; tabId: number; url?: string; title?: string; pending?: true; }>; download?: { tab: string; afterSequence: number; started: Array<{ seq: number; guid?: string; url: string; suggestedFilename: string; }>; }; method?: "dom"; tabId: string; }>;
|
|
17
|
+
tab_act(input: { tabId: string; action: { [x: string]: unknown; }; }): Promise<{ action: ActAction; delivery: "applied" | "received" | "dispatched"; controlState: "verified" | "unverified"; network?: { afterSequence: number; cursor: number; }; effect?: "unknown" | "none" | "navigated" | "changed"; settled?: false; pendingRequests?: number; matches_n?: number; navigated?: boolean; url?: string; title?: string; timedOut?: boolean; ref?: string; filled?: boolean; verified?: boolean; actual?: string; checked?: boolean; changed?: boolean; selected?: Array<string>; files?: number; openedTabs?: Array<{ tab?: string; tabId: number; url?: string; title?: string; pending?: true; }>; download?: { tab: string; afterSequence: number; started: Array<{ seq: number; guid?: string; url: string; suggestedFilename: string; }>; }; method?: "dom"; tabId: string; }>;
|
|
18
18
|
};
|
|
19
19
|
agent: { browsers: { getDefault(): Promise<Browser>; }; browser: Browser; documentation: { get(name: string): Promise<string | null>; }; };
|
|
20
20
|
sites: Record<string, unknown> & { search(q: string, limit?: number): Promise<unknown>; list(): Promise<unknown>; enable(site: string, opts?: { write?: boolean; }): Promise<{ site: string; tools: Array<string>; }>; disable(site: string): Promise<boolean>; run(site: string, name: string, args?: Record<string, unknown>): Promise<unknown>; };
|
|
@@ -67,7 +67,8 @@ class Browser {
|
|
|
67
67
|
class Tab {
|
|
68
68
|
tabId?: number; // `id` is the stable backend page handle; `tabId` is the numeric backend id when claimed from a user tab.
|
|
69
69
|
id: string;
|
|
70
|
-
|
|
70
|
+
waitForContentOn(page: RuntimePage): Promise<ContentState>;
|
|
71
|
+
goto(url: string, opts?: { waitUntil?: "load" | "none"; settleMs?: number; ready?: Expectation; timeoutMs?: number; }): Promise<{ url: string | null; title: string | null; content?: "empty" | "placeholder"; }>; // Navigate and wait for the page's content, not only its load event. `content` is present when the page still had no text (`empty`) or only a loading placeholder (`placeholder`) after the bounded wait.
|
|
71
72
|
markDeliverable(): Promise<void>; // Preserve this tab for the user when the session is finalized.
|
|
72
73
|
markHandoff(): Promise<void>; // Preserve this tab for a subsequent turn; the same session handle remains usable after finalization.
|
|
73
74
|
clearRetention(): Promise<void>; // Restore default cleanup: close agent tabs, release borrowed user tabs.
|
|
@@ -133,6 +134,12 @@ interface ActionOutcome {
|
|
|
133
134
|
delivery: 'applied' | 'received' | 'dispatched';
|
|
134
135
|
controlState: 'verified' | 'unverified';
|
|
135
136
|
network?: { afterSequence: number; cursor: number };
|
|
137
|
+
/**
|
|
138
|
+
* What the page did in response, measured in the action's document (and the top document for a frame target):
|
|
139
|
+
* `navigated` (new document or URL), `changed` (DOM, form value or scroll changed), `none` (nothing changed: the
|
|
140
|
+
* input reached the page but it did not react), `unknown` (the page could not be read afterwards).
|
|
141
|
+
*/
|
|
142
|
+
effect?: 'navigated' | 'changed' | 'none' | 'unknown'; settled?: false; pendingRequests?: number;
|
|
136
143
|
matches_n?: number;
|
|
137
144
|
navigated?: boolean; url?: string; title?: string; timedOut?: boolean;
|
|
138
145
|
ref?: string; filled?: boolean; verified?: boolean; actual?: string;
|
package/dist/docs/api-use.md
CHANGED
|
@@ -15,11 +15,18 @@ await tab.expect({target, value:'42'});
|
|
|
15
15
|
|
|
16
16
|
The same target works in `observe({target})`, `find(target)`, `read({target})`, `act({target,...})` and `expect({target,...})`. Refs remember their observed frame automatically within this session and tab. Copy them unchanged. Surviving Elements retain their refs; replacement or navigation makes old refs stale. Never substitute a similarly named element automatically.
|
|
17
17
|
|
|
18
|
-
Semantic targets (`role/name`, `label`, `text`, `testid`, `selector`) resolve the current page. Add `frame` for an explicit iframe route and `within` for a container. Resolution is strict: multiple matches require exactly one visible match, or fail with `selector_ambiguous`. An explicit `nth` is supported when you have inspected the ordered candidates; the engine never silently chooses the first match.
|
|
18
|
+
Semantic targets (`role/name`, `label`, `text`, `testid`, `selector`) resolve the current page. Add `frame` for an explicit iframe route and `within` for a container. Resolution is strict: multiple matches require exactly one visible match, or fail with `selector_ambiguous`. The error lists each candidate's ref, role, name and region (`in form "Support"`, `in shadow root of <x-widget>`): act on one of those refs or scope with `within`. A locator that matches nothing on a page that has not changed for 2 s fails after about 0.5 s instead of the default 3 s; a page that just loaded or reacted keeps the full wait. Pass `timeoutMs` for content that renders later (a timer, a lazy panel): an explicit timeout is always waited out. An explicit `nth` is supported when you have inspected the ordered candidates; the engine never silently chooses the first match.
|
|
19
19
|
|
|
20
|
-
`act` waits for actionability, scrolls, hit-tests, dispatches input and settles
|
|
20
|
+
`act` waits for actionability, scrolls, hit-tests, dispatches input and settles: it returns once the page shows no change and no request the action started is in flight, or after `settleMs` (default 1000). Every outcome carries `effect`:
|
|
21
21
|
|
|
22
|
-
- `
|
|
22
|
+
- `navigated`: a new document or URL (`url` says where).
|
|
23
|
+
- `changed`: the DOM, a form value or the scroll position changed.
|
|
24
|
+
- `none`: the input reached the page and nothing changed. The control did not react: inspect it (disabled look, overlay, wrong target) before acting again; do not repeat the same action.
|
|
25
|
+
- `unknown`: the page could not be read afterwards.
|
|
26
|
+
|
|
27
|
+
`settled:false` with `pendingRequests` means the page was still loading when `act` returned; wait with `expect` rather than acting on a half-updated page. `changed` says the page reacted, not that the task succeeded. Verify the cheapest authoritative result:
|
|
28
|
+
|
|
29
|
+
- `expect({target})` waits for visibility. Elements with `opacity:0` are not visible, and their text is not page text: observations leave it out, `expect({text})` does not match it. A transparent native control (a styled checkbox) stays in observations because a click still reaches it.
|
|
23
30
|
- `expect({target, value:'42'})`, `{target, checked:true}`, `{target, selected:['id']}`, or `{target, enabled:true}` check control state. Multiple conditions must all hold.
|
|
24
31
|
- `expect({target, text:'Saved'})` checks text in that element; `{text:'Saved'}` checks the document.
|
|
25
32
|
- `expect({url:'/receipt'})` or `{title:'Receipt'}` checks the page. Keep page and element expectations separate.
|
|
@@ -30,6 +37,11 @@ Semantic targets (`role/name`, `label`, `text`, `testid`, `selector`) resolve th
|
|
|
30
37
|
## Choose the evidence needed
|
|
31
38
|
|
|
32
39
|
- `observe()` provides a compact viewport ARIA overview and child frames; use `{viewport:false}` for the rendered document. It is not full HTML. Keep headings, messages and surrounding context when choosing an action.
|
|
40
|
+
- `browser.tabs.new(url)` and `tab.goto(url)` return after the page shows content, not only after its load event: script-rendered text and "Loading…" placeholders get a few seconds. `goto` reports `content:'empty'` or `content:'placeholder'` when the page still had nothing to read; wait for the specific content with `expect` before concluding the page is empty.
|
|
41
|
+
- Controls inside closed shadow roots (payment fields, some design-system widgets) are observed and actionable like any other: refs, role/name locators and `expect` reach them. Page scripts still see those roots as closed.
|
|
42
|
+
- Observations and `read()` contain only rendered content: inactive tab panels hidden with `display:none` and transparent content are left out. In your own `tab.evaluate` code, `el.innerText` of a hidden element returns its full `textContent`, so filter with `el.checkVisibility({checkOpacity:true})` before extracting.
|
|
43
|
+
- Content of a closed `<details>` is not on screen: it is left out of observations and `read()`, and `expect` does not match it. Its `summary` line shows `[collapsed]` or `[expanded]`.
|
|
44
|
+
- Snapshot lines carry state the ARIA tree lacks: `[empty class="salary"]` marks a field that exists but shows no value (often withheld until login: the field is not missing); `[current=page]` comes from `aria-current`; `[selected? class="cur"]` marks the one sibling of a group (tab strip, panel set) that the page styles as selected without ARIA state. The `?` means it is inferred from class names: confirm it before relying on it.
|
|
33
45
|
- `observe({target})` expands a known branch. `observe({format:'dom'})` finds visible DOM controls and live values when ARIA lacks detail.
|
|
34
46
|
- `read({target})` reads exact current element text/attributes without scrolling. `read()` scans document text, including bounded scroll-and-read for lazy content, and restores scrolling.
|
|
35
47
|
- `find({query:'...'})` searches DOM evidence and returns candidate refs. `find({x,y})` connects screenshot coordinates to elements.
|
|
@@ -13,6 +13,6 @@ Start with `docs_get {}` for a short quickstart and available topics. For exact
|
|
|
13
13
|
- If ARIA misses a control, use `tab.observe({format:"dom"})` for visible DOM controls and live values; `tab.read({target:{ref}})` reads exact text/attributes. Refs automatically route to their observed frame. Reuse the same target for read, act and expect. Use a screenshot for visual meaning absent from DOM.
|
|
14
14
|
- Browser management uses `browser.chrome.call(method, argsArray)`; inspect signatures with `browser.chrome.describe(member)`. Page scripts use `tab.evaluate`, and Tab-level protocol calls use `tab.cdp.send`. Discover availability through `browser.capabilities.list()`.
|
|
15
15
|
- Batch already determined steps and data processing. Return new evidence when the next step needs model judgment. Await every API operation before returning.
|
|
16
|
-
-
|
|
16
|
+
- Read `effect` on every action outcome: `none` means the page did not react, so inspect instead of repeating it; `navigated`/`changed` mean it reacted, not that the task succeeded. Verify the cheapest authoritative result; inspect before retrying uncertain actions.
|
|
17
17
|
- Finish with `session_finish`, keeping only deliverable/handoff tabs. `js_reset` clears JavaScript bindings, closes explicit subscriptions and stops its worker; it does not close browser tabs. `doctor` reports connection and JavaScript execution status.
|
|
18
18
|
- To create an adapter, read `define-tools`, explore and verify its workflow, then use `tools.define`, `tools.try`, and `tools.activate` in `js`.
|
package/dist/src/api/browser.js
CHANGED
|
@@ -48,6 +48,8 @@ export class Browser {
|
|
|
48
48
|
await tab.close().catch(() => { });
|
|
49
49
|
throw new ActionError('page_not_loaded', `navigation to ${url} ended on ${landed}`, 'Another Chrome extension intercepted this site (redirect or interstitial); disable it for this site or open the page manually and claim the tab.');
|
|
50
50
|
}
|
|
51
|
+
// The first load of a script-rendered page has no content yet: an observe right after it would read nothing.
|
|
52
|
+
await tab.use(page => tab.waitForContentOn(page)).catch(() => { });
|
|
51
53
|
}
|
|
52
54
|
return tab;
|
|
53
55
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/api/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAqD,MAAM,2BAA2B,CAAC;AAMxI,OAAO,EAAE,cAAc,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AC,IAAY,EAAE,KAA+B,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;YAAC,CAAC;YACte,MAAM,IAAI,WAAW,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,GAAG,EAAE,6DAA6D,CAAC,CAAC;QACtI,CAAC;KACF,CAAC;IAEF,KAAK,CAAC,aAAa;QACjB,MAAM,GAAG,GAAe,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;QACrF,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;IACvI,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const INTERVAL_MS = 250;
|
|
2
|
+
const ENOUGH_CHARS = 1500;
|
|
3
|
+
const SHORT_CHARS = 200;
|
|
4
|
+
const BLANK_RELEASE_MS = 2000;
|
|
5
|
+
const PLACEHOLDER_MS = 3000;
|
|
6
|
+
export const CONTENT_WAIT_MS = 5000;
|
|
7
|
+
const PLACEHOLDER = /(?:^|\s)(?:loading|please wait|just a moment|one moment|redirecting|checking your browser)\b|加载中|正在加载|请稍候|(?:\.\.\.|…)$/i;
|
|
8
|
+
export async function waitForContent(probe, budgetMs = CONTENT_WAIT_MS) {
|
|
9
|
+
const started = Date.now();
|
|
10
|
+
let previous = -1, same = 0, failures = 0, last = null;
|
|
11
|
+
let loadedAt = null, placeholderSince = null;
|
|
12
|
+
for (;;) {
|
|
13
|
+
try {
|
|
14
|
+
last = await probe();
|
|
15
|
+
failures = 0;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
last = null;
|
|
19
|
+
if (++failures >= 4)
|
|
20
|
+
return 'unknown';
|
|
21
|
+
} // navigating: the next document has no world yet
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
if (last && !/^(?:about|chrome|chrome-error|edge|brave):/i.test(last.href)) {
|
|
24
|
+
if (last.ready === 'complete')
|
|
25
|
+
loadedAt ??= now;
|
|
26
|
+
if (last.chars >= ENOUGH_CHARS)
|
|
27
|
+
return 'ready';
|
|
28
|
+
same = last.chars === previous ? same + 1 : 0;
|
|
29
|
+
previous = last.chars;
|
|
30
|
+
const placeholder = last.chars > 0 && last.chars < SHORT_CHARS && PLACEHOLDER.test(last.head);
|
|
31
|
+
placeholderSince = placeholder ? placeholderSince ?? now : null;
|
|
32
|
+
if (placeholder) {
|
|
33
|
+
if (now - placeholderSince >= PLACEHOLDER_MS)
|
|
34
|
+
return 'placeholder';
|
|
35
|
+
}
|
|
36
|
+
else if (last.chars === 0) {
|
|
37
|
+
if (loadedAt !== null && now - loadedAt >= BLANK_RELEASE_MS)
|
|
38
|
+
return 'empty';
|
|
39
|
+
}
|
|
40
|
+
else if (same >= (last.ready !== 'complete' && last.chars < SHORT_CHARS ? 3 : 1))
|
|
41
|
+
return 'ready';
|
|
42
|
+
}
|
|
43
|
+
if (now - started + INTERVAL_MS > budgetMs)
|
|
44
|
+
return !last ? 'unknown' : placeholderSince !== null ? 'placeholder' : last.chars > 0 ? 'ready' : 'empty';
|
|
45
|
+
await new Promise(resolve => setTimeout(resolve, INTERVAL_MS));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=content-wait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-w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
|
package/dist/src/api/tab.js
CHANGED
|
@@ -8,6 +8,7 @@ import { ariaDiff } from './diff.js';
|
|
|
8
8
|
import { networkDetail, networkSummary } from './network.js';
|
|
9
9
|
import { compactAria } from '../shared/aria-tree.js';
|
|
10
10
|
import { observationPage } from './observation.js';
|
|
11
|
+
import { waitForContent } from './content-wait.js';
|
|
11
12
|
import { targetToSelector, fallbackSelector, frameSteps } from '../shared/engine.js';
|
|
12
13
|
export class Tab {
|
|
13
14
|
initialId;
|
|
@@ -70,6 +71,14 @@ export class Tab {
|
|
|
70
71
|
throw new ActionError('stale_ref', 'This ref has no observed document in this tab.', 'Observe or find the target again; use its returned ref.');
|
|
71
72
|
return frame?.length ? { ...target, frame } : target;
|
|
72
73
|
}
|
|
74
|
+
/** @internal After a load: wait until the page shows content (see content-wait.ts). */
|
|
75
|
+
async waitForContentOn(page) {
|
|
76
|
+
return waitForContent(() => page.pageCall('contentProbe', undefined, 2000));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Navigate and wait for the page's content, not only its load event. `content` is present when the page still had
|
|
80
|
+
* no text (`empty`) or only a loading placeholder (`placeholder`) after the bounded wait.
|
|
81
|
+
*/
|
|
73
82
|
async goto(url, opts = {}) {
|
|
74
83
|
if (!/^(https?:\/\/|data:text\/html)/i.test(url))
|
|
75
84
|
throw new ActionError('invalid_url', 'Only http(s) (or data:text/html) URLs can be opened', 'Pass an absolute http:// or https:// URL');
|
|
@@ -79,6 +88,7 @@ export class Tab {
|
|
|
79
88
|
throw new ActionError('invalid_args', 'timeoutMs must be a finite non-negative number.');
|
|
80
89
|
return this.use(async (page) => {
|
|
81
90
|
await page.goto(url, opts);
|
|
91
|
+
const content = opts.waitUntil === 'none' || opts.ready ? 'unknown' : await this.waitForContentOn(page);
|
|
82
92
|
if (opts.ready) {
|
|
83
93
|
const timeoutMs = opts.timeoutMs ?? 15000;
|
|
84
94
|
try {
|
|
@@ -90,7 +100,7 @@ export class Tab {
|
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
await this.harvest(page);
|
|
93
|
-
return this.info(page);
|
|
103
|
+
return { ...await this.info(page), ...(content === 'empty' || content === 'placeholder' ? { content } : {}) };
|
|
94
104
|
});
|
|
95
105
|
}
|
|
96
106
|
/**
|
|
@@ -351,7 +361,7 @@ export class Tab {
|
|
|
351
361
|
}
|
|
352
362
|
if (!opts.target)
|
|
353
363
|
throw new ActionError('missing_target', `action "${action}" needs a target`, 'Pass a target: a {ref} from observe, or a selector/role+name/label/text/testid.');
|
|
354
|
-
const r = await page.act({ kind: action, target: opts.target, value: opts.value, files: opts.files, to: opts.to, direction: opts.direction, amount: opts.amount, timeoutMs: opts.timeoutMs, settleMs: opts.settleMs
|
|
364
|
+
const r = await page.act({ kind: action, target: opts.target, value: opts.value, files: opts.files, to: opts.to, direction: opts.direction, amount: opts.amount, timeoutMs: opts.timeoutMs, settleMs: opts.settleMs, cursor: this.ctx.rt.cursorEnabled, ...(opts.method ? { method: opts.method } : {}) });
|
|
355
365
|
if (capture)
|
|
356
366
|
await this.harvest(page);
|
|
357
367
|
if (r.ref)
|
|
@@ -364,6 +374,8 @@ export class Tab {
|
|
|
364
374
|
delivery,
|
|
365
375
|
controlState: controlVerified ? 'verified' : 'unverified',
|
|
366
376
|
...(capture && { network: { afterSequence: networkFrom, cursor: this.ctx.state.netLog.get(this.id)?.seq ?? networkFrom } }),
|
|
377
|
+
...(r.effect ? { effect: r.effect } : {}),
|
|
378
|
+
...(r.settled === false ? { settled: false, pendingRequests: r.pendingRequests ?? 0 } : {}),
|
|
367
379
|
...(r.matches_n > 1 ? { matches_n: r.matches_n } : {}),
|
|
368
380
|
...(r.navigated ? { navigated: true, ...(r.url !== undefined && { url: r.url }) } : {}),
|
|
369
381
|
...(r.ref ? { ref: r.ref } : {}),
|