dsh-browser-playwright-codex 0.5.2 → 0.5.3
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 +30 -0
- package/lib/browser-lifecycle.d.ts +12 -0
- package/lib/browser-lifecycle.js +186 -0
- package/lib/challenge.d.ts +20 -0
- package/lib/challenge.js +40 -0
- package/lib/config.d.ts +81 -0
- package/lib/config.js +61 -0
- package/lib/extract.d.ts +13 -0
- package/lib/extract.js +34 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.js +3 -1
- package/lib/login-state.d.ts +10 -0
- package/lib/login-state.js +83 -0
- package/lib/page-actions.d.ts +134 -0
- package/lib/page-actions.js +725 -0
- package/lib/page-diagnostics.d.ts +65 -0
- package/lib/page-diagnostics.js +181 -0
- package/lib/page-probes.d.ts +78 -0
- package/lib/page-probes.js +281 -0
- package/lib/page-snapshot.d.ts +96 -0
- package/lib/page-snapshot.js +280 -0
- package/lib/playwright.d.ts +5 -644
- package/lib/playwright.js +28 -2602
- package/lib/provider.d.ts +157 -0
- package/lib/provider.js +352 -0
- package/lib/session.d.ts +410 -0
- package/lib/session.js +633 -0
- package/lib/tool-render.d.ts +20 -0
- package/lib/tool-render.js +137 -0
- package/lib/tool-schemas.d.ts +76 -0
- package/lib/tool-schemas.js +46 -0
- package/lib/tool-types.d.ts +82 -0
- package/lib/tool-types.js +1 -0
- package/lib/tool.d.ts +2 -26
- package/lib/tool.js +5 -252
- package/lib/url-policy.d.ts +2 -0
- package/lib/url-policy.js +26 -0
- package/lib/window-focus.d.ts +27 -0
- package/lib/window-focus.js +54 -0
- package/package.json +1 -1
- package/scripts/dsh-browser-verify.mjs +2 -1
- package/scripts/prompt-cost.mjs +1 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Locator, Page } from 'playwright-core';
|
|
2
|
+
import type { PlaywrightSession } from './session.ts';
|
|
3
|
+
import type { ActionResult } from './provider.ts';
|
|
4
|
+
import type { LoadState } from './types.ts';
|
|
5
|
+
/** Wrap a Playwright op so an aborted signal rejects while the op keeps draining in the background. */
|
|
6
|
+
export declare function withAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Post-hover note. A hover proves nothing by itself: the call returning only
|
|
9
|
+
* means the pointer moved. The cheap evidence that content appeared is how the
|
|
10
|
+
* actionable ref count changed, so the note reports it and tells the model
|
|
11
|
+
* what to do when nothing appeared (retarget the owner of the menu, never
|
|
12
|
+
* retry the same hover, never fall back to raw coordinates).
|
|
13
|
+
* @param target - description of what was hovered (a ref, or a quoted label).
|
|
14
|
+
* @param refsBefore - actionable refs before the hover.
|
|
15
|
+
* @param refsAfter - actionable refs in the returned snapshot.
|
|
16
|
+
* @param navigated - whether the hover changed the page URL.
|
|
17
|
+
*/
|
|
18
|
+
export declare function hoverNote(target: string, refsBefore: number, refsAfter: number, navigated: boolean): string;
|
|
19
|
+
/** Fast actionability pre-check (visible/enabled/editable) before an action. */
|
|
20
|
+
export declare function assertActionable(_session: PlaywrightSession, locator: Locator, options?: {
|
|
21
|
+
editable?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Run one page action that may raise a native dialog. Such an action never
|
|
25
|
+
* resolves while the dialog is up, so race it against the dialog appearing
|
|
26
|
+
* and hand the caller the pending state instead (Playwright-MCP pattern).
|
|
27
|
+
*/
|
|
28
|
+
export declare function runAction(session: PlaywrightSession, page: Page, action: () => Promise<unknown>): Promise<ActionResult>;
|
|
29
|
+
export declare function navigate(session: PlaywrightSession, url: string, waitUntil: LoadState, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot | {
|
|
30
|
+
url: string;
|
|
31
|
+
title: string;
|
|
32
|
+
nodes: never[];
|
|
33
|
+
totalRefs: number;
|
|
34
|
+
truncated: boolean;
|
|
35
|
+
dialogNote: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Codex-style click-point resolution. Tries a scroll-alignment ladder
|
|
39
|
+
* (centre, then end, then start). For each alignment: scroll the element
|
|
40
|
+
* into view with a native scrollIntoView, wait for its bounding rect to
|
|
41
|
+
* stop moving, sample the rect centre in-page (sub-pixel, no screenshot
|
|
42
|
+
* measurement), then hit-test that exact point with elementFromPoint — so
|
|
43
|
+
* an overlaying element can never swallow the click silently. Returns the
|
|
44
|
+
* first unobstructed {x, y}, or throws describing what intercepted it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveClickPoint(session: PlaywrightSession, locator: Locator, signal: AbortSignal | undefined): Promise<{
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
hitDesc: string;
|
|
50
|
+
hitSelf: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Click an element the snapshot gave no ref, addressed by its visible label
|
|
54
|
+
* (e.g. a menu item revealed by browser_hover that is plain text). The
|
|
55
|
+
* label must equal an element's own direct text; the deepest match wins,
|
|
56
|
+
* and the landing note names what was actually clicked plus how many
|
|
57
|
+
* elements shared the label.
|
|
58
|
+
*/
|
|
59
|
+
export declare function clickText(session: PlaywrightSession, text: string, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot | {
|
|
60
|
+
url: string;
|
|
61
|
+
title: string;
|
|
62
|
+
nodes: never[];
|
|
63
|
+
totalRefs: number;
|
|
64
|
+
truncated: boolean;
|
|
65
|
+
dialogNote: string;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Shared click core: enforce the URL policy for link targets, run the
|
|
69
|
+
* Codex-style geometry ladder with the Playwright actionability fallback,
|
|
70
|
+
* then report what actually received the click. The label names the target
|
|
71
|
+
* in the landing note; shared is how many elements matched it (0 for refs).
|
|
72
|
+
*/
|
|
73
|
+
export declare function clickLocator(session: PlaywrightSession, locator: Locator, signal: AbortSignal | undefined, label: string, shared: number): Promise<import("./types.ts").BrowserSnapshot | {
|
|
74
|
+
url: string;
|
|
75
|
+
title: string;
|
|
76
|
+
nodes: never[];
|
|
77
|
+
totalRefs: number;
|
|
78
|
+
truncated: boolean;
|
|
79
|
+
dialogNote: string;
|
|
80
|
+
}>;
|
|
81
|
+
export declare function clickAt(session: PlaywrightSession, x: number, y: number, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot | {
|
|
82
|
+
url: string;
|
|
83
|
+
title: string;
|
|
84
|
+
nodes: never[];
|
|
85
|
+
totalRefs: number;
|
|
86
|
+
truncated: boolean;
|
|
87
|
+
dialogNote: string;
|
|
88
|
+
}>;
|
|
89
|
+
export declare function clickAtRef(session: PlaywrightSession, ref: string, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot | {
|
|
90
|
+
url: string;
|
|
91
|
+
title: string;
|
|
92
|
+
nodes: never[];
|
|
93
|
+
totalRefs: number;
|
|
94
|
+
truncated: boolean;
|
|
95
|
+
dialogNote: string;
|
|
96
|
+
}>;
|
|
97
|
+
export declare function fill(session: PlaywrightSession, ref: string, text: string, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot>;
|
|
98
|
+
/** Read the field back and decide whether the fill landed. */
|
|
99
|
+
export declare function verifyFill(_session: PlaywrightSession, locator: Locator, tag: string, text: string): Promise<boolean>;
|
|
100
|
+
export declare function press(session: PlaywrightSession, ref: string, key: string, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot | {
|
|
101
|
+
url: string;
|
|
102
|
+
title: string;
|
|
103
|
+
nodes: never[];
|
|
104
|
+
totalRefs: number;
|
|
105
|
+
truncated: boolean;
|
|
106
|
+
dialogNote: string;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Hover a trigger the snapshot gave no ref, addressed by its visible label
|
|
110
|
+
* (e.g. a plain span that reveals a menu on mouseenter). The label must
|
|
111
|
+
* equal an element's own direct text; the deepest match wins, and the
|
|
112
|
+
* landing note names what was hovered plus how many elements shared it.
|
|
113
|
+
*/
|
|
114
|
+
export declare function hoverText(session: PlaywrightSession, text: string, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot>;
|
|
115
|
+
/**
|
|
116
|
+
* Shared hover core: rest the pointer on a resolved locator, then report
|
|
117
|
+
* what the actionable ref count did. The label names the target in the
|
|
118
|
+
* landing note; shared is how many elements matched that label (0 when the
|
|
119
|
+
* target came from a ref).
|
|
120
|
+
*/
|
|
121
|
+
export declare function hoverLocator(session: PlaywrightSession, locator: Locator, signal: AbortSignal | undefined, label: string, shared: number): Promise<import("./types.ts").BrowserSnapshot>;
|
|
122
|
+
export declare function scroll(session: PlaywrightSession, direction: 'up' | 'down', amount: number, ref: string, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot>;
|
|
123
|
+
export declare function back(session: PlaywrightSession, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot>;
|
|
124
|
+
export declare function forward(session: PlaywrightSession, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot>;
|
|
125
|
+
export declare function switchTab(session: PlaywrightSession, index: number, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot | {
|
|
126
|
+
url: string;
|
|
127
|
+
title: string;
|
|
128
|
+
nodes: never[];
|
|
129
|
+
totalRefs: number;
|
|
130
|
+
truncated: boolean;
|
|
131
|
+
dialogNote: string;
|
|
132
|
+
}>;
|
|
133
|
+
export declare function openTab(session: PlaywrightSession, url: string, waitUntil: LoadState, signal: AbortSignal | undefined): Promise<import("./types.ts").BrowserSnapshot>;
|
|
134
|
+
export declare function closeTab(session: PlaywrightSession, index: number, signal: AbortSignal | undefined): Promise<void>;
|