webhands 0.2.0 → 0.4.0
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 +69 -6
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +607 -9
- package/dist/cli.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +25 -2
- package/dist/errors.js.map +1 -1
- package/package.json +2 -2
- package/src/cli.ts +734 -9
- package/src/errors.ts +31 -0
package/src/errors.ts
CHANGED
|
@@ -2,11 +2,15 @@ import {
|
|
|
2
2
|
isControllerError,
|
|
3
3
|
MissingBrowserBinaryError,
|
|
4
4
|
MissingStealthDependencyError,
|
|
5
|
+
InvalidProxyError,
|
|
5
6
|
MissingProfileError,
|
|
6
7
|
AttachNotChromiumError,
|
|
7
8
|
AttachNoContextError,
|
|
8
9
|
NoLiveServerError,
|
|
9
10
|
SessionAlreadyActiveError,
|
|
11
|
+
CrossOriginFrameError,
|
|
12
|
+
ScreenshotPathError,
|
|
13
|
+
StaleRefError,
|
|
10
14
|
type ControllerError,
|
|
11
15
|
type ControllerErrorCode,
|
|
12
16
|
} from '@webhands/core';
|
|
@@ -52,6 +56,10 @@ export function fixCommandFor(error: ControllerError, binary: string): string {
|
|
|
52
56
|
// is absent. Name the package from the typed error so the install command
|
|
53
57
|
// is ready to run; we never silently fall back to vanilla Playwright.
|
|
54
58
|
return `pnpm add ${(error as MissingStealthDependencyError).dependency}`;
|
|
59
|
+
case 'invalid-proxy':
|
|
60
|
+
// The --proxy value could not be parsed into a SOCKS proxy. Show the
|
|
61
|
+
// expected URL shape; socks5h tunnels DNS too (no leak).
|
|
62
|
+
return `${binary} serve --proxy socks5h://host:1080 (or socks5://user:pass@host:1080)`;
|
|
55
63
|
case 'missing-profile':
|
|
56
64
|
// A profile is created by the headed `setup-profile` flow (the ONE place
|
|
57
65
|
// a profile dir is created — see core's MissingProfileError). Name the
|
|
@@ -73,6 +81,25 @@ export function fixCommandFor(error: ControllerError, binary: string): string {
|
|
|
73
81
|
// A session is already live; v1 holds exactly one. The fix is to tear it
|
|
74
82
|
// down before starting another.
|
|
75
83
|
return `${binary} stop`;
|
|
84
|
+
case 'cross-origin-frame':
|
|
85
|
+
// `eval --frame` reaches the top document and SAME-ORIGIN child frames
|
|
86
|
+
// only (page-world JS cannot cross a security boundary). There is no
|
|
87
|
+
// flag that makes a cross-origin frame reachable here; the fix is to
|
|
88
|
+
// target a same-origin frame, or omit --frame for the top document. (The
|
|
89
|
+
// cross-origin reach is the separate Tier-4 surface.)
|
|
90
|
+
return `${binary} eval '<expression>' (drop --frame for the top document, or pass a SAME-ORIGIN frame selector)`;
|
|
91
|
+
case 'screenshot-path-outside-managed-dir':
|
|
92
|
+
// A --out override escaped the managed screenshots dir. webhands writes
|
|
93
|
+
// only WITHIN that dir; the fix is to drop --out (let webhands mint a
|
|
94
|
+
// path) or pass one under the managed dir.
|
|
95
|
+
return `${binary} screenshot (drop --out to let webhands mint a path under ${(error as ScreenshotPathError).managedDir}, or pass an --out inside it)`;
|
|
96
|
+
case 'stale-ref':
|
|
97
|
+
// A durable `query` ref went stale (resolve-to-zero) or ambiguous
|
|
98
|
+
// (resolve-to-many) before the action ran: the page changed between the
|
|
99
|
+
// query and the act. There is no flag that revives a stale handle; the
|
|
100
|
+
// fix is to re-run `query --with-refs` against the fresh DOM and act on
|
|
101
|
+
// the NEW ref (the agent's natural read-then-act loop).
|
|
102
|
+
return `${binary} query '<locator>' --with-refs (re-read the page to get a fresh ref, then click/type --by-ref with it)`;
|
|
76
103
|
default: {
|
|
77
104
|
// Exhaustiveness guard: a new ControllerErrorCode must add a fix command
|
|
78
105
|
// here rather than silently fall through to a generic message.
|
|
@@ -112,10 +139,14 @@ export function mapControllerError(
|
|
|
112
139
|
export {
|
|
113
140
|
MissingBrowserBinaryError,
|
|
114
141
|
MissingStealthDependencyError,
|
|
142
|
+
InvalidProxyError,
|
|
115
143
|
MissingProfileError,
|
|
116
144
|
AttachNotChromiumError,
|
|
117
145
|
AttachNoContextError,
|
|
118
146
|
NoLiveServerError,
|
|
119
147
|
SessionAlreadyActiveError,
|
|
148
|
+
CrossOriginFrameError,
|
|
149
|
+
ScreenshotPathError,
|
|
150
|
+
StaleRefError,
|
|
120
151
|
};
|
|
121
152
|
export type {ControllerError, ControllerErrorCode};
|