@boxline/sdk 1.1.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.
@@ -0,0 +1,252 @@
1
+ import type { Boxline } from "./client.js";
2
+ import type { RequestOptions } from "./core.js";
3
+ import type { PagePromise, Page } from "./pagination.js";
4
+ import type { ActionItem, ActionResult, AgentProvider, CaptchaKind, ComputerAction, ComputerOptions, ComputerResult, DragTarget, ExecExit, ExecOptions, ExecResult, ExtractValue, FileList, FileRef, GotoResult, PageContent, PageElements, ProxyOption, Recording, RunScriptOptions, ScreenshotValue, ScriptResult, SessionData, SessionEvent, SessionEventsParams, SessionUrls, StepOptions, StepResult, TabList, UpdateSessionParams, VisitedPage, WaitUntil, ListParams, MouseButton, MoveTimings, Point } from "./types.js";
5
+ export interface ClickOptions {
6
+ button?: MouseButton;
7
+ /** 2 = double click, 3 = triple click. */
8
+ count?: 1 | 2 | 3;
9
+ /** Keys held during the click, e.g. ["Shift"]. */
10
+ modifiers?: string[];
11
+ }
12
+ /**
13
+ * One session: a machine with a browser and/or a shell and a shared /workspace disk. `data` is the session as the
14
+ * API last returned it; lifecycle calls (pause, update, extend, …) refresh it.
15
+ */
16
+ export declare class Session {
17
+ private readonly client;
18
+ data: SessionData;
19
+ constructor(client: Boxline, data: SessionData);
20
+ get id(): string;
21
+ get status(): import("./types.js").SessionStatus;
22
+ /** WebSocket URL for Playwright/Puppeteer `connectOverCDP`. Treat it like a password. */
23
+ get connectUrl(): string | null;
24
+ get liveUrl(): string | null;
25
+ get terminalUrl(): string | null;
26
+ get workspacePath(): string;
27
+ private set;
28
+ refresh(options?: RequestOptions): Promise<this>;
29
+ release(options?: RequestOptions): Promise<this>;
30
+ /** Saves browser state and files, frees the machine and stops billing. Connecting again resumes it. */
31
+ pause(options?: RequestOptions): Promise<this>;
32
+ resume(options?: RequestOptions): Promise<this>;
33
+ /**
34
+ * Makes the current connectUrl, liveUrl and terminalUrl stop working (use it if one leaked) and closes
35
+ * connections made with them; the session gets fresh URLs.
36
+ */
37
+ rotateUrls(options?: RequestOptions): Promise<this>;
38
+ /** Changes keepAlive, userMetadata, the proxy, the captcha option or the browser settings. */
39
+ update(patch: UpdateSessionParams, options?: RequestOptions): Promise<this>;
40
+ /** Sets, changes or (null) removes the session's proxy; new connections use it right away. */
41
+ setProxy(proxy: ProxyOption | null, options?: RequestOptions): Promise<this>;
42
+ /** A new IP for the session's proxy (sticky sessions keep one IP until this is called). */
43
+ rotateProxy(options?: RequestOptions): Promise<this>;
44
+ /** Adds time (60–3600 s), up to the plan's maximum session length. */
45
+ extend(seconds: number, options?: RequestOptions): Promise<this>;
46
+ /** Moves the live session to a fresh machine; reconnect to the same connectUrl afterwards. Returns the timings. */
47
+ move(options?: RequestOptions): Promise<MoveTimings>;
48
+ /** Fresh signed URLs (also stored on this object). */
49
+ live(options?: RequestOptions): Promise<SessionUrls>;
50
+ /**
51
+ * Waits until no CAPTCHA is waiting for a person (someone solved it in the live view, or the page moved on).
52
+ * Throws CaptchaTimeoutError after `timeoutMs` (default 5 minutes).
53
+ */
54
+ waitForHuman(opts?: {
55
+ timeoutMs?: number;
56
+ intervalMs?: number;
57
+ }): Promise<this>;
58
+ /**
59
+ * Calls `handler` when a CAPTCHA starts waiting for a person ("detected") and when it is gone ("cleared").
60
+ * Polls the session's events every `intervalMs` (default 2 s), starting after event number `after` (default 0:
61
+ * challenges seen before you subscribed are reported too). It stops by itself when the session ends; the
62
+ * returned function stops it sooner.
63
+ */
64
+ onCaptcha(handler: (e: {
65
+ state: "detected" | "cleared";
66
+ kind: CaptchaKind;
67
+ url: string;
68
+ event: SessionEvent;
69
+ }) => void | Promise<void>, opts?: {
70
+ intervalMs?: number;
71
+ after?: number;
72
+ }): () => void;
73
+ /** Console, network, navigation, error, lifecycle, action, exec and captcha events (oldest first). */
74
+ events(params?: SessionEventsParams, options?: RequestOptions): PagePromise<SessionEvent, Page<SessionEvent> & {
75
+ nextAfter: number;
76
+ }>;
77
+ /** Events as they happen (the backlog after `after` first). Stop with `break` or the signal. */
78
+ streamEvents(params?: {
79
+ after?: number;
80
+ }, options?: RequestOptions): AsyncGenerator<SessionEvent>;
81
+ /** Pages visited in this session. */
82
+ pages(params?: ListParams, options?: RequestOptions): PagePromise<VisitedPage>;
83
+ /** Replay frames (JPEG) kept while the session ran. */
84
+ recording(options?: RequestOptions): Promise<Recording>;
85
+ /** One replay frame as JPEG bytes. */
86
+ recordingFrame(index: number, options?: RequestOptions): Promise<Uint8Array>;
87
+ /** Runs actions next to the browser (one HTTP call for the whole list); a bare string is a plain-English step. */
88
+ actions(actions: ActionItem[] | ActionItem, opts?: {
89
+ timeoutMs?: number;
90
+ }, options?: RequestOptions): Promise<ActionResult[]>;
91
+ private one;
92
+ /**
93
+ * Runs one plain-English step ("click Sign in", "type %email% into the email field"). `secrets: ["NAME"]` lets it use
94
+ * project secrets as %NAME%, each on its own sites (see StepOptions).
95
+ */
96
+ step(instruction: string, opts?: StepOptions, options?: RequestOptions): Promise<StepResult>;
97
+ /** Structured data from the current page. */
98
+ extract<T = unknown>(instruction: string, opts?: {
99
+ schema?: Record<string, unknown>;
100
+ provider?: AgentProvider;
101
+ model?: string;
102
+ }, options?: RequestOptions): Promise<ExtractValue<T>>;
103
+ goto(url: string, opts?: {
104
+ waitUntil?: WaitUntil;
105
+ }, options?: RequestOptions): Promise<GotoResult>;
106
+ /** Clicks an element (CSS selector) or a point ({x, y}); `count: 2` double-clicks, `button: "right"` right-clicks. */
107
+ click(target: string | Point, opts?: ClickOptions, options?: RequestOptions): Promise<null>;
108
+ /** Moves the pointer over an element (CSS selector) or to a point. */
109
+ hover(target: string | Point, options?: RequestOptions): Promise<null>;
110
+ /** Where the pointer is on this tab (where the API last moved it; 0, 0 before any move). */
111
+ cursor(options?: RequestOptions): Promise<Point>;
112
+ fill(selector: string, value: string, options?: RequestOptions): Promise<null>;
113
+ /** Types text with the keyboard (into `selector` if given). */
114
+ type(text: string, opts?: {
115
+ selector?: string;
116
+ delayMs?: number;
117
+ }, options?: RequestOptions): Promise<null>;
118
+ press(key: string, options?: RequestOptions): Promise<null>;
119
+ /** Turns the wheel by `deltaY` pixels (and `deltaX`), over x/y when given. */
120
+ scroll(deltaY: number, at?: {
121
+ x?: number;
122
+ y?: number;
123
+ deltaX?: number;
124
+ modifiers?: string[];
125
+ }, options?: RequestOptions): Promise<null>;
126
+ /** Waits for a selector, or a number of milliseconds. */
127
+ wait(target: string | number, options?: RequestOptions): Promise<null>;
128
+ /** Picks an option of a select element by its label or value. */
129
+ select(selector: string, option: string, options?: RequestOptions): Promise<null>;
130
+ /** The page as a model sees it: title, URL, visible text and numbered interactive elements. */
131
+ elements(options?: RequestOptions): Promise<PageElements>;
132
+ evaluate<T = unknown>(expression: string, options?: RequestOptions): Promise<T>;
133
+ content(format?: "markdown" | "html" | "text", options?: RequestOptions): Promise<PageContent>;
134
+ /**
135
+ * A screenshot of the current tab: `{data (base64), mimeType}`. `maxWidth` scales it down and `cursor` draws the
136
+ * pointer (then also `width`, `height`, `scale`).
137
+ */
138
+ screenshot(opts?: {
139
+ fullPage?: boolean;
140
+ format?: "png" | "jpeg";
141
+ quality?: number;
142
+ maxWidth?: number;
143
+ cursor?: boolean;
144
+ }, options?: RequestOptions): Promise<ScreenshotValue>;
145
+ /** Sets a file input to a file in the workspace (e.g. one written with files.write). */
146
+ upload(selector: string, path: string, options?: RequestOptions): Promise<null>;
147
+ tabs(options?: RequestOptions): Promise<TabList>;
148
+ newTab(url?: string, options?: RequestOptions): Promise<{
149
+ index: number;
150
+ }>;
151
+ switchTab(index: number, options?: RequestOptions): Promise<null>;
152
+ closeTab(index?: number, options?: RequestOptions): Promise<null>;
153
+ back(options?: RequestOptions): Promise<{
154
+ url: string;
155
+ }>;
156
+ forward(options?: RequestOptions): Promise<{
157
+ url: string;
158
+ }>;
159
+ reload(options?: RequestOptions): Promise<{
160
+ url: string;
161
+ }>;
162
+ /**
163
+ * The mouse, in viewport CSS pixels (the session's viewport, 1280×720 by default). Straight lines only: `steps`
164
+ * spreads a move over that many evenly spaced points. It acts on the page, never on the machine's desktop.
165
+ */
166
+ readonly mouse: {
167
+ move: (x: number, y: number, opts?: {
168
+ steps?: number;
169
+ }, options?: RequestOptions) => Promise<Point>;
170
+ /** Moves by dx/dy from where the pointer is. */
171
+ moveBy: (dx: number, dy: number, opts?: {
172
+ steps?: number;
173
+ }, options?: RequestOptions) => Promise<Point>;
174
+ click: (x: number, y: number, opts?: ClickOptions, options?: RequestOptions) => Promise<null>;
175
+ down: (opts?: {
176
+ button?: MouseButton;
177
+ }, options?: RequestOptions) => Promise<null>;
178
+ up: (opts?: {
179
+ button?: MouseButton;
180
+ }, options?: RequestOptions) => Promise<null>;
181
+ /**
182
+ * Presses at `from`, moves to `to` (in `steps` points, default 10) and releases; each end is a point or a selector.
183
+ * Or pass a path of 2–200 points to follow.
184
+ */
185
+ drag: (fromOrPath: DragTarget | Point[], to?: DragTarget | DragOptions, opts?: DragOptions, options?: RequestOptions) => Promise<{
186
+ from: Point;
187
+ to: Point;
188
+ }>;
189
+ };
190
+ /** The keyboard. Key names are Playwright's (Enter, Tab, ArrowLeft, Control, Shift, Meta…); ctrl, cmd, Return work too. */
191
+ readonly keyboard: {
192
+ /** A combination held together, "Control+A" or ["Control", "A"]; several separated by spaces run one after the other. */
193
+ key: (keys: string | string[], opts?: {
194
+ holdMs?: number;
195
+ }, options?: RequestOptions) => Promise<null>;
196
+ type: (text: string, opts?: {
197
+ delayMs?: number;
198
+ }, options?: RequestOptions) => Promise<null>;
199
+ press: (key: string, options?: RequestOptions) => Promise<null>;
200
+ };
201
+ /**
202
+ * Runs ONE computer-use action as the model's tool gave it (Anthropic `computer` input, or one OpenAI
203
+ * `computer_call` action) and returns the screen after it (see Sessions.computer).
204
+ */
205
+ computer(action: ComputerAction, opts?: ComputerOptions, options?: RequestOptions): Promise<ComputerResult>;
206
+ /** Writes the browser's cookies as a Netscape cookie file inside the workspace, for curl -b / wget. */
207
+ exportCookies(path?: string, options?: RequestOptions): Promise<{
208
+ path: string;
209
+ count: number;
210
+ }>;
211
+ /** @deprecated Use session.exportCookies(). */
212
+ readonly browser: {
213
+ exportCookies: (path?: string, options?: RequestOptions) => Promise<{
214
+ path: string;
215
+ count: number;
216
+ }>;
217
+ };
218
+ /** Runs a shell command (persistent bash by default: cd/export survive between calls). */
219
+ exec(command: string, opts?: ExecOptions, options?: RequestOptions): Promise<ExecResult>;
220
+ /** Runs a command and streams its output. Aborting `signal` stops the command. */
221
+ execStream(command: string, onData: (stream: "stdout" | "stderr", data: string) => void, opts?: ExecOptions & {
222
+ signal?: AbortSignal;
223
+ }, options?: RequestOptions): Promise<ExecExit>;
224
+ /**
225
+ * Runs Playwright code inside the session (needs a shell). `page`, `context`, `browser`, `env`, and the AI helpers
226
+ * `step()`, `extract()` and `useModel(model)` / `useModel(provider, model)` are in scope; top-level await works. A
227
+ * step or extract uses the call's own `{provider, model}`, else the last `useModel()`, else `ai`, else the default.
228
+ */
229
+ runScript(code: string, opts?: RunScriptOptions, options?: RequestOptions): Promise<ScriptResult>;
230
+ /** Restarts the persistent shell (or the named one). */
231
+ restartShell(name?: string, options?: RequestOptions): Promise<void>;
232
+ /** @deprecated Use session.restartShell(). */
233
+ readonly shell: {
234
+ restart: (name?: string, options?: RequestOptions) => Promise<void>;
235
+ };
236
+ readonly files: {
237
+ list: (path?: string, options?: RequestOptions) => Promise<FileList>;
238
+ read: (path: string, options?: RequestOptions) => Promise<Uint8Array>;
239
+ readText: (path: string, options?: RequestOptions) => Promise<string>;
240
+ write: (path: string, data: string | Uint8Array | Blob, options?: RequestOptions) => Promise<FileRef>;
241
+ delete: (path: string, options?: RequestOptions) => Promise<void>;
242
+ /** Waits for a file matching a glob (e.g. `downloads/*.csv`) that has finished writing. */
243
+ waitFor: (pattern: string, timeoutMs?: number, options?: RequestOptions) => Promise<FileRef>;
244
+ };
245
+ toJSON(): SessionData;
246
+ }
247
+ export interface DragOptions {
248
+ /** Points per move (from/to: default 10; a path: per segment, default 1). */
249
+ steps?: number;
250
+ button?: MouseButton;
251
+ modifiers?: string[];
252
+ }
@@ -0,0 +1,345 @@
1
+ import { CaptchaTimeoutError, makeError } from "./errors.js";
2
+ /** HTTP status an action result's code stands for, when one action of a list fails (the call itself answered 200). */
3
+ const ACTION_STATUS = { captcha_timeout: 409, model_refused: 422 };
4
+ /**
5
+ * One session: a machine with a browser and/or a shell and a shared /workspace disk. `data` is the session as the
6
+ * API last returned it; lifecycle calls (pause, update, extend, …) refresh it.
7
+ */
8
+ export class Session {
9
+ data;
10
+ constructor(client, data) {
11
+ // Not enumerable: logging a session shows its data, never the client (and its API key).
12
+ Object.defineProperty(this, "client", { value: client, enumerable: false });
13
+ this.data = data;
14
+ }
15
+ get id() {
16
+ return this.data.id;
17
+ }
18
+ get status() {
19
+ return this.data.status;
20
+ }
21
+ /** WebSocket URL for Playwright/Puppeteer `connectOverCDP`. Treat it like a password. */
22
+ get connectUrl() {
23
+ return this.data.connectUrl;
24
+ }
25
+ get liveUrl() {
26
+ return this.data.liveUrl;
27
+ }
28
+ get terminalUrl() {
29
+ return this.data.terminalUrl;
30
+ }
31
+ get workspacePath() {
32
+ return this.data.workspacePath;
33
+ }
34
+ set(s) {
35
+ this.data = s.data;
36
+ return this;
37
+ }
38
+ // ----- lifecycle
39
+ async refresh(options) {
40
+ return this.set(await this.client.sessions.get(this.id, options));
41
+ }
42
+ async release(options) {
43
+ return this.set(await this.client.sessions.release(this.id, options));
44
+ }
45
+ /** Saves browser state and files, frees the machine and stops billing. Connecting again resumes it. */
46
+ async pause(options) {
47
+ return this.set(await this.client.sessions.pause(this.id, options));
48
+ }
49
+ async resume(options) {
50
+ return this.set(await this.client.sessions.resume(this.id, options));
51
+ }
52
+ /**
53
+ * Makes the current connectUrl, liveUrl and terminalUrl stop working (use it if one leaked) and closes
54
+ * connections made with them; the session gets fresh URLs.
55
+ */
56
+ async rotateUrls(options) {
57
+ return this.set(await this.client.sessions.rotateUrls(this.id, options));
58
+ }
59
+ /** Changes keepAlive, userMetadata, the proxy, the captcha option or the browser settings. */
60
+ async update(patch, options) {
61
+ return this.set(await this.client.sessions.update(this.id, patch, options));
62
+ }
63
+ /** Sets, changes or (null) removes the session's proxy; new connections use it right away. */
64
+ async setProxy(proxy, options) {
65
+ return this.update({ proxy }, options);
66
+ }
67
+ /** A new IP for the session's proxy (sticky sessions keep one IP until this is called). */
68
+ async rotateProxy(options) {
69
+ return this.set(await this.client.sessions.rotateProxy(this.id, options));
70
+ }
71
+ /** Adds time (60–3600 s), up to the plan's maximum session length. */
72
+ async extend(seconds, options) {
73
+ return this.set(await this.client.sessions.extend(this.id, seconds, options));
74
+ }
75
+ /** Moves the live session to a fresh machine; reconnect to the same connectUrl afterwards. Returns the timings. */
76
+ async move(options) {
77
+ const r = await this.client.sessions.move(this.id, options);
78
+ this.data = r.session.data;
79
+ return r.timings;
80
+ }
81
+ /** Fresh signed URLs (also stored on this object). */
82
+ async live(options) {
83
+ const urls = await this.client.sessions.live(this.id, options);
84
+ this.data = { ...this.data, ...urls };
85
+ return urls;
86
+ }
87
+ /**
88
+ * Waits until no CAPTCHA is waiting for a person (someone solved it in the live view, or the page moved on).
89
+ * Throws CaptchaTimeoutError after `timeoutMs` (default 5 minutes).
90
+ */
91
+ async waitForHuman(opts = {}) {
92
+ const deadline = Date.now() + (opts.timeoutMs ?? 300_000);
93
+ for (;;) {
94
+ await this.refresh();
95
+ const a = this.data.attention;
96
+ if (!a || this.data.status !== "RUNNING")
97
+ return this;
98
+ if (Date.now() > deadline)
99
+ throw new CaptchaTimeoutError(408, "captcha_timeout", `nobody solved the CAPTCHA on ${a.url} in time`);
100
+ await new Promise((r) => setTimeout(r, opts.intervalMs ?? 1000));
101
+ }
102
+ }
103
+ /**
104
+ * Calls `handler` when a CAPTCHA starts waiting for a person ("detected") and when it is gone ("cleared").
105
+ * Polls the session's events every `intervalMs` (default 2 s), starting after event number `after` (default 0:
106
+ * challenges seen before you subscribed are reported too). It stops by itself when the session ends; the
107
+ * returned function stops it sooner.
108
+ */
109
+ onCaptcha(handler, opts = {}) {
110
+ let stopped = false;
111
+ void (async () => {
112
+ let after = opts.after ?? 0;
113
+ for (let round = 1; !stopped; round++) {
114
+ try {
115
+ const page = await this.events({ types: ["captcha"], after });
116
+ for (const event of page.data) {
117
+ if (stopped)
118
+ return;
119
+ const d = (event.data ?? {});
120
+ if ((d.state === "detected" || d.state === "cleared") && d.kind)
121
+ await handler({ state: d.state, kind: d.kind, url: event.url ?? "", event });
122
+ }
123
+ after = page.nextAfter;
124
+ if (round % 5 === 0)
125
+ await this.refresh(); // stop by itself once the session has ended
126
+ if (this.data.status === "COMPLETED" || this.data.status === "ERROR")
127
+ return;
128
+ }
129
+ catch {
130
+ /* keep polling; the session may be moving */
131
+ }
132
+ await new Promise((r) => setTimeout(r, opts.intervalMs ?? 2000));
133
+ }
134
+ })();
135
+ return () => {
136
+ stopped = true;
137
+ };
138
+ }
139
+ // ----- logs and recording
140
+ /** Console, network, navigation, error, lifecycle, action, exec and captcha events (oldest first). */
141
+ events(params = {}, options) {
142
+ return this.client.sessions.events(this.id, params, options);
143
+ }
144
+ /** Events as they happen (the backlog after `after` first). Stop with `break` or the signal. */
145
+ streamEvents(params = {}, options) {
146
+ return this.client.sessions.streamEvents(this.id, params, options);
147
+ }
148
+ /** Pages visited in this session. */
149
+ pages(params = {}, options) {
150
+ return this.client.sessions.pages(this.id, params, options);
151
+ }
152
+ /** Replay frames (JPEG) kept while the session ran. */
153
+ recording(options) {
154
+ return this.client.sessions.recording(this.id, options);
155
+ }
156
+ /** One replay frame as JPEG bytes. */
157
+ recordingFrame(index, options) {
158
+ return this.client.sessions.recordingFrame(this.id, index, options);
159
+ }
160
+ // ----- browser
161
+ /** Runs actions next to the browser (one HTTP call for the whole list); a bare string is a plain-English step. */
162
+ actions(actions, opts = {}, options) {
163
+ return this.client.sessions.actions(this.id, actions, opts, options);
164
+ }
165
+ async one(action, options) {
166
+ const [r] = await this.actions(action, {}, options);
167
+ if (!r?.ok) {
168
+ const code = r?.code ?? "action_failed";
169
+ throw makeError(ACTION_STATUS[code] ?? 400, code, r?.error ?? "action failed");
170
+ }
171
+ return r.value;
172
+ }
173
+ /**
174
+ * Runs one plain-English step ("click Sign in", "type %email% into the email field"). `secrets: ["NAME"]` lets it use
175
+ * project secrets as %NAME%, each on its own sites (see StepOptions).
176
+ */
177
+ step(instruction, opts = {}, options) {
178
+ return this.one({ action: "step", instruction, ...opts }, options);
179
+ }
180
+ /** Structured data from the current page. */
181
+ extract(instruction, opts = {}, options) {
182
+ return this.one({ action: "extract", instruction, ...opts }, options);
183
+ }
184
+ goto(url, opts = {}, options) {
185
+ return this.one({ action: "goto", url, ...opts }, options);
186
+ }
187
+ /** Clicks an element (CSS selector) or a point ({x, y}); `count: 2` double-clicks, `button: "right"` right-clicks. */
188
+ click(target, opts = {}, options) {
189
+ return this.one(typeof target === "string" ? { action: "click", selector: target, ...opts } : { action: "click", x: target.x, y: target.y, ...opts }, options);
190
+ }
191
+ /** Moves the pointer over an element (CSS selector) or to a point. */
192
+ hover(target, options) {
193
+ return this.one(typeof target === "string" ? { action: "hover", selector: target } : { action: "hover", x: target.x, y: target.y }, options);
194
+ }
195
+ /** Where the pointer is on this tab (where the API last moved it; 0, 0 before any move). */
196
+ cursor(options) {
197
+ return this.one({ action: "cursor" }, options);
198
+ }
199
+ fill(selector, value, options) {
200
+ return this.one({ action: "fill", selector, value }, options);
201
+ }
202
+ /** Types text with the keyboard (into `selector` if given). */
203
+ type(text, opts = {}, options) {
204
+ return this.one({ action: "type", text, ...opts }, options);
205
+ }
206
+ press(key, options) {
207
+ return this.one({ action: "press", key }, options);
208
+ }
209
+ /** Turns the wheel by `deltaY` pixels (and `deltaX`), over x/y when given. */
210
+ scroll(deltaY, at = {}, options) {
211
+ return this.one({ action: "scroll", deltaY, ...at }, options);
212
+ }
213
+ /** Waits for a selector, or a number of milliseconds. */
214
+ wait(target, options) {
215
+ return this.one(typeof target === "number" ? { action: "wait", ms: target } : { action: "wait", selector: target }, options);
216
+ }
217
+ /** Picks an option of a select element by its label or value. */
218
+ select(selector, option, options) {
219
+ return this.one({ action: "select", selector, option }, options);
220
+ }
221
+ /** The page as a model sees it: title, URL, visible text and numbered interactive elements. */
222
+ elements(options) {
223
+ return this.one({ action: "elements" }, options);
224
+ }
225
+ evaluate(expression, options) {
226
+ return this.one({ action: "evaluate", expression }, options);
227
+ }
228
+ content(format = "markdown", options) {
229
+ return this.one({ action: "content", format }, options);
230
+ }
231
+ /**
232
+ * A screenshot of the current tab: `{data (base64), mimeType}`. `maxWidth` scales it down and `cursor` draws the
233
+ * pointer (then also `width`, `height`, `scale`).
234
+ */
235
+ screenshot(opts = {}, options) {
236
+ return this.one({ action: "screenshot", ...opts }, options);
237
+ }
238
+ /** Sets a file input to a file in the workspace (e.g. one written with files.write). */
239
+ upload(selector, path, options) {
240
+ return this.one({ action: "upload", selector, path }, options);
241
+ }
242
+ tabs(options) {
243
+ return this.one({ action: "tabs" }, options);
244
+ }
245
+ newTab(url, options) {
246
+ return this.one({ action: "newTab", url }, options);
247
+ }
248
+ switchTab(index, options) {
249
+ return this.one({ action: "switchTab", index }, options);
250
+ }
251
+ closeTab(index, options) {
252
+ return this.one({ action: "closeTab", index }, options);
253
+ }
254
+ back(options) {
255
+ return this.one({ action: "back" }, options);
256
+ }
257
+ forward(options) {
258
+ return this.one({ action: "forward" }, options);
259
+ }
260
+ reload(options) {
261
+ return this.one({ action: "reload" }, options);
262
+ }
263
+ /**
264
+ * The mouse, in viewport CSS pixels (the session's viewport, 1280×720 by default). Straight lines only: `steps`
265
+ * spreads a move over that many evenly spaced points. It acts on the page, never on the machine's desktop.
266
+ */
267
+ mouse = {
268
+ move: (x, y, opts = {}, options) => this.one({ action: "move", x, y, ...opts }, options),
269
+ /** Moves by dx/dy from where the pointer is. */
270
+ moveBy: (dx, dy, opts = {}, options) => this.one({ action: "move", dx, dy, ...opts }, options),
271
+ click: (x, y, opts = {}, options) => this.one({ action: "click", x, y, ...opts }, options),
272
+ down: (opts = {}, options) => this.one({ action: "mouse_down", ...opts }, options),
273
+ up: (opts = {}, options) => this.one({ action: "mouse_up", ...opts }, options),
274
+ /**
275
+ * Presses at `from`, moves to `to` (in `steps` points, default 10) and releases; each end is a point or a selector.
276
+ * Or pass a path of 2–200 points to follow.
277
+ */
278
+ drag: (fromOrPath, to, opts = {}, options) => {
279
+ if (Array.isArray(fromOrPath))
280
+ return this.one({ action: "drag", path: fromOrPath, ...(to ?? {}) }, options);
281
+ return this.one({ action: "drag", from: fromOrPath, to: to, ...opts }, options);
282
+ },
283
+ };
284
+ /** The keyboard. Key names are Playwright's (Enter, Tab, ArrowLeft, Control, Shift, Meta…); ctrl, cmd, Return work too. */
285
+ keyboard = {
286
+ /** A combination held together, "Control+A" or ["Control", "A"]; several separated by spaces run one after the other. */
287
+ key: (keys, opts = {}, options) => this.one({ action: "key", keys, ...opts }, options),
288
+ type: (text, opts = {}, options) => this.one({ action: "type", text, ...opts }, options),
289
+ press: (key, options) => this.one({ action: "press", key }, options),
290
+ };
291
+ /**
292
+ * Runs ONE computer-use action as the model's tool gave it (Anthropic `computer` input, or one OpenAI
293
+ * `computer_call` action) and returns the screen after it (see Sessions.computer).
294
+ */
295
+ computer(action, opts = {}, options) {
296
+ return this.client.sessions.computer(this.id, action, opts, options);
297
+ }
298
+ /** Writes the browser's cookies as a Netscape cookie file inside the workspace, for curl -b / wget. */
299
+ exportCookies(path, options) {
300
+ return this.client.sessions.exportCookies(this.id, path, options);
301
+ }
302
+ /** @deprecated Use session.exportCookies(). */
303
+ browser = {
304
+ exportCookies: (path, options) => this.exportCookies(path, options),
305
+ };
306
+ // ----- shell
307
+ /** Runs a shell command (persistent bash by default: cd/export survive between calls). */
308
+ exec(command, opts = {}, options) {
309
+ return this.client.sessions.exec(this.id, command, opts, options);
310
+ }
311
+ /** Runs a command and streams its output. Aborting `signal` stops the command. */
312
+ execStream(command, onData, opts = {}, options) {
313
+ return this.client.sessions.execStream(this.id, command, onData, opts, options);
314
+ }
315
+ /**
316
+ * Runs Playwright code inside the session (needs a shell). `page`, `context`, `browser`, `env`, and the AI helpers
317
+ * `step()`, `extract()` and `useModel(model)` / `useModel(provider, model)` are in scope; top-level await works. A
318
+ * step or extract uses the call's own `{provider, model}`, else the last `useModel()`, else `ai`, else the default.
319
+ */
320
+ runScript(code, opts = {}, options) {
321
+ return this.client.sessions.runScript(this.id, code, opts, options);
322
+ }
323
+ /** Restarts the persistent shell (or the named one). */
324
+ restartShell(name, options) {
325
+ return this.client.sessions.restartShell(this.id, name, options);
326
+ }
327
+ /** @deprecated Use session.restartShell(). */
328
+ shell = {
329
+ restart: (name, options) => this.restartShell(name, options),
330
+ };
331
+ // ----- files in /workspace
332
+ files = {
333
+ list: (path = ".", options) => this.client.sessions.files.list(this.id, path, options),
334
+ read: (path, options) => this.client.sessions.files.read(this.id, path, options),
335
+ readText: (path, options) => this.client.sessions.files.readText(this.id, path, options),
336
+ write: (path, data, options) => this.client.sessions.files.write(this.id, path, data, options),
337
+ delete: (path, options) => this.client.sessions.files.delete(this.id, path, options),
338
+ /** Waits for a file matching a glob (e.g. `downloads/*.csv`) that has finished writing. */
339
+ waitFor: (pattern, timeoutMs = 30_000, options) => this.client.sessions.files.waitFor(this.id, pattern, timeoutMs, options),
340
+ };
341
+ toJSON() {
342
+ return this.data;
343
+ }
344
+ }
345
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA0C7D,sHAAsH;AACtH,MAAM,aAAa,GAA2B,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC;AAU3F;;;GAGG;AACH,MAAM,OAAO,OAAO;IAEX,IAAI,CAAc;IAEzB,YAAY,MAAe,EAAE,IAAiB;QAC5C,wFAAwF;QACxF,M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wB,EAAoB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;KACvK,CAAC;IAEF,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ /** Readers for the API's streamed replies: NDJSON (exec, scripts) and server-sent events (event streams). */
2
+ /** Lines of a response body; leaving early (break, return) closes the connection. */
3
+ export declare function lines(body: ReadableStream<Uint8Array>): AsyncGenerator<string>;
4
+ /** One JSON value per non-empty line (lines that are not JSON are skipped). */
5
+ export declare function ndjson<T = Record<string, unknown>>(body: ReadableStream<Uint8Array>): AsyncGenerator<T>;
6
+ /** The `data:` of each server-sent event, parsed as JSON (comments such as keep-alive pings are skipped). */
7
+ export declare function sse<T = Record<string, unknown>>(body: ReadableStream<Uint8Array>): AsyncGenerator<T>;