@querying/sneaky 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +171 -2
- package/bin/sneaky-mcp.mjs +5 -0
- package/bin/sneaky.mjs +51 -0
- package/dist/agent/index.d.ts +277 -0
- package/dist/agent/index.js +319 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/browser/index.d.ts +69 -0
- package/dist/browser/index.js +326 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/cli/index.d.ts +51 -0
- package/dist/cli/index.js +189 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/driver/cdp.d.ts +36 -0
- package/dist/driver/cdp.js +240 -0
- package/dist/driver/cdp.js.map +1 -0
- package/dist/driver/frame.d.ts +229 -0
- package/dist/driver/frame.js +794 -0
- package/dist/driver/frame.js.map +1 -0
- package/dist/driver/index.d.ts +13 -0
- package/dist/driver/index.js +6 -0
- package/dist/driver/index.js.map +1 -0
- package/dist/driver/keys.d.ts +9 -0
- package/dist/driver/keys.js +65 -0
- package/dist/driver/keys.js.map +1 -0
- package/dist/driver/launcher.d.ts +49 -0
- package/dist/driver/launcher.js +251 -0
- package/dist/driver/launcher.js.map +1 -0
- package/dist/driver/page.d.ts +391 -0
- package/dist/driver/page.js +1594 -0
- package/dist/driver/page.js.map +1 -0
- package/dist/index.d.ts +501 -0
- package/dist/index.js +688 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +35 -0
- package/dist/mcp/server.js +548 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/repl/cli.d.ts +1 -0
- package/dist/repl/cli.js +246 -0
- package/dist/repl/cli.js.map +1 -0
- package/dist/repl/host.d.ts +46 -0
- package/dist/repl/host.js +167 -0
- package/dist/repl/host.js.map +1 -0
- package/dist/repl/index.d.ts +246 -0
- package/dist/repl/index.js +923 -0
- package/dist/repl/index.js.map +1 -0
- package/dist/repl/transform.d.ts +19 -0
- package/dist/repl/transform.js +590 -0
- package/dist/repl/transform.js.map +1 -0
- package/dist/request/index.d.ts +265 -0
- package/dist/request/index.js +898 -0
- package/dist/request/index.js.map +1 -0
- package/package.json +83 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anymorph AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,172 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@querying/sneaky`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Unified stealth web automation & Chrome-stack HTTP suite by **anymorph-ai** — available as an **npm package (`@querying/sneaky`)**, **CLI (`sneaky`)**, **MCP server (stdio & Streamable HTTP)**, and **zero-dependency TypeScript/Go SDK**.
|
|
4
|
+
|
|
5
|
+
Use each capability **standalone** or **composed together** under one shared Persona, Proxy, and bidirectional Cookie Bridge (with local ↔ `querying.ai Browser` cloud parity).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Run CLI or MCP with zero setup
|
|
11
|
+
npx @querying/sneaky doctor
|
|
12
|
+
npx @querying/sneaky probe https://example.com
|
|
13
|
+
npx @querying/sneaky mcp
|
|
14
|
+
|
|
15
|
+
# Or install globally for `sneaky` and `sneaky-mcp` commands
|
|
16
|
+
npm install -g @querying/sneaky
|
|
17
|
+
|
|
18
|
+
# Or add the SDK to a Node.js / TypeScript project (>= 22)
|
|
19
|
+
npm install @querying/sneaky
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Platform binaries (`@querying/sneaky-{darwin-arm64,darwin-x64,linux-x64,linux-arm64,win32-x64}`) are installed automatically via npm `optionalDependencies` (esbuild pattern) — no runtime download or compiler needed.
|
|
23
|
+
|
|
24
|
+
## What's Inside
|
|
25
|
+
|
|
26
|
+
| Layer | Standalone Usage | Composed Usage (`Sneaky` / `sneaky serve`) |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| **Persistent Multi-Profile Browser** | `sneaky profile create/use/list`, `sneaky browser start/open/stop` | Persistent `user-data-dir` + `sneaky-browser-seed` per profile, auto-managed background daemon, local/remote/cloud hosts |
|
|
29
|
+
| **Persistent JS REPL (`@querying/sneaky/repl`)** | `sneaky repl [--profile <id>|--incognito] [code]` | Aside-grade `vm` REPL (`openTab`, `snapshot` tree+diff, `locator('eN')`, `annotatedScreenshot`, `display`, cookie-bearing `tfrd` `fetch`) |
|
|
30
|
+
| **Chrome-stack HTTP (`tfrd`)** | `sneaky fetch <url>` or `@querying/sneaky/request` (~32 KB/session, real BoringSSL/HTTP2/HTTP3) | Lazy HTTP lane inside a unified `Session` sharing Persona + Proxy + CookieJar |
|
|
31
|
+
| **Browser Persona & Flags** | `@querying/sneaky/browser` (`buildArgs`, `buildEnv`, `profileSeed`, zero Playwright dep) | Automatic `sneaky-browser` flag/fontconfig/proxy-auth launch + `Browser.humanized*` C++ input |
|
|
32
|
+
| **Zero-`Runtime.enable` Agent** | `@querying/sneaky/agent` or `@querying/sneaky/driver` (Playwright-aligned TS CDP driver) | Lazy Browser lane (`goto`, `snapshot`, `act`, `extract`, `screenshot`, `pdf`, `eval`, `query`, `network`, WS RPC) |
|
|
33
|
+
| **Bidirectional Cookie Bridge** | `sneaky cookies get\|sync` | Auto-syncs HTTP `Set-Cookie` (including 3xx redirects) → Browser CDP on promote, and Browser CDP cookies → HTTP `tfrd` |
|
|
34
|
+
| **MCP Server (stdio + HTTP)** | `npx -y @querying/sneaky mcp [--repl-only]` or `sneaky-mcp` | Persistent `repl` (with native image blocks on `display()`) + `browser_profiles` + full Sneaky tools; also mounted at `POST /mcp` |
|
|
35
|
+
| **Optional Captcha Hook** | External sidecar (`SNEAKY_CAPTCHA_URL`) or custom `CaptchaPlugin` | Zero ONNX/Playwright bloat in core binary; opt-in only |
|
|
36
|
+
|
|
37
|
+
Heavy engine/model builds remain in their dedicated repositories (`anymorph-ai/sneaky-browser`, `anymorph-ai/sneaky-request`, `anymorph-ai/sneaky-captcha`); `sneaky install` downloads version-pinned engine binaries with SHA-256 verification into `~/.sneaky/bin`.
|
|
38
|
+
|
|
39
|
+
## MCP Setup (Claude Code, Codex, Cursor, Claude Desktop)
|
|
40
|
+
|
|
41
|
+
Print ready-to-paste config anytime:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx @querying/sneaky mcp config --client json # Claude Desktop / Cursor / Claude Code
|
|
45
|
+
npx @querying/sneaky mcp config --client codex # Codex ~/.codex/config.toml
|
|
46
|
+
npx @querying/sneaky mcp config --client http # Remote / local Streamable HTTP (/mcp)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Claude Desktop / Cursor / Claude Code (stdio):**
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"sneaky": {
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": ["-y", "@querying/sneaky", "mcp"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Codex (`~/.codex/config.toml`):**
|
|
63
|
+
|
|
64
|
+
```toml
|
|
65
|
+
[mcp_servers.sneaky]
|
|
66
|
+
command = "npx"
|
|
67
|
+
args = ["-y", "@querying/sneaky", "mcp"]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Streamable HTTP MCP (when running `sneaky serve`):**
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
sneaky serve --listen 127.0.0.1:9333
|
|
74
|
+
# MCP endpoint available at http://127.0.0.1:9333/mcp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## TypeScript SDK (`@querying/sneaky`)
|
|
78
|
+
|
|
79
|
+
Zero runtime dependencies. Tree-shakable subpath exports let you import only what you need, or compose everything via the root client.
|
|
80
|
+
|
|
81
|
+
### Zero-Config Managed Daemon (`Sneaky.start()`)
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { Sneaky } from "@querying/sneaky";
|
|
85
|
+
|
|
86
|
+
const sneaky = await Sneaky.start(); // spawns bundled Go daemon on a free port
|
|
87
|
+
try {
|
|
88
|
+
const session = await sneaky.createSession({
|
|
89
|
+
mode: "auto", // lazy: neither tfrd nor Chromium starts until called
|
|
90
|
+
persona: { seed: 42, platform: "macos", locale: "ko-KR", tlsProfile: "chrome-146" },
|
|
91
|
+
proxyServer: "http://user:pass@proxy.example:8080",
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await session.connectRPC(); // optional persistent WS RPC for both HTTP & browser calls
|
|
95
|
+
|
|
96
|
+
// 1. Fast Chrome-stack HTTP via tfrd (optional auto-escalation to browser on 403/503)
|
|
97
|
+
const res = await session.fetch("https://target.example/api", {
|
|
98
|
+
escalateOnStatus: [403, 503],
|
|
99
|
+
escalateMode: "retry",
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// 2. Or explicitly drive the browser with the same Persona + Proxy + HTTP cookies
|
|
103
|
+
await session.goto("https://target.example/login", { returnSnapshot: true });
|
|
104
|
+
await session.fill("#email", "alice@example.com");
|
|
105
|
+
await session.click("button[type=submit]", { speed: "stealth" });
|
|
106
|
+
|
|
107
|
+
// 3. Pull cleared browser cookies back to fast tfrd HTTP lane
|
|
108
|
+
await session.syncBrowserToHttp();
|
|
109
|
+
const data = await session.fetch("https://target.example/api/me");
|
|
110
|
+
|
|
111
|
+
await session.close();
|
|
112
|
+
} finally {
|
|
113
|
+
await sneaky.stop();
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Pass `{ apiKey }` to `new Sneaky({ apiKey })` to target remote **`querying.ai Browser`** with the same API.
|
|
118
|
+
|
|
119
|
+
### Standalone Subpath Imports
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
// Standalone tfrd HTTP/WS client (no Chromium)
|
|
123
|
+
import { Daemon } from "@querying/sneaky/request";
|
|
124
|
+
|
|
125
|
+
// Standalone sneaky-browser persona flags, fontconfig & profileSeed (no Playwright)
|
|
126
|
+
import { buildArgs, buildEnv, profileSeed } from "@querying/sneaky/browser";
|
|
127
|
+
|
|
128
|
+
// Standalone zero-Runtime.enable agent client
|
|
129
|
+
import { SneakyAgent } from "@querying/sneaky/agent";
|
|
130
|
+
|
|
131
|
+
// Standalone Playwright-aligned zero-Runtime.enable CDP driver
|
|
132
|
+
import { chromium } from "@querying/sneaky/driver";
|
|
133
|
+
|
|
134
|
+
// Programmatic binary resolver & daemon launcher
|
|
135
|
+
import { resolveBinaryPath, startDaemon } from "@querying/sneaky/cli";
|
|
136
|
+
|
|
137
|
+
// Persistent Aside-compatible stealth JS REPL
|
|
138
|
+
import { SneakyReplSession } from "@querying/sneaky/repl";
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## CLI Quick Reference
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
sneaky guide [repl|profiles|hosts] # concise onboarding manual for external AI agents
|
|
145
|
+
sneaky profile create work --locale ko-KR # create persistent profile (cookies + fingerprint seed)
|
|
146
|
+
sneaky browser start --profile work --headful # launch persistent profile browser (auto-starts daemon)
|
|
147
|
+
sneaky repl --profile work "const t = await openTab('https://example.com'); console.log((await snapshot(t)).tree)"
|
|
148
|
+
sneaky repl --profile work # interactive persistent JS REPL
|
|
149
|
+
sneaky host add office http://100.64.0.12:9333 --token <secret>
|
|
150
|
+
sneaky daemon start|stop|status # manage background daemon (~/.sneaky/state/daemon.json)
|
|
151
|
+
sneaky doctor # inspect detected Chrome/sneaky-browser & tfrd
|
|
152
|
+
sneaky install [all|browser|tfrd] # install pinned engine binaries into ~/.sneaky/bin
|
|
153
|
+
sneaky fetch https://example.com --locale ko-KR # standalone Chrome-stack HTTP via tfrd
|
|
154
|
+
sneaky probe https://example.com # one-shot browser probe (local or querying.ai cloud)
|
|
155
|
+
sneaky serve --listen 127.0.0.1:9333 [--auth-token <secret>]
|
|
156
|
+
sneaky mcp [--repl-only] # stdio MCP server (persistent repl + browser_profiles + tools)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Building & Publishing npm Packages
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Test Go + TS SDK locally
|
|
163
|
+
go vet ./...
|
|
164
|
+
go test -race -count=1 ./...
|
|
165
|
+
go build -o bin/sneaky ./cmd/sneaky
|
|
166
|
+
(cd sdk/ts && npm ci && npm run build && npm test)
|
|
167
|
+
|
|
168
|
+
# Cross-compile all 5 platform packages + assembled @querying/sneaky into dist-npm/
|
|
169
|
+
node scripts/build-npm-packages.mjs --version 0.1.0
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Pushing a `v*` tag triggers [`.github/workflows/release.yml`](.github/workflows/release.yml), which cross-compiles all 5 platform binaries, attaches checksums to a GitHub Release, and publishes `@querying/sneaky-*` + `@querying/sneaky` to npm when `NPM_TOKEN` is configured.
|
package/bin/sneaky.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { resolveBinaryPath } from "../dist/cli/index.js";
|
|
4
|
+
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
|
|
7
|
+
// Persistent JS REPL and Node-powered REPL MCP server run directly in Node.js while driving the Go Sneaky daemon.
|
|
8
|
+
if (args[0] === "repl") {
|
|
9
|
+
const { runReplCli } = await import("../dist/repl/cli.js");
|
|
10
|
+
const code = await runReplCli(args.slice(1));
|
|
11
|
+
process.exit(code);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (args[0] === "mcp" && args[1] !== "config") {
|
|
15
|
+
const { runMcpCli } = await import("../dist/mcp/server.js");
|
|
16
|
+
const code = await runMcpCli(args.slice(1));
|
|
17
|
+
process.exit(code);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let bin;
|
|
21
|
+
try {
|
|
22
|
+
bin = resolveBinaryPath();
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(`sneaky: ${err instanceof Error ? err.message : String(err)}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const child = spawn(bin, args, { stdio: "inherit" });
|
|
29
|
+
|
|
30
|
+
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
31
|
+
process.on(sig, () => {
|
|
32
|
+
try {
|
|
33
|
+
child.kill(sig);
|
|
34
|
+
} catch {
|
|
35
|
+
// Ignore if child already exited.
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
child.on("error", (err) => {
|
|
41
|
+
console.error(`sneaky: failed to launch ${bin}: ${err.message}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
child.on("exit", (code, signal) => {
|
|
46
|
+
if (signal) {
|
|
47
|
+
process.kill(process.pid, signal);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
process.exit(code ?? 1);
|
|
51
|
+
});
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
export type SnapshotMode = "interactive" | "compact" | "full";
|
|
2
|
+
export type SnapshotSource = "dom" | "ax";
|
|
3
|
+
export type ActionSpeed = "fast" | "natural" | "stealth";
|
|
4
|
+
export type WaitUntil = "commit" | "domcontentloaded" | "load" | "networkidle";
|
|
5
|
+
export type ExtractKind = "markdown" | "text" | "html" | "links" | "json_ld";
|
|
6
|
+
export type BlockResourceType = "image" | "font" | "media" | "stylesheet";
|
|
7
|
+
export declare const DEFAULT_LOCAL_URL = "http://127.0.0.1:9333";
|
|
8
|
+
export declare const DEFAULT_REMOTE_URL = "https://api.querying.ai/browser";
|
|
9
|
+
export declare class SneakyError extends Error {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly extra?: Record<string, unknown> | undefined;
|
|
13
|
+
constructor(message: string, status: number, code: string, extra?: Record<string, unknown> | undefined);
|
|
14
|
+
}
|
|
15
|
+
export interface SneakyAgentOptions {
|
|
16
|
+
/** Local daemon URL or remote querying.ai Browser URL. Defaults to remote when apiKey is set, otherwise local. */
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
/** Optional querying.ai vt_ API key for remote cloud sessions. */
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
fetch?: typeof fetch;
|
|
22
|
+
}
|
|
23
|
+
export interface CreateSessionOptions {
|
|
24
|
+
headless?: boolean;
|
|
25
|
+
stealth?: boolean;
|
|
26
|
+
country?: string;
|
|
27
|
+
proxyServer?: string;
|
|
28
|
+
userDataDir?: string;
|
|
29
|
+
viewport?: {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
url?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SessionInfo {
|
|
36
|
+
session_id: string;
|
|
37
|
+
cdp_ws_url?: string;
|
|
38
|
+
browser_live_view_url?: string;
|
|
39
|
+
headless?: boolean;
|
|
40
|
+
stealth?: boolean;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface Target {
|
|
44
|
+
ref?: string;
|
|
45
|
+
snapshot_id?: string;
|
|
46
|
+
selector?: string;
|
|
47
|
+
role?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
text?: string;
|
|
52
|
+
exact?: boolean;
|
|
53
|
+
nth?: number;
|
|
54
|
+
x?: number;
|
|
55
|
+
y?: number;
|
|
56
|
+
}
|
|
57
|
+
export type TargetInput = string | Target;
|
|
58
|
+
export interface Action {
|
|
59
|
+
type: "click" | "dblclick" | "hover" | "fill" | "type" | "press" | "select" | "scroll" | "wait" | "extract" | "navigate" | "back" | "forward" | "reload";
|
|
60
|
+
target?: Target;
|
|
61
|
+
text?: string;
|
|
62
|
+
value?: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
key?: string;
|
|
65
|
+
url?: string;
|
|
66
|
+
wait_until?: WaitUntil;
|
|
67
|
+
button?: "left" | "right" | "middle";
|
|
68
|
+
click_count?: number;
|
|
69
|
+
clear?: boolean;
|
|
70
|
+
speed?: ActionSpeed;
|
|
71
|
+
humanize?: boolean;
|
|
72
|
+
dx?: number;
|
|
73
|
+
dy?: number;
|
|
74
|
+
timeout_ms?: number;
|
|
75
|
+
wait_ms?: number;
|
|
76
|
+
url_contains?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface PageMeta {
|
|
79
|
+
url: string;
|
|
80
|
+
title: string;
|
|
81
|
+
ready_state: string;
|
|
82
|
+
viewport: {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
};
|
|
86
|
+
scroll: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
};
|
|
92
|
+
active_tag?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface SnapshotRef {
|
|
95
|
+
ref: string;
|
|
96
|
+
role: string;
|
|
97
|
+
name?: string;
|
|
98
|
+
value?: string;
|
|
99
|
+
states?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
export interface SnapshotDiff {
|
|
102
|
+
base_snapshot_id: string;
|
|
103
|
+
added?: string[];
|
|
104
|
+
removed?: string[];
|
|
105
|
+
unchanged_count: number;
|
|
106
|
+
}
|
|
107
|
+
export interface SnapshotResult {
|
|
108
|
+
snapshot_id: string;
|
|
109
|
+
mode: SnapshotMode;
|
|
110
|
+
source?: SnapshotSource;
|
|
111
|
+
page: PageMeta;
|
|
112
|
+
tree?: string;
|
|
113
|
+
refs: Record<string, SnapshotRef>;
|
|
114
|
+
ref_count: number;
|
|
115
|
+
truncated: boolean;
|
|
116
|
+
diff?: SnapshotDiff;
|
|
117
|
+
screenshot?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface ActOptions {
|
|
120
|
+
returnSnapshot?: boolean;
|
|
121
|
+
snapshotMode?: SnapshotMode;
|
|
122
|
+
snapshotSource?: SnapshotSource;
|
|
123
|
+
diffFrom?: string;
|
|
124
|
+
diffFromLast?: boolean;
|
|
125
|
+
settleMs?: number;
|
|
126
|
+
screenshot?: boolean;
|
|
127
|
+
speed?: ActionSpeed;
|
|
128
|
+
humanize?: boolean;
|
|
129
|
+
timeoutMs?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface ActResult {
|
|
132
|
+
ok: boolean;
|
|
133
|
+
failed_step?: number;
|
|
134
|
+
results: Array<{
|
|
135
|
+
index: number;
|
|
136
|
+
type: string;
|
|
137
|
+
ok: boolean;
|
|
138
|
+
duration_ms: number;
|
|
139
|
+
data?: Record<string, unknown>;
|
|
140
|
+
error?: string;
|
|
141
|
+
code?: string;
|
|
142
|
+
}>;
|
|
143
|
+
page: PageMeta;
|
|
144
|
+
snapshot?: SnapshotResult;
|
|
145
|
+
}
|
|
146
|
+
export interface NetworkEntry {
|
|
147
|
+
seq: number;
|
|
148
|
+
request_id: string;
|
|
149
|
+
method: string;
|
|
150
|
+
url: string;
|
|
151
|
+
resource_type: string;
|
|
152
|
+
status?: number;
|
|
153
|
+
mime_type?: string;
|
|
154
|
+
duration_ms?: number;
|
|
155
|
+
encoded_bytes?: number;
|
|
156
|
+
failed?: boolean;
|
|
157
|
+
error_text?: string;
|
|
158
|
+
request_headers?: Record<string, string>;
|
|
159
|
+
response_headers?: Record<string, string>;
|
|
160
|
+
body_available: boolean;
|
|
161
|
+
body?: string;
|
|
162
|
+
}
|
|
163
|
+
export declare function parseTarget(input: TargetInput): Target;
|
|
164
|
+
export declare class SneakyAgent {
|
|
165
|
+
readonly baseUrl: string;
|
|
166
|
+
private readonly apiKey?;
|
|
167
|
+
private readonly timeoutMs;
|
|
168
|
+
private readonly fetchImpl;
|
|
169
|
+
constructor(options?: SneakyAgentOptions);
|
|
170
|
+
request<T>(method: "GET" | "POST" | "DELETE", path: string, options?: {
|
|
171
|
+
body?: unknown;
|
|
172
|
+
query?: Record<string, string | number | undefined>;
|
|
173
|
+
}): Promise<T>;
|
|
174
|
+
create(options?: CreateSessionOptions): Promise<Session>;
|
|
175
|
+
attach(sessionId: string): Session;
|
|
176
|
+
list(): Promise<SessionInfo[]>;
|
|
177
|
+
close(sessionId: string): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
export declare class Session {
|
|
180
|
+
private readonly client;
|
|
181
|
+
readonly id: string;
|
|
182
|
+
readonly info?: SessionInfo | undefined;
|
|
183
|
+
readonly network: Network;
|
|
184
|
+
private rpcWs?;
|
|
185
|
+
private rpcSeq;
|
|
186
|
+
private rpcPending;
|
|
187
|
+
constructor(client: SneakyAgent, id: string, info?: SessionInfo | undefined);
|
|
188
|
+
private p;
|
|
189
|
+
/** Open a persistent multiplexed WebSocket RPC channel to eliminate per-call HTTP overhead. */
|
|
190
|
+
connectRPC(): Promise<void>;
|
|
191
|
+
private callRPC;
|
|
192
|
+
private tryCallRPC;
|
|
193
|
+
private invoke;
|
|
194
|
+
goto(url: string, options?: {
|
|
195
|
+
waitUntil?: WaitUntil;
|
|
196
|
+
timeoutMs?: number;
|
|
197
|
+
returnSnapshot?: boolean;
|
|
198
|
+
snapshotMode?: SnapshotMode;
|
|
199
|
+
}): Promise<{
|
|
200
|
+
url: string;
|
|
201
|
+
title: string;
|
|
202
|
+
ready_state: string;
|
|
203
|
+
duration_ms: number;
|
|
204
|
+
snapshot?: SnapshotResult;
|
|
205
|
+
}>;
|
|
206
|
+
snapshot(options?: {
|
|
207
|
+
mode?: SnapshotMode;
|
|
208
|
+
source?: SnapshotSource;
|
|
209
|
+
diffFrom?: string;
|
|
210
|
+
maxNodes?: number;
|
|
211
|
+
maxChars?: number;
|
|
212
|
+
screenshot?: boolean;
|
|
213
|
+
}): Promise<SnapshotResult>;
|
|
214
|
+
act(actions: Action | Action[], options?: ActOptions): Promise<ActResult>;
|
|
215
|
+
click(target: TargetInput, options?: ActOptions): Promise<ActResult>;
|
|
216
|
+
fill(target: TargetInput, text: string, options?: ActOptions & {
|
|
217
|
+
clear?: boolean;
|
|
218
|
+
}): Promise<ActResult>;
|
|
219
|
+
press(key: string, options?: ActOptions): Promise<ActResult>;
|
|
220
|
+
locator(selector: string): Locator;
|
|
221
|
+
getByRole(role: string, options?: {
|
|
222
|
+
name?: string;
|
|
223
|
+
exact?: boolean;
|
|
224
|
+
}): Locator;
|
|
225
|
+
getByText(text: string, options?: {
|
|
226
|
+
exact?: boolean;
|
|
227
|
+
}): Locator;
|
|
228
|
+
extract(options?: {
|
|
229
|
+
kind?: ExtractKind;
|
|
230
|
+
target?: TargetInput;
|
|
231
|
+
maxChars?: number;
|
|
232
|
+
}): Promise<Record<string, unknown>>;
|
|
233
|
+
close(): Promise<void>;
|
|
234
|
+
}
|
|
235
|
+
export declare class Locator {
|
|
236
|
+
private readonly session;
|
|
237
|
+
private readonly target;
|
|
238
|
+
constructor(session: Session, target: Target);
|
|
239
|
+
first(): Locator;
|
|
240
|
+
last(): Locator;
|
|
241
|
+
nth(index: number): Locator;
|
|
242
|
+
click(options?: ActOptions): Promise<ActResult>;
|
|
243
|
+
fill(text: string, options?: ActOptions & {
|
|
244
|
+
clear?: boolean;
|
|
245
|
+
}): Promise<ActResult>;
|
|
246
|
+
}
|
|
247
|
+
export declare class Network {
|
|
248
|
+
private readonly client;
|
|
249
|
+
private readonly sessionId;
|
|
250
|
+
private readonly tryRPC?;
|
|
251
|
+
constructor(client: SneakyAgent, sessionId: string, tryRPC?: (<T>(method: string, params: unknown) => Promise<T> | undefined) | undefined);
|
|
252
|
+
private p;
|
|
253
|
+
capture(options?: {
|
|
254
|
+
enabled?: boolean;
|
|
255
|
+
resourceTypes?: string[];
|
|
256
|
+
urlContains?: string;
|
|
257
|
+
captureBodies?: boolean;
|
|
258
|
+
blockResourceTypes?: BlockResourceType[];
|
|
259
|
+
}): Promise<{
|
|
260
|
+
enabled: boolean;
|
|
261
|
+
blocked_urls?: number;
|
|
262
|
+
}>;
|
|
263
|
+
list(filter?: {
|
|
264
|
+
resourceType?: string;
|
|
265
|
+
method?: string;
|
|
266
|
+
urlContains?: string;
|
|
267
|
+
limit?: number;
|
|
268
|
+
}): Promise<{
|
|
269
|
+
enabled: boolean;
|
|
270
|
+
count: number;
|
|
271
|
+
requests: NetworkEntry[];
|
|
272
|
+
}>;
|
|
273
|
+
get(requestId: string): Promise<NetworkEntry>;
|
|
274
|
+
clear(): Promise<{
|
|
275
|
+
cleared: boolean;
|
|
276
|
+
}>;
|
|
277
|
+
}
|